void _bgWork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { lblMsg.Visible = false; if (_fromPrint) { if (chkSplitByStudentNumber.Checked) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "請選擇檔案儲存的資料夾.."; if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { foreach (Dictionary <string, string> data in _DataDict) { foreach (KeyValuePair <string, string> val in data) { // 當有學號才處理 if (val.Key == "B_學號" && val.Value != "") { string num = val.Value; List <Dictionary <string, string> > tmpList = new List <Dictionary <string, string> >(); tmpList.Add(data); _DocumentMerge = new DAO.DocumentMerge(_MappingField, tmpList, _DocTemplateTransfer.GetUsingTemplate(), fbd.SelectedPath + "\\" + num, false); _DocumentMerge.Merge(); break; } } } // 是否置自動開啟資料夾 if (FISCA.Presentation.Controls.MsgBox.Show("儲存完成,請問是否自動開啟儲存資料夾?", "儲存", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = fbd.SelectedPath; proc.Start(); } } } else { // 全部在一個檔案 SaveFileDialog sd = new SaveFileDialog(); sd.Title = "另存新檔"; sd.FileName = "Doc1.doc"; sd.Filter = "Word檔案 (*.doc)|*.doc|所有檔案 (*.*)|*.*"; if (sd.ShowDialog() == DialogResult.OK) { bool isOopenFile = true; if (FISCA.Presentation.Controls.MsgBox.Show("請問儲存後是否自動開啟檔案?", "儲存", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { isOopenFile = true; } else { isOopenFile = false; } _DocumentMerge = new DAO.DocumentMerge(_MappingField, _DataDict, _DocTemplateTransfer.GetUsingTemplate(), "", isOopenFile); if (chkSplitByStudentNumber.Checked == false) { _DocumentMerge.Merge(); } } } _fromPrint = false; btnPrint.Enabled = true; } if (_fromTempExport) { ExportMappingFieldToExcel(); _fromTempExport = false; ilblExportExcelField.Enabled = true; } }
void _bgWork_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { lblMsg.Visible = false; if (_fromPrint) { if (chkSplitByStudentNumber.Checked) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "請選擇檔案儲存的資料夾.."; if (fbd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { foreach (Dictionary<string, string> data in _DataDict) { foreach (KeyValuePair<string, string> val in data) { // 當有學號才處理 if (val.Key == "B_學號" && val.Value != "") { string num = val.Value; List<Dictionary<string, string>> tmpList = new List<Dictionary<string, string>>(); tmpList.Add(data); _DocumentMerge = new DAO.DocumentMerge(_MappingField, tmpList, _DocTemplateTransfer.GetUsingTemplate(), fbd.SelectedPath + "\\" + num, false); _DocumentMerge.Merge(); break; } } } // 是否置自動開啟資料夾 if (FISCA.Presentation.Controls.MsgBox.Show("儲存完成,請問是否自動開啟儲存資料夾?", "儲存", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) { System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo.FileName = fbd.SelectedPath; proc.Start(); } } } else { // 全部在一個檔案 SaveFileDialog sd = new SaveFileDialog(); sd.Title = "另存新檔"; sd.FileName = "Doc1.doc"; sd.Filter = "Word檔案 (*.doc)|*.doc|所有檔案 (*.*)|*.*"; if (sd.ShowDialog() == DialogResult.OK) { bool isOopenFile = true; if (FISCA.Presentation.Controls.MsgBox.Show("請問儲存後是否自動開啟檔案?", "儲存", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes) isOopenFile = true; else isOopenFile = false; _DocumentMerge = new DAO.DocumentMerge(_MappingField, _DataDict, _DocTemplateTransfer.GetUsingTemplate(), "", isOopenFile); if (chkSplitByStudentNumber.Checked == false) _DocumentMerge.Merge(); } } _fromPrint = false; btnPrint.Enabled = true; } if (_fromTempExport) { ExportMappingFieldToExcel(); _fromTempExport = false; ilblExportExcelField.Enabled = true; } }