diff --git a/project/ProjectTourAgency/Forms/FormDirectoryReport.Designer.cs b/project/ProjectTourAgency/Forms/FormDirectoryReport.Designer.cs new file mode 100644 index 0000000..5672748 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormDirectoryReport.Designer.cs @@ -0,0 +1,99 @@ +namespace ProjectTourAgency.Forms +{ + partial class FormDirectoryReport + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + checkBoxEmployees = new CheckBox(); + checkBoxRoutes = new CheckBox(); + checkBoxClients = new CheckBox(); + buttonBuild = new Button(); + SuspendLayout(); + // + // checkBoxEmployees + // + checkBoxEmployees.AutoSize = true; + checkBoxEmployees.Location = new Point(55, 27); + checkBoxEmployees.Name = "checkBoxEmployees"; + checkBoxEmployees.Size = new Size(124, 29); + checkBoxEmployees.TabIndex = 0; + checkBoxEmployees.Text = "Работники"; + checkBoxEmployees.UseVisualStyleBackColor = true; + // + // checkBoxRoutes + // + checkBoxRoutes.AutoSize = true; + checkBoxRoutes.Location = new Point(55, 149); + checkBoxRoutes.Name = "checkBoxRoutes"; + checkBoxRoutes.Size = new Size(128, 29); + checkBoxRoutes.TabIndex = 1; + checkBoxRoutes.Text = "Маршруты"; + checkBoxRoutes.UseVisualStyleBackColor = true; + // + // checkBoxClients + // + checkBoxClients.AutoSize = true; + checkBoxClients.Location = new Point(55, 90); + checkBoxClients.Name = "checkBoxClients"; + checkBoxClients.Size = new Size(97, 29); + checkBoxClients.TabIndex = 2; + checkBoxClients.Text = "Клинты"; + checkBoxClients.UseVisualStyleBackColor = true; + // + // buttonBuild + // + buttonBuild.Location = new Point(255, 90); + buttonBuild.Name = "buttonBuild"; + buttonBuild.Size = new Size(191, 34); + buttonBuild.TabIndex = 3; + buttonBuild.Text = "Сформировать"; + buttonBuild.UseVisualStyleBackColor = true; + buttonBuild.Click += buttonBuild_Click; + // + // FormDirectoryReport + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(484, 210); + Controls.Add(buttonBuild); + Controls.Add(checkBoxClients); + Controls.Add(checkBoxRoutes); + Controls.Add(checkBoxEmployees); + Name = "FormDirectoryReport"; + Text = "FormDirectoryReport"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private CheckBox checkBoxEmployees; + private CheckBox checkBoxRoutes; + private CheckBox checkBoxClients; + private Button buttonBuild; + } +} \ No newline at end of file diff --git a/project/ProjectTourAgency/Forms/FormDirectoryReport.cs b/project/ProjectTourAgency/Forms/FormDirectoryReport.cs new file mode 100644 index 0000000..cbcbdc5 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormDirectoryReport.cs @@ -0,0 +1,64 @@ +using ProjectTourAgency.Reports; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ProjectTourAgency.Forms +{ + public partial class FormDirectoryReport : Form + { + private readonly IUnityContainer _container; + + public FormDirectoryReport(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? + throw new ArgumentNullException(nameof(container)); + } + + private void ButtonBuild_Click(object sender, EventArgs e) + { + try + { + if (!checkBoxClients.Checked && !checkBoxEmployees.Checked + && !checkBoxRoutes.Checked) + { + throw new Exception("Не выбран ни один справочник для выгрузки"); + } + + var sfd = new SaveFileDialog() + { + Filter = "Docx Files | *.docx" + }; + + if (sfd.ShowDialog() != DialogResult.OK) + { + throw new Exception("Не выбран файла для отчета"); + } + + if (_container.Resolve().CreateDoc(sfd.FileName, checkBoxClients.Checked, + checkBoxEmployees.Checked, checkBoxRoutes.Checked)) + { + MessageBox.Show("Документ сформирован", "Формирование документа", + MessageBoxButtons.OK, MessageBoxIcon.Information); + } + else + { + MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", + "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/project/ProjectTourAgency/Forms/FormDirectoryReport.resx b/project/ProjectTourAgency/Forms/FormDirectoryReport.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/project/ProjectTourAgency/Forms/FormDirectoryReport.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file