private void btnLogin_Click(object sender, EventArgs e) { string username = txbUsername.Text; string password = txbPassword.Text; if (Login(username, password)) { AccountDTO accountDTO = AccountDAO.Instance.GetAccountByUsername(username); int AcType = accountDTO.AcType; string PersonId = accountDTO.PersonId; LibrarianDTO librarianDTO = LibrarianDAO.Instance.GetLibrarianById(PersonId); MemberDTO memberDTO = MemberDAO.Instance.GetMembertById(PersonId); if (AcType == 1) { if (librarianDTO.Status == true) { fLibraryManager manager = new fLibraryManager(librarianDTO); this.Hide(); manager.ShowDialog(); this.Show(); txbPassword.Text = ""; } else { MessageBox.Show("Tài khoản của bạn đã bị khóa!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (AcType == 2) { if (librarianDTO.Status == true) { fLibraryStaff staff = new fLibraryStaff(librarianDTO); this.Hide(); staff.ShowDialog(); this.Show(); txbPassword.Text = ""; } else { MessageBox.Show("Tài khoản của bạn đã bị khóa!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { fLibraryCustomer customer = new fLibraryCustomer(memberDTO); this.Hide(); customer.ShowDialog(); this.Show(); txbPassword.Text = ""; } } else { MessageBox.Show("Tên tài khoản hoặc mật khẩu sai!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public List <LibrarianDTO> GetListLibrarianStatusFalse() { List <LibrarianDTO> librarianDTOs = new List <LibrarianDTO>(); string query = string.Format("SELECT * FROM dbo.Librarian WHERE Status = 0"); DataTable dataTable = DataProvider.Instance.ExcuteQuery(query); foreach (DataRow item in dataTable.Rows) { LibrarianDTO librarianDTO = new LibrarianDTO(item); librarianDTOs.Add(librarianDTO); } return(librarianDTOs); }
public bool AddLibrarian(LibrarianDTO dto) { var library = this.db.Libraries.Find(dto.LibraryId); this.userService.ChangeRoles(dto.Email, "User", "Librarian"); var user = this.userService.GetUser(dto.Email); library.LibraryUsers.Add(user); int resultCount = this.db.SaveChanges(); if (resultCount == 0) { return(false); } return(true); }