예제 #1
0
 void UCDictionaryAddOrEdit_ExportEvent(object sender, EventArgs e)
 {
     try
     {
         string dir = Application.StartupPath + @"\ExportFile";
         if (!Directory.Exists(dir))
         {
             Directory.CreateDirectory(dir);
         }
         SaveFileDialog sfd = new SaveFileDialog();
         sfd.InitialDirectory = dir;
         sfd.Title            = "导出文件";
         sfd.DefaultExt       = "xls";
         sfd.Filter           = "Microsoft Office Excel 文件(*.xls;*.xlsx)|*.xls;*.xlsx|Microsoft Office Excel 文件(*.xls)|*.xls|Microsoft Office Excel 文件(*.xlsx)|*.xlsx";
         sfd.FileName         = dir + @"\字典码表" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls";
         DialogResult result = sfd.ShowDialog();
         if (result == DialogResult.OK)
         {
             int totalCount = 0;
             PercentProcessOperator process = new PercentProcessOperator();
             #region 匿名方法,后台线程执行完调用
             process.BackgroundWork =
                 delegate(Action <int> percent)
             {
                 DataTable dt = DBHelper.GetTable("查询码表", "v_dictionaries", "*", where, "", "order by dic_code");
                 totalCount = dt.Rows.Count;
                 dt         = ExcelHandler.HandleDataTableForExcel(dt, dgvDicList);
                 ExcelHandler.ExportDTtoExcel(dt, "", sfd.FileName, percent);
             };
             #endregion
             process.MessageInfo = "正在执行中";
             process.Maximum     = totalCount;
             #region 匿名方法,后台线程执行完调用
             process.BackgroundWorkerCompleted += new EventHandler <BackgroundWorkerEventArgs>(
                 delegate(object osender, BackgroundWorkerEventArgs be)
             {
                 if (be.BackGroundException == null)
                 {
                     MessageBoxEx.ShowInformation("导出成功!");
                 }
                 else
                 {
                     Utility.Log.Log.writeLineToLog("【字典码表】" + be.BackGroundException.Message, "client");
                     MessageBoxEx.ShowWarning("导出出现异常");
                 }
             }
                 );
             #endregion
             process.Start();
         }
     }
     catch (Exception ex)
     {
         Utility.Log.Log.writeLineToLog("【字典码表】" + ex.Message, "client");
         MessageBoxEx.ShowWarning("导出失败!");
     }
 }
예제 #2
0
 /// <summary> 导出
 /// </summary>
 void UCDictionaryManager_ExportEvent(object sender, EventArgs e)
 {
     try
     {
         //获取数据表
         DataTable dt = DBHelper.GetTable("查询码表", "v_dictionaries", "*", where, "", "order by dic_code");
         //根据datagridview列制定datatable导出列及列名称
         dt = ExcelHandler.HandleDataTableForExcel(dt, dgvDicList);
         string fileName = "字典码表" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls";
         ExcelHandler.ExportExcel(fileName, dt);
     }
     catch (Exception ex)
     {
         Utility.Log.Log.writeLineToLog("【字典码表】" + ex.Message, "client");
         MessageBoxEx.ShowWarning("导出失败!");
     }
 }
예제 #3
0
 //导出
 void UCPersonnelManager_ExportEvent(object sender, EventArgs e)
 {
     if (this.dgvUser.Rows.Count == 0)
     {
         return;
     }
     try
     {
         string fileName = "人员管理" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls";
         ExcelHandler.ExportExcel(fileName, ExcelHandler.HandleDataTableForExcel(dgvUser.GetBoundData(), dgvUser));
     }
     catch (Exception ex)
     {
         Utility.Log.Log.writeLineToLog("人员管理" + ex.Message, "client");
         MessageBoxEx.ShowWarning("导出失败!");
     }
 }
예제 #4
0
 //导出
 void UCReceivableManage_ExportEvent(object sender, EventArgs e)
 {
     try
     {
         string dir = Application.StartupPath + @"\ExportFile";
         if (!Directory.Exists(dir))
         {
             Directory.CreateDirectory(dir);
         }
         SaveFileDialog sfd = new SaveFileDialog();
         sfd.InitialDirectory = dir;
         sfd.Title            = "导出文件";
         sfd.DefaultExt       = "xls";
         sfd.Filter           = "Microsoft Office Excel 文件(*.xls;*.xlsx)|*.xls;*.xlsx|Microsoft Office Excel 文件(*.xls)|*.xls|Microsoft Office Excel 文件(*.xlsx)|*.xlsx";
         sfd.FileName         = dir + @"\" + Title + DateTime.Now.ToString("yyyy-MM-dd") + ".xls";
         DialogResult result = sfd.ShowDialog();
         if (result == DialogResult.OK)
         {
             string    strWhere = GetWhere();
             DataTable dt       = DBHelper.GetTable("查询" + Title, "tb_bill_receivable", "*", strWhere, "", "order by create_time desc");
             if (dt == null || dt.Rows.Count == 0)
             {
                 MessageBoxEx.ShowInformation("没有可导出的数据!");
                 return;
             }
             dt.DataTableToDate("order_date");
             if (orderType == DataSources.EnumOrderType.RECEIVABLE)
             {
                 dt.DateTableToEnum("payment_type", typeof(DataSources.EnumReceivableType));
             }
             else
             {
                 dt.DateTableToEnum("payment_type", typeof(DataSources.EnumPaymentType));
             }
             dt.DateTableToEnum("order_status", typeof(DataSources.EnumAuditStatus));
             PercentProcessOperator process = new PercentProcessOperator();
             #region 匿名方法,后台线程执行完调用
             process.BackgroundWork =
                 delegate(Action <int> percent)
             {
                 dt = ExcelHandler.HandleDataTableForExcel(dt, dgvBillReceivable);
                 ExcelHandler.ExportDTtoExcel(dt, "", sfd.FileName, percent);
             };
             #endregion
             process.MessageInfo = "正在执行中";
             process.Maximum     = dt.Rows.Count;
             #region 匿名方法,后台线程执行完调用
             process.BackgroundWorkerCompleted += new EventHandler <BackgroundWorkerEventArgs>(
                 delegate(object osender, BackgroundWorkerEventArgs be)
             {
                 if (be.BackGroundException == null)
                 {
                     MessageBoxEx.ShowInformation("导出成功!");
                 }
                 else
                 {
                     Utility.Log.Log.writeLineToLog("【" + Title + "】" + be.BackGroundException.Message, "client");
                     MessageBoxEx.ShowWarning("导出出现异常");
                 }
             }
                 );
             #endregion
             process.Start();
         }
     }
     catch (Exception ex)
     {
         Utility.Log.Log.writeLineToLog("【" + Title + "】" + ex.Message, "client");
         MessageBoxEx.ShowWarning("导出失败!");
     }
 }