protected void Page_Load(object sender, EventArgs e) { if (Session["_userid"] == null) { Common.MessageAlert.AlertLocation(Page, "alert('对不起,您没有登陆!');location.href='Login.aspx'"); } else { Label1.Text=Session["_username"].ToString(); Model.user mol = new Model.user (); mol.userid = Convert.ToInt32(Session["_userid"]); BLL.userBLL bls = new BLL.userBLL(); MySqlDataReader dr = bls.drti(mol); if (dr.Read()) { Label2.Text = dr["_logintime"].ToString(); } DateTime dt = DateTime.Now; Model.user mod = new Model.user(); mod.userid = Convert.ToInt32(Session["_userid"]); mod.time = dt; BLL.userBLL blur = new BLL.userBLL(); int i = blur.update(mod); } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { string email = Server.HtmlEncode(TextBox3.Text); string pwd = Server.HtmlEncode(TextBox4.Text); Model.user mod = new Model.user(); mod.email = email; mod.pwd = pwd; BLL.userBLL bll = new BLL.userBLL(); MySqlDataReader dr = bll.login(mod); //ds.Tables[0].Rows[0]["_userid"]; if (CheckBox1.Checked) { MySqlDataReader dr1 = bll.lo(mod); if (dr1.Read()) { Session["_username"] = dr1["_username"].ToString(); Session["_userid"]=dr1["_userid"].ToString(); dr1.Close(); } dr1.Close(); } else { Session["_username"] = ""; } if (Session["CheckCode"] != null) { if (TextBox1.Text.ToLower() == Session["CheckCode"].ToString().ToLower()) { if (dr.Read()) { Response.Redirect("ACIndex.aspx"); Model.user mol = new Model.user(); mol.userid = Convert.ToInt32(Session["_userid"]); BLL.userBLL bllu = new BLL.userBLL(); int r = bllu.update(mol); MySqlDataReader dr2 = bll.lo(mod); if (dr2.Read()) { Session["_username"] = dr2["_username"].ToString(); Session["_userid"] = dr2["_userid"].ToString(); dr2.Close(); } dr2.Close(); } else { Common.MessageAlert.Alert(Page, "登入失败!"); } } else { Common.MessageAlert.Alert(Page, "验证码错误!"); } } }