Exemplo n.º 1
0
        private void btLuu_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult dialogResult = XtraMessageBox.Show("Xác nhận", "Bạn thực sự muốn thay đổi?", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes)
                {
                    NhanvienDao nvdao    = new NhanvienDao();
                    bool        gioitinh = true;
                    if (rdioGioiTinh.SelectedIndex == 1)
                    {
                        gioitinh = false;
                    }
                    nvdao.suathongtincanhan(txtMaNV.Text, txtHoTenNV.Text, txtSdt.Text, gioitinh, txtDiaChi.Text, dtngaysinh.DateTime);

                    XtraMessageBox.Show("Đã sửa thành công!!");
                    //f.tattab();

                    setalltextboxUneditable();

                    btSua.Visible = true;
                }
            }
            catch (Exception ex)
            {
                string   loi      = ex.InnerException.ToString();
                string[] loichia  = loi.Split('\n');
                string[] loichinh = loichia[0].Split(':');
                XtraMessageBox.Show(loichinh[2]);
            }
        }
Exemplo n.º 2
0
        public void guiemail(string manv)
        {
            try
            {
                NhanvienDao nvdao = new NhanvienDao();
                MailMessage mail  = new MailMessage();

                //Server mail của Google
                SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
                mail.From = new MailAddress("*****@*****.**");
                // Email cần đến
                mail.To.Add(nvdao.getEmailcuanhanvien(manv));
                mail.Subject = ("Thông báo mật khẩu");
                mail.Body    = "Mật khẩu của bạn là 123456!!\nVui lòng đổi mật khẩu lại ngay!!";

                smtpServer.Port        = 587;
                smtpServer.Credentials = new NetworkCredential("*****@*****.**", "ngocsonvipro456");
                smtpServer.EnableSsl   = true;
                nvdao.resetmatkhaunhanvien(manv);
                smtpServer.Send(mail);
                XtraMessageBox.Show("Gửi email thành công đến: " + nvdao.getEmailcuanhanvien(manv));
            }
            catch
            {
                XtraMessageBox.Show("Lổi xảy ra trong quá trình gửi mail");
            }
        }
Exemplo n.º 3
0
        public void SetCategoryViewBagNV(string manv = null)
        {
            var dao          = new NhanvienDao();
            var listCategory = dao.GetListActiveNV();

            ViewBag.NHANVIEN = new SelectList(listCategory, "TEN_NHANVIEN", "TEN_NHANVIEN", manv);
        }
Exemplo n.º 4
0
        public void loaddatabase()
        {
            HopDongDao  hd  = new HopDongDao();
            NhanvienDao nvd = new NhanvienDao();

            hopDongsBindingSource.DataSource = hd.loadtheoyeucau(nvd.getchucvutunhanvien(manvhientai), manvhientai);
        }
        private void FormThemNhanVien_Load(object sender, EventArgs e)
        {
            loadcomboboxMaCVvacomboboxQuyenhanvacomboboxMaNVQL();
            NhanvienDao nvdao = new NhanvienDao();

            txtMaNV.Text = nvdao.getlastnhanvien();
        }
        private void cboTenCV_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Trưởng phòng xuống nhân viên
            if (macvhientai == "TP" && cboTenCV.SelectedIndex == 0)
            {
                NhanvienDao nvdao = new NhanvienDao();
                cboMaNVQL.Enabled = true;
                loadlaicomboboxMaNVQL();
                if (nvdao.checkxemconhanviennaoconchiuqlcuaTP(txtMaNV.Text) != 0)
                {
                    btnChuyenNVcuaTruongPhong.Visible = true;
                }
            }

            if (macvhientai == "TP" && cboTenCV.SelectedIndex == 1)
            {
                cboMaNVQL.Enabled = false;
                cboMaNVQL.Text    = gridView2.GetFocusedRowCellValue(colMaNVQL).ToString();
                btnChuyenNVcuaTruongPhong.Visible = false;
            }

            //Nhân viên lên trưởng phòng
            if (macvhientai == "NV" && cboTenCV.SelectedIndex == 1)
            {
                cboMaNVQL.Text = "NV0001";
            }
            if (macvhientai == "NV" && cboTenCV.SelectedIndex == 0)
            {
                cboMaNVQL.Text = gridView2.GetFocusedRowCellValue(colMaNVQL).ToString();
            }
        }
