private void btnChangePassword_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { try { int RowsAffected = 0; BusinessManager BM = new BusinessManager(); BOAddUser bo = new BOAddUser(); bo.NewPassword = txtNewPassword.Text.Trim(); bo.Username = txtUsername.Text.Trim(); RowsAffected = BM.BALChangeUserPasswordbyAdmin(bo); if (RowsAffected > 0) { MessageBox.Show("Password successfully changed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); txtUsername.Text = ""; txtNewPassword.Text = ""; txtConfirmPassword.Text = ""; } else { MessageBox.Show("Invalid Username or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUsername.Text = ""; txtNewPassword.Text = ""; txtConfirmPassword.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnCheck_Click(object sender, EventArgs e) { try { BusinessManager BM = new BusinessManager(); BOAddUser BO = new BOAddUser(); BO.Username = txtUsername.Text.Trim(); bool res = BM.BALVerifyUserName(BO); if (txtUsername.Text.Trim().Length == 0) { MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUsername.Focus(); return; } if (res == true) { MessageBox.Show("Username not available", "", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!res) { MessageBox.Show("Username available", "", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUsername.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnOK_Click(object sender, EventArgs e) { if (txtUsername.Text.Trim().Length == 0) { MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUsername.Focus(); return; } if (txtPassword.Text.Trim().Length == 0) { MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.Focus(); return; } try { BusinessManager bm = new BusinessManager(); BOAddUser boUser = new BOAddUser(); boUser.Username = txtUsername.Text.Trim(); boUser.Password = txtPassword.Text.Trim(); string res = bm.BALCheckLogin(boUser); if (res == "1") { int i; progressBar1.Visible = true; progressBar1.Maximum = 200; progressBar1.Minimum = 0; progressBar1.Value = 4; progressBar1.Step = 2; for (i = 0; i <= 200; i++) { progressBar1.PerformStep(); } //ThreadStart ts = new ThreadStart(StartMainMenu); //Thread td = new Thread(ts); //td.Start(); this.Hide(); frmMainMenu frm = new frmMainMenu(); frm.lblUser.Text = txtUsername.Text; frm.Show(); } else { MessageBox.Show("Login Failed... Try again!", "Access Denied", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUsername.Clear(); txtPassword.Clear(); txtUsername.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void frmMainMenu_Load(object sender, EventArgs e) { toolStripStatusLabel4.Text = System.DateTime.Now.ToString("dd/MM/yyyy"); Start_Timer(); BusinessManager BM = new BusinessManager(); BOAddUser BO = new BOAddUser(); BO.Username = lblUser.Text; byte[] data = BM.BALGetImageData(); pictureBox1.Image = BM.BbyteArrayToImage(data); SetButtonsEnabledDisabled(IsAdmin(BM.GetUserType(BO))); }
private void btnUpdate_Click(object sender, EventArgs e) { if(ValidateChildren(ValidationConstraints.Enabled)) { try { BusinessManager updateUser = new BusinessManager(); BOAddUser boUser = new BOAddUser(); boUser.Username = txtUsername.Text.Trim(); boUser.Password = txtPassword.Text.Trim(); boUser.Name = txtName.Text.Trim(); boUser.Contact = txtContact.Text.Trim(); boUser.Email = txtEmail.Text.Trim(); if (cmbUserType.SelectedIndex == 1) { boUser.UserType = 1; } else { boUser.UserType = 2; } int rt = updateUser.BALupdateuser(boUser); if (rt > 0) { MessageBox.Show("User updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUsername.Text = ""; txtPassword.Text = ""; txtName.Text = ""; txtContact.Text = ""; txtEmail.Text = ""; txtConfirmPassword.Text = ""; txtUsername.Enabled = true; txtPassword.Enabled = true; } else { MessageBox.Show("User couldn't be updated", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnRegister_Click(object sender, EventArgs e) { if(ValidateChildren(ValidationConstraints.Enabled)) { try { BusinessManager addUser = new BusinessManager(); BOAddUser boUser = new BOAddUser(); boUser.Username = txtUsername.Text.Trim(); boUser.Password = txtPassword.Text.Trim(); boUser.Name = txtName.Text.Trim(); boUser.Contact = txtContact.Text.Trim(); boUser.Email = txtEmail.Text.Trim(); if (cmbUserType.SelectedIndex == 1) { boUser.UserType = 1; } else { boUser.UserType = 2; } int rt = addUser.BALadduser(boUser); if (rt > 0) { MessageBox.Show("User added successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUsername.Text = ""; txtPassword.Text = ""; txtName.Text = ""; txtContact.Text = ""; txtEmail.Text = ""; txtConfirmPassword.Text = ""; cmbUserType.ResetText(); } else { MessageBox.Show("User couldn't be added", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception) { MessageBox.Show("User already exists. Choose a unique username and try again.", "User Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnChangePassword_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { try { int RowsAffected = 0; BusinessManager bm = new BusinessManager(); BOAddUser bo = new BOAddUser(); bo.OldPassword = txtOldPassword.Text.Trim(); bo.NewPassword = txtNewPassword.Text.Trim(); bo.Username = txtUsername.Text.Trim(); RowsAffected = bm.BALChangePassword(bo); if (RowsAffected > 0) { MessageBox.Show("Password successfully changed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); txtUsername.Text = ""; txtOldPassword.Text = ""; txtNewPassword.Text = ""; txtConfirmPassword.Text = ""; frmLogin userlogin = new frmLogin(); userlogin.Show(); userlogin.txtUsername.Text = ""; userlogin.txtPassword.Text = ""; userlogin.progressBar1.Visible = false; userlogin.txtUsername.Focus(); } else { MessageBox.Show("Invalid Username or Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUsername.Text = ""; txtOldPassword.Text = ""; txtNewPassword.Text = ""; txtConfirmPassword.Text = ""; txtOldPassword.Focus(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnDelete_Click(object sender, EventArgs e) { if (ValidateChildren(ValidationConstraints.Enabled)) { if (MessageBox.Show("Do you really want to delete the user?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { BusinessManager deleteUser = new BusinessManager(); BOAddUser delete = new BOAddUser(); delete.Username = txtUsername.Text.Trim(); delete.Password = txtPassword.Text.Trim(); int RowsAffected = deleteUser.BALdeleteuser(delete); if (RowsAffected > 0) { MessageBox.Show("User deleted successfully!", "User Deleted", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUsername.Text = ""; txtPassword.Text = ""; txtName.Text = ""; txtContact.Text = ""; txtEmail.Text = ""; txtConfirmPassword.Text = ""; txtUsername.Focus(); } else { MessageBox.Show("The user couldn't be deleted", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUsername.Text = ""; txtPassword.Text = ""; txtName.Text = ""; txtContact.Text = ""; txtEmail.Text = ""; txtConfirmPassword.Text = ""; txtUsername.Focus(); } } } }
public bool BALVerifyUserName(BOAddUser User) { DBManager DALObject = new DBManager(); return(DALObject.VerifyUserName(User)); }
public int BALChangeUserPasswordbyAdmin(BOAddUser BLUserMas) { DBManager DALObject = new DBManager(); return(DALObject.ChangeUserPasswordbyAdmin(BLUserMas)); }
public int GetUserType(BOAddUser Login) { DBManager DALObject = new DBManager(); return(DALObject.GetUserType(Login)); }
public string BALCheckLogin(BOAddUser BLUserMas) { DBManager dal = new DBManager(); return(dal.UserLogin(BLUserMas)); }
public int BALdeleteuser(BOAddUser delete) { DBManager deleteObject = new DBManager(); return(deleteObject.DeleteFromTableRegistration(delete)); }
public int BALupdateuser(BOAddUser BLUserMas) { DBManager DALObject = new DBManager(); return(DALObject.UpdateIntoTableRegistration(BLUserMas)); }
public int BALadduser(BOAddUser BLUserMas) { DBManager DALObject = new DBManager(); return(DALObject.InsertIntoTableRegistration(BLUserMas)); }