private void btnLuu_Click(object sender, RoutedEventArgs e)
        {
            var result = MessageBox.Show("Do you want to save changes?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                NhanVien nhanVien = new NhanVien();
                nhanVien.maNhanVien     = txtMaNhanVien.Text;
                nhanVien.hoNhanVien     = txtHoNhanVien.Text;
                nhanVien.tenNhanVien    = txtTenNhanVien.Text;
                nhanVien.soDienThoai    = txtSoDienThoai.Text;
                nhanVien.ngaySinh       = dateNgaySinh.SelectedDate.Value.Date;
                nhanVien.phai           = cmbPhai.SelectedIndex == 0 ? true : false;
                nhanVien.cMND           = txtCMND.Text;
                nhanVien.thuongTru      = txtThuongTru.Text;
                nhanVien.tamTru         = txtTamTru.Text;
                nhanVien.ngayVaoLam     = dateNgayVaoLam.SelectedDate.Value.Date;
                nhanVien.maLoaiNhanVien = CLoaiNhanVien_BUS.findMaLoaiByTenLoai(cmbLoaiNhanVien.SelectedItem.ToString());
                nhanVien.urlAnh         = urlAnh;
                nhanVien.trangThai      = cmbTrangThai.SelectedIndex;
                if (nhanVien.trangThai == 2 || nhanVien.trangThai == 1)
                {
                    if (CTaiKhoan_BUS.khoaTaiKhoanNV(nhanVien.maNhanVien) == false)
                    {
                        return;
                    }
                }

                if (CNhanVien_BUS.edit(nhanVien))
                {
                    this.Close();
                }
            }
        }
 public frmThongTinNhanVien(NhanVien nhanVien = null, int flag = 1)
 {
     InitializeComponent();
     cmbLoaiNhanVien.ItemsSource = CLoaiNhanVien_BUS.toListTenLoai();
     dateNgayVaoLam.SelectedDate = DateTime.Now;
     // khi người dùng nhấn thêm thì ấn nút sửa
     if (flag == 1)
     {
         txtMaNhanVien.Text = CServices.taoMa <NhanVien>(CNhanVien_BUS.toListAll());
         btnSua.IsEnabled   = false;
         btnLuu.IsEnabled   = false;
     }
     // khi người dùng nhấn nút sửa
     else if (flag == 2)
     {
         btnThem.IsEnabled = false;
         btnSua.IsEnabled  = false;
     }
     // là khi người dùng bấm nút xem chi tiết
     else
     {
         btnThem.IsEnabled   = false;
         btnLuu.IsEnabled    = false;
         btnChosse.IsEnabled = false;
         isEnabledThongTin(false);
     }
     if (nhanVien != null)
     {
         nhanVienSelect = nhanVien;
         hienThiThongTin(nhanVienSelect);
     }
 }
        private void btnThem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                LoaiNhanVien loaiNhanVien = new LoaiNhanVien();
                loaiNhanVien.maLoaiNhanvien = txtMaLoaiNhanVien.Text;
                loaiNhanVien.tenLoai        = txtTenLoai.Text;

                if (CLoaiNhanVien_BUS.add(loaiNhanVien))
                {
                    MessageBox.Show("Thêm thành công");
                    hienThiDSLoaiNhanVien(CLoaiNhanVien_BUS.toList());

                    txtMaLoaiNhanVien.Text = CServices.taoMa <LoaiNhanVien>(CLoaiNhanVien_BUS.toList());
                    txtTenLoai.Text        = "";
                }
            }
            catch (ArgumentNullException)
            {
                MessageBox.Show("Lỗi! Dữ liệu rống");
            }
            catch (FormatException)
            {
                MessageBox.Show("Lỗi! Dữ liệu không hợp lệ, Lương cơ bản phải là số");
            }
            catch (OverflowException)
            {
                MessageBox.Show("Lỗi! Độ dài quá giới hạn cho phép");
            }
        }
        private void btnThem_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dateNgaySinh.SelectedDate.Value != null &&
                    dateNgayVaoLam.SelectedDate.Value != null &&
                    cmbLoaiNhanVien.SelectedItem.ToString() != null)
                {
                    NhanVien nhanVien = new NhanVien();
                    nhanVien.maNhanVien     = txtMaNhanVien.Text;
                    nhanVien.hoNhanVien     = txtHoNhanVien.Text;
                    nhanVien.tenNhanVien    = txtTenNhanVien.Text;
                    nhanVien.soDienThoai    = txtSoDienThoai.Text;
                    nhanVien.ngaySinh       = dateNgaySinh.SelectedDate.Value.Date;
                    nhanVien.phai           = cmbPhai.SelectedIndex == 0 ? true : false;
                    nhanVien.cMND           = txtCMND.Text;
                    nhanVien.thuongTru      = txtThuongTru.Text;
                    nhanVien.tamTru         = txtTamTru.Text;
                    nhanVien.ngayVaoLam     = dateNgayVaoLam.SelectedDate.Value.Date;
                    nhanVien.maLoaiNhanVien = CLoaiNhanVien_BUS.findMaLoaiByTenLoai(cmbLoaiNhanVien.SelectedItem.ToString());
                    nhanVien.urlAnh         = urlAnh;
                    nhanVien.trangThai      = cmbTrangThai.SelectedIndex;

                    if (CNhanVien_BUS.add(nhanVien))
                    {
                        MessageBox.Show("Thêm thành công!");
                        this.Close();
                    }
                }
            }
            catch (InvalidOperationException)
            {
                MessageBox.Show("Lỗi! Không được để dữ liệu nhập vào là rỗng");
            }
        }
 private void btnBoChon_Click(object sender, RoutedEventArgs e)
 {
     hienThiThongTin(new LoaiNhanVien());
     isEnabledThongTin(false);
     loaiNhanVienSelect     = null;
     txtMaLoaiNhanVien.Text = CServices.taoMa <LoaiNhanVien>(CLoaiNhanVien_BUS.toList());
 }
 public frmQuanLyLoaiNhanVien()
 {
     InitializeComponent();
     loaiNhanVienSelect = new LoaiNhanVien();
     hienThiDSLoaiNhanVien(CLoaiNhanVien_BUS.toList());
     isEnabledThongTin(false);
     txtMaLoaiNhanVien.Text = CServices.taoMa <LoaiNhanVien>(CLoaiNhanVien_BUS.toList());
 }
 private void dgDSLoaiNhanVien_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (dgDSLoaiNhanVien.SelectedItem != null)
     {
         string maLoaiNhanVien = dgDSLoaiNhanVien.SelectedValue.ToString();
         loaiNhanVienSelect = CLoaiNhanVien_BUS.find(maLoaiNhanVien);
         hienThiThongTin(loaiNhanVienSelect);
         isEnabledThongTin(true);
     }
 }
        private void btnXoa_Click(object sender, RoutedEventArgs e)
        {
            if (loaiNhanVienSelect != null)
            {
                if (CLoaiNhanVien_BUS.remove(loaiNhanVienSelect))
                {
                    MessageBox.Show("Xóa thành công");
                    hienThiDSLoaiNhanVien(CLoaiNhanVien_BUS.toList());
                    loaiNhanVienSelect = null;

                    txtTenLoai.Text        = "";
                    txtMaLoaiNhanVien.Text = CServices.taoMa <LoaiNhanVien>(CLoaiNhanVien_BUS.toList());
                }
            }
            else
            {
                MessageBox.Show("Vui lòng chọn nhân viên cần xóa");
            }
        }
        private void btnSua_Click(object sender, RoutedEventArgs e)
        {
            if (loaiNhanVienSelect != null)
            {
                var result = MessageBox.Show("Do you want to save changes?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (result == MessageBoxResult.Yes)
                {
                    LoaiNhanVien loaiNhanVien = new LoaiNhanVien();
                    loaiNhanVien.maLoaiNhanvien = txtMaLoaiNhanVien.Text;
                    loaiNhanVien.tenLoai        = txtTenLoai.Text;

                    if (CLoaiNhanVien_BUS.edit(loaiNhanVien))
                    {
                        MessageBox.Show("Sửa thành công");
                        hienThiDSLoaiNhanVien(CLoaiNhanVien_BUS.toList());

                        txtTenLoai.Text        = "";
                        txtMaLoaiNhanVien.Text = CServices.taoMa <LoaiNhanVien>(CLoaiNhanVien_BUS.toList());
                    }
                }
            }
        }