Exemplo n.º 7
0
        public void ImportNV(string tennv, string email, string sdt, string gioitinh, string diachi, DateTime ngaysinh)
        {
            NhanvienDao nvdao = new NhanvienDao();
            NhanVien    nv    = new NhanVien();

            nv.MaNV = nvdao.getlastnhanvien();
            if (nvdao.getchucvutunhanvien(manvhientai) == "QL")
            {
                nv.MaCV = "TP";
            }
            else
            {
                nv.MaCV = "NV";
            }

            nv.TenNV = tennv;
            nv.Email = email;
            nv.Sdt   = sdt;
            bool gioitinhbool = true;

            if (gioitinh == "Nữ")
            {
                gioitinhbool = false;
            }
            nv.GioiTinh   = gioitinhbool;
            nv.DiaChi     = diachi;
            nv.MaNVQuanLi = manvhientai;
            nv.MatKhau    = MahoaMD5.getMd5Hash("123456");
            nv.NgaySinh   = ngaysinh;
            nv.Status     = true;
            db.NhanViens.Add(nv);
            db.SaveChanges();
        }
Exemplo n.º 8
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            if (txtHoTenNV.Text == "" || txtemail.Text == "" || txtDiaChi.Text == "" || txtSdt.Text == "" || dtngaysinh.Text == "")
            {
                XtraMessageBox.Show("Hãy điền đầy đủ thông tin!");
            }
            else
            {
                NhanVien    nv    = new NhanVien();
                NhanvienDao nvdao = new NhanvienDao();
                nv.MaNV = txtMaNV.Text;

                string macv = db.ChucVus.Where(p => p.TenCV == cboQuyenHan.Text).Select(l => l.MaCV).SingleOrDefault();
                nv.MaCV  = macv;
                nv.TenNV = txtHoTenNV.Text;
                bool gioitinh = true;
                if (cboGioiTinh.Text != "Nam")
                {
                    gioitinh = false;
                }
                nv.GioiTinh   = gioitinh;
                nv.NgaySinh   = dtngaysinh.DateTime;;
                nv.MaNVQuanLi = txtMaNVQL.Text;
                nv.DiaChi     = txtDiaChi.Text;
                nv.Sdt        = txtSdt.Text;;
                nv.MatKhau    = "123456";
                nv.Email      = txtemail.Text;
                nv.Status     = true;
                nvdao.themnhanvien(nv);
                XtraMessageBox.Show("Thêm thành công");
                f.loadlaigridview();
                this.Close();
            }
        }
        private void gridControl2_Click(object sender, EventArgs e)
        {
            txtMaHD.Text    = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaHD").ToString();
            cboMaGoiHD.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaGoiHD").ToString();
            cboMaChuKy.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaChuKy").ToString();
            txtMaNV.Text    = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaNV").ToString();
            cboMaKH.Text    = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaKHChinh").ToString();

            string   ngayhieuluc  = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NgayHieuLuc").ToString();
            DateTime ngaysinhnhat = DateTime.Parse(ngayhieuluc);

            dtmNgayHieuLuc.DateTime = ngaysinhnhat;

            txtMucPhi.Text         = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GoiHopDong.MucPhi").ToString();
            txtGiaTriBaoHiem.Text  = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GoiHopDong.GiaTriBaoHiem").ToString();
            txtThoiHanBaoHiem.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GoiHopDong.ThoiHanBaoHiem").ToString();
            //txtThoiHanDongPhi.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GoiHopDong.ThoiHanDongPhi").ToString();

            NhanvienDao nvdao = new NhanvienDao();

            if (nvdao.getchucvutunhanvien(manvhientai) == "QL" || nvdao.getchucvutunhanvien(manvhientai) == "TP")
            {
                btnSua.Visible = false;
                btnHuy.Visible = false;
            }
            else
            {
                btnSua.Visible = true;
                btnHuy.Visible = true;
            }
        }
