namespace Membermanger
{
public partial class Memremod : System.Web.UI.Page
{
MemdbDataContext db = new MemdbDataContext();
void showData()
{
var res = from r in db.Mrecharge
orderby r.Mrid
select new
{
r.Mrid,
会员卡号 = r.Mrvipid,
充值时间 = r.Mrtime,
充值金额 = r.Mrmoney,
操作员 = r.Mruserid
};
gvR.DataSource = res;
gvR.DataBind();
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) showData();
}
protected void btnS_Click(object sender, EventArgs e)
{
if (txtRd.Text.Trim().Length == 0)
Response.Write("<Script>alter('会员卡不能为空值!');</Script>");
if (txtM.Text.Trim().Length == 0)
Response.Write("<Script>alter('充值金额不能为空值!');</Script>");
if (txtRt.Text.Trim().Length == 0)
Response.Write("<Script>alter('充值时间不能为空值!');</Script>");
if (txtU.Text.Trim().Length == 0)
Response.Write("<Script>alter('操作员ID不能为空值!');</Script>");
var res = from r in db.Mrecharge where r.Mrid.ToString() == lblR.Text select r;
var rec = res.First();
rec.Mrvipid = txtRd.Text;
rec.Mrtime =Convert.ToDateTime(txtRt.Text);
rec.Mrmoney = Convert.ToDouble(txtM.Text);
rec.Mruserid = txtU.Text;
db.SubmitChanges();
showData();
int ssid = Convert.ToInt32(txtRd.Text.Trim());
var qus = from p in db.Mvipcard
//join q in db.Mrecharge
//on p.Mvipid equals q.Mrvipid
where p.Mvipid == ssid.ToString()
select p;
var qq = qus.First();
qq.Mvipbal +=Convert.ToDouble(txtM.Text.Trim()) ;
db.SubmitChanges();
}
protected void gvR_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
gvR.PageIndex = e.NewSelectedIndex;
showData();
}
protected void gvR_SelectedIndexChanged(object sender, EventArgs e)
{
String Mrech = gvR.SelectedValue.ToString();
var res = from r in db.Mrecharge where r.Mrid.ToString () == Mrech select r;
var rec=res.First();
lblR.Text = rec.Mrid.ToString ();
txtRd.Text = rec.Mrvipid.ToString();
txtRt.Text = rec.Mrtime.ToString();
txtM.Text = rec.Mrmoney.ToString();
txtU.Text = rec.Mruserid.ToString();
}
}
}
问题是什么?
抱歉 这个问题后来自己已解决了