Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BBSDataContext lq   = new BBSDataContext();
            BBSNote        note = new BBSNote();

            note.bnSubject = txtbnSubject.Text;
            note.bnContent = txtbnContent.Text;
            note.bnID      = Convert.ToInt16(Session["uID"].ToString());
            note.bnAddTime = System.DateTime.Now;
            lq.BBSNote.InsertOnSubmit(note);
            lq.SubmitChanges();
            Response.Redirect("BBSNoteList.aspx");
        }
Esempio n. 2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            BBSDataContext lq   = new BBSDataContext(); //实例化LINQ类
            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?id=" + Request["id"]); //重新定位到该页面
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            BBSDataContext lq = new BBSDataContext();
            BBSAnswer      ba = new BBSAnswer();

            ba.uID       = Convert.ToInt16(Session["uID"]);
            ba.bnID      = Convert.ToInt16(Request["id"]);
            ba.baContent = txtbaContent.Text;
            ba.baAddTime = System.DateTime.Now;
            lq.BBSAnswer.InsertOnSubmit(ba);
            lq.SubmitChanges();
            Response.Redirect("BBSAnswerList.aspx?id=" + Request["id"]);
        }
Esempio n. 4
0
        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);
        }