Exemplo n.º 10
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                NhanvienDao nvdao    = new NhanvienDao();
                bool        gioitinh = true;
                if (cboGioiTinh.SelectedIndex == 1)
                {
                    gioitinh = false;
                }
                string macv = listchucvu.Where(p => p.TenCV == cboQuyenHan.Text).Select(l => l.MaCV).SingleOrDefault();

                nvdao.suanhanvien(txtMaNV.Text, macv, txtHoTenNV.Text, txtSdt.Text, gioitinh, txtDiaChi.Text, cboMaNVQL.Text, dtngaysinh.DateTime);

                XtraMessageBox.Show("Đã sửa thành công!!");
                loadlaigridview();
            }

            catch (Exception ex)
            {
                string   loi      = ex.InnerException.ToString();
                string[] loichia  = loi.Split('\n');
                string[] loichinh = loichia[0].Split(':');
                XtraMessageBox.Show(loichinh[2]);
            }
        }
        private void dgvKhachHang_Click(object sender, EventArgs e)
        {
            try
            {
                NhanvienDao nvdao = new NhanvienDao();
                if (nvdao.getchucvutunhanvien(manvhientai) == "QL" || nvdao.getchucvutunhanvien(manvhientai) == "TP")
                {
                    btnLuu.Visible = false;
                    btnHuy.Visible = false;
                }
                else
                {
                    enabletextbox();
                    btnLuu.Visible = true;
                    btnHuy.Visible = true;
                }

                if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GioiTinh").Equals(true))
                {
                    cboGioiTinh.Text = "Nam";
                }
                else
                {
                    cboGioiTinh.Text = "Nữ";
                }
                txtDiaChi.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DiaChi").ToString();
                txtMaKH.Text   = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaKH").ToString();
                txtTenKH.Text  = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "TenKH").ToString();
                cboTenCD.Text  = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "CapDo.TenCD").ToString();
                txtCMND.Text   = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "CMND").ToString();
                txtSdt.Text    = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "Sdt").ToString();
                var      ngaysinh = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NgaySinh").ToString();
                DateTime dateTime = DateTime.Parse(ngaysinh);
                dtmNgaySinh.Text = dateTime.ToString("dd/MM/yyyy");
                KhachHangDao kh     = new KhachHangDao();
                var          result = kh.getKH(txtMaKH.Text);
                if (result.HinhAnh != null)
                {
                    MemoryStream ms = new MemoryStream(result.HinhAnh);
                    imagebox.Image = Image.FromStream(ms);
                    ima            = result.HinhAnh;
                }
                else
                {
                    imagebox.Image = null;
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("Đã Có Lỗi Xảy Ra", "Thông Báo");
            }
        }
Exemplo n.º 12
0
        public void checkxemaidangsudung(string manvhientai2)
        {
            NhanvienDao nvdao = new NhanvienDao();

            if (nvdao.getchucvutunhanvien(manvhientai) == "QL" || nvdao.getchucvutunhanvien(manvhientai) == "TP")
            {
                btnThemKH.Enabled = false;
                btnUpdate.Enabled = false;
                btnXoa.Enabled    = false;
                btnExport.Enabled = true;
                settextboxchoadminvatruongphong();
            }
        }
        private void btLuu_Click(object sender, EventArgs e)
        {
            NhanvienDao nvdao    = new NhanvienDao();
            bool        gioitinh = true;

            if (rdioGioiTinh.SelectedIndex == 1)
            {
                gioitinh = false;
            }
            nvdao.suathongtincanhan(txtMaNV.Text, txtHoTenNV.Text, txtSdt.Text, gioitinh, txtDiaChi.Text, dtngaysinh.DateTime);

            XtraMessageBox.Show("Đã sửa thành công!!");
            f.tattab();
        }
Exemplo n.º 14
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            NhanvienDao nvdao    = new NhanvienDao();
            bool        gioitinh = true;

            if (cboGioiTinh.SelectedIndex == 1)
            {
                gioitinh = false;
            }
            string macv = listchucvu.Where(p => p.TenCV == cboQuyenHan.Text).Select(l => l.MaCV).SingleOrDefault();

            nvdao.suanhanvien(txtMaNV.Text, macv, txtHoTenNV.Text, txtSdt.Text, gioitinh, txtDiaChi.Text, cboMaNVQL.Text, dtngaysinh.DateTime);

            XtraMessageBox.Show("Đã sửa thành công!!");
            loadlaigridview();
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            NhanvienDao nvdao = new NhanvienDao();

            if (macvhientai == "TP" && cboTenCV.SelectedIndex == 0)
            {
                if (nvdao.checkxemconhanviennaoconchiuqlcuaTP(txtMaNV.Text) == 1)
                {
                    XtraMessageBox.Show("Bạn phải chuyển nhân viên quản lý cho những nhân viên được thay đổi!!");
                }
                else
                {
                    int sothutu = cboTenCV.SelectedIndex;

                    //NhanvienDao nvdao = new NhanvienDao();
                    nvdao.suachucvunhanvien(txtMaNV.Text, listchucvu[sothutu].MaCV, cboMaNVQL.Text);
                    XtraMessageBox.Show("Đã sửa thành công!!");
                    loaddatabse();


                    //claer
                    txtMaNV.Text      = "";
                    txtTenNV.Text     = "";
                    cboTenCV.Text     = "";
                    cboMaNVQL.Text    = "";
                    cboMaNVQL.Enabled = false;
                    btnChuyenNVcuaTruongPhong.Visible = false;
                }
            }

            else
            {
                int sothutu = cboTenCV.SelectedIndex;

                //NhanvienDao nvdao = new NhanvienDao();
                nvdao.suachucvunhanvien(txtMaNV.Text, listchucvu[sothutu].MaCV, cboMaNVQL.Text);
                XtraMessageBox.Show("Đã sửa thành công!!");
                loaddatabse();

                ////claer
                txtMaNV.Text      = "";
                txtTenNV.Text     = "";
                cboTenCV.Text     = "";
                cboMaNVQL.Text    = "";
                cboMaNVQL.Enabled = false;
            }
        }
        private void btnLuu_Click(object sender, EventArgs e)
        {
            int sothutu = cboTenCV.SelectedIndex;

            NhanvienDao nvdao = new NhanvienDao();

            nvdao.suachucvunhanvien(txtMaNV.Text, listchucvu[sothutu].MaCV, cboMaNVQL.Text);
            XtraMessageBox.Show("Đã sửa thành công!!");
            loaddatabse();

            //claer
            txtMaNV.Text      = "";
            txtTenNV.Text     = "";
            cboTenCV.Text     = "";
            cboMaNVQL.Text    = "";
            cboMaNVQL.Enabled = false;
        }
        private void btnThem_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtHoTenNV.Text == "" || txtemail.Text == "" || txtDiaChi.Text == "" || txtSdt.Text == "" || dtngaysinh.Text == "")
                {
                    XtraMessageBox.Show("Bạn chưa điền đầy đủ thông tin!");
                }
                else
                {
                    NhanVien    nv    = new NhanVien();
                    NhanvienDao nvdao = new NhanvienDao();
                    nv.MaNV = txtMaNV.Text;

                    string macv = db.ChucVus.Where(p => p.TenCV == cboQuyenHan.Text).Select(l => l.MaCV).SingleOrDefault();
                    nv.MaCV  = macv;
                    nv.TenNV = txtHoTenNV.Text;
                    bool gioitinh = true;
                    if (cboGioiTinh.Text != "Nam")
                    {
                        gioitinh = false;
                    }
                    nv.GioiTinh   = gioitinh;
                    nv.NgaySinh   = dtngaysinh.DateTime;;
                    nv.MaNVQuanLi = txtMaNVQL.Text;
                    nv.DiaChi     = txtDiaChi.Text;
                    nv.Sdt        = txtSdt.Text;;
                    nv.MatKhau    = MahoaMD5.getMd5Hash("123456");
                    nv.Email      = txtemail.Text;
                    nv.Status     = true;
                    nvdao.themnhanvien(nv);
                    XtraMessageBox.Show("Thêm thành công");
                    f.loadlaigridview();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                string   loi      = ex.InnerException.ToString();
                string[] loichia  = loi.Split('\n');
                string[] loichinh = loichia[0].Split(':');
                XtraMessageBox.Show(loichinh[2]);
            }
        }
Exemplo n.º 18
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (txtMaNV.Text == "")
     {
         XtraMessageBox.Show("Bạn chưa chọn dòng!!");
     }
     else
     {
         DialogResult dialogResult = XtraMessageBox.Show("Xác nhận", "Bạn thực sự muốn xóa?", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.Yes)
         {
             NhanvienDao nvdao = new NhanvienDao();
             nvdao.xoanhanvien(txtMaNV.Text);
             XtraMessageBox.Show("Đã xóa thành công!!");
             loadlaigridview();
             resettextbox();
         }
     }
 }
