protected override ResultStatus Export() { try { //1.開始轉出資料 panFilter.Enabled = false; labMsg.Visible = true; labMsg.Text = "開始轉檔..."; this.Cursor = Cursors.WaitCursor; this.Refresh(); Thread.Sleep(5); //1.1 copy template xls to target path string excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID); Workbook workbook = new Workbook(); workbook.LoadDocument(excelDestinationPath); //2.匯出資料 //共同的參數一起設定,init param = { D30395 dao, string startMonth } Object[] args = { dao30395, txtStartMonth.Text }; int pos = 0; IReportData GDF = CreateReport(GetType(), "GDF", args); pos += GDF.Export(workbook); //IReportData GDF_Detail = CreateReport(GetType(), "GDF_Detail", args); //GDF_Detail.Export(workbook); IReportData TGF = CreateReport(GetType(), "TGF", args); pos += TGF.Export(workbook); //IReportData TGF_Detail = CreateReport(GetType(), "TGF_Detail", args); //TGF_Detail.Export(workbook); if (pos <= 0) { File.Delete(excelDestinationPath); MessageDisplay.Info(MessageDisplay.MSG_NO_DATA, GlobalInfo.ResultText); return(ResultStatus.Fail); } //存檔 workbook.SaveDocument(excelDestinationPath); if (FlagAdmin) { System.Diagnostics.Process.Start(excelDestinationPath); } return(ResultStatus.Success); } catch (Exception ex) { WriteLog(ex); } finally { panFilter.Enabled = true; labMsg.Text = ""; labMsg.Visible = false; this.Cursor = Cursors.Arrow; } return(ResultStatus.Fail); }
protected override ResultStatus Export() { try { #region 輸入&日期檢核 if (string.Compare(txtStartMonth.Text, txtEndMonth.Text) > 0) { MessageDisplay.Error("月份起始年月不可小於迄止年月!", GlobalInfo.ErrorText); return(ResultStatus.Fail); } if (string.Compare(txtStartDate.Text, txtEndDate.Text) > 0) { MessageDisplay.Error(CheckDate.Datedif, GlobalInfo.ErrorText); return(ResultStatus.Fail); } #endregion //1.開始轉出資料 panFilter.Enabled = false; labMsg.Visible = true; labMsg.Text = "訊息:資料轉出中........"; this.Refresh(); //1.1 copy template xls to target path string excelDestinationPath = PbFunc.wf_copy_file(_ProgramID, _ProgramID); Workbook workbook = new Workbook(); workbook.LoadDocument(excelDestinationPath); #region //ken,第一次改寫(廢除) //if (chkGroup.Items[1].CheckState == System.Windows.Forms.CheckState.Checked) { // if (rdoGroup.Text == "期貨" || rdoGroup.Text == "全部") // wf_30770_date(workbook, "F%", SheetType.FutureDetail, StartDate, EndDate, OswGrp);//sheetName = 期貨日明細 // if (rdoGroup.Text == "選擇權" || rdoGroup.Text == "全部") // wf_30770_date(workbook, "O%", SheetType.FutureDetail, StartDate, EndDate, OswGrp);//sheetName = 選擇權日明細 //}//if (chkGroup.Items[1].CheckState == System.Windows.Forms.CheckState.Checked) { //if (chkGroup.Items[0].CheckState == System.Windows.Forms.CheckState.Checked) { // if (rdoGroup.Text == "期貨" || rdoGroup.Text == "全部") // wf_30770_mth(workbook, "F%", SheetType.FutureSum, StartDate, EndDate, OswGrp);//sheetName = 期貨月統計 // if (rdoGroup.Text == "選擇權" || rdoGroup.Text == "全部") // wf_30770_mth(workbook, "O%", SheetType.OptionSum, StartDate, EndDate, OswGrp);//sheetName = 選擇權月統計 //}//if (chkGroup.Items[0].CheckState == System.Windows.Forms.CheckState.Checked) { #endregion //2.匯出資料(看勾選情況,目前最多跑2x2=4次) Object[] args = { dao30770, _ProgramID, StartMonth, EndMonth, StartDate, EndDate, OswGrp, OswGrpText }; int pos = 0; foreach (CheckedListBoxItem chk in chkGroup.Items) { if (chk.CheckState == CheckState.Checked) { if (rdoGroup.Text == "%") { //全部,兩個都要跑 IReportData Future = CreateReport(GetType(), "Future" + chk.Value.ToString(), args); pos += Future.Export(workbook); IReportData Option = CreateReport(GetType(), "Option" + chk.Value.ToString(), args); pos += Option.Export(workbook); } else { IReportData ReportData = CreateReport(GetType(), rdoGroup.Text + chk.Value.ToString(), args); pos += ReportData.Export(workbook); } //if (rdoGroup.Text == "%") { } //if(chk.CheckState == CheckState.Checked){ } //foreach(CheckedListBoxItem chk in chkGroup.Items){ if (pos <= 0) { File.Delete(excelDestinationPath); MessageDisplay.Info("查無資料!", GlobalInfo.ResultText); return(ResultStatus.Fail); } //存檔 workbook.SaveDocument(excelDestinationPath); //if (FlagAdmin) // System.Diagnostics.Process.Start(excelDestinationPath); return(ResultStatus.Success); } catch (Exception ex) { WriteLog(ex); } finally { panFilter.Enabled = true; labMsg.Text = ""; labMsg.Visible = false; } return(ResultStatus.Fail); }