private void load_file_excel()
        {
            if(m_ofd_exel_file.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
                try {
                    // Reset lại ds mới nếu chọn lại file excel khác
                    m_ds = new DS_EXCEL_IMPORT_HOC_VIEN();

                    m_lbl_loading_mes.Visible = true;
                    CExcelReport v_excel_rpt = new CExcelReport(m_ofd_exel_file.FileName);

                    m_ds.EnforceConstraints = false;
                    v_excel_rpt.Export2DatasetDS_by_DucVT(m_ds, m_ds.EXCEL_IMPORT_HOC_VIEN.TableName, 2);

                    m_fg.Redraw = false;

                    //Gán DataSource
                    //m_fg.DataSource = m_ds.DM_NHAN_SU;

                    CGridUtils.Dataset2C1Grid(m_ds, m_fg, m_obj_trans);
                    m_fg.Redraw = true;
                    m_lbl_loading_mes.Visible = false;

                }
                catch(Exception v_e) {
                    CSystemLog_301.ExceptionHandle(v_e);
                }
            }
        }
        private void load_excel_2_grid(C1.Win.C1FlexGrid.C1FlexGrid m_fg)
        {
            var m_obj_dialog = new System.Windows.Forms.OpenFileDialog();
            DialogResult v_result = new DialogResult();
            v_result = m_obj_dialog.ShowDialog();

            if(v_result == DialogResult.Cancel) {
                BaseMessages.MsgBox_Infor("Bạn chưa chọn file Excel!");
                m_obj_dialog.Dispose();
                return;
            }
            Workbook wb = null;
            wb = Workbook.getWorkbook(m_obj_dialog.FileName);
            Sheet sheet = wb.getSheet(0);
            //Cái này để thêm hàng vào grid
            int v_count_row = 7;
            while(sheet.getCell(2, v_count_row).Contents != "") {
                v_count_row = v_count_row + 1;
                m_fg.Rows.Add();
            }
            wb.close();

            Hashtable v_hst_excel_col = get_mapping_col_excel_grid();
            CExcelReport v_obj_excel_rpt = new CExcelReport(m_obj_dialog.FileName);
            int v_i_start_excel_row = 7;

            for(int v_i_cur_col = m_fg.Cols.Fixed; v_i_cur_col < m_fg.Cols.Count; v_i_cur_col++) {
                m_lbl_loading.Visible = true;
                progressBar1.Visible = true;
                progressBar1.Minimum = m_fg.Cols.Fixed;
                progressBar1.Maximum = m_fg.Cols.Count;
                progressBar1.Value = v_i_cur_col;
                v_obj_excel_rpt.Export2Grid(m_fg,
                    v_i_start_excel_row
                    , (int)v_hst_excel_col[v_i_cur_col]
                    , v_i_cur_col);
            }
            m_lbl_tong_so_bill.Text = CIPConvert.ToStr(count_record_in_grid(m_fg));
            make_stt(m_fg);
            m_lbl_loading.Visible = false;
            progressBar1.Visible = false;
            m_fg.Select(0, 0);
        }
 private void export_2_excel()
 {
     CExcelReport v_obj_excel_report = new CExcelReport("f405_Tra_cuc_so_Bill_new.xls", 6, 1);
     v_obj_excel_report.AddFindAndReplaceItem("<tu_ngay>", m_dt_tu_ngay.Text);
     v_obj_excel_report.AddFindAndReplaceItem("<den_ngay>", m_dt_den_ngay.Text);
     v_obj_excel_report.AddFindAndReplaceItem("<phap_nhan>", m_cbo_ten_pb.Text);
     //v_obj_excel_report.AddFindAndReplaceItem("<trang_thai>", m_cbo_trang_thai.Text);
     v_obj_excel_report.FindAndReplace(false);
     DataSet v_ds = new DataSet();
     v_ds=grid_to_dataset_export_excel(m_fg);
     m_fg_excel.DataSource = v_ds.Tables[0].DefaultView;
     v_obj_excel_report.Export2ExcelWithoutFixedRows(m_fg_excel, 0, m_fg_excel.Cols.Count -1, true);
 }
        private void export_excel()
        {
            CExcelReport v_obj_exe_report = new CExcelReport();
            switch (m_e_form_mode)
            {
                case eFormMode.KE_KHAI:
                    v_obj_exe_report = new CExcelReport(TEN_BAO_CAO.BCDM_TSLM_KE_KHAI, 21, 1);
                    break;
                case eFormMode.DE_NGHI_XU_LY:
                    v_obj_exe_report = new CExcelReport(TEN_BAO_CAO.BCDM_TSLM_DE_NGHI_XU_LY, 21, 1);
                    break;

            }
            v_obj_exe_report.AddFindAndReplaceItem("<DON_VI_SU_DUNG_TAI_SAN>", m_cbo_don_vi_su_dung.Text);
            if (m_fg_excel_nha[1, (int)e_col_Excel_number.MA_DON_VI_SU_DUNG] != null)
                v_obj_exe_report.AddFindAndReplaceItem("<MA_DON_VI>", m_fg_excel_nha[1, (int)e_col_Excel_number.MA_DON_VI_SU_DUNG]);
            else v_obj_exe_report.AddFindAndReplaceItem("<MA_DON_VI>", "");
            v_obj_exe_report.AddFindAndReplaceItem("<LOAI_HINH_DON_VI>", m_cbo_loai_hinh_don_vi.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<TRU_SO_LAM_VIEC>", m_lbl_lam_tru_so_lam_viec.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<DIA_CHI>", m_lbl_dia_chi.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<DT_KHUON_VIEN>", m_lbl_dien_tich_khuon_vien_dat.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<CO_SO_HDSN>", m_lbl_lam_co_so_hd_su_nghiep.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<LAM_NHA_O>", m_lbl_lam_nha_o.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<CHO_THUE>", m_lbl_cho_thue.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<BO_TRONG>", m_lbl_bo_trong.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<BI_LAN_CHIEM>", m_lbl_bi_lan_chiem.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<KHAC>", m_lbl_su_dung_vao_muc_dich_khac.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<GT_THEO_SO_KE_TOAN>", m_lbl_gia_tri_theo_so_ke_toan.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<NGAY>", DateTime.Now.Day);
            v_obj_exe_report.AddFindAndReplaceItem("<THANG>", DateTime.Now.Month);
            v_obj_exe_report.AddFindAndReplaceItem("<NAM>", DateTime.Now.Year);

            v_obj_exe_report.FindAndReplace(false);
            v_obj_exe_report.Export2ExcelWithoutFixedRows(m_fg_nha, 2, m_fg_nha.Cols.Count - 1, true);
        }
        }

        private void m_cmd_update_Click(object sender, EventArgs e)
        {
            try{
                update_v_gd_don_dat_hang_detail();
            }
            catch (Exception v_e){
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }

        private void m_cmd_xuat_excel_Click(object sender, EventArgs e)
        {
        //private void Export2Dataset_BangChiPhiCuoiThangNCC(string ip_path_and_file_name, System.Data.DataSet i_DataSet, int i_iSheetStartRow)
        //{
        //    // khởi tạo đường dẫn InitPath()
        //    string m_strOutputPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Reports\\Templates\\";
        //    string m_strTemplatesPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Reports\\Output\\";
        //    //Khởi tạo đối tượng Excel
        //    Excel.Application v_objExcelApp;
        //    Excel.Worksheet v_objExcelWorksheet;
        //    v_objExcelApp = new Excel.Application();
        //    try
        //    {
        //        System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
        //        v_objExcelApp.Workbooks.Open(ip_path_and_file_name);
        //        v_objExcelApp.Workbooks[1].Worksheets.Select(1);
        //        v_objExcelWorksheet = (Excel.Worksheet)v_objExcelApp.Workbooks[1].Worksheets[1];
        //        int i_iExcelRow = 0;
        //        int i_iExcelCol = 0;
        //        bool v_bol_stop = false;
        //        while (!v_bol_stop)
        //        {
        //            System.Data.DataRow v_iDataRow;
        //            v_iDataRow = i_DataSet.Tables[0].NewRow();
        //            v_iDataRow[i_iExcelCol] = i_iExcelCol + 1;
        //            for (i_iExcelCol = 0; i_iExcelCol <= i_DataSet.Tables[0].Columns.Count - 2; i_iExcelCol++)
        //            {
        //                if (!object.ReferenceEquals(v_objExcelWorksheet.Cells[i_iExcelRow + i_iSheetStartRow, 3], null))
        //                {
        //                    if (!(v_objExcelWorksheet.Cells[i_iExcelRow + i_iSheetStartRow, i_iExcelCol + 1] == null))
        //                    {
        //                        v_iDataRow[i_iExcelCol + 1] = v_objExcelWorksheet.Cells[i_iExcelRow + i_iSheetStartRow, i_iExcelCol + 1];
        //                    }
        //                }
        //                else
        //                {
        //                    v_bol_stop = true;
        //                }
        //            }
        //            if (!v_bol_stop)
        //            {
        //                i_DataSet.Tables[0].Rows.InsertAt(v_iDataRow, i_iExcelRow);
        //                i_iExcelRow += 1;
        //            }
        //        }
        //        v_objExcelApp.Workbooks.Close();
        //        v_objExcelApp.Quit();
        //        //Unmount
        //        v_objExcelWorksheet = null;
        //        v_objExcelApp = null;
        //    }
        //    catch (Exception v_e)
        //    {
        //        v_objExcelApp.Workbooks.Close();
        //        //Unmount
        //        v_objExcelWorksheet = null;
        //        v_objExcelApp = null;
        //        throw v_e;
        //    }
        //}
        private void load_danh_sach_excel()
        {
            if (m_OpenFile_dlg.ShowDialog() == DialogResult.OK)
            {
                string v_str_path_and_file_name = m_OpenFile_dlg.FileName;
                string v_str_file_name = v_str_path_and_file_name.Substring(v_str_path_and_file_name.LastIndexOf("\\") + 1, v_str_path_and_file_name.Length - v_str_path_and_file_name.LastIndexOf("\\") - 1);
                CExcelReport v_xls_file = new CExcelReport(v_str_path_and_file_name);
                try
                {
                    m_lbl_thong_bao_cap_nhat.Visible = false;
                    m_lbl_loading.Visible = true;
                    m_ds.EnforceConstraints = false;
                    //Export2Dataset_BangChiPhiCuoiThangNCC(v_str_path_and_file_name, v_ds, 14);
                    v_xls_file.Export2DatasetDSPhongThi(m_ds, m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.TableName, 14);

                    //set MA_HD_NCC cho từng bản ghi
                    //int v_i_row_fg = 0;
                    //string v_str_ma_don_hang_ncc = "";

                    //for (v_i_row_fg = 0; v_i_row_fg < m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Count; v_i_row_fg++)
                    //{
                    //    if (m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Rows[v_i_row_fg][2].ToString() != "")
                    //    {
                    //        v_str_ma_don_hang_ncc = m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Rows[v_i_row_fg][2].ToString();
                    //    }
                    //    else
                    //    {
                    //        m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Rows[v_i_row_fg][2] = v_str_ma_don_hang_ncc;
                    //    }
                    //}

                    //set NGAY cho từng hóa đơn
                    //v_i_row_fg = 0;
                    //DateTime v_dat_ngay = DateTime.Parse(m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Rows[v_i_row_fg][1].ToString());
                    //for (v_i_row_fg = 0; v_i_row_fg < m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Count; v_i_row_fg++)
                    //{
                    //    if (m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Rows[v_i_row_fg][1].ToString() != "")
                    //    {
                    //        v_dat_ngay = DateTime.Parse(m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Rows[v_i_row_fg][1].ToString());
                    //    }
                    //    else
                    //    {
                    //        m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Rows[v_i_row_fg][1] = v_dat_ngay;
                    //    }
                    //}

                    // Đưa dữ liệu lên lưới:
                    CGridUtils.Dataset2C1Grid(m_ds, m_fg, m_obj_trans_xls);

                    //CGridUtils.MakeSoTT(0, m_fg);
                    //m_fg.Subtotal(C1.Win.C1FlexGrid.AggregateEnum.Count // chỗ này dùng hàm count tức là để đếm, có thể dùng các hàm khác thay thế
                    //    , 0
                    //    , (int)e_col_Number.NGAY // chỗ này là tên trường mà mình nhóm
                    //    , (int)e_col_Number.TEN_VPP // chỗ này là tên trường mà mình Count
                    //     , "{0}"
                    //     );
                    //m_fg.Subtotal(C1.Win.C1FlexGrid.AggregateEnum.Sum
                    //    , 0
                    //    , (int)e_col_Number.NGAY
                    //    , (int)e_col_Number.DOANH_THU
                    //    , "{0}"
                    //    );
                    //m_fg.Redraw = true;
                    //m_fg.Tree.Show(1);

                    //m_lbl_tong_so_luong.Text = CIPConvert.ToStr(m_fg_load_file.Rows.Count - 1);

                    //set mã hóa đơn MA_HD cho từng bản ghi
                    //int v_i_row_fg = 0;
                    //string v_str_ma_don_hang_ncc = "";
                    //for (v_i_row_fg = 0; v_i_row_fg < m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Count; v_i_row_fg++)
                    //{
                    //    if (m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Rows[v_i_row_fg][(int)e_col_Number.MA_HD].ToString() != "")
                    //    {
                    //        v_str_ma_don_hang_ncc = m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Rows[v_i_row_fg][(int)e_col_Number.MA_HD].ToString();
                    //    }
                    //    else
                    //    {
                    //        m_ds.RPT_BANG_CHI_PHI_CUOI_THANG_NCC.Rows[v_i_row_fg][(int)e_col_Number.MA_HD] = v_str_ma_don_hang_ncc;
                    //    }
                    //}
                    m_lbl_loading.Visible = false;
                }
                catch (Exception v_e)
                {
                    if (v_e.Message.ToString() == "Cannot set Column 'STT' to be null. Please use DBNull instead.")
                        BaseMessages.MsgBox_Error(THONG_BAO.ER_COT_STT_DE_TRONG);
                    else CSystemLog_301.ExceptionHandle(v_e);
                }

            }
        }
        private void export_excel()
        {
            CExcelReport v_obj_exe_report = new CExcelReport();
            switch (m_e_form_mode)
            {
                case eFormMode.TONG_HOP_CHUNG:
                    v_obj_exe_report = new CExcelReport(TEN_BAO_CAO.BCTH_THSD_TSK_THC, 17, 1);
                    break;
                case eFormMode.CHI_TIET_THEO_LOAI_HINH:
                    v_obj_exe_report = new CExcelReport(TEN_BAO_CAO.BCTH_THSD_TSK_LH, 17, 1);
                    break;
                case eFormMode.CHI_TIET_THEO_TUNG_DON_VI:
                    v_obj_exe_report = new CExcelReport(TEN_BAO_CAO.BCTH_THSD_TSK_DV, 17, 1);
                    break;

            }
            v_obj_exe_report.AddFindAndReplaceItem("<BO_TINH>", m_lbl_don_vi_bo_tinh.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<DON_VI_BO_TINH>", m_lbl_don_vi_bo_tinh.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<DON_VI_CHU_QUAN>", m_lbl_don_vi_chu_quan.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<MA_DON_VI>", m_lbl_ma_don_vi.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<NGAY>", DateTime.Now.Day);
            v_obj_exe_report.AddFindAndReplaceItem("<THANG>", DateTime.Now.Month);
            v_obj_exe_report.AddFindAndReplaceItem("<NAM>", DateTime.Now.Year);
            v_obj_exe_report.FindAndReplace(false);
            v_obj_exe_report.Export2ExcelWithoutFixedRows(m_fg_tai_san_khac, 2, m_fg_tai_san_khac.Cols.Count - 1, true);
        }
        void m_xuat_excel_Click(object sender, EventArgs e)
        {
            try {
                CExcelReport v_excel = new CExcelReport("f130_chuc_nang.xls", 6, 1);
                v_excel.FindAndReplace(false);
                v_excel.Export2ExcelWithoutFixedRows(m_fg_load_file, (int)e_col_Number.SOCT, (int)e_col_Number.GHICHU, true);
                //v_excel.OpenExcelFile();
            }
            catch(Exception v_e) {

                CSystemLog_301.ExceptionHandle(v_e);
            }
        }
        private void export_excel()
        {
            CExcelReport v_obj_exe_report = new CExcelReport();
            switch (m_e_form_mode)
            {
                case eFormMode.KE_KHAI:
                    v_obj_exe_report = new CExcelReport(TEN_BAO_CAO.BCDM_OTO_KE_KHAI, 13, 1);
                    break;
                case eFormMode.DE_NGHI_XU_LY:
                    v_obj_exe_report = new CExcelReport(TEN_BAO_CAO.BCDM_OTO_DE_NGHI_XU_LY, 13, 1);
                    break;

            }
            v_obj_exe_report.AddFindAndReplaceItem("<DON_VI_SU_DUNG_TAI_SAN>", m_cbo_don_vi_su_dung.Text);
            if (m_fg_oto_excel[1, (int)e_col_Excel_number.MA_DON_VI_SU_DUNG] != null)
                v_obj_exe_report.AddFindAndReplaceItem("<MA_DON_VI>", m_fg_oto_excel[1, (int)e_col_Excel_number.MA_DON_VI_SU_DUNG]);
            else v_obj_exe_report.AddFindAndReplaceItem("<MA_DON_VI>", "");
            v_obj_exe_report.AddFindAndReplaceItem("<LOAI_HINH_DON_VI>", m_cbo_loai_hinh_don_vi.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<NGAY>", DateTime.Now.Day);
            v_obj_exe_report.AddFindAndReplaceItem("<THANG>", DateTime.Now.Month);
            v_obj_exe_report.AddFindAndReplaceItem("<NAM>", DateTime.Now.Year);

            v_obj_exe_report.FindAndReplace(false);
            v_obj_exe_report.Export2ExcelWithoutFixedRows(m_fg_oto, 2, m_fg_oto.Cols.Count - 1, true);
        }
 private void export_excel()
 {
     CExcelReport v_obj_exe_report;
     switch (m_e_form_mode)
     {
         case eFormMode.KE_KHAI:
             v_obj_exe_report = new CExcelReport(TEN_BAO_CAO.BCDM_TST_TREN500TRIEU_KK, 12, 1);
             v_obj_exe_report.AddFindAndReplaceItem("<TEN_DON_VI_CHU_QUAN>", m_lbl_don_vi_chu_quan.Text);
             v_obj_exe_report.AddFindAndReplaceItem("<DON_VI_SU_DUNG>", m_lbl_don_vi_su_dung.Text);
             break;
         case eFormMode.DE_NGHI_XU_LY:
             v_obj_exe_report = new CExcelReport(TEN_BAO_CAO.BCDM_TSK_DE_NGHI_XU_LY, 12, 1);
             break;
         default:
             v_obj_exe_report = new CExcelReport();
             break;
     }
     v_obj_exe_report.AddFindAndReplaceItem("<DON_VI_SU_DUNG_TAI_SAN>", m_lbl_ma_don_vi.Text);
     v_obj_exe_report.AddFindAndReplaceItem("<MA_DON_VI>", m_lbl_ma_don_vi.Text);
     v_obj_exe_report.AddFindAndReplaceItem("<LOAI_HINH_DON_VI>", m_lbl_loai_hinh_don_vi.Text);
     v_obj_exe_report.AddFindAndReplaceItem("<NGAY>", DateTime.Now.Day);
     v_obj_exe_report.AddFindAndReplaceItem("<THANG>", DateTime.Now.Month);
     v_obj_exe_report.AddFindAndReplaceItem("<NAM>", DateTime.Now.Year);
     v_obj_exe_report.FindAndReplace(false);
     v_obj_exe_report.Export2ExcelWithoutFixedRows(m_fg_tai_san_khac, 2, m_fg_tai_san_khac.Cols.Count - 1, true);
 }
 private void excel_file_to_dataset(string ip_str_file_path)
 {
     CExcelReport v_cer = new CExcelReport(ip_str_file_path);
     //tao 1 dataset de luu du lieu tu file excel
     m_ds_temp = new DataSet();
     m_dt_temp = new DataTable();
     m_dt_temp.TableName = "DM_VPP";
     m_dt_temp.Columns.Add("Temp");//cot thua
     m_dt_temp.Columns.Add("STT");
     m_dt_temp.Columns.Add("MA_SAN_PHAM");
     m_dt_temp.Columns.Add("TEN_VPP");
     m_dt_temp.Columns.Add("DON_VI_TINH");
     m_dt_temp.Columns.Add("DON_GIA_CHUA_VAT");
     m_dt_temp.Columns.Add("DON_GIA_GOM_VAT");
     m_dt_temp.Columns.Add("GIOI_HAN_VPP");
     m_ds_temp.Tables.Add(m_dt_temp);
     //data from excel file to dataset and fill to grid
     v_cer.Export2DatasetDSPhongThi(m_ds_temp, m_ds_temp.Tables[0].TableName, 10);
     m_ds_temp.Tables[0].Columns.RemoveAt(0);//loai bo cot thua
     m_ds_temp.AcceptChanges();
     //format lai 2 cot don gia
     for (int i = 0; i < m_ds_temp.Tables[0].Rows.Count; i++)
     {
         m_ds.Tables[0].Rows[i][2] = CIPConvert.ToDecimal(m_ds.Tables[0].Rows[i][4]).ToString();
         m_ds.Tables[0].Rows[i][3] = CIPConvert.ToDecimal(m_ds.Tables[0].Rows[i][5]).ToString();
     }
     m_fg.DataSource = m_ds_temp.Tables[0];
 }
 private void xuat_excel()
 {
     var v_start_row = 8;
     var v_start_col = 2;
     var v_obj_excel_rpt = new CExcelReport("f460_tinh_hinh_thoi_hoc.xlsx", v_start_row, v_start_col);
     v_obj_excel_rpt.AddFindAndReplaceItem("<tu_ngay>", string.Format("{0}/{1}/{2}", m_dat_tu_ngay.Value.Date.Day, m_dat_tu_ngay.Value.Month, m_dat_tu_ngay.Value.Year));
     v_obj_excel_rpt.AddFindAndReplaceItem("<den_ngay>", string.Format("{0}/{1}/{2}", m_dat_den_ngay.Value.Day, m_dat_den_ngay.Value.Month, m_dat_den_ngay.Value.Year));
     v_obj_excel_rpt.AddFindAndReplaceItem("<tong_so>", m_txt_sl_dang_hoc.Text);
     v_obj_excel_rpt.FindAndReplace(false);
     v_obj_excel_rpt.Export2ExcelWithoutFixedRows(m_fg, 0, m_fg.Cols.Count - 1, false);
 }
 private void export_2_excel()
 {
     m_fg.Cols[(int)e_col_Number.UU_TIEN].Visible = false;
     m_dat_chon_thang = CIPConvert.ToDatetime("01/" + m_dt_chon_thang.Text);
     DateTime v_dt_tu_ngay = m_dat_chon_thang;
     DateTime v_dt_den_ngay = m_dat_chon_thang.AddMonths(1).AddDays(-m_dat_chon_thang.Day);
     CExcelReport v_obj_excel_report = new CExcelReport("f406_bc_Tong_hop_bill_theo_phong_ban.xlsx", 5, 1);
     US_HT_NGUOI_SU_DUNG v_ht_nguoi_su_dung = new US_HT_NGUOI_SU_DUNG(CAppContext_201.getCurrentUserID());
     //v_obj_excel_report.AddFindAndReplaceItem("<tu_ngay>", v_dt_tu_ngay.ToShortDateString());
     //v_obj_excel_report.AddFindAndReplaceItem("<den_ngay>", v_dt_den_ngay.ToShortDateString());
     v_obj_excel_report.AddFindAndReplaceItem("<THANG_TONG_HOP>", v_dt_tu_ngay.Month);
     v_obj_excel_report.AddFindAndReplaceItem("<NGUOI_LAP>", v_ht_nguoi_su_dung.strTEN);
     v_obj_excel_report.AddFindAndReplaceItem("<ngay>", DateTime.Now.Day);
     v_obj_excel_report.AddFindAndReplaceItem("<thang>", DateTime.Now.Month);
     v_obj_excel_report.AddFindAndReplaceItem("<nam>", DateTime.Now.Year);
     //v_obj_excel_report.AddFindAndReplaceItem("<trang_thai>", m_cbo_trang_thai.Text);
     v_obj_excel_report.FindAndReplace(false);
     v_obj_excel_report.Export2ExcelWithoutFixedRows(m_fg, 0, m_fg.Cols.Count - 1, true);
     m_fg.Cols[(int)e_col_Number.UU_TIEN].Visible = true;
 }
 private void export_2_excel()
 {
     CExcelReport v_obj_excel_report = new CExcelReport("f407_bc_chi_tiet_bill_cua_phong_ban.xlsx", 6, 1);
     v_obj_excel_report.AddFindAndReplaceItem("<tu_ngay>", m_lbl_tu_ngay.Text);
     v_obj_excel_report.AddFindAndReplaceItem("<den_ngay>", m_lbl_den_ngay.Text);
     v_obj_excel_report.AddFindAndReplaceItem("<phong_ban>", m_lbl_ten_phong_ban.Text);
     v_obj_excel_report.AddFindAndReplaceItem("<tong_bill>", m_lbl_tong_bill.Text);
     v_obj_excel_report.AddFindAndReplaceItem("<tong_tien>", m_lbl_tong_tien.Text);
     v_obj_excel_report.FindAndReplace(false);
     v_obj_excel_report.Export2ExcelWithoutFixedRows(m_fg, 0, m_fg.Cols.Count - 1, true);
 }
            }
            catch (Exception v_e) {
                v_us.Rollback();
                CDBExceptionHandler v_objErrHandler = new CDBExceptionHandler(v_e,
                    new CDBClientDBExceptionInterpret());
                v_objErrHandler.showErrorMessage();
            }
        }

        //private void set_search_tu_khoa_format_before()
        //{
        //    if (m_txt_tu_khoa.Text == "")
        //    {
        //        m_txt_tu_khoa.Text = m_str_goi_y;
        //        m_txt_tu_khoa.ForeColor = Color.Gray;
        //    }
        //}
        //private void set_search_tu_khoa_format_after()
        //{
        //    if (m_txt_tu_khoa.Text == m_str_goi_y)
        //    {
        //        m_txt_tu_khoa.Text = "";
        //    }
        private void load_excel_2_grid_excel(string ip_str_file_name)
        {
            IP.Core.IPExcelReport.CExcelReport v_obj_excel_report
               = new IP.Core.IPExcelReport.CExcelReport(ip_str_file_name);
            int v_int_row_count = v_obj_excel_report.GetCountRow();
            m_fg_oto.Rows.Count = v_int_row_count;
            m_fg_oto_excel.Rows.Count = v_int_row_count;

            for (int v_i_grid_col = 1; v_i_grid_col < m_fg_oto_excel.Cols.Count; v_i_grid_col++)
            {
                v_obj_excel_report.Export2Grid(
                m_fg_oto_excel
                , 5
                , v_i_grid_col
                , v_i_grid_col);
            }
            for (int v_i_cur_row = m_fg_oto_excel.Rows.Count - 1; v_i_cur_row > m_fg_oto_excel.Rows.Fixed; v_i_cur_row--)
            {
                if (m_fg_oto_excel[v_i_cur_row, 1] == null)
                {
                    m_fg_oto_excel.Rows.Remove(v_i_cur_row);
                }
                else
                    if (m_fg_oto_excel[v_i_cur_row, 1].ToString().Trim().Length == 0)
                    {
                        m_fg_oto_excel.Rows.Remove(v_i_cur_row);
                    }
            }
        }
        //}
        private void export_2_excel()
        {
            CExcelReport v_obj_excel_report = new CExcelReport("f535_gui_don_hang_cho_NCC.xls", 6,1);
            v_obj_excel_report.AddFindAndReplaceItem("<thang>",m_dtp_thang.Text);
            v_obj_excel_report.FindAndReplace(false);
            v_obj_excel_report.Export2ExcelWithoutFixedRows(m_grv_don_hang, 0, m_grv_don_hang.Cols.Count - 1, true);
        }

        private void export_dataset_2_excel()
        private void load_danh_sach_excel()
        {
            if (m_dgl_open_file.ShowDialog() == DialogResult.OK)
            {
                string v_str_path_and_file_name = m_dgl_open_file.FileName;
                string v_str_file_name = v_str_path_and_file_name.Substring(v_str_path_and_file_name.LastIndexOf("\\") + 1, v_str_path_and_file_name.Length - v_str_path_and_file_name.LastIndexOf("\\") - 1);
                CExcelReport v_xls_file = new CExcelReport(v_str_path_and_file_name);
                DS_CM_DM_DANG_KY_GUI_DANH_SACH_TUNG_PHONG v_ds_cm_dm_dang_ky_gui_danh_sach_tung_phong = new DS_CM_DM_DANG_KY_GUI_DANH_SACH_TUNG_PHONG();
                try
                {
                    m_lbl_load.Visible = true;
                    v_ds_cm_dm_dang_ky_gui_danh_sach_tung_phong.EnforceConstraints = false;
                    v_xls_file.Export2DatasetDSPhongThi(v_ds_cm_dm_dang_ky_gui_danh_sach_tung_phong, v_ds_cm_dm_dang_ky_gui_danh_sach_tung_phong.CM_DM_DANG_KY_GUI_DANH_SACH_TUNG_PHONG.TableName, 2);

                    //DataSet v_ds_cm_dm_bang_modify = ModifyDateToUSFormat(v_ds_cm_dm_bang_chi_tiet_cuoi_thang);
                    CGridUtils.Dataset2C1Grid(v_ds_cm_dm_dang_ky_gui_danh_sach_tung_phong, m_fg_load_file, m_obj_trans);
                    m_i_flag = 0;
                    m_lbl_tong_bill.Text = CIPConvert.ToStr(m_fg_load_file.Rows.Count - 1);
                    m_lbl_load.Visible = false;
                }
                catch (Exception v_e)
                {
                    if (v_e.Message.ToString() == "Cannot set Column 'STT' to be null. Please use DBNull instead.")
                        BaseMessages.MsgBox_Error(THONG_BAO.ER_COT_STT_DE_TRONG);
                    else CSystemLog_301.ExceptionHandle(v_e);
                }
            }
        }
 private void export_2_excel()
 {
     CExcelReport v_obj_excel_report = new CExcelReport("F461_Bao_cao_so_sanh_chi_phi_cuoi_thang.xls", 8, 1);
     v_obj_excel_report.AddFindAndReplaceItem("<ngay>", DateTime.Now.ToShortDateString());
     v_obj_excel_report.FindAndReplace(false);
     v_obj_excel_report.Export2ExcelWithoutFixedRows(m_fg, 0, m_fg.Cols.Count - 1, true);
 }
Esempio n. 20
0
        private void export_2_excel()
        {
            m_grv_bill.Cols[(int)e_col_Number.CHON_GUI_MAIL].Visible = false;
            CExcelReport v_obj_excel_report = new CExcelReport("f512_bill_bi_tra_lai.xls", 6, 1);
            v_obj_excel_report.AddFindAndReplaceItem("<tu_ngay>", m_dtp_tu_ngay.Text);
            v_obj_excel_report.AddFindAndReplaceItem("<den_ngay>", m_dtp_den_ngay.Text);
            v_obj_excel_report.FindAndReplace(false);

            v_obj_excel_report.Export2ExcelWithoutFixedRows(m_grv_bill, 0, m_grv_bill.Cols.Count - 1, true);
            m_grv_bill.Cols[(int)e_col_Number.CHON_GUI_MAIL].Visible = true;
        }
        private void load_excel_2_grid_excel()
        {
            IP.Core.IPExcelReport.CExcelReport v_obj_excel_report
               = new IP.Core.IPExcelReport.CExcelReport(m_txt_file_path.Text);
            int v_int_excel_row_cout = v_obj_excel_report.GetCountRow();
            m_fg_nha.Rows.Count = v_int_excel_row_cout;
            m_fg_excel_nha.Rows.Count = v_int_excel_row_cout;

            for (int v_i_grid_col = 1; v_i_grid_col < m_fg_excel_nha.Cols.Count; v_i_grid_col++)
            {
                v_obj_excel_report.Export2Grid(
                m_fg_excel_nha
                , 5
                , v_i_grid_col
                , v_i_grid_col);
            }
            for (int v_i_cur_row = m_fg_excel_nha.Rows.Count - 1; v_i_cur_row > m_fg_excel_nha.Rows.Fixed; v_i_cur_row--)
            {
                if (m_fg_excel_nha[v_i_cur_row, 1] == null)
                {
                    m_fg_excel_nha.Rows.Remove(v_i_cur_row);
                }
                else
                    if (m_fg_excel_nha[v_i_cur_row, 1].ToString().Trim().Length == 0)
                    {
                        m_fg_excel_nha.Rows.Remove(v_i_cur_row);
                    }
            }
        }
 private void xuat_excel()
 {
     var v_start_row = 8;
     var v_start_col = 2;
     var v_obj_excel_rpt = new CExcelReport("f420_bao_cao_tai_chinh_hs_theo_lop.xlsx", v_start_row, v_start_col);
     v_obj_excel_rpt.AddFindAndReplaceItem("<tu_ngay>", string.Format("{0}/{1}/{2}", m_dat_tu_ngay.Value.Date.Day, m_dat_tu_ngay.Value.Month, m_dat_tu_ngay.Value.Year));
     v_obj_excel_rpt.AddFindAndReplaceItem("<den_ngay>", string.Format("{0}/{1}/{2}", m_dat_den_ngay.Value.Day, m_dat_den_ngay.Value.Month, m_dat_den_ngay.Value.Year));
     v_obj_excel_rpt.AddFindAndReplaceItem("<ten_lop>", m_cbo_lop.Text.Trim());
     v_obj_excel_rpt.FindAndReplace(false);
     v_obj_excel_rpt.Export2ExcelWithoutFixedRows(m_fg, 0, m_fg.Cols.Count - 1, false);
 }
 private void export_2_excel()
 {
     CExcelReport v_obj_excel_report = new CExcelReport("f710_bc_tinh_hinh_VPP_theo_phong_ban.xlsx", 7, 1);
     v_obj_excel_report.AddFindAndReplaceItem("<tu_ngay>", v_dt_tu_ngay.ToShortDateString());
     v_obj_excel_report.AddFindAndReplaceItem("<den_ngay>", v_dt_den_ngay.ToShortDateString());
     v_obj_excel_report.FindAndReplace(false);
     //v_obj_excel_report.Export2ExcelWithoutFixedRows(m_fg, 0, m_fg.Cols.Count - 1, true);
     v_obj_excel_report.Export2ExcelWithoutFixedRows_saveDialog("abc",m_fg, 0, m_fg.Cols.Count - 1, true);
 }
     v_us.CommitTransaction();
     m_grv_trang_thai.Rows.Remove(m_grv_trang_thai.Row);
 }
 catch (Exception v_e) {
     v_us.Rollback();
     CDBExceptionHandler v_objErrHandler = new CDBExceptionHandler(v_e,
         new CDBClientDBExceptionInterpret());
     v_objErrHandler.showErrorMessage();
        private void export_excel()
        {
            CExcelReport v_obj_exe_report = new CExcelReport("BC-002 Bao cao ke khai xe o to.xls", 13, 1); ;
            switch (m_e_form_mode)
            {
                case eFormMode.KE_KHAI_O_TO:
                    v_obj_exe_report = new CExcelReport("BC-002 Bao cao ke khai xe o to.xls", 13, 1);
                    break;
                case eFormMode.O_TO_DE_NGHI_XU_LY:
                    v_obj_exe_report = new CExcelReport("BC-005 Danh muc xe oto de nghi xu ly.xls", 13, 1);
                    break;
                case eFormMode.O_TO_GIAO_DON_VI_SU_NGHIEP:
                    v_obj_exe_report = new CExcelReport("BC-023 Bao cao danh muc xe o to giao cho don vi su nghiep cong lap tu chu tai chinh.xls", 13, 1);
                    break;
                default:
                    break;
            }
            v_obj_exe_report.AddFindAndReplaceItem("<BO_TINH>", m_cbo_bo_tinh.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<DON_VI_CHU_QUAN>", m_cbo_don_vi_chu_quan.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<DON_VI_SU_DUNG_TAI_SAN>", m_cbo_don_vi_su_dung.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<MA_DON_VI>", m_txt_ma_don_vi.Text);
            v_obj_exe_report.AddFindAndReplaceItem("<LOAI_HINH_DON_VI>", m_txt_loai_hinh_don_vi.Text);

            v_obj_exe_report.FindAndReplace(false);
            v_obj_exe_report.Export2ExcelWithoutFixedRows(m_fg, 1, m_fg.Cols.Count - 1, true);
        }
                v_objErrHandler.showErrorMessage();
            }
        }

        private void export_2_excel()
        {
            CExcelReport v_obj_excel_report = new CExcelReport("f555_tong_hop_chi_phi_vpp.xls", 6, 1);
        private void xuat_excel()
        {
            var v_start_row = 8;
            var v_start_col = 2;
            var v_obj_excel_rpt = new CExcelReport("f230_ds_hoc_vien_theo_lop.xlsx", v_start_row, v_start_col);
            v_obj_excel_rpt.AddFindAndReplaceItem("<ten_lop>", m_cbo_lop_mon.Text);

            v_obj_excel_rpt.FindAndReplace(false);
            v_obj_excel_rpt.Export2ExcelWithoutFixedRows(m_fg, 0, m_fg.Cols.Count - 1, false);
        }
 private void export_2_excel()
 {
     CExcelReport v_obj_excel_report = new CExcelReport("f410_bc_chi_phi_theo_phap_nhan.xlsx", 5, 1);
     v_obj_excel_report.AddFindAndReplaceItem("<tu_ngay>", m_dt_tu_ngay.Text);
     v_obj_excel_report.AddFindAndReplaceItem("<den_ngay>", m_dt_den_ngay.Text);
     //v_obj_excel_report.AddFindAndReplaceItem("<trang_thai>", m_cbo_trang_thai.Text);
     v_obj_excel_report.FindAndReplace(false);
     v_obj_excel_report.Export2ExcelWithoutFixedRows(m_fg, 0, m_fg.Cols.Count - 1, true);
 }
 private void export_2_excel_pn_pb()
 {
     CExcelReport v_obj_excel_report = new CExcelReport("f405_Tra_cuu_so_Bill_PN_PB.xls", 6, 1);
     v_obj_excel_report.AddFindAndReplaceItem("<tu_ngay>", m_dt_tu_ngay.Text);
     v_obj_excel_report.AddFindAndReplaceItem("<den_ngay>", m_dt_den_ngay.Text);
     v_obj_excel_report.AddFindAndReplaceItem("<phap_nhan>", m_cbo_ten_pb.Text);
     //v_obj_excel_report.AddFindAndReplaceItem("<trang_thai>", m_cbo_trang_thai.Text);
     v_obj_excel_report.FindAndReplace(false);
     v_obj_excel_report.Export2ExcelWithoutFixedRows(m_fg, 0, m_fg.Cols.Count - 5, true);
 }
        private void load_danh_sach_excel()
        {
            //Chọn đường dẫn tới file excel
            var m_obj_dialog = new System.Windows.Forms.OpenFileDialog();
            m_obj_dialog.ShowDialog();

            //Mở sheet đầu tiên
            Workbook wb = null;
            wb = Workbook.getWorkbook(m_obj_dialog.FileName);
            Sheet sheet = wb.getSheet(0);
            //->Cái này để thêm hàng vào grid, cho tới khi row ở cột barcode rỗng
            int v_count_row = 1;
            while(sheet.getCell(3, v_count_row).Contents != "") {
                v_count_row = v_count_row + 1;
                //m_fg.Rows.Add();
            }
            m_fg.Rows.Count = v_count_row + 1;

            wb.close();//Đóng connection khi sử dụng NExcel

            //Load dữ liệu lên lưới
            CExcelReport v_obj_excel_rpt = new CExcelReport(m_obj_dialog.FileName);
            m_lbl_loading.Visible = true;
            int v_i_start_excel_row = 2;
            int v_i_sheet_col = 1;
            for(int v_i_cur_col = m_fg.Cols.Fixed; v_i_cur_col < m_fg.Cols.Count; v_i_cur_col++) {
                progressBar1.Visible = true;
                progressBar1.Minimum = 1;
                progressBar1.Maximum = m_fg.Cols.Count;
                progressBar1.Value = v_i_cur_col;
                v_obj_excel_rpt.Export2Grid(m_fg,
                    v_i_start_excel_row
                    , v_i_sheet_col
                    , v_i_cur_col);
                v_i_sheet_col = v_i_sheet_col + 1;
            }
            //m_fg.Rows[m_fg.Rows.Count - 1].Clear(C1.Win.C1FlexGrid.ClearFlags.All);
            m_lbl_loading.Visible = false;
            progressBar1.Visible = false;
            m_fg.Select(0,0);
        }