private void tsiExportWord_Click(object sender, EventArgs e) { ChooseGroupsForm choose = new ChooseGroupsForm(); choose.adapter = EducationAdapter; choose.Rooms = Rooms; if (Schedule == null) { MessageBox.Show("Расписание не задано!"); return; } if (choose.ShowDialog() == System.Windows.Forms.DialogResult.OK && choose.ChooseNames.Count > 0) { stampParamsForm param = new stampParamsForm(Schedule.FirstDaySem.Year); if (param.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SaveFileDialog frmSave = new SaveFileDialog(); frmSave.Filter = "(*.doc)|*.doc"; frmSave.FileName = "report1.doc"; if (frmSave.ShowDialog() == DialogResult.OK && frmSave.FileName != "") { // Проверяем наличие файла if (File.Exists(frmSave.FileName) == true) { try { File.Delete(frmSave.FileName); } catch (Exception ex) { MessageBox.Show(ex.Message); } } createReport(new DocExporter(choose.ChooseNames, Schedule, choose.ChooseView, frmSave.FileName, param.parametrs)); } } } }
private void tsiExport_Excel_Click(object sender, EventArgs e) { ChooseGroupsForm choose = new ChooseGroupsForm(); choose.adapter = EducationAdapter; choose.Rooms = Rooms; if (Schedule == null) { MessageBox.Show("Расписание не задано!"); return; } if (choose.ShowDialog() == System.Windows.Forms.DialogResult.OK && choose.ChooseNames.Count > 0) { SaveFileDialog frmSave = new SaveFileDialog(); frmSave.Filter = "(*.xls)|*.xls"; frmSave.FileName = "schedule1.xls"; if (frmSave.ShowDialog() == DialogResult.OK && frmSave.FileName != "") { // Проверяем наличие файла if (File.Exists(frmSave.FileName) == true) { try { File.Delete(frmSave.FileName); } catch (Exception ex) { MessageBox.Show(ex.Message); } } createReport(new XLSExporter(choose.ChooseNames, Schedule, choose.ChooseView, frmSave.FileName)); } } }