Exemplo n.º 19
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            NhanvienDao nvdao = new NhanvienDao();

            nvdao.suaMaNVQLCustom(txtMaNV.Text, cboMaNVQL.Text);
            XtraMessageBox.Show("Thay đổi thành công");
            refreshgridview();

            loaddanhsach(manvqlhientai);
            if (dsnhanviencanchuyenTP.Count == 0)
            {
                DialogResult dialogResult = XtraMessageBox.Show("Bạn đã có thể chuyển chức vụ cho nhân viên " + manvqlhientai, "Thông báo", MessageBoxButtons.OK);
                if (dialogResult == DialogResult.OK)
                {
                    f.loaddatabse();

                    this.Close();
                }
            }
        }
Exemplo n.º 20
0
 private void btnXoa_Click(object sender, EventArgs e)
 {
     if (txtMaHD.Text == "")
     {
         XtraMessageBox.Show("Bạn chưa chọn dòng!!");
     }
     else
     {
         DialogResult dialogResult = XtraMessageBox.Show("Xác nhận", "Bạn thực sự muốn xóa?", MessageBoxButtons.YesNo);
         if (dialogResult == DialogResult.Yes)
         {
             HopDongDao  hd  = new HopDongDao();
             NhanvienDao nvd = new NhanvienDao();
             hd.XoaHD(txtMaHD.Text);
             XtraMessageBox.Show("Đã xóa thành công!!");
             hopDongsBindingSource.DataSource = hd.loadtheoyeucau(nvd.getchucvutunhanvien(manvhientai), manvhientai);
             reset();
         }
     }
 }
Exemplo n.º 21
0
 private void simpleButton1_Click(object sender, EventArgs e)
 {
     if (txtTaikhoan.Text == "")
     {
         XtraMessageBox.Show("Vui lòng nhập đủ thông tin");
     }
     else
     {
         NhanvienDao nvdao = new NhanvienDao();
         if (nvdao.kiemtrataikhoantontai(txtTaikhoan.Text) == false)
         {
             XtraMessageBox.Show("Tên tài khoản không tồn tại!!");
         }
         else
         {
             EmailSupport emailsp = new EmailSupport();
             emailsp.guiemail(txtTaikhoan.Text);
             this.Close();
         }
     }
 }
Exemplo n.º 22
0
        public void thembangtuongung(string manv)
        {
            NhanvienDao nvdao = new NhanvienDao();
            string      macv  = nvdao.getchucvutunhanvien(manv);

            if (macv == "QL")
            {
                cboTenBang.Properties.Items.Add("Nhân viên");
            }
            else
            {
                if (macv == "TP")
                {
                    cboTenBang.Properties.Items.Add("Nhân viên");
                }
                else
                {
                    cboTenBang.Properties.Items.Add("Khách hàng");
                    cboTenBang.Properties.Items.Add("Hợp đồng");
                }
            }
        }
        public void guiemail(string manv)
        {
            try
            {
                NhanvienDao nvdao     = new NhanvienDao();
                MailMessage mail      = new MailMessage();
                Random      rd        = new Random();
                int         pass      = rd.Next(111111, 999999);
                string      emailnv   = nvdao.getEmailcuanhanvien(manv);
                string[]    emailchia = emailnv.Split('@');
                char[]      bentrai   = emailchia[0].ToArray();

                for (int i = 0; i < (int)(bentrai.Length / 2); i++)
                {
                    bentrai[i] = '*';
                }
                string passdache = new string(bentrai) + "@" + emailchia[1];

                //Server mail của Google
                SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
                mail.From = new MailAddress("*****@*****.**");
                // Email cần đến
                mail.To.Add(nvdao.getEmailcuanhanvien(manv));
                mail.Subject = ("Thông báo mật khẩu");
                mail.Body    = "Mật khẩu của bạn là " + pass + "!!\nVui lòng đổi mật khẩu lại ngay!!";

                smtpServer.Port        = 587;
                smtpServer.Credentials = new NetworkCredential("*****@*****.**", "ngocsonvipro456");
                smtpServer.EnableSsl   = true;
                nvdao.resetmatkhaunhanvien(manv, pass.ToString());
                smtpServer.Send(mail);
                XtraMessageBox.Show("Gửi email thành công đến: " + passdache);
            }
            catch
            {
                XtraMessageBox.Show("Lổi xảy ra trong quá trình gửi mail");
            }
        }
