private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { MsgBox.Show("產生報表時發生錯誤。" + e.Error.Message); return; } //MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); //ReportSaver.SaveDocument(_doc, Global.ReportName); bool pdf = Config.GetBoolean("輸出成PDF格式", false); if (pdf) { MotherForm.SetStatusBarMessage("轉換成 PDF 格式中..."); ReportSaver.SaveDocument(_doc, Global.ReportName, ReportSaver.OutputType.PDF); MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); } else { MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); ReportSaver.SaveDocument(_doc, Global.ReportName); } }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { MsgBox.Show("產生報表時發生錯誤"); return; } bool pdf = Config.GetBoolean("輸出成PDF格式", false); if (OneFileSave) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "請選擇儲存資料夾"; fbd.ShowNewFolderButton = true; if (fbd.ShowDialog() == DialogResult.Cancel) { return; } if (pdf) { MotherForm.SetStatusBarMessage("轉換成 PDF 格式中..."); foreach (string each in StudentDoc.Keys) { StudentDoc[each].Save(fbd.SelectedPath + "\\" + each, SaveFormat.AsposePdf); //ReportSaver.SaveDocument(StudentDoc[each], each, ReportSaver.OutputType.PDF); } } else { foreach (string each in StudentDoc.Keys) { StudentDoc[each].Save(fbd.SelectedPath + "\\" + each + ".doc"); } } MotherForm.SetStatusBarMessage("產生完成"); System.Diagnostics.Process.Start(fbd.SelectedPath); } else { if (pdf) { MotherForm.SetStatusBarMessage("轉換成 PDF 格式中..."); ReportSaver.SaveDocument(_doc, Global.ReportName, ReportSaver.OutputType.PDF); MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); } else { MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); ReportSaver.SaveDocument(_doc, Global.ReportName); } } }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { K12.Presentation.NLDPanels.Student.AddToTemp(_overStudentList); if (e.Error != null) { MsgBox.Show("產生報表時發生錯誤。" + e.Error.Message); return; } if ("" + e.Result == "Cancel") { MotherForm.SetStatusBarMessage(""); return; } MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); ReportSaver.SaveDocument(_doc, Global.ReportName); }
// 未達畢業標準通知單 void _ExportWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { MsgBox.Show("產生報表時發生錯誤。" + e.Error.Message); return; } MotherForm.SetStatusBarMessage(ReportName + "產生完成"); ReportSaver.SaveDocument(_doc, ReportName); // 檢查是否產生學生清單 if (_UserSelExportStudentList) { if (_wbStudentList != null) { SaveFileDialog sd = new SaveFileDialog(); sd.FileName = "學生清單(未達畢業標準學生)"; sd.Filter = "Excel檔案(*.xls)|*.xls"; if (sd.ShowDialog() != DialogResult.OK) { return; } try { _wbStudentList.Save(sd.FileName, FileFormatType.Excel2003); if (MsgBox.Show("報表產生完成,是否立刻開啟?", MessageBoxButtons.YesNo) == DialogResult.Yes) { System.Diagnostics.Process.Start(sd.FileName); } } catch (Exception ex) { SmartSchool.ErrorReporting.ReportingService.ReportException(ex); MsgBox.Show("儲存失敗。" + ex.Message); } } } }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { //throw e.Error; MsgBox.Show("產生報表時發生錯誤。" + e.Error.Message); return; } //MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); //ReportSaver.SaveDocument(_doc, Global.ReportName); bool pdf = Config.GetBoolean("輸出成PDF格式", false); if (OneFileSave) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "請選擇儲存資料夾"; fbd.ShowNewFolderButton = true; if (fbd.ShowDialog() == DialogResult.Cancel) { return; } if (pdf) { MotherForm.SetStatusBarMessage("轉換成 PDF 格式中..."); foreach (string each in StudentDoc.Keys) { //StudentDoc[each].Save(fbd.SelectedPath + "\\" + each, SaveFormat.AsposePdf); //ReportSaver.SaveDocument(StudentDoc[each], fPath, ReportSaver.OutputType.PDF); //ReportSaver.SaveDocument(StudentDoc[each], each, ReportSaver.OutputType.PDF); #region 處理產生 PDF string fPath = fbd.SelectedPath + "\\" + each + ".pdf"; FileInfo fi = new FileInfo(fPath); DirectoryInfo folder = new DirectoryInfo(Path.Combine(fi.DirectoryName, Path.GetRandomFileName())); if (!folder.Exists) { folder.Create(); } FileInfo fileinfo = new FileInfo(Path.Combine(folder.FullName, fi.Name)); string XmlFileName = fileinfo.FullName.Substring(0, fileinfo.FullName.Length - fileinfo.Extension.Length) + ".xml"; string PDFFileName = fileinfo.FullName.Substring(0, fileinfo.FullName.Length - fileinfo.Extension.Length) + ".pdf"; StudentDoc[each].Save(XmlFileName, Aspose.Words.SaveFormat.AsposePdf); Aspose.Pdf.Pdf pdf1 = new Aspose.Pdf.Pdf(); pdf1.BindXML(XmlFileName, null); pdf1.Save(PDFFileName); if (File.Exists(fPath)) { File.Delete(Path.Combine(fi.DirectoryName, fi.Name)); } File.Move(PDFFileName, fPath); folder.Delete(true); #endregion } } else { foreach (string each in StudentDoc.Keys) { StudentDoc[each].Save(fbd.SelectedPath + "\\" + each + ".doc"); } } MotherForm.SetStatusBarMessage("產生完成"); System.Diagnostics.Process.Start(fbd.SelectedPath); } else { if (pdf) { MotherForm.SetStatusBarMessage("轉換成 PDF 格式中..."); ReportSaver.SaveDocument(_doc, Global.ReportName, ReportSaver.OutputType.PDF); MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); } else { MotherForm.SetStatusBarMessage(Global.ReportName + "產生完成"); ReportSaver.SaveDocument(_doc, Global.ReportName); } } }