Exemplo n.º 1
0
        public GetExportData GetExportData(string objectCode)
        {
            GetExportData getExportData = new GetExportData();

            using (IDbConnection dbConnection = (new AppDataBase()).connection)
            {
                dbConnection.Open();
                // IDbTransaction transaction = dbConnection.BeginTransaction();
                try
                {
                    string sql = @"select * from V_FLC_OBJECTPROPERTY   where obj_code = '" + objectCode + @"'  and lan = 'zn_CN'
                 order by obj_table ,obj_pro_using desc,obj_pro_null desc  ";
                    getExportData.v_FLC_s = AppDataBase.Query <V_FLC_OBJECTPROPERTY>(sql, null, null, dbConnection);

                    string sql2 = @"select *from flc_objects   objs
                                    left join flc_lang lan on lan.key=objs.obj_code||'.'||objs.obj_table
                                      where obj_code='" + objectCode + "'   and lan='zn_CN'  and is_main=0         ";
                    getExportData.objectsUnions = AppDataBase.Query <ObjectsUnionLang>(sql2, null, null, dbConnection);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(getExportData);
        }
Exemplo n.º 2
0
        private void ExportDataToCSV(string pullPath)
        {
            try
            {
                int       iyear    = int.Parse(txtTargetAccYear.Text);
                DataTable dtResult = GetExportData.GetAccount(iyear);
                if (!pullPath.EndsWith(@"\"))
                {
                    pullPath += "\\";
                }
                string fileName = "kj_ztjk_.csv";
                CSVHelper.SaveCSV(dtResult, pullPath + fileName);

                dtResult = GetExportData.GetCode(iyear);
                fileName = "kj_kmjk_.csv";
                CSVHelper.SaveCSV(dtResult, pullPath + fileName);

                dtResult = GetExportData.GetVoucherSum(iyear);
                fileName = "kj_yejk_.csv";
                CSVHelper.SaveCSV(dtResult, pullPath + fileName);

                dtResult = GetExportData.GetVoucher(iyear);
                if (dtResult.Rows.Count > 10000000)//超过1000万行,按月导
                {
                    DataRow[] drs;
                    DataTable dtMResult;
                    for (int iperiod = 1; iperiod < 13; iperiod++)
                    {
                        drs = dtResult.Select(string.Format("KJQJ={0}", iperiod));
                        if (drs.Length > 0)
                        {
                            dtMResult = drs.CopyToDataTable();
                            fileName  = string.Format("kj_pzjk_{0}.csv", iperiod.ToString().PadLeft(2, '0'));
                            CSVHelper.SaveCSV(dtResult, pullPath + fileName);
                        }
                    }
                }
                else
                {
                    fileName = "kj_pzjk_.csv";
                    CSVHelper.SaveCSV(dtResult, pullPath + fileName);
                }
                MessageBox.Show("导出成功!", "信息", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }