private void txtUsername_KeyPress(object sender, KeyPressEventArgs e) { balEmployee balEmployee = new balEmployee(); List <dtoEmployee> dtoEmployees = new List <dtoEmployee>(); try { if (e.KeyChar == (char)13) { if (txtUsername.Text != frmLogin.UserLogin.EmployeeID.ToString()) { throw new Exception("Sai thông tin đăng nhập, vui lòng nhập lại!"); } else if (txtUsername.Text == "" || txtPass.Text == "" || txtNewPass.Text == "" || txtConfirmPass.Text == "") { throw new Exception("Vui lòng nhập đầy đủ thông tin tài khoản!"); } else if (!balEmployee.Login(Convert.ToInt32(txtUsername.Text), txtPass.Text)) { throw new Exception("Sai thông tin đăng nhập, vui lòng nhập lại!"); } else if (txtNewPass.Text != txtConfirmPass.Text) { throw new Exception("Mật khẩu mới và xác nhận không khớp!"); } else { balEmployee.UpdatePassword(Convert.ToInt32(txtUsername.Text), txtNewPass.Text); txtPass.Text = ""; txtConfirmPass.Text = ""; txtNewPass.Text = ""; XtraMessageBox.Show("Đổi mật khẩu thành công!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void txtUsername_KeyPress(object sender, KeyPressEventArgs e) { balEmployee balEmployee = new balEmployee(); balViewEmployee balViewEmployee = new balViewEmployee(); List <dtoViewEmployees> listEmployee = balViewEmployee.GetViewEmployees(); try { if (e.KeyChar == (char)13) { if (txtUsername.Text == "" || txtPass.Text == "") { throw new Exception("Vui lòng nhập đầy đủ thông tin đăng nhập!"); } else if (!balEmployee.Login(Convert.ToInt32(txtUsername.Text), txtPass.Text)) { throw new Exception("Sai thông tin đăng nhập, vui lòng nhập lại!"); } else { flag = true; foreach (dtoViewEmployees i in listEmployee) { if (Convert.ToInt32(txtUsername.Text) == i.EmployeeID) { UserLogin = i; } } txtPass.Text = ""; XtraMessageBox.Show("Đăng nhập thành công!", "Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Hide(); } } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }