protected void Button1_Click(object sender, EventArgs e) { BBSDataContext lq = new BBSDataContext(); BBSNote note = new BBSNote(); note.bnSubject = txtbnSubject.Text; note.bnContent = txtbnContent.Text; note.uID = Convert.ToInt32(Session["uID"]); note.bnAddTime = System.DateTime.Now; lq.BBSNote.InsertOnSubmit(note); lq.SubmitChanges(); Response.Redirect("BBSNoteList.aspx"); }
protected void btnSave_Click(object sender, EventArgs e) { BBSDataContext lq = new BBSDataContext(); BBSAnswer ba = new BBSAnswer(); ba.uID = Convert.ToInt32(Session["uID"]); ba.bnID = Convert.ToInt32(Request["id"]); ba.baContent = txtbaContent.Text; ba.baAddTime = System.DateTime.Now; lq.BBSAnswer.InsertOnSubmit(ba); lq.SubmitChanges(); Response.Redirect("BBSAnswerList.aspx?id=" + Request["id"]); }
/// <summary> /// 获取会员ID /// </summary> /// <param name="uName">用户名</param> /// <param name="uPwd">密码</param> /// <returns>如果返回的id值为0,说明输入的用户名和密码不正确,否则返回用户名和密码对应的uID字段的值</returns> protected int getUserIdByName(string name, string pwd) { int id = 0; BBSDataContext lq = new BBSDataContext(); var users = from gt in lq.Users where gt.uName == name && gt.uPwd == pwd select gt; foreach (Users user in users) { id = user.uID; } return(id); }