public void LoadUser() { Employee_DL objEmpDL = new Employee_DL(ConnectionStringClass.GetConnection()); User_DL objUserDL = new User_DL(ConnectionStringClass.GetConnection()); try { cmbEmp.DataSource = objEmpDL.Get(); bindUserList.DataSource = objUserDL.Get(); cmbUserRole.DataSource = objUserRoleDL.GetDataview(); } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnUserDelete_Click(object sender, EventArgs e) { User_BL objUserBL = new User_BL(ConnectionStringClass.GetConnection()); User_DL objUserDL = new User_DL(ConnectionStringClass.GetConnection()); try { if (this.UserSelect) { DialogResult dr = MessageBox.Show(this, "Are you sure you want to delete Selected User? Click Yes to Delete", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { int x = objUserBL.Delete(objUser.UserID); if (x > 0) { MessageBox.Show(this, "User Deleted Successfully", "Successful", MessageBoxButtons.OK); bindUserList.DataSource = objUserDL.Get(); } else { MessageBox.Show(this, "This User Cann't be deleted", "UnSuccessful", MessageBoxButtons.OK); } ClearUser(); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objUserBL = null; objUserDL = null; } }
private void btnClearPassword_Click(object sender, EventArgs e) { User_DL objUserDL = new User_DL(ConnectionStringClass.GetConnection()); User_BL objUserBL = new User_BL(ConnectionStringClass.GetConnection()); Employee objEmployee = new Employee(); objEmployee = (Employee)cmbEmp.SelectedItem; try { if (this.UserSelect) { int x = objUserBL.Clear_Password(objUser); if (x == -1) { MessageBox.Show(this, "User Name is already in the database,Please enter another User Name", "User Name invalid", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (x == -2) { MessageBox.Show(this, "Selected Employee already has an Account ", "Already has Account", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (x == 1) { MessageBox.Show(this, "Successfully Saved", "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information); bindUserList.DataSource = objUserDL.Get(); ClearUser(); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objUserBL = null; objUserDL = null; } }
private void btnUserSave_Click(object sender, EventArgs e) { User_DL objUserDL = new User_DL(ConnectionStringClass.GetConnection()); User_BL objUserBL = new User_BL(ConnectionStringClass.GetConnection()); Employee objEmployee = new Employee(); objEmployee = (Employee)cmbEmp.SelectedItem; try { objUser.UserName = txtUserName.Text; objUser.UserStatus = cbUser.Checked; objUser.UserRoleID = Convert.ToInt64(cmbUserRole.SelectedValue); if (this.UserSelect) { int x = objUserBL.Update(objUser); if (x == -1) { MessageBox.Show(this, "User Name is already in the database,Please enter another User Name", "User Name invalid", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (x == -2) { MessageBox.Show(this, "Selected Employee already has an Account ", "Already has Account", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (x == 1) { MessageBox.Show(this, "Successfully Saved", "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information); bindUserList.DataSource = objUserDL.Get(); ClearUser(); } } else { objUser.UserPassword = txtUserName.Text; objUser.UserEmp = objEmployee; objUser.UserQuestion = "N/A"; objUser.UserAnswer = "N/A"; objUser.UserRoleID = Convert.ToInt64(cmbUserRole.SelectedValue); int x = objUserBL.Add(objUser); if (x == -1) { MessageBox.Show(this, "User Name is already in the database,Please enter another User Name", "User Name invalid", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (x == -2) { MessageBox.Show(this, "Selected Employee already has an Account ", "Already has Account", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (x == 1) { MessageBox.Show(this, "Successfully Saved", "Successfull", MessageBoxButtons.OK, MessageBoxIcon.Information); bindUserList.DataSource = objUserDL.Get(); ClearUser(); } } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { objUserBL = null; objUserDL = null; } }