diff --git a/FlowerShop/FlowerShop/FormMain.Designer.cs b/FlowerShop/FlowerShop/FormMain.Designer.cs
index d8d8c14..1de98e2 100644
--- a/FlowerShop/FlowerShop/FormMain.Designer.cs
+++ b/FlowerShop/FlowerShop/FormMain.Designer.cs
@@ -38,11 +38,14 @@
this.guidesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.bouquetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.shopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.reportsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.listOfBouquetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.componentsByBouquetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.listOfOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.shopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.shopListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.bouquetsInShopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ordersByDateToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonSupplyShop = new System.Windows.Forms.Button();
this.buttonSellBouquets = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
@@ -152,12 +155,22 @@
this.bouquetsToolStripMenuItem.Text = "Букеты";
this.bouquetsToolStripMenuItem.Click += new System.EventHandler(this.bouquetsToolStripMenuItem_Click);
//
+ // shopsToolStripMenuItem
+ //
+ this.shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
+ this.shopsToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
+ this.shopsToolStripMenuItem.Text = "Магазины";
+ this.shopsToolStripMenuItem.Click += new System.EventHandler(this.shopsToolStripMenuItem_Click);
+ //
// reportsToolStripMenuItem
//
this.reportsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.listOfBouquetsToolStripMenuItem,
this.componentsByBouquetsToolStripMenuItem,
- this.listOfOrdersToolStripMenuItem});
+ this.listOfOrdersToolStripMenuItem,
+ this.shopListToolStripMenuItem,
+ this.bouquetsInShopsToolStripMenuItem,
+ this.ordersByDateToolStripMenuItem});
this.reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
this.reportsToolStripMenuItem.Size = new System.Drawing.Size(60, 22);
this.reportsToolStripMenuItem.Text = "Отчёты";
@@ -182,13 +195,27 @@
this.listOfOrdersToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
this.listOfOrdersToolStripMenuItem.Text = "Список заказов";
this.listOfOrdersToolStripMenuItem.Click += new System.EventHandler(this.listOfOrdersToolStripMenuItem_Click);
- //
- // shopsToolStripMenuItem
//
- this.shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
- this.shopsToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
- this.shopsToolStripMenuItem.Text = "Магазины";
- this.shopsToolStripMenuItem.Click += new System.EventHandler(this.shopsToolStripMenuItem_Click);
+ // shopListToolStripMenuItem
+ //
+ this.shopListToolStripMenuItem.Name = "shopListToolStripMenuItem";
+ this.shopListToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
+ this.shopListToolStripMenuItem.Text = "Список магазинов";
+ this.shopListToolStripMenuItem.Click += new System.EventHandler(this.shopListToolStripMenuItem_Click);
+ //
+ // bouquetsInShopsToolStripMenuItem
+ //
+ this.bouquetsInShopsToolStripMenuItem.Name = "bouquetsInShopsToolStripMenuItem";
+ this.bouquetsInShopsToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
+ this.bouquetsInShopsToolStripMenuItem.Text = "Букеты в магазинах";
+ this.bouquetsInShopsToolStripMenuItem.Click += new System.EventHandler(this.bouquetsInShopsToolStripMenuItem_Click);
+ //
+ // ordersByDateToolStripMenuItem
+ //
+ this.ordersByDateToolStripMenuItem.Name = "ordersByDateToolStripMenuItem";
+ this.ordersByDateToolStripMenuItem.Size = new System.Drawing.Size(210, 22);
+ this.ordersByDateToolStripMenuItem.Text = "Список заказов по дате";
+ this.ordersByDateToolStripMenuItem.Click += new System.EventHandler(this.ordersByDateToolStripMenuItem_Click);
//
// buttonSupplyShop
//
@@ -256,5 +283,8 @@
private ToolStripMenuItem shopsToolStripMenuItem;
private Button buttonSupplyShop;
private Button buttonSellBouquets;
+ private ToolStripMenuItem shopListToolStripMenuItem;
+ private ToolStripMenuItem bouquetsInShopsToolStripMenuItem;
+ private ToolStripMenuItem ordersByDateToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/FlowerShop/FlowerShop/FormMain.cs b/FlowerShop/FlowerShop/FormMain.cs
index ac721db..42b26ab 100644
--- a/FlowerShop/FlowerShop/FormMain.cs
+++ b/FlowerShop/FlowerShop/FormMain.cs
@@ -211,5 +211,36 @@ namespace FlowerShop
form.ShowDialog();
}
}
+
+ private void shopListToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ _reportLogic.SaveShopsToWordFile(new ReportBindingModel
+ {
+ FileName = dialog.FileName
+ });
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+
+ private void bouquetsInShopsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportShopBouquets));
+ if (service is FormReportShopBouquets form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void ordersByDateToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportDateOrders));
+ if (service is FormReportDateOrders form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
diff --git a/FlowerShop/FlowerShop/FormReportDateOrders.Designer.cs b/FlowerShop/FlowerShop/FormReportDateOrders.Designer.cs
new file mode 100644
index 0000000..5cb9af0
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormReportDateOrders.Designer.cs
@@ -0,0 +1,90 @@
+namespace FlowerShop
+{
+ partial class FormReportDateOrders
+ {
+ ///
+ /// 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()
+ {
+ this.panel = new System.Windows.Forms.Panel();
+ this.buttonCreateToPdf = new System.Windows.Forms.Button();
+ this.buttonCreateReport = new System.Windows.Forms.Button();
+ this.panel.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // panel
+ //
+ this.panel.Controls.Add(this.buttonCreateToPdf);
+ this.panel.Controls.Add(this.buttonCreateReport);
+ this.panel.Dock = System.Windows.Forms.DockStyle.Top;
+ this.panel.Location = new System.Drawing.Point(0, 0);
+ this.panel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.panel.Name = "panel";
+ this.panel.Size = new System.Drawing.Size(856, 52);
+ this.panel.TabIndex = 1;
+ //
+ // buttonCreateToPdf
+ //
+ this.buttonCreateToPdf.Location = new System.Drawing.Point(678, 11);
+ this.buttonCreateToPdf.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonCreateToPdf.Name = "buttonCreateToPdf";
+ this.buttonCreateToPdf.Size = new System.Drawing.Size(166, 29);
+ this.buttonCreateToPdf.TabIndex = 5;
+ this.buttonCreateToPdf.Text = "PDF";
+ this.buttonCreateToPdf.UseVisualStyleBackColor = true;
+ this.buttonCreateToPdf.Click += new System.EventHandler(this.buttonCreateToPdf_Click);
+ //
+ // buttonCreateReport
+ //
+ this.buttonCreateReport.Location = new System.Drawing.Point(485, 11);
+ this.buttonCreateReport.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonCreateReport.Name = "buttonCreateReport";
+ this.buttonCreateReport.Size = new System.Drawing.Size(166, 29);
+ this.buttonCreateReport.TabIndex = 4;
+ this.buttonCreateReport.Text = "Сформировать";
+ this.buttonCreateReport.UseVisualStyleBackColor = true;
+ this.buttonCreateReport.Click += new System.EventHandler(this.buttonCreateReport_Click);
+ //
+ // FormReportDateOrders
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(856, 338);
+ this.Controls.Add(this.panel);
+ this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.Name = "FormReportDateOrders";
+ this.Text = "Заказы по датам";
+ this.panel.ResumeLayout(false);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Panel panel;
+ private Button buttonCreateToPdf;
+ private Button buttonCreateReport;
+ }
+}
\ No newline at end of file
diff --git a/FlowerShop/FlowerShop/FormReportDateOrders.cs b/FlowerShop/FlowerShop/FormReportDateOrders.cs
new file mode 100644
index 0000000..897e342
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormReportDateOrders.cs
@@ -0,0 +1,73 @@
+using FlowerShopContracts.BindingModels;
+using FlowerShopContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using Microsoft.Reporting.WinForms;
+
+namespace FlowerShop
+{
+ public partial class FormReportDateOrders : Form
+ {
+ private readonly ReportViewer reportViewer;
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+
+ public FormReportDateOrders(ILogger logger, IReportLogic reportLogic)
+ {
+ InitializeComponent();
+
+ _logger = logger;
+ _logic = reportLogic;
+ reportViewer = new ReportViewer
+ {
+ Dock = DockStyle.Fill
+ };
+
+ reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrdersByDate.rdlc", FileMode.Open));
+ Controls.Clear();
+ Controls.Add(reportViewer);
+ Controls.Add(panel);
+ }
+
+ private void buttonCreateReport_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ var dataSource = _logic.GetDateOrders();
+ var source = new ReportDataSource("DataSetOrders", dataSource);
+
+ reportViewer.LocalReport.DataSources.Clear();
+ reportViewer.LocalReport.DataSources.Add(source);
+ reportViewer.RefreshReport();
+
+ _logger.LogInformation("Loading list of orders by date");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error during loading list of orders by date");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonCreateToPdf_Click(object sender, EventArgs e)
+ {
+ using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ try
+ {
+ _logic.SaveDateOrdersToPdfFile(new ReportBindingModel
+ {
+ FileName = dialog.FileName
+ });
+ _logger.LogInformation("Saving list of orders by date");
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error during saving list of orders by date");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+}
diff --git a/FlowerShop/FlowerShop/FormReportDateOrders.resx b/FlowerShop/FlowerShop/FormReportDateOrders.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormReportDateOrders.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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
diff --git a/FlowerShop/FlowerShop/FormReportShopBouquets.Designer.cs b/FlowerShop/FlowerShop/FormReportShopBouquets.Designer.cs
new file mode 100644
index 0000000..e5c77e9
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormReportShopBouquets.Designer.cs
@@ -0,0 +1,110 @@
+namespace FlowerShop
+{
+ partial class FormReportShopBouquets
+ {
+ ///
+ /// 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()
+ {
+ this.buttonSaveToExcel = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.Shop = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Bouquet = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonSaveToExcel
+ //
+ this.buttonSaveToExcel.Location = new System.Drawing.Point(10, 6);
+ this.buttonSaveToExcel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonSaveToExcel.Name = "buttonSaveToExcel";
+ this.buttonSaveToExcel.Size = new System.Drawing.Size(154, 35);
+ this.buttonSaveToExcel.TabIndex = 0;
+ this.buttonSaveToExcel.Text = "Сохранить в Excel";
+ this.buttonSaveToExcel.UseVisualStyleBackColor = true;
+ this.buttonSaveToExcel.Click += new System.EventHandler(this.buttonSaveToExcel_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.Shop,
+ this.Bouquet,
+ this.Count});
+ this.dataGridView.Location = new System.Drawing.Point(10, 45);
+ this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(679, 283);
+ this.dataGridView.TabIndex = 1;
+ //
+ // Shop
+ //
+ this.Shop.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Shop.HeaderText = "Магазин";
+ this.Shop.MinimumWidth = 6;
+ this.Shop.Name = "Shop";
+ //
+ // Bouquet
+ //
+ this.Bouquet.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
+ this.Bouquet.HeaderText = "Букет";
+ this.Bouquet.MinimumWidth = 6;
+ this.Bouquet.Name = "Bouquet";
+ //
+ // Count
+ //
+ this.Count.HeaderText = "Количество";
+ this.Count.MinimumWidth = 6;
+ this.Count.Name = "Count";
+ this.Count.Width = 125;
+ //
+ // FormReportShopBouquets
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(700, 338);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.buttonSaveToExcel);
+ this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.Name = "FormReportShopBouquets";
+ this.Text = "Букеты в магазинах";
+ this.Load += new System.EventHandler(this.FormReportShopBouquets_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Button buttonSaveToExcel;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn Shop;
+ private DataGridViewTextBoxColumn Bouquet;
+ private DataGridViewTextBoxColumn Count;
+ }
+}
\ No newline at end of file
diff --git a/FlowerShop/FlowerShop/FormReportShopBouquets.cs b/FlowerShop/FlowerShop/FormReportShopBouquets.cs
new file mode 100644
index 0000000..6049db0
--- /dev/null
+++ b/FlowerShop/FlowerShop/FormReportShopBouquets.cs
@@ -0,0 +1,78 @@
+using FlowerShopContracts.BindingModels;
+using FlowerShopContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+
+namespace FlowerShop
+{
+ public partial class FormReportShopBouquets : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+
+ public FormReportShopBouquets(ILogger logger, IReportLogic reportLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = reportLogic;
+ }
+
+ private void buttonSaveToExcel_Click(object sender, EventArgs e)
+ {
+ using var dialog = new SaveFileDialog
+ {
+ Filter = "xlsx|*.xlsx"
+ };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ try
+ {
+ _logic.SaveShopBouquetsToExcelFile(new ReportBindingModel
+ {
+ FileName = dialog.FileName
+ });
+ _logger.LogInformation("Saving list of shops with bouquets");
+
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Error during saving list of shops with bouquets");
+
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void FormReportShopBouquets_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var dict = _logic.GetShopBouquets();
+ if (dict != null)
+ {
+ dataGridView.Rows.Clear();
+
+ foreach (var elem in dict)
+ {
+ dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" });
+
+ foreach (var listElem in elem.Bouquets)
+ {
+ dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
+ }
+
+ dataGridView.Rows.Add(new object[] { "Всего:", "", elem.Count });
+ dataGridView.Rows.Add(Array.Empty