//Admin login implementation protected void btnlogin_Click(object sender, EventArgs e) { try { if (chkremeber.Checked) //set Cookies for 90 days { Response.Cookies["UserNamecookie"].Expires = DateTime.Now.AddDays(90); Response.Cookies["passwordcoookie"].Expires = DateTime.Now.AddDays(90); } else {// else - expire the cookies Response.Cookies["UserNamecookie"].Expires = DateTime.Now.AddDays(-1); Response.Cookies["passwordcoookie"].Expires = DateTime.Now.AddDays(-1); } //create cookies Response.Cookies["UserNamecookie"].Value = txtusername.Text.Trim(); Response.Cookies["passwordcoookie"].Value = txtpassword.Text.Trim(); string username, password; username = txtusername.Text.Trim(); password = txtpassword.Text.Trim(); if (Checks.Empty(username) && Checks.Empty(password)) { lblmsg.Text = "*Please fill all fields!!"; } else if (Checks.Empty(username)) { lblmsg.Text = "*Please Enter Username!!"; } else if (Checks.Empty(password)) { lblmsg.Text = "*Please Enter Password!!"; } else if (!Checks.Empty(username) && !Checks.Empty(password)) { LoginInfoData data = new LoginInfoData(); data.Username = username; data.Password = password; loginInfo li = new LoginInfoAction().login(data); // method calling for login if (li != null) { Session["Username"] = txtusername.Text.Trim(); //create session for user Session["UserID"] = li.LoginInfoId; Session["Loginstatus"] = true; Response.Redirect("~/Admin/Dashboard.aspx"); } else { lblmsg.Text = "*Invalid Username Or Password!!"; } } } catch (Exception ex) { lblmsg.Text = ex.Message; } }
//Change admin password implementation protected void lnkaddchnge_Click(object sender, EventArgs e) { try { string oldpassword, newpassword, confirmpassword; oldpassword = txtoldpswd.Text.Trim(); newpassword = txtnewpswd.Text.Trim(); confirmpassword = txtnewpswd.Text.Trim(); if (oldpassword == "" && newpassword == "" && confirmpassword == "") { lblmsg.Text = "*Please Fill all Fields!!"; } else if (oldpassword == "") { lblmsg.Text = "*Please Enter Old Password!!"; } else if (newpassword == "") { lblmsg.Text = "*Please Enter New Password!!"; } else if (confirmpassword == "") { lblmsg.Text = "*Please Enter confirm Password!!"; } else if (newpassword != confirmpassword) { lblmsg.Text = "*Password Doesn't matched!!"; } else if (newpassword == confirmpassword && oldpassword != "" && newpassword != "" && confirmpassword != "") { LoginInfoData data = new LoginInfoData(); if (Session["UserID"] != null) { data.Userid = int.Parse(Session["UserID"].ToString()); data.Password = newpassword; data.Oldpassword = oldpassword; bool result = new LoginInfoAction().changepassword(data); //change password method calling if (result == true) { lblmsg.Text = "*Password Change Successfully!!"; } else { lblmsg.Text = "*Old Password Is Incorrect!!"; } } } } catch (Exception ex) { lblmsg.Text = ex.Message; } }
//Admin login implementation protected void btnlogin_Click(object sender, EventArgs e) { try { string username, password; username = txtusername.Text.Trim(); password = txtpassword.Text.Trim(); if (username == "") { lblmsg.Text = "Please Enter Username!!"; } else if (password == "") { lblmsg.Text = "Please Enter Password!!"; } else { LoginInfoData data = new LoginInfoData(); //send data to class data.Username = username; data.Password = password; LoginInfo li = new LoginInfoAction().login(data); // method calling for login if (li != null) { Session["Username"] = username; //create session for user Session["UserID"] = li.UserID; Session["Loginstatus"] = true; Response.Redirect("~/Admin/Dashboard.aspx"); } else { lblmsg.Text = "Invalid Username Or Password!!"; } } } catch (Exception ex) { lblmsg.Text = ex.Message; } }