/// <summary> /// Создает форму для отображения информации о BiWeekly-отчете /// </summary> /// <param name="biWeeklyReport"></param> public BiWeeklyForm(BiWeekly biWeeklyReport) { currentBiWeeklyReport = biWeeklyReport; mode = ScreenMode.Edit; InitializeComponent(); UpdateInformation(); }
/// <summary> /// Обновляет информацию в данном элементе управления /// </summary> /// <param name="reloadReport">Синхронизировать ли с базой данных</param> private void UpdateInformation(bool reloadReport) { if (reloadReport) { #if RELEASE try { #endif report.Reload(); RemoveTempFile(); #if RELEASE } catch (Exception ex) { MessageBox.Show("Error while loading data" + Environment.NewLine + ex.Message, (string)new StaticProjectTermsProvider()["SystemName"], MessageBoxButtons.OK, MessageBoxIcon.Error); return; } #endif } textBoxShortName.Text = report.ShortName; textBoxReportName.Text = report.RealName; textBoxDescription.Text = report.FullName; if (mode == ScreenMode.Edit) { labelDownloadDateValue.Text = UsefulMethods.NormalizeDate(report.RecievedDate); } else { labelDownloadDateValue.Text = UsefulMethods.NormalizeDate(DateTime.Now); } tempReport = new BiWeekly(report.RealName, report.Report); if (tempReport.Report != null) { tempReport.SaveReportToFile(out tempFilePath); } bool permission = report.HasPermission(Users.CurrentUser, DataEvent.Update); if (mode == ScreenMode.Edit) { headerControl.ButtonEdit.Enabled = permission; } buttonLoad.Enabled = permission; buttonSaveToFile.Enabled = !(tempReport.Report == null); textBoxShortName.ReadOnly = !permission; textBoxReportName.ReadOnly = !permission; textBoxDescription.ReadOnly = !permission; buttonDeleteReport.Visible = (mode == ScreenMode.Edit); buttonDeleteReport.Enabled = report.HasPermission(Users.CurrentUser, DataEvent.Remove); }
private void ClearFields() { textBoxShortName.Text = ""; textBoxReportName.Text = ""; textBoxDescription.Text = ""; labelDownloadDateValue.Text = UsefulMethods.NormalizeDate(DateTime.Now); buttonSaveToFile.Enabled = false; reportViewItem.Icon = icons.PDFGray; reportViewItem.Cursor = Cursors.Default; report = new BiWeekly("", null); tempReport = new BiWeekly("", null); }
/// <summary> /// Создает форму для добавления BiWeekly-отчета /// </summary> /// <param name="dialogFileName"></param> public BiWeeklyForm(string dialogFileName) { currentBiWeeklyReport = new BiWeekly(); mode = ScreenMode.Add; InitializeComponent(); string fileName = dialogFileName.Substring(dialogFileName.LastIndexOf('\\') + 1); if (fileName.LastIndexOf('.') == -1) { textBoxShortName.Text = fileName; } else { textBoxShortName.Text = fileName.Substring(0, fileName.LastIndexOf('.')); } currentBiWeeklyReport.LoadReport(dialogFileName); }
private void listViewBiWeeklies_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) { BiWeekly item = (BiWeekly)e.Item.Tag; if (e.IsSelected) { selectedItemsArray.Add(item); } else { if (selectedItemsArray.Contains(item)) { selectedItemsArray.Remove(item); } } if (SelectedItemsChanged != null) { SelectedItemsChanged(this, new EventArgs()); } }
private void OpenReport(object parameter) { BiWeekly biWeeklyReport = (BiWeekly)parameter; string path = TermsProvider.GetTempFolderPath() + "\\" + biWeeklyReport.RealName; bool successCreating = true; if (!File.Exists(path)) { successCreating = biWeeklyReport.SaveReportToFile(path); } if (!successCreating) { return; } Process tempProcess = new Process(); tempProcess.StartInfo = new ProcessStartInfo(path); try { tempProcess.Start(); tempProcess.WaitForExit(); } catch (Exception ex) { Program.Provider.Logger.Log("Error while loading data", ex); } try { TryDeleteFile(path); } catch (Exception ex) { Program.Provider.Logger.Log("Error while deleting data", ex); } }
public BiWeeklyReportScreen(BiWeekly report, ScreenMode mode) { this.report = report; this.mode = mode; tempReport = new BiWeekly(report.RealName, report.Report); operatorHeaderControl = new BiWeekliesHeaderControl(true); // // headerControl // headerControl.Controls.Add(operatorHeaderControl); headerControl.ActionControl.ButtonEdit.DisplayerRequested += ButtonEdit_DisplayerRequested; headerControl.ReloadRised += headerControl_ReloadRised; headerControl.ContextActionControl.ButtonHelp.TopicID = "bi_weekly_reports"; if (mode == ScreenMode.Edit) { headerControl.ActionControl.ButtonEdit.Icon = icons.Save; headerControl.ActionControl.ButtonEdit.IconNotEnabled = icons.SaveGray; headerControl.ActionControl.ButtonEdit.TextMain = "Save"; headerControl.ActionControl.ButtonEdit.Enabled = true; } else { headerControl.ButtonReload.Icon = icons.SaveAndAdd; headerControl.ButtonReload.IconNotEnabled = icons.SaveAndAddGray; headerControl.ButtonReload.TextMain = "Save and"; headerControl.ButtonReload.TextSecondary = "add another"; headerControl.ButtonEdit.Icon = icons.Save; headerControl.ButtonEdit.IconNotEnabled = icons.SaveGray; headerControl.ButtonEdit.TextMain = "Save"; headerControl.ButtonEdit.TextSecondary = "and close"; headerControl.ButtonEdit.ReflectionType = ReflectionTypes.CloseSelected; } // // labelShortName // labelShortName.Location = new Point(LEFT_MARGIN, TOP_MARGIN); labelShortName.Font = Css.OrdinaryText.Fonts.RegularFont; labelShortName.ForeColor = Css.OrdinaryText.Colors.ForeColor; labelShortName.Size = defaultLabelSize; labelShortName.Text = "Short Name:"; labelShortName.TextAlign = ContentAlignment.MiddleLeft; // // textBoxShortName // textBoxShortName.BackColor = Color.White; textBoxShortName.Location = new Point(labelShortName.Right, TOP_MARGIN); textBoxShortName.Font = Css.OrdinaryText.Fonts.RegularFont; textBoxShortName.ForeColor = Css.OrdinaryText.Colors.ForeColor; textBoxShortName.Size = defaultTextBoxSize; // // labelReportName // labelReportName.Location = new Point(LEFT_MARGIN, labelShortName.Bottom + HEIGHT_INTERVAL); labelReportName.Font = Css.OrdinaryText.Fonts.RegularFont; labelReportName.ForeColor = Css.OrdinaryText.Colors.ForeColor; labelReportName.Size = defaultLabelSize; labelReportName.Text = "Report Name:"; labelReportName.TextAlign = ContentAlignment.MiddleLeft; // // textBoxReportName // textBoxReportName.BackColor = Color.White; textBoxReportName.Location = new Point(labelReportName.Right, textBoxShortName.Bottom + HEIGHT_INTERVAL); textBoxReportName.Font = Css.OrdinaryText.Fonts.RegularFont; textBoxReportName.ForeColor = Css.OrdinaryText.Colors.ForeColor; textBoxReportName.Size = defaultTextBoxSize; textBoxReportName.LostFocus += textBoxReportName_LostFocus; // // labelDescription // labelDescription.Location = new Point(LEFT_MARGIN, labelReportName.Bottom + HEIGHT_INTERVAL); labelDescription.Font = Css.OrdinaryText.Fonts.RegularFont; labelDescription.ForeColor = Css.OrdinaryText.Colors.ForeColor; labelDescription.Size = defaultLabelSize; labelDescription.Text = "Description:"; labelDescription.TextAlign = ContentAlignment.MiddleLeft; // // textBoxDescription // textBoxDescription.BackColor = Color.White; textBoxDescription.Location = new Point(labelDescription.Right, textBoxReportName.Bottom + HEIGHT_INTERVAL); textBoxDescription.Font = Css.OrdinaryText.Fonts.RegularFont; textBoxDescription.ForeColor = Css.OrdinaryText.Colors.ForeColor; textBoxDescription.Multiline = true; textBoxDescription.Size = new Size(defaultTextBoxSize.Width, defaultTextBoxSize.Height * 5); // // labelDownloadDate // labelDownloadDate.Location = new Point(LEFT_MARGIN, textBoxDescription.Bottom + HEIGHT_INTERVAL); labelDownloadDate.Font = Css.OrdinaryText.Fonts.RegularFont; labelDownloadDate.ForeColor = Css.OrdinaryText.Colors.ForeColor; labelDownloadDate.Size = defaultLabelSize; labelDownloadDate.Text = "Download Date:"; labelDownloadDate.TextAlign = ContentAlignment.MiddleLeft; // // labelDownloadDateValue // labelDownloadDateValue.Location = new Point(labelDownloadDate.Right, textBoxDescription.Bottom + HEIGHT_INTERVAL); labelDownloadDateValue.Font = Css.OrdinaryText.Fonts.RegularFont; labelDownloadDateValue.ForeColor = Css.OrdinaryText.Colors.ForeColor; labelDownloadDateValue.Size = defaultTextBoxSize; labelDownloadDateValue.TextAlign = ContentAlignment.MiddleLeft; // // linkBiWeeklies // linkBiWeeklies.AutoSize = true; linkBiWeeklies.Location = new Point(LEFT_MARGIN, labelDownloadDate.Bottom + HEIGHT_INTERVAL); linkBiWeeklies.Font = Css.SimpleLink.Fonts.Font; linkBiWeeklies.ForeColor = Css.SimpleLink.Colors.LinkColor; linkBiWeeklies.Text = "BiWeekly Reports"; linkBiWeeklies.DisplayerRequested += linkBiWeeklies_DisplayerRequested; // // reportViewItem // if (mode == ScreenMode.Edit) { reportViewItem = new BiWeeklyItem(icons.PDF, "View PDF", Cursors.Hand); } else { reportViewItem = new BiWeeklyItem(icons.PDFGray, "View PDF", Cursors.Default); } reportViewItem.Location = new Point(textBoxShortName.Right + HEIGHT_INTERVAL, TOP_MARGIN); reportViewItem.DisplayerRequested += reportViewItem_DisplayerRequested; // // buttonLoad // buttonLoad.FontMain = Css.HeaderControl.Fonts.PrimaryFont; buttonLoad.ForeColorMain = Css.HeaderControl.Colors.PrimaryColor; buttonLoad.Location = new Point(reportViewItem.Right + HEIGHT_INTERVAL, reportViewItem.Top); buttonLoad.Icon = icons.Load; buttonLoad.IconNotEnabled = icons.LoadGray; buttonLoad.TextMain = "Load PDF"; buttonLoad.Click += buttonLoad_Click; // // buttonSaveToFile // buttonSaveToFile.FontMain = Css.HeaderControl.Fonts.PrimaryFont; buttonSaveToFile.ForeColorMain = Css.HeaderControl.Colors.PrimaryColor; buttonSaveToFile.Location = new Point(reportViewItem.Right + HEIGHT_INTERVAL, buttonLoad.Bottom); buttonSaveToFile.Icon = icons.Save; buttonSaveToFile.IconNotEnabled = icons.SaveGray; buttonSaveToFile.TextMain = "Save to file"; buttonSaveToFile.Click += buttonSaveToFile_Click; // // buttonDeleteReport // buttonDeleteReport.FontMain = Css.HeaderControl.Fonts.PrimaryFont; buttonDeleteReport.FontSecondary = Css.HeaderControl.Fonts.PrimaryFont; buttonDeleteReport.ForeColorMain = Css.HeaderControl.Colors.PrimaryColor; buttonDeleteReport.ForeColorSecondary = Css.HeaderControl.Colors.PrimaryColor; buttonDeleteReport.Location = new Point(1100, TOP_MARGIN); buttonDeleteReport.Icon = icons.Delete; buttonDeleteReport.IconNotEnabled = icons.DeleteGray; buttonDeleteReport.Size = new Size(200, 50); buttonDeleteReport.TextAlignMain = ContentAlignment.MiddleLeft; buttonDeleteReport.TextMain = "Delete report"; buttonDeleteReport.DisplayerRequested += buttonDeleteReport_DisplayerRequested; // // mainPanel // mainPanel.Dock = DockStyle.Fill; mainPanel.Controls.Add(labelShortName); mainPanel.Controls.Add(labelReportName); mainPanel.Controls.Add(labelDescription); mainPanel.Controls.Add(labelDownloadDate); mainPanel.Controls.Add(textBoxShortName); mainPanel.Controls.Add(textBoxReportName); mainPanel.Controls.Add(textBoxDescription); mainPanel.Controls.Add(labelDownloadDateValue); mainPanel.Controls.Add(linkBiWeeklies); mainPanel.Controls.Add(reportViewItem); mainPanel.Controls.Add(buttonLoad); mainPanel.Controls.Add(buttonSaveToFile); mainPanel.Controls.Add(buttonDeleteReport); BackColor = Css.CommonAppearance.Colors.BackColor; Controls.Add(mainPanel); Controls.Add(headerControl); Controls.Add(footerControl); UpdateInformation(false); }
/// <summary> /// Создаёт новый экземпляр класса BiWeeklyItem /// </summary> public BiWeeklyItem(Image icon, string caption, Cursor cursor, BiWeekly report) { this.report = report; InitializeComponents(icon, caption, cursor); }
public DispatcheredBiWeeklyReportScreen(BiWeekly report, ScreenMode mode) : base(report, mode) { Dock = DockStyle.Fill; }