private void btnDangNhap_Click(object sender, EventArgs e) { string username = txtMaNguoiDung.Text; string password = txtMatKhau.Text; // try { if (BAL_NhanVien.IsLogin(username, password)) { if (BAL_NhanVien.GetSpeciesById(username) == "LNV1") { frmQuanLyKho frmQuanLyKho = new frmQuanLyKho(); this.Hide(); frmQuanLyKho.tenNhanVienDangNhap = BAL_NhanVien.GetNameById(username); frmQuanLyKho.ShowDialog(); this.Close(); } else { frmThuThu frmThuThu = new frmThuThu(); this.Hide(); frmThuThu.tenNhanVienDangNhap = BAL_NhanVien.GetNameById(username); frmThuThu.ShowDialog(); this.Close(); } } else if (BAL_DocGia.IsLogin(username, password)) { frmDocGia frmDocGia = new frmDocGia(); this.Hide(); frmDocGia.tenNhanVienDangNhap = BAL_DocGia.GetNameById(username); frmDocGia.ShowDialog(); this.Close(); } else { MessageBox.Show("Mã người dùng hoặc mật khẩu không chính xác!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception err) { MessageBox.Show(err.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnThem_Click(object sender, EventArgs e) { string maDocGia = txtMaDocGia.Text; string tenDocGia = txtTenDocGia.Text; string gioiTinh; if (radNam.Checked == true) { gioiTinh = "Nam"; } else { gioiTinh = "Nữ"; } DateTime ngaySinh = dtpNgaySinhDocGia.Value; string diaChi = txtDiaChiDocGia.Text; string dienThoai = txtDienThoaiDocGia.Text; string matKhau = txtMatKhauDocGia.Text; string maLoaiDocGia = cboMaLoaiDocGia.Text; if (maLoaiDocGia == "Trẻ em") { maLoaiDocGia = "LDG001"; } else if (maLoaiDocGia == "Người lớn") { maLoaiDocGia = "LDG002"; } string trangThai = txtTrangThaiDocGia.Text; BEL_DocGia docGia = new BEL_DocGia(maDocGia, tenDocGia, gioiTinh, ngaySinh, diaChi, dienThoai, matKhau, maLoaiDocGia, trangThai); try { if (!BAL_DocGia.IsExist(maDocGia)) { if (tenDocGia == "") { txtTenDocGia.Focus(); } else if (gioiTinh == "") { radNam.Focus(); } else if (ngaySinh == null) { dtpNgaySinhDocGia.Focus(); } else if (diaChi == "") { txtDiaChiDocGia.Focus(); } else if (dienThoai == "") { txtDienThoaiDocGia.Focus(); } else if (matKhau == "") { txtMatKhauDocGia.Focus(); } else if (maLoaiDocGia == "") { cboMaLoaiDocGia.Focus(); } else if (trangThai == "") { txtTrangThaiDocGia.Focus(); } if (BAL_DocGia.Add(docGia)) { MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Thêm không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Mã độc giả đã tồn tại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); txtMaDocGia.Focus(); } } catch (Exception Err) { MessageBox.Show(Err.Message, "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } }