private void save_grid_to_database()
    {
        US_DM_BILL v_us_dm_bill;
        GridViewRow[] v_arr_gvr = new GridViewRow[m_grv_dm_bill.Rows.Count];
        System.Web.UI.WebControls.TextBox v_txt_so_bill;
        System.Web.UI.WebControls.TextBox v_txt_ma_phong_ban;
        System.Web.UI.WebControls.TextBox v_txt_nguoi_nhan;
        System.Web.UI.WebControls.TextBox v_txt_nguoi_gui;
        System.Web.UI.WebControls.TextBox v_txt_noi_nhan;
        System.Web.UI.WebControls.TextBox v_txt_noi_dung_gui;
        System.Web.UI.WebControls.TextBox v_txt_noi_ghi_chu;
        System.Web.UI.WebControls.RadioButton v_rdb_trong_nuoc;
        //eWorld.UI.CalendarPopup v_dat_ngay_gui;
        m_grv_dm_bill.Rows.CopyTo(v_arr_gvr, 0);

        //Phải chia nhỏ để insert nếu số lượng bản ghi lớn

        int start_number = 0; //vị trí bản ghi bắt đầu insert
        int numbers_record_limited = v_arr_gvr.Length; // số bản ghi được insert k vượt quá 50
        //int numbers_record_remain = v_arr_gvr.Length; //số bản ghi còn lại sau mỗi lần insert

        //while (numbers_record_remain >= 0)
        //{
        //    if (numbers_record_remain - 50 > 0)
        //        numbers_record_limited = 50;
        //    else
        //        numbers_record_limited = numbers_record_remain;
        for (int i = start_number; i < numbers_record_limited; i++)
        {
            v_txt_so_bill = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_so_bill_grid");
            v_txt_ma_phong_ban = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_ma_phong_ban_grid");
            v_txt_nguoi_nhan = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_nguoi_nhan_grid");
            v_txt_nguoi_gui = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_nguoi_gui_grid");
            v_txt_noi_nhan = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_noi_nhan_grid");
            v_txt_noi_dung_gui = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_noi_dung_grid");
            v_txt_noi_ghi_chu = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_ghi_chu_grid");
            v_rdb_trong_nuoc = (System.Web.UI.WebControls.RadioButton)v_arr_gvr[i].FindControl("m_rdb_trong_nuoc");
            //v_dat_ngay_gui = (eWorld.UI.CalendarPopup)v_arr_gvr[i].FindControl("m_dat_ngay_gui");
            System.Web.UI.WebControls.TextBox v_txt_ngay_gui = (System.Web.UI.WebControls.TextBox)v_arr_gvr[i].FindControl("m_txt_ngay_gui_grid");

            US_DM_PHONG_BAN v_us_dm_phong_ban = new US_DM_PHONG_BAN();
            DS_DM_PHONG_BAN v_ds_dm_phong_ban = new DS_DM_PHONG_BAN();
            // chỗ này kiêm tra điêu kiên phân quyen du lieu
            // chi cho luu du lieu cua phong ban duoc phan quyen

            //em bỏ check ơr ma phong ban roi
            if (CIPConvert.ToDecimal(m_hdf_so_ban_ghi.Value) == m_grv_dm_bill.PageIndex) return;
            v_us_dm_phong_ban.FillDataset(v_ds_dm_phong_ban, "where id=" + CIPConvert.ToDecimal(m_hdf_id_trung_tam.Value));
            if (v_ds_dm_phong_ban.DM_PHONG_BAN.Count < 1) continue;
            else
            {
                v_us_dm_bill = new US_DM_BILL();
                //v_us_dm_bill.BeginTransaction();
                v_us_dm_bill.dcID_PHONG_BAN = CIPConvert.ToDecimal(v_ds_dm_phong_ban.DM_PHONG_BAN[0][0]);
                v_us_dm_bill.dcID_TRANG_THAI = CONST_ID_TRANG_THAI_THU.ID_DA_NHAN_NOI_BO;
                v_us_dm_bill.strSO_BILL = v_txt_so_bill.Text.Trim();
                v_us_dm_bill.strGHI_CHU = v_txt_noi_ghi_chu.Text.Trim();
                v_us_dm_bill.strNGUOI_GUI = v_txt_nguoi_gui.Text.Trim();
                v_us_dm_bill.strNGUOI_NHAN = v_txt_nguoi_nhan.Text.Trim();
                v_us_dm_bill.strNOI_NHAN = v_txt_noi_nhan.Text.Trim();
                v_us_dm_bill.strNOI_DUNG = v_txt_noi_dung_gui.Text.Trim();
                //v_us_dm_bill.datNGAY_GUI = v_dat_ngay_gui.SelectedDate;
                v_us_dm_bill.datNGAY_GUI = CIPConvert.ToDatetime(v_txt_ngay_gui.Text.Trim(), "dd/MM/yyyy");
                if (v_rdb_trong_nuoc.Checked == true)
                {
                    v_us_dm_bill.strTRONG_NUOC = "x";
                    v_us_dm_bill.SetNUOC_NGOAINull();
                }
                else
                {
                    v_us_dm_bill.SetTRONG_NUOCNull();
                    v_us_dm_bill.strNUOC_NGOAI = "x";
                }
                v_us_dm_bill.Insert();
                thong_bao("Đã import thành công " + (m_grv_dm_bill.PageIndex + 1) + "/" + m_grv_dm_bill.PageCount, true);
            }
            //}
            //if (numbers_record_limited == 50)
            //    start_number = start_number + 50; // lấy vị trí bản ghi tiếp theo sẽ dc insert nếu còn
            //numbers_record_remain = numbers_record_remain - 50; // tính số bản ghi còn lại chưa insert
        }
        m_grv_dm_bill.PageIndex = m_grv_dm_bill.PageIndex + 1;
        if (CIPConvert.ToDecimal(m_hdf_so_ban_ghi.Value) == m_grv_dm_bill.PageIndex)
        {
            m_grv_dm_bill.DataSource = null;
            m_grv_dm_bill.Visible = false;
        }
        m_grv_dm_bill.DataBind();
    }
        private void add_danh_sach_du_lieu()
        {
            US_DM_BILL v_us_dm_bill = new US_DM_BILL();
            DS_DM_BILL v_ds_dm_bill = new DS_DM_BILL();
            try
            {
                m_lbl_loading.Visible = true;
                v_us_dm_bill.BeginTransaction();
                for (int v_int_row = m_fg_load_file.Rows.Fixed; v_int_row <= m_fg_load_file.Rows.Count - 1; v_int_row++)
                {
                    //IFormatProvider theCultureInfo = new System.Globalization.CultureInfo("en-GB", true);

                    //DateTime theDateTime = DateTime.ParseExact(abc, "mm-dd-yyyy", theCultureInfo);

                    v_us_dm_bill.strNOI_DUNG = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.NOI_DUNG]);
                    v_us_dm_bill.strNOI_NHAN = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.NOI_NHAN]);
                    v_us_dm_bill.strNGUOI_NHAN = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.NGUOI_NHAN]);
                    v_us_dm_bill.strTRONG_NUOC = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.TRONG_NUOC]);
                    v_us_dm_bill.strNUOC_NGOAI = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.NUOC_NGOAI]);
                    v_us_dm_bill.strSO_BILL = CIPConvert.ToStr(m_fg_load_file[v_int_row, (int)e_col_Number.SO_BILL]);
                    v_us_dm_bill.strNGUOI_GUI = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.NGUOI_GUI]);
                    v_us_dm_bill.datNGAY_GUI = Convert.ToDateTime(m_fg_load_file[v_int_row, (int)e_col_Number.NGAY_GUI].ToString());
                    v_us_dm_bill.strGHI_CHU = nullToString((string)m_fg_load_file[v_int_row, (int)e_col_Number.GHI_CHU]);
                    v_us_dm_bill.dcID_PHONG_BAN = CIPConvert.ToDecimal(m_cbo_phong_ban.SelectedValue.ToString());
                    v_us_dm_bill.SetSO_TIENNull();
                    v_us_dm_bill.dcID_TRANG_THAI = CONST_ID_TRANG_THAI_THU.ID_DA_NHAN_NOI_BO;
                    v_us_dm_bill.Insert();
                }
                v_us_dm_bill.CommitTransaction();
                m_lbl_load.Visible = false;
                ghi_log_he_thong();
                m_i_flag = 0;
                BaseMessages.MsgBox_Infor("Đã import dữ liệu nhận từ Bưu cục thành công");
            }
            catch (Exception v_e)
            {

                v_us_dm_bill.Rollback();
                CDBExceptionHandler v_exceptionHander = new CDBExceptionHandler(v_e,
                    new CDBClientDBExceptionInterpret());
                v_exceptionHander.showErrorMessage();
            }
        }