protected void btnLogin_Click(object sender, EventArgs e) { try { lblError.Text = ""; lblSuccess.Text = ""; bool fields = true; String errorMsg = ""; if (String.IsNullOrEmpty(txtPassword.Text.Trim())) { errorMsg += "Please enter your password. <br/>"; fields = false; } if (String.IsNullOrEmpty(txtEmployeeID.Text.Trim())) { errorMsg += "Please enter your username. <br/>"; fields = false; } else if (!BusinessLayer.Validate.IsValidEmployeeID(txtEmployeeID.Text)) { errorMsg += "Incorrect Username. <br/>"; fields = false; } if (fields) { if (EmployeeFactory.AuthenticateEmployee(Convert.ToInt32(txtEmployeeID.Text), txtPassword.Text)) { //AuthenticationLvl = Convert.ToInt32(txtUserName.Text); Session["empID"] = Convert.ToInt32(txtEmployeeID.Text); Response.Redirect(Request.RawUrl); } else { lblError.Text = "Invalid Employee ID or Password."; } } else { lblError.Text = errorMsg; } } catch (Exception ex) { lblError.Text = ex.Message; } }
private void btnLogin_Click(object sender, EventArgs e) { try { bool fields = true; errorProvider1.Clear(); if (String.IsNullOrEmpty(txtPassword.Text.Trim())) { errorProvider1.SetError(txtPassword, "Please enter your password."); fields = false; } if (String.IsNullOrEmpty(txtEmpID.Text.Trim())) { errorProvider1.SetError(txtEmpID, "Please enter your username."); fields = false; } else if (!BusinessLayer.Validate.IsValidEmployeeID(txtEmpID.Text)) { errorProvider1.SetError(txtEmpID, "Incorrect Username."); fields = false; } if (fields) { if (EmployeeFactory.AuthenticateEmployee(Convert.ToInt32(txtEmpID.Text), txtPassword.Text)) { //AuthenticationLvl = Convert.ToInt32(txtUserName.Text); empID = Convert.ToInt32(txtEmpID.Text); DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } else { MessageBox.Show("Invalid Employee ID or Password."); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }