public void XoaChiTietBienDong(int id)
 {
     DAL.BHBIENDONGBAOHIEM bdbh = new QuanLyBienDongBaoHiemController().GetBienDongBaoHiemByID(id);
     new QuanLyBienDongBaoHiemController().DeleteBienDongBaoHiem(bdbh);
     //Dialog.ShowNotification("Thông báo", "Đã xoá thành công");
     //grpChiTietNhanVien.Reload();
     //grpBienDongBaoHiem.Reload();
 }
    [DirectMethod] //khi kích vào nút sửa, tự động load dữ liệu biến động
    public void loadThongTinBienDong()
    {              // thay đổi title icon windown
        wdThemSuaBienDongNhanVien.Title = "Sửa biến động cho nhân viên";
        wdThemSuaBienDongNhanVien.Icon  = Icon.Pencil;
        ChiTietNhanVienBienDongInfo bdbh = new QuanLyBienDongBaoHiemController().GetByIDBienDongBaoHiem(int.Parse(hdfChiTietID.Text));

        txtMaCanBo1.Text  = bdbh.MaNhanVien;
        txtHoTen1.Text    = bdbh.HoTen;
        dfNgaySinh1.Value = bdbh.NgaySinh;
        txtSoSoBHXH1.Text = bdbh.MaSo;
        // thông tin về truy thu thoái thu
        nfTruyThuBHXH.Text  = bdbh.TruyThuBHXH.ToString();
        nfTruyThuBHYT.Text  = bdbh.TruyThuBHYT.ToString();
        nfThoaiThuBHXH.Text = bdbh.ThoaiThuBHXH.ToString();
        nfThoaiThuBHYT.Text = bdbh.ThoaiThuBHYT.ToString();
        //thong tin nhan vien
        DAL.BHNHANVIEN_BAOHIEM hs = new NhanVien_BaoHiemController().GetNhanVien_BaoHiemByMaNhanVien(hdfMaNhanVien.Value.ToString());
        txtLuongDongBH1.Text      = hs.LuongBaoHiem.ToString();
        txtThoiGianDongBHXH1.Text = new BaoHiemController().ChuyenSoThangDongBH((int)hs.ThoiGianDongBaoHiem);
        // check
        chkBHTN1.SetValue(hs.DangDongBHTN);
        chkBHYT1.SetValue(hs.DangDongBHYT);
        chkBHXH1.SetValue(hs.DangDongBHXH);
        hdfIsBHXH.Text = hs.DangDongBHXH.ToString();
        hdfIsBHYT.Text = hs.DangDongBHYT.ToString();
        hdfIsBHTN.Text = hs.DangDongBHTN.ToString();

        //thông tin quy định biến động
        DAL.BHQUYDINHBIENDONG qdbd = new BHQUYDINHBIENDONGController().Lay1QuyDinhBienDong(bdbh.IDQuyDinhBienDong);
        //set 1 số id cho hiddenfield
        hdfIdNhanVien_BaoHiem.Text = hs.IDNhanVien_BaoHiem.ToString();
        hdfIDQuyDinhBienDong.Text  = qdbd.IDQuyDinhBienDong.ToString();
        hdfIDLoaiCheDo.Text        = qdbd.IDCheDoBaoHiem.ToString();
        hdfMaLoaiBienDong.Text     = qdbd.MaBienDong;
        tgfChonBienDong1.Text      = qdbd.TenBienDong;  //dt.Rows[0]["TenBienDong"].ToString();
        hdfMaLoaiBienDong.Text     = qdbd.MaBienDong;
        chkBHXH1.Checked           = (bool)qdbd.IsBHXH; // (bool)dt.Rows[0]["IsBHXH"];
        chkBHYT1.Checked           = (bool)qdbd.IsBHYT; // (bool)dt.Rows[0]["IsBHYT"];
        chkBHTN1.Checked           = (bool)qdbd.IsBHTN; // (bool)dt.Rows[0]["IsBHTN"];
        if (qdbd.IDCheDoBaoHiem != null)
        {
            hdfIDLoaiCheDo.Text = qdbd.IDCheDoBaoHiem.ToString();
            //       RM.RegisterClientScriptBlock("rlst", "#{cbbLoaiCheDo1_Store}.reload();");
        }
        hdfIDQuyDinhBienDong.Text = qdbd.IDQuyDinhBienDong.ToString();// dt.Rows[0]["IDQuyDinhBienDong"].ToString();


        txtLuongDongBHXHCu1.Text  = bdbh.TienLuongCu.ToString();
        txtPhuCapTNVKCu1.Text     = bdbh.PhuCapTNVKCu.ToString();
        txtPhuCapTNNCu1.Text      = bdbh.PhuCapNgheCu.ToString();
        txtPhuCapCVCu1.Text       = bdbh.PhuCapCVCu.ToString();
        txtLuongDongBHXHMoi1.Text = bdbh.TienLuongMoi.ToString();
        txtPhuCapCVMoi1.Text      = bdbh.PhuCapCVMoi.ToString();
        txtPhuCapTNNMoi1.Text     = bdbh.PhuCapTNNgheMoi.ToString();
        txtPhuCapTNVKMoi1.Text    = bdbh.PhuCapTNVKMoi.ToString();
        txtLuongDongBHXHMoi1.Text = bdbh.TienLuongMoi.ToString();
        //if (qdbd.LoaiAnhHuong == "TMD" || qdbd.LoaiAnhHuong == "GMD")
        //{
        //    RM.RegisterClientScriptBlock("rl10", "#{pnlThongTinLuong1}.enable();");//#{tabPanel1}.addTab(#{pnlThongTinLuong1});
        //}
        //else
        //{
        //    RM.RegisterClientScriptBlock("rl11", "#{pnlThongTinLuong1}.disable();");//#{tabPanel1}.closeTab(#{pnlThongTinLuong1}, 'hide');
        //}

        //if (qdbd.LoaiAnhHuong == "TruyThu" || qdbd.LoaiAnhHuong == "ThoaiThu")
        //{
        //    RM.RegisterClientScriptBlock("rl2", "#{pnlTruyThoaithu1}.enable();");//#{tabPanel1}.addTab(#{pnlThongTinLuong1});
        //}
        //else
        //{
        //    RM.RegisterClientScriptBlock("rl13", "#{pnlTruyThoaithu1}.disable();");//#{tabPanel1}.closeTab(#{pnlThongTinLuong1}, 'hide');
        //    //RM.RegisterClientScriptBlock("rl4", "#{tabPanel}.closeTab(#{pnlTruyThoaithu}, 'hide');");
        //}

        dfTuNgay1.Value = bdbh.TuNgay.Value;
        if (bdbh.DenNgay != null)
        {
            dfDenNgay1.Value = bdbh.DenNgay;
        }
        if (bdbh.ThangDangKy.HasValue)
        {
            dfNgayDangKyVoiCQBH.Value = bdbh.ThangDangKy.Value;
        }
        chkDaCoSo.Checked      = (bool)bdbh.DaCoSo;
        chkKhongTraThe.Checked = (bool)bdbh.KhongTraThe;
        txtDienGiai1.Text      = bdbh.DienGiai;
        //Thông tin chế độ.
    }
    //sự kiện cập nhật sửa
    protected void btnCapNhatSua_Click(object sender, DirectEventArgs e)
    {
        QuanLyBienDongBaoHiemController qlbd = new QuanLyBienDongBaoHiemController();
        BHBIENDONGBAOHIEM bdbh = qlbd.GetBienDongBaoHiemByID(int.Parse(hdfChiTietID.Text));

        bdbh.IDQuyDinhBienDong = int.Parse(hdfIDQuyDinhBienDong.Text);
        bdbh.TuNgay            = (DateTime)dfTuNgay1.Value;

        if (!SoftCore.Util.GetInstance().IsDateNull(dfDenNgay1.SelectedDate))
        {
            bdbh.DenNgay = (DateTime)dfDenNgay1.Value;
        }
        if (!SoftCore.Util.GetInstance().IsDateNull(dfNgayDangKyVoiCQBH.SelectedDate))
        {
            bdbh.ThangDangKy = (DateTime)dfNgayDangKyVoiCQBH.Value;
        }
        DAL.BHQUYDINHBIENDONG qdbd = new BHQUYDINHBIENDONGController().Lay1QuyDinhBienDong(bdbh.IDQuyDinhBienDong);
        bdbh.Loai = qdbd.LoaiAnhHuong;
        BHNHANVIEN_BAOHIEM hs = new NhanVien_BaoHiemController().GetNhanVien_BaoHiemByMaNhanVien(hdfMaNhanVien.Value.ToString());

        if (!string.IsNullOrEmpty(hs.LuongBaoHiem.ToString()))
        {
            txtLuongDongBHXHCu1.Text  = hs.LuongBaoHiem.ToString();
            txtLuongDongBHXHMoi1.Text = txtLuongDongBHXHCu1.Text;
        }
        if (!string.IsNullOrEmpty(hs.PhuCapCV.ToString()))
        {
            txtPhuCapCVCu1.Text  = hs.PhuCapCV.ToString();
            txtPhuCapCVMoi1.Text = txtPhuCapCVCu1.Text;
        }
        if (!string.IsNullOrEmpty(hs.PhuCapTNVK.ToString()))
        {
            txtPhuCapTNVKCu1.Text  = hs.PhuCapTNVK.ToString();
            txtPhuCapTNVKMoi1.Text = txtPhuCapTNVKCu1.Text;
        }
        if (!string.IsNullOrEmpty(hs.PhuCapTNN.ToString()))
        {
            txtPhuCapTNNCu1.Text  = hs.PhuCapTNN.ToString();
            txtPhuCapTNNMoi1.Text = txtPhuCapTNNCu1.Text;
        }
        if (qdbd.LoaiAnhHuong == "TMD" || qdbd.LoaiAnhHuong == "GMD")
        {
            bdbh.TienLuongCu     = txtLuongDongBHXHCu1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHCu1.Text.Replace('.', ','));
            bdbh.PhuCapTNVKCu    = txtPhuCapTNVKCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNVKCu1.Text.Replace('.', ','));
            bdbh.PhuCapNgheCu    = txtPhuCapTNNCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNNCu1.Text.Replace('.', ','));
            bdbh.PhuCapCVCu      = txtPhuCapCVCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapCVCu1.Text.Replace('.', ','));
            bdbh.TienLuongMoi    = txtLuongDongBHXHMoi1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHMoi1.Text.Replace('.', ','));
            bdbh.PhuCapCVMoi     = txtPhuCapCVMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapCVMoi1.Text.Replace('.', ','));
            bdbh.PhuCapTNNgheMoi = txtPhuCapTNNMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNNMoi1.Text.Replace('.', ','));
            bdbh.PhuCapTNVKMoi   = txtPhuCapTNVKMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNVKMoi1.Text.Replace('.', ','));
            bdbh.TienLuongMoi    = txtLuongDongBHXHMoi1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHMoi1.Text.Replace('.', ','));

            if (e.ExtraParams["Command"] == "Insert")
            {
                if (hdfMaLoaiBienDong.Text == "TMD" || hdfMaLoaiBienDong.Text == "GMD")
                {
                    UpdateNguocNhanVien_BaoHiem();
                }
            }
        }
        else if (qdbd.LoaiAnhHuong == "TruyThu")
        {
            bdbh.TruyThuBHXH = nfTruyThuBHXH.Text == "" ? 0 : Convert.ToDecimal(nfTruyThuBHXH.Text.Replace('.', ','));
            bdbh.TruyThuBHYT = nfTruyThuBHYT.Text == "" ? 0 : Convert.ToDecimal(nfTruyThuBHYT.Text.Replace('.', ','));
        }
        else if (qdbd.LoaiAnhHuong == "ThoaiThu")
        {
            bdbh.ThoaiThuBHYT = nfThoaiThuBHYT.Text == "" ? 0 : Convert.ToDecimal(nfThoaiThuBHYT.Text.Replace('.', ','));
            bdbh.ThoaiThuBHXH = nfThoaiThuBHXH.Text == "" ? 0 : Convert.ToDecimal(nfThoaiThuBHXH.Text.Replace('.', ','));
        }
        else
        {
            bdbh.TienLuongCu     = txtLuongDongBHXHCu1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHCu1.Text.Replace('.', ','));
            bdbh.PhuCapTNVKCu    = txtPhuCapTNVKCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNVKCu1.Text.Replace('.', ','));
            bdbh.PhuCapNgheCu    = txtPhuCapTNNCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNNCu1.Text.Replace('.', ','));
            bdbh.PhuCapCVCu      = txtPhuCapCVCu1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapCVCu1.Text.Replace('.', ','));
            bdbh.TienLuongMoi    = txtLuongDongBHXHMoi1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHMoi1.Text.Replace('.', ','));
            bdbh.PhuCapCVMoi     = txtPhuCapCVMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapCVMoi1.Text.Replace('.', ','));
            bdbh.PhuCapTNNgheMoi = txtPhuCapTNNMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNNMoi1.Text.Replace('.', ','));
            bdbh.PhuCapTNVKMoi   = txtPhuCapTNVKMoi1.Text == "" ? 0 : Convert.ToDecimal(txtPhuCapTNVKMoi1.Text.Replace('.', ','));
            bdbh.TienLuongMoi    = txtLuongDongBHXHMoi1.Text == "" ? 0 : Convert.ToDecimal(txtLuongDongBHXHMoi1.Text.Replace('.', ','));
        }

        bdbh.KhongTraThe = chkKhongTraThe.Checked;
        bdbh.DaCoSo      = chkDaCoSo.Checked;
        bdbh.DienGiai    = txtDienGiai1.Text;
        qlbd.UpdateBienDongBaoHiem(bdbh);

        //update tinh trangg dong cho nhan vien
        BHNHANVIEN_BAOHIEM nvbh = new NhanVien_BaoHiemController().GetNhanVien_BaoHiemByMaNhanVien(Convert.ToInt32(hdfIdNhanVien_BaoHiem.Text));

        nvbh.IDNhanVien_BaoHiem = Convert.ToInt32(hdfIdNhanVien_BaoHiem.Text);
        nvbh.DangDongBHXH       = chkBHXH1.Checked;
        nvbh.DangDongBHYT       = chkBHYT1.Checked;
        nvbh.DangDongBHTN       = chkBHTN1.Checked;
        new NhanVien_BaoHiemController().UpdateNhanVien_BaoHiem(nvbh);


        Dialog.ShowNotification("Thông báo", "Đã cập nhật thành công");
        if (e.ExtraParams["Close"] == "True")
        {
            wdThemSuaBienDongNhanVien.Hide();
        }
        grpChiTietNhanVien.Reload();
        grpBienDongBaoHiem.Reload();
    }