public void mnuXacNhanDiLam_Click(object sender, DirectEventArgs e)
 {
     try
     {
         foreach (var item in checkboxSelection.SelectedRows)
         {
             DAL.HoSoUngVien hsuv = new DAL.HoSoUngVien();
             hsuv.MaUngVien = int.Parse("0" + item.RecordID);
             if (e.ExtraParams["XacNhan"] == "TuChoi")
             {
                 hsuv.XacNhanDiLam = false;
             }
             else
             {
                 hsuv.XacNhanDiLam = true;
             }
             new HoSoUngVienController().XacNhanDiLam(hsuv);
         }
         checkboxSelection.ClearSelections();
         GridPanel1.Reload();
         btnChuyenTiep.Disabled     = true;
         btnRoiNgayDiLam.Disabled   = true;
         btnTinhTrangDiLam.Disabled = true;
     }
     catch (Exception ex)
     {
         Dialog.ShowError(ex.Message);
     }
 }
    protected void btnChuyenTiep_Click(object sender, DirectEventArgs e)
    {
        string type         = "";
        bool   datrungtuyen = false;
        HoSoUngVienController hosoungvien = new HoSoUngVienController();

        DAL.HoSoUngVien hsuv = new DAL.HoSoUngVien();
        if (Equals(hdfType.Text, "toList"))
        {
            type         = "";
            datrungtuyen = true;
        }
        else
        {
            if (Equals(hdfType.Text, "store"))
            {
                type = "store";
            }
            else
            {
                if (Equals(hdfType.Text, "black"))
                {
                    type = "black";
                }
            }
        }
        try
        {
            foreach (var item in checkboxSelection.SelectedRows)
            {
                hsuv.MaUngVien        = decimal.Parse("0" + item.RecordID);
                hsuv.BlackListOrStore = type;
                if (datrungtuyen == false)
                {
                    hsuv.GhiChu = txt_Chuyen_GhiChu.Text;
                    hsuv.MaLyDo = int.Parse("0" + hdfChuyen_LyDo.Text);
                }
                hosoungvien.ChuyenDanhSach(hsuv, datrungtuyen);
            }
            checkboxSelection.ClearSelections();
            GridPanel1.Reload();
            btnChuyenTiep.Disabled     = true;
            btnRoiNgayDiLam.Disabled   = true;
            btnTinhTrangDiLam.Disabled = true;
            Dialog.ShowNotification("Chuyển thành công!");
        }
        catch (Exception ex)
        {
            Dialog.ShowError("Lỗi xảy ra " + ex.Message);
        }
    }
    public void btn_ChuyenLichHenPV_Click(object sender, DirectEventArgs e)
    {
        try
        {
            LichPhongVanController lichphongvan = new LichPhongVanController();
            DAL.LichHenPhongVan    lpv          = new DAL.LichHenPhongVan();
            HoSoUngVienController  hosoungvien  = new HoSoUngVienController();
            DAL.HoSoUngVien        hsuv         = new DAL.HoSoUngVien();
            foreach (var item in RowSelectionModel3.SelectedRows)
            {
                lpv.FR_KEY      = decimal.Parse("0" + item.RecordID);
                lpv.CreatedBy   = CurrentUser.ID;
                lpv.CreatedDate = DateTime.Now;
                if (!df_NgayPhongVan.SelectedDate.ToString().Contains("0001"))
                {
                    lpv.LichHen = Convert.ToDateTime(df_NgayPhongVan.SelectedDate);
                }
                lpv.ThoiGian      = tf_GioPhongVan.Text;
                lpv.ThuTuPhongVan = int.Parse("0" + txt_ThuTuPhongVan.Text);
                lpv.VongPhongVan  = int.Parse("0" + txt_VongPhongVan.Text);
                lpv.GhiChu        = txt_ghichu.Text;
                lichphongvan.InsertByHoSoUngVien(lpv);
                hsuv.MaUngVien        = decimal.Parse("0" + item.RecordID);
                hsuv.BlackListOrStore = "";
                hosoungvien.ChuyenDanhSach(hsuv, false);
            }

            wdChuyenLichHenPV.Hide();
            GridPanel1.Reload();
            RowSelectionModel3.ClearSelections();
            btnDelete.Disabled = true;
            btnEdit.Disabled   = true;
            btnNext.Disabled   = true;
            btnPrint.Disabled  = true;
            Dialog.ShowNotification("Chuyển thành công!");
        }
        catch (Exception ex)
        {
            Dialog.ShowError("Thông báo", "Có lỗi xảy ra: " + ex.Message);
        }
    }
    public void btnChuyenTiep_Click(object sender, DirectEventArgs e)
    {
        string type         = "";
        bool   datrungtuyen = false;
        HoSoUngVienController hosoungvien = new HoSoUngVienController();

        DAL.HoSoUngVien hsuv = new DAL.HoSoUngVien();
        if (e.ExtraParams["type"] == "toList")
        {
            type         = "";
            datrungtuyen = true;
        }
        else
        {
            if (e.ExtraParams["type"] == "toDaTrungTuyen")
            {
                type = "DaTrungTuyen";
                hsuv.DaTrungTuyen = true;
                datrungtuyen      = true;
            }
            else
            {
                if (Equals(hdfType.Text, "store"))
                {
                    type = "black";
                }
                else
                {
                    if (Equals(hdfType.Text, "black"))
                    {
                        type = "store";
                    }
                }
            }
        }
        try
        {
            foreach (var item in RowSelectionModel3.SelectedRows)
            {
                hsuv.MaUngVien        = decimal.Parse("0" + item.RecordID);
                hsuv.BlackListOrStore = type;
                if (datrungtuyen == false)
                {
                    hsuv.MaLyDo = int.Parse("0" + hdfChuyen_LyDo.Text);
                    hsuv.GhiChu = txt_Chuyen_GhiChu.Text;
                }
                hsuv.XacNhanDiLam = null;
                hosoungvien.ChuyenDanhSach(hsuv, datrungtuyen);
            }
            wdChuyenLyDo.Hide();
            GridPanel1.Reload();
            RowSelectionModel3.ClearSelections();
            btnDelete.Disabled = true;
            btnEdit.Disabled   = true;
            btnNext.Disabled   = true;
            btnPrint.Disabled  = true;
            Dialog.ShowNotification("Chuyển thành công!");
        }
        catch (Exception ex)
        {
            Dialog.ShowError("Thông báo", "Có lỗi xảy ra: " + ex.Message);
        }
    }
    protected void btn_UpdateUngVien_Click(object sender, DirectEventArgs e)
    {
        try
        {
            SoftCore.Util         util        = new Util();
            LinqProvider          linq        = new LinqProvider();
            HoSoUngVienController hosoungvien = new HoSoUngVienController();
            DAL.HoSoUngVien       hsuv        = new DAL.HoSoUngVien();
            if (string.IsNullOrEmpty(fufUploadControl.FileName) == false)
            {
                hsuv.Anh = hdfImageFolder.Text + "/" + fufUploadControl.FileName;
            }
            hsuv.Ten = txt_tenungvien.Text;
            // lấy họ và đệm từ họ tên
            int position = hsuv.Ten.LastIndexOf(' ');
            if (position == -1)
            {
                hsuv.Ten = hsuv.Ten;
            }
            else
            {
                hsuv.Ten   = txt_tenungvien.Text.Substring(position + 1).Trim();
                hsuv.HoDem = txt_tenungvien.Text.Remove(position).Trim();
            }
            hsuv.MaUngVien = decimal.Parse("0" + hdfRecordID.Text.ToString());
            hsuv.SoCMT     = txt_socmnd.Text.Replace("-", "");
            hsuv.SoCMT     = hsuv.SoCMT.Trim();
            hsuv.HoTen     = txt_tenungvien.Text.Trim();
            if (!util.IsDateNull(df_ngaysinh.SelectedDate))
            {
                hsuv.NgaySinh = df_ngaysinh.SelectedDate;
            }
            hsuv.GioiTinh           = cbx_gioitinh.SelectedItem.Value;
            hsuv.HoKhauThuongTru    = txt_hokhau.Text.Trim();
            hsuv.NoiSinh            = txt_noisinh.Text.Trim();
            hsuv.MaTinhTrangHonNhan = hdfTinhTrangHN.Text;
            hsuv.MaTinhTrangSucKhoe = hdfTinhTrangSK.Text;
            hsuv.MaQuocTich         = hdfQuocTich.Text;
            hsuv.DiDong             = txt_didong.Text;
            if (!df_ngaycapcmnd.SelectedDate.ToString().Contains("0001"))
            {
                hsuv.NgayCapCMT = df_ngaycapcmnd.SelectedDate;
            }
            hsuv.MaTinhThanh       = hdfTinhThanh.Text;
            hsuv.MaDanToc          = hdfDanToc.Text;
            hsuv.Email             = txt_email.Text.Trim();
            hsuv.MaTonGiao         = hdfTonGiao.Text;
            hsuv.NoiCapCMT         = hdfNoiCapCMND.Text;
            hsuv.DiaChiLienHe      = txt_diachilhe.Text.Trim();
            hsuv.KinhNghiem        = txt_kinhnghiem.Text.Trim();
            hsuv.MucLuongMongMuon  = decimal.Parse("0" + txt_mucluongmongmuon.Text.Trim());
            hsuv.MucLuongToiThieu  = decimal.Parse("0" + txt_mucluongtoithieu.Text.Trim());
            hsuv.MaTrinhDoVH       = hdfTrinhDoVanHoa.Text;
            hsuv.MaTrinhDoTinHoc   = hdfTrinhDoTinHoc.Text;
            hsuv.MaTrinhDoNgoaiNgu = hdfTrinhDoNgoaiNgu.Text;
            hsuv.MaChuyenNganh     = hdfChuyenNganh.Text;
            hsuv.MaTruongDaoTao    = hdfTruongDaoTao.Text;
            hsuv.MaTrinhDoHocVan   = hdfTrinhDo.Text;
            hsuv.MaViTriCongViec   = hdfCongViec.Text;
            hsuv.SoThich           = txt_sothich.Text.Trim();
            hsuv.UuDiem            = txt_uudiem.Text.Trim();
            hsuv.NhuocDiem         = txt_nhuocdiem.Text.Trim();
            hsuv.BlackListOrStore  = "";
            hsuv.MaLyDo            = int.Parse("0" + hdfLyDo.Text);
            hsuv.MaDotTuyenDung    = int.Parse("0" + hdfDotTuyenDung.Text);
            hsuv.DTCoDinh          = txt_dienthoaicodinh.Text.Trim();
            hsuv.NhomMau           = hdfNhomMau.Text;
            hsuv.ChieuCao          = txt_chieucao.Text.Trim();
            hsuv.CanNang           = txt_cannang.Text.Trim();
            hsuv.GhiChu            = txt_ghichu.Text.Trim();
            hsuv.NguoiLienHeTrongTruongHopKhanCap = txt_nguoilienhe.Text.Trim();
            hsuv.DienThoaiNguoiLienHe             = txt_sdtnguoilh.Text.Trim();
            hsuv.DiaChiNguoiLienHe = txt_diachinguoilienhe.Text.Trim();
            hsuv.EmailNguoiLienHe  = txt_emailnguoilh.Text.Trim();
            hsuv.QuanHeVoiUngVien  = txt_MoiQH.Text.Trim();
            //["67","KN"]
            string   _khanang = mcb_KhaNang.SelectedItems.ValuesToJsonArray();
            string[] split    = _khanang.Split(new Char[] { '[', ']', ' ', '"' });
            _khanang = "";
            foreach (string s in split)
            {
                if (s.Trim() != "")
                {
                    _khanang += s;
                }
            }
            hsuv.MaKhaNang = _khanang;
            if (!util.IsDateNull(df_ngaycothedilam.SelectedDate))
            {
                hsuv.NgayCoTheDiLam = df_ngaycothedilam.SelectedDate;
            }
            if (Equals(type, "black"))
            {
                hsuv.BlackListOrStore = "black";
            }
            else
            {
                if (Equals(type, "store"))
                {
                    hsuv.BlackListOrStore = "store";
                }
            }
            if (!df_ngaynophs.SelectedDate.ToString().Contains("0001"))
            {
                hsuv.NgayNopHS = df_ngaynophs.SelectedDate;
            }
            if (int.Parse("0" + DataHandler.GetInstance().ExecuteScalar("KiemTraTonTaiCMND", "@maungvien", "@cmnd", hsuv.MaUngVien, hsuv.SoCMT).ToString()) == 1)
            {
                X.Msg.Alert("Có lỗi dữ liệu xảy ra", "Đã tồn tại số Chứng minh nhân dân trong Danh sách Hồ sơ nhân sự").Show();
                txt_socmnd.Focus();
            }
            else
            {
                if (int.Parse("0" + DataHandler.GetInstance().ExecuteScalar("KiemTraTonTaiCMND", "@maungvien", "@cmnd", hsuv.MaUngVien, hsuv.SoCMT).ToString()) == 2)
                {
                    X.Msg.Alert("Có lỗi dữ liệu xảy ra", "Đã tồn tại số Chứng minh nhân dân trong Danh sách ứng viên").Show();
                    txt_socmnd.Focus();
                }
                else
                {
                    if (e.ExtraParams["Command"] == "Edit")
                    {
                        hosoungvien.Update(hsuv);
                        wdAddUngVien.Hide();
                        Dialog.ShowNotification("Cập nhật dữ liệu thành công!");
                    }
                    else
                    {
                        hosoungvien.Insert(hsuv);
                        X.Js.Call("ResetWdAddUngVien");
                        Dialog.ShowNotification("Thêm mới thành công!");
                    }

                    if (e.ExtraParams["Close"] == "True")
                    {
                        wdAddUngVien.Hide();
                    }
                    // reload
                    if (AfterUpdate != null)
                    {
                        AfterUpdate(sender, e);
                    }
                }
            }
        }
        catch (SqlException sql)
        {
            X.Msg.Alert("Có lỗi dữ liệu xảy ra", sql.Message).Show();
        }
        catch (Exception ex)
        {
            X.Msg.Alert("Có lỗi xảy ra", ex.Message).Show();
        }
    }