Что-то похожее на сделанную лабу

This commit is contained in:
dasha 2023-03-23 19:48:59 +04:00
parent 32635a6eba
commit ec4a31077f
23 changed files with 1178 additions and 46 deletions

View File

@ -37,6 +37,9 @@
this.списокИнгредиентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.списокИнгредиентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ингредиентыПоСушиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ингредиентыПоСушиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокМагазиновToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.магазинССушиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.списокЗаказовОбъединенныхПоДатамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonUpdate = new System.Windows.Forms.Button(); this.buttonUpdate = new System.Windows.Forms.Button();
this.buttonSetToFinish = new System.Windows.Forms.Button(); this.buttonSetToFinish = new System.Windows.Forms.Button();
this.buttonSetToDone = new System.Windows.Forms.Button(); this.buttonSetToDone = new System.Windows.Forms.Button();
@ -45,7 +48,6 @@
this.dataGridView = new System.Windows.Forms.DataGridView(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonAddSushiInShop = new System.Windows.Forms.Button(); this.buttonAddSushiInShop = new System.Windows.Forms.Button();
this.buttonSellSushi = new System.Windows.Forms.Button(); this.buttonSellSushi = new System.Windows.Forms.Button();
this.списокМагазиновToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip.SuspendLayout(); this.menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
@ -98,7 +100,9 @@
this.списокИнгредиентовToolStripMenuItem, this.списокИнгредиентовToolStripMenuItem,
this.ингредиентыПоСушиToolStripMenuItem, this.ингредиентыПоСушиToolStripMenuItem,
this.списокЗаказовToolStripMenuItem, this.списокЗаказовToolStripMenuItem,
this.списокМагазиновToolStripMenuItem}); this.списокМагазиновToolStripMenuItem,
this.магазинССушиToolStripMenuItem,
this.списокЗаказовОбъединенныхПоДатамToolStripMenuItem});
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20); this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
this.отчетыToolStripMenuItem.Text = "Отчеты"; this.отчетыToolStripMenuItem.Text = "Отчеты";
@ -106,24 +110,45 @@
// списокИнгредиентовToolStripMenuItem // списокИнгредиентовToolStripMenuItem
// //
this.списокИнгредиентовToolStripMenuItem.Name = "списокИнгредиентовToolStripMenuItem"; this.списокИнгредиентовToolStripMenuItem.Name = "списокИнгредиентовToolStripMenuItem";
this.списокИнгредиентовToolStripMenuItem.Size = new System.Drawing.Size(203, 22); this.списокИнгредиентовToolStripMenuItem.Size = new System.Drawing.Size(310, 22);
this.списокИнгредиентовToolStripMenuItem.Text = "Список суши"; this.списокИнгредиентовToolStripMenuItem.Text = "Список суши";
this.списокИнгредиентовToolStripMenuItem.Click += new System.EventHandler(this.SushiListToolStripMenuItem_Click); this.списокИнгредиентовToolStripMenuItem.Click += new System.EventHandler(this.SushiListToolStripMenuItem_Click);
// //
// ингредиентыПоСушиToolStripMenuItem // ингредиентыПоСушиToolStripMenuItem
// //
this.ингредиентыПоСушиToolStripMenuItem.Name = "ингредиентыПоСушиToolStripMenuItem"; this.ингредиентыПоСушиToolStripMenuItem.Name = "ингредиентыПоСушиToolStripMenuItem";
this.ингредиентыПоСушиToolStripMenuItem.Size = new System.Drawing.Size(203, 22); this.ингредиентыПоСушиToolStripMenuItem.Size = new System.Drawing.Size(310, 22);
this.ингредиентыПоСушиToolStripMenuItem.Text = "Суши с ингредиентами"; this.ингредиентыПоСушиToolStripMenuItem.Text = "Суши с ингредиентами";
this.ингредиентыПоСушиToolStripMenuItem.Click += new System.EventHandler(this.SushiIngredientToolStripMenuItem_Click); this.ингредиентыПоСушиToolStripMenuItem.Click += new System.EventHandler(this.SushiIngredientToolStripMenuItem_Click);
// //
// списокЗаказовToolStripMenuItem // списокЗаказовToolStripMenuItem
// //
this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(203, 22); this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(310, 22);
this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
// //
// списокМагазиновToolStripMenuItem
//
this.списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
this.списокМагазиновToolStripMenuItem.Size = new System.Drawing.Size(310, 22);
this.списокМагазиновToolStripMenuItem.Text = "Список магазинов";
this.списокМагазиновToolStripMenuItem.Click += new System.EventHandler(this.ShopsReportToolStripMenuItem_Click);
//
// магазинССушиToolStripMenuItem
//
this.магазинССушиToolStripMenuItem.Name = агазинССушиToolStripMenuItem";
this.магазинССушиToolStripMenuItem.Size = new System.Drawing.Size(310, 22);
this.магазинССушиToolStripMenuItem.Text = "Магазин с суши";
this.магазинССушиToolStripMenuItem.Click += new System.EventHandler(this.ShopSushiToolStripMenuItem_Click);
//
// списокЗаказовОбъединенныхПоДатамToolStripMenuItem
//
this.списокЗаказовОбъединенныхПоДатамToolStripMenuItem.Name = "списокЗаказовОбъединенныхПоДатамToolStripMenuItem";
this.списокЗаказовОбъединенныхПоДатамToolStripMenuItem.Size = new System.Drawing.Size(310, 22);
this.списокЗаказовОбъединенныхПоДатамToolStripMenuItem.Text = "Список заказов, сгрупированных по датам";
this.списокЗаказовОбъединенныхПоДатамToolStripMenuItem.Click += new System.EventHandler(this.OrdersGroupedByDateToolStripMenuItem_Click);
//
// buttonUpdate // buttonUpdate
// //
this.buttonUpdate.Location = new System.Drawing.Point(778, 212); this.buttonUpdate.Location = new System.Drawing.Point(778, 212);
@ -213,13 +238,6 @@
this.buttonSellSushi.UseVisualStyleBackColor = true; this.buttonSellSushi.UseVisualStyleBackColor = true;
this.buttonSellSushi.Click += new System.EventHandler(this.ButtonSellSushi_Click); this.buttonSellSushi.Click += new System.EventHandler(this.ButtonSellSushi_Click);
// //
// списокМагазиновToolStripMenuItem
//
this.списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
this.списокМагазиновToolStripMenuItem.Size = new System.Drawing.Size(203, 22);
this.списокМагазиновToolStripMenuItem.Text = "Список магазинов";
this.списокМагазиновToolStripMenuItem.Click += new System.EventHandler(this.ShopsReportToolStripMenuItem_Click);
//
// FormMain // FormMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@ -266,5 +284,7 @@
private Button buttonAddSushiInShop; private Button buttonAddSushiInShop;
private Button buttonSellSushi; private Button buttonSellSushi;
private ToolStripMenuItem списокМагазиновToolStripMenuItem; private ToolStripMenuItem списокМагазиновToolStripMenuItem;
private ToolStripMenuItem магазинССушиToolStripMenuItem;
private ToolStripMenuItem списокЗаказовОбъединенныхПоДатамToolStripMenuItem;
} }
} }