Exemplo n.º 24
0
 private void btnSua_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtMaHD.Text == "" || cboMaGoiHD.Text == "" || cboMaChuKy.Text == "" || cboMaKH.Text == "" || txtMaNV.Text == "" || dtmNgayHieuLuc.Text == "")
         {
             XtraMessageBox.Show("Điền Đầy Đủ Thông Tin", "Thông báo");
         }
         else
         {
             HopDongDao  hd  = new HopDongDao();
             NhanvienDao nvd = new NhanvienDao();
             hd.SuaHD(txtMaHD.Text, cboMaGoiHD.Text, cboMaChuKy.Text, txtMaNV.Text, cboMaKH.Text, dtmNgayHieuLuc.DateTime);
             XtraMessageBox.Show("Sửa thành công", "Thông báo");
             hopDongsBindingSource.DataSource = hd.loadtheoyeucau(nvd.getchucvutunhanvien(manvhientai), manvhientai);
             txtGiaTriBaoHiem.Text            = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GoiHopDong.GiaTriBaoHiem").ToString();
         }
     }
     catch (Exception ex)
     {
         XtraMessageBox.Show("Có lỗi xảy ra", "Thông báo");
     }
 }
Exemplo n.º 25
0
        public void loaddanhsach(string manvql)
        {
            NhanvienDao nvdao = new NhanvienDao();

            dsnhanviencanchuyenTP = nvdao.danhsachnhanviencuaTP(manvql);
        }
Exemplo n.º 26
0
        private void gridControl2_Click(object sender, EventArgs e)
        {
            if (gridView1.RowCount > 0)
            {
                if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaHD") == null)
                {
                    txtMaHD.Text = "";
                }
                else
                {
                    txtMaHD.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaHD").ToString();
                }

                if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaGoiHD") == null)
                {
                    cboMaGoiHD.Text = "";
                }
                else
                {
                    cboMaGoiHD.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaGoiHD").ToString();
                }

                if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaChuKy") == null)
                {
                    cboMaChuKy.Text = "";
                }
                else
                {
                    cboMaChuKy.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaChuKy").ToString();
                }

                if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaNV") == null)
                {
                    txtMaNV.Text = "";
                }
                else
                {
                    txtMaNV.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaNV").ToString();
                }

                if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaKHChinh") == null)
                {
                    cboMaKH.Text = "";
                }
                else
                {
                    cboMaKH.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaKHChinh").ToString();
                }

                if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NgayHieuLuc") == null)
                {
                    dtmNgayHieuLuc.Text = "";
                }
                else
                {
                    string   ngayhieuluc  = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "NgayHieuLuc").ToString();
                    DateTime ngaysinhnhat = DateTime.Parse(ngayhieuluc);
                    dtmNgayHieuLuc.DateTime = ngaysinhnhat;
                }

                if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GoiHopDong.MucPhi") == null)
                {
                    txtMucPhi.Text = "";
                }
                else
                {
                    txtMucPhi.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GoiHopDong.MucPhi").ToString();
                }

                if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GoiHopDong.GiaTriBaoHiem") == null)
                {
                    txtGiaTriBaoHiem.Text = "";
                }
                else
                {
                    txtGiaTriBaoHiem.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GoiHopDong.GiaTriBaoHiem").ToString();
                }

                if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GoiHopDong.ThoiHanBaoHiem") == null)
                {
                    txtThoiHanBaoHiem.Text = "";
                }
                else
                {
                    txtThoiHanBaoHiem.Text = gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "GoiHopDong.ThoiHanBaoHiem").ToString();
                }


                NhanvienDao nvdao = new NhanvienDao();
                if (nvdao.getchucvutunhanvien(manvhientai) == "QL" || nvdao.getchucvutunhanvien(manvhientai) == "TP" || gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "MaHD") == null)
                {
                    btnSua.Visible = false;
                    btnHuy.Visible = false;
                }
                else
                {
                    dtmNgayHieuLuc.Enabled = true;
                    cboMaChuKy.Enabled     = true;
                    cboMaGoiHD.Enabled     = true;
                    cboMaKH.Enabled        = true;



                    btnSua.Visible = true;
                    btnHuy.Visible = true;
                }
            }
            else
            {
                XtraMessageBox.Show("Không có gì để hiện thị!!!");
            }
        }