public bool Login(string username, string password) { //MessageBox.Show("Login Action"); AccountDao AcDAO = new AccountDao(); bool LoginSuccess = AcDAO.CheckLogin(username, password); if (LoginSuccess) { MessageBox.Show("LoginSuccess"); User = AcDAO.GetAccountByUsername(username); welcomeToolStripMenuItem.Text = "Xin chào " + username; // chuyển đến form Order this.mainPanel.Controls.Clear(); ResetUserLogin(); int userRole = User.UserRole; if (userRole == 1) { PhanQuyenNhanVien(); } else if (userRole == 2) { PhanQuyenAdmin(); } return(true); } else { MessageBox.Show("LoginFailed"); return(false); } }
private void btnEdit_Click(object sender, EventArgs e) { if (lsvAccount.SelectedItems.Count > 0) { AccountDao acDao = new AccountDao(); Account a = acDao.GetAccountByUsername(lsvAccount.SelectedItems[0].SubItems[1].Text); a.Username = txtUsername.Text; a.EmployeeId = Convert.ToInt32(txtEmployeeId.Text); a.UserRole = cboRole.SelectedIndex + 1; lsvAccount.SelectedItems[0].SubItems[1].Text = txtUsername.Text; lsvAccount.SelectedItems[0].SubItems[3].Text = txtEmployeeId.Text; lsvAccount.SelectedItems[0].SubItems[2].Text = cboRole.SelectedItem.ToString(); acDao.UpdateAccount(a); txtEmployeeId.Text = ""; txtUsername.Text = ""; } }