View File

@ -174,6 +174,15 @@ namespace SushiBarView
} }
} }
private void ShopSushiToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportShopListSushi));
if (service is FormReportShopListSushi form)
{
form.ShowDialog();
}
}
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
@ -182,6 +191,16 @@ namespace SushiBarView
form.ShowDialog(); form.ShowDialog();
} }
} }
private void OrdersGroupedByDateToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrdersGroupedByDate));
if (service is FormReportOrdersGroupedByDate form)
{
form.ShowDialog();
}
}
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e) private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormShops)); var service = Program.ServiceProvider?.GetService(typeof(FormShops));

View File

@ -0,0 +1,92 @@
namespace SushiBarView
{
partial class FormReportOrdersGroupedByDate
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel = new System.Windows.Forms.Panel();
this.buttonToPdf = new System.Windows.Forms.Button();
this.buttonMake = new System.Windows.Forms.Button();
this.panel.SuspendLayout();
this.SuspendLayout();
//
// panel
//
this.panel.Controls.Add(this.buttonToPdf);
this.panel.Controls.Add(this.buttonMake);
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(4, 3, 4, 3);
this.panel.Name = "panel";
this.panel.Size = new System.Drawing.Size(1031, 40);
this.panel.TabIndex = 0;
//
// buttonToPdf
//
this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonToPdf.Location = new System.Drawing.Point(160, 8);
this.buttonToPdf.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonToPdf.Name = "buttonToPdf";
this.buttonToPdf.Size = new System.Drawing.Size(139, 27);
this.buttonToPdf.TabIndex = 5;
this.buttonToPdf.Text = "В Pdf";
this.buttonToPdf.UseVisualStyleBackColor = true;
this.buttonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click);
//
// buttonMake
//
this.buttonMake.Location = new System.Drawing.Point(13, 8);
this.buttonMake.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonMake.Name = "buttonMake";
this.buttonMake.Size = new System.Drawing.Size(139, 27);
this.buttonMake.TabIndex = 4;
this.buttonMake.Text = "Сформировать";
this.buttonMake.UseVisualStyleBackColor = true;
this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click);
//
// FormReportOrdersGroupedByDate
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1031, 647);
this.Controls.Add(this.panel);
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "FormReportOrdersGroupedByDate";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Заказы, сгрупированные по дате";
this.panel.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Panel panel;
private System.Windows.Forms.Button buttonToPdf;
private System.Windows.Forms.Button buttonMake;
}
}

View File

@ -0,0 +1,73 @@
using Microsoft.Extensions.Logging;
using Microsoft.Reporting.WinForms;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts;
namespace SushiBarView
{
public partial class FormReportOrdersGroupedByDate : Form
{
private readonly ReportViewer reportViewer;
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public FormReportOrdersGroupedByDate(ILogger<FormReportOrdersGroupedByDate> logger, IReportLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
reportViewer = new ReportViewer
{
Dock = DockStyle.Fill
};
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrdersGroupedByDate.rdlc", FileMode.Open));
Controls.Clear();
Controls.Add(reportViewer);
Controls.Add(panel);
}
private void ButtonMake_Click(object sender, EventArgs e)
{
try
{
var dataSource = _logic.GetOrdersGroupedByDate();
var source = new ReportDataSource("DataSetOrders", dataSource);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(source);
reportViewer.RefreshReport();
_logger.LogInformation("Загрузка списка заказов, сгруппированных по дате");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка заказов, сгруппированных по дате");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonToPdf_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SaveOrdersGroupedByDateToPdfFile(new ReportBindingModel
{
FileName = dialog.FileName
});
_logger.LogInformation("Сохранение списка заказов");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,115 @@
namespace SushiBarView
{
partial class FormReportShopListSushi
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.ColumnShop = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnSushi = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.button1 = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.AllowUserToOrderColumns = true;
this.dataGridView.AllowUserToResizeColumns = false;
this.dataGridView.AllowUserToResizeRows = false;
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ColumnShop,
this.ColumnSushi,
this.ColumnCount});
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom;
this.dataGridView.Location = new System.Drawing.Point(0, 47);
this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.dataGridView.MultiSelect = false;
this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersVisible = false;
this.dataGridView.Size = new System.Drawing.Size(616, 510);
this.dataGridView.TabIndex = 2;
//
// ColumnShop
//
this.ColumnShop.HeaderText = "Магазин";
this.ColumnShop.Name = "ColumnShop";
this.ColumnShop.ReadOnly = true;
this.ColumnShop.Width = 200;
//
// ColumnSushi
//
this.ColumnSushi.HeaderText = "Суши";
this.ColumnSushi.Name = "ColumnSushi";
this.ColumnSushi.ReadOnly = true;
this.ColumnSushi.Width = 200;
//
// ColumnCount
//
this.ColumnCount.HeaderText = "Количество";
this.ColumnCount.Name = "ColumnCount";
this.ColumnCount.ReadOnly = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(13, 14);
this.button1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(186, 27);
this.button1.TabIndex = 4;
this.button1.Text = "Сохранить в Excel";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
//
// FormReportShopListSushi
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(616, 557);
this.Controls.Add(this.button1);
this.Controls.Add(this.dataGridView);
this.Name = "FormReportShopListSushi";
this.Text = "Суши по магазинам";
this.Load += new System.EventHandler(this.FormReportShopListSushi_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private DataGridViewTextBoxColumn ColumnShop;
private DataGridViewTextBoxColumn ColumnSushi;
private DataGridViewTextBoxColumn ColumnCount;
private Button button1;
}
}

View File

@ -0,0 +1,70 @@
using Microsoft.Extensions.Logging;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts;
namespace SushiBarView
{
public partial class FormReportShopListSushi : Form
{
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public FormReportShopListSushi(ILogger<FormReportShopListSushi> logger, IReportLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormReportShopListSushi_Load(object sender, EventArgs e)
{
try
{
var dict = _logic.GetShopSushi();
if (dict != null)
{
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" });
foreach (var listElem in elem.ListSushi)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
dataGridView.Rows.Add(Array.Empty<object>());
}
}
_logger.LogInformation("Загрузка списка магазинов с суши");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка магазинов с суши");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SaveShopSushiToExcelFile(new ReportBindingModel
{
FileName = dialog.FileName
});
_logger.LogInformation("Сохранение списка магазинов с суши");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка магазинов с суши");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -47,12 +47,12 @@ namespace SushiBarView
services.AddTransient<IOrderLogic, OrderLogic>(); services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ISushiLogic, SushiLogic>(); services.AddTransient<ISushiLogic, SushiLogic>();
services.AddTransient<IReportLogic, ReportLogic>(); services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>(); services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToWord, SaveToWord>(); services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>(); services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<FormIngredient>(); services.AddTransient<FormIngredient>();
services.AddTransient<FormIngredients>(); services.AddTransient<FormIngredients>();
@ -61,7 +61,9 @@ namespace SushiBarView
services.AddTransient<FormSushiIngredients>(); services.AddTransient<FormSushiIngredients>();
services.AddTransient<FormListSushi>(); services.AddTransient<FormListSushi>();
services.AddTransient<FormReportSushiIngredients>(); services.AddTransient<FormReportSushiIngredients>();
services.AddTransient<FormReportShopListSushi>();
services.AddTransient<FormReportOrders>(); services.AddTransient<FormReportOrders>();
services.AddTransient<FormReportOrdersGroupedByDate>();
services.AddTransient<FormShopSushi>(); services.AddTransient<FormShopSushi>();
services.AddTransient<FormShops>(); services.AddTransient<FormShops>();
services.AddTransient<FormShop>(); services.AddTransient<FormShop>();

View File

@ -0,0 +1,394 @@
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<AutoRefresh>0</AutoRefresh>
<DataSources>
<DataSource Name="SushiBarContractsViewModels">
<ConnectionProperties>
<DataProvider>System.Data.DataSet</DataProvider>
<ConnectString>/* Local Connection */</ConnectString>
</ConnectionProperties>
<rd:DataSourceID>10791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
</DataSource>
</DataSources>
<DataSets>
<DataSet Name="DataSetOrders">
<Query>
<DataSourceName>SushiBarContractsViewModels</DataSourceName>
<CommandText>/* Local Query */</CommandText>
</Query>
<Fields>
<Field Name="DateCreate">
<DataField>DateCreate</DataField>
<rd:TypeName>System.DateTime</rd:TypeName>
</Field>
<Field Name="Sum">
<DataField>Sum</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="Count">
<DataField>Count</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
</Fields>
<rd:DataSetInfo>
<rd:DataSetName>SushiBarContracts.ViewModels</rd:DataSetName>
<rd:TableName>ReportOrdersViewModel</rd:TableName>
<rd:ObjectDataSourceType>SushiBarContracts.ViewModels.ReportOrdersViewModel, SushiBarContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
</rd:DataSetInfo>
</DataSet>
</DataSets>
<ReportSections>
<ReportSection>
<Body>
<ReportItems>
<Textbox Name="ReportParameterPeriod">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Parameters!ReportParameterPeriod.Value</Value>
<Style>
<FontSize>14pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
<Top>1cm</Top>
<Height>1cm</Height>
<Width>21cm</Width>
<Style>
<Border>
<Style>None</Style>
</Border>
<VerticalAlign>Middle</VerticalAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Textbox Name="TextboxTitle">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Заказы</Value>
<Style>
<FontSize>16pt</FontSize>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style>
<TextAlign>Center</TextAlign>
</Style>
</Paragraph>
</Paragraphs>
<Height>1cm</Height>
<Width>21cm</Width>
<ZIndex>1</ZIndex>
<Style>
<Border>
<Style>None</Style>
</Border>
<VerticalAlign>Middle</VerticalAlign>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<Tablix Name="Tablix1">
<TablixBody>
<TablixColumns>
<TablixColumn>
<Width>6.60986cm</Width>
</TablixColumn>
<TablixColumn>
<Width>6.60986cm</Width>
</TablixColumn>
<TablixColumn>
<Width>6.60986cm</Width>
</TablixColumn>
</TablixColumns>
<TablixRows>
<TablixRow>
<Height>0.61323cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="Textbox2">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Дата заказов</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox2</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox1">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Количество заказов</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox1</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Textbox7">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>Сумма</Value>
<Style>
<FontWeight>Bold</FontWeight>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Textbox7</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
<TablixRow>
<Height>0.61323cm</Height>
<TablixCells>
<TablixCell>
<CellContents>
<Textbox Name="DateCreate">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!DateCreate.Value</Value>
<Style>
<Format>d</Format>
</Style>
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>DateCreate</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<rd:Selected>true</rd:Selected>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Count">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Count.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Count</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
<TablixCell>
<CellContents>
<Textbox Name="Sum">
<CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether>
<Paragraphs>
<Paragraph>
<TextRuns>
<TextRun>
<Value>=Fields!Sum.Value</Value>
<Style />
</TextRun>
</TextRuns>
<Style />
</Paragraph>
</Paragraphs>
<rd:DefaultName>Sum</rd:DefaultName>
<Style>
<Border>
<Color>LightGrey</Color>
<Style>Solid</Style>
</Border>
<PaddingLeft>2pt</PaddingLeft>
<PaddingRight>2pt</PaddingRight>
<PaddingTop>2pt</PaddingTop>
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
</CellContents>
</TablixCell>
</TablixCells>
</TablixRow>
</TablixRows>
</TablixBody>
<TablixColumnHierarchy>
<TablixMembers>
<TablixMember />
<TablixMember />
<TablixMember />
</TablixMembers>
</TablixColumnHierarchy>
<TablixRowHierarchy>
<TablixMembers>
<TablixMember>
<KeepWithGroup>After</KeepWithGroup>
</TablixMember>
<TablixMember>
<Group Name="Подробности" />
</TablixMember>
</TablixMembers>
</TablixRowHierarchy>
<DataSetName>DataSetOrders</DataSetName>
<Top>2.48391cm</Top>
<Left>0.55245cm</Left>
<Height>1.22646cm</Height>
<Width>19.82958cm</Width>
<ZIndex>2</ZIndex>
<Style>
<Border>
<Style>Double</Style>
</Border>
</Style>
</Tablix>
</ReportItems>
<Height>5.72875cm</Height>
<Style />
</Body>
<Width>21cm</Width>
<Page>
<PageHeight>29.7cm</PageHeight>
<PageWidth>21cm</PageWidth>
<LeftMargin>2cm</LeftMargin>
<RightMargin>2cm</RightMargin>
<TopMargin>2cm</TopMargin>
<BottomMargin>2cm</BottomMargin>
<ColumnSpacing>0.13cm</ColumnSpacing>
<Style />
</Page>
</ReportSection>
</ReportSections>
<ReportParameters>
<ReportParameter Name="ReportParameterPeriod">
<DataType>String</DataType>
<Nullable>true</Nullable>
<Prompt>ReportParameter1</Prompt>
</ReportParameter>
</ReportParameters>
<ReportParametersLayout>
<GridLayoutDefinition>
<NumberOfColumns>4</NumberOfColumns>
<NumberOfRows>2</NumberOfRows>
<CellDefinitions>
<CellDefinition>
<ColumnIndex>0</ColumnIndex>
<RowIndex>0</RowIndex>
<ParameterName>ReportParameterPeriod</ParameterName>
</CellDefinition>
</CellDefinitions>
</GridLayoutDefinition>
</ReportParametersLayout>
<rd:ReportUnitType>Cm</rd:ReportUnitType>
<rd:ReportID>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID>
</Report>

View File

@ -35,5 +35,11 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="ReportOrdersGroupedByDate.rdlc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -10,8 +10,6 @@ namespace SushiBarBusinessLogic.BusinessLogics
{ {
public class ReportLogic : IReportLogic public class ReportLogic : IReportLogic
{ {
private readonly IIngredientStorage _ingredientStorage;
private readonly ISushiStorage _sushiStorage; private readonly ISushiStorage _sushiStorage;
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
@ -24,17 +22,16 @@ namespace SushiBarBusinessLogic.BusinessLogics
private readonly AbstractSaveToPdf _saveToPdf; private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(ISushiStorage productStorage, IIngredientStorage ingredientStorage, IOrderStorage orderStorage, public ReportLogic(ISushiStorage productStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf, IShopStorage shopStorage) AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf, IShopStorage shopStorage)
{ {
_sushiStorage = productStorage; _sushiStorage = productStorage;
_ingredientStorage = ingredientStorage;
_orderStorage = orderStorage; _orderStorage = orderStorage;
_shopStorage = shopStorage;
_saveToExcel = saveToExcel; _saveToExcel = saveToExcel;
_saveToWord = saveToWord; _saveToWord = saveToWord;
_saveToPdf = saveToPdf; _saveToPdf = saveToPdf;
_shopStorage = shopStorage;
} }
/// <summary> /// <summary>
@ -43,13 +40,11 @@ namespace SushiBarBusinessLogic.BusinessLogics
/// <returns></returns> /// <returns></returns>
public List<ReportSushiIngredientViewModel> GetSushiIngredient() public List<ReportSushiIngredientViewModel> GetSushiIngredient()
{ {
var ingredients = _ingredientStorage.GetFullList(); var listSushi = _sushiStorage.GetFullList();
var sushiList = _sushiStorage.GetFullList();
var list = new List<ReportSushiIngredientViewModel>(); var list = new List<ReportSushiIngredientViewModel>();
foreach (var sushi in sushiList) foreach (var sushi in listSushi)
{ {
var record = new ReportSushiIngredientViewModel var record = new ReportSushiIngredientViewModel
{ {
@ -57,19 +52,41 @@ namespace SushiBarBusinessLogic.BusinessLogics
Ingredients = new(), Ingredients = new(),
TotalCount = 0 TotalCount = 0
}; };
foreach (var ingredient in ingredients) foreach (var ingredient in sushi.SushiIngredients)
{ {
if (sushi.SushiIngredients.ContainsKey(ingredient.Id)) record.Ingredients.Add(new(ingredient.Value.Item1.IngredientName, ingredient.Value.Item2));
{ record.TotalCount += ingredient.Value.Item2;
record.Ingredients.Add(new(ingredient.IngredientName,
sushi.SushiIngredients[ingredient.Id].Item2));
record.TotalCount += sushi.SushiIngredients[ingredient.Id].Item2;
}
} }
list.Add(record); list.Add(record);
} }
return list;
}
/// <summary>
/// Получение списка суши с указанием, в каких магазинах используются
/// </summary>
/// <returns></returns>
public List<ReportShopSushiViewModel> GetShopSushi()
{
var shops = _shopStorage.GetFullList();
var list = new List<ReportShopSushiViewModel>();
foreach (var shop in shops)
{
var record = new ReportShopSushiViewModel
{
ShopName = shop.ShopName,
ListSushi = new(),
TotalCount = 0
};
foreach (var sushi in shop.ListSushi)
{
record.ListSushi.Add(new(sushi.Value.Item1.SushiName, sushi.Value.Item2));
record.TotalCount += sushi.Value.Item2;
}
list.Add(record);
}
return list; return list;
} }
@ -92,6 +109,24 @@ namespace SushiBarBusinessLogic.BusinessLogics
.ToList(); .ToList();
} }
/// <summary>
/// Получение списка заказов, сгруппированных по дате
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public List<ReportOrdersGroupedByDateViewModel> GetOrdersGroupedByDate()
{
return _orderStorage.GetFullList()
.GroupBy(x => x.DateCreate.Date)
.Select(x => new ReportOrdersGroupedByDateViewModel
{
DateCreate = x.Key,
Count = x.Count(),
Sum = x.Sum(x => x.Sum)
})
.ToList();
}
/// <summary> /// <summary>
/// Сохранение суши в файл-Word /// Сохранение суши в файл-Word
/// </summary> /// </summary>
@ -134,6 +169,20 @@ namespace SushiBarBusinessLogic.BusinessLogics
}); });
} }
/// <summary>
/// Сохранение ингредиентов с указаеним суши в файл-Excel
/// </summary>
/// <param name="model"></param>
public void SaveShopSushiToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateShopReport(new ExcelInfo
{
FileName = model.FileName,
Title = "Список магазинов",
ShopListSushi = GetShopSushi()
});
}
/// <summary> /// <summary>
/// Сохранение заказов в файл-Pdf /// Сохранение заказов в файл-Pdf
/// </summary> /// </summary>
@ -149,5 +198,19 @@ namespace SushiBarBusinessLogic.BusinessLogics
Orders = GetOrders(model) Orders = GetOrders(model)
}); });
} }
/// <summary>
/// Сохранение заказов в файл-Pdf
/// </summary>
/// <param name="model"></param>
public void SaveOrdersGroupedByDateToPdfFile(ReportBindingModel model)
{
_saveToPdf.CreateOrdersGroupedByDateDoc(new PdfInfo
{
FileName = model.FileName,
Title = "Список заказов",
OrdersGroupedByDate = GetOrdersGroupedByDate()
});
}
} }
} }

View File

@ -28,18 +28,18 @@ namespace SushiBarBusinessLogic.OfficePackage
}); });
uint rowIndex = 2; uint rowIndex = 2;
foreach (var pc in info.SushiIngredients) foreach (var si in info.SushiIngredients)
{ {
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
ColumnName = "A", ColumnName = "A",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = pc.SushiName, Text = si.SushiName,
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });
rowIndex++; rowIndex++;
foreach (var (Ingredient, Count) in pc.Ingredients) foreach (var (Ingredient, Count) in si.Ingredients)
{ {
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {
@ -71,7 +71,7 @@ namespace SushiBarBusinessLogic.OfficePackage
{ {
ColumnName = "C", ColumnName = "C",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = pc.TotalCount.ToString(), Text = si.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });
rowIndex++; rowIndex++;
@ -80,11 +80,86 @@ namespace SushiBarBusinessLogic.OfficePackage
SaveExcel(info); SaveExcel(info);
} }
/// <summary> /// <summary>
/// Создание excel-файла /// Создание отчета по
/// </summary> /// </summary>
/// <param name="info"></param> /// <param name="info"></param>
protected abstract void CreateExcel(ExcelInfo info); public void CreateShopReport(ExcelInfo info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var ss in info.ShopListSushi)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = ss.ShopName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var (Sushi, Count) in ss.ListSushi)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = Sushi,
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = Count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBroder
});
rowIndex++;
}
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = "Итого",
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = ss.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
SaveExcel(info);
}
/// <summary>
/// Создание excel-файла
/// </summary>
/// <param name="info"></param>
protected abstract void CreateExcel(ExcelInfo info);
/// <summary> /// <summary>
/// Добавляем новую ячейку в лист /// Добавляем новую ячейку в лист

View File

@ -5,6 +5,10 @@ namespace SushiBarBusinessLogic.OfficePackage
{ {
public abstract class AbstractSaveToPdf public abstract class AbstractSaveToPdf
{ {
/// <summary>
/// Создание doc-файла
/// </summary>
/// <param name="info"></param>
public void CreateDoc(PdfInfo info) public void CreateDoc(PdfInfo info)
{ {
CreatePdf(info); CreatePdf(info);
@ -34,10 +38,32 @@ namespace SushiBarBusinessLogic.OfficePackage
SavePdf(info); SavePdf(info);
} }
/// <summary> public void CreateOrdersGroupedByDateDoc(PdfInfo info)
/// Создание doc-файла {
/// </summary> CreatePdf(info);
/// <param name="info"></param> CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateTable(new List<string> { "3cm", "3cm", "3cm"});
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Дата заказов", "Количество заказов" ,"Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
foreach (var order in info.OrdersGroupedByDate)
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { order.DateCreate.ToShortDateString(), order.Count.ToString(), order.Sum.ToString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});
}
SavePdf(info);
}
protected abstract void CreatePdf(PdfInfo info); protected abstract void CreatePdf(PdfInfo info);
/// <summary> /// <summary>

View File

@ -9,5 +9,7 @@ namespace SushiBarBusinessLogic.OfficePackage.HelperModels
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<ReportSushiIngredientViewModel> SushiIngredients { get; set; } = new(); public List<ReportSushiIngredientViewModel> SushiIngredients { get; set; } = new();
public List<ReportShopSushiViewModel> ShopListSushi { get; set; } = new();
} }
} }

