protected void btnLogin_Click(object sender, EventArgs e) { string str1 = null; string[] LoginName = null; try { if (txtUsername.Text.Contains("@")) { string str = txtUsername.Text; LoginName = str.Split('@'); clsLogin.LoginName = LoginName[0].ToString(); str1 = LoginName[0].ToString(); } else { clsLogin.LoginName = txtUsername.Text.Trim(); str1 = txtUsername.Text.Trim(); } clsLogin.Password = txtPassword.Text.Trim(); string houseno, name; string Role = objLogin.GetUserLogin(out houseno, out name); if (Role == "NoUser") { lblMsg.Text = "User Name and password mismatch. Try again."; } else { if (Role.ToUpper() == "ADMIN") { Session["AdminId"] = houseno; Session["UserType"] = "Admin"; FormsAuthentication.RedirectFromLoginPage("Admin", false); } else if (Role.ToUpper() == "USERS") { Session["UserId"] = houseno; Session["UserType"] = "Users"; Session["UserName"] = name; FormsAuthentication.RedirectFromLoginPage("Users", false); } else { lblMsg.Text = "Login Failed for this User"; } } } catch (Exception ex) { lblMsg.Text = ex.Message; } }
protected void btnLogin_Click(object sender, EventArgs e) { lblLogoutMsg.Text = ""; lblmsg.Text = ""; lblLogoutMsg.Visible = false; string str1 = null; string[] UserName = null; try { if (txtUname.Text.Contains("@")) { string str = txtUname.Text; UserName = str.Split('@'); objLogin.UserName = UserName[0].ToString(); str1 = UserName[0].ToString(); } else { objLogin.UserName = txtUname.Text.Trim(); str1 = txtUname.Text.Trim(); } objLogin.Password = txtPassword.Text.Trim(); string Role = objLogin.GetUserLogin(); if (Role.ToUpper() == "NOUSER") { lblmsg.Text = "Incorrect LoginId and Password. Try again."; } else { Session["EmpId"] = objLogin.GetUserIdByLoginDetails(str1, txtPassword.Text.Trim()); if (Role.ToUpper() == "ADMIN") { Session["UserName"] = str1; Session["pwd"] = txtPassword.Text.Trim(); FormsAuthentication.RedirectFromLoginPage("Admin", false); } else if (Role.ToUpper() == "EMP") { Session["UserName"] = str1; FormsAuthentication.RedirectFromLoginPage("Emp", false); } else if (Role.ToUpper() == "SECURITY") { Session["UserName"] = str1; FormsAuthentication.RedirectFromLoginPage("Security", false); } } } catch (Exception ex) { lblmsg.Text = ex.Message; } }
protected void btnSubmit_Click(object sender, EventArgs e) { string str1 = null; string[] UserName = null; try { if (txtUserName.Text.Contains("@")) { string str = txtUserName.Text; UserName = str.Split('@'); clsLogin.UserName = UserName[0].ToString(); str1 = UserName[0].ToString(); } else { clsLogin.UserName = txtUserName.Text.Trim(); str1 = txtUserName.Text.Trim(); } clsLogin.Password = txtPassword.Text.Trim(); string Role = objLogin.GetUserLogin(); if (Role == "NoUser") { lblMsg.Text = "User Name and password mismatch. Try again."; } else if (Role == "Admin") { Session["UserName"] = str1; Response.Redirect("~/Admin/AdminHome.aspx"); } else if (Role == "Manager") { Session["UserName"] = str1; Response.Redirect("~/HRManager/ManagerHome.aspx"); } else if (Role == "Employee") { Session["UserName"] = str1; Response.Redirect("~/Employee/EmployeeHome.aspx"); } } catch (Exception ex) { lblMsg.Text = ex.Message; } }