//---------------------------------------------------------------------------- //----------------------- Load Employee Profile ------------------------------ private void MyProfile_Load(object sender, EventArgs e) { DataSet dsEmployeeUser = null; string employeeId = LoginInfo.employeeId; try { dsEmployeeUser = FinTrustBL.GetEmployeeDetails(employeeId); Object[] Data = null; if (dsEmployeeUser.Tables[0].Rows.Count > 0) { Data = dsEmployeeUser.Tables[0].Rows[0].ItemArray; textBoxEmployeeId.Text = Data[0].ToString(); textBoxEmployeeName.Text = Data[1].ToString(); textBoxDesignation.Text = Data[4].ToString(); textBoxDOB.Text = Data[2].ToString().Substring(0, 9); textBoxGender.Text = Data[3].ToString(); textBoxPhone.Text = Data[5].ToString(); textBoxEmail.Text = Data[6].ToString(); } } catch (Exception ex) { Console.Out.WriteLine("Error : FinTrustBL:GetEmployeeDetails : " + ex.Message.ToString()); } }
//--------------------------------------------------------------------------- //--------------- Password Changing ----------------------------------------- private void btnChangePassword_Click(object sender, EventArgs e) { string pswd1 = textBoxPassword1.Text; string pswd2 = textBoxPassword2.Text; string employeeId = LoginInfo.employeeId; int output = 0; if (pswd1 == pswd2 && pswd1.Trim() != "") { output = FinTrustBL.UpdatePassword(pswd1, employeeId); if (output > 0) { MessageBox.Show("Password Updated Successfully!"); } else { MessageBox.Show("Password Updation Failed!"); } } else if (pswd1 != pswd2) { MessageBox.Show("The specified passwords do not match."); } else if (pswd1.Trim() == "") { MessageBox.Show("Password should not be empty."); } else { MessageBox.Show("Invalid Password."); } }
//---------------------------------------------------------------------------------------------- //----------------------- Employee Login ------------------------------------------------------- private void buttonLogin_Click(object sender, EventArgs e) { User objUser = null; if (comboBoxUser.Text == string.Empty || textBoxUsername.Text == string.Empty || textBoxPassword.Text == string.Empty) { labelLoginMessage.Text = "Enter Valid Input !!"; } else { objUser = new User(); objUser.Email = textBoxUsername.Text; objUser.Password = textBoxPassword.Text; objUser.Designation = comboBoxUser.Text; bool validUser = FinTrustBL.CheckEmployeeUser(objUser); if (validUser) { if (objUser.Designation == "Branch Manager") { this.Hide(); Branch_Manager BMHomeForm = new Branch_Manager(); BMHomeForm.Show(); } else if (objUser.Designation == "Probationary Officer") { this.Hide(); Probationary_Officer POHomeForm = new Probationary_Officer(); POHomeForm.Show(); } else if (objUser.Designation == "Cashier") { this.Hide(); FinTrust_Cashier CashierHomeForm = new FinTrust_Cashier(); CashierHomeForm.Show(); } else if (objUser.Designation == "Clerk") { this.Hide(); Clerk ClerkHomeForm = new Clerk(); ClerkHomeForm.Show(); } } else { labelLoginMessage.Text = "Invalid Login Credentials!"; } } }
//---------------------------------------------------------------------------------------------- //----------------------- Employee Registration ------------------------------------------------ private void buttonUserRegister_Click(object sender, EventArgs e) { User objUser = null; int output = 0; try { if (textBoxEmployeeID.Text == string.Empty || textBoxEmployeeName.Text == string.Empty || comboBoxDesignation.SelectedIndex == -1 || textBoxEmployeePhone.Text == string.Empty || textBoxEmployeeEmail.Text == string.Empty || textBoxEmployeeAddress.Text == string.Empty || textBoxEmployeeAadhar.Text == string.Empty || textBoxtEmployeePAN.Text == string.Empty || !(radioButtonEmployeeFemale.Checked || radioButtonEmployeeMale.Checked)) { foreach (Control control in this.Controls) { control.Focus(); // Set focus on control if (!Validate()) // Validate causes the control's Validating event to be fired,if CausesValidation is True { DialogResult = DialogResult.None; return; } } } //************************************************* INSERTING USER DETAILS ***************************************** else { objUser = new User(); objUser.EmployeeId = textBoxEmployeeID.Text; objUser.EmployeeName = textBoxEmployeeName.Text; objUser.DateOfBirth = dateTimePickerEmployeeDOB.Value.ToString("MM-dd-yyyy"); if (radioButtonEmployeeMale.Checked == true) { objUser.Gender = "Male"; } else { objUser.Gender = "Female"; } objUser.Designation = comboBoxDesignation.Text; objUser.Phone = Convert.ToInt64(textBoxEmployeePhone.Text); objUser.Email = textBoxEmployeeEmail.Text; objUser.Address = textBoxEmployeeAddress.Text; objUser.AadharNumber = Convert.ToInt64(textBoxEmployeeAadhar.Text); objUser.PanNumber = textBoxtEmployeePAN.Text; output = FinTrustBL.InsertUserDetails(objUser); string Title = "Employee Registration"; if (output < 0) { MessageBox.Show("User Registration Failed", Title); } else { MessageBox.Show("User Registration Success", Title); } } } catch (Exception ex) { Console.Out.WriteLine(ex.Message.ToString()); } }