//Открывает новую заданную форму public Form RunCommandReporter(ReporterCommand c) { if (Forms.ContainsKey(c) && Forms[c] != null) { var fm = Forms[c]; if (!fm.Visible) { fm.Show(); } if (fm.WindowState == FormWindowState.Minimized) { fm.WindowState = FormWindowState.Normal; } fm.Focus(); return(fm); } if (!c.OneForAllBooks() && IsReportForming) { return(null); } if (c.NeedCheckReport() && !SysPage.IsInfoTask()) { MessageReportError("Да запуска команды необходимо открыть отчет InfoTask"); return(null); } Form f = null; using (StartAtom(c)) { try { AddEvent("Закрытие лишних форм"); var less = new Dictionary <ReporterCommand, Form>(); var great = new Dictionary <ReporterCommand, Form>(); foreach (var k in Forms) { if (c.Greater(k.Key)) { less.Add(k.Key, k.Value); } if (c.Less(k.Key)) { great.Add(k.Key, k.Value); } } var cForms = GeneralRep.CommonBook.Forms; foreach (var k in cForms) { if (c.Less(k.Key)) { great.Add(k.Key, k.Value); } } if (great.Count > 0) { string smess = ""; foreach (var g in great) { smess += (smess != "" ? "," : "") + " Форма " + g.Key.ToFormName(); } smess = "Команда не может быть выполнена, пока открыты:" + smess + ". Закрыть формы?"; if (!MessageReportQuestion(smess)) { return(null); } } foreach (var k in less) { k.Value.Close(); if (Forms.ContainsKey(k.Key)) { Forms.Remove(k.Key); } if (cForms.ContainsKey(k.Key)) { cForms.Remove(k.Key); } } foreach (var k in great) { GeneralRep.CloseForm(k.Key, true); } if (c == ReporterCommand.PutLinks || c == ReporterCommand.ShapeLibrary || c == ReporterCommand.Report || c == ReporterCommand.LiveReport || c == ReporterCommand.Intervals || c == ReporterCommand.AbsoluteEdit || c == ReporterCommand.LinksList) { UpdateDataFile(false); } System.Windows.Forms.Application.EnableVisualStyles(); switch (c) { case ReporterCommand.GroupReports: f = new FormGroupReports(); break; case ReporterCommand.GroupReportEdit: f = new FormGroupReportEdit(); break; case ReporterCommand.Create: f = new FormCreate(); break; case ReporterCommand.Setup: f = new FormSetup(); break; case ReporterCommand.CopyServerReport: CopyServerReport(); break; case ReporterCommand.PutLinks: using (Start()) LoadCurTemplate(); LastChangeLinks = DateTime.Now; f = new FormPutLinks(); break; case ReporterCommand.FilterParams: f = new FormFiltersParams(); break; case ReporterCommand.LinkProperties: f = new FormLinkProperties(); break; case ReporterCommand.FindLinks: f = new FormFindLinks(); break; case ReporterCommand.LinksTemplate: f = new FormLinksTemplate(); break; case ReporterCommand.DeleteLinks: DeleteLinks(); LastChangeLinks = DateTime.Now; break; case ReporterCommand.ClearCells: Forms.Add(ReporterCommand.ClearCells, null); UsedFileToMemory(); ClearAllCells(); Forms.Remove(ReporterCommand.ClearCells); break; case ReporterCommand.ShapeLibrary: f = new FormShapeLibrary(); break; case ReporterCommand.Report: UsedFileToMemory(); PrepareController(); f = new FormReport(); break; case ReporterCommand.LiveReport: UsedFileToMemory(); PrepareController(); f = new FormLiveReport(); break; case ReporterCommand.Video: UsedFileToMemory(); PrepareController(); f = new FormVideo(); break; case ReporterCommand.ArchivesRanges: f = new FormArchivesRanges(); break; case ReporterCommand.Intervals: UsedFileToMemory(); if (FormInf == null || FormToDir || FormToFile) { MessageReportError("Сохранение в журнал возможно только при формировании отчета непосредственно в бланк отчета (задается в настройках)"); } else { PrepareArchive(); f = new FormIntervals(); } break; case ReporterCommand.FilterIntervals: f = new FormFiltersIntervals(); break; case ReporterCommand.SaveReport: if (CanSaveReport()) { f = new FormSaveReport(); } break; case ReporterCommand.AbsoluteEdit: UsedFileToMemory(); AddEvent("Чтение абсолютных значений из архива"); foreach (var project in UsedProjects.Values) { project.AbsoluteEditValues = project.Archive.ReadAbsoluteEdit(project.Code, false); } f = new FormAbsoluteEdit(); break; case ReporterCommand.Update: UpdateDataFile(true); if (!Command.IsError) { MessageReport("Ссылки были обновлены"); } break; case ReporterCommand.LinksList: f = new FormLinksList(); break; case ReporterCommand.AppInfo: f = new FormAppInfo(); break; } if (f != null) { if (!c.OneForAllBooks()) { f.Text += " (" + Code + ")"; } Forms.Add(c, f); f.Show(); } } catch (Exception ex) { AddError("Ошибка при открытии формы", ex, c.ToString()); } if (Command != null && Command.IsError) { foreach (var ff in Forms) { if (ff.Key != ReporterCommand.LinkProperties && ff.Value != null && ff.Value.Visible) { ff.Value.Activate(); break; } } ShowError(); } } return(f); }
private void ButFilter_Click(object sender, EventArgs e) { _filterForm = (FormFiltersParams)_book.RunCommandReporter(ReporterCommand.FilterParams); BindingNavigator1.Items["ButSetFilter"].Enabled = true; }