View File

@ -13,5 +13,7 @@ namespace SushiBarBusinessLogic.OfficePackage.HelperModels
public DateTime DateTo { get; set; } public DateTime DateTo { get; set; }
public List<ReportOrdersViewModel> Orders { get; set; } = new(); public List<ReportOrdersViewModel> Orders { get; set; } = new();
public List<ReportOrdersGroupedByDateViewModel> OrdersGroupedByDate { get; set; } = new();
} }
} }

View File

@ -11,6 +11,12 @@ namespace SushiBarContracts.BusinessLogicsContracts
/// <returns></returns> /// <returns></returns>
List<ReportSushiIngredientViewModel> GetSushiIngredient(); List<ReportSushiIngredientViewModel> GetSushiIngredient();
/// <summary>
/// Получение списка суши с указанием, в каких магазинах используются
/// </summary>
/// <returns></returns>
List<ReportShopSushiViewModel> GetShopSushi();
/// <summary> /// <summary>
/// Получение списка заказов за определенный период /// Получение списка заказов за определенный период
/// </summary> /// </summary>
@ -18,6 +24,13 @@ namespace SushiBarContracts.BusinessLogicsContracts
/// <returns></returns> /// <returns></returns>
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model); List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
/// <summary>
/// Получение списка заказов, сгруппированных по дате
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
List<ReportOrdersGroupedByDateViewModel> GetOrdersGroupedByDate();
/// <summary> /// <summary>
/// Сохранение суши в файл-Word /// Сохранение суши в файл-Word
/// </summary> /// </summary>
@ -36,10 +49,22 @@ namespace SushiBarContracts.BusinessLogicsContracts
/// <param name="model"></param> /// <param name="model"></param>
void SaveSushiIngredientToExcelFile(ReportBindingModel model); void SaveSushiIngredientToExcelFile(ReportBindingModel model);
/// <summary>
/// Сохранение суши с указаеним магазинов в файл-Excel
/// </summary>
/// <param name="model"></param>
void SaveShopSushiToExcelFile(ReportBindingModel model);
/// <summary> /// <summary>
/// Сохранение заказов в файл-Pdf /// Сохранение заказов в файл-Pdf
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
void SaveOrdersToPdfFile(ReportBindingModel model); void SaveOrdersToPdfFile(ReportBindingModel model);
/// <summary>
/// Сохранение сгруппированных заказов в файл-Pdf
/// </summary>
/// <param name="model"></param>
void SaveOrdersGroupedByDateToPdfFile(ReportBindingModel model);
} }
} }

