private void tsmiChangePassword_Click(object sender, EventArgs e) { FrmChangePassword frmChangePassword = new FrmChangePassword(staff); frmChangePassword.Show(); this.Enabled = false; frmChangePassword.FormClosed += frmChangePassword_FormClosed; }
private void btnLogin_Click(object sender, EventArgs e) { try { if (txtbAccName.Text == "") { throw new Exception("Bạn chưa nhập tên tài khoản!"); } else { if (txtbPassword.Text == "") { throw new Exception("Bạn chưa nhập mật khẩu!"); } else { Staff staff = staffBUS.GetStaffByAccount(txtbAccName.Text); if (staff.Password.Equals(txtbPassword.Text)) { if (staff.Password.Equals(staff.Account)) { FrmChangePassword frmChangePassword = new FrmChangePassword(staff); frmChangePassword.Show(); this.Enabled = false; frmChangePassword.FormClosed += frmChangePassword_FormClosed; } else { FrmMain frmMain = new FrmMain(staff); frmMain.Show(); this.Visible = false; frmMain.FormClosed += frmMain_FormClosed; } } else { throw new Exception("Mật khẩu không đúng!"); } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void txtbPassword_KeyDown(object sender, KeyEventArgs e) { try { if (firstPress2) { txtbPassword.ForeColor = Color.Black; txtbPassword.UseSystemPasswordChar = true; txtbPassword.Text = ""; firstPress2 = false; } if (e.KeyCode == Keys.Enter) { Staff staff = staffBUS.GetStaffByAccount(txtbAccName.Text); if (staff.Password.Equals(txtbPassword.Text)) { if (staff.Password.Equals(staff.Account)) { FrmChangePassword frmChangePassword = new FrmChangePassword(staff); frmChangePassword.Show(); this.Enabled = false; frmChangePassword.FormClosed += frmChangePassword_FormClosed; } else { FrmMain frmMain = new FrmMain(staff); frmMain.Show(); this.Visible = false; frmMain.FormClosed += frmMain_FormClosed; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }