Пример #1
0
        private void btn_Luu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string error    = "";
            bool   isUpdate = false;

            if (_listUpdate.Count > 1)
            {
                foreach (int id in _listUpdate)
                {
                    NhanVien nv = new NhanVien();
                    nv.id_nhanvien = int.Parse(gridView1.GetRowCellValue(id, "id_nhanvien").ToString());
                    nv.tennhanvien = gridView1.GetRowCellValue(id, "tennhanvien").ToString();
                    nv.tendangnhap = gridView1.GetRowCellValue(id, "tendangnhap").ToString();
                    nv.matkhau     = gridView1.GetRowCellValue(id, "matkhau").ToString();
                    nv.id_quyen    = int.Parse(gridView1.GetRowCellValue(id, "id_quyen").ToString());

                    if (!_Nv_Bll.KiemTraTDNTonTai(nv.tendangnhap, nv.id_nhanvien))
                    {
                        _Nv_Bll.CapNhatNhanVien(nv);
                        isUpdate = true;
                    }
                    else
                    {
                        if (error == "")
                        {
                            error = nv.tennhanvien;
                        }
                        else
                        {
                            error += " | " + nv.tennhanvien;
                        }
                    }
                }
            }
            if (isUpdate == true)
            {
                if (error.Length == 0)
                {
                    Notifications.Success("Cập dữ liệu thành công.");
                }
                else
                {
                    Notifications.Error("Có lỗi xảy ra khi cập nhật dữ liệu. Các nhân viên chưa được cập nhật (" + error + "). Lỗi: Tên nhân viên đã tồn tại.");
                }
            }
            else
            {
                Notifications.Error("Có lỗi xảy ra khi cập nhật dữ liệu. Lỗi: Tên nhân viên đã tồn tại.");
            }
            btn_Luu.Enabled = false;
            LoadDataSource();
        }
Пример #2
0
        private void btmCapNhatNV_Click(object sender, EventArgs e)
        {
            btmCapNhatNV.Enabled = false;
            NhanVien_DTO nvDTO = new NhanVien_DTO();

            nvDTO.MaNV        = txtMaNV.Text;
            nvDTO.TenNhanVien = txtTenNV.Text;
            nvDTO.NgaySinh    = Convert.ToDateTime(dtpNgaySinh.Text);
            nvDTO.DiaChi      = txtDiaChi.Text;
            nvDTO.CMND        = txtCMND.Text;
            if (rdbNam.Checked)
            {
                nvDTO.GioiTinh = "Nam";
            }
            else
            {
                nvDTO.GioiTinh = "Nữ";
            }
            nvDTO.SDT      = txtSDT.Text;
            nvDTO.MaChucVu = (string)cmbMaChucVu.SelectedValue;
            if (NhanVien_BLL.CapNhatNhanVien(nvDTO) == 1)
            {
                NhanVien_DTO nvDTOUpdate = lstNhanVien.Single(n => n.MaNV == nvDTO.MaNV);
                nvDTOUpdate.MaNV        = nvDTO.MaNV;
                nvDTOUpdate.TenNhanVien = nvDTO.TenNhanVien;
                nvDTOUpdate.NgaySinh    = nvDTO.NgaySinh;
                nvDTOUpdate.DiaChi      = nvDTO.DiaChi;
                nvDTOUpdate.CMND        = nvDTO.CMND;
                nvDTOUpdate.GioiTinh    = nvDTO.GioiTinh;
                nvDTOUpdate.SDT         = nvDTO.SDT;
                nvDTOUpdate.MaChucVu    = nvDTO.MaChucVu;

                HienThiDanhSachCacNhanVien(pos);
                XtraMessageBox.Show("Cập nhật 1 nhân viên thành công!", "Thông báo");
            }
            else
            {
                XtraMessageBox.Show("Cập nhật 1 nhân viên thất bại. Xin xem lại dữ liệu cần cập nhật!", "Thông báo");
            }
        }