private void button1_Click(object sender, EventArgs e) { User objUser = new User(); User_BL objUserBL = new User_BL(ConnectionStringClass.GetConnection()); try { objUser = objUserBL.Login(txtUserName.Text, txtPassword.Text); if (objUser.UserID == 0) { MessageBox.Show(this, "Invalid User Name or Password,Contact System Administrator for more information", "Incorrect User Name or Password", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { if (objUser.LastLoggedIn.ToString() == "1/1/0001 12:00:00 AM") { frmChangePassword objFrm = new frmChangePassword(objUser, 0); //Production.BatchFile.frmBatchFile objFrm = new MRP_GUI.Production.BatchFile.frmBatchFile(objUser); objFrm.Show(); this.Hide(); } else { User_DL objUser_DL = new User_DL(ConnectionStringClass.GetConnection()); int y = objUser_DL.CheckForPasswordExpiry(objUser); if (y == 1) { frmChangePassword objFrm = new frmChangePassword(objUser, 0); //Production.BatchFile.frmBatchFile objFrm = new MRP_GUI.Production.BatchFile.frmBatchFile(objUser); objFrm.Show(); this.Hide(); } else { if (objUser.Online == true) { MessageBox.Show(this, "This User has already Logged-In. Please Contact System Administrator", "Already Logged-In", MessageBoxButtons.OK); } else { MRP_Main objFrm = new MRP_Main(objUser); //Production.BatchFile.frmBatchFile objFrm = new MRP_GUI.Production.BatchFile.frmBatchFile(objUser); objFrm.Show(); this.Hide(); objUser.Online = true; objUser_DL.Update_OnlineState(objUser); } } } } } catch (Exception ex) { MessageBox.Show(this, "Database error, " + ex.Message, "Logging Failure", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public int Update_Status(User objUser) { User_DL objUserDL = new User_DL(Connection); try { return(objUserDL.Update_Status(objUser)); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public int Delete(long UserID) { User_DL objUserDL = new User_DL(Connection); try { return(objUserDL.Delete(UserID)); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public int Clear_Password(User objUser) { objUser.UserPassword = Encrypt(objUser.UserName, true); User_DL objUserDL = new User_DL(Connection); try { return(objUserDL.Update(objUser)); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
public User Login(String UserName, String Password) { User objUser = new User(); User_DL objUserDL = new User_DL(Connection); try { String EncryptPass = Encrypt(Password, true); objUser = objUserDL.Login(UserName, EncryptPass); return(objUser); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
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); } }
public int Add(User objUser) { User_DL objUserDL = new User_DL(Connection); try { objUser.UserPassword = Encrypt(objUser.UserPassword, true); return(objUserDL.Add(objUser)); } catch (Exception ex) { throw new Exception(ex.Message, ex); } finally { 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 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 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; } }