protected void submit_Click(object sender, EventArgs e) { String username = (String)tbUsername.Text.Trim().ToLower(); String password = (String)tbPassword.Text.Trim(); String role = (String)Submit_Role_Value.Text.Trim(); Service1Client client = new Service1Client(); if (role == "0") { CustomerClass cust = client.VerifyCustomer(username); if (cust.ID != Guid.Empty) { if (client.VerifyPassword(cust.Email, password, "Customer")) { Boolean setSession = true; if (cust.blackListed) { List <BlackListClass> resultOne = client.SelectAllBlacklist(username).ToList(); for (int i = 0; i < resultOne.Count; i++) { if (resultOne[i].Deleted == false) { Int16 rtmpesult = client.UpdateBlacklistDeleted(resultOne[i].ID, resultOne[i].CustomerID, true); if (rtmpesult == -4) { divErrorMsg.Visible = true; lbErrorMsg.Text = "You have been blacklisted. Reason: " + HttpUtility.HtmlEncode(resultOne[i].Reason); setSession = false; } else if (rtmpesult > 0) { client.UpdateCustomerStatus(cust.ID, cust.Email, "blackListedStatus", false); } else if (rtmpesult != 1) { setSession = false; } } } } if (!cust.emailVerified) { divErrorMsg.Visible = true; lbErrorMsg.Text = "You have changed your email, please verify before proceeding"; setSession = false; } if (cust.delete) { Int16 resultOne = client.DeleteCustomer(cust.ID, cust.Email, cust.deleteDate.AddDays(30)); if (resultOne != 1) { Int16 rtmpesult = client.UpdateCustomerStatus(cust.ID, cust.Email, "deleteStatus", false); if (rtmpesult != 1) { setSession = false; } } } if (setSession) { Boolean result = AuthRequire.SetUserSession(cust.ID, cust.Email, "Customer"); if (result == true) { Response.Redirect("~/CustomerProfile"); } } } else { divErrorMsg.Visible = true; lbErrorMsg.Text = "Invalid email or password"; } } else { Response.Redirect("~/CustomerRegistration"); } } else if (role == "1") { BusinessUser business = client.GetBusinessUserByEmail(username); if (business != null) { if (client.VerifyPassword(business.Email, password, "Business")) { Boolean setSession = true; if (business.blackListed) { List <BlackListClass> resultOne = client.SelectAllBlacklist(username).ToList(); for (int i = 0; i < resultOne.Count; i++) { if (resultOne[i].Deleted == false) { Int16 rtmpesult = client.UpdateBlacklistDeleted(resultOne[i].ID, resultOne[i].CustomerID, true); if (rtmpesult == -4) { divErrorMsg.Visible = true; lbErrorMsg.Text = "You have been blacklisted. Reason: " + HttpUtility.HtmlEncode(resultOne[i].Reason); setSession = false; } else if (rtmpesult > 0) { client.UpdateBusinessStatus(business.Email, "blackListedStatus", false); } else if (rtmpesult != 1) { setSession = false; } } } } if (!business.emailVerified) { divErrorMsg.Visible = true; lbErrorMsg.Text = "You have changed your email, please verify before proceeding"; setSession = false; } if (business.delete) { Int16 resultOne = client.DeleteBusinessUser(business.Email, business.deleteDate.AddDays(30)); if (resultOne != 1) { Int16 rtmpesult = client.UpdateBusinessStatus(business.Email, "deleteStatus", false); if (rtmpesult != 1) { setSession = false; } } } if (setSession) { Boolean result = AuthRequire.SetUserSession(Guid.Parse(business.Id), business.Email, "Customer"); if (result == true) { Response.Redirect("/BDHome.aspx", false); } } } else { divErrorMsg.Visible = true; lbErrorMsg.Text = "Invalid email or password"; } } } else if (role == "2") { AdminClass admin = client.SelectOneAdmin(username); if (admin != null) { if (client.VerifyPassword(admin.UserName, password, "Admin")) { Boolean result = AuthRequire.SetUserSession(admin.ID, admin.UserName, "Admin"); if (result == true) { Response.Redirect("~/AdminHome"); } } else { divErrorMsg.Visible = true; lbErrorMsg.Text = "Invalid email or password"; } } } else { } }