private void btnLogin_Click(object sender, EventArgs e) { string userName = txtUsername.Text; string password = txtPassword.Text; CheckMD5 md5 = new CheckMD5(); EmployeeDAO dao = new EmployeeDAO(); EmployeeDTO dto = dao.CheckLogin(userName, md5.CreateMD5(password)); if (dto != null && dto.EmpRole == false) { frmChangeAccount changeAccountForm = new frmChangeAccount(dto, this); this.Hide(); changeAccountForm.Show(); changeAccountForm.FormClosed += Main_Closed; } else if (dto != null && dto.EmpRole == true) { frmMaintainBooks booksForm = new frmMaintainBooks(this); this.Hide(); booksForm.Show(); booksForm.FormClosed += Main_Closed; } else if (dto == null) { MessageBox.Show("Invalid username or password!!!"); } }
private void btnSaveChange_Click(object sender, EventArgs e) { EmployeeDAO dao = new EmployeeDAO(); CheckMD5 md5 = new CheckMD5(); if (txtPassword.Text.Length < 2 || txtPassword.Text.Length > 15) { MessageBox.Show("Password require 2 - 15 characters."); } else { bool r = dao.ChagePassword(Employee.EmpID, md5.CreateMD5(txtPassword.Text)); if (r == true) { MessageBox.Show("Save successful."); } else { MessageBox.Show("Save fail."); } } }