首页 新闻 会员 周边 捐助

关于LINQ TO sql 多表更新的问题

0
悬赏园豆:5 [待解决问题]

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();
}
}
}

折羽青鸟-fly的主页 折羽青鸟-fly | 初学一级 | 园豆:199
提问于:2014-04-03 10:39
< >
分享
所有回答(2)
0

问题是什么?

seaconch | 园豆:4823 (老鸟四级) | 2014-04-04 14:56
0

抱歉 这个问题后来自己已解决了

折羽青鸟-fly | 园豆:199 (初学一级) | 2014-04-04 15:00
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册