View File

@ -0,0 +1,11 @@
namespace SushiBarContracts.ViewModels
{
public class ReportOrdersGroupedByDateViewModel
{
public DateTime DateCreate { get; set; }
public int Count { get; set; }
public double Sum { get; set; }
}
}

View File

@ -0,0 +1,11 @@
namespace SushiBarContracts.ViewModels
{
public class ReportShopSushiViewModel
{
public string ShopName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<(string Sushi, int Count)> ListSushi { get; set; } = new();
}
}

View File

@ -12,7 +12,7 @@ using SushiBarDatabaseImplement;
namespace SushiBarDatabaseImplement.Migrations namespace SushiBarDatabaseImplement.Migrations
{ {
[DbContext(typeof(SushiBarDatabase))] [DbContext(typeof(SushiBarDatabase))]
[Migration("20230314085708_ShopMigration")] [Migration("20230323154341_ShopMigration")]
partial class ShopMigration partial class ShopMigration
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -197,7 +197,7 @@ namespace SushiBarDatabaseImplement.Migrations
.IsRequired(); .IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi") b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
.WithMany() .WithMany("ShopsFk")
.HasForeignKey("SushiId") .HasForeignKey("SushiId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
@ -241,6 +241,8 @@ namespace SushiBarDatabaseImplement.Migrations
b.Navigation("Ingredients"); b.Navigation("Ingredients");
b.Navigation("Orders"); b.Navigation("Orders");
b.Navigation("ShopsFk");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }

View File

@ -194,7 +194,7 @@ namespace SushiBarDatabaseImplement.Migrations
.IsRequired(); .IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi") b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
.WithMany() .WithMany("ShopsFk")
.HasForeignKey("SushiId") .HasForeignKey("SushiId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
@ -238,6 +238,8 @@ namespace SushiBarDatabaseImplement.Migrations
b.Navigation("Ingredients"); b.Navigation("Ingredients");
b.Navigation("Orders"); b.Navigation("Orders");
b.Navigation("ShopsFk");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }

View File

@ -36,6 +36,8 @@ namespace SushiBarDatabaseImplement.Models
public virtual List<SushiIngredient> Ingredients { get; set; } = new(); public virtual List<SushiIngredient> Ingredients { get; set; } = new();
[ForeignKey("SushiId")] [ForeignKey("SushiId")]
public virtual List<Order> Orders { get; set; } = new(); public virtual List<Order> Orders { get; set; } = new();
[ForeignKey("SushiId")]
public virtual List<ShopSushi> ShopsFk { get; set; } = new();
public static Sushi Create(SushiBarDatabase context, SushiBindingModel model) public static Sushi Create(SushiBarDatabase context, SushiBindingModel model)
{ {