protected void Button1_Click(object sender, EventArgs e) { encryption enc = new encryption(); TextBox1.Text = enc.Encryption(TextBox1.Text.ToString()); TextBox2.Text = enc.Encryption(TextBox2.Text.ToString()); TextBox3.Text = enc.Encryption(TextBox3.Text.ToString()); TextBox4.Text = enc.Encryption(TextBox4.Text.ToString()); TextBox5.Text = enc.Encryption(TextBox5.Text.ToString()); TextBox6.Text = enc.Encryption(TextBox6.Text.ToString()); TextBox7.Text = enc.Encryption(TextBox7.Text.ToString()); TextBox8.Text = enc.Encryption(TextBox8.Text.ToString()); TextBox9.Text = enc.Encryption(TextBox9.Text.ToString()); TextBox10.Text = enc.Encryption(TextBox10.Text.ToString()); TextBox11.Text = enc.Encryption(TextBox11.Text.ToString()); TextBox12.Text = enc.Encryption(TextBox12.Text.ToString()); }
protected void btn_Submit_Click(object sender, EventArgs e) { Model1 ctx = new Model1(); int count = ctx.Users.Count(); User[] users = new User[count]; users = ctx.Users.ToArray(); User u = ctx.Users.Where(x => x.Email == tbx_Email.Text).First(); encryption enc = new encryption(); string newpassword = enc.Encryption(tbx_Password.Text.ToString()); u.Password = newpassword; ctx.SaveChanges(); lbl_Status.Text = "Reset Successful!"; tbx_Password.Enabled = false; tbx_Confirm.Enabled = false; tbx_Email.Enabled = true; tbx_UserName.Enabled = true; tbx_Verification.Enabled = true; }
protected void btn_Login_Click(object sender, EventArgs e) { string sign = (string)Session["sign"]; Session["sign"] = tbx_UserName.Text; Model1 ctx = new Model1(); bool isFound = false; int count = ctx.Users.Count(); User[] users = new User[count]; users = ctx.Users.ToArray(); for (int i = 0; i < count; i++) { if (tbx_UserName.Text == users[i].UserName) { isFound = true; } } if (isFound == false) { tbx_UserName.Text = ""; tbx_Password.Text = ""; lbl_Status.Text = "UserName can not be found,please try again"; } else { User u = ctx.Users.Where(x => x.UserName == tbx_UserName.Text).First(); Session["sign"] = u.UserName; encryption enc = new encryption(); if (u.Password != enc.Encryption(tbx_Password.Text)) { tbx_UserName.Text = ""; tbx_Password.Text = ""; lbl_Status.Text = "Password is not correct,please try again"; } else { if (u.Password == enc.Encryption(tbx_Password.Text) && u.Role == "DeptHead") { Response.Redirect("DepartmentPage/HomePageHead.aspx"); } else if (u.Password == enc.Encryption(tbx_Password.Text.ToString()) && (u.Role == "DeptEmp" || u.Role == "DeptRepre")) { Response.Redirect("DepartmentPage/HomePageEmployee.aspx"); } else if (u.Password == enc.Encryption(tbx_Password.Text) && u.Role == "StoreClerk") { //Label1.Text = "cleckhomepage"; Response.Redirect("StorePage/ClerkHomePage.aspx"); } else if (u.Password == enc.Encryption(tbx_Password.Text) && u.Role == "StoreSuper") { Response.Redirect("StorePage/SupervisorHomePage.aspx"); } else if (u.Password == enc.Encryption(tbx_Password.Text) && u.Role == "StoreManager") { Response.Redirect("StorePage/ManagerHomePage.aspx"); } else if (u.Password == enc.Encryption(tbx_Password.Text) && u.Role == "DeptDelegate") { Response.Redirect("DepartmentPage/HomePageDelegate.aspx"); } } } }