Compare commits
28 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a5416faf49 | |||
| 5aa0881ebb | |||
| 50ca7e4588 | |||
| 482c968ec5 | |||
| efc5be0212 | |||
| b4e81d4ee3 | |||
| 58b7de8dfd | |||
| d0f477cbb7 | |||
| 60dbd3137f | |||
| 33f57f1dcc | |||
| c591edeb20 | |||
| fca9722997 | |||
| bec20cc03c | |||
| a02860894a | |||
| 67b8b93a20 | |||
| 5c684836d6 | |||
| 442ebcea15 | |||
| 3787a8f033 | |||
| 5ab370a59d | |||
| 5259f0c89f | |||
| 787432c6ec | |||
| 5c96df7985 | |||
| a86de588aa | |||
| 351921e1f7 | |||
| 0fa0867876 | |||
| 9c61f92636 | |||
| 363f6fe4e4 | |||
| 2cd58bcc70 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -400,4 +400,5 @@ FodyWeavers.xsd
|
|||||||
|
|
||||||
|
|
||||||
/Pizzeria/ImplementationExtensions
|
/Pizzeria/ImplementationExtensions
|
||||||
|
BusinessLogicExtensions
|
||||||
/BankExecutor
|
/BankExecutor
|
||||||
@@ -19,7 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaDatabaseImplement",
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaShopRestApi", "PizzeriaShopRestApi\PizzeriaShopRestApi.csproj", "{6B68ABCB-DDDE-452C-AE2E-9299654EE136}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaShopRestApi", "PizzeriaShopRestApi\PizzeriaShopRestApi.csproj", "{6B68ABCB-DDDE-452C-AE2E-9299654EE136}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaShowClientApp", "PizzeriaShowClientApp\PizzeriaShowClientApp.csproj", "{398E33EF-536B-4D15-8D69-9B4E9406DA93}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PizzeriaShowClientApp", "PizzeriaShowClientApp\PizzeriaShowClientApp.csproj", "{398E33EF-536B-4D15-8D69-9B4E9406DA93}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PizzeriaShopsApp", "PizzeriaShopsApi\PizzeriaShopsApp.csproj", "{FC601C98-1314-4801-ADB7-5FDCBCC7D507}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -63,6 +65,10 @@ Global
|
|||||||
{398E33EF-536B-4D15-8D69-9B4E9406DA93}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{398E33EF-536B-4D15-8D69-9B4E9406DA93}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{398E33EF-536B-4D15-8D69-9B4E9406DA93}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{398E33EF-536B-4D15-8D69-9B4E9406DA93}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{398E33EF-536B-4D15-8D69-9B4E9406DA93}.Release|Any CPU.Build.0 = Release|Any CPU
|
{398E33EF-536B-4D15-8D69-9B4E9406DA93}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FC601C98-1314-4801-ADB7-5FDCBCC7D507}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FC601C98-1314-4801-ADB7-5FDCBCC7D507}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FC601C98-1314-4801-ADB7-5FDCBCC7D507}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FC601C98-1314-4801-ADB7-5FDCBCC7D507}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -6,6 +6,6 @@
|
|||||||
<add key="PopHost" value="pop.gmail.com" />
|
<add key="PopHost" value="pop.gmail.com" />
|
||||||
<add key="PopPort" value="995" />
|
<add key="PopPort" value="995" />
|
||||||
<add key="MailLogin" value="zahar230668@gmail.com" />
|
<add key="MailLogin" value="zahar230668@gmail.com" />
|
||||||
<add key="MailPassword" value="klwy ypmv gefu yrug" />
|
<add key="MailPassword" value="mdvt hqni jfqf frme" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
@@ -45,6 +45,7 @@ namespace PizzeriaView
|
|||||||
{
|
{
|
||||||
column.Width = columnAttr.Width;
|
column.Width = columnAttr.Width;
|
||||||
}
|
}
|
||||||
|
column.DefaultCellStyle.Format = columnAttr.Format;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
35
Pizzeria/Pizzeria/FormComponents.Designer.cs
generated
35
Pizzeria/Pizzeria/FormComponents.Designer.cs
generated
@@ -43,13 +43,12 @@
|
|||||||
this.dataGridView.AllowUserToAddRows = false;
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
this.dataGridView.AllowUserToDeleteRows = false;
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Location = new System.Drawing.Point(10, 9);
|
this.dataGridView.Location = new System.Drawing.Point(11, 12);
|
||||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.dataGridView.Name = "dataGridView";
|
this.dataGridView.Name = "dataGridView";
|
||||||
this.dataGridView.ReadOnly = true;
|
this.dataGridView.ReadOnly = true;
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
this.dataGridView.Size = new System.Drawing.Size(516, 320);
|
this.dataGridView.Size = new System.Drawing.Size(590, 427);
|
||||||
this.dataGridView.TabIndex = 0;
|
this.dataGridView.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// ToolsPanel
|
// ToolsPanel
|
||||||
@@ -58,18 +57,16 @@
|
|||||||
this.ToolsPanel.Controls.Add(this.buttonDelete);
|
this.ToolsPanel.Controls.Add(this.buttonDelete);
|
||||||
this.ToolsPanel.Controls.Add(this.buttonEdit);
|
this.ToolsPanel.Controls.Add(this.buttonEdit);
|
||||||
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
||||||
this.ToolsPanel.Location = new System.Drawing.Point(532, 9);
|
this.ToolsPanel.Location = new System.Drawing.Point(608, 12);
|
||||||
this.ToolsPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.ToolsPanel.Name = "ToolsPanel";
|
this.ToolsPanel.Name = "ToolsPanel";
|
||||||
this.ToolsPanel.Size = new System.Drawing.Size(158, 320);
|
this.ToolsPanel.Size = new System.Drawing.Size(181, 427);
|
||||||
this.ToolsPanel.TabIndex = 1;
|
this.ToolsPanel.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// buttonUpdate
|
// buttonUpdate
|
||||||
//
|
//
|
||||||
this.buttonUpdate.Location = new System.Drawing.Point(27, 154);
|
this.buttonUpdate.Location = new System.Drawing.Point(31, 205);
|
||||||
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonUpdate.Name = "buttonUpdate";
|
this.buttonUpdate.Name = "buttonUpdate";
|
||||||
this.buttonUpdate.Size = new System.Drawing.Size(110, 27);
|
this.buttonUpdate.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonUpdate.TabIndex = 3;
|
this.buttonUpdate.TabIndex = 3;
|
||||||
this.buttonUpdate.Text = "Обновить";
|
this.buttonUpdate.Text = "Обновить";
|
||||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
@@ -77,10 +74,9 @@
|
|||||||
//
|
//
|
||||||
// buttonDelete
|
// buttonDelete
|
||||||
//
|
//
|
||||||
this.buttonDelete.Location = new System.Drawing.Point(27, 106);
|
this.buttonDelete.Location = new System.Drawing.Point(31, 141);
|
||||||
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonDelete.Name = "buttonDelete";
|
this.buttonDelete.Name = "buttonDelete";
|
||||||
this.buttonDelete.Size = new System.Drawing.Size(110, 27);
|
this.buttonDelete.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonDelete.TabIndex = 2;
|
this.buttonDelete.TabIndex = 2;
|
||||||
this.buttonDelete.Text = "Удалить";
|
this.buttonDelete.Text = "Удалить";
|
||||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||||
@@ -88,10 +84,9 @@
|
|||||||
//
|
//
|
||||||
// buttonEdit
|
// buttonEdit
|
||||||
//
|
//
|
||||||
this.buttonEdit.Location = new System.Drawing.Point(27, 57);
|
this.buttonEdit.Location = new System.Drawing.Point(31, 76);
|
||||||
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonEdit.Name = "buttonEdit";
|
this.buttonEdit.Name = "buttonEdit";
|
||||||
this.buttonEdit.Size = new System.Drawing.Size(110, 27);
|
this.buttonEdit.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonEdit.TabIndex = 1;
|
this.buttonEdit.TabIndex = 1;
|
||||||
this.buttonEdit.Text = "Изменить";
|
this.buttonEdit.Text = "Изменить";
|
||||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||||
@@ -99,10 +94,9 @@
|
|||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(27, 12);
|
this.buttonAdd.Location = new System.Drawing.Point(31, 16);
|
||||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(110, 27);
|
this.buttonAdd.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonAdd.TabIndex = 0;
|
this.buttonAdd.TabIndex = 0;
|
||||||
this.buttonAdd.Text = "Добавить";
|
this.buttonAdd.Text = "Добавить";
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
@@ -110,12 +104,11 @@
|
|||||||
//
|
//
|
||||||
// FormComponents
|
// FormComponents
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
this.ClientSize = new System.Drawing.Size(800, 451);
|
||||||
this.Controls.Add(this.ToolsPanel);
|
this.Controls.Add(this.ToolsPanel);
|
||||||
this.Controls.Add(this.dataGridView);
|
this.Controls.Add(this.dataGridView);
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
|
||||||
this.Name = "FormComponents";
|
this.Name = "FormComponents";
|
||||||
this.Text = "Ингредиенты";
|
this.Text = "Ингредиенты";
|
||||||
this.Load += new System.EventHandler(this.FormComponents_Load);
|
this.Load += new System.EventHandler(this.FormComponents_Load);
|
||||||
|
|||||||
@@ -33,21 +33,13 @@ namespace PizzeriaView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
if (list != null)
|
_logger.LogInformation("Загрузка компонентов");
|
||||||
{
|
|
||||||
dataGridView.DataSource = list;
|
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
|
||||||
dataGridView.Columns["ComponentName"].AutoSizeMode =
|
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Загрузка ингридиентов");
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки ингридиентов");
|
_logger.LogError(ex, "Ошибка загрузки компонентов");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
MessageBoxIcon.Error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
|||||||
143
Pizzeria/Pizzeria/FormCreateSupply.Designer.cs
generated
Normal file
143
Pizzeria/Pizzeria/FormCreateSupply.Designer.cs
generated
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
partial class FormCreateSupply
|
||||||
|
{
|
||||||
|
/// <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.comboBoxShop = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelShop = new System.Windows.Forms.Label();
|
||||||
|
this.labelPizza = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxPizza = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBoxShop
|
||||||
|
//
|
||||||
|
this.comboBoxShop.FormattingEnabled = true;
|
||||||
|
this.comboBoxShop.Location = new System.Drawing.Point(115, 12);
|
||||||
|
this.comboBoxShop.Name = "comboBoxShop";
|
||||||
|
this.comboBoxShop.Size = new System.Drawing.Size(344, 28);
|
||||||
|
this.comboBoxShop.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// labelShop
|
||||||
|
//
|
||||||
|
this.labelShop.AutoSize = true;
|
||||||
|
this.labelShop.Location = new System.Drawing.Point(12, 15);
|
||||||
|
this.labelShop.Name = "labelShop";
|
||||||
|
this.labelShop.Size = new System.Drawing.Size(76, 20);
|
||||||
|
this.labelShop.TabIndex = 1;
|
||||||
|
this.labelShop.Text = "Магазин: ";
|
||||||
|
//
|
||||||
|
// labelPizza
|
||||||
|
//
|
||||||
|
this.labelPizza.AutoSize = true;
|
||||||
|
this.labelPizza.Location = new System.Drawing.Point(12, 49);
|
||||||
|
this.labelPizza.Name = "labelPizza";
|
||||||
|
this.labelPizza.Size = new System.Drawing.Size(75, 20);
|
||||||
|
this.labelPizza.TabIndex = 2;
|
||||||
|
this.labelPizza.Text = "Пицца: ";
|
||||||
|
//
|
||||||
|
// comboBoxPizza
|
||||||
|
//
|
||||||
|
this.comboBoxPizza.FormattingEnabled = true;
|
||||||
|
this.comboBoxPizza.Location = new System.Drawing.Point(115, 46);
|
||||||
|
this.comboBoxPizza.Name = "comboBoxPizza";
|
||||||
|
this.comboBoxPizza.Size = new System.Drawing.Size(344, 28);
|
||||||
|
this.comboBoxPizza.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
this.labelCount.AutoSize = true;
|
||||||
|
this.labelCount.Location = new System.Drawing.Point(12, 83);
|
||||||
|
this.labelCount.Name = "labelCount";
|
||||||
|
this.labelCount.Size = new System.Drawing.Size(97, 20);
|
||||||
|
this.labelCount.TabIndex = 4;
|
||||||
|
this.labelCount.Text = "Количество: ";
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(115, 80);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(344, 27);
|
||||||
|
this.textBoxCount.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(300, 113);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(116, 39);
|
||||||
|
this.buttonCancel.TabIndex = 6;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(168, 113);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(116, 39);
|
||||||
|
this.buttonSave.TabIndex = 7;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// FormCreateSupply
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(471, 164);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.labelCount);
|
||||||
|
this.Controls.Add(this.comboBoxPizza);
|
||||||
|
this.Controls.Add(this.labelPizza);
|
||||||
|
this.Controls.Add(this.labelShop);
|
||||||
|
this.Controls.Add(this.comboBoxShop);
|
||||||
|
this.Name = "FormCreateSupply";
|
||||||
|
this.Text = "Создание поставки";
|
||||||
|
this.Load += new System.EventHandler(this.FormCreateSupply_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox comboBoxShop;
|
||||||
|
private Label labelShop;
|
||||||
|
private Label labelPizza;
|
||||||
|
private ComboBox comboBoxPizza;
|
||||||
|
private Label labelCount;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
}
|
||||||
|
}
|
||||||
95
Pizzeria/Pizzeria/FormCreateSupply.cs
Normal file
95
Pizzeria/Pizzeria/FormCreateSupply.cs
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.BusinessLogicsContracts;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
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 static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
public partial class FormCreateSupply : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IPizzaLogic _logicP;
|
||||||
|
private readonly IShopLogic _logicS;
|
||||||
|
private List<ShopViewModel> _shopList= new List<ShopViewModel>();
|
||||||
|
private List<PizzaViewModel> _pizzaList= new List<PizzaViewModel>();
|
||||||
|
public FormCreateSupply(ILogger<FormCreateSupply> logger, IPizzaLogic logicP, IShopLogic logicS)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logicP = logicP;
|
||||||
|
_logicS = logicS;
|
||||||
|
}
|
||||||
|
private void FormCreateSupply_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_shopList = _logicS.ReadList(null);
|
||||||
|
_pizzaList = _logicP.ReadList(null);
|
||||||
|
if (_shopList != null)
|
||||||
|
{
|
||||||
|
comboBoxShop.DisplayMember = "ShopName";
|
||||||
|
comboBoxShop.ValueMember = "Id";
|
||||||
|
comboBoxShop.DataSource = _shopList;
|
||||||
|
comboBoxShop.SelectedItem = null;
|
||||||
|
_logger.LogInformation("Загрузка магазинов для поставок");
|
||||||
|
}
|
||||||
|
if (_pizzaList != null)
|
||||||
|
{
|
||||||
|
comboBoxPizza.DisplayMember = "PizzaName";
|
||||||
|
comboBoxPizza.ValueMember = "Id";
|
||||||
|
comboBoxPizza.DataSource = _pizzaList;
|
||||||
|
comboBoxPizza.SelectedItem = null;
|
||||||
|
_logger.LogInformation("Загрузка пиццы для поставок");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if(comboBoxShop.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxPizza.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите пиццу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Создание поставки");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var operationResult = _logicS.MakeSupply(new SupplyBindingModel
|
||||||
|
{
|
||||||
|
ShopId = Convert.ToInt32(comboBoxShop.SelectedValue),
|
||||||
|
PizzaId = Convert.ToInt32(comboBoxPizza.SelectedValue),
|
||||||
|
Count = Convert.ToInt32(textBoxCount.Text)
|
||||||
|
});
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания поставки");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
Pizzeria/Pizzeria/FormCreateSupply.resx
Normal file
60
Pizzeria/Pizzeria/FormCreateSupply.resx
Normal 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>
|
||||||
174
Pizzeria/Pizzeria/FormImplementers.Designer.cs
generated
174
Pizzeria/Pizzeria/FormImplementers.Designer.cs
generated
@@ -28,93 +28,93 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.ToolsPanel = new System.Windows.Forms.Panel();
|
this.ToolsPanel = new System.Windows.Forms.Panel();
|
||||||
this.buttonRef = new System.Windows.Forms.Button();
|
this.buttonRef = new System.Windows.Forms.Button();
|
||||||
this.buttonDel = new System.Windows.Forms.Button();
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
this.buttonUpd = new System.Windows.Forms.Button();
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.ToolsPanel.SuspendLayout();
|
this.ToolsPanel.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// ToolsPanel
|
// ToolsPanel
|
||||||
//
|
//
|
||||||
this.ToolsPanel.Controls.Add(this.buttonRef);
|
this.ToolsPanel.Controls.Add(this.buttonRef);
|
||||||
this.ToolsPanel.Controls.Add(this.buttonDel);
|
this.ToolsPanel.Controls.Add(this.buttonDel);
|
||||||
this.ToolsPanel.Controls.Add(this.buttonUpd);
|
this.ToolsPanel.Controls.Add(this.buttonUpd);
|
||||||
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
||||||
this.ToolsPanel.Location = new System.Drawing.Point(608, 12);
|
this.ToolsPanel.Location = new System.Drawing.Point(992, 12);
|
||||||
this.ToolsPanel.Name = "ToolsPanel";
|
this.ToolsPanel.Name = "ToolsPanel";
|
||||||
this.ToolsPanel.Size = new System.Drawing.Size(180, 426);
|
this.ToolsPanel.Size = new System.Drawing.Size(180, 426);
|
||||||
this.ToolsPanel.TabIndex = 3;
|
this.ToolsPanel.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// buttonRef
|
// buttonRef
|
||||||
//
|
//
|
||||||
this.buttonRef.Location = new System.Drawing.Point(31, 206);
|
this.buttonRef.Location = new System.Drawing.Point(31, 206);
|
||||||
this.buttonRef.Name = "buttonRef";
|
this.buttonRef.Name = "buttonRef";
|
||||||
this.buttonRef.Size = new System.Drawing.Size(126, 36);
|
this.buttonRef.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonRef.TabIndex = 3;
|
this.buttonRef.TabIndex = 3;
|
||||||
this.buttonRef.Text = "Обновить";
|
this.buttonRef.Text = "Обновить";
|
||||||
this.buttonRef.UseVisualStyleBackColor = true;
|
this.buttonRef.UseVisualStyleBackColor = true;
|
||||||
this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
|
this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
|
||||||
//
|
//
|
||||||
// buttonDel
|
// buttonDel
|
||||||
//
|
//
|
||||||
this.buttonDel.Location = new System.Drawing.Point(31, 142);
|
this.buttonDel.Location = new System.Drawing.Point(31, 142);
|
||||||
this.buttonDel.Name = "buttonDel";
|
this.buttonDel.Name = "buttonDel";
|
||||||
this.buttonDel.Size = new System.Drawing.Size(126, 36);
|
this.buttonDel.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonDel.TabIndex = 2;
|
this.buttonDel.TabIndex = 2;
|
||||||
this.buttonDel.Text = "Удалить";
|
this.buttonDel.Text = "Удалить";
|
||||||
this.buttonDel.UseVisualStyleBackColor = true;
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
|
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
|
||||||
//
|
//
|
||||||
// buttonUpd
|
// buttonUpd
|
||||||
//
|
//
|
||||||
this.buttonUpd.Location = new System.Drawing.Point(31, 76);
|
this.buttonUpd.Location = new System.Drawing.Point(31, 76);
|
||||||
this.buttonUpd.Name = "buttonUpd";
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
this.buttonUpd.Size = new System.Drawing.Size(126, 36);
|
this.buttonUpd.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonUpd.TabIndex = 1;
|
this.buttonUpd.TabIndex = 1;
|
||||||
this.buttonUpd.Text = "Изменить";
|
this.buttonUpd.Text = "Изменить";
|
||||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click);
|
this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click);
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
this.buttonAdd.Location = new System.Drawing.Point(31, 16);
|
this.buttonAdd.Location = new System.Drawing.Point(31, 16);
|
||||||
this.buttonAdd.Name = "buttonAdd";
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
this.buttonAdd.Size = new System.Drawing.Size(126, 36);
|
this.buttonAdd.Size = new System.Drawing.Size(126, 36);
|
||||||
this.buttonAdd.TabIndex = 0;
|
this.buttonAdd.TabIndex = 0;
|
||||||
this.buttonAdd.Text = "Добавить";
|
this.buttonAdd.Text = "Добавить";
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
this.dataGridView.AllowUserToAddRows = false;
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
this.dataGridView.AllowUserToDeleteRows = false;
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||||
this.dataGridView.Name = "dataGridView";
|
this.dataGridView.Name = "dataGridView";
|
||||||
this.dataGridView.ReadOnly = true;
|
this.dataGridView.ReadOnly = true;
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
this.dataGridView.Size = new System.Drawing.Size(590, 426);
|
this.dataGridView.Size = new System.Drawing.Size(957, 426);
|
||||||
this.dataGridView.TabIndex = 2;
|
this.dataGridView.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// FormImplementers
|
// FormImplementers
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(1206, 450);
|
||||||
this.Controls.Add(this.ToolsPanel);
|
this.Controls.Add(this.ToolsPanel);
|
||||||
this.Controls.Add(this.dataGridView);
|
this.Controls.Add(this.dataGridView);
|
||||||
this.Name = "FormImplementers";
|
this.Name = "FormImplementers";
|
||||||
this.Text = "Исполнители";
|
this.Text = "Исполнители";
|
||||||
this.Load += new System.EventHandler(this.FormImplementers_Load);
|
this.Load += new System.EventHandler(this.FormImplementers_Load);
|
||||||
this.ToolsPanel.ResumeLayout(false);
|
this.ToolsPanel.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
182
Pizzeria/Pizzeria/FormLetter.Designer.cs
generated
Normal file
182
Pizzeria/Pizzeria/FormLetter.Designer.cs
generated
Normal file
@@ -0,0 +1,182 @@
|
|||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
partial class FormLetter
|
||||||
|
{
|
||||||
|
/// <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.textBoxEmail = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelAdress = new System.Windows.Forms.Label();
|
||||||
|
this.labelSubject = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxSubject = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelBody = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxBody = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonClose = new System.Windows.Forms.Button();
|
||||||
|
this.buttonReply = new System.Windows.Forms.Button();
|
||||||
|
this.labelDate = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxDate = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonSend = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// textBoxEmail
|
||||||
|
//
|
||||||
|
this.textBoxEmail.Location = new System.Drawing.Point(72, 6);
|
||||||
|
this.textBoxEmail.Name = "textBoxEmail";
|
||||||
|
this.textBoxEmail.ReadOnly = true;
|
||||||
|
this.textBoxEmail.Size = new System.Drawing.Size(186, 27);
|
||||||
|
this.textBoxEmail.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// labelAdress
|
||||||
|
//
|
||||||
|
this.labelAdress.AutoSize = true;
|
||||||
|
this.labelAdress.Location = new System.Drawing.Point(12, 9);
|
||||||
|
this.labelAdress.Name = "labelAdress";
|
||||||
|
this.labelAdress.Size = new System.Drawing.Size(54, 20);
|
||||||
|
this.labelAdress.TabIndex = 1;
|
||||||
|
this.labelAdress.Text = "Адрес:";
|
||||||
|
//
|
||||||
|
// labelSubject
|
||||||
|
//
|
||||||
|
this.labelSubject.AutoSize = true;
|
||||||
|
this.labelSubject.Location = new System.Drawing.Point(12, 55);
|
||||||
|
this.labelSubject.Name = "labelSubject";
|
||||||
|
this.labelSubject.Size = new System.Drawing.Size(47, 20);
|
||||||
|
this.labelSubject.TabIndex = 2;
|
||||||
|
this.labelSubject.Text = "Тема:";
|
||||||
|
//
|
||||||
|
// textBoxSubject
|
||||||
|
//
|
||||||
|
this.textBoxSubject.Location = new System.Drawing.Point(72, 52);
|
||||||
|
this.textBoxSubject.Name = "textBoxSubject";
|
||||||
|
this.textBoxSubject.ReadOnly = true;
|
||||||
|
this.textBoxSubject.Size = new System.Drawing.Size(552, 27);
|
||||||
|
this.textBoxSubject.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// labelBody
|
||||||
|
//
|
||||||
|
this.labelBody.AutoSize = true;
|
||||||
|
this.labelBody.Location = new System.Drawing.Point(12, 96);
|
||||||
|
this.labelBody.Name = "labelBody";
|
||||||
|
this.labelBody.Size = new System.Drawing.Size(104, 20);
|
||||||
|
this.labelBody.TabIndex = 4;
|
||||||
|
this.labelBody.Text = "Текст письма:";
|
||||||
|
//
|
||||||
|
// textBoxBody
|
||||||
|
//
|
||||||
|
this.textBoxBody.Location = new System.Drawing.Point(12, 119);
|
||||||
|
this.textBoxBody.Multiline = true;
|
||||||
|
this.textBoxBody.Name = "textBoxBody";
|
||||||
|
this.textBoxBody.ReadOnly = true;
|
||||||
|
this.textBoxBody.Size = new System.Drawing.Size(612, 186);
|
||||||
|
this.textBoxBody.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// buttonClose
|
||||||
|
//
|
||||||
|
this.buttonClose.Location = new System.Drawing.Point(491, 326);
|
||||||
|
this.buttonClose.Name = "buttonClose";
|
||||||
|
this.buttonClose.Size = new System.Drawing.Size(111, 39);
|
||||||
|
this.buttonClose.TabIndex = 6;
|
||||||
|
this.buttonClose.Text = "Закрыть";
|
||||||
|
this.buttonClose.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
|
||||||
|
//
|
||||||
|
// buttonReply
|
||||||
|
//
|
||||||
|
this.buttonReply.Location = new System.Drawing.Point(290, 326);
|
||||||
|
this.buttonReply.Name = "buttonReply";
|
||||||
|
this.buttonReply.Size = new System.Drawing.Size(177, 39);
|
||||||
|
this.buttonReply.TabIndex = 7;
|
||||||
|
this.buttonReply.Text = "Ответить";
|
||||||
|
this.buttonReply.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonReply.Click += new System.EventHandler(this.buttonReply_Click);
|
||||||
|
//
|
||||||
|
// labelDate
|
||||||
|
//
|
||||||
|
this.labelDate.AutoSize = true;
|
||||||
|
this.labelDate.Location = new System.Drawing.Point(278, 9);
|
||||||
|
this.labelDate.Name = "labelDate";
|
||||||
|
this.labelDate.Size = new System.Drawing.Size(127, 20);
|
||||||
|
this.labelDate.TabIndex = 8;
|
||||||
|
this.labelDate.Text = "Дата получения: ";
|
||||||
|
//
|
||||||
|
// textBoxDate
|
||||||
|
//
|
||||||
|
this.textBoxDate.Location = new System.Drawing.Point(411, 6);
|
||||||
|
this.textBoxDate.Name = "textBoxDate";
|
||||||
|
this.textBoxDate.ReadOnly = true;
|
||||||
|
this.textBoxDate.Size = new System.Drawing.Size(213, 27);
|
||||||
|
this.textBoxDate.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// buttonSend
|
||||||
|
//
|
||||||
|
this.buttonSend.Location = new System.Drawing.Point(149, 326);
|
||||||
|
this.buttonSend.Name = "buttonSend";
|
||||||
|
this.buttonSend.Size = new System.Drawing.Size(109, 39);
|
||||||
|
this.buttonSend.TabIndex = 10;
|
||||||
|
this.buttonSend.Text = "Отправить";
|
||||||
|
this.buttonSend.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSend.Visible = false;
|
||||||
|
this.buttonSend.Click += new System.EventHandler(this.buttonSend_Click);
|
||||||
|
//
|
||||||
|
// FormLetter
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(636, 377);
|
||||||
|
this.Controls.Add(this.buttonSend);
|
||||||
|
this.Controls.Add(this.textBoxDate);
|
||||||
|
this.Controls.Add(this.labelDate);
|
||||||
|
this.Controls.Add(this.buttonReply);
|
||||||
|
this.Controls.Add(this.buttonClose);
|
||||||
|
this.Controls.Add(this.textBoxBody);
|
||||||
|
this.Controls.Add(this.labelBody);
|
||||||
|
this.Controls.Add(this.textBoxSubject);
|
||||||
|
this.Controls.Add(this.labelSubject);
|
||||||
|
this.Controls.Add(this.labelAdress);
|
||||||
|
this.Controls.Add(this.textBoxEmail);
|
||||||
|
this.Name = "FormLetter";
|
||||||
|
this.Text = "Письмо";
|
||||||
|
this.Load += new System.EventHandler(this.FormLetter_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private TextBox textBoxEmail;
|
||||||
|
private Label labelAdress;
|
||||||
|
private Label labelSubject;
|
||||||
|
private TextBox textBoxSubject;
|
||||||
|
private Label labelBody;
|
||||||
|
private TextBox textBoxBody;
|
||||||
|
private Button buttonClose;
|
||||||
|
private Button buttonReply;
|
||||||
|
private Label labelDate;
|
||||||
|
private TextBox textBoxDate;
|
||||||
|
private Button buttonSend;
|
||||||
|
}
|
||||||
|
}
|
||||||
151
Pizzeria/Pizzeria/FormLetter.cs
Normal file
151
Pizzeria/Pizzeria/FormLetter.cs
Normal file
@@ -0,0 +1,151 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Pizzeria;
|
||||||
|
using PizzeriaBusinessLogic.MailWorker;
|
||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.BusinessLogicsContracts;
|
||||||
|
using PizzeriaContracts.DI;
|
||||||
|
using PizzeriaContracts.SearchModels;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
public partial class FormLetter : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IMessageInfoLogic _logic;
|
||||||
|
private readonly AbstractMailWorker _worker;
|
||||||
|
|
||||||
|
public MessageInfoViewModel? model;
|
||||||
|
public string? messageId;
|
||||||
|
|
||||||
|
public FormLetter(ILogger<FormLetter> logger, IMessageInfoLogic logic, AbstractMailWorker worker)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
_worker = worker;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormLetter_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(messageId))
|
||||||
|
{
|
||||||
|
ReloadLetter();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (model != null)
|
||||||
|
{
|
||||||
|
ConfigurateToCreateAnsver();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogError("Для формы не переданно сведений о письме, на которое отвечаем!");
|
||||||
|
DialogResult = DialogResult.Abort;
|
||||||
|
Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReloadLetter()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка существующего письма с id:{}", messageId);
|
||||||
|
model = _logic.ReadElement(new MessageInfoSearchModel
|
||||||
|
{
|
||||||
|
MessageId = messageId
|
||||||
|
});
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Письмо найдено");
|
||||||
|
textBoxEmail.Text = model.SenderName;
|
||||||
|
textBoxDate.Text = model.DateDelivery.ToString();
|
||||||
|
textBoxSubject.Text = model.Subject;
|
||||||
|
textBoxBody.Text = model.Body;
|
||||||
|
|
||||||
|
|
||||||
|
if (model.IsReply)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Письмо само и есть ответ");
|
||||||
|
buttonReply.Visible = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(model.ReplyMessageId))
|
||||||
|
{
|
||||||
|
_logger.LogInformation("У письма есть ответ.");
|
||||||
|
buttonReply.Text = "Прочитать ответ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogWarning("Письмо с таким id не удалось найти");
|
||||||
|
DialogResult = DialogResult.Abort;
|
||||||
|
Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConfigurateToCreateAnsver()
|
||||||
|
{
|
||||||
|
textBoxEmail.Text = model.SenderName;
|
||||||
|
labelDate.Visible = false;
|
||||||
|
textBoxDate.Visible = false;
|
||||||
|
textBoxSubject.Text = $"re: {model.Subject}";
|
||||||
|
textBoxBody.ReadOnly = false;
|
||||||
|
buttonReply.Visible = false;
|
||||||
|
buttonSend.Visible = true;
|
||||||
|
_logger.LogInformation("Запущена форма создания нового письма - ответа");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonClose_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonReply_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = DependencyManager.Instance.Resolve<FormLetter>();
|
||||||
|
if (service is FormLetter form)
|
||||||
|
{
|
||||||
|
if(!string.IsNullOrEmpty(model.ReplyMessageId)) {
|
||||||
|
form.messageId = model.ReplyMessageId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
form.model = model;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(form.ShowDialog() != DialogResult.Cancel)
|
||||||
|
{
|
||||||
|
buttonReply.Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSend_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string subject = textBoxSubject.Text;
|
||||||
|
string text = textBoxBody.Text;
|
||||||
|
|
||||||
|
Task.Run(()=>_worker.MailSendReplyAsync(new MailReplySendInfoBindingModel
|
||||||
|
{
|
||||||
|
MailAddress = model.SenderName,
|
||||||
|
Subject = subject,
|
||||||
|
Text = text,
|
||||||
|
ParentMessageId= model.MessageId,
|
||||||
|
}));
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
Pizzeria/Pizzeria/FormLetter.resx
Normal file
60
Pizzeria/Pizzeria/FormLetter.resx
Normal 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>
|
||||||
124
Pizzeria/Pizzeria/FormMail.Designer.cs
generated
124
Pizzeria/Pizzeria/FormMail.Designer.cs
generated
@@ -28,40 +28,106 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.panel1 = new System.Windows.Forms.Panel();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.SuspendLayout();
|
this.buttonOpen = new System.Windows.Forms.Button();
|
||||||
//
|
this.numericUpDownPage = new System.Windows.Forms.NumericUpDown();
|
||||||
// dataGridView
|
this.buttonPreveous = new System.Windows.Forms.Button();
|
||||||
//
|
this.buttonNext = new System.Windows.Forms.Button();
|
||||||
this.dataGridView.AllowUserToAddRows = false;
|
this.panel1.SuspendLayout();
|
||||||
this.dataGridView.AllowUserToDeleteRows = false;
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPage)).BeginInit();
|
||||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.SuspendLayout();
|
||||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
//
|
||||||
this.dataGridView.Name = "dataGridView";
|
// panel1
|
||||||
this.dataGridView.ReadOnly = true;
|
//
|
||||||
this.dataGridView.RowHeadersWidth = 51;
|
this.panel1.Controls.Add(this.dataGridView);
|
||||||
this.dataGridView.RowTemplate.Height = 29;
|
this.panel1.Location = new System.Drawing.Point(3, 1);
|
||||||
this.dataGridView.Size = new System.Drawing.Size(786, 270);
|
this.panel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
this.dataGridView.TabIndex = 0;
|
this.panel1.Name = "panel1";
|
||||||
//
|
this.panel1.Size = new System.Drawing.Size(795, 431);
|
||||||
// FormMail
|
this.panel1.TabIndex = 0;
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
// dataGridView
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
//
|
||||||
this.ClientSize = new System.Drawing.Size(786, 270);
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
this.Controls.Add(this.dataGridView);
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
this.Name = "FormMail";
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.Text = "Письма";
|
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.Load += new System.EventHandler(this.FormMail_Load);
|
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
this.dataGridView.Name = "dataGridView";
|
||||||
this.ResumeLayout(false);
|
this.dataGridView.ReadOnly = true;
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(795, 431);
|
||||||
|
this.dataGridView.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// buttonOpen
|
||||||
|
//
|
||||||
|
this.buttonOpen.Location = new System.Drawing.Point(806, 80);
|
||||||
|
this.buttonOpen.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.buttonOpen.Name = "buttonOpen";
|
||||||
|
this.buttonOpen.Size = new System.Drawing.Size(107, 31);
|
||||||
|
this.buttonOpen.TabIndex = 1;
|
||||||
|
this.buttonOpen.Text = "Прочитать";
|
||||||
|
this.buttonOpen.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
|
||||||
|
//
|
||||||
|
// numericUpDownPage
|
||||||
|
//
|
||||||
|
this.numericUpDownPage.Location = new System.Drawing.Point(825, 287);
|
||||||
|
this.numericUpDownPage.Name = "numericUpDownPage";
|
||||||
|
this.numericUpDownPage.Size = new System.Drawing.Size(85, 27);
|
||||||
|
this.numericUpDownPage.TabIndex = 4;
|
||||||
|
this.numericUpDownPage.ValueChanged += new System.EventHandler(this.numericUpDownPage_ValueChanged);
|
||||||
|
//
|
||||||
|
// buttonPreveous
|
||||||
|
//
|
||||||
|
this.buttonPreveous.Location = new System.Drawing.Point(825, 323);
|
||||||
|
this.buttonPreveous.Name = "buttonPreveous";
|
||||||
|
this.buttonPreveous.Size = new System.Drawing.Size(39, 29);
|
||||||
|
this.buttonPreveous.TabIndex = 5;
|
||||||
|
this.buttonPreveous.Text = "<-";
|
||||||
|
this.buttonPreveous.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonPreveous.Click += new System.EventHandler(this.buttonPreveous_Click);
|
||||||
|
//
|
||||||
|
// buttonNext
|
||||||
|
//
|
||||||
|
this.buttonNext.Location = new System.Drawing.Point(872, 323);
|
||||||
|
this.buttonNext.Name = "buttonNext";
|
||||||
|
this.buttonNext.Size = new System.Drawing.Size(39, 29);
|
||||||
|
this.buttonNext.TabIndex = 6;
|
||||||
|
this.buttonNext.Text = "->";
|
||||||
|
this.buttonNext.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonNext.Click += new System.EventHandler(this.buttonNext_Click);
|
||||||
|
//
|
||||||
|
// FormMail
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(925, 428);
|
||||||
|
this.Controls.Add(this.buttonNext);
|
||||||
|
this.Controls.Add(this.buttonPreveous);
|
||||||
|
this.Controls.Add(this.numericUpDownPage);
|
||||||
|
this.Controls.Add(this.buttonOpen);
|
||||||
|
this.Controls.Add(this.panel1);
|
||||||
|
this.Name = "FormMail";
|
||||||
|
this.Text = "Письма";
|
||||||
|
this.Load += new System.EventHandler(this.FormMail_Load);
|
||||||
|
this.panel1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPage)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel1;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonOpen;
|
||||||
|
private NumericUpDown numericUpDownPage;
|
||||||
|
private Button buttonPreveous;
|
||||||
|
private Button buttonNext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Pizzeria;
|
||||||
using PizzeriaBusinessLogic.BusinessLogics;
|
using PizzeriaBusinessLogic.BusinessLogics;
|
||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
using PizzeriaContracts.BusinessLogicsContracts;
|
using PizzeriaContracts.BusinessLogicsContracts;
|
||||||
|
using PizzeriaContracts.DI;
|
||||||
|
using PizzeriaContracts.SearchModels;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@@ -17,8 +22,10 @@ namespace PizzeriaView
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IMessageInfoLogic _logic;
|
private readonly IMessageInfoLogic _logic;
|
||||||
|
private int currentPage = 1;
|
||||||
|
private int pageLength = 2;
|
||||||
|
|
||||||
public FormMail(ILogger<FormMail> logger, IMessageInfoLogic logic)
|
public FormMail(ILogger<FormMail> logger, IMessageInfoLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
@@ -43,5 +50,50 @@ namespace PizzeriaView
|
|||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void buttonOpen_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var service = DependencyManager.Instance.Resolve<FormLetter>();
|
||||||
|
if (service is FormLetter form)
|
||||||
|
{
|
||||||
|
string? messageId = dataGridView.SelectedRows[0].Cells["MessageId"].Value.ToString();
|
||||||
|
if (messageId == null) return;
|
||||||
|
form.messageId = messageId;
|
||||||
|
|
||||||
|
if (!Convert.ToBoolean(dataGridView.SelectedRows[0].Cells["IsReaded"].Value))
|
||||||
|
{
|
||||||
|
_logic.Update(new MessageInfoBindingModel
|
||||||
|
{
|
||||||
|
MessageId = messageId,
|
||||||
|
IsReaded = true,
|
||||||
|
ReplyMessageId = dataGridView.SelectedRows[0].Cells["ReplyMessageId"].Value?.ToString()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonPreveous_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
currentPage = Math.Max(1, currentPage - 1);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonNext_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
currentPage++;
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void numericUpDownPage_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pageLength = Math.Max(1, (int)numericUpDownPage.Value);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
150
Pizzeria/Pizzeria/FormMain.Designer.cs
generated
150
Pizzeria/Pizzeria/FormMain.Designer.cs
generated
@@ -34,7 +34,20 @@
|
|||||||
this.pizzasToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.pizzasToolStripMenuItem = 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.shopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.operationToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.transactionToolStripMenuItem = 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.загруженностьToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.заказыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.заказыToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.заказыПоГруппамToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.componentsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
this.componentsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.componentPizzaToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
this.componentPizzaToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
@@ -56,10 +69,11 @@
|
|||||||
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.bookToolStripMenuItem,
|
this.bookToolStripMenuItem,
|
||||||
this.отчётыToolStripMenuItem,
|
|
||||||
this.запускРаботToolStripMenuItem,
|
this.запускРаботToolStripMenuItem,
|
||||||
|
this.создатьБекапToolStripMenuItem,
|
||||||
this.почтаToolStripMenuItem,
|
this.почтаToolStripMenuItem,
|
||||||
this.создатьБекапToolStripMenuItem});
|
this.operationToolStripMenuItem,
|
||||||
|
this.отчётыToolStripMenuItem});
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
|
this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
|
||||||
@@ -72,8 +86,9 @@
|
|||||||
this.bookToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.bookToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.ingridientsToolStripMenuItem,
|
this.ingridientsToolStripMenuItem,
|
||||||
this.pizzasToolStripMenuItem,
|
this.pizzasToolStripMenuItem,
|
||||||
this.клиентToolStripMenuItem,
|
this.исполнителиToolStripMenuItem,
|
||||||
this.исполнителиToolStripMenuItem});
|
this.shopsToolStripMenuItem,
|
||||||
|
this.клиентToolStripMenuItem});
|
||||||
this.bookToolStripMenuItem.Name = "bookToolStripMenuItem";
|
this.bookToolStripMenuItem.Name = "bookToolStripMenuItem";
|
||||||
this.bookToolStripMenuItem.Size = new System.Drawing.Size(87, 20);
|
this.bookToolStripMenuItem.Size = new System.Drawing.Size(87, 20);
|
||||||
this.bookToolStripMenuItem.Text = "Справочник";
|
this.bookToolStripMenuItem.Text = "Справочник";
|
||||||
@@ -106,36 +121,114 @@
|
|||||||
this.исполнителиToolStripMenuItem.Text = "Исполнители";
|
this.исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||||
this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.employersToolStripMenuItem_Click);
|
this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.employersToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// shopsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
|
||||||
|
this.shopsToolStripMenuItem.Size = new System.Drawing.Size(148, 22);
|
||||||
|
this.shopsToolStripMenuItem.Text = "Магазины";
|
||||||
|
this.shopsToolStripMenuItem.Click += new System.EventHandler(this.shopsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// operationToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.operationToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.transactionToolStripMenuItem,
|
||||||
|
this.продажаToolStripMenuItem});
|
||||||
|
this.operationToolStripMenuItem.Name = "operationToolStripMenuItem";
|
||||||
|
this.operationToolStripMenuItem.Size = new System.Drawing.Size(75, 20);
|
||||||
|
this.operationToolStripMenuItem.Text = "Операции";
|
||||||
|
//
|
||||||
|
// transactionToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.transactionToolStripMenuItem.Name = "transactionToolStripMenuItem";
|
||||||
|
this.transactionToolStripMenuItem.Size = new System.Drawing.Size(125, 22);
|
||||||
|
this.transactionToolStripMenuItem.Text = "Поставка";
|
||||||
|
this.transactionToolStripMenuItem.Click += new System.EventHandler(this.transactionToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// продажаToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.продажаToolStripMenuItem.Name = "продажаToolStripMenuItem";
|
||||||
|
this.продажаToolStripMenuItem.Size = new System.Drawing.Size(125, 22);
|
||||||
|
this.продажаToolStripMenuItem.Text = "Продажа";
|
||||||
|
this.продажаToolStripMenuItem.Click += new System.EventHandler(this.SellToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// отчётыToolStripMenuItem
|
// отчётыToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.componentsToolStripMenuItem1,
|
this.изделияToolStripMenuItem,
|
||||||
this.componentPizzaToolStripMenuItem1,
|
this.магазинToolStripMenuItem,
|
||||||
this.ordersToolStripMenuItem});
|
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 = "Отчёты";
|
||||||
//
|
//
|
||||||
// componentsToolStripMenuItem1
|
// изделияToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.componentsToolStripMenuItem1.Name = "componentsToolStripMenuItem1";
|
this.изделияToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.componentsToolStripMenuItem1.Size = new System.Drawing.Size(205, 22);
|
this.списокИзделийToolStripMenuItem,
|
||||||
this.componentsToolStripMenuItem1.Text = "Пиццы";
|
this.пиццаСИнгридиентамиToolStripMenuItem});
|
||||||
this.componentsToolStripMenuItem1.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
|
||||||
|
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.изделияToolStripMenuItem.Text = "Пицца";
|
||||||
//
|
//
|
||||||
// componentPizzaToolStripMenuItem1
|
// списокИзделийToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.componentPizzaToolStripMenuItem1.Name = "componentPizzaToolStripMenuItem1";
|
this.списокИзделийToolStripMenuItem.Name = "списокИзделийToolStripMenuItem";
|
||||||
this.componentPizzaToolStripMenuItem1.Size = new System.Drawing.Size(205, 22);
|
this.списокИзделийToolStripMenuItem.Size = new System.Drawing.Size(208, 22);
|
||||||
this.componentPizzaToolStripMenuItem1.Text = "Пицца с компонентами";
|
this.списокИзделийToolStripMenuItem.Text = "Список пицц";
|
||||||
this.componentPizzaToolStripMenuItem1.Click += new System.EventHandler(this.ComponentPizzaToolStripMenuItem_Click);
|
this.списокИзделийToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// ordersToolStripMenuItem
|
// пиццаСИнгридиентамиToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.ordersToolStripMenuItem.Name = "ordersToolStripMenuItem";
|
this.пиццаСИнгридиентамиToolStripMenuItem.Name = "пиццаСИнгридиентамиToolStripMenuItem";
|
||||||
this.ordersToolStripMenuItem.Size = new System.Drawing.Size(205, 22);
|
this.пиццаСИнгридиентамиToolStripMenuItem.Size = new System.Drawing.Size(208, 22);
|
||||||
this.ordersToolStripMenuItem.Text = "Заказы";
|
this.пиццаСИнгридиентамиToolStripMenuItem.Text = "Пицца с ингридиентами";
|
||||||
this.ordersToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
|
this.пиццаСИнгридиентамиToolStripMenuItem.Click += new System.EventHandler(this.ComponentPizzaToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// магазинToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.магазинToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.информацияToolStripMenuItem,
|
||||||
|
this.загруженностьToolStripMenuItem});
|
||||||
|
this.магазинToolStripMenuItem.Name = "магазинToolStripMenuItem";
|
||||||
|
this.магазинToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.магазинToolStripMenuItem.Text = "Магазин";
|
||||||
|
//
|
||||||
|
// информацияToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.информацияToolStripMenuItem.Name = "информацияToolStripMenuItem";
|
||||||
|
this.информацияToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.информацияToolStripMenuItem.Text = "Информация";
|
||||||
|
this.информацияToolStripMenuItem.Click += new System.EventHandler(this.InfoToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// загруженностьToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.загруженностьToolStripMenuItem.Name = "загруженностьToolStripMenuItem";
|
||||||
|
this.загруженностьToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.загруженностьToolStripMenuItem.Text = "Загруженность";
|
||||||
|
this.загруженностьToolStripMenuItem.Click += new System.EventHandler(this.BusyShopsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// заказыToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.заказыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
|
this.заказыToolStripMenuItem1,
|
||||||
|
this.заказыПоГруппамToolStripMenuItem});
|
||||||
|
this.заказыToolStripMenuItem.Name = "заказыToolStripMenuItem";
|
||||||
|
this.заказыToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.заказыToolStripMenuItem.Text = "Заказы";
|
||||||
|
//
|
||||||
|
// заказыToolStripMenuItem1
|
||||||
|
//
|
||||||
|
this.заказыToolStripMenuItem1.Name = "заказыToolStripMenuItem1";
|
||||||
|
this.заказыToolStripMenuItem1.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.заказыToolStripMenuItem1.Text = "Заказы";
|
||||||
|
this.заказыToolStripMenuItem1.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// заказыПоГруппамToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.заказыПоГруппамToolStripMenuItem.Name = "заказыПоГруппамToolStripMenuItem";
|
||||||
|
this.заказыПоГруппамToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.заказыПоГруппамToolStripMenuItem.Text = "Заказы по группам";
|
||||||
|
this.заказыПоГруппамToolStripMenuItem.Click += new System.EventHandler(this.GroupOrdersToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// запускРаботToolStripMenuItem
|
// запускРаботToolStripMenuItem
|
||||||
//
|
//
|
||||||
@@ -269,6 +362,19 @@
|
|||||||
private ToolStripMenuItem componentPizzaToolStripMenuItem1;
|
private ToolStripMenuItem componentPizzaToolStripMenuItem1;
|
||||||
private ToolStripMenuItem ordersToolStripMenuItem;
|
private ToolStripMenuItem ordersToolStripMenuItem;
|
||||||
private ToolStripMenuItem клиентToolStripMenuItem;
|
private ToolStripMenuItem клиентToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem shopsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem operationToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem transactionToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem продажаToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem изделияToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem списокИзделийToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem пиццаСИнгридиентамиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem магазинToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem информацияToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem загруженностьToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem заказыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem заказыToolStripMenuItem1;
|
||||||
|
private ToolStripMenuItem заказыПоГруппамToolStripMenuItem;
|
||||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||||
private ToolStripMenuItem почтаToolStripMenuItem;
|
private ToolStripMenuItem почтаToolStripMenuItem;
|
||||||
|
|||||||
@@ -159,6 +159,48 @@ namespace PizzeriaView
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void shopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = DependencyManager.Instance.Resolve<FormShops>();
|
||||||
|
form.ShowDialog();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void transactionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = DependencyManager.Instance.Resolve<FormCreateSupply>();
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SellToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = DependencyManager.Instance.Resolve<FormSellPizza>();
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InfoToolStripMenuItem_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 BusyShopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = DependencyManager.Instance.Resolve<FormReportShop>();
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GroupOrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var form = DependencyManager.Instance.Resolve<FormReportGroupedOrders>();
|
||||||
|
form.ShowDialog();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
|
private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var form = DependencyManager.Instance.Resolve<FormClients>();
|
var form = DependencyManager.Instance.Resolve<FormClients>();
|
||||||
@@ -209,3 +251,4 @@ namespace PizzeriaView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
86
Pizzeria/Pizzeria/FormReportGroupedOrders.Designer.cs
generated
Normal file
86
Pizzeria/Pizzeria/FormReportGroupedOrders.Designer.cs
generated
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
partial class FormReportGroupedOrders
|
||||||
|
{
|
||||||
|
/// <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.Name = "panel";
|
||||||
|
this.panel.Size = new System.Drawing.Size(970, 52);
|
||||||
|
this.panel.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonToPDF
|
||||||
|
//
|
||||||
|
this.buttonToPDF.Location = new System.Drawing.Point(486, 12);
|
||||||
|
this.buttonToPDF.Name = "buttonToPDF";
|
||||||
|
this.buttonToPDF.Size = new System.Drawing.Size(411, 29);
|
||||||
|
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(49, 12);
|
||||||
|
this.buttonMake.Name = "buttonMake";
|
||||||
|
this.buttonMake.Size = new System.Drawing.Size(377, 29);
|
||||||
|
this.buttonMake.TabIndex = 4;
|
||||||
|
this.buttonMake.Text = "Сформировать";
|
||||||
|
this.buttonMake.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click);
|
||||||
|
//
|
||||||
|
// FormReportGroupedOrders
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(970, 450);
|
||||||
|
this.Controls.Add(this.panel);
|
||||||
|
this.Name = "FormReportGroupedOrders";
|
||||||
|
this.Text = "Отчёт по группированным заказам ";
|
||||||
|
this.panel.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel;
|
||||||
|
private Button buttonToPDF;
|
||||||
|
private Button buttonMake;
|
||||||
|
}
|
||||||
|
}
|
||||||
78
Pizzeria/Pizzeria/FormReportGroupedOrders.cs
Normal file
78
Pizzeria/Pizzeria/FormReportGroupedOrders.cs
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Reporting.WinForms;
|
||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.BusinessLogicsContracts;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
public partial class FormReportGroupedOrders : Form
|
||||||
|
{
|
||||||
|
private readonly ReportViewer reportViewer;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IReportLogic _logic;
|
||||||
|
|
||||||
|
public FormReportGroupedOrders(ILogger<FormReportGroupedOrders> logger, IReportLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
reportViewer = new ReportViewer
|
||||||
|
{
|
||||||
|
Dock = DockStyle.Fill
|
||||||
|
};
|
||||||
|
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupedOrders.rdlc", FileMode.Open));
|
||||||
|
Controls.Clear();
|
||||||
|
Controls.Add(reportViewer);
|
||||||
|
Controls.Add(panel);
|
||||||
|
}
|
||||||
|
private void ButtonMake_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dataSource = _logic.GetGroupedOrders();
|
||||||
|
var source = new ReportDataSource("DataSetGroupedOrders", 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.SaveGroupedOrdersToPdfFile(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
Pizzeria/Pizzeria/FormReportGroupedOrders.resx
Normal file
60
Pizzeria/Pizzeria/FormReportGroupedOrders.resx
Normal 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>
|
||||||
116
Pizzeria/Pizzeria/FormReportShop.Designer.cs
generated
Normal file
116
Pizzeria/Pizzeria/FormReportShop.Designer.cs
generated
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
partial class FormReportShop
|
||||||
|
{
|
||||||
|
/// <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.buttonSaveToExcel = new System.Windows.Forms.Button();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.ColumnShop = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.ColumnPizza = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonSaveToExcel
|
||||||
|
//
|
||||||
|
this.buttonSaveToExcel.Location = new System.Drawing.Point(0, 6);
|
||||||
|
this.buttonSaveToExcel.Name = "buttonSaveToExcel";
|
||||||
|
this.buttonSaveToExcel.Size = new System.Drawing.Size(223, 29);
|
||||||
|
this.buttonSaveToExcel.TabIndex = 3;
|
||||||
|
this.buttonSaveToExcel.Text = "Сохранить в Excel";
|
||||||
|
this.buttonSaveToExcel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
this.dataGridView.AllowUserToOrderColumns = true;
|
||||||
|
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.ColumnShop,
|
||||||
|
this.ColumnPizza,
|
||||||
|
this.ColumnCount});
|
||||||
|
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(0, 47);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.ReadOnly = true;
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(598, 403);
|
||||||
|
this.dataGridView.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// ColumnShop
|
||||||
|
//
|
||||||
|
this.ColumnShop.FillWeight = 130F;
|
||||||
|
this.ColumnShop.HeaderText = "Магазин";
|
||||||
|
this.ColumnShop.MinimumWidth = 6;
|
||||||
|
this.ColumnShop.Name = "ColumnShop";
|
||||||
|
this.ColumnShop.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnPizza
|
||||||
|
//
|
||||||
|
this.ColumnPizza.FillWeight = 140F;
|
||||||
|
this.ColumnPizza.HeaderText = "Пицца";
|
||||||
|
this.ColumnPizza.MinimumWidth = 6;
|
||||||
|
this.ColumnPizza.Name = "ColumnPizza";
|
||||||
|
this.ColumnPizza.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnCount
|
||||||
|
//
|
||||||
|
this.ColumnCount.FillWeight = 90F;
|
||||||
|
this.ColumnCount.HeaderText = "Количество";
|
||||||
|
this.ColumnCount.MinimumWidth = 6;
|
||||||
|
this.ColumnCount.Name = "ColumnCount";
|
||||||
|
this.ColumnCount.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// FormReportShop
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(598, 450);
|
||||||
|
this.Controls.Add(this.buttonSaveToExcel);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormReportShop";
|
||||||
|
this.Text = "Наполненость магазинов";
|
||||||
|
this.Load += new System.EventHandler(this.FormReportShop_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonSaveToExcel;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private DataGridViewTextBoxColumn ColumnShop;
|
||||||
|
private DataGridViewTextBoxColumn ColumnPizza;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
76
Pizzeria/Pizzeria/FormReportShop.cs
Normal file
76
Pizzeria/Pizzeria/FormReportShop.cs
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.BusinessLogicsContracts;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
public partial class FormReportShop : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IReportLogic _logic;
|
||||||
|
|
||||||
|
public FormReportShop(ILogger<FormReportShop> logger, IReportLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
private void FormReportShop_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dict = _logic.GetShops();
|
||||||
|
if (dict != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var elem in dict)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" });
|
||||||
|
foreach (var listElem in elem.Pizzas)
|
||||||
|
{
|
||||||
|
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.SaveShopsToExcelFile(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
69
Pizzeria/Pizzeria/FormReportShop.resx
Normal file
69
Pizzeria/Pizzeria/FormReportShop.resx
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<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>
|
||||||
|
<metadata name="ColumnShop.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnPizza.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
120
Pizzeria/Pizzeria/FormSellPizza.Designer.cs
generated
Normal file
120
Pizzeria/Pizzeria/FormSellPizza.Designer.cs
generated
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
partial class FormSellPizza
|
||||||
|
{
|
||||||
|
/// <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.labelPizza = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxPizza = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonSell = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelPizza
|
||||||
|
//
|
||||||
|
this.labelPizza.AutoSize = true;
|
||||||
|
this.labelPizza.Location = new System.Drawing.Point(12, 14);
|
||||||
|
this.labelPizza.Name = "labelPizza";
|
||||||
|
this.labelPizza.Size = new System.Drawing.Size(75, 20);
|
||||||
|
this.labelPizza.TabIndex = 0;
|
||||||
|
this.labelPizza.Text = "Пицца: ";
|
||||||
|
//
|
||||||
|
// comboBoxPizza
|
||||||
|
//
|
||||||
|
this.comboBoxPizza.FormattingEnabled = true;
|
||||||
|
this.comboBoxPizza.Location = new System.Drawing.Point(115, 11);
|
||||||
|
this.comboBoxPizza.Name = "comboBoxPizza";
|
||||||
|
this.comboBoxPizza.Size = new System.Drawing.Size(239, 28);
|
||||||
|
this.comboBoxPizza.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
this.labelCount.AutoSize = true;
|
||||||
|
this.labelCount.Location = new System.Drawing.Point(12, 55);
|
||||||
|
this.labelCount.Name = "labelCount";
|
||||||
|
this.labelCount.Size = new System.Drawing.Size(97, 20);
|
||||||
|
this.labelCount.TabIndex = 2;
|
||||||
|
this.labelCount.Text = "Количество: ";
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(115, 52);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(239, 27);
|
||||||
|
this.textBoxCount.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonSell
|
||||||
|
//
|
||||||
|
this.buttonSell.Location = new System.Drawing.Point(128, 99);
|
||||||
|
this.buttonSell.Name = "buttonSell";
|
||||||
|
this.buttonSell.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonSell.TabIndex = 4;
|
||||||
|
this.buttonSell.Text = "Продать";
|
||||||
|
this.buttonSell.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSell.Click += new System.EventHandler(this.ButtonSell_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(242, 99);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||||
|
this.buttonCancel.TabIndex = 5;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// FormSellPizza
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(366, 140);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSell);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.labelCount);
|
||||||
|
this.Controls.Add(this.comboBoxPizza);
|
||||||
|
this.Controls.Add(this.labelPizza);
|
||||||
|
this.Name = "FormSellPizza";
|
||||||
|
this.Text = "Продажа пиццы";
|
||||||
|
this.Load += new System.EventHandler(this.FormSellingPizza_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelPizza;
|
||||||
|
private ComboBox comboBoxPizza;
|
||||||
|
private Label labelCount;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private Button buttonSell;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
83
Pizzeria/Pizzeria/FormSellPizza.cs
Normal file
83
Pizzeria/Pizzeria/FormSellPizza.cs
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PizzeriaContracts.BusinessLogicsContracts;
|
||||||
|
using PizzeriaContracts.SearchModels;
|
||||||
|
using PizzeriaContracts.StoragesContracts;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
public partial class FormSellPizza : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IPizzaLogic _logicP;
|
||||||
|
private readonly IShopLogic _logicS;
|
||||||
|
private List<PizzaViewModel> _pizzaList = new List<PizzaViewModel>();
|
||||||
|
public FormSellPizza(ILogger<FormSellPizza> logger, IPizzaLogic logicP, IShopLogic logicS)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logicP = logicP;
|
||||||
|
_logicS = logicS;
|
||||||
|
}
|
||||||
|
private void FormSellingPizza_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_pizzaList = _logicP.ReadList(null);
|
||||||
|
if (_pizzaList != null)
|
||||||
|
{
|
||||||
|
comboBoxPizza.DisplayMember = "PizzaName";
|
||||||
|
comboBoxPizza.ValueMember = "Id";
|
||||||
|
comboBoxPizza.DataSource = _pizzaList;
|
||||||
|
comboBoxPizza.SelectedItem = null;
|
||||||
|
_logger.LogInformation("Загрузка пиццы для продажи");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonSell_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxPizza.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите пиццу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Создание покупки");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool resout = _logicS.Sale(new SupplySearchModel
|
||||||
|
{
|
||||||
|
PizzaId = Convert.ToInt32(comboBoxPizza.SelectedValue),
|
||||||
|
Count = Convert.ToInt32(textBoxCount.Text)
|
||||||
|
});
|
||||||
|
if (resout)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Проверка пройдена, продажа проведена");
|
||||||
|
MessageBox.Show("Продажа проведена", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_logger.LogInformation("Проверка не пройдена");
|
||||||
|
MessageBox.Show("Продажа не может быть создана.", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания покупки");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
Pizzeria/Pizzeria/FormSellPizza.resx
Normal file
60
Pizzeria/Pizzeria/FormSellPizza.resx
Normal 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>
|
||||||
222
Pizzeria/Pizzeria/FormShop.Designer.cs
generated
Normal file
222
Pizzeria/Pizzeria/FormShop.Designer.cs
generated
Normal file
@@ -0,0 +1,222 @@
|
|||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
partial class FormShop
|
||||||
|
{
|
||||||
|
/// <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.labelName = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxAdress = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelAdress = new System.Windows.Forms.Label();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.PizzaName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.dateTimeOpen = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.numericUpPizzaMaxCount = new System.Windows.Forms.NumericUpDown();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpPizzaMaxCount)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
this.labelName.AutoSize = true;
|
||||||
|
this.labelName.Location = new System.Drawing.Point(11, 15);
|
||||||
|
this.labelName.Name = "labelName";
|
||||||
|
this.labelName.Size = new System.Drawing.Size(84, 20);
|
||||||
|
this.labelName.TabIndex = 0;
|
||||||
|
this.labelName.Text = "Название: ";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
this.textBoxName.Location = new System.Drawing.Point(102, 12);
|
||||||
|
this.textBoxName.Name = "textBoxName";
|
||||||
|
this.textBoxName.Size = new System.Drawing.Size(276, 27);
|
||||||
|
this.textBoxName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// textBoxAdress
|
||||||
|
//
|
||||||
|
this.textBoxAdress.Location = new System.Drawing.Point(102, 59);
|
||||||
|
this.textBoxAdress.Name = "textBoxAdress";
|
||||||
|
this.textBoxAdress.Size = new System.Drawing.Size(427, 27);
|
||||||
|
this.textBoxAdress.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// labelAdress
|
||||||
|
//
|
||||||
|
this.labelAdress.AutoSize = true;
|
||||||
|
this.labelAdress.Location = new System.Drawing.Point(11, 61);
|
||||||
|
this.labelAdress.Name = "labelAdress";
|
||||||
|
this.labelAdress.Size = new System.Drawing.Size(58, 20);
|
||||||
|
this.labelAdress.TabIndex = 2;
|
||||||
|
this.labelAdress.Text = "Адрес: ";
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(451, 457);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(130, 44);
|
||||||
|
this.buttonCancel.TabIndex = 5;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(315, 457);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(130, 44);
|
||||||
|
this.buttonSave.TabIndex = 6;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.id,
|
||||||
|
this.PizzaName,
|
||||||
|
this.Count});
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 185);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.ReadOnly = true;
|
||||||
|
this.dataGridView.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
|
||||||
|
this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(569, 266);
|
||||||
|
this.dataGridView.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// id
|
||||||
|
//
|
||||||
|
this.id.HeaderText = "id";
|
||||||
|
this.id.MinimumWidth = 6;
|
||||||
|
this.id.Name = "id";
|
||||||
|
this.id.ReadOnly = true;
|
||||||
|
this.id.Visible = false;
|
||||||
|
//
|
||||||
|
// PizzaName
|
||||||
|
//
|
||||||
|
this.PizzaName.HeaderText = "Пицца";
|
||||||
|
this.PizzaName.MinimumWidth = 6;
|
||||||
|
this.PizzaName.Name = "PizzaName";
|
||||||
|
this.PizzaName.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// Count
|
||||||
|
//
|
||||||
|
this.Count.HeaderText = "Количество";
|
||||||
|
this.Count.MinimumWidth = 6;
|
||||||
|
this.Count.Name = "Count";
|
||||||
|
this.Count.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(12, 103);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(110, 20);
|
||||||
|
this.label1.TabIndex = 8;
|
||||||
|
this.label1.Text = "Дата открытия";
|
||||||
|
//
|
||||||
|
// dateTimeOpen
|
||||||
|
//
|
||||||
|
this.dateTimeOpen.Location = new System.Drawing.Point(128, 103);
|
||||||
|
this.dateTimeOpen.Name = "dateTimeOpen";
|
||||||
|
this.dateTimeOpen.Size = new System.Drawing.Size(401, 27);
|
||||||
|
this.dateTimeOpen.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(12, 148);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(100, 20);
|
||||||
|
this.label2.TabIndex = 10;
|
||||||
|
this.label2.Text = "Вместимость";
|
||||||
|
//
|
||||||
|
// numericUpPizzaMaxCount
|
||||||
|
//
|
||||||
|
this.numericUpPizzaMaxCount.Location = new System.Drawing.Point(128, 146);
|
||||||
|
this.numericUpPizzaMaxCount.Maximum = new decimal(new int[] {
|
||||||
|
10000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.numericUpPizzaMaxCount.Name = "numericUpPizzaMaxCount";
|
||||||
|
this.numericUpPizzaMaxCount.Size = new System.Drawing.Size(401, 27);
|
||||||
|
this.numericUpPizzaMaxCount.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// FormShop
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(593, 513);
|
||||||
|
this.Controls.Add(this.numericUpPizzaMaxCount);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.dateTimeOpen);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.textBoxAdress);
|
||||||
|
this.Controls.Add(this.labelAdress);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Controls.Add(this.labelName);
|
||||||
|
this.Name = "FormShop";
|
||||||
|
this.Text = "Магазин";
|
||||||
|
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpPizzaMaxCount)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelName;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private TextBox textBoxAdress;
|
||||||
|
private Label labelAdress;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private DataGridViewTextBoxColumn id;
|
||||||
|
private DataGridViewTextBoxColumn PizzaName;
|
||||||
|
private DataGridViewTextBoxColumn Count;
|
||||||
|
private Label label1;
|
||||||
|
private DateTimePicker dateTimeOpen;
|
||||||
|
private Label label2;
|
||||||
|
private NumericUpDown numericUpPizzaMaxCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
127
Pizzeria/Pizzeria/FormShop.cs
Normal file
127
Pizzeria/Pizzeria/FormShop.cs
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
using PizzeriaDataModels.Models;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.BusinessLogicsContracts;
|
||||||
|
using PizzeriaContracts.SearchModels;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
public partial class FormShop : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IShopLogic _logic;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
private Dictionary<int, (IPizzaModel, int)> _ShopPizzas;
|
||||||
|
private DateTime? _openingDate = null;
|
||||||
|
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
_ShopPizzas = new Dictionary<int, (IPizzaModel, int)>();
|
||||||
|
}
|
||||||
|
private void FormShop_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка магазина");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logic.ReadElement(new ShopSearchModel
|
||||||
|
{
|
||||||
|
Id = _id.Value
|
||||||
|
});
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = view.ShopName;
|
||||||
|
textBoxAdress.Text = view.Adress;
|
||||||
|
dateTimeOpen.Value = view.OpeningDate;
|
||||||
|
numericUpPizzaMaxCount.Value = view.PizzaMaxCount;
|
||||||
|
_ShopPizzas = view.ShopPizzas ?? new Dictionary<int, (IPizzaModel, int)>();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка пиццы в магазине");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_ShopPizzas != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var sr in _ShopPizzas)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { sr.Key, sr.Value.Item1.PizzaName, sr.Value.Item2 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки пиццы магазина");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(textBoxAdress.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение магазина");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ShopName = textBoxName.Text,
|
||||||
|
Adress = textBoxAdress.Text,
|
||||||
|
OpeningDate = dateTimeOpen.Value,
|
||||||
|
PizzaMaxCount = (int) numericUpPizzaMaxCount.Value
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения магазина");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
78
Pizzeria/Pizzeria/FormShop.resx
Normal file
78
Pizzeria/Pizzeria/FormShop.resx
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<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>
|
||||||
|
<metadata name="id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="PizzaName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="PizzaName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
130
Pizzeria/Pizzeria/FormShops.Designer.cs
generated
Normal file
130
Pizzeria/Pizzeria/FormShops.Designer.cs
generated
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
partial class FormShops
|
||||||
|
{
|
||||||
|
/// <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.ToolsPanel = new System.Windows.Forms.Panel();
|
||||||
|
this.buttonRef = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.ToolsPanel.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// ToolsPanel
|
||||||
|
//
|
||||||
|
this.ToolsPanel.Controls.Add(this.buttonRef);
|
||||||
|
this.ToolsPanel.Controls.Add(this.buttonDel);
|
||||||
|
this.ToolsPanel.Controls.Add(this.buttonUpd);
|
||||||
|
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
||||||
|
this.ToolsPanel.Location = new System.Drawing.Point(676, 12);
|
||||||
|
this.ToolsPanel.Name = "ToolsPanel";
|
||||||
|
this.ToolsPanel.Size = new System.Drawing.Size(180, 406);
|
||||||
|
this.ToolsPanel.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonRef
|
||||||
|
//
|
||||||
|
this.buttonRef.Location = new System.Drawing.Point(31, 196);
|
||||||
|
this.buttonRef.Name = "buttonRef";
|
||||||
|
this.buttonRef.Size = new System.Drawing.Size(126, 34);
|
||||||
|
this.buttonRef.TabIndex = 3;
|
||||||
|
this.buttonRef.Text = "Обновить";
|
||||||
|
this.buttonRef.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(31, 135);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(126, 34);
|
||||||
|
this.buttonDel.TabIndex = 2;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(31, 72);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(126, 34);
|
||||||
|
this.buttonUpd.TabIndex = 1;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(31, 15);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(126, 34);
|
||||||
|
this.buttonAdd.TabIndex = 0;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 11);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.ReadOnly = true;
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(649, 415);
|
||||||
|
this.dataGridView.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// FormShops
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(868, 429);
|
||||||
|
this.Controls.Add(this.ToolsPanel);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormShops";
|
||||||
|
this.Text = "Магазины";
|
||||||
|
this.Load += new System.EventHandler(this.FormShops_Load);
|
||||||
|
this.ToolsPanel.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel ToolsPanel;
|
||||||
|
private Button buttonRef;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
||||||
103
Pizzeria/Pizzeria/FormShops.cs
Normal file
103
Pizzeria/Pizzeria/FormShops.cs
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Pizzeria;
|
||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.BusinessLogicsContracts;
|
||||||
|
using PizzeriaContracts.DI;
|
||||||
|
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;
|
||||||
|
|
||||||
|
namespace PizzeriaView
|
||||||
|
{
|
||||||
|
public partial class FormShops : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IShopLogic _logic;
|
||||||
|
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
private void FormShops_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||||
|
_logger.LogInformation("Загрузка магазинов");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = DependencyManager.Instance.Resolve<FormShop>();
|
||||||
|
if (service is FormShop form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = DependencyManager.Instance.Resolve<FormShop>();
|
||||||
|
if (service is FormShop form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
_logger.LogInformation("Удаление магазина");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
Pizzeria/Pizzeria/FormShops.resx
Normal file
60
Pizzeria/Pizzeria/FormShops.resx
Normal 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>
|
||||||
@@ -26,6 +26,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Update="ReportGroupedOrders.rdlc">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="ReportOrder.rdlc">
|
<None Update="ReportOrder.rdlc">
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Pizzeria
|
|||||||
});
|
});
|
||||||
|
|
||||||
// todo Delete email to fine work
|
// todo Delete email to fine work
|
||||||
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
//var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -65,22 +65,6 @@ namespace Pizzeria
|
|||||||
option.AddNLog("nlog.config");
|
option.AddNLog("nlog.config");
|
||||||
});
|
});
|
||||||
|
|
||||||
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IPizzaLogic, PizzaLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
|
||||||
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
|
||||||
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
|
||||||
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
|
||||||
|
|
||||||
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
|
||||||
|
|
||||||
DependencyManager.Instance.RegisterType<FormMain>();
|
DependencyManager.Instance.RegisterType<FormMain>();
|
||||||
DependencyManager.Instance.RegisterType<FormComponent>();
|
DependencyManager.Instance.RegisterType<FormComponent>();
|
||||||
DependencyManager.Instance.RegisterType<FormComponents>();
|
DependencyManager.Instance.RegisterType<FormComponents>();
|
||||||
@@ -94,6 +78,14 @@ namespace Pizzeria
|
|||||||
DependencyManager.Instance.RegisterType<FormImplementers>();
|
DependencyManager.Instance.RegisterType<FormImplementers>();
|
||||||
DependencyManager.Instance.RegisterType<FormImplementer>();
|
DependencyManager.Instance.RegisterType<FormImplementer>();
|
||||||
DependencyManager.Instance.RegisterType<FormMail>();
|
DependencyManager.Instance.RegisterType<FormMail>();
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<FormShop>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormShops>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormSellPizza>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormReportShop>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormReportGroupedOrders>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormLetter>();
|
||||||
|
DependencyManager.Instance.RegisterType<FormCreateSupply>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
||||||
|
|||||||
441
Pizzeria/Pizzeria/ReportGroupedOrders.rdlc
Normal file
441
Pizzeria/Pizzeria/ReportGroupedOrders.rdlc
Normal file
@@ -0,0 +1,441 @@
|
|||||||
|
<?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="PrecastConcretePlantContractsViewModels">
|
||||||
|
<ConnectionProperties>
|
||||||
|
<DataProvider>System.Data.DataSet</DataProvider>
|
||||||
|
<ConnectString>/* Local Connection */</ConnectString>
|
||||||
|
</ConnectionProperties>
|
||||||
|
<rd:DataSourceID>20791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
|
||||||
|
</DataSource>
|
||||||
|
</DataSources>
|
||||||
|
<DataSets>
|
||||||
|
<DataSet Name="DataSetGroupedOrders">
|
||||||
|
<Query>
|
||||||
|
<DataSourceName>PrecastConcretePlantContractsViewModels</DataSourceName>
|
||||||
|
<CommandText>/* Local Query */</CommandText>
|
||||||
|
</Query>
|
||||||
|
<Fields>
|
||||||
|
<Field Name="Date">
|
||||||
|
<DataField>Date</DataField>
|
||||||
|
<rd:TypeName>System.DateTime</rd:TypeName>
|
||||||
|
</Field>
|
||||||
|
<Field Name="OrdersCount">
|
||||||
|
<DataField>OrdersCount</DataField>
|
||||||
|
<rd:TypeName>System.Int32</rd:TypeName>
|
||||||
|
</Field>
|
||||||
|
<Field Name="OrdersSum">
|
||||||
|
<DataField>OrdersSum</DataField>
|
||||||
|
<rd:TypeName>System.Decimal</rd:TypeName>
|
||||||
|
</Field>
|
||||||
|
</Fields>
|
||||||
|
<rd:DataSetInfo>
|
||||||
|
<rd:DataSetName>PrecastConcretePlantContracts.ViewModels</rd:DataSetName>
|
||||||
|
<rd:TableName>ReportGroupOrdersViewModel</rd:TableName>
|
||||||
|
<rd:ObjectDataSourceType>PrecastConcretePlantContracts.ViewModels.ReportGroupOrdersViewModel, PrecastConcretePlantContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
||||||
|
</rd:DataSetInfo>
|
||||||
|
</DataSet>
|
||||||
|
</DataSets>
|
||||||
|
<ReportSections>
|
||||||
|
<ReportSection>
|
||||||
|
<Body>
|
||||||
|
<ReportItems>
|
||||||
|
<Textbox Name="TextboxTitle">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Отчёт по заказам</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Center</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<Width>16.51cm</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="ReportParameterPeriod">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Parameters!ReportParameterPeriod.Value</Value>
|
||||||
|
<Style>
|
||||||
|
<Format>d</Format>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Center</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
|
||||||
|
<Top>0.6cm</Top>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<Width>16.51cm</Width>
|
||||||
|
<ZIndex>1</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
<Tablix Name="Tablix1">
|
||||||
|
<TablixBody>
|
||||||
|
<TablixColumns>
|
||||||
|
<TablixColumn>
|
||||||
|
<Width>3.90406cm</Width>
|
||||||
|
</TablixColumn>
|
||||||
|
<TablixColumn>
|
||||||
|
<Width>3.97461cm</Width>
|
||||||
|
</TablixColumn>
|
||||||
|
<TablixColumn>
|
||||||
|
<Width>3.65711cm</Width>
|
||||||
|
</TablixColumn>
|
||||||
|
</TablixColumns>
|
||||||
|
<TablixRows>
|
||||||
|
<TablixRow>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<TablixCells>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="TextboxDate">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Дата создания</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<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="TextboxCount">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Количество заказов</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<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="TextboxSum">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Общая сумма заказов</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<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.6cm</Height>
|
||||||
|
<TablixCells>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="Date">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Fields!Date.Value</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Date</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="OrdersCount">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Fields!OrdersCount.Value</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>OrdersCount</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="OrdersSum">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Fields!OrdersSum.Value</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>OrdersSum</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>DataSetGroupedOrders</DataSetName>
|
||||||
|
<Top>1.88242cm</Top>
|
||||||
|
<Left>2.68676cm</Left>
|
||||||
|
<Height>1.2cm</Height>
|
||||||
|
<Width>11.53578cm</Width>
|
||||||
|
<ZIndex>2</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
</Style>
|
||||||
|
</Tablix>
|
||||||
|
<Textbox Name="TextboxResout">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Итого:</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Right</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<Top>3.29409cm</Top>
|
||||||
|
<Left>8.06542cm</Left>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<Width>2.5cm</Width>
|
||||||
|
<ZIndex>3</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
<Textbox Name="TextboxFullSum">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Sum(Fields!OrdersSum.Value, "DataSetGroupedOrders")</Value>
|
||||||
|
<Style>
|
||||||
|
<Format>0.00;(0.00)</Format>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Right</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<Top>3.29409cm</Top>
|
||||||
|
<Left>10.70653cm</Left>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<Width>3.48072cm</Width>
|
||||||
|
<ZIndex>4</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</ReportItems>
|
||||||
|
<Height>2in</Height>
|
||||||
|
<Style />
|
||||||
|
</Body>
|
||||||
|
<Width>6.5in</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>b5a8ad5e-1151-4687-8576-a5270295c079</rd:ReportID>
|
||||||
|
</Report>
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using PizzeriaBusinessLogic.Implements;
|
||||||
|
using PizzeriaBusinessLogic.MailWorker;
|
||||||
|
using PizzeriaBusinessLogic.OfficePackage;
|
||||||
|
using PizzeriaContracts.BusinessLogicsContracts;
|
||||||
|
using PizzeriaContracts.DI;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class BusinessLogicExtension : IBusinessLogicExtension
|
||||||
|
{
|
||||||
|
public int Priority => 0;
|
||||||
|
|
||||||
|
public void RegisterServices()
|
||||||
|
{
|
||||||
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IPizzaLogic, PizzaLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
||||||
|
DependencyManager.Instance.RegisterType<IShopLogic, ShopLogic>();
|
||||||
|
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
||||||
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
||||||
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
||||||
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
|
||||||
|
|
||||||
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,8 +25,10 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
|
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. MessageId:{MessageId}.ClientId:{ClientId}", model?.MessageId, model?.ClientId);
|
if (model == null)
|
||||||
var list = model == null ? _messageInfoStorage.GetFullList() : _messageInfoStorage.GetFilteredList(model);
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
_logger.LogInformation("ReadList. MessageId:{MessageId}.ClientId:{ClientId}.PageLength:{PageLength}.PageCount:{PageIndex}", model?.MessageId, model?.ClientId, model?.PageLength, model?.PageIndex);
|
||||||
|
var list = _messageInfoStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
@@ -38,7 +40,8 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
public bool Create(MessageInfoBindingModel model)
|
public bool Create(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model);
|
||||||
if (_messageInfoStorage.Insert(model) == null)
|
var message = _messageInfoStorage.Insert(model);
|
||||||
|
if (message == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Insert operation failed");
|
_logger.LogWarning("Insert operation failed");
|
||||||
return false;
|
return false;
|
||||||
@@ -51,27 +54,26 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
if (!withParams)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(model.MessageId))
|
if (string.IsNullOrEmpty(model.MessageId))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Не указан id сообщения", nameof(model.MessageId));
|
throw new ArgumentNullException("Не указан id сообщения", nameof(model.MessageId));
|
||||||
}
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(model.SenderName))
|
if (string.IsNullOrEmpty(model.SenderName))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Не указао почта", nameof(model.SenderName));
|
throw new ArgumentNullException("Не указао имя отправителя(электронная почта)", nameof(model.SenderName));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.Subject))
|
if (string.IsNullOrEmpty(model.Subject))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Не указана тема", nameof(model.Subject));
|
throw new ArgumentNullException("Не указана темма", nameof(model.Subject));
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(model.Body))
|
if (string.IsNullOrEmpty(model.Body))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Не указан текст сообщения", nameof(model.Subject));
|
throw new ArgumentNullException("Не указан текст сообщения", nameof(model.Subject));
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("MessageInfo. MessageId:{MessageId}.SenderName:{SenderName}.Subject:{Subject}.Body:{Body}", model.MessageId, model.SenderName, model.Subject, model.Body);
|
_logger.LogInformation("MessageInfo. MessageId:{MessageId}.SenderName:{SenderName}.Subject:{Subject}.Body:{Body}", model.MessageId, model.SenderName, model.Subject, model.Body);
|
||||||
var element = _clientStorage.GetElement(new ClientSearchModel
|
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||||
{
|
{
|
||||||
@@ -86,5 +88,33 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
model.ClientId = element.Id;
|
model.ClientId = element.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? ReadElement(MessageInfoSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. MessageId:{MessageId}", model?.MessageId);
|
||||||
|
var element = _messageInfoStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.MessageId);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, withParams: false);
|
||||||
|
if (_messageInfoStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,12 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
private readonly AbstractMailWorker _mailWorker;
|
private readonly AbstractMailWorker _mailWorker;
|
||||||
static readonly object _locker = new object();
|
static readonly object _locker = new object();
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, AbstractMailWorker mailWorker)
|
private readonly IShopStorage _shopStorage;
|
||||||
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopStorage shopStorage, AbstractMailWorker mailWorker)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
_mailWorker = mailWorker;
|
_mailWorker = mailWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -43,16 +45,17 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("ReadList. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}",
|
_logger.LogInformation("ReadList. ClientId:{ClientId}.Status:{Status}.ImplementerId:{ImplementerId}.DateFrom:{DateFrom}.DateTo:{DateTo}OrderId:{Id}",
|
||||||
model?.ClientId, model?.Status, model?.ImplementerId, model?.DateFrom, model?.DateTo, model?.Id);
|
model?.ClientId, model?.Status, model?.ImplementerId, model?.DateFrom, model?.DateTo, model?.Id);
|
||||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||||
if (list == null)
|
if (list == null)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("ReadList return null list");
|
_logger.LogWarning("ReadList return null list");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
return list;
|
return list;
|
||||||
|
|
||||||
}
|
}
|
||||||
public bool CreateOrder(OrderBindingModel model)
|
public bool CreateOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
@@ -87,7 +90,33 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
public bool DeliveryOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
return ChangeStatus(model, OrderStatus.Выдан);
|
lock (_locker)
|
||||||
|
{
|
||||||
|
//Создаём новую модель для обновления
|
||||||
|
(model, var element) = FillOrderBindingModel(model);
|
||||||
|
if (model.Status != OrderStatus.Готов && model.Status != OrderStatus.Ожидает)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Changing status operation faled: Current-{Status}:required-Выдан.", model.Status);
|
||||||
|
throw new InvalidOperationException($"Невозможно приствоить статус выдан заказу с текущим статусом {model.Status}");
|
||||||
|
}
|
||||||
|
//Пытаемся совершить поставку
|
||||||
|
if (!_shopStorage.RestockingShops(new SupplyBindingModel
|
||||||
|
{
|
||||||
|
PizzaId = model.PizzaId,
|
||||||
|
Count = model.Count
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
if (model.Status == OrderStatus.Готов)
|
||||||
|
{
|
||||||
|
model.Status = OrderStatus.Ожидает;
|
||||||
|
|
||||||
|
UpdateOrder(model, element);
|
||||||
|
}
|
||||||
|
throw new ArgumentException("Недостаточно места в магазинах для поставки");
|
||||||
|
}
|
||||||
|
model.Status = OrderStatus.Выдан;
|
||||||
|
return UpdateOrder(model, element);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
@@ -115,47 +144,61 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
model.PizzaId, model.Count,model.Sum, model.Id);
|
model.PizzaId, model.Count,model.Sum, model.Id);
|
||||||
}
|
}
|
||||||
private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) {
|
private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) {
|
||||||
CheckModel(model, false);
|
(model, var element) = FillOrderBindingModel(model);
|
||||||
var element = _orderStorage.GetElement(new OrderSearchModel()
|
|
||||||
{
|
|
||||||
Id = model.Id
|
|
||||||
});
|
|
||||||
if(element == null)
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException(nameof(element));
|
|
||||||
}
|
|
||||||
model.DateCreate = element.DateCreate;
|
|
||||||
model.PizzaId = element.PizzaId;
|
|
||||||
model.DateImplement = element.DateImplement;
|
|
||||||
model.ClientId = element.ClientId;
|
|
||||||
|
|
||||||
if (!model.ImplementerId.HasValue)
|
|
||||||
model.ImplementerId = element.ImplementerId;
|
|
||||||
|
|
||||||
model.Status = element.Status;
|
|
||||||
model.Count = element.Count;
|
|
||||||
model.Sum = element.Sum;
|
|
||||||
if (requiredStatus - model.Status == 1)
|
if (requiredStatus - model.Status == 1)
|
||||||
{
|
{
|
||||||
model.Status = requiredStatus;
|
model.Status = requiredStatus;
|
||||||
if (model.Status == OrderStatus.Готов)
|
if (model.Status == OrderStatus.Готов)
|
||||||
model.DateImplement = DateTime.Now;
|
model.DateImplement = DateTime.Now;
|
||||||
if (_orderStorage.Update(model) == null)
|
return UpdateOrder(model, element);
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
string DateInfo = model.DateImplement.HasValue ? $"Дата выполнения {model.DateImplement}" : "";
|
|
||||||
Task.Run(() => _mailWorker.MailSendAsync(new MailSendInfoBindingModel
|
|
||||||
{
|
|
||||||
MailAddress = element.ClientEmail,
|
|
||||||
Subject = $"Изменение статуса заказа номер {element.Id}",
|
|
||||||
Text = $"Ваш заказ номер {element.Id} на пиццу {element.PizzaName} от {element.DateCreate} на сумму {element.Sum} {model.Status}. {DateInfo}"
|
|
||||||
}));
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
_logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus);
|
_logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus);
|
||||||
throw new InvalidOperationException($"Невозможно приствоить статус {requiredStatus} заказу с текущим статусом {model.Status}");
|
throw new InvalidOperationException($"Невозможно приствоить статус {requiredStatus} заказу с текущим статусом {model.Status}");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private (OrderBindingModel, OrderViewModel) FillOrderBindingModel(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
var element = _orderStorage.GetElement(new OrderSearchModel()
|
||||||
|
{
|
||||||
|
Id = model.Id
|
||||||
|
});
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(nameof(element));
|
||||||
|
}
|
||||||
|
model.Id = element.Id;
|
||||||
|
model.DateCreate = element.DateCreate;
|
||||||
|
model.PizzaId = element.PizzaId;
|
||||||
|
model.DateImplement = element.DateImplement;
|
||||||
|
model.ClientId = element.ClientId;
|
||||||
|
model.Status = element.Status;
|
||||||
|
model.Count = element.Count;
|
||||||
|
model.Sum = element.Sum;
|
||||||
|
if (!model.ImplementerId.HasValue)
|
||||||
|
model.ImplementerId = element.ImplementerId;
|
||||||
|
|
||||||
|
return (model, element);
|
||||||
|
}
|
||||||
|
private bool UpdateOrder(OrderBindingModel model, OrderViewModel MailNotificationModel)
|
||||||
|
{
|
||||||
|
if (_orderStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_logger.LogWarning("Update operation sucsess");
|
||||||
|
string DateInfo = model.DateImplement.HasValue ? $"Дата выполнения {model.DateImplement}" : "";
|
||||||
|
Task.Run(() => _mailWorker.MailSendAsync(new MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
MailAddress = MailNotificationModel.ClientEmail,
|
||||||
|
Subject = $"Изменение статуса заказа номер {MailNotificationModel.Id}",
|
||||||
|
Text = $"Ваш заказ номер {MailNotificationModel.Id} на изделие {MailNotificationModel.PizzaName} от" +
|
||||||
|
$" {MailNotificationModel.DateCreate} на сумму {MailNotificationModel.Sum} {model.Status}. {DateInfo}"
|
||||||
|
}));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using PizzeriaBusinessLogic.OfficePackage.HelperModels.Word;
|
||||||
|
using PizzeriaBusinessLogic.OfficePackage.HelperModels.Excel;
|
||||||
|
using PizzeriaBusinessLogic.OfficePackage.HelperModels.PDF;
|
||||||
|
|
||||||
namespace PizzeriaBusinessLogic.BusinessLogics
|
namespace PizzeriaBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
@@ -18,16 +21,18 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
private readonly IComponentStorage _componentStorage;
|
private readonly IComponentStorage _componentStorage;
|
||||||
private readonly IPizzaStorage _pizzaStorage;
|
private readonly IPizzaStorage _pizzaStorage;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
private readonly AbstractSaveToExcel _saveToExcel;
|
private readonly AbstractSaveToExcel _saveToExcel;
|
||||||
private readonly AbstractSaveToWord _saveToWord;
|
private readonly AbstractSaveToWord _saveToWord;
|
||||||
private readonly AbstractSaveToPdf _saveToPdf;
|
private readonly AbstractSaveToPdf _saveToPdf;
|
||||||
|
|
||||||
public ReportLogic(IPizzaStorage pizzaStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
|
public ReportLogic(IPizzaStorage pizzaStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, IShopStorage shopStorage,
|
||||||
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||||
{
|
{
|
||||||
_pizzaStorage = pizzaStorage;
|
_pizzaStorage = pizzaStorage;
|
||||||
_componentStorage = componentStorage;
|
_componentStorage = componentStorage;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
|
|
||||||
_saveToExcel = saveToExcel;
|
_saveToExcel = saveToExcel;
|
||||||
_saveToWord = saveToWord;
|
_saveToWord = saveToWord;
|
||||||
@@ -57,7 +62,7 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
public void SavePizzasToWordFile(ReportBindingModel model)
|
public void SavePizzasToWordFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
_saveToWord.CreateDoc(new WordInfo
|
_saveToWord.CreatePizzaDoc(new WordPizzaInfo
|
||||||
{
|
{
|
||||||
FileName = model.FileName,
|
FileName = model.FileName,
|
||||||
Title = "Список пицц",
|
Title = "Список пицц",
|
||||||
@@ -84,5 +89,55 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
Orders = GetOrders(model)
|
Orders = GetOrders(model)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ReportShopsViewModel> GetShops()
|
||||||
|
{
|
||||||
|
return _shopStorage.GetFullList().Select(x => new ReportShopsViewModel
|
||||||
|
{
|
||||||
|
ShopName = x.ShopName,
|
||||||
|
Pizzas = x.ShopPizzas.Select(x => (x.Value.Item1.PizzaName, x.Value.Item2)).ToList(),
|
||||||
|
TotalCount = x.ShopPizzas.Select(x => x.Value.Item2).Sum()
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ReportGroupOrdersViewModel> GetGroupedOrders()
|
||||||
|
{
|
||||||
|
return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportGroupOrdersViewModel
|
||||||
|
{
|
||||||
|
Date = x.Key,
|
||||||
|
OrdersCount = x.Count(),
|
||||||
|
OrdersSum = x.Select(y => y.Sum).Sum()
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveShopsToWordFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToWord.CreateShopsDoc(new WordShopInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список магазинов",
|
||||||
|
Shops = _shopStorage.GetFullList()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveShopsToExcelFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToExcel.CreateShopPizzasReport(new ExcelShop
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Наполненость магазинов",
|
||||||
|
ShopPizzas = GetShops()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveGroupedOrdersToPdfFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToPdf.CreateGroupedOrdersDoc(new PdfGroupedOrdersInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список заказов сгруппированных по дате заказов",
|
||||||
|
GroupedOrders = GetGroupedOrders()
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
180
Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ShopLogic.cs
Normal file
180
Pizzeria/PizzeriaBusinessLogic/BusinessLogics/ShopLogic.cs
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.BusinessLogicsContracts;
|
||||||
|
using PizzeriaContracts.SearchModels;
|
||||||
|
using PizzeriaContracts.StoragesContracts;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ShopLogic : IShopLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
|
private readonly IPizzaStorage _pizzaStorage;
|
||||||
|
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage, IPizzaStorage pizzaStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
|
_pizzaStorage = pizzaStorage;
|
||||||
|
}
|
||||||
|
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id}", model?.ShopName, model?.Id);
|
||||||
|
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
public ShopViewModel? ReadElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id);
|
||||||
|
var element = _shopStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
public bool Create(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_shopStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_shopStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_shopStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool MakeSupply(SupplyBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (model.Count <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Количество пиццы должно быть больше 0");
|
||||||
|
}
|
||||||
|
var shop = _shopStorage.GetElement(new ShopSearchModel
|
||||||
|
{
|
||||||
|
Id = model.ShopId
|
||||||
|
});
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Магазина не существует");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (shop.ShopPizzas.ContainsKey(model.PizzaId))
|
||||||
|
{
|
||||||
|
var oldValue = shop.ShopPizzas[model.PizzaId];
|
||||||
|
oldValue.Item2 += model.Count;
|
||||||
|
shop.ShopPizzas[model.PizzaId] = oldValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var pizza = _pizzaStorage.GetElement(new PizzaSearchModel
|
||||||
|
{
|
||||||
|
Id = model.PizzaId
|
||||||
|
});
|
||||||
|
if (pizza == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"Поставка: Товар с id:{model.PizzaId} не найденн");
|
||||||
|
}
|
||||||
|
shop.ShopPizzas.Add(model.PizzaId, (pizza, model.Count));
|
||||||
|
|
||||||
|
}
|
||||||
|
_shopStorage.Update(new ShopBindingModel()
|
||||||
|
{
|
||||||
|
Id = shop.Id,
|
||||||
|
ShopName = shop.ShopName,
|
||||||
|
Adress = shop.Adress,
|
||||||
|
OpeningDate = shop.OpeningDate,
|
||||||
|
ShopPizzas = shop.ShopPizzas,
|
||||||
|
PizzaMaxCount = shop.PizzaMaxCount,
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Adress))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Адрес магазина длжен быть заполнен",nameof(model.Adress));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Название магазина должно быть заполнено",nameof(model.ShopName));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Shop. ShopName:{ShopName}.Adres:{Adres}.OpeningDate:{OpeningDate}.Id:{ Id}", model.ShopName, model.Adress, model.OpeningDate, model.Id);
|
||||||
|
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||||
|
{
|
||||||
|
ShopName = model.ShopName
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Sale(SupplySearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.PizzaId.HasValue || !model.Count.HasValue)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Check pizza count in all shops");
|
||||||
|
if (_shopStorage.Sale(model))
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Selling sucsess");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Selling failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -35,12 +35,14 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
_logger.LogWarning("DoWork. Implementers is null");
|
_logger.LogWarning("DoWork. Implementers is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
|
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Выдан });
|
||||||
if (orders == null || orders.Count == 0)
|
int count = _orderLogic.ReadList(null).Count;
|
||||||
|
if (orders == null || count == orders.Count)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
orders = _orderLogic.ReadList(null);
|
||||||
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
||||||
foreach (var implementer in implementers)
|
foreach (var implementer in implementers)
|
||||||
{
|
{
|
||||||
@@ -59,6 +61,7 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await DeliverWaitingOrder(implementer);
|
||||||
await RunOrderInWork(implementer);
|
await RunOrderInWork(implementer);
|
||||||
|
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
@@ -81,6 +84,7 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
Id = order.Id
|
Id = order.Id
|
||||||
});
|
});
|
||||||
|
_orderLogic.DeliveryOrder(new OrderBindingModel { Id = order.Id });
|
||||||
}
|
}
|
||||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||||
catch (InvalidOperationException ex)
|
catch (InvalidOperationException ex)
|
||||||
@@ -130,6 +134,7 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
Id = runOrder.Id
|
Id = runOrder.Id
|
||||||
});
|
});
|
||||||
|
_orderLogic.DeliveryOrder(new OrderBindingModel { Id = runOrder.Id });
|
||||||
// отдыхаем
|
// отдыхаем
|
||||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
}
|
}
|
||||||
@@ -145,5 +150,47 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task DeliverWaitingOrder(ImplementerViewModel implementer)
|
||||||
|
{
|
||||||
|
if (_orderLogic == null || implementer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var waitingOrders = await Task.Run(() => _orderLogic.ReadList(new OrderSearchModel
|
||||||
|
{
|
||||||
|
ImplementerId = implementer.Id,
|
||||||
|
Status = OrderStatus.Ожидает
|
||||||
|
})) ;
|
||||||
|
if (waitingOrders == null || waitingOrders.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("DeliverWaitingOrder. Find some waitig order for implementer:{id}.Count:{count}", implementer.Id, waitingOrders.Count);
|
||||||
|
foreach (var waitingOrder in waitingOrders)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("DeliverWaitingOrder. Trying to deliver order id:{id}", waitingOrder.Id);
|
||||||
|
var res = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = waitingOrder.Id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "DeliverWaitingOrder. Fault");
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error try deliver order");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ namespace PizzeriaBusinessLogic.Implements
|
|||||||
_ => 0U,
|
_ => 0U,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
protected override void CreateExcel(ExcelInfo info)
|
protected override void CreateExcel(IDocument info)
|
||||||
{
|
{
|
||||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||||
// Создаем книгу (в ней хранятся листы)
|
// Создаем книгу (в ней хранятся листы)
|
||||||
@@ -269,7 +269,7 @@ namespace PizzeriaBusinessLogic.Implements
|
|||||||
};
|
};
|
||||||
mergeCells.Append(mergeCell);
|
mergeCells.Append(mergeCell);
|
||||||
}
|
}
|
||||||
protected override void SaveExcel(ExcelInfo info)
|
protected override void SaveExcel(IDocument info)
|
||||||
{
|
{
|
||||||
if (_spreadsheetDocument == null)
|
if (_spreadsheetDocument == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace PizzeriaBusinessLogic.Implements
|
|||||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||||
style.Font.Bold = true;
|
style.Font.Bold = true;
|
||||||
}
|
}
|
||||||
protected override void CreatePdf(PdfInfo info)
|
protected override void CreatePdf(IDocument info)
|
||||||
{
|
{
|
||||||
_document = new Document();
|
_document = new Document();
|
||||||
DefineStyles(_document);
|
DefineStyles(_document);
|
||||||
@@ -95,7 +95,7 @@ namespace PizzeriaBusinessLogic.Implements
|
|||||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void SavePdf(PdfInfo info)
|
protected override void SavePdf(IDocument info)
|
||||||
{
|
{
|
||||||
var renderer = new PdfDocumentRenderer(true)
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using DocumentFormat.OpenXml.Wordprocessing;
|
|||||||
using PizzeriaBusinessLogic.OfficePackage;
|
using PizzeriaBusinessLogic.OfficePackage;
|
||||||
using PizzeriaBusinessLogic.OfficePackage.HelperEnums;
|
using PizzeriaBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using PizzeriaBusinessLogic.OfficePackage.HelperModels;
|
using PizzeriaBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using PizzeriaBusinessLogic.OfficePackage.HelperModels.Word;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -69,7 +70,7 @@ namespace PizzeriaBusinessLogic.Implements
|
|||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
protected override void CreateWord(WordInfo info)
|
protected override void CreateWord(IDocument info)
|
||||||
{
|
{
|
||||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||||
@@ -105,7 +106,7 @@ namespace PizzeriaBusinessLogic.Implements
|
|||||||
|
|
||||||
_docBody.AppendChild(docParagraph);
|
_docBody.AppendChild(docParagraph);
|
||||||
}
|
}
|
||||||
protected override void SaveWord(WordInfo info)
|
protected override void SaveWord(IDocument info)
|
||||||
{
|
{
|
||||||
if (_docBody == null || _wordDocument == null)
|
if (_docBody == null || _wordDocument == null)
|
||||||
{
|
{
|
||||||
@@ -117,5 +118,76 @@ namespace PizzeriaBusinessLogic.Implements
|
|||||||
|
|
||||||
_wordDocument.Close();
|
_wordDocument.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Table? _lastTable;
|
||||||
|
protected override void CreateTable(List<string> columns)
|
||||||
|
{
|
||||||
|
if (_docBody == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_lastTable = new Table();
|
||||||
|
|
||||||
|
var tableProp = new TableProperties();
|
||||||
|
tableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
|
||||||
|
tableProp.AppendChild(new TableBorders(
|
||||||
|
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 }
|
||||||
|
));
|
||||||
|
tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
|
||||||
|
_lastTable.AppendChild(tableProp);
|
||||||
|
|
||||||
|
TableGrid tableGrid = new TableGrid();
|
||||||
|
foreach (var column in columns)
|
||||||
|
{
|
||||||
|
tableGrid.AppendChild(new GridColumn() { Width = column });
|
||||||
|
}
|
||||||
|
_lastTable.AppendChild(tableGrid);
|
||||||
|
|
||||||
|
_docBody.AppendChild(_lastTable);
|
||||||
|
}
|
||||||
|
protected override void CreateRow(WordRowParameters rowParameters)
|
||||||
|
{
|
||||||
|
if (_docBody == null || _lastTable == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TableRow docRow = new TableRow();
|
||||||
|
foreach (var column in rowParameters.Texts)
|
||||||
|
{
|
||||||
|
var docParagraph = new Paragraph();
|
||||||
|
WordParagraph paragraph = new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)> { (column, rowParameters.TextProperties) },
|
||||||
|
TextProperties = rowParameters.TextProperties
|
||||||
|
};
|
||||||
|
|
||||||
|
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||||
|
|
||||||
|
foreach (var run in paragraph.Texts)
|
||||||
|
{
|
||||||
|
var docRun = new Run();
|
||||||
|
|
||||||
|
var properties = new RunProperties();
|
||||||
|
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||||
|
if (run.Item2.Bold)
|
||||||
|
{
|
||||||
|
properties.AppendChild(new Bold());
|
||||||
|
}
|
||||||
|
docRun.AppendChild(properties);
|
||||||
|
|
||||||
|
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||||
|
|
||||||
|
docParagraph.AppendChild(docRun);
|
||||||
|
}
|
||||||
|
|
||||||
|
TableCell docCell = new TableCell();
|
||||||
|
docCell.AppendChild(docParagraph);
|
||||||
|
docRow.AppendChild(docCell);
|
||||||
|
}
|
||||||
|
_lastTable.AppendChild(docRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,50 @@ namespace PizzeriaBusinessLogic.MailWorker
|
|||||||
_messageInfoLogic.Create(mail);
|
_messageInfoLogic.Create(mail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
|
|
||||||
|
public async void MailSendReplyAsync(MailReplySendInfoBindingModel info)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text) || string.IsNullOrEmpty(info.ParentMessageId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogDebug("Send Mail as reply: {To}, {Subject}, {parentId}", info.MailAddress, info.Subject, info.ParentMessageId);
|
||||||
|
|
||||||
|
string? messageId = await SendMailAsync(info);
|
||||||
|
if (string.IsNullOrEmpty(messageId))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Непредвиденная ошибка при отправке сообщения в ответ");
|
||||||
|
}
|
||||||
|
if (_messageInfoLogic.Create(new MessageInfoBindingModel
|
||||||
|
{
|
||||||
|
MessageId = messageId,
|
||||||
|
DateDelivery = DateTime.Now,
|
||||||
|
SenderName = _mailLogin,
|
||||||
|
IsReply = true,
|
||||||
|
Subject = info.Subject,
|
||||||
|
Body = info.Text,
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
_messageInfoLogic.Update(new MessageInfoBindingModel()
|
||||||
|
{
|
||||||
|
MessageId = info.ParentMessageId,
|
||||||
|
ReplyMessageId = messageId,
|
||||||
|
IsReaded = true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected abstract Task<string?> SendMailAsync(MailSendInfoBindingModel info);
|
||||||
protected abstract Task<List<MessageInfoBindingModel>> ReceiveMailAsync();
|
protected abstract Task<List<MessageInfoBindingModel>> ReceiveMailAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,30 +17,36 @@ namespace PizzeriaBusinessLogic.MailWorker
|
|||||||
{
|
{
|
||||||
public MailKitWorker(ILogger<MailKitWorker> logger, IMessageInfoLogic messageInfoLogic) : base(logger, messageInfoLogic) { }
|
public MailKitWorker(ILogger<MailKitWorker> logger, IMessageInfoLogic messageInfoLogic) : base(logger, messageInfoLogic) { }
|
||||||
|
|
||||||
protected override async Task SendMailAsync(MailSendInfoBindingModel info)
|
protected override async Task<string?> SendMailAsync(MailSendInfoBindingModel info)
|
||||||
{
|
{
|
||||||
|
string? resount = null;
|
||||||
|
|
||||||
using var objMailMessage = new MailMessage();
|
using var objMailMessage = new MailMessage();
|
||||||
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
|
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
objMailMessage.From = new MailAddress(_mailLogin);
|
ConfigurateSmtpClient(objSmtpClient);
|
||||||
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
CreateMessage(objMailMessage, info);
|
||||||
objMailMessage.Subject = info.Subject;
|
|
||||||
objMailMessage.Body = info.Text;
|
|
||||||
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
|
||||||
objMailMessage.BodyEncoding = Encoding.UTF8;
|
|
||||||
|
|
||||||
objSmtpClient.UseDefaultCredentials = false;
|
if (info is MailReplySendInfoBindingModel replyInfo)
|
||||||
objSmtpClient.EnableSsl = true;
|
{
|
||||||
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
objMailMessage.Headers.Add("In-Reply-To", replyInfo.ParentMessageId);
|
||||||
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
objMailMessage.Headers.Add("References", replyInfo.ParentMessageId);
|
||||||
|
|
||||||
|
string messageGuid = Guid.NewGuid().ToString();
|
||||||
|
objMailMessage.Headers.Add("Message-Id", messageGuid);
|
||||||
|
resount = messageGuid;
|
||||||
|
}
|
||||||
|
|
||||||
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return resount;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async Task<List<MessageInfoBindingModel>> ReceiveMailAsync()
|
protected override async Task<List<MessageInfoBindingModel>> ReceiveMailAsync()
|
||||||
@@ -78,5 +84,24 @@ namespace PizzeriaBusinessLogic.MailWorker
|
|||||||
});
|
});
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CreateMessage(MailMessage objMailMessage, MailSendInfoBindingModel info)
|
||||||
|
{
|
||||||
|
objMailMessage.From = new MailAddress(_mailLogin);
|
||||||
|
objMailMessage.To.Add(new MailAddress(info.MailAddress));
|
||||||
|
objMailMessage.Subject = info.Subject;
|
||||||
|
objMailMessage.Body = info.Text;
|
||||||
|
objMailMessage.SubjectEncoding = Encoding.UTF8;
|
||||||
|
objMailMessage.BodyEncoding = Encoding.UTF8;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConfigurateSmtpClient(SmtpClient objSmtpClient)
|
||||||
|
{
|
||||||
|
|
||||||
|
objSmtpClient.UseDefaultCredentials = false;
|
||||||
|
objSmtpClient.EnableSsl = true;
|
||||||
|
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||||
|
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using PizzeriaBusinessLogic.OfficePackage.HelperEnums;
|
using PizzeriaBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using PizzeriaBusinessLogic.OfficePackage.HelperModels;
|
using PizzeriaBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using PizzeriaBusinessLogic.OfficePackage.HelperModels.Excel;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -80,9 +81,82 @@ namespace PizzeriaBusinessLogic.OfficePackage
|
|||||||
|
|
||||||
SaveExcel(info);
|
SaveExcel(info);
|
||||||
}
|
}
|
||||||
protected abstract void CreateExcel(ExcelInfo info);
|
|
||||||
|
public void CreateShopPizzasReport(ExcelShop 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 sr in info.ShopPizzas)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = sr.ShopName,
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
rowIndex++;
|
||||||
|
|
||||||
|
foreach (var (Pizza, Count) in sr.Pizzas)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "B",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = Pizza,
|
||||||
|
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 = sr.TotalCount.ToString(),
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveExcel(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void CreateExcel(IDocument info);
|
||||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||||
protected abstract void SaveExcel(ExcelInfo info);
|
protected abstract void SaveExcel(IDocument info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using PizzeriaBusinessLogic.OfficePackage.HelperEnums;
|
using PizzeriaBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using PizzeriaBusinessLogic.OfficePackage.HelperModels;
|
using PizzeriaBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using PizzeriaBusinessLogic.OfficePackage.HelperModels.PDF;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -38,10 +39,40 @@ namespace PizzeriaBusinessLogic.OfficePackage
|
|||||||
|
|
||||||
SavePdf(info);
|
SavePdf(info);
|
||||||
}
|
}
|
||||||
protected abstract void CreatePdf(PdfInfo info);
|
|
||||||
|
public void CreateGroupedOrdersDoc(PdfGroupedOrdersInfo info)
|
||||||
|
{
|
||||||
|
CreatePdf(info);
|
||||||
|
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
|
|
||||||
|
CreateTable(new List<string> { "4cm", "3cm", "2cm" });
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Дата заказа", "Кол-во", "Сумма" },
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var groupedOrder in info.GroupedOrders)
|
||||||
|
{
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { groupedOrder.Date.ToShortDateString(), groupedOrder.OrdersCount.ToString(), groupedOrder.OrdersSum.ToString() },
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.GroupedOrders.Sum(x => x.OrdersSum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
|
|
||||||
|
SavePdf(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void CreatePdf(IDocument info);
|
||||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||||
protected abstract void CreateTable(List<string> columns);
|
protected abstract void CreateTable(List<string> columns);
|
||||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||||
protected abstract void SavePdf(PdfInfo info);
|
protected abstract void SavePdf(IDocument info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using PizzeriaBusinessLogic.OfficePackage.HelperEnums;
|
using PizzeriaBusinessLogic.OfficePackage.HelperEnums;
|
||||||
using PizzeriaBusinessLogic.OfficePackage.HelperModels;
|
using PizzeriaBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using PizzeriaBusinessLogic.OfficePackage.HelperModels.Word;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -10,7 +11,7 @@ namespace PizzeriaBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
public abstract class AbstractSaveToWord
|
public abstract class AbstractSaveToWord
|
||||||
{
|
{
|
||||||
public void CreateDoc(WordInfo info)
|
public void CreatePizzaDoc(WordPizzaInfo info)
|
||||||
{
|
{
|
||||||
CreateWord(info);
|
CreateWord(info);
|
||||||
|
|
||||||
@@ -42,8 +43,51 @@ namespace PizzeriaBusinessLogic.OfficePackage
|
|||||||
|
|
||||||
SaveWord(info);
|
SaveWord(info);
|
||||||
}
|
}
|
||||||
protected abstract void CreateWord(WordInfo info);
|
|
||||||
|
public void CreateShopsDoc(WordShopInfo info)
|
||||||
|
{
|
||||||
|
CreateWord(info);
|
||||||
|
CreateParagraph(new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
JustificationType = WordJustificationType.Center
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
CreateTable(new List<string> { "3000", "3000", "3000" });
|
||||||
|
CreateRow(new WordRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Название", "Адрес", "Дата открытия" },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
Bold = true,
|
||||||
|
JustificationType = WordJustificationType.Center
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var shop in info.Shops)
|
||||||
|
{
|
||||||
|
CreateRow(new WordRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { shop.ShopName, shop.Adress, shop.OpeningDate.ToString() },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "22",
|
||||||
|
JustificationType = WordJustificationType.Both
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveWord(info);
|
||||||
|
}
|
||||||
|
protected abstract void CreateWord(IDocument info);
|
||||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||||
protected abstract void SaveWord(WordInfo info);
|
protected abstract void SaveWord(IDocument info);
|
||||||
|
protected abstract void CreateTable(List<string> colums);
|
||||||
|
protected abstract void CreateRow(WordRowParameters rowParameters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
|
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class ExcelInfo
|
public class ExcelInfo : IDocument
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels.Excel
|
||||||
|
{
|
||||||
|
public class ExcelShop : IDocument
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public List<ReportShopsViewModel> ShopPizzas { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels.PDF
|
||||||
|
{
|
||||||
|
public class PdfGroupedOrdersInfo : IDocument
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public DateTime DateFrom { get; set; }
|
||||||
|
public DateTime DateTo { get; set; }
|
||||||
|
public List<ReportGroupOrdersViewModel> GroupedOrders { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
|
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class PdfInfo
|
public class PdfInfo : IDocument
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
|
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class WordInfo
|
public class WordPizzaInfo : IDocument
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels.Word
|
||||||
|
{
|
||||||
|
public class WordRowParameters
|
||||||
|
{
|
||||||
|
public List<string> Texts { get; set; } = new();
|
||||||
|
public WordTextProperties TextProperties { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaBusinessLogic.OfficePackage.HelperModels.Word
|
||||||
|
{
|
||||||
|
public class WordShopInfo : IDocument
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public List<ShopViewModel> Shops { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Pizzeria/PizzeriaBusinessLogic/OfficePackage/IDocument.cs
Normal file
14
Pizzeria/PizzeriaBusinessLogic/OfficePackage/IDocument.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public interface IDocument
|
||||||
|
{
|
||||||
|
public string FileName { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,10 @@
|
|||||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
|
<Exec Command="copy /Y "$(TargetDir)*.dll" "$(SolutionDir)BusinessLogicExtensions\*.dll"" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\PizzeriaContracts\PizzeriaContracts.csproj" />
|
<ProjectReference Include="..\PizzeriaContracts\PizzeriaContracts.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -13,13 +13,18 @@
|
|||||||
|
|
||||||
public bool IsUseAutoSize { get; private set; }
|
public bool IsUseAutoSize { get; private set; }
|
||||||
|
|
||||||
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false)
|
public string Format { get; private set; }
|
||||||
|
|
||||||
|
public ColumnAttribute(string title = "", bool visible = true, int width = 0,
|
||||||
|
GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false,
|
||||||
|
string format = "")
|
||||||
{
|
{
|
||||||
Title = title;
|
Title = title;
|
||||||
Visible = visible;
|
Visible = visible;
|
||||||
Width = width;
|
Width = width;
|
||||||
GridViewAutoSize = gridViewAutoSize;
|
GridViewAutoSize = gridViewAutoSize;
|
||||||
IsUseAutoSize = isUseAutoSize;
|
IsUseAutoSize = isUseAutoSize;
|
||||||
|
Format = format;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class MailReplySendInfoBindingModel : MailSendInfoBindingModel
|
||||||
|
{
|
||||||
|
public string ParentMessageId { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,9 @@ namespace PizzeriaContracts.BindingModels
|
|||||||
public string Subject { get; set; } = string.Empty;
|
public string Subject { get; set; } = string.Empty;
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
public bool IsReaded { get; set; }
|
||||||
|
public string? ReplyMessageId { get; set; }
|
||||||
|
public bool IsReply { get; set; }
|
||||||
public int Id => throw new NotImplementedException();
|
public int Id => throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
Pizzeria/PizzeriaContracts/BindingModels/ShopBindingModel.cs
Normal file
19
Pizzeria/PizzeriaContracts/BindingModels/ShopBindingModel.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using PizzeriaDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ShopBindingModel : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
public string Adress { get; set; } = string.Empty;
|
||||||
|
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||||
|
public Dictionary<int, (IPizzaModel, int)> ShopPizzas { get; set; } = new();
|
||||||
|
public int PizzaMaxCount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using PizzeriaDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class SupplyBindingModel : ISupplyModel
|
||||||
|
{
|
||||||
|
public int ShopId { get; set; }
|
||||||
|
public int PizzaId { get; set; }
|
||||||
|
public int Count { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,6 +11,9 @@ namespace PizzeriaContracts.BusinessLogicsContracts
|
|||||||
{
|
{
|
||||||
public interface IMessageInfoLogic
|
public interface IMessageInfoLogic
|
||||||
{
|
{
|
||||||
|
MessageInfoViewModel? ReadElement(MessageInfoSearchModel model);
|
||||||
|
|
||||||
|
bool Update(MessageInfoBindingModel model);
|
||||||
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
||||||
bool Create(MessageInfoBindingModel model);
|
bool Create(MessageInfoBindingModel model);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,13 @@ namespace PizzeriaContracts.BusinessLogicsContracts
|
|||||||
{
|
{
|
||||||
List<ReportPizzaComponentViewModel> GetPizzaComponents();
|
List<ReportPizzaComponentViewModel> GetPizzaComponents();
|
||||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||||
|
List<ReportShopsViewModel> GetShops();
|
||||||
|
List<ReportGroupOrdersViewModel> GetGroupedOrders();
|
||||||
void SavePizzasToWordFile(ReportBindingModel model);
|
void SavePizzasToWordFile(ReportBindingModel model);
|
||||||
void SavePizzaComponentToExcelFile(ReportBindingModel model);
|
void SavePizzaComponentToExcelFile(ReportBindingModel model);
|
||||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||||
|
void SaveShopsToWordFile(ReportBindingModel model);
|
||||||
|
void SaveShopsToExcelFile(ReportBindingModel model);
|
||||||
|
void SaveGroupedOrdersToPdfFile(ReportBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.SearchModels;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IShopLogic
|
||||||
|
{
|
||||||
|
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||||
|
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||||
|
bool Create(ShopBindingModel model);
|
||||||
|
bool Update(ShopBindingModel model);
|
||||||
|
bool Delete(ShopBindingModel model);
|
||||||
|
bool MakeSupply(SupplyBindingModel model);
|
||||||
|
bool Sale(SupplySearchModel model);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,12 +28,14 @@ namespace PizzeriaContracts.DI
|
|||||||
public static void InitDependency()
|
public static void InitDependency()
|
||||||
{
|
{
|
||||||
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
||||||
if (ext == null)
|
var extLogic = ServiceProviderLoader.GetBusinessLogicExtensions();
|
||||||
|
if (ext == null || extLogic == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
|
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям");
|
||||||
}
|
}
|
||||||
// регистрируем зависимости
|
// регистрируем зависимости
|
||||||
ext.RegisterServices();
|
ext.RegisterServices();
|
||||||
|
extLogic.RegisterServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
15
Pizzeria/PizzeriaContracts/DI/IBusinessLogicExtension.cs
Normal file
15
Pizzeria/PizzeriaContracts/DI/IBusinessLogicExtension.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.DI
|
||||||
|
{
|
||||||
|
public interface IBusinessLogicExtension
|
||||||
|
{
|
||||||
|
public int Priority { get; }
|
||||||
|
|
||||||
|
public void RegisterServices();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,6 +42,35 @@ namespace PizzeriaContracts.DI
|
|||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IBusinessLogicExtension? GetBusinessLogicExtensions()
|
||||||
|
{
|
||||||
|
IBusinessLogicExtension? source = null;
|
||||||
|
var files = Directory.GetFiles(TryGetBusinessLogicExtensionsFolder(), "*.dll", SearchOption.AllDirectories);
|
||||||
|
foreach (var file in files.Distinct())
|
||||||
|
{
|
||||||
|
Assembly asm = Assembly.LoadFrom(file);
|
||||||
|
foreach (var t in asm.GetExportedTypes())
|
||||||
|
{
|
||||||
|
if (t.IsClass && typeof(IBusinessLogicExtension).IsAssignableFrom(t))
|
||||||
|
{
|
||||||
|
if (source == null)
|
||||||
|
{
|
||||||
|
source = (IBusinessLogicExtension)Activator.CreateInstance(t)!;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newSource = (IBusinessLogicExtension)Activator.CreateInstance(t)!;
|
||||||
|
if (newSource.Priority > source.Priority)
|
||||||
|
{
|
||||||
|
source = newSource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
private static string TryGetImplementationExtensionsFolder()
|
private static string TryGetImplementationExtensionsFolder()
|
||||||
{
|
{
|
||||||
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||||
@@ -51,5 +80,15 @@ namespace PizzeriaContracts.DI
|
|||||||
}
|
}
|
||||||
return $"{directory?.FullName}\\ImplementationExtensions";
|
return $"{directory?.FullName}\\ImplementationExtensions";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string TryGetBusinessLogicExtensionsFolder()
|
||||||
|
{
|
||||||
|
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||||
|
while (directory != null && !directory.GetDirectories("BusinessLogicExtensions", SearchOption.AllDirectories).Any(x => x.Name == "BusinessLogicExtensions"))
|
||||||
|
{
|
||||||
|
directory = directory.Parent;
|
||||||
|
}
|
||||||
|
return $"{directory?.FullName}\\BusinessLogicExtensions";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
50
Pizzeria/PizzeriaContracts/DI/UnityDependencyContainer.cs
Normal file
50
Pizzeria/PizzeriaContracts/DI/UnityDependencyContainer.cs
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Unity;
|
||||||
|
using Unity.Microsoft.Logging;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.DI
|
||||||
|
{
|
||||||
|
public class UnityDependencyContainer : IDependencyContainer
|
||||||
|
{
|
||||||
|
private readonly UnityContainer _container;
|
||||||
|
|
||||||
|
public UnityDependencyContainer()
|
||||||
|
{
|
||||||
|
_container = new UnityContainer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||||
|
{
|
||||||
|
_container.AddExtension(new LoggingExtension(LoggerFactory.Create(configure)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_container.RegisterSingleton<T, U>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_container.RegisterType<T, U>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterType<T>(bool isSingle) where T : class
|
||||||
|
{
|
||||||
|
if (isSingle)
|
||||||
|
{
|
||||||
|
_container.RegisterSingleton<T>();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_container.RegisterType<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Resolve<T>()
|
||||||
|
{
|
||||||
|
return _container.Resolve<T>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -10,5 +10,7 @@ namespace PizzeriaContracts.SearchModels
|
|||||||
{
|
{
|
||||||
public int? ClientId { get; set; }
|
public int? ClientId { get; set; }
|
||||||
public string? MessageId { get; set; }
|
public string? MessageId { get; set; }
|
||||||
|
public int? PageLength { get; set; }
|
||||||
|
public int? PageIndex { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
Pizzeria/PizzeriaContracts/SearchModels/ShopSearchModel.cs
Normal file
14
Pizzeria/PizzeriaContracts/SearchModels/ShopSearchModel.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ShopSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? ShopName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Pizzeria/PizzeriaContracts/SearchModels/SupplySearchModel.cs
Normal file
14
Pizzeria/PizzeriaContracts/SearchModels/SupplySearchModel.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class SupplySearchModel
|
||||||
|
{
|
||||||
|
public int? PizzaId { get; set; }
|
||||||
|
public int? Count { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,5 +15,6 @@ namespace PizzeriaContracts.StoragesContracts
|
|||||||
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
||||||
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
||||||
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
||||||
|
MessageInfoViewModel? Update(MessageInfoBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
23
Pizzeria/PizzeriaContracts/StoragesContracts/IShopStorage.cs
Normal file
23
Pizzeria/PizzeriaContracts/StoragesContracts/IShopStorage.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.SearchModels;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IShopStorage
|
||||||
|
{
|
||||||
|
List<ShopViewModel> GetFullList();
|
||||||
|
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||||
|
ShopViewModel? GetElement(ShopSearchModel model);
|
||||||
|
ShopViewModel? Insert(ShopBindingModel model);
|
||||||
|
ShopViewModel? Update(ShopBindingModel model);
|
||||||
|
ShopViewModel? Delete(ShopBindingModel model);
|
||||||
|
bool Sale(SupplySearchModel model);
|
||||||
|
bool RestockingShops(SupplyBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ namespace PizzeriaContracts.ViewModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[Column(title: "Название ингридиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[Column(title: "Название ингридиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string ComponentName { get; set; } = string.Empty;
|
public string ComponentName { get; set; } = string.Empty;
|
||||||
[Column(title: "Цена", width: 150)]
|
[Column(title: "Цена", width: 150, format: "c")]
|
||||||
public double Cost { get; set; }
|
public double Cost { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,16 +14,16 @@ namespace PizzeriaContracts.ViewModels
|
|||||||
[Column(visible: false)]
|
[Column(visible: false)]
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[Column(title: "ФИО исполнителя", width: 300)]
|
||||||
public string ImplementerFIO { get; set; } = string.Empty;
|
public string ImplementerFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Column(title: "Пароль", width: 100)]
|
[Column(title: "Пароль", width: 100)]
|
||||||
public string Password { get; set; } = string.Empty;
|
public string Password { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Column(title: "Стаж работы", width: 60)]
|
[Column(title: "Стаж работы", width: 100)]
|
||||||
public int WorkExperience { get; set; }
|
public int WorkExperience { get; set; }
|
||||||
|
|
||||||
[Column(title: "Квалификация", width: 60)]
|
[Column(title: "Квалификация", width: 100)]
|
||||||
public int Qualification { get; set; }
|
public int Qualification { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace PizzeriaContracts.ViewModels
|
|||||||
[Column(title: "Отправитель", width: 150)]
|
[Column(title: "Отправитель", width: 150)]
|
||||||
public string SenderName { get; set; } = string.Empty;
|
public string SenderName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Column(title: "Дата письма", width: 120)]
|
[Column(title: "Дата письма", width: 120, format: "g")]
|
||||||
public DateTime DateDelivery { get; set; }
|
public DateTime DateDelivery { get; set; }
|
||||||
|
|
||||||
[Column(title: "Заголовок", width: 120)]
|
[Column(title: "Заголовок", width: 120)]
|
||||||
@@ -31,5 +31,14 @@ namespace PizzeriaContracts.ViewModels
|
|||||||
|
|
||||||
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Прочитанно")]
|
||||||
|
public bool IsReaded { get; set; }
|
||||||
|
|
||||||
|
public string? ReplyMessageId { get; set; }
|
||||||
|
|
||||||
|
public IMessageInfoModel? Reply { get; set; }
|
||||||
|
|
||||||
|
public bool IsReply { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,16 +34,16 @@ namespace PizzeriaContracts.ViewModels
|
|||||||
[Column(title: "Количество", width: 100)]
|
[Column(title: "Количество", width: 100)]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
[Column(title: "Сумма", width: 120)]
|
[Column(title: "Сумма", width: 120, format: "c")]
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
|
|
||||||
[Column(title: "Статус", width: 70)]
|
[Column(title: "Статус", width: 70)]
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
|
|
||||||
[Column(title: "Дата создания", width: 120)]
|
[Column(title: "Дата создания", width: 120, format: "g")]
|
||||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
[Column(title: "Дата выполнения", width: 120)]
|
[Column(title: "Дата выполнения", width: 120, format: "g")]
|
||||||
public DateTime? DateImplement { get; set; }
|
public DateTime? DateImplement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
Pizzeria/PizzeriaContracts/ViewModels/PizzaCount.cs
Normal file
16
Pizzeria/PizzeriaContracts/ViewModels/PizzaCount.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using PizzeriaDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class PizzaCount
|
||||||
|
{
|
||||||
|
public PizzaViewModel Pizza { get; set; }
|
||||||
|
|
||||||
|
public int Count { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ namespace PizzeriaContracts.ViewModels
|
|||||||
[Column(title: "Название пиццы", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
[Column(title: "Название пиццы", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||||
public string PizzaName { get; set; } = string.Empty;
|
public string PizzaName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[Column(title: "Цена", width: 70)]
|
[Column(title: "Цена", width: 70, format: "c2")]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
[Column(visible: false)]
|
[Column(visible: false)]
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportGroupOrdersViewModel
|
||||||
|
{
|
||||||
|
public DateTime Date { get; set; } = DateTime.Now;
|
||||||
|
public int OrdersCount { get; set; }
|
||||||
|
public double OrdersSum { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportShopsViewModel
|
||||||
|
{
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
public int TotalCount { get; set; }
|
||||||
|
public List<(string Pizza, int count)> Pizzas { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
14
Pizzeria/PizzeriaContracts/ViewModels/ShopPizzaViewModel.cs
Normal file
14
Pizzeria/PizzeriaContracts/ViewModels/ShopPizzaViewModel.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ShopPizzaViewModel
|
||||||
|
{
|
||||||
|
public ShopViewModel Shop { get; set; } = new();
|
||||||
|
public Dictionary<int, PizzaCount> ShopPizza { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
28
Pizzeria/PizzeriaContracts/ViewModels/ShopViewModel.cs
Normal file
28
Pizzeria/PizzeriaContracts/ViewModels/ShopViewModel.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using PizzeriaContracts.Attributes;
|
||||||
|
using PizzeriaDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ShopViewModel : IShopModel
|
||||||
|
{
|
||||||
|
[Column(visible: false)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
[Column(title: "Магазин", width: 200)]
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
[Column(title: "Адрес", width: 100)]
|
||||||
|
public string Adress { get; set; } = string.Empty;
|
||||||
|
[Column(title: "Дата открытия", width: 100, format: "d")]
|
||||||
|
public DateTime OpeningDate { get; set; }
|
||||||
|
|
||||||
|
[Column(visible: false)]
|
||||||
|
public Dictionary<int, (IPizzaModel, int)> ShopPizzas { get; set; } = new();
|
||||||
|
[Column(title: "Вместимость", width: 100)]
|
||||||
|
public int PizzaMaxCount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ namespace PizzeriaDataModels.Enums
|
|||||||
Принят = 0,
|
Принят = 0,
|
||||||
Выполняется = 1,
|
Выполняется = 1,
|
||||||
Готов = 2,
|
Готов = 2,
|
||||||
Выдан = 3
|
Ожидает = 3,
|
||||||
|
Выдан = 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,5 +14,8 @@ namespace PizzeriaDataModels.Models
|
|||||||
DateTime DateDelivery { get; }
|
DateTime DateDelivery { get; }
|
||||||
string Subject { get; }
|
string Subject { get; }
|
||||||
string Body { get; }
|
string Body { get; }
|
||||||
|
bool IsReaded { get; }
|
||||||
|
string? ReplyMessageId { get; }
|
||||||
|
bool IsReply { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
Pizzeria/PizzeriaDataModels/Models/IShopModel.cs
Normal file
19
Pizzeria/PizzeriaDataModels/Models/IShopModel.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using PizzeriaDataModels;
|
||||||
|
using PizzeriaDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IShopModel : IId
|
||||||
|
{
|
||||||
|
string ShopName { get; }
|
||||||
|
string Adress { get; }
|
||||||
|
DateTime OpeningDate { get; }
|
||||||
|
Dictionary<int, (IPizzaModel, int)> ShopPizzas { get; }
|
||||||
|
public int PizzaMaxCount { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
15
Pizzeria/PizzeriaDataModels/Models/ISupplyModel.cs
Normal file
15
Pizzeria/PizzeriaDataModels/Models/ISupplyModel.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaDataModels.Models
|
||||||
|
{
|
||||||
|
public interface ISupplyModel
|
||||||
|
{
|
||||||
|
int ShopId { get; }
|
||||||
|
int PizzaId { get; }
|
||||||
|
int Count { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,6 +19,8 @@ namespace PizzeriaDatabaseImplement
|
|||||||
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
DependencyManager.Instance.RegisterType<IComponentStorage, ComponentStorage>();
|
||||||
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
DependencyManager.Instance.RegisterType<IImplementerStorage, ImplementerStorage>();
|
||||||
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
DependencyManager.Instance.RegisterType<IMessageInfoStorage, MessageInfoStorage>();
|
||||||
|
DependencyManager.Instance.RegisterType<IShopStorage, ShopStorage>();
|
||||||
|
|
||||||
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
|
||||||
DependencyManager.Instance.RegisterType<IPizzaStorage, PizzaStorage>();
|
DependencyManager.Instance.RegisterType<IPizzaStorage, PizzaStorage>();
|
||||||
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
|
||||||
|
|||||||
@@ -20,13 +20,23 @@ namespace PizzeriaDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.ClientId.HasValue)
|
if (!model.ClientId.HasValue && !model.PageLength.HasValue && !model.PageIndex.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return new();
|
||||||
}
|
}
|
||||||
using var context = new PizzeriaDatabase();
|
using var context = new PizzeriaDatabase();
|
||||||
return context.MessageInfos.Where(x => x.ClientId.HasValue && x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
|
IEnumerable<MessageInfo> request = context.MessageInfos.Where(x => !x.IsReply);
|
||||||
|
if (model.ClientId.HasValue)
|
||||||
|
request = request.Where(x => x.ClientId.HasValue && x.ClientId == model.ClientId);
|
||||||
|
if (model.PageLength.HasValue)
|
||||||
|
{
|
||||||
|
int skipRows = model.PageIndex.HasValue ? (model.PageIndex.Value - 1) * model.PageLength.Value : 0;
|
||||||
|
request = request.Skip(skipRows).Take(model.PageLength.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return request.Select(x => x.GetViewModel).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(model.MessageId))
|
if (string.IsNullOrEmpty(model.MessageId))
|
||||||
@@ -38,15 +48,34 @@ namespace PizzeriaDatabaseImplement.Implements
|
|||||||
}
|
}
|
||||||
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
|
||||||
{
|
{
|
||||||
|
|
||||||
var newMessage = MessageInfo.Create(model);
|
var newMessage = MessageInfo.Create(model);
|
||||||
if (newMessage == null)
|
if (newMessage == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
using var context = new PizzeriaDatabase();
|
using var context = new PizzeriaDatabase();
|
||||||
context.MessageInfos.Add(newMessage);
|
try {
|
||||||
|
context.MessageInfos.Add(newMessage);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newMessage.GetViewModel;
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new PizzeriaDatabase();
|
||||||
|
var message = context.MessageInfos.FirstOrDefault(x => x.MessageId == model.MessageId);
|
||||||
|
if (message == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
message.Update(context, model);
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return newMessage.GetViewModel;
|
return message.GetViewModel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
191
Pizzeria/PizzeriaDatabaseImplement/Implements/ShopStorage.cs
Normal file
191
Pizzeria/PizzeriaDatabaseImplement/Implements/ShopStorage.cs
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.SearchModels;
|
||||||
|
using PizzeriaContracts.StoragesContracts;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using PizzeriaDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ShopStorage : IShopStorage
|
||||||
|
{
|
||||||
|
public List<ShopViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new PizzeriaDatabase();
|
||||||
|
return context.Shops.Include(x => x.Pizzas).ThenInclude(x => x.Pizza).ToList().
|
||||||
|
Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new PizzeriaDatabase();
|
||||||
|
return context.Shops.Include(x => x.Pizzas).ThenInclude(x => x.Pizza).Where(x => x.ShopName.Contains(model.ShopName)).
|
||||||
|
ToList().Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new PizzeriaDatabase();
|
||||||
|
return context.Shops.Include(x => x.Pizzas).ThenInclude(x => x.Pizza)
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
(!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) ||
|
||||||
|
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Insert(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new PizzeriaDatabase();
|
||||||
|
var newShop = Shop.Create(context, model);
|
||||||
|
if (newShop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Shops.Add(newShop);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newShop.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new PizzeriaDatabase();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var shop = context.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
shop.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
shop.UpdatePizzas(context, model);
|
||||||
|
transaction.Commit();
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new PizzeriaDatabase();
|
||||||
|
var shop = context.Shops.Include(x => x.Pizzas).FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (shop != null)
|
||||||
|
{
|
||||||
|
context.Shops.Remove(shop);
|
||||||
|
context.SaveChanges();
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RestockingShops(SupplyBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new PizzeriaDatabase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
var Shops = context.Shops.Include(x => x.Pizzas).ThenInclude(x => x.Pizza).ToList().
|
||||||
|
Where(x => x.PizzaMaxCount > x.ShopPizzas.Select(x => x.Value.Item2).Sum()).ToList();
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (Shop shop in Shops)
|
||||||
|
{
|
||||||
|
int difference = shop.PizzaMaxCount - shop.ShopPizzas.Select(x => x.Value.Item2).Sum();
|
||||||
|
int refill = Math.Min(difference, model.Count);
|
||||||
|
model.Count -= refill;
|
||||||
|
if (shop.ShopPizzas.ContainsKey(model.PizzaId))
|
||||||
|
{
|
||||||
|
var datePair = shop.ShopPizzas[model.PizzaId];
|
||||||
|
datePair.Item2 += refill;
|
||||||
|
shop.ShopPizzas[model.PizzaId] = datePair;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var pizza = context.Pizzas.First(x => x.Id == model.PizzaId);
|
||||||
|
shop.ShopPizzas.Add(model.PizzaId, (pizza, refill));
|
||||||
|
}
|
||||||
|
shop.PizzasDictionatyUpdate(context);
|
||||||
|
if (model.Count == 0)
|
||||||
|
{
|
||||||
|
transaction.Commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
transaction.Rollback();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Sale(SupplySearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new PizzeriaDatabase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var shops = context.Shops.Include(x => x.Pizzas).ThenInclude(x => x.Pizza).ToList().
|
||||||
|
Where(x => x.ShopPizzas.ContainsKey(model.PizzaId.Value)).OrderByDescending(x => x.ShopPizzas[model.PizzaId.Value].Item2).ToList();
|
||||||
|
|
||||||
|
foreach (var shop in shops)
|
||||||
|
{
|
||||||
|
int residue = model.Count.Value - shop.ShopPizzas[model.PizzaId.Value].Item2;
|
||||||
|
if (residue > 0)
|
||||||
|
{
|
||||||
|
shop.ShopPizzas.Remove(model.PizzaId.Value);
|
||||||
|
shop.PizzasDictionatyUpdate(context);
|
||||||
|
context.SaveChanges();
|
||||||
|
model.Count = residue;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (residue == 0)
|
||||||
|
shop.ShopPizzas.Remove(model.PizzaId.Value);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var dataPair = shop.ShopPizzas[model.PizzaId.Value];
|
||||||
|
dataPair.Item2 = -residue;
|
||||||
|
shop.ShopPizzas[model.PizzaId.Value] = dataPair;
|
||||||
|
}
|
||||||
|
|
||||||
|
shop.PizzasDictionatyUpdate(context);
|
||||||
|
transaction.Commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
transaction.Rollback();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ using PizzeriaDatabaseImplement;
|
|||||||
namespace PizzeriaDatabaseImplement.Migrations
|
namespace PizzeriaDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(PizzeriaDatabase))]
|
[DbContext(typeof(PizzeriaDatabase))]
|
||||||
[Migration("20230503155413_init")]
|
[Migration("20230517084350_init")]
|
||||||
partial class init
|
partial class init
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -112,6 +112,15 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.Property<DateTime>("DateDelivery")
|
b.Property<DateTime>("DateDelivery")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<bool>("IsReaded")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsReply")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("ReplyMessageId")
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
b.Property<string>("SenderName")
|
b.Property<string>("SenderName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
@@ -124,6 +133,8 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("ReplyMessageId");
|
||||||
|
|
||||||
b.ToTable("MessageInfos");
|
b.ToTable("MessageInfos");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -216,13 +227,72 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.ToTable("PizzaComponents");
|
b.ToTable("PizzaComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Adress")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("OpeningDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("PizzaMaxCount")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("ShopName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Shops");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.ShopPizzas", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PizzaId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ShopId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PizzaId");
|
||||||
|
|
||||||
|
b.HasIndex("ShopId");
|
||||||
|
|
||||||
|
b.ToTable("ShopPizzas");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.MessageInfo", b =>
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.MessageInfo", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("PizzeriaDatabaseImplement.Models.Client", "Client")
|
b.HasOne("PizzeriaDatabaseImplement.Models.Client", "Client")
|
||||||
.WithMany("ClientMessages")
|
.WithMany("ClientMessages")
|
||||||
.HasForeignKey("ClientId");
|
.HasForeignKey("ClientId");
|
||||||
|
|
||||||
|
b.HasOne("PizzeriaDatabaseImplement.Models.MessageInfo", "Reply")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ReplyMessageId");
|
||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Reply");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b =>
|
||||||
@@ -269,6 +339,25 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.Navigation("Pizza");
|
b.Navigation("Pizza");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.ShopPizzas", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("PizzaId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("PizzeriaDatabaseImplement.Models.Shop", "Shop")
|
||||||
|
.WithMany("Pizzas")
|
||||||
|
.HasForeignKey("ShopId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Pizza");
|
||||||
|
|
||||||
|
b.Navigation("Shop");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Client", b =>
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Client", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ClientMessages");
|
b.Navigation("ClientMessages");
|
||||||
@@ -292,6 +381,11 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.Navigation("Orders");
|
b.Navigation("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Pizzas");
|
||||||
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,6 +70,22 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
table.PrimaryKey("PK_Pizzas", x => x.Id);
|
table.PrimaryKey("PK_Pizzas", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Shops",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Adress = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
OpeningDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
|
PizzaMaxCount = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "MessageInfos",
|
name: "MessageInfos",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@@ -79,7 +95,10 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
SenderName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
DateDelivery = table.Column<DateTime>(type: "datetime2", nullable: false),
|
DateDelivery = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
Subject = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
Body = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
Body = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
IsReaded = table.Column<bool>(type: "bit", nullable: false),
|
||||||
|
ReplyMessageId = table.Column<string>(type: "nvarchar(450)", nullable: true),
|
||||||
|
IsReply = table.Column<bool>(type: "bit", nullable: false)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
@@ -89,6 +108,11 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
column: x => x.ClientId,
|
column: x => x.ClientId,
|
||||||
principalTable: "Clients",
|
principalTable: "Clients",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id");
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_MessageInfos_MessageInfos_ReplyMessageId",
|
||||||
|
column: x => x.ReplyMessageId,
|
||||||
|
principalTable: "MessageInfos",
|
||||||
|
principalColumn: "MessageId");
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
@@ -155,11 +179,43 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ShopPizzas",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
PizzaId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ShopId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Count = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ShopPizzas", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ShopPizzas_Pizzas_PizzaId",
|
||||||
|
column: x => x.PizzaId,
|
||||||
|
principalTable: "Pizzas",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ShopPizzas_Shops_ShopId",
|
||||||
|
column: x => x.ShopId,
|
||||||
|
principalTable: "Shops",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_MessageInfos_ClientId",
|
name: "IX_MessageInfos_ClientId",
|
||||||
table: "MessageInfos",
|
table: "MessageInfos",
|
||||||
column: "ClientId");
|
column: "ClientId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_MessageInfos_ReplyMessageId",
|
||||||
|
table: "MessageInfos",
|
||||||
|
column: "ReplyMessageId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Orders_ClientId",
|
name: "IX_Orders_ClientId",
|
||||||
table: "Orders",
|
table: "Orders",
|
||||||
@@ -184,6 +240,16 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
name: "IX_PizzaComponents_PizzaId",
|
name: "IX_PizzaComponents_PizzaId",
|
||||||
table: "PizzaComponents",
|
table: "PizzaComponents",
|
||||||
column: "PizzaId");
|
column: "PizzaId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ShopPizzas_PizzaId",
|
||||||
|
table: "ShopPizzas",
|
||||||
|
column: "PizzaId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ShopPizzas_ShopId",
|
||||||
|
table: "ShopPizzas",
|
||||||
|
column: "ShopId");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@@ -198,6 +264,9 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "PizzaComponents");
|
name: "PizzaComponents");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ShopPizzas");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Clients");
|
name: "Clients");
|
||||||
|
|
||||||
@@ -209,6 +278,9 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Pizzas");
|
name: "Pizzas");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Shops");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -109,6 +109,15 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.Property<DateTime>("DateDelivery")
|
b.Property<DateTime>("DateDelivery")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<bool>("IsReaded")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsReply")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("ReplyMessageId")
|
||||||
|
.HasColumnType("nvarchar(450)");
|
||||||
|
|
||||||
b.Property<string>("SenderName")
|
b.Property<string>("SenderName")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("nvarchar(max)");
|
.HasColumnType("nvarchar(max)");
|
||||||
@@ -121,6 +130,8 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("ReplyMessageId");
|
||||||
|
|
||||||
b.ToTable("MessageInfos");
|
b.ToTable("MessageInfos");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -213,13 +224,72 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.ToTable("PizzaComponents");
|
b.ToTable("PizzaComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Adress")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("OpeningDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("PizzaMaxCount")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("ShopName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Shops");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.ShopPizzas", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("PizzaId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ShopId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("PizzaId");
|
||||||
|
|
||||||
|
b.HasIndex("ShopId");
|
||||||
|
|
||||||
|
b.ToTable("ShopPizzas");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.MessageInfo", b =>
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.MessageInfo", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("PizzeriaDatabaseImplement.Models.Client", "Client")
|
b.HasOne("PizzeriaDatabaseImplement.Models.Client", "Client")
|
||||||
.WithMany("ClientMessages")
|
.WithMany("ClientMessages")
|
||||||
.HasForeignKey("ClientId");
|
.HasForeignKey("ClientId");
|
||||||
|
|
||||||
|
b.HasOne("PizzeriaDatabaseImplement.Models.MessageInfo", "Reply")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ReplyMessageId");
|
||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Reply");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b =>
|
||||||
@@ -266,6 +336,25 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.Navigation("Pizza");
|
b.Navigation("Pizza");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.ShopPizzas", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("PizzaId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("PizzeriaDatabaseImplement.Models.Shop", "Shop")
|
||||||
|
.WithMany("Pizzas")
|
||||||
|
.HasForeignKey("ShopId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Pizza");
|
||||||
|
|
||||||
|
b.Navigation("Shop");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Client", b =>
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Client", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("ClientMessages");
|
b.Navigation("ClientMessages");
|
||||||
@@ -289,6 +378,11 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.Navigation("Orders");
|
b.Navigation("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Pizzas");
|
||||||
|
});
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,17 @@ namespace PizzeriaDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public string Body { get; set; } = string.Empty;
|
public string Body { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public bool IsReaded { get; set; }
|
||||||
|
|
||||||
|
public string? ReplyMessageId { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey("ReplyMessageId")]
|
||||||
|
public virtual MessageInfo? Reply { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public bool IsReply { get; set; }
|
||||||
|
|
||||||
public static MessageInfo? Create(MessageInfoBindingModel? model)
|
public static MessageInfo? Create(MessageInfoBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@@ -57,10 +68,26 @@ namespace PizzeriaDatabaseImplement.Models
|
|||||||
DateDelivery = model.DateDelivery,
|
DateDelivery = model.DateDelivery,
|
||||||
Subject = model.Subject,
|
Subject = model.Subject,
|
||||||
Body = model.Body,
|
Body = model.Body,
|
||||||
|
IsReaded = model.IsReaded,
|
||||||
|
ReplyMessageId = model.ReplyMessageId,
|
||||||
|
IsReply = model.IsReply
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Update(PizzeriaDatabase context, MessageInfoBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
IsReaded = model.IsReaded;
|
||||||
|
ReplyMessageId = model.ReplyMessageId;
|
||||||
|
if (!string.IsNullOrEmpty(ReplyMessageId))
|
||||||
|
{
|
||||||
|
Reply = context.MessageInfos.First(x => x.MessageId == ReplyMessageId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public MessageInfoViewModel GetViewModel => new()
|
public MessageInfoViewModel GetViewModel => new()
|
||||||
{
|
{
|
||||||
MessageId = MessageId,
|
MessageId = MessageId,
|
||||||
@@ -68,7 +95,11 @@ namespace PizzeriaDatabaseImplement.Models
|
|||||||
SenderName = SenderName,
|
SenderName = SenderName,
|
||||||
DateDelivery = DateDelivery,
|
DateDelivery = DateDelivery,
|
||||||
Subject = Subject,
|
Subject = Subject,
|
||||||
Body = Body
|
Body = Body,
|
||||||
|
IsReaded = IsReaded,
|
||||||
|
ReplyMessageId = ReplyMessageId,
|
||||||
|
Reply = Reply,
|
||||||
|
IsReply = IsReply
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
133
Pizzeria/PizzeriaDatabaseImplement/Models/Shop.cs
Normal file
133
Pizzeria/PizzeriaDatabaseImplement/Models/Shop.cs
Normal file
@@ -0,0 +1,133 @@
|
|||||||
|
using PizzeriaContracts.BindingModels;
|
||||||
|
using PizzeriaContracts.ViewModels;
|
||||||
|
using PizzeriaDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
[DataContract]
|
||||||
|
public class Shop : IShopModel
|
||||||
|
{
|
||||||
|
[DataMember]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
|
public string ShopName { get; set; } = String.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
|
public string Adress { get; set; } = String.Empty;
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
|
public DateTime OpeningDate { get; set; }
|
||||||
|
|
||||||
|
[DataMember]
|
||||||
|
[Required]
|
||||||
|
public int PizzaMaxCount { get; set; }
|
||||||
|
|
||||||
|
private Dictionary<int, (IPizzaModel, int)>? _shopPizzas = null;
|
||||||
|
public Dictionary<int, (IPizzaModel, int)> ShopPizzas
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_shopPizzas == null) {
|
||||||
|
if (_shopPizzas == null)
|
||||||
|
{
|
||||||
|
_shopPizzas = Pizzas
|
||||||
|
.ToDictionary(recSP => recSP.PizzaId, recSP => (recSP.Pizza as IPizzaModel, recSP.Count));
|
||||||
|
}
|
||||||
|
return _shopPizzas;
|
||||||
|
}
|
||||||
|
return _shopPizzas;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ForeignKey("ShopId")]
|
||||||
|
public List<ShopPizzas> Pizzas { get; set; } = new();
|
||||||
|
|
||||||
|
public static Shop Create(PizzeriaDatabase context, ShopBindingModel model)
|
||||||
|
{
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShopName = model.ShopName,
|
||||||
|
Adress = model.Adress,
|
||||||
|
OpeningDate = model.OpeningDate,
|
||||||
|
Pizzas = model.ShopPizzas.Select(x => new ShopPizzas
|
||||||
|
{
|
||||||
|
Pizza = context.Pizzas.First(y => y.Id == x.Key),
|
||||||
|
Count = x.Value.Item2
|
||||||
|
}).ToList(),
|
||||||
|
PizzaMaxCount = model.PizzaMaxCount
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
ShopName = model.ShopName;
|
||||||
|
Adress = model.Adress;
|
||||||
|
OpeningDate = model.OpeningDate;
|
||||||
|
PizzaMaxCount = model.PizzaMaxCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopName = ShopName,
|
||||||
|
Adress = Adress,
|
||||||
|
OpeningDate = OpeningDate,
|
||||||
|
ShopPizzas = ShopPizzas,
|
||||||
|
PizzaMaxCount = PizzaMaxCount
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void UpdatePizzas(PizzeriaDatabase context, ShopBindingModel model)
|
||||||
|
{
|
||||||
|
var ShopPizzas = context.ShopPizzas.Where(rec => rec.ShopId == model.Id).ToList();
|
||||||
|
if (ShopPizzas != null && ShopPizzas.Count > 0)
|
||||||
|
{
|
||||||
|
context.ShopPizzas.RemoveRange(ShopPizzas.Where(rec => !model.ShopPizzas.ContainsKey(rec.PizzaId)));
|
||||||
|
context.SaveChanges();
|
||||||
|
ShopPizzas = context.ShopPizzas.Where(rec => rec.ShopId == model.Id).ToList();
|
||||||
|
foreach (var updatePizza in ShopPizzas)
|
||||||
|
{
|
||||||
|
updatePizza.Count = model.ShopPizzas[updatePizza.PizzaId].Item2;
|
||||||
|
model.ShopPizzas.Remove(updatePizza.PizzaId);
|
||||||
|
}
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
var shop = context.Shops.First(x => x.Id == Id);
|
||||||
|
foreach (var ar in model.ShopPizzas)
|
||||||
|
{
|
||||||
|
context.ShopPizzas.Add(new ShopPizzas
|
||||||
|
{
|
||||||
|
Shop = shop,
|
||||||
|
Pizza = context.Pizzas.First(x => x.Id == ar.Key),
|
||||||
|
Count = ar.Value.Item2
|
||||||
|
});
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
_shopPizzas = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PizzasDictionatyUpdate(PizzeriaDatabase context)
|
||||||
|
{
|
||||||
|
UpdatePizzas(context, new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopPizzas = ShopPizzas,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
27
Pizzeria/PizzeriaDatabaseImplement/Models/ShopPizzas.cs
Normal file
27
Pizzeria/PizzeriaDatabaseImplement/Models/ShopPizzas.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PizzeriaDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class ShopPizzas
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int PizzaId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int ShopId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
public virtual Shop Shop { get; set; } = new();
|
||||||
|
|
||||||
|
public virtual Pizza Pizza { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@ namespace PizzeriaDatabaseImplement
|
|||||||
{
|
{
|
||||||
if (!optionsBuilder.IsConfigured)
|
if (!optionsBuilder.IsConfigured)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=SHADOWIK\SHADOWIK;Initial Catalog=PizzeriaDatabase;Integrated Security=True;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer(@"Data Source=SHADOWIK\SHADOWIK;Initial Catalog=PizzeriaHardDatabase;Integrated Security=True;TrustServerCertificate=True");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,8 @@ namespace PizzeriaDatabaseImplement
|
|||||||
public virtual DbSet<Order> Orders { set; get; }
|
public virtual DbSet<Order> Orders { set; get; }
|
||||||
public virtual DbSet<Client> Clients { set; get; }
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
public virtual DbSet<Implementer> Implementers { set; get; }
|
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||||
|
public virtual DbSet<Shop> Shops { set; get; }
|
||||||
|
public virtual DbSet<ShopPizzas> ShopPizzas { set; get; }
|
||||||
public virtual DbSet<MessageInfo> MessageInfos { set; get; }
|
public virtual DbSet<MessageInfo> MessageInfos { set; get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user