protected void Session_End(object sender, EventArgs e) { currentNumberOfUsers -= 1; if (Session["userID"] != null) { tbl_AccountLog ne = new tbl_AccountLog(); ne.UserID = int.Parse(Session["userID"].ToString()); ne.Date = DateTime.Now; ne.Type = "Log out"; db.tbl_AccountLogs.InsertOnSubmit(ne); db.SubmitChanges(); } }
protected void lnkbtnLogout_Click(object sender, EventArgs e) { if (Session["userID"] != null) { tbl_AccountLog ne = new tbl_AccountLog(); ne.UserID = int.Parse(Session["userID"].ToString()); ne.Date = DateTime.Now; ne.Type = "Log out"; db.tbl_AccountLogs.InsertOnSubmit(ne); db.SubmitChanges(); } Session["userID"] = null; Response.Cookies["userID"].Expires = DateTime.Now.AddDays(-1); Response.Redirect("Default.aspx"); }
protected void Session_Start(object sender, EventArgs e) { int b = int.Parse(Application["hit"].ToString()); totalNumberOfUsers += 1; b++; Application["hit"] = b; currentNumberOfUsers += 1; Session.Timeout = 90; if (Request.Cookies["userID"] != null) { tbl_AccountLog ne = new tbl_AccountLog(); int a = int.Parse(Request.Cookies["userID"].Value.ToString()); ne.UserID = a; ne.Date = DateTime.Now; ne.Type = "Log in"; db.tbl_AccountLogs.InsertOnSubmit(ne); db.SubmitChanges(); } }
partial void Deletetbl_AccountLog(tbl_AccountLog instance);
partial void Updatetbl_AccountLog(tbl_AccountLog instance);
partial void Inserttbl_AccountLog(tbl_AccountLog instance);
protected void btn_Login_Click(object sender, EventArgs e) { if (txbox_password.Text == "" || txbox_Username.Text == "") { lbl_Intro.Text = "Please Fill The Empty Places!"; return; } var item = from x in db.tbl_users where x.UserName == txbox_Username.Text select x; int us = 0; foreach (var u in item) { us = 1; if (u.Password != txbox_password.Text) { lbl_Intro.Text = "You entered wrong password, Please try again!"; return; } } if (us == 0) { lbl_Intro.Text = "There is not such a username, Please click register button to register!"; return; } foreach (var u in item) { Session["userID"] = u.UserID; if (Session["userID"] != null) { tbl_AccountLog ne = new tbl_AccountLog(); ne.UserID = int.Parse(Session["userID"].ToString()); ne.Date = DateTime.Now; ne.Type = "Log in"; db.tbl_AccountLogs.InsertOnSubmit(ne); db.SubmitChanges(); } if (checkbox_rememberMe.Checked) { Response.Cookies["userID"].Value = u.UserID.ToString(); Response.Cookies["userID"].Expires = DateTime.Now.AddDays(30); } if (u.Type == 1 || u.Type == 3) { Response.Redirect("Default.aspx"); } else if (u.Type == 0) { Response.Redirect("DefaultAdmin.aspx"); } else { Response.Redirect("DefaultSupporter.aspx"); } } }