Compare commits
29 Commits
SeventhLab
...
EightLabWo
| Author | SHA1 | Date | |
|---|---|---|---|
| 9da5d369c9 | |||
| 019e3cf3bc | |||
| 4379527e7b | |||
| 46ac3df1d5 | |||
| 23c53498ee | |||
| 2eafb37689 | |||
| 9f5a54c146 | |||
| 408bd55e02 | |||
| 6827bb438e | |||
| 58e4ebdda8 | |||
| 9323e7706a | |||
| 10e72cbe76 | |||
| d857dcfd5f | |||
| 5b2a67f07c | |||
| e101e0d5dc | |||
| 7685f120a1 | |||
| cdc24707a4 | |||
| 1ba74d2506 | |||
| a0dd21b9dd | |||
| 89ec8b112b | |||
| ee00622ffc | |||
| 3ae2fdb8de | |||
| 7b7830da50 | |||
| d53a3c7c03 | |||
| 25c3cebc4d | |||
| 551cc53791 | |||
|
|
fdcdf48b7a | ||
|
|
de92e35964 | ||
|
|
280ec9184d |
@@ -12,6 +12,7 @@ namespace AbstractFurnitureAssemblyDataModels.Enums
|
||||
Принят = 0,
|
||||
Выполняется = 1,
|
||||
Готов = 2,
|
||||
Выдан = 3
|
||||
Выдан = 3,
|
||||
Ожидание = 4
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
using AbstractFurnitureAssemblyDataModels;
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
namespace AbstractFurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IImplementerModel : IId
|
||||
{
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDataModels.Models
|
||||
namespace AbstractFurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IMessageInfoModel
|
||||
{
|
||||
@@ -14,5 +15,7 @@ namespace FurnitureAssemblyDataModels.Models
|
||||
DateTime DateDelivery { get; }
|
||||
string Subject { get; }
|
||||
string Body { get; }
|
||||
bool IsRead { get; }
|
||||
string? Reply { get; }
|
||||
}
|
||||
}
|
||||
|
||||
17
AbstractFurnitureAssemblyDataModels/Models/IShopModel.cs
Normal file
17
AbstractFurnitureAssemblyDataModels/Models/IShopModel.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AbstractFurnitureAssemblyDataModels.Models
|
||||
{
|
||||
public interface IShopModel : IId
|
||||
{
|
||||
string ShopName { get; }
|
||||
string Address { get; }
|
||||
DateTime DateOpening { get; }
|
||||
int MaxCount { get; }
|
||||
Dictionary<int, (IFurnitureModel, int)> Furnitures { get; }
|
||||
}
|
||||
}
|
||||
@@ -32,18 +32,7 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Email"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Password"].Visible = false;
|
||||
}
|
||||
_logger.LogInformation("Загрузка клиентов");
|
||||
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -33,14 +33,7 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ComponentName"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
55
FurnitureAssembly/DataGridViewExtension.cs
Normal file
55
FurnitureAssembly/DataGridViewExtension.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using FurnitureAssemblyContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
public static class DataGridViewExtension
|
||||
{
|
||||
public static void FillandConfigGrid<T>(this DataGridView grid, List<T>? data)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
grid.DataSource = data;
|
||||
var type = typeof(T);
|
||||
var properties = type.GetProperties();
|
||||
foreach (DataGridViewColumn column in grid.Columns)
|
||||
{
|
||||
var property = properties.FirstOrDefault(x => x.Name == column.Name);
|
||||
if (property == null)
|
||||
{
|
||||
throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем { column.Name }");
|
||||
}
|
||||
var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault();
|
||||
if (attribute == null)
|
||||
{
|
||||
throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства { property.Name }");
|
||||
}
|
||||
// ищем нужный нам атрибут
|
||||
if (attribute is ColumnAttribute columnAttr)
|
||||
{
|
||||
column.HeaderText = columnAttr.Title;
|
||||
column.Visible = columnAttr.Visible;
|
||||
if (columnAttr.IsUseAutoSize)
|
||||
{
|
||||
column.AutoSizeMode =
|
||||
(DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
column.Width = columnAttr.Width;
|
||||
}
|
||||
if (columnAttr.IsFormatable)
|
||||
{
|
||||
column.DefaultCellStyle.Format = columnAttr.Formatter;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
142
FurnitureAssembly/FormAddToShop.Designer.cs
generated
Normal file
142
FurnitureAssembly/FormAddToShop.Designer.cs
generated
Normal file
@@ -0,0 +1,142 @@
|
||||
namespace FurnitureAssembly
|
||||
{
|
||||
partial class FormAddToShop
|
||||
{
|
||||
/// <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.comboBoxFurniture = new System.Windows.Forms.ComboBox();
|
||||
this.labelFurniture = new System.Windows.Forms.Label();
|
||||
this.labelNum = new System.Windows.Forms.Label();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// comboBoxShop
|
||||
//
|
||||
this.comboBoxShop.FormattingEnabled = true;
|
||||
this.comboBoxShop.Location = new System.Drawing.Point(133, 18);
|
||||
this.comboBoxShop.Name = "comboBoxShop";
|
||||
this.comboBoxShop.Size = new System.Drawing.Size(296, 23);
|
||||
this.comboBoxShop.TabIndex = 0;
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
this.labelShop.AutoSize = true;
|
||||
this.labelShop.Location = new System.Drawing.Point(46, 21);
|
||||
this.labelShop.Name = "labelShop";
|
||||
this.labelShop.Size = new System.Drawing.Size(54, 15);
|
||||
this.labelShop.TabIndex = 1;
|
||||
this.labelShop.Text = "Магазин";
|
||||
//
|
||||
// comboBoxFurniture
|
||||
//
|
||||
this.comboBoxFurniture.FormattingEnabled = true;
|
||||
this.comboBoxFurniture.Location = new System.Drawing.Point(133, 62);
|
||||
this.comboBoxFurniture.Name = "comboBoxFurniture";
|
||||
this.comboBoxFurniture.Size = new System.Drawing.Size(296, 23);
|
||||
this.comboBoxFurniture.TabIndex = 2;
|
||||
//
|
||||
// labelFurniture
|
||||
//
|
||||
this.labelFurniture.AutoSize = true;
|
||||
this.labelFurniture.Location = new System.Drawing.Point(46, 65);
|
||||
this.labelFurniture.Name = "labelFurniture";
|
||||
this.labelFurniture.Size = new System.Drawing.Size(53, 15);
|
||||
this.labelFurniture.TabIndex = 4;
|
||||
this.labelFurniture.Text = "Изделие";
|
||||
//
|
||||
// labelNum
|
||||
//
|
||||
this.labelNum.AutoSize = true;
|
||||
this.labelNum.Location = new System.Drawing.Point(46, 106);
|
||||
this.labelNum.Name = "labelNum";
|
||||
this.labelNum.Size = new System.Drawing.Size(72, 15);
|
||||
this.labelNum.TabIndex = 5;
|
||||
this.labelNum.Text = "Количество";
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(194, 161);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(99, 29);
|
||||
this.buttonAdd.TabIndex = 6;
|
||||
this.buttonAdd.Text = "Пополнить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(330, 161);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(99, 29);
|
||||
this.buttonCancel.TabIndex = 7;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(133, 103);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(160, 23);
|
||||
this.textBoxCount.TabIndex = 8;
|
||||
//
|
||||
// FormReplenishmentShop
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(479, 214);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.labelNum);
|
||||
this.Controls.Add(this.labelFurniture);
|
||||
this.Controls.Add(this.comboBoxFurniture);
|
||||
this.Controls.Add(this.labelShop);
|
||||
this.Controls.Add(this.comboBoxShop);
|
||||
this.Name = "FormReplenishmentShop";
|
||||
this.Text = "Пополнение магазина";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBoxShop;
|
||||
private Label labelShop;
|
||||
private ComboBox comboBoxFurniture;
|
||||
private Label labelFurniture;
|
||||
private Label labelNum;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
private TextBox textBoxCount;
|
||||
}
|
||||
}
|
||||
129
FurnitureAssembly/FormAddToShop.cs
Normal file
129
FurnitureAssembly/FormAddToShop.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
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 Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FurnitureAssembly
|
||||
{
|
||||
public partial class FormAddToShop : Form
|
||||
{
|
||||
|
||||
private readonly List<ShopViewModel>? _listShops;
|
||||
private readonly List<FurnitureViewModel>? _listFurnitures;
|
||||
private IShopLogic _shopLogic;
|
||||
private ILogger _logger;
|
||||
|
||||
|
||||
public int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(comboBoxShop.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBoxShop.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int FurnitureId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(comboBoxFurniture.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBoxFurniture.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||
set
|
||||
{ textBoxCount.Text = value.ToString(); }
|
||||
}
|
||||
public FormAddToShop(IShopLogic shopLogic, IfurnitureLogic furnitureLogic, ILogger<FormShop> logger)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_shopLogic = shopLogic;
|
||||
_listShops = shopLogic.ReadList(null);
|
||||
_listFurnitures = furnitureLogic.ReadList(null);
|
||||
if (_listShops != null)
|
||||
{
|
||||
comboBoxShop.DisplayMember = "ShopName";
|
||||
comboBoxShop.ValueMember = "Id";
|
||||
comboBoxShop.DataSource = _listShops;
|
||||
comboBoxShop.SelectedItem = null;
|
||||
}
|
||||
if (_listFurnitures != null)
|
||||
{
|
||||
comboBoxFurniture.DisplayMember = "FurnitureName";
|
||||
comboBoxFurniture.ValueMember = "Id";
|
||||
comboBoxFurniture.DataSource = _listFurnitures;
|
||||
comboBoxFurniture.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxShop.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxFurniture.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Укажите количество поступившего изделия", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Добавление в магазин с id = {ShopName} изделия: id = { FurnitureName} - { Count}", Id, FurnitureId, Count);
|
||||
var operationResult = _shopLogic.AddFurniture(new ShopBindingModel { Id = Id }, new FurnitureBindingModel { Id = FurnitureId }, Count);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при пополнении магазина. Дополнительная информация в логах.");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при пополнении магазина c id = " + Id);
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
60
FurnitureAssembly/FormAddToShop.resx
Normal file
60
FurnitureAssembly/FormAddToShop.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>
|
||||
119
FurnitureAssembly/FormSell.Designer.cs
generated
Normal file
119
FurnitureAssembly/FormSell.Designer.cs
generated
Normal file
@@ -0,0 +1,119 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class FormSell
|
||||
{
|
||||
/// <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.labelFurniture = new System.Windows.Forms.Label();
|
||||
this.comboBoxToSell = 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();
|
||||
//
|
||||
// labelFurniture
|
||||
//
|
||||
this.labelFurniture.AutoSize = true;
|
||||
this.labelFurniture.Location = new System.Drawing.Point(38, 53);
|
||||
this.labelFurniture.Name = "labelFurniture";
|
||||
this.labelFurniture.Size = new System.Drawing.Size(80, 25);
|
||||
this.labelFurniture.TabIndex = 0;
|
||||
this.labelFurniture.Text = "Изделие";
|
||||
//
|
||||
// comboBoxToSell
|
||||
//
|
||||
this.comboBoxToSell.FormattingEnabled = true;
|
||||
this.comboBoxToSell.Location = new System.Drawing.Point(174, 50);
|
||||
this.comboBoxToSell.Name = "comboBoxToSell";
|
||||
this.comboBoxToSell.Size = new System.Drawing.Size(182, 33);
|
||||
this.comboBoxToSell.TabIndex = 1;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(43, 133);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(107, 25);
|
||||
this.labelCount.TabIndex = 2;
|
||||
this.labelCount.Text = "Количество";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(178, 131);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(150, 31);
|
||||
this.textBoxCount.TabIndex = 3;
|
||||
//
|
||||
// buttonSell
|
||||
//
|
||||
this.buttonSell.Location = new System.Drawing.Point(38, 225);
|
||||
this.buttonSell.Name = "buttonSell";
|
||||
this.buttonSell.Size = new System.Drawing.Size(112, 34);
|
||||
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(216, 225);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(112, 34);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// FormSell
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(463, 313);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSell);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.comboBoxToSell);
|
||||
this.Controls.Add(this.labelFurniture);
|
||||
this.Name = "FormSell";
|
||||
this.Text = "Продажа мебели";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelFurniture;
|
||||
private ComboBox comboBoxToSell;
|
||||
private Label labelCount;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonSell;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
||||
113
FurnitureAssembly/FormSell.cs
Normal file
113
FurnitureAssembly/FormSell.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class FormSell : Form
|
||||
{
|
||||
private readonly IShopLogic _shopLogic;
|
||||
private readonly List<FurnitureViewModel>? _listFurnitures;
|
||||
|
||||
public int Id
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(comboBoxToSell.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBoxToSell.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IFurnitureModel? FurnitureModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_listFurnitures == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var elem in _listFurnitures)
|
||||
{
|
||||
if (elem.Id == Id)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(textBoxCount.Text);
|
||||
}
|
||||
set
|
||||
{
|
||||
textBoxCount.Text = value.ToString();
|
||||
}
|
||||
}
|
||||
public FormSell(IShopLogic shopLogic, IfurnitureLogic furnitureLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_shopLogic = shopLogic;
|
||||
|
||||
_listFurnitures = furnitureLogic.ReadList(null);
|
||||
if (_listFurnitures != null)
|
||||
{
|
||||
comboBoxToSell.DisplayMember = "FurnitureName";
|
||||
comboBoxToSell.ValueMember = "Id";
|
||||
comboBoxToSell.DataSource = _listFurnitures;
|
||||
comboBoxToSell.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSell_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (FurnitureModel == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Count <= 0)
|
||||
{
|
||||
MessageBox.Show("Укажите количество изделия", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_shopLogic.Sell(new() { Id = FurnitureModel.Id }, Count))
|
||||
{
|
||||
MessageBox.Show("Не удалось продать изделие " + FurnitureModel.FurnitureName, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
MessageBox.Show("Продажа прошла успешно", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
60
FurnitureAssembly/FormSell.resx
Normal file
60
FurnitureAssembly/FormSell.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>
|
||||
220
FurnitureAssembly/FormShop.Designer.cs
generated
Normal file
220
FurnitureAssembly/FormShop.Designer.cs
generated
Normal file
@@ -0,0 +1,220 @@
|
||||
namespace FurnitureAssembly
|
||||
{
|
||||
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.labelShopName = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
||||
this.labelAddress = new System.Windows.Forms.Label();
|
||||
this.labelDate = new System.Windows.Forms.Label();
|
||||
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||
this.ButtonSave = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.dataGridView1 = new System.Windows.Forms.DataGridView();
|
||||
this.FurnitureId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.FurnitureName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.labelMaxCount = new System.Windows.Forms.Label();
|
||||
this.textBoxMaxCount = new System.Windows.Forms.TextBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelShopName
|
||||
//
|
||||
this.labelShopName.AutoSize = true;
|
||||
this.labelShopName.Location = new System.Drawing.Point(53, 75);
|
||||
this.labelShopName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelShopName.Name = "labelShopName";
|
||||
this.labelShopName.Size = new System.Drawing.Size(170, 25);
|
||||
this.labelShopName.TabIndex = 0;
|
||||
this.labelShopName.Text = "Название магазина";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(240, 70);
|
||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(401, 31);
|
||||
this.textBoxName.TabIndex = 1;
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
this.textBoxAddress.Location = new System.Drawing.Point(240, 138);
|
||||
this.textBoxAddress.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.textBoxAddress.Name = "textBoxAddress";
|
||||
this.textBoxAddress.Size = new System.Drawing.Size(401, 31);
|
||||
this.textBoxAddress.TabIndex = 3;
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
this.labelAddress.AutoSize = true;
|
||||
this.labelAddress.Location = new System.Drawing.Point(53, 143);
|
||||
this.labelAddress.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelAddress.Name = "labelAddress";
|
||||
this.labelAddress.Size = new System.Drawing.Size(62, 25);
|
||||
this.labelAddress.TabIndex = 2;
|
||||
this.labelAddress.Text = "Адрес";
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
this.labelDate.AutoSize = true;
|
||||
this.labelDate.Location = new System.Drawing.Point(53, 213);
|
||||
this.labelDate.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelDate.Name = "labelDate";
|
||||
this.labelDate.Size = new System.Drawing.Size(131, 25);
|
||||
this.labelDate.TabIndex = 4;
|
||||
this.labelDate.Text = "Дата открытия";
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
this.dateTimePicker.Location = new System.Drawing.Point(240, 203);
|
||||
this.dateTimePicker.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.dateTimePicker.Name = "dateTimePicker";
|
||||
this.dateTimePicker.Size = new System.Drawing.Size(401, 31);
|
||||
this.dateTimePicker.TabIndex = 6;
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
this.ButtonSave.Location = new System.Drawing.Point(546, 817);
|
||||
this.ButtonSave.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.ButtonSave.Name = "ButtonSave";
|
||||
this.ButtonSave.Size = new System.Drawing.Size(141, 47);
|
||||
this.ButtonSave.TabIndex = 7;
|
||||
this.ButtonSave.Text = "Сохранить";
|
||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(727, 817);
|
||||
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(141, 47);
|
||||
this.ButtonCancel.TabIndex = 8;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.FurnitureId,
|
||||
this.FurnitureName,
|
||||
this.Count});
|
||||
this.dataGridView1.Location = new System.Drawing.Point(53, 371);
|
||||
this.dataGridView1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.dataGridView1.Name = "dataGridView1";
|
||||
this.dataGridView1.RowHeadersWidth = 62;
|
||||
this.dataGridView1.RowTemplate.Height = 25;
|
||||
this.dataGridView1.Size = new System.Drawing.Size(816, 406);
|
||||
this.dataGridView1.TabIndex = 9;
|
||||
//
|
||||
// FurnitureId
|
||||
//
|
||||
this.FurnitureId.HeaderText = "Id";
|
||||
this.FurnitureId.MinimumWidth = 8;
|
||||
this.FurnitureId.Name = "FurnitureId";
|
||||
this.FurnitureId.Visible = false;
|
||||
this.FurnitureId.Width = 150;
|
||||
//
|
||||
// FurnitureName
|
||||
//
|
||||
this.FurnitureName.HeaderText = "Название";
|
||||
this.FurnitureName.MinimumWidth = 8;
|
||||
this.FurnitureName.Name = "FurnitureName";
|
||||
this.FurnitureName.Width = 150;
|
||||
//
|
||||
// Count
|
||||
//
|
||||
this.Count.HeaderText = "Количество";
|
||||
this.Count.MinimumWidth = 8;
|
||||
this.Count.Name = "Count";
|
||||
this.Count.Width = 150;
|
||||
//
|
||||
// labelMaxCount
|
||||
//
|
||||
this.labelMaxCount.AutoSize = true;
|
||||
this.labelMaxCount.Location = new System.Drawing.Point(58, 275);
|
||||
this.labelMaxCount.Name = "labelMaxCount";
|
||||
this.labelMaxCount.Size = new System.Drawing.Size(117, 25);
|
||||
this.labelMaxCount.TabIndex = 10;
|
||||
this.labelMaxCount.Text = "Вместимость";
|
||||
//
|
||||
// textBoxMaxCount
|
||||
//
|
||||
this.textBoxMaxCount.Location = new System.Drawing.Point(242, 267);
|
||||
this.textBoxMaxCount.Name = "textBoxMaxCount";
|
||||
this.textBoxMaxCount.Size = new System.Drawing.Size(399, 31);
|
||||
this.textBoxMaxCount.TabIndex = 11;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(901, 883);
|
||||
this.Controls.Add(this.textBoxMaxCount);
|
||||
this.Controls.Add(this.labelMaxCount);
|
||||
this.Controls.Add(this.dataGridView1);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Controls.Add(this.dateTimePicker);
|
||||
this.Controls.Add(this.labelDate);
|
||||
this.Controls.Add(this.textBoxAddress);
|
||||
this.Controls.Add(this.labelAddress);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.labelShopName);
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.Name = "FormShop";
|
||||
this.Text = "Магазин";
|
||||
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelShopName;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxAddress;
|
||||
private Label labelAddress;
|
||||
private Label labelDate;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Button ButtonSave;
|
||||
private Button ButtonCancel;
|
||||
private DataGridView dataGridView1;
|
||||
private DataGridViewTextBoxColumn FurnitureId;
|
||||
private DataGridViewTextBoxColumn FurnitureName;
|
||||
private DataGridViewTextBoxColumn Count;
|
||||
private Label labelMaxCount;
|
||||
private TextBox textBoxMaxCount;
|
||||
}
|
||||
}
|
||||
144
FurnitureAssembly/FormShop.cs
Normal file
144
FurnitureAssembly/FormShop.cs
Normal file
@@ -0,0 +1,144 @@
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace FurnitureAssembly
|
||||
{
|
||||
public partial class FormShop : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
private Dictionary<int, (IFurnitureModel, int)> _shopFurnitures;
|
||||
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_shopFurnitures = new Dictionary<int, (IFurnitureModel, int)>();
|
||||
}
|
||||
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(dateTimePicker.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните дату открытия", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (Convert.ToInt32(textBoxMaxCount.Text) <= 0)
|
||||
{
|
||||
MessageBox.Show("Некорректная вместимость", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
try
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpening = dateTimePicker.Value,
|
||||
MaxCount = Convert.ToInt32(textBoxMaxCount.Text)
|
||||
|
||||
};
|
||||
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();
|
||||
}
|
||||
|
||||
private void FormShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение магазина");
|
||||
var view = _logic.ReadElement(new ShopSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAddress.Text = view.Address.ToString();
|
||||
dateTimePicker.Value = view.DateOpening;
|
||||
textBoxMaxCount.Text = view.MaxCount.ToString();
|
||||
_shopFurnitures = view.Furnitures ?? new
|
||||
Dictionary<int, (IFurnitureModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка компонент изделия");
|
||||
try
|
||||
{
|
||||
if (_shopFurnitures != null)
|
||||
{
|
||||
dataGridView1.Rows.Clear();
|
||||
foreach (var pc in _shopFurnitures)
|
||||
{
|
||||
dataGridView1.Rows.Add(new object[] { pc.Key, pc.Value.Item1.FurnitureName, pc.Value.Item2 });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
69
FurnitureAssembly/FormShop.resx
Normal file
69
FurnitureAssembly/FormShop.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="FurnitureId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="FurnitureName.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>
|
||||
114
FurnitureAssembly/FormShops.Designer.cs
generated
Normal file
114
FurnitureAssembly/FormShops.Designer.cs
generated
Normal file
@@ -0,0 +1,114 @@
|
||||
namespace FurnitureAssembly
|
||||
{
|
||||
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.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ButtonRef = new System.Windows.Forms.Button();
|
||||
this.ButtonUpd = new System.Windows.Forms.Button();
|
||||
this.ButtonDel = new System.Windows.Forms.Button();
|
||||
this.ButtonAdd = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(-1, -1);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(559, 453);
|
||||
this.dataGridView.TabIndex = 6;
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
this.ButtonRef.Location = new System.Drawing.Point(601, 223);
|
||||
this.ButtonRef.Name = "ButtonRef";
|
||||
this.ButtonRef.Size = new System.Drawing.Size(105, 29);
|
||||
this.ButtonRef.TabIndex = 13;
|
||||
this.ButtonRef.Text = "Обновить";
|
||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// ButtonUpd
|
||||
//
|
||||
this.ButtonUpd.Location = new System.Drawing.Point(601, 168);
|
||||
this.ButtonUpd.Name = "ButtonUpd";
|
||||
this.ButtonUpd.Size = new System.Drawing.Size(105, 29);
|
||||
this.ButtonUpd.TabIndex = 12;
|
||||
this.ButtonUpd.Text = "Изменить";
|
||||
this.ButtonUpd.UseVisualStyleBackColor = true;
|
||||
this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// ButtonDel
|
||||
//
|
||||
this.ButtonDel.Location = new System.Drawing.Point(601, 113);
|
||||
this.ButtonDel.Name = "ButtonDel";
|
||||
this.ButtonDel.Size = new System.Drawing.Size(105, 29);
|
||||
this.ButtonDel.TabIndex = 11;
|
||||
this.ButtonDel.Text = "Удалить";
|
||||
this.ButtonDel.UseVisualStyleBackColor = true;
|
||||
this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
this.ButtonAdd.Location = new System.Drawing.Point(601, 59);
|
||||
this.ButtonAdd.Name = "ButtonAdd";
|
||||
this.ButtonAdd.Size = new System.Drawing.Size(105, 29);
|
||||
this.ButtonAdd.TabIndex = 10;
|
||||
this.ButtonAdd.Text = "Добавить";
|
||||
this.ButtonAdd.UseVisualStyleBackColor = true;
|
||||
this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// FormShops
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(743, 451);
|
||||
this.Controls.Add(this.ButtonRef);
|
||||
this.Controls.Add(this.ButtonUpd);
|
||||
this.Controls.Add(this.ButtonDel);
|
||||
this.Controls.Add(this.ButtonAdd);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormShops";
|
||||
this.Text = "Магазины";
|
||||
this.Load += new System.EventHandler(this.FormShops_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button ButtonRef;
|
||||
private Button ButtonUpd;
|
||||
private Button ButtonDel;
|
||||
private Button ButtonAdd;
|
||||
}
|
||||
}
|
||||
108
FurnitureAssembly/FormShops.cs
Normal file
108
FurnitureAssembly/FormShops.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
|
||||
namespace FurnitureAssembly
|
||||
{
|
||||
public partial class FormShops : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
public FormShops(ILogger<FormShop> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
if (service is FormShop form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FormShops_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(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
FurnitureAssembly/FormShops.resx
Normal file
60
FurnitureAssembly/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>
|
||||
@@ -31,14 +31,7 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
DataGridView.DataSource = list;
|
||||
DataGridView.Columns["Id"].Visible = false;
|
||||
DataGridView.Columns["FurnitureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
DataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
|
||||
|
||||
@@ -27,34 +27,6 @@ namespace FurnitureAssemblyView
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void ImplementerForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение исполнителя");
|
||||
var view = _logic.ReadElement(new ImplementerSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFIO.Text = view.ImplementerFIO;
|
||||
textBoxPassword.Text = view.Password;
|
||||
numericUpDownWE.Value = view.WorkExperience;
|
||||
numericUpDownQual.Value = view.Qualification;
|
||||
}
|
||||
}
|
||||
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(textBoxFIO.Text))
|
||||
@@ -105,5 +77,33 @@ namespace FurnitureAssemblyView
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ImplementerForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение исполнителя");
|
||||
var view = _logic.ReadElement(new ImplementerSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFIO.Text = view.ImplementerFIO;
|
||||
textBoxPassword.Text = view.Password;
|
||||
numericUpDownWE.Value = view.WorkExperience;
|
||||
numericUpDownQual.Value = view.Qualification;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения исполнителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
12
FurnitureAssembly/ImplementersForm.Designer.cs
generated
12
FurnitureAssembly/ImplementersForm.Designer.cs
generated
@@ -38,7 +38,7 @@
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
this.ButtonRef.Location = new System.Drawing.Point(749, 309);
|
||||
this.ButtonRef.Location = new System.Drawing.Point(853, 411);
|
||||
this.ButtonRef.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.ButtonRef.Name = "ButtonRef";
|
||||
this.ButtonRef.Size = new System.Drawing.Size(150, 48);
|
||||
@@ -49,7 +49,7 @@
|
||||
//
|
||||
// ButtonDel
|
||||
//
|
||||
this.ButtonDel.Location = new System.Drawing.Point(749, 212);
|
||||
this.ButtonDel.Location = new System.Drawing.Point(853, 314);
|
||||
this.ButtonDel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.ButtonDel.Name = "ButtonDel";
|
||||
this.ButtonDel.Size = new System.Drawing.Size(150, 48);
|
||||
@@ -60,7 +60,7 @@
|
||||
//
|
||||
// ButtonUpd
|
||||
//
|
||||
this.ButtonUpd.Location = new System.Drawing.Point(749, 117);
|
||||
this.ButtonUpd.Location = new System.Drawing.Point(853, 219);
|
||||
this.ButtonUpd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.ButtonUpd.Name = "ButtonUpd";
|
||||
this.ButtonUpd.Size = new System.Drawing.Size(150, 48);
|
||||
@@ -71,7 +71,7 @@
|
||||
//
|
||||
// ButtonAdd
|
||||
//
|
||||
this.ButtonAdd.Location = new System.Drawing.Point(749, 24);
|
||||
this.ButtonAdd.Location = new System.Drawing.Point(853, 126);
|
||||
this.ButtonAdd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.ButtonAdd.Name = "ButtonAdd";
|
||||
this.ButtonAdd.Size = new System.Drawing.Size(150, 48);
|
||||
@@ -88,14 +88,14 @@
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 62;
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(707, 540);
|
||||
this.dataGridView.Size = new System.Drawing.Size(795, 482);
|
||||
this.dataGridView.TabIndex = 12;
|
||||
//
|
||||
// ImplementersForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(992, 568);
|
||||
this.ClientSize = new System.Drawing.Size(1035, 528);
|
||||
this.Controls.Add(this.ButtonRef);
|
||||
this.Controls.Add(this.ButtonDel);
|
||||
this.Controls.Add(this.ButtonUpd);
|
||||
|
||||
@@ -29,18 +29,12 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillandConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка исполнителей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -53,6 +47,7 @@ namespace FurnitureAssemblyView
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ImplementerForm));
|
||||
if (service is ImplementerForm form)
|
||||
{
|
||||
|
||||
50
FurnitureAssembly/MailForm.Designer.cs
generated
50
FurnitureAssembly/MailForm.Designer.cs
generated
@@ -28,18 +28,57 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonOpen = new System.Windows.Forms.Button();
|
||||
this.buttonNext = new System.Windows.Forms.Button();
|
||||
this.buttonPrev = new System.Windows.Forms.Button();
|
||||
|
||||
this.dataGridViewMail = new System.Windows.Forms.DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridViewMail)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonOpen
|
||||
//
|
||||
this.buttonOpen.Location = new System.Drawing.Point(889, 559);
|
||||
this.buttonOpen.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.buttonOpen.Name = "buttonOpen";
|
||||
this.buttonOpen.Size = new System.Drawing.Size(133, 44);
|
||||
this.buttonOpen.TabIndex = 7;
|
||||
this.buttonOpen.Text = "Открыть";
|
||||
this.buttonOpen.UseVisualStyleBackColor = true;
|
||||
this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
|
||||
//
|
||||
// buttonNext
|
||||
//
|
||||
this.buttonNext.Location = new System.Drawing.Point(445, 559);
|
||||
this.buttonNext.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.buttonNext.Name = "buttonNext";
|
||||
this.buttonNext.Size = new System.Drawing.Size(172, 38);
|
||||
this.buttonNext.TabIndex = 6;
|
||||
this.buttonNext.Text = "Следующая";
|
||||
this.buttonNext.UseVisualStyleBackColor = true;
|
||||
this.buttonNext.Click += new System.EventHandler(this.buttonNext_Click);
|
||||
//
|
||||
// buttonPrev
|
||||
//
|
||||
this.buttonPrev.Location = new System.Drawing.Point(93, 559);
|
||||
this.buttonPrev.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.buttonPrev.Name = "buttonPrev";
|
||||
this.buttonPrev.Size = new System.Drawing.Size(146, 38);
|
||||
this.buttonPrev.TabIndex = 5;
|
||||
this.buttonPrev.Text = "Предыдущая";
|
||||
this.buttonPrev.UseVisualStyleBackColor = true;
|
||||
this.buttonPrev.Click += new System.EventHandler(this.buttonPrev_Click);
|
||||
//
|
||||
// dataGridViewMail
|
||||
//
|
||||
this.dataGridViewMail.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridViewMail.Location = new System.Drawing.Point(0, 2);
|
||||
this.dataGridViewMail.Location = new System.Drawing.Point(13, 5);
|
||||
|
||||
this.dataGridViewMail.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.dataGridViewMail.Name = "dataGridViewMail";
|
||||
this.dataGridViewMail.RowHeadersWidth = 62;
|
||||
this.dataGridViewMail.RowTemplate.Height = 25;
|
||||
|
||||
this.dataGridViewMail.Size = new System.Drawing.Size(965, 592);
|
||||
this.dataGridViewMail.TabIndex = 1;
|
||||
//
|
||||
@@ -47,7 +86,12 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
|
||||
this.ClientSize = new System.Drawing.Size(965, 593);
|
||||
this.Controls.Add(this.buttonOpen);
|
||||
this.Controls.Add(this.buttonNext);
|
||||
this.Controls.Add(this.buttonPrev);
|
||||
|
||||
this.Controls.Add(this.dataGridViewMail);
|
||||
this.Name = "MailForm";
|
||||
this.Text = "Письма";
|
||||
@@ -59,6 +103,10 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonOpen;
|
||||
private Button buttonNext;
|
||||
private Button buttonPrev;
|
||||
|
||||
private DataGridView dataGridViewMail;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
|
||||
using FurnitureAssembly;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -16,6 +19,10 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMessageInfoLogic _logic;
|
||||
private readonly int pageSize = 4;
|
||||
private int _page = 1;
|
||||
private int _totalPages = 1;
|
||||
|
||||
public MailForm(ILogger<MailForm> logger, IMessageInfoLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -24,16 +31,23 @@ namespace FurnitureAssemblyView
|
||||
}
|
||||
|
||||
private void MailForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
buttonPrev.Enabled = false;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridViewMail.DataSource = list;
|
||||
dataGridViewMail.Columns["ClientId"].Visible = false;
|
||||
dataGridViewMail.Columns["MessageId"].Visible = false;
|
||||
dataGridViewMail.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
var totalCount = list!.Capacity;
|
||||
_totalPages = (int)Math.Ceiling((decimal)totalCount / pageSize);
|
||||
list = list!.Skip((_page - 1) * pageSize).Take(pageSize).ToList();
|
||||
dataGridViewMail.FillandConfigGrid(list);
|
||||
}
|
||||
_logger.LogInformation("Загрузка писем");
|
||||
}
|
||||
@@ -44,5 +58,48 @@ namespace FurnitureAssemblyView
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonPrev_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_page > 1)
|
||||
{
|
||||
_page -= 1;
|
||||
buttonNext.Enabled = true;
|
||||
LoadData();
|
||||
if (_page == 1)
|
||||
{
|
||||
buttonPrev.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonNext_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_page < _totalPages)
|
||||
{
|
||||
_page += 1;
|
||||
buttonPrev.Enabled = true;
|
||||
LoadData();
|
||||
if (_page == _totalPages)
|
||||
{
|
||||
buttonNext.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonOpen_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridViewMail.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(OneMailForm));
|
||||
if (service is OneMailForm form)
|
||||
{
|
||||
form.MessageId = (string)dataGridViewMail.SelectedRows[0].Cells["MessageId"].Value;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
87
FurnitureAssembly/MainForm.Designer.cs
generated
87
FurnitureAssembly/MainForm.Designer.cs
generated
@@ -39,13 +39,26 @@
|
||||
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.FurnituresToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.FurnituresComponentsToolStripMenuItem = 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.buttonSell = new System.Windows.Forms.Button();
|
||||
this.запускРаботToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
||||
|
||||
this.письмаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
||||
buttonReady = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.menuStrip.SuspendLayout();
|
||||
@@ -68,7 +81,7 @@
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 62;
|
||||
this.dataGridView.RowTemplate.Height = 33;
|
||||
this.dataGridView.Size = new System.Drawing.Size(1227, 386);
|
||||
this.dataGridView.Size = new System.Drawing.Size(1227, 441);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonCreate
|
||||
@@ -116,6 +129,9 @@
|
||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.справочникиToolStripMenuItem,
|
||||
this.пополнениеМагазинаToolStripMenuItem,
|
||||
|
||||
|
||||
this.отчетыToolStripMenuItem,
|
||||
this.запускРаботToolStripMenuItem,
|
||||
this.письмаToolStripMenuItem});
|
||||
@@ -131,6 +147,8 @@
|
||||
this.компонентыToolStripMenuItem,
|
||||
this.изделияToolStripMenuItem,
|
||||
this.клиентыToolStripMenuItem,
|
||||
|
||||
this.магазиныToolStripMenuItem,
|
||||
this.исполнителиToolStripMenuItem});
|
||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(139, 29);
|
||||
@@ -157,6 +175,13 @@
|
||||
this.клиентыToolStripMenuItem.Text = "Клиенты";
|
||||
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.ClientsToolStripMenuItem_Click);
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.магазиныToolStripMenuItem.Text = "Магазины";
|
||||
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopToolStripMenuItem_Click);
|
||||
//
|
||||
// исполнителиToolStripMenuItem
|
||||
//
|
||||
this.исполнителиToolStripMenuItem.Name = "исполнителиToolStripMenuItem";
|
||||
@@ -164,12 +189,22 @@
|
||||
this.исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||
this.исполнителиToolStripMenuItem.Click += new System.EventHandler(this.ImplementersToolStripMenuItem_Click);
|
||||
//
|
||||
// пополнениеМагазинаToolStripMenuItem
|
||||
//
|
||||
this.пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
|
||||
this.пополнениеМагазинаToolStripMenuItem.Size = new System.Drawing.Size(210, 29);
|
||||
this.пополнениеМагазинаToolStripMenuItem.Text = "Пополнение магазина";
|
||||
this.пополнениеМагазинаToolStripMenuItem.Click += new System.EventHandler(this.AddToShopToolStripMenuItem_Click);
|
||||
//
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.FurnituresToolStripMenuItem,
|
||||
this.FurnituresComponentsToolStripMenuItem,
|
||||
this.списокЗаказовToolStripMenuItem});
|
||||
this.списокЗаказовToolStripMenuItem,
|
||||
this.списокМагазиновToolStripMenuItem,
|
||||
this.изделияВМагазинахToolStripMenuItem,
|
||||
this.списокЗаказовПоДатамToolStripMenuItem});
|
||||
this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(88, 29);
|
||||
this.отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
@@ -195,6 +230,44 @@
|
||||
this.списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||
this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click);
|
||||
//
|
||||
// списокМагазиновToolStripMenuItem
|
||||
//
|
||||
this.списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
|
||||
this.списокМагазиновToolStripMenuItem.Size = new System.Drawing.Size(325, 34);
|
||||
this.списокМагазиновToolStripMenuItem.Text = "Список магазинов";
|
||||
this.списокМагазиновToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click);
|
||||
//
|
||||
// изделияВМагазинахToolStripMenuItem
|
||||
//
|
||||
this.изделияВМагазинахToolStripMenuItem.Name = "изделияВМагазинахToolStripMenuItem";
|
||||
this.изделияВМагазинахToolStripMenuItem.Size = new System.Drawing.Size(325, 34);
|
||||
this.изделияВМагазинахToolStripMenuItem.Text = "Изделия в магазинах";
|
||||
this.изделияВМагазинахToolStripMenuItem.Click += new System.EventHandler(this.ShopsFurnituresToolStripMenuItem_Click);
|
||||
//
|
||||
// списокЗаказовПоДатамToolStripMenuItem
|
||||
//
|
||||
this.списокЗаказовПоДатамToolStripMenuItem.Name = "списокЗаказовПоДатамToolStripMenuItem";
|
||||
this.списокЗаказовПоДатамToolStripMenuItem.Size = new System.Drawing.Size(325, 34);
|
||||
this.списокЗаказовПоДатамToolStripMenuItem.Text = "Список заказов по датам";
|
||||
this.списокЗаказовПоДатамToolStripMenuItem.Click += new System.EventHandler(this.OrderDateToolStripMenuItem_Click);
|
||||
//
|
||||
// запускРаботToolStripMenuItem
|
||||
//
|
||||
this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
|
||||
this.запускРаботToolStripMenuItem.Size = new System.Drawing.Size(136, 29);
|
||||
this.запускРаботToolStripMenuItem.Text = "Запуск работ";
|
||||
this.запускРаботToolStripMenuItem.Click += new System.EventHandler(this.doWorkToolStripMenuItem_Click);
|
||||
//
|
||||
// buttonSell
|
||||
//
|
||||
this.buttonSell.Location = new System.Drawing.Point(1280, 450);
|
||||
this.buttonSell.Name = "buttonSell";
|
||||
this.buttonSell.Size = new System.Drawing.Size(208, 34);
|
||||
this.buttonSell.TabIndex = 7;
|
||||
this.buttonSell.Text = "Продать";
|
||||
this.buttonSell.UseVisualStyleBackColor = true;
|
||||
this.buttonSell.Click += new System.EventHandler(this.buttonSell_Click);
|
||||
|
||||
// запускРаботToolStripMenuItem
|
||||
//
|
||||
this.запускРаботToolStripMenuItem.Name = "запускРаботToolStripMenuItem";
|
||||
@@ -213,7 +286,8 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1530, 450);
|
||||
this.ClientSize = new System.Drawing.Size(1530, 505);
|
||||
this.Controls.Add(this.buttonSell);
|
||||
this.Controls.Add(this.buttonRefresh);
|
||||
this.Controls.Add(this.buttonPut);
|
||||
this.Controls.Add(buttonReady);
|
||||
@@ -244,10 +318,17 @@
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem изделияToolStripMenuItem;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
|
||||
private Button buttonSell;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
private ToolStripMenuItem FurnituresToolStripMenuItem;
|
||||
private ToolStripMenuItem FurnituresComponentsToolStripMenuItem;
|
||||
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
||||
|
||||
private ToolStripMenuItem списокМагазиновToolStripMenuItem;
|
||||
private ToolStripMenuItem изделияВМагазинахToolStripMenuItem;
|
||||
private ToolStripMenuItem списокЗаказовПоДатамToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||
private ToolStripMenuItem запускРаботToolStripMenuItem;
|
||||
|
||||
@@ -19,14 +19,16 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
private readonly IReportLogic _reportLogic;
|
||||
private readonly IWorkProcess _workModeling;
|
||||
|
||||
public MainForm(ILogger<MainForm> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workModeling)
|
||||
public MainForm(ILogger<MainForm> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IShopLogic shopLogic, IWorkProcess workModeling)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
_shopLogic = shopLogic;
|
||||
_reportLogic = reportLogic;
|
||||
_workModeling = workModeling;
|
||||
}
|
||||
@@ -40,15 +42,7 @@ namespace FurnitureAssemblyView
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["FurnitureId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
}
|
||||
dataGridView.FillandConfigGrid(_orderLogic.ReadList(null));
|
||||
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
@@ -133,8 +127,7 @@ namespace FurnitureAssemblyView
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
||||
try
|
||||
{
|
||||
try {
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
@@ -144,10 +137,8 @@ namespace FurnitureAssemblyView
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -199,7 +190,26 @@ namespace FurnitureAssemblyView
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void FurnituresToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void ShopToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||
if (service is FormShops form)
|
||||
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddToShopToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormAddToShop));
|
||||
if (service is FormAddToShop form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void FurnituresToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
@@ -219,16 +229,57 @@ namespace FurnitureAssemblyView
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormReportFurnitureComponents));
|
||||
if (service is FormReportFurnitureComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSell_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSell));
|
||||
if (service is FormSell form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
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 ShopsFurnituresToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ReportShopFurnituresForm));
|
||||
if (service is ReportShopFurnituresForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void OrderDateToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ReportCountOrdersByPeriodForm));
|
||||
if (service is ReportCountOrdersByPeriodForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
@@ -255,8 +306,8 @@ namespace FurnitureAssemblyView
|
||||
private void doWorkToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_workModeling.DoWork((
|
||||
Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!,
|
||||
_orderLogic);
|
||||
Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!,
|
||||
_orderLogic);
|
||||
}
|
||||
|
||||
private void mailToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
||||
203
FurnitureAssembly/OneMailForm.Designer.cs
generated
Normal file
203
FurnitureAssembly/OneMailForm.Designer.cs
generated
Normal file
@@ -0,0 +1,203 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class OneMailForm
|
||||
{
|
||||
/// <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.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonSend = new System.Windows.Forms.Button();
|
||||
this.labelReply = new System.Windows.Forms.Label();
|
||||
this.labelBody = new System.Windows.Forms.Label();
|
||||
this.richTextBoxReply = new System.Windows.Forms.RichTextBox();
|
||||
this.labelName = new System.Windows.Forms.Label();
|
||||
this.labelDate = new System.Windows.Forms.Label();
|
||||
this.labelSenderName = new System.Windows.Forms.Label();
|
||||
this.richTextBoxBody = new System.Windows.Forms.RichTextBox();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.dateTime = new System.Windows.Forms.DateTimePicker();
|
||||
this.textBoxSenderName = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(749, 741);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(107, 38);
|
||||
this.buttonCancel.TabIndex = 24;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// buttonSend
|
||||
//
|
||||
this.buttonSend.Location = new System.Drawing.Point(907, 741);
|
||||
this.buttonSend.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.buttonSend.Name = "buttonSend";
|
||||
this.buttonSend.Size = new System.Drawing.Size(107, 38);
|
||||
this.buttonSend.TabIndex = 23;
|
||||
this.buttonSend.Text = "Отправить";
|
||||
this.buttonSend.UseVisualStyleBackColor = true;
|
||||
this.buttonSend.Click += new System.EventHandler(this.buttonSend_Click);
|
||||
//
|
||||
// labelReply
|
||||
//
|
||||
this.labelReply.AutoSize = true;
|
||||
this.labelReply.Location = new System.Drawing.Point(26, 502);
|
||||
this.labelReply.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelReply.Name = "labelReply";
|
||||
this.labelReply.Size = new System.Drawing.Size(59, 25);
|
||||
this.labelReply.TabIndex = 22;
|
||||
this.labelReply.Text = "Ответ";
|
||||
//
|
||||
// labelBody
|
||||
//
|
||||
this.labelBody.AutoSize = true;
|
||||
this.labelBody.Location = new System.Drawing.Point(26, 269);
|
||||
this.labelBody.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelBody.Name = "labelBody";
|
||||
this.labelBody.Size = new System.Drawing.Size(118, 25);
|
||||
this.labelBody.TabIndex = 21;
|
||||
this.labelBody.Text = "Текст письма";
|
||||
//
|
||||
// richTextBoxReply
|
||||
//
|
||||
this.richTextBoxReply.Location = new System.Drawing.Point(26, 532);
|
||||
this.richTextBoxReply.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.richTextBoxReply.Name = "richTextBoxReply";
|
||||
this.richTextBoxReply.Size = new System.Drawing.Size(987, 182);
|
||||
this.richTextBoxReply.TabIndex = 20;
|
||||
this.richTextBoxReply.Text = "";
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
this.labelName.AutoSize = true;
|
||||
this.labelName.Location = new System.Drawing.Point(26, 186);
|
||||
this.labelName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelName.Name = "labelName";
|
||||
this.labelName.Size = new System.Drawing.Size(99, 25);
|
||||
this.labelName.TabIndex = 19;
|
||||
this.labelName.Text = "Заголовок";
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
this.labelDate.AutoSize = true;
|
||||
this.labelDate.Location = new System.Drawing.Point(333, 86);
|
||||
this.labelDate.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelDate.Name = "labelDate";
|
||||
this.labelDate.Size = new System.Drawing.Size(113, 25);
|
||||
this.labelDate.TabIndex = 18;
|
||||
this.labelDate.Text = "Дата письма";
|
||||
//
|
||||
// labelSenderName
|
||||
//
|
||||
this.labelSenderName.AutoSize = true;
|
||||
this.labelSenderName.Location = new System.Drawing.Point(26, 86);
|
||||
this.labelSenderName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelSenderName.Name = "labelSenderName";
|
||||
this.labelSenderName.Size = new System.Drawing.Size(117, 25);
|
||||
this.labelSenderName.TabIndex = 17;
|
||||
this.labelSenderName.Text = "Отправитель";
|
||||
//
|
||||
// richTextBoxBody
|
||||
//
|
||||
this.richTextBoxBody.Enabled = false;
|
||||
this.richTextBoxBody.Location = new System.Drawing.Point(26, 299);
|
||||
this.richTextBoxBody.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.richTextBoxBody.Name = "richTextBoxBody";
|
||||
this.richTextBoxBody.Size = new System.Drawing.Size(987, 182);
|
||||
this.richTextBoxBody.TabIndex = 16;
|
||||
this.richTextBoxBody.Text = "";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Enabled = false;
|
||||
this.textBoxName.Location = new System.Drawing.Point(26, 216);
|
||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(987, 31);
|
||||
this.textBoxName.TabIndex = 15;
|
||||
//
|
||||
// dateTime
|
||||
//
|
||||
this.dateTime.Enabled = false;
|
||||
this.dateTime.Location = new System.Drawing.Point(333, 126);
|
||||
this.dateTime.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.dateTime.Name = "dateTime";
|
||||
this.dateTime.Size = new System.Drawing.Size(204, 31);
|
||||
this.dateTime.TabIndex = 14;
|
||||
//
|
||||
// textBoxSenderName
|
||||
//
|
||||
this.textBoxSenderName.Enabled = false;
|
||||
this.textBoxSenderName.Location = new System.Drawing.Point(26, 126);
|
||||
this.textBoxSenderName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.textBoxSenderName.Name = "textBoxSenderName";
|
||||
this.textBoxSenderName.Size = new System.Drawing.Size(265, 31);
|
||||
this.textBoxSenderName.TabIndex = 13;
|
||||
//
|
||||
// OneMailForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1046, 837);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSend);
|
||||
this.Controls.Add(this.labelReply);
|
||||
this.Controls.Add(this.labelBody);
|
||||
this.Controls.Add(this.richTextBoxReply);
|
||||
this.Controls.Add(this.labelName);
|
||||
this.Controls.Add(this.labelDate);
|
||||
this.Controls.Add(this.labelSenderName);
|
||||
this.Controls.Add(this.richTextBoxBody);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.dateTime);
|
||||
this.Controls.Add(this.textBoxSenderName);
|
||||
this.Name = "OneMailForm";
|
||||
this.Text = "OneMailForm";
|
||||
this.Load += new System.EventHandler(this.OneMailForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCancel;
|
||||
private Button buttonSend;
|
||||
private Label labelReply;
|
||||
private Label labelBody;
|
||||
private RichTextBox richTextBoxReply;
|
||||
private Label labelName;
|
||||
private Label labelDate;
|
||||
private Label labelSenderName;
|
||||
private RichTextBox richTextBoxBody;
|
||||
private TextBox textBoxName;
|
||||
private DateTimePicker dateTime;
|
||||
private TextBox textBoxSenderName;
|
||||
}
|
||||
}
|
||||
98
FurnitureAssembly/OneMailForm.cs
Normal file
98
FurnitureAssembly/OneMailForm.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using FurnitureAssemblyBusinessLogic.MailWorker;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class OneMailForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMessageInfoLogic _logic;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
private MessageInfoViewModel messageInfo;
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
public OneMailForm(ILogger<OneMailForm> logger, IMessageInfoLogic messageInfoLogic, AbstractMailWorker mailWorker)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = messageInfoLogic;
|
||||
_mailWorker = mailWorker;
|
||||
}
|
||||
|
||||
private void OneMailForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(MessageId))
|
||||
{
|
||||
_logger.LogInformation("Загрузка письма");
|
||||
try
|
||||
{
|
||||
messageInfo = _logic.ReadElement(new()
|
||||
{
|
||||
MessageId = MessageId
|
||||
});
|
||||
if (messageInfo == null)
|
||||
{
|
||||
throw new ArgumentNullException($"Письма с id {MessageId} не существует");
|
||||
}
|
||||
textBoxSenderName.Text = messageInfo.SenderName;
|
||||
textBoxName.Text = messageInfo.Subject;
|
||||
richTextBoxBody.Text = messageInfo.Body;
|
||||
richTextBoxReply.Text = messageInfo.Reply;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки письма");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
_logic.Update(new()
|
||||
{
|
||||
MessageId = MessageId,
|
||||
Reply = messageInfo?.Reply,
|
||||
IsRead = true,
|
||||
});
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void buttonSend_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(richTextBoxReply.Text))
|
||||
{
|
||||
MessageBox.Show("Напишите ответ для отправки", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_mailWorker.MailSendAsync(new()
|
||||
{
|
||||
MailAddress = messageInfo.SenderName,
|
||||
Subject = messageInfo.Subject,
|
||||
Text = richTextBoxReply.Text
|
||||
});
|
||||
_logic.Update(new()
|
||||
{
|
||||
MessageId = MessageId,
|
||||
Reply = richTextBoxReply.Text,
|
||||
IsRead = true
|
||||
});
|
||||
MessageBox.Show("Успешно отправлен ответ на письмо", "Отправка ответа на письмо", MessageBoxButtons.OK);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
60
FurnitureAssembly/OneMailForm.resx
Normal file
60
FurnitureAssembly/OneMailForm.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>
|
||||
@@ -3,7 +3,6 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using FurnitureAssemblyDatabaseImplement.Implements;
|
||||
using FurnitureAssemblyBusinessLogic.BusinessLogics;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyBusinessLogic.BusinessLogics;
|
||||
using NLog.Extensions.Logging;
|
||||
using FurnitureAssemblyView;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -27,6 +26,7 @@ namespace FurnitureAssembly
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
|
||||
try
|
||||
{
|
||||
var mailSender =
|
||||
@@ -55,6 +55,7 @@ namespace FurnitureAssembly
|
||||
var logger = _serviceProvider.GetService<ILogger>();
|
||||
logger?.LogError(ex, "Error");
|
||||
}
|
||||
|
||||
Application.Run(_serviceProvider.GetRequiredService<MainForm>());
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
@@ -67,18 +68,23 @@ namespace FurnitureAssembly
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IFurnitureStorage, FurnitureStorage>();
|
||||
services.AddTransient<IShopStorage, ShopStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IfurnitureLogic, FurnitureLogic>();
|
||||
services.AddTransient<IShopLogic, ShopLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
|
||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
|
||||
services.AddTransient<MainForm>();
|
||||
services.AddTransient<ComponentForm>();
|
||||
services.AddTransient<ComponentsForm>();
|
||||
@@ -86,19 +92,28 @@ namespace FurnitureAssembly
|
||||
services.AddTransient<FurnitureForm>();
|
||||
services.AddTransient<FurnituresForm>();
|
||||
services.AddTransient<FurnitureComponentForm>();
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormAddToShop>();
|
||||
services.AddTransient<FormSell>();
|
||||
services.AddTransient<ReportShopFurnituresForm>();
|
||||
services.AddTransient<ReportCountOrdersByPeriodForm>();
|
||||
services.AddTransient<ClientsForm>();
|
||||
services.AddTransient<MailForm>();
|
||||
|
||||
|
||||
services.AddTransient<FormReportFurnitureComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
|
||||
services.AddTransient<ImplementersForm>();
|
||||
services.AddTransient<ImplementerForm>();
|
||||
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
||||
services.AddTransient<ImplementersForm>();
|
||||
services.AddTransient<ImplementerForm>();
|
||||
}
|
||||
|
||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||
|
||||
}
|
||||
|
||||
133
FurnitureAssembly/ReportCountOrdersByPeriodForm.Designer.cs
generated
Normal file
133
FurnitureAssembly/ReportCountOrdersByPeriodForm.Designer.cs
generated
Normal file
@@ -0,0 +1,133 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class ReportCountOrdersByPeriodForm
|
||||
{
|
||||
/// <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.buttonMake_Pdf = new System.Windows.Forms.Button();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.buttonToPdf = new System.Windows.Forms.Button();
|
||||
this.buttonMake = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.panel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel
|
||||
//
|
||||
this.panel.Controls.Add(this.button2);
|
||||
this.panel.Controls.Add(this.buttonMake_Pdf);
|
||||
this.panel.Controls.Add(this.button1);
|
||||
this.panel.Controls.Add(this.buttonToPdf);
|
||||
this.panel.Controls.Add(this.buttonMake);
|
||||
this.panel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.panel.Name = "panel";
|
||||
this.panel.Size = new System.Drawing.Size(986, 67);
|
||||
this.panel.TabIndex = 3;
|
||||
//
|
||||
// buttonMake_Pdf
|
||||
//
|
||||
this.buttonMake_Pdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonMake_Pdf.Location = new System.Drawing.Point(1966, 13);
|
||||
this.buttonMake_Pdf.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.buttonMake_Pdf.Name = "buttonMake_Pdf";
|
||||
this.buttonMake_Pdf.Size = new System.Drawing.Size(199, 45);
|
||||
this.buttonMake_Pdf.TabIndex = 7;
|
||||
this.buttonMake_Pdf.Text = "В Pdf";
|
||||
this.buttonMake_Pdf.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button1.Location = new System.Drawing.Point(3020, 13);
|
||||
this.button1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(199, 45);
|
||||
this.button1.TabIndex = 6;
|
||||
this.button1.Text = "В Pdf";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonToPdf
|
||||
//
|
||||
this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonToPdf.Location = new System.Drawing.Point(4289, 13);
|
||||
this.buttonToPdf.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.buttonToPdf.Name = "buttonToPdf";
|
||||
this.buttonToPdf.Size = new System.Drawing.Size(199, 45);
|
||||
this.buttonToPdf.TabIndex = 5;
|
||||
this.buttonToPdf.Text = "В Pdf";
|
||||
this.buttonToPdf.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonMake
|
||||
//
|
||||
this.buttonMake.Location = new System.Drawing.Point(126, 14);
|
||||
this.buttonMake.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.buttonMake.Name = "buttonMake";
|
||||
this.buttonMake.Size = new System.Drawing.Size(199, 45);
|
||||
this.buttonMake.TabIndex = 4;
|
||||
this.buttonMake.Text = "Сформировать";
|
||||
this.buttonMake.UseVisualStyleBackColor = true;
|
||||
this.buttonMake.Click += new System.EventHandler(this.buttonMake_Click);
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.button2.Location = new System.Drawing.Point(584, 14);
|
||||
this.button2.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(199, 45);
|
||||
this.button2.TabIndex = 8;
|
||||
this.button2.Text = "В Pdf";
|
||||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.button2_Click);
|
||||
//
|
||||
// ReportCountOrdersByPeriodForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(986, 491);
|
||||
this.Controls.Add(this.panel);
|
||||
this.Name = "ReportCountOrdersByPeriodForm";
|
||||
this.Text = "Заказы по датам";
|
||||
this.Load += new System.EventHandler(this.ReportCountOrdersByPeriodForm_Load);
|
||||
this.panel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel;
|
||||
private Button button2;
|
||||
private Button buttonMake_Pdf;
|
||||
private Button button1;
|
||||
private Button buttonToPdf;
|
||||
private Button buttonMake;
|
||||
}
|
||||
}
|
||||
87
FurnitureAssembly/ReportCountOrdersByPeriodForm.cs
Normal file
87
FurnitureAssembly/ReportCountOrdersByPeriodForm.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Reporting.WinForms;
|
||||
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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class ReportCountOrdersByPeriodForm : Form
|
||||
{
|
||||
private readonly ReportViewer reportViewer;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IReportLogic _logic;
|
||||
|
||||
public ReportCountOrdersByPeriodForm(ILogger<ReportCountOrdersByPeriodForm> logger, IReportLogic reportLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = reportLogic;
|
||||
reportViewer = new ReportViewer
|
||||
{
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrdersCount.rdlc", FileMode.Open)); // другой файл
|
||||
Controls.Clear();
|
||||
Controls.Add(reportViewer);
|
||||
Controls.Add(panel);
|
||||
}
|
||||
|
||||
private void ReportCountOrdersByPeriodForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buttonMake_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dataSource = _logic.GetCountOrders();
|
||||
var source = new ReportDataSource("DataSetOrders", dataSource);
|
||||
reportViewer.LocalReport.DataSources.Clear();
|
||||
reportViewer.LocalReport.DataSources.Add(source);
|
||||
|
||||
|
||||
reportViewer.RefreshReport();
|
||||
_logger.LogInformation("Загрузка списка заказов, объединенных по дате");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка заказов на период");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveCountOrdersToPdfFile(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
FurnitureAssembly/ReportCountOrdersByPeriodForm.resx
Normal file
60
FurnitureAssembly/ReportCountOrdersByPeriodForm.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>
|
||||
459
FurnitureAssembly/ReportOrdersCount.rdlc
Normal file
459
FurnitureAssembly/ReportOrdersCount.rdlc
Normal file
@@ -0,0 +1,459 @@
|
||||
<?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="FurnitureAssemblyContractsViewModels">
|
||||
<ConnectionProperties>
|
||||
<DataProvider>System.Data.DataSet</DataProvider>
|
||||
<ConnectString>/* Local Connection */</ConnectString>
|
||||
</ConnectionProperties>
|
||||
<rd:DataSourceID>10791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
|
||||
</DataSource>
|
||||
</DataSources>
|
||||
<DataSets>
|
||||
<DataSet Name="DataSetOrders">
|
||||
<Query>
|
||||
<DataSourceName>FurnitureAssemblyContractsViewModels</DataSourceName>
|
||||
<CommandText>/* Local Query */</CommandText>
|
||||
</Query>
|
||||
<Fields>
|
||||
<Field Name="DateCreate">
|
||||
<DataField>DateCreate</DataField>
|
||||
<rd:TypeName>System.DateTime</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="CountOrders">
|
||||
<DataField>CountOrders</DataField>
|
||||
<rd:TypeName>System.Decimal</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="TotalSumOrders">
|
||||
<DataField>TotalSumOrders</DataField>
|
||||
<rd:TypeName>System.Double</rd:TypeName>
|
||||
</Field>
|
||||
</Fields>
|
||||
<rd:DataSetInfo>
|
||||
<rd:DataSetName>FurnitureAssemblyContracts.ViewModels</rd:DataSetName>
|
||||
<rd:TableName>ReportCountOrdersViewModel</rd:TableName>
|
||||
<rd:ObjectDataSourceType>FurnitureAssemblyContracts.ViewModels.ReportCountOrdersViewModel, FurnitureAssemblyContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
||||
</rd:DataSetInfo>
|
||||
</DataSet>
|
||||
</DataSets>
|
||||
<ReportSections>
|
||||
<ReportSection>
|
||||
<Body>
|
||||
<ReportItems>
|
||||
<Textbox Name="ReportParameterPeriod">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Parameters!ReportParameterPeriod.Value</Value>
|
||||
<Style>
|
||||
<FontSize>14pt</FontSize>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Center</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
|
||||
<Top>1cm</Top>
|
||||
<Height>1cm</Height>
|
||||
<Width>21cm</Width>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<VerticalAlign>Middle</VerticalAlign>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Textbox Name="TextboxTitle">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Заказы</Value>
|
||||
<Style>
|
||||
<FontSize>16pt</FontSize>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Center</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Height>1cm</Height>
|
||||
<Width>21cm</Width>
|
||||
<ZIndex>1</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<VerticalAlign>Middle</VerticalAlign>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Tablix Name="Tablix1">
|
||||
<TablixBody>
|
||||
<TablixColumns>
|
||||
<TablixColumn>
|
||||
<Width>3cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>3cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>7cm</Width>
|
||||
</TablixColumn>
|
||||
</TablixColumns>
|
||||
<TablixRows>
|
||||
<TablixRow>
|
||||
<Height>0.6cm</Height>
|
||||
<TablixCells>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Textbox1">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Дата создания</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox1</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Textbox3">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Количество заказов</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox3</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="Textbox2">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Сумма</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox2</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
</TablixCells>
|
||||
</TablixRow>
|
||||
<TablixRow>
|
||||
<Height>0.6cm</Height>
|
||||
<TablixCells>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="DateCreate">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!DateCreate.Value</Value>
|
||||
<Style>
|
||||
<Format>d</Format>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>DateCreate</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="CountOrders">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!CountOrders.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>CountOrders</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="TotalSumOrders">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!TotalSumOrders.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>TotalSumOrders</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
</TablixCells>
|
||||
</TablixRow>
|
||||
</TablixRows>
|
||||
</TablixBody>
|
||||
<TablixColumnHierarchy>
|
||||
<TablixMembers>
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
</TablixMembers>
|
||||
</TablixColumnHierarchy>
|
||||
<TablixRowHierarchy>
|
||||
<TablixMembers>
|
||||
<TablixMember>
|
||||
<KeepWithGroup>After</KeepWithGroup>
|
||||
</TablixMember>
|
||||
<TablixMember>
|
||||
<Group Name="Подробности" />
|
||||
</TablixMember>
|
||||
</TablixMembers>
|
||||
</TablixRowHierarchy>
|
||||
<DataSetName>DataSetOrders</DataSetName>
|
||||
<Top>2.48391cm</Top>
|
||||
<Left>0.55245cm</Left>
|
||||
<Height>1.2cm</Height>
|
||||
<Width>19.84713cm</Width>
|
||||
<ZIndex>2</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>Double</Style>
|
||||
</Border>
|
||||
</Style>
|
||||
</Tablix>
|
||||
<Textbox Name="TextboxTotalSum">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Итого:</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Right</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Top>4cm</Top>
|
||||
<Left>15.39958cm</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="SumTotal">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Sum(Fields!TotalSumOrders.Value, "DataSetOrders")</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Right</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Top>4cm</Top>
|
||||
<Left>17.89958cm</Left>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>2.5cm</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>5.72875cm</Height>
|
||||
<Style />
|
||||
</Body>
|
||||
<Width>21cm</Width>
|
||||
<Page>
|
||||
<PageHeight>29.7cm</PageHeight>
|
||||
<PageWidth>21cm</PageWidth>
|
||||
<LeftMargin>2cm</LeftMargin>
|
||||
<RightMargin>2cm</RightMargin>
|
||||
<TopMargin>2cm</TopMargin>
|
||||
<BottomMargin>2cm</BottomMargin>
|
||||
<ColumnSpacing>0.13cm</ColumnSpacing>
|
||||
<Style />
|
||||
</Page>
|
||||
</ReportSection>
|
||||
</ReportSections>
|
||||
<ReportParameters>
|
||||
<ReportParameter Name="ReportParameterPeriod">
|
||||
<DataType>String</DataType>
|
||||
<Nullable>true</Nullable>
|
||||
<Prompt>ReportParameter1</Prompt>
|
||||
</ReportParameter>
|
||||
</ReportParameters>
|
||||
<ReportParametersLayout>
|
||||
<GridLayoutDefinition>
|
||||
<NumberOfColumns>4</NumberOfColumns>
|
||||
<NumberOfRows>2</NumberOfRows>
|
||||
<CellDefinitions>
|
||||
<CellDefinition>
|
||||
<ColumnIndex>0</ColumnIndex>
|
||||
<RowIndex>0</RowIndex>
|
||||
<ParameterName>ReportParameterPeriod</ParameterName>
|
||||
</CellDefinition>
|
||||
</CellDefinitions>
|
||||
</GridLayoutDefinition>
|
||||
</ReportParametersLayout>
|
||||
<rd:ReportUnitType>Cm</rd:ReportUnitType>
|
||||
<rd:ReportID>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID>
|
||||
</Report>
|
||||
110
FurnitureAssembly/ReportShopFurnituresForm.Designer.cs
generated
Normal file
110
FurnitureAssembly/ReportShopFurnituresForm.Designer.cs
generated
Normal file
@@ -0,0 +1,110 @@
|
||||
namespace FurnitureAssemblyView
|
||||
{
|
||||
partial class ReportShopFurnituresForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.Shop = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Furniture = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ButtonSaveToExcel = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.Shop,
|
||||
this.Furniture,
|
||||
this.Count});
|
||||
this.dataGridView.Location = new System.Drawing.Point(10, 76);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 62;
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(777, 384);
|
||||
this.dataGridView.TabIndex = 4;
|
||||
//
|
||||
// Shop
|
||||
//
|
||||
this.Shop.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.Shop.HeaderText = "Магазин";
|
||||
this.Shop.MinimumWidth = 8;
|
||||
this.Shop.Name = "Shop";
|
||||
//
|
||||
// Furniture
|
||||
//
|
||||
this.Furniture.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.Furniture.HeaderText = "Изделие";
|
||||
this.Furniture.MinimumWidth = 8;
|
||||
this.Furniture.Name = "Furniture";
|
||||
//
|
||||
// Count
|
||||
//
|
||||
this.Count.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
|
||||
this.Count.HeaderText = "Количество";
|
||||
this.Count.MinimumWidth = 8;
|
||||
this.Count.Name = "Count";
|
||||
this.Count.Width = 143;
|
||||
//
|
||||
// ButtonSaveToExcel
|
||||
//
|
||||
this.ButtonSaveToExcel.Location = new System.Drawing.Point(10, 17);
|
||||
this.ButtonSaveToExcel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.ButtonSaveToExcel.Name = "ButtonSaveToExcel";
|
||||
this.ButtonSaveToExcel.Size = new System.Drawing.Size(181, 49);
|
||||
this.ButtonSaveToExcel.TabIndex = 3;
|
||||
this.ButtonSaveToExcel.Text = "Сохранить в Excel";
|
||||
this.ButtonSaveToExcel.UseVisualStyleBackColor = true;
|
||||
this.ButtonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
|
||||
//
|
||||
// ReportShopFurnituresForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 476);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.ButtonSaveToExcel);
|
||||
this.Name = "ReportShopFurnituresForm";
|
||||
this.Text = "Магазины и изделия";
|
||||
this.Load += new System.EventHandler(this.ReportShopFurnituresForm_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn Shop;
|
||||
private DataGridViewTextBoxColumn Furniture;
|
||||
private DataGridViewTextBoxColumn Count;
|
||||
private Button ButtonSaveToExcel;
|
||||
}
|
||||
}
|
||||
87
FurnitureAssembly/ReportShopFurnituresForm.cs
Normal file
87
FurnitureAssembly/ReportShopFurnituresForm.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
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 FurnitureAssemblyView
|
||||
{
|
||||
public partial class ReportShopFurnituresForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportLogic _logic;
|
||||
public ReportShopFurnituresForm(ILogger<ReportShopFurnituresForm> logger, IReportLogic reportLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = reportLogic;
|
||||
}
|
||||
|
||||
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "xlsx|*.xlsx"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveShopFurnituresToExcelFile(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportShopFurnituresForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dict = _logic.GetShopFurnitures();
|
||||
if (dict != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var elem in dict)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" });
|
||||
foreach (var listElem in elem.Furnitures)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
78
FurnitureAssembly/ReportShopFurnituresForm.resx
Normal file
78
FurnitureAssembly/ReportShopFurnituresForm.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="Shop.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Furniture.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="Shop.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Furniture.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>
|
||||
@@ -113,6 +113,7 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
throw new ArgumentNullException("Нет пароля пользователя",
|
||||
nameof(model.Password));
|
||||
}
|
||||
|
||||
if (!Regex.IsMatch(model.Email, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,})+)$"))
|
||||
{
|
||||
throw new ArgumentException("Некорректно введена почта клиента", nameof(model.Email));
|
||||
|
||||
@@ -103,28 +103,28 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException("Нет ФИО исполнителя",
|
||||
nameof(model.ImplementerFIO));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля пользователя",
|
||||
nameof(model.Password));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Password))
|
||||
{
|
||||
throw new ArgumentNullException("Нет пароля пользователя",
|
||||
nameof(model.Password));
|
||||
}
|
||||
|
||||
if (model.WorkExperience < 0)
|
||||
{
|
||||
throw new ArgumentException("Опыт работы не должен быть отрицательным", nameof(model.WorkExperience));
|
||||
}
|
||||
if (model.Qualification < 0)
|
||||
{
|
||||
throw new ArgumentException("Квалификация не должна быть отрицательной", nameof(model.Qualification));
|
||||
}
|
||||
if (model.WorkExperience < 0)
|
||||
{
|
||||
throw new ArgumentException("Опыт работы не должен быть отрицательным", nameof(model.WorkExperience));
|
||||
}
|
||||
if (model.Qualification < 0)
|
||||
{
|
||||
throw new ArgumentException("Квалификация не должна быть отрицательной", nameof(model.Qualification));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Implementer. ImplementerFIO:{ImplementerFIO}. Id: { Id}", model.ImplementerFIO, model.Id);
|
||||
var element = _implementerStorage.GetElement(new ImplementerSearchModel { ImplementerFIO = model.ImplementerFIO });
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Исполнитель с таким логином уже есть");
|
||||
_logger.LogInformation("Implementer. ImplementerFIO:{ImplementerFIO}. Id: { Id}", model.ImplementerFIO, model.Id);
|
||||
var element = _implementerStorage.GetElement(new ImplementerSearchModel { ImplementerFIO = model.ImplementerFIO });
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Исполнитель с таким логином уже есть");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,23 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
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 List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ClientId:{ClientId}. MessageId:{ MessageId}", model?.ClientId, model?.MessageId);
|
||||
@@ -45,5 +62,15 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool Update(MessageInfoBindingModel model)
|
||||
{
|
||||
if (_messageInfoStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AbstractFurnitureAssemblyDataModels.Enums;
|
||||
using FurnitureAssemblyBusinessLogic.MailWorker;
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
@@ -19,16 +20,21 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
private readonly IClientLogic _clientLogic;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IClientLogic clientLogic, AbstractMailWorker abstractMailWorker)
|
||||
private readonly IShopLogic _shopLogic;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IClientLogic clientLogic, AbstractMailWorker abstractMailWorker, IShopLogic shopLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_clientLogic = clientLogic;
|
||||
_mailWorker = abstractMailWorker;
|
||||
_shopLogic = shopLogic;
|
||||
|
||||
}
|
||||
|
||||
private bool ChangeStatus(OrderBindingModel model, OrderStatus orderStatus)
|
||||
{
|
||||
if (model.Status + 1 != orderStatus)
|
||||
if (model.Status + 1 != orderStatus && !(model.Status == OrderStatus.Ожидание && orderStatus == OrderStatus.Готов) && !(model.Status == OrderStatus.Выполняется && orderStatus == OrderStatus.Ожидание))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -36,13 +42,19 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
SendMail(model.ClientId, $"Статус заказа {model.Id} изменен", $"Заказ {model.Id} переведен в статус {model.Status}");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (model.Status != OrderStatus.Неизвестен) return false;
|
||||
model.Status = OrderStatus.Принят;
|
||||
|
||||
if (!ChangeStatus(model, OrderStatus.Принят))
|
||||
{
|
||||
_logger.LogWarning("Order's status is wrong");
|
||||
throw new InvalidOperationException("Order's status is wrong");
|
||||
}
|
||||
var order = _orderStorage.Insert(model);
|
||||
if (order == null) {
|
||||
if (order == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
@@ -50,6 +62,56 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
var modelNew = ReadElement(new OrderSearchModel { Id = model.Id }); // в связи с обновлением контракта, предыдущий метод не нужен
|
||||
if (modelNew == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
model.Status = modelNew.Status;
|
||||
model.ClientId = modelNew.ClientId;
|
||||
if (!ChangeStatus(model, OrderStatus.Выполняется))
|
||||
{
|
||||
_logger.LogWarning("Order's status is wrong");
|
||||
throw new InvalidOperationException("Order's status is wrong");
|
||||
}
|
||||
_orderStorage.Update(model);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
var modelNew = ReadElement(new OrderSearchModel { Id = model.Id }); // в связи с обновлением контракта, предыдущий метод не нужен
|
||||
if (modelNew == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
model.ClientId = modelNew.ClientId;
|
||||
model.ImplementerId = modelNew.ImplementerId;
|
||||
model.Status = modelNew.Status;
|
||||
if (!ChangeStatus(model, OrderStatus.Готов))
|
||||
{
|
||||
_logger.LogWarning("Order's status is wrong");
|
||||
throw new InvalidOperationException("Order's status is wrong");
|
||||
}
|
||||
if (!_shopLogic.AddFurnituresAtShops(new FurnitureBindingModel() { Id = modelNew.FurnitureId }, modelNew.Count))
|
||||
{
|
||||
model.Status--;
|
||||
if (!ChangeStatus(model, OrderStatus.Ожидание))
|
||||
{
|
||||
_logger.LogWarning($"Order's status {model.Status} is wrong");
|
||||
throw new InvalidOperationException("Order's status is wrong");
|
||||
}
|
||||
_orderStorage.Update(model);
|
||||
_logger.LogWarning("There are not empty places at shops. Replenishment is impossible");
|
||||
return false;
|
||||
}
|
||||
model.DateImplement = DateTime.Now;
|
||||
_orderStorage.Update(model);
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
var modelNew = ReadElement(new OrderSearchModel { Id = model.Id }); // в связи с обновлением контракта, предыдущий метод не нужен
|
||||
@@ -57,7 +119,6 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
{
|
||||
return false;
|
||||
}
|
||||
model.Id = modelNew.Id;
|
||||
model.Status = modelNew.Status;
|
||||
model.ClientId = modelNew.ClientId;
|
||||
model.ImplementerId = modelNew.ImplementerId;
|
||||
@@ -72,31 +133,10 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool FinishOrder(OrderBindingModel model)
|
||||
{
|
||||
var modelNew = ReadElement(new OrderSearchModel { Id = model.Id });
|
||||
if (modelNew == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
model.Id = modelNew.Id;
|
||||
model.Status = modelNew.Status;
|
||||
model.ClientId = modelNew.ClientId;
|
||||
model.ImplementerId = modelNew.ImplementerId;
|
||||
if (!ChangeStatus(model, OrderStatus.Готов))
|
||||
{
|
||||
_logger.LogWarning("Order's status is wrong");
|
||||
return false;
|
||||
}
|
||||
model.DateImplement = DateTime.Now;
|
||||
_orderStorage.Update(model);
|
||||
return true;
|
||||
}
|
||||
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. OrderId:{Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
_logger.LogInformation("ReadList. Id:{ Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
@@ -106,54 +146,33 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(OrderBindingModel model)
|
||||
{
|
||||
var modelNew = ReadElement(new OrderSearchModel { Id = model.Id });
|
||||
if (modelNew == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
model.Status = modelNew.Status;
|
||||
model.ClientId = modelNew.ClientId;
|
||||
model.Id = modelNew.Id;
|
||||
if (!ChangeStatus(model, OrderStatus.Выполняется))
|
||||
{
|
||||
_logger.LogWarning("Order's status is wrong");
|
||||
return false;
|
||||
}
|
||||
_orderStorage.Update(model);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (model.FurnitureId < 0)
|
||||
if (model.FurnitureId <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.FurnitureId));
|
||||
throw new ArgumentNullException("Неверный идентификатор изделия", nameof(model.FurnitureId));
|
||||
}
|
||||
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество изделий в заказе должно быть больше 0", nameof(model.Count));
|
||||
throw new ArgumentNullException("Количество изделий должно быть больше 0", nameof(model.Count));
|
||||
}
|
||||
|
||||
if (model.Sum <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
|
||||
throw new ArgumentNullException("Стоимость заказа должна быть больше 0", nameof(model.Sum));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Order. OrderId:{Id}.Sum:{ Sum}. PackageId: { PackageId}", model.Id, model.Sum, model.FurnitureId);
|
||||
_logger.LogInformation("Order. OrderId: { Id}. OrderStatus: {OrderStatus} DateCreate: {DateCreate} " +
|
||||
"FurnitureId:{FurnitureId}. Count:{ Count}. Sum:{ Sum}. ",
|
||||
model.Id, model.Status, model.DateCreate, model.FurnitureId, model.Count, model.Sum);
|
||||
}
|
||||
|
||||
public OrderViewModel? ReadElement(OrderSearchModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
@@ -170,6 +189,7 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
private bool SendMail(int clientId, string subject, string text)
|
||||
{
|
||||
var client = _clientLogic.ReadElement(new() { Id = clientId });
|
||||
|
||||
@@ -15,21 +15,21 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReportLogic : IReportLogic
|
||||
{
|
||||
private readonly IComponentStorage _componentStorage;
|
||||
private readonly IFurnitureStorage _furnitureStorage;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly IShopStorage _shopStorage;
|
||||
private readonly AbstractSaveToExcel _saveToExcel;
|
||||
private readonly AbstractSaveToWord _saveToWord;
|
||||
private readonly AbstractSaveToPdf _saveToPdf;
|
||||
public ReportLogic(IFurnitureStorage furnitureStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
|
||||
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||
public ReportLogic(IFurnitureStorage furnitureStorage, IOrderStorage orderStorage,
|
||||
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf, IShopStorage shopStorage)
|
||||
{
|
||||
_furnitureStorage = furnitureStorage;
|
||||
_componentStorage = componentStorage;
|
||||
_orderStorage = orderStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
_shopStorage = shopStorage;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение списка компонент с указанием, в каких изделиях используются
|
||||
@@ -38,7 +38,6 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
public List<ReportFurnitureComponentViewModel> GetFurnitureComponent()
|
||||
{
|
||||
var furnitures = _furnitureStorage.GetFullList();
|
||||
var components = _componentStorage.GetFullList();
|
||||
var list = new List<ReportFurnitureComponentViewModel>();
|
||||
foreach (var furniture in furnitures)
|
||||
{
|
||||
@@ -48,13 +47,10 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
Components = new List<Tuple<string, int>>(),
|
||||
TotalCount = 0
|
||||
};
|
||||
foreach (var component in components)
|
||||
foreach (var componentCount in furniture.FurnitureComponents.Values)
|
||||
{
|
||||
if (furniture.FurnitureComponents.ContainsKey(component.Id))
|
||||
{
|
||||
record.Components.Add(new Tuple<string, int>(component.ComponentName, furniture.FurnitureComponents[component.Id].Item2));
|
||||
record.TotalCount += furniture.FurnitureComponents[component.Id].Item2;
|
||||
}
|
||||
record.Components.Add(new Tuple<string, int>(componentCount.Item1.ComponentName, componentCount.Item2));
|
||||
record.TotalCount += componentCount.Item2;
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
@@ -88,7 +84,7 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
/// <param name="model"></param>
|
||||
public void SaveFurnituresToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDoc(new WordInfo
|
||||
_saveToWord.CreateDoc(new WordInfoFurnitures
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список изделий",
|
||||
@@ -101,7 +97,7 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
/// <param name="model"></param>
|
||||
public void SaveFurnitureComponentToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelInfo
|
||||
_saveToExcel.CreateReport(new ExcelInfoFurnitures
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список изделий",
|
||||
@@ -114,7 +110,7 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
/// <param name="model"></param>
|
||||
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfo
|
||||
_saveToPdf.CreateDoc(new PdfInfoOrders
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список заказов",
|
||||
@@ -123,5 +119,69 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
Orders = GetOrders(model)
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение магазинов в файл-Word
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void SaveShopsToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateTableDoc(new WordInfoShops
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список магазинов",
|
||||
Shops = _shopStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveShopFurnituresToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelInfoShops
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список магазинов с изделиями",
|
||||
ShopFurnitures = GetShopFurnitures()
|
||||
});
|
||||
}
|
||||
|
||||
public List<ReportShopFurnituresViewModel> GetShopFurnitures()
|
||||
{
|
||||
var shops = _shopStorage.GetFullList();
|
||||
var list = new List<ReportShopFurnituresViewModel>();
|
||||
foreach (var shop in shops)
|
||||
{
|
||||
var record = new ReportShopFurnituresViewModel
|
||||
{
|
||||
ShopName = shop.ShopName,
|
||||
Furnitures = new List<Tuple<string, int>>(),
|
||||
TotalCount = 0
|
||||
};
|
||||
foreach (var furnitureCount in shop.Furnitures.Values)
|
||||
{
|
||||
record.Furnitures.Add(new Tuple<string, int>(furnitureCount.Item1.FurnitureName, furnitureCount.Item2));
|
||||
record.TotalCount += furnitureCount.Item2;
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportCountOrdersViewModel> GetCountOrders()
|
||||
{
|
||||
return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportCountOrdersViewModel
|
||||
{
|
||||
DateCreate = x.Key,
|
||||
CountOrders = x.Count(),
|
||||
TotalSumOrders = x.Sum(y => y.Sum)
|
||||
}).ToList();
|
||||
}
|
||||
public void SaveCountOrdersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfoCountOrders
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список объединенных по дате заказов",
|
||||
CountOrders = GetCountOrders()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
208
FurnitureAssemblyBusinessLogic/BusinessLogics/ShopLogic.cs
Normal file
208
FurnitureAssemblyBusinessLogic/BusinessLogics/ShopLogic.cs
Normal file
@@ -0,0 +1,208 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ShopLogic : IShopLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopStorage _shopStorage;
|
||||
private readonly IFurnitureStorage _furnitureStorage;
|
||||
|
||||
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage, IFurnitureStorage furnitureStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_shopStorage = shopStorage;
|
||||
_furnitureStorage = furnitureStorage;
|
||||
}
|
||||
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 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 bool Create(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_shopStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert 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 Update(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_shopStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
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.ShopName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Address))
|
||||
{
|
||||
throw new ArgumentNullException("Нет адреса магазина", nameof(model.Address));
|
||||
}
|
||||
if (model.DateOpening.Equals(null))
|
||||
{
|
||||
throw new ArgumentNullException("Нет даты открытия магазина", nameof(model.DateOpening));
|
||||
}
|
||||
if (model.MaxCount <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Нет вместимости магазина", nameof(model.DateOpening));
|
||||
}
|
||||
_logger.LogInformation("Shop. ShopName:{ShopName}. Address:{ Address}. DateOpening:{ DateOpening}. Id: { Id}", model.ShopName, model.Address, model.DateOpening, model.Id);
|
||||
var element = _shopStorage.GetElement(new ShopSearchModel { ShopName = model.ShopName });
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddFurniture(ShopBindingModel model, FurnitureBindingModel furnitureModel, int count)
|
||||
{
|
||||
var shop = _shopStorage.GetElement(new ShopSearchModel { Id = model.Id });
|
||||
var furniture = _furnitureStorage.GetElement(new FurnitureSearchModel { Id = furnitureModel.Id });
|
||||
|
||||
if (shop == null || furniture == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (GetCountFreePlaces(model.Id) < count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (shop.Furnitures.ContainsKey(furniture.Id))
|
||||
{
|
||||
int prev_count = shop.Furnitures[furniture.Id].Item2;
|
||||
shop.Furnitures[furniture.Id] = (furniture, prev_count + count);
|
||||
}
|
||||
else
|
||||
{
|
||||
shop.Furnitures[furniture.Id] = (furniture, count);
|
||||
}
|
||||
model.Furnitures = shop.Furnitures;
|
||||
model.DateOpening = shop.DateOpening;
|
||||
model.Address = shop.Address;
|
||||
model.MaxCount = shop.MaxCount;
|
||||
model.ShopName = shop.ShopName;
|
||||
if (_shopStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Replenishment operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private int GetCountFreePlaces(int ShopId)
|
||||
{
|
||||
var shop = ReadElement(new ShopSearchModel { Id = ShopId });
|
||||
if (shop == null)
|
||||
return 0;
|
||||
int count = shop.MaxCount;
|
||||
foreach (var f in shop.Furnitures)
|
||||
{
|
||||
count -= f.Value.Item2;
|
||||
if (count <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private int GetCountFreePlaces_All()
|
||||
{
|
||||
return _shopStorage.GetFullList().Select(x => GetCountFreePlaces(x.Id)).Sum();
|
||||
}
|
||||
|
||||
public bool AddFurnituresAtShops(FurnitureBindingModel furnitureModel, int count)
|
||||
{
|
||||
if (GetCountFreePlaces_All() < count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var shop in _shopStorage.GetFullList())
|
||||
{
|
||||
int countShop = GetCountFreePlaces(shop.Id);
|
||||
if (countShop >= count)
|
||||
{
|
||||
AddFurniture(new() { Id = shop.Id }, furnitureModel, count);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
AddFurniture(new() { Id = shop.Id }, furnitureModel, countShop);
|
||||
}
|
||||
count -= countShop;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Sell(FurnitureBindingModel furnitureBindingModel, int count)
|
||||
{
|
||||
return _shopStorage.Sell(furnitureBindingModel, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,6 @@ using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
{
|
||||
@@ -36,17 +31,29 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
{
|
||||
Status = OrderStatus.Принят
|
||||
});
|
||||
var ordersInWorking = _orderLogic.ReadList(new OrderSearchModel
|
||||
{
|
||||
Status = OrderStatus.Выполняется
|
||||
});
|
||||
var ordersInWaiting = _orderLogic.ReadList(new OrderSearchModel
|
||||
{
|
||||
Status = OrderStatus.Ожидание
|
||||
});
|
||||
// могут остаться заказы в этих статусах, поэтому следует их тоже пустить в работу
|
||||
if (ordersInWorking != null)
|
||||
orders?.AddRange(ordersInWorking);
|
||||
if (ordersInWaiting != null)
|
||||
orders?.AddRange(ordersInWaiting);
|
||||
|
||||
if (orders == null || orders.Count == 0)
|
||||
{
|
||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||
return;
|
||||
}
|
||||
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
||||
|
||||
foreach (var implementer in implementers)
|
||||
{
|
||||
Task.Run(() => WorkerWorkAsync(implementer, orders));
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
@@ -60,33 +67,18 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
foreach (var order in orders)
|
||||
foreach (var order in orders.Where(x => x.Status == OrderStatus.Ожидание && x.ImplementerId == implementer.Id))
|
||||
{
|
||||
try
|
||||
{
|
||||
RunOrderInWork(implementer);
|
||||
_logger.LogDebug("DoWork. Worker {Id} try get order { Order}", implementer.Id, order.Id);
|
||||
// пытаемся назначить заказ на исполнителя
|
||||
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id,
|
||||
ImplementerId = implementer.Id
|
||||
});
|
||||
// делаем работу
|
||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(50,
|
||||
1000) * order.Count);
|
||||
_logger.LogDebug("DoWork. Worker {Id} finish order{ Order} ", implementer.Id, order.Id);
|
||||
_orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id,
|
||||
ImplementerId = implementer.Id
|
||||
Id = order.Id
|
||||
});
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
|
||||
}
|
||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
@@ -100,7 +92,45 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
await RunOrderInWork(implementer);
|
||||
await Task.Run(() =>
|
||||
{
|
||||
foreach (var order in orders.Where(x => x.Status == OrderStatus.Принят))
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogDebug("DoWork. Worker {Id} try get order { Order}", implementer.Id, order.Id);
|
||||
// пытаемся назначить заказ на исполнителя
|
||||
_orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id,
|
||||
ImplementerId = implementer.Id
|
||||
});
|
||||
// делаем работу
|
||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100,
|
||||
1000) * order.Count);
|
||||
_logger.LogDebug("DoWork. Worker {Id} finish order{ Order} ", implementer.Id, order.Id);
|
||||
_orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = order.Id
|
||||
});
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
// заканчиваем выполнение имитации в случае иной ошибки
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -129,14 +159,12 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}",
|
||||
implementer.Id, runOrder.Id);
|
||||
// доделываем работу
|
||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(50, 300) *
|
||||
runOrder.Count);
|
||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * runOrder.Count);
|
||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}",
|
||||
implementer.Id, runOrder.Id);
|
||||
_orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = runOrder.Id,
|
||||
ImplementerId = implementer.Id
|
||||
Id = runOrder.Id
|
||||
});
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
@@ -146,6 +174,48 @@ namespace FurnitureAssemblyBusinessLogic.BusinessLogics
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Ищем заказ, которые находятся в ожидании
|
||||
/// </summary>
|
||||
/// <param name="implementer"></param>
|
||||
/// <returns></returns>
|
||||
private async Task RunOrderInWaiting(ImplementerViewModel implementer)
|
||||
{
|
||||
if (_orderLogic == null || implementer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var runOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
||||
{
|
||||
ImplementerId = implementer.Id,
|
||||
Status = OrderStatus.Ожидание
|
||||
}));
|
||||
if (runOrder == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = runOrder.Id
|
||||
});
|
||||
// отдыхаем
|
||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||
}
|
||||
// заказа может не быть, просто игнорируем ошибку
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogWarning(ex, "Error try get work");
|
||||
}
|
||||
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error while do work");
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.MailWorker
|
||||
{
|
||||
public abstract class AbstractMailWorker
|
||||
{
|
||||
protected string _mailLogin = string.Empty;
|
||||
protected string _mailPassword = string.Empty;
|
||||
protected string _smtpClientHost = string.Empty;
|
||||
protected int _smtpClientPort;
|
||||
protected string _popHost = string.Empty;
|
||||
protected int _popPort;
|
||||
private readonly IMessageInfoLogic _messageInfoLogic;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IClientLogic _clientLogic;
|
||||
public AbstractMailWorker(ILogger<AbstractMailWorker> logger,
|
||||
IMessageInfoLogic messageInfoLogic,
|
||||
IClientLogic clientLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_messageInfoLogic = messageInfoLogic;
|
||||
_clientLogic = clientLogic;
|
||||
}
|
||||
public void MailConfig(MailConfigBindingModel config)
|
||||
{
|
||||
_mailLogin = config.MailLogin;
|
||||
_mailPassword = config.MailPassword;
|
||||
_smtpClientHost = config.SmtpClientHost;
|
||||
_smtpClientPort = config.SmtpClientPort;
|
||||
_popHost = config.PopHost;
|
||||
_popPort = config.PopPort;
|
||||
_logger.LogDebug("Config: {login}, {password}, {clientHost},{ clientPOrt}, { popHost}, { popPort}", _mailLogin, _mailPassword, _smtpClientHost,
|
||||
_smtpClientPort, _popHost, _popPort);
|
||||
}
|
||||
public async void MailSendAsync(MailSendInfoBindingModel 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))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress,
|
||||
info.Subject);
|
||||
await SendMailAsync(info);
|
||||
}
|
||||
public async void MailCheck()
|
||||
{
|
||||
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(_popHost) || _popPort == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_messageInfoLogic == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var list = await ReceiveMailAsync();
|
||||
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
|
||||
foreach (var mail in list)
|
||||
{
|
||||
mail.ClientId = _clientLogic.ReadElement(new() { Email = mail.SenderName })?.Id;
|
||||
_messageInfoLogic.Create(mail);
|
||||
}
|
||||
}
|
||||
protected abstract Task SendMailAsync(MailSendInfoBindingModel info);
|
||||
protected abstract Task<List<MessageInfoBindingModel>> ReceiveMailAsync();
|
||||
}
|
||||
}
|
||||
78
FurnitureAssemblyBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
78
FurnitureAssemblyBusinessLogic/MailWorker/MailKitWorker.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Net.Mail;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using MailKit.Net.Pop3;
|
||||
using MailKit.Security;
|
||||
using FurnitureAssemblyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.MailWorker
|
||||
{
|
||||
public class MailKitWorker : AbstractMailWorker
|
||||
{
|
||||
public MailKitWorker(ILogger<MailKitWorker> logger, IMessageInfoLogic messageInfoLogic, IClientLogic clientLogic) : base(logger, messageInfoLogic, clientLogic) { }
|
||||
protected override async Task SendMailAsync(MailSendInfoBindingModel
|
||||
info)
|
||||
{
|
||||
using var objMailMessage = new MailMessage();
|
||||
using var objSmtpClient = new SmtpClient(_smtpClientHost,_smtpClientPort);
|
||||
try
|
||||
{
|
||||
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;
|
||||
objSmtpClient.UseDefaultCredentials = false;
|
||||
objSmtpClient.EnableSsl = true;
|
||||
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
objSmtpClient.Credentials = new NetworkCredential(_mailLogin,
|
||||
_mailPassword);
|
||||
await Task.Run(() => objSmtpClient.Send(objMailMessage));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
protected override async Task<List<MessageInfoBindingModel>>
|
||||
ReceiveMailAsync()
|
||||
{
|
||||
var list = new List<MessageInfoBindingModel>();
|
||||
using var client = new Pop3Client();
|
||||
await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
client.Connect(_popHost, _popPort, SecureSocketOptions.SslOnConnect);
|
||||
client.Authenticate(_mailLogin, _mailPassword);
|
||||
for (int i = 0; i < client.Count; i++)
|
||||
{
|
||||
var message = client.GetMessage(i);
|
||||
foreach (var mail in message.From.Mailboxes)
|
||||
{
|
||||
list.Add(new MessageInfoBindingModel
|
||||
{
|
||||
DateDelivery = message.Date.DateTime,
|
||||
MessageId = message.MessageId,
|
||||
SenderName = mail.Address,
|
||||
Subject = message.Subject,
|
||||
Body = message.TextBody
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (AuthenticationException)
|
||||
{ }
|
||||
finally
|
||||
{
|
||||
client.Disconnect(true);
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,19 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||
CellToName = "C1"
|
||||
});
|
||||
uint rowIndex = 2;
|
||||
if (info is ExcelInfoFurnitures infoFurnitures)
|
||||
{
|
||||
CreateExcelCellsFurnitures(infoFurnitures, rowIndex);
|
||||
}
|
||||
else if (info is ExcelInfoShops infoShops)
|
||||
{
|
||||
CreateExcelCellsShops(infoShops, rowIndex);
|
||||
}
|
||||
|
||||
SaveExcel(info);
|
||||
}
|
||||
private void CreateExcelCellsFurnitures(ExcelInfoFurnitures info, uint rowIndex)
|
||||
{
|
||||
foreach (var pc in info.FurnitureComponents)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
@@ -76,8 +89,58 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||
});
|
||||
rowIndex++;
|
||||
}
|
||||
SaveExcel(info);
|
||||
}
|
||||
|
||||
private void CreateExcelCellsShops(ExcelInfoShops info, uint rowIndex)
|
||||
{
|
||||
foreach (var sF in info.ShopFurnitures)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = sF.ShopName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
foreach (var furniture in sF.Furnitures)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = furniture.Item1,
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = furniture.Item2.ToString(),
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
rowIndex++;
|
||||
}
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = "Итого",
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = sF.TotalCount.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание excel-файла
|
||||
/// </summary>
|
||||
|
||||
@@ -19,11 +19,26 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
|
||||
if (info is PdfInfoOrders infoOrders)
|
||||
{
|
||||
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateDocOrders(infoOrders);
|
||||
}
|
||||
else if (info is PdfInfoCountOrders countOrders)
|
||||
{
|
||||
CreateDocCountOrders(countOrders);
|
||||
}
|
||||
SavePdf(info);
|
||||
}
|
||||
|
||||
private void CreateDocOrders(PdfInfoOrders info)
|
||||
{
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
@@ -47,7 +62,33 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||
ParagraphAlignment =
|
||||
PdfParagraphAlignmentType.Right
|
||||
});
|
||||
SavePdf(info);
|
||||
}
|
||||
|
||||
private void CreateDocCountOrders(PdfInfoCountOrders info)
|
||||
{
|
||||
CreateTable(new List<string> { "3cm", "3cm", "7cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Дата заказа", "Количество заказов", "Сумма" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var order in info.CountOrders)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { order.DateCreate.ToShortDateString(), order.CountOrders.ToString(), order.TotalSumOrders.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"Итого: {info.CountOrders.Sum(x => x.TotalSumOrders)}\t",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment =
|
||||
PdfParagraphAlignmentType.Right
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание doc-файла
|
||||
|
||||
@@ -6,6 +6,49 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToWord
|
||||
{
|
||||
public void CreateTableDoc(WordInfo wordInfo)
|
||||
{
|
||||
CreateWord(wordInfo);
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (wordInfo.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
WordTable wordTable = new();
|
||||
if (wordInfo is WordInfoShops infoShops)
|
||||
{
|
||||
wordTable = CreateTableDocShops(infoShops);
|
||||
}
|
||||
CreateTable(wordTable);
|
||||
|
||||
SaveWord(wordInfo);
|
||||
|
||||
}
|
||||
private WordTable CreateTableDocShops(WordInfoShops wordInfo)
|
||||
{
|
||||
var list = new List<string>();
|
||||
foreach (var shop in wordInfo.Shops)
|
||||
{
|
||||
list.Add(shop.ShopName);
|
||||
list.Add(shop.Address);
|
||||
list.Add(shop.DateOpening.ToString());
|
||||
}
|
||||
|
||||
var wordTable = new WordTable
|
||||
{
|
||||
Headers = new List<string> {
|
||||
"Название",
|
||||
"Адрес",
|
||||
"Дата открытия"},
|
||||
Texts = list
|
||||
};
|
||||
return wordTable;
|
||||
}
|
||||
|
||||
public void CreateDoc(WordInfo info)
|
||||
{
|
||||
CreateWord(info);
|
||||
@@ -18,20 +61,23 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
foreach (var furniture in info.Furnitures)
|
||||
if (info is WordInfoFurnitures infoFurnitures)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
foreach (var furniture in infoFurnitures.Furnitures)
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (furniture.FurnitureName,
|
||||
new WordTextProperties { Size = "24", Bold=true}),
|
||||
(" - " + furniture.Price.ToString(), new WordTextProperties { Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
Texts = new List<(string, WordTextProperties)> { (furniture.FurnitureName,
|
||||
new WordTextProperties { Size = "24", Bold=true}), (" - " + furniture.Price.ToString(),
|
||||
new WordTextProperties { Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
SaveWord(info);
|
||||
}
|
||||
@@ -40,6 +86,7 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void CreateWord(WordInfo info);
|
||||
protected abstract void CreateTable(WordTable info);
|
||||
/// <summary>
|
||||
/// Создание абзаца с текстом
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfoFurnitures : ExcelInfo
|
||||
{
|
||||
public List<ReportFurnitureComponentViewModel> FurnitureComponents
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfoShops : ExcelInfo
|
||||
{
|
||||
public List<ReportShopFurnituresViewModel> ShopFurnitures
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfInfoCountOrders : PdfInfo
|
||||
{
|
||||
public List<ReportCountOrdersViewModel> CountOrders { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfInfoOrders : PdfInfo
|
||||
{
|
||||
public List<ReportOrdersViewModel> Orders { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordInfoFurnitures : WordInfo
|
||||
{
|
||||
public List<FurnitureViewModel> Furnitures { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordInfoShops : WordInfo
|
||||
{
|
||||
public List<ShopViewModel> Shops { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
|
||||
namespace FurnitureAssemblyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordTable
|
||||
{
|
||||
public List<string> Headers { get; set; } = new();
|
||||
public List<string> Texts { get; set; } = new ();
|
||||
}
|
||||
}
|
||||
@@ -122,5 +122,90 @@ namespace FurnitureAssemblyBusinessLogic.OfficePackage.Implements
|
||||
_wordDocument.MainDocumentPart!.Document.Save();
|
||||
_wordDocument.Close();
|
||||
}
|
||||
|
||||
protected override void CreateTable(WordTable table)
|
||||
{
|
||||
if (_docBody == null || table == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Table tab = new Table();
|
||||
TableProperties props = new TableProperties(
|
||||
new TableBorders(
|
||||
new TopBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new BottomBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new LeftBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new RightBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideHorizontalBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideVerticalBorder
|
||||
{
|
||||
Val = new EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
}
|
||||
)
|
||||
);
|
||||
tab.AppendChild<TableProperties>(props);
|
||||
// разметка сетки таблицы
|
||||
TableGrid tableGrid = new TableGrid();
|
||||
for (int i = 0; i < table.Headers.Count; i++)
|
||||
{
|
||||
tableGrid.AppendChild(new GridColumn());
|
||||
}
|
||||
tab.AppendChild(tableGrid);
|
||||
TableRow tableRow = new TableRow();
|
||||
// заполнение заголовков
|
||||
foreach (var text in table.Headers)
|
||||
{
|
||||
tableRow.AppendChild(CreateTableCell(text));
|
||||
}
|
||||
tab.AppendChild(tableRow);
|
||||
// заполнение содержимым
|
||||
int height = table.Texts.Count / table.Headers.Count;
|
||||
int width = table.Headers.Count;
|
||||
for (int i = 0; i < height; i++)
|
||||
{
|
||||
tableRow = new TableRow();
|
||||
for (int j = 0; j < width; j++)
|
||||
{
|
||||
var element = table.Texts[i * table.Headers.Count + j];
|
||||
tableRow.AppendChild(CreateTableCell(element));
|
||||
}
|
||||
tab.AppendChild(tableRow);
|
||||
}
|
||||
|
||||
_docBody.AppendChild(tab);
|
||||
|
||||
}
|
||||
|
||||
private TableCell CreateTableCell(string element)
|
||||
{
|
||||
var tableParagraph = new Paragraph();
|
||||
var run = new Run();
|
||||
run.AppendChild(new Text { Text = element });
|
||||
tableParagraph.AppendChild(run);
|
||||
var tableCell = new TableCell();
|
||||
tableCell.AppendChild(tableParagraph);
|
||||
return tableCell;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +145,7 @@ namespace FurnitureAssemblyClientApp.Controllers
|
||||
);
|
||||
return count * (prod?.Price ?? 1);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Mails()
|
||||
{
|
||||
|
||||
@@ -10,34 +10,58 @@ ViewData["Title"] = "Mails";
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Дата письма</th>
|
||||
<th>Заголовок</th>
|
||||
<th>Текст</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Дата письма</th>
|
||||
<th>Заголовок</th>
|
||||
<th>Текст</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>
|
||||
item.DateDelivery)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Subject)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>item.Body)
|
||||
</td>
|
||||
</tr>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Subject)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem =>item.Body)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</tbody>
|
||||
</table>
|
||||
@if (ViewBag.TotalPages > 1)
|
||||
{
|
||||
<div class="pagination">
|
||||
@if (ViewBag.CurrentPage > 1)
|
||||
{
|
||||
<a href="@Url.Action("Mails", new { page = ViewBag.CurrentPage - 1 })">Previous</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Previous</span>
|
||||
}
|
||||
|
||||
@if (ViewBag.CurrentPage < ViewBag.TotalPages)
|
||||
{
|
||||
<a href="@Url.Action("Mails", new { page = ViewBag.CurrentPage + 1 })">Next</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Next</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
}
|
||||
</div>
|
||||
@@ -30,6 +30,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Mails">Письма</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Mails">Письма</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asparea="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
</li>
|
||||
|
||||
29
FurnitureAssemblyContracts/Attributes/ColumnAttribute.cs
Normal file
29
FurnitureAssemblyContracts/Attributes/ColumnAttribute.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace FurnitureAssemblyContracts.Attributes
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Property)]
|
||||
public class ColumnAttribute : Attribute
|
||||
{
|
||||
public ColumnAttribute(string title = "", bool visible = true, int width
|
||||
= 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool
|
||||
isUseAutoSize = false, string formatter = "")
|
||||
{
|
||||
Title = title;
|
||||
Visible = visible;
|
||||
Width = width;
|
||||
GridViewAutoSize = gridViewAutoSize;
|
||||
IsUseAutoSize = isUseAutoSize;
|
||||
Formatter = formatter;
|
||||
|
||||
}
|
||||
public string Title { get; private set; }
|
||||
public bool Visible { get; private set; }
|
||||
public int Width { get; private set; }
|
||||
public GridViewAutoSize GridViewAutoSize { get; private set; }
|
||||
public bool IsUseAutoSize { get; private set; }
|
||||
public bool IsFormatable => !string.IsNullOrEmpty(Formatter) ;
|
||||
public string Formatter { get; private set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
14
FurnitureAssemblyContracts/Attributes/GridViewAutoSize.cs
Normal file
14
FurnitureAssemblyContracts/Attributes/GridViewAutoSize.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace FurnitureAssemblyContracts.Attributes
|
||||
{
|
||||
public enum GridViewAutoSize
|
||||
{
|
||||
NotSet = 0,
|
||||
None = 1,
|
||||
ColumnHeader = 2,
|
||||
AllCellsExceptHeader = 4,
|
||||
AllCells = 6,
|
||||
DisplayedCellsExceptHeader = 8,
|
||||
DisplayedCells = 10,
|
||||
Fill = 16
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -20,5 +20,9 @@ namespace FurnitureAssemblyContracts.BindingModels
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
public string Body { get; set; } = string.Empty;
|
||||
|
||||
public string? Reply { get; set; }
|
||||
public bool IsRead { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
22
FurnitureAssemblyContracts/BindingModels/ShopBindingModel.cs
Normal file
22
FurnitureAssemblyContracts/BindingModels/ShopBindingModel.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BindingModels
|
||||
{
|
||||
public class ShopBindingModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateOpening { get; set; }
|
||||
public int MaxCount { get; set; }
|
||||
|
||||
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,9 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IMessageInfoLogic
|
||||
{
|
||||
MessageInfoViewModel? ReadElement(MessageInfoSearchModel model);
|
||||
List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model);
|
||||
bool Create(MessageInfoBindingModel model);
|
||||
bool Update(MessageInfoBindingModel model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
OrderViewModel? ReadElement(OrderSearchModel? model);
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
|
||||
@@ -31,5 +31,15 @@ namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||
void SaveShopsToWordFile(ReportBindingModel model);
|
||||
void SaveShopFurnituresToExcelFile(ReportBindingModel model);
|
||||
List<ReportShopFurnituresViewModel> GetShopFurnitures();
|
||||
/// <summary>
|
||||
/// Получение объединенных по дате заказов за определенный период
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
List<ReportCountOrdersViewModel> GetCountOrders();
|
||||
void SaveCountOrdersToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.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 AddFurniture(ShopBindingModel model, FurnitureBindingModel furnitureModel, int count);
|
||||
bool AddFurnituresAtShops(FurnitureBindingModel furnitureModel, int count);
|
||||
bool Sell(FurnitureBindingModel furnitureModel, int count);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
namespace FurnitureAssemblyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IWorkProcess
|
||||
{
|
||||
|
||||
71
FurnitureAssemblyContracts/DI/DependencyManager.cs
Normal file
71
FurnitureAssemblyContracts/DI/DependencyManager.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FurnitureAssemblyContracts.DI
|
||||
{
|
||||
public class DependencyManager
|
||||
{
|
||||
private readonly IDependencyContainer _dependencyManager;
|
||||
private static DependencyManager? _manager;
|
||||
private static readonly object _locjObject = new();
|
||||
private DependencyManager()
|
||||
{
|
||||
_dependencyManager = new ServiceDependencyContainer();
|
||||
}
|
||||
public static DependencyManager Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_manager == null) { lock (_locjObject) { _manager = new DependencyManager(); } }
|
||||
return
|
||||
_manager;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Иницализация библиотек, в которых идут установки зависомстей
|
||||
/// </summary>
|
||||
public static void InitDependency()
|
||||
{
|
||||
var ext = ServiceProviderLoader.GetImplementationExtensions();
|
||||
if (ext == null)
|
||||
{
|
||||
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям (хранилище)");
|
||||
}
|
||||
// регистрируем зависимости
|
||||
ext.RegisterServices();
|
||||
|
||||
var extBL = ServiceProviderLoader.GetImplementationBusinessLogicExtensions();
|
||||
if (extBL == null)
|
||||
{
|
||||
throw new ArgumentNullException("Отсутствуют компоненты для загрузки зависимостей по модулям (бизнес-логика)");
|
||||
}
|
||||
extBL.RegisterServices();
|
||||
}
|
||||
/// <summary>
|
||||
/// Регистрация логгера
|
||||
/// </summary>
|
||||
/// <param name="configure"></param>
|
||||
public void AddLogging(Action<ILoggingBuilder> configure) =>
|
||||
_dependencyManager.AddLogging(configure);
|
||||
/// <summary>
|
||||
/// Добавление зависимости
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="U"></typeparam>
|
||||
public void RegisterType<T, U>(bool isSingle = false) where U :
|
||||
class, T where T : class => _dependencyManager.RegisterType<T, U>(isSingle);
|
||||
/// <summary>
|
||||
/// Добавление зависимости
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="U"></typeparam>
|
||||
public void RegisterType<T>(bool isSingle = false) where T : class =>
|
||||
_dependencyManager.RegisterType<T>(isSingle);
|
||||
/// <summary>
|
||||
/// Получение класса со всеми зависмостями
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
public T Resolve<T>() => _dependencyManager.Resolve<T>();
|
||||
|
||||
}
|
||||
}
|
||||
34
FurnitureAssemblyContracts/DI/IDependencyContainer.cs
Normal file
34
FurnitureAssemblyContracts/DI/IDependencyContainer.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FurnitureAssemblyContracts.DI
|
||||
{
|
||||
public interface IDependencyContainer
|
||||
{
|
||||
/// <summary>
|
||||
/// Регистрация логгера
|
||||
/// </summary>
|
||||
/// <param name="configure"></param>
|
||||
void AddLogging(Action<ILoggingBuilder> configure);
|
||||
/// <summary>
|
||||
/// Добавление зависимости
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="U"></typeparam>
|
||||
/// <param name="isSingle"></param>
|
||||
void RegisterType<T, U>(bool isSingle) where U : class, T where T :
|
||||
class;
|
||||
/// <summary>
|
||||
/// Добавление зависимости
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="isSingle"></param>
|
||||
void RegisterType<T>(bool isSingle) where T : class;
|
||||
/// <summary>
|
||||
/// Получение класса со всеми зависмостями
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <returns></returns>
|
||||
T Resolve<T>();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace FurnitureAssemblyContracts.DI
|
||||
{
|
||||
public interface IImplementationBusinessLogicExtension : IImplementationExtension
|
||||
{
|
||||
}
|
||||
}
|
||||
11
FurnitureAssemblyContracts/DI/IImplementationExtension.cs
Normal file
11
FurnitureAssemblyContracts/DI/IImplementationExtension.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace FurnitureAssemblyContracts.DI
|
||||
{
|
||||
public interface IImplementationExtension
|
||||
{
|
||||
public int Priority { get; }
|
||||
/// <summary>
|
||||
/// Регистрация сервисов
|
||||
/// </summary>
|
||||
public void RegisterServices();
|
||||
}
|
||||
}
|
||||
57
FurnitureAssemblyContracts/DI/ServiceDependencyContainer.cs
Normal file
57
FurnitureAssemblyContracts/DI/ServiceDependencyContainer.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace FurnitureAssemblyContracts.DI
|
||||
{
|
||||
public class ServiceDependencyContainer : IDependencyContainer
|
||||
{
|
||||
private ServiceProvider? _serviceProvider;
|
||||
|
||||
private readonly ServiceCollection _serviceCollection;
|
||||
|
||||
public ServiceDependencyContainer()
|
||||
{
|
||||
_serviceCollection = new ServiceCollection();
|
||||
}
|
||||
|
||||
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||
{
|
||||
_serviceCollection.AddLogging(configure);
|
||||
}
|
||||
|
||||
public void RegisterType<T, U>(bool isSingle) where U : class, T where T : class
|
||||
{
|
||||
if (isSingle)
|
||||
{
|
||||
_serviceCollection.AddSingleton<T, U>();
|
||||
}
|
||||
else
|
||||
{
|
||||
_serviceCollection.AddTransient<T, U>();
|
||||
}
|
||||
_serviceProvider = null;
|
||||
}
|
||||
|
||||
public void RegisterType<T>(bool isSingle) where T : class
|
||||
{
|
||||
if (isSingle)
|
||||
{
|
||||
_serviceCollection.AddSingleton<T>();
|
||||
}
|
||||
else
|
||||
{
|
||||
_serviceCollection.AddTransient<T>();
|
||||
}
|
||||
_serviceProvider = null;
|
||||
}
|
||||
|
||||
public T Resolve<T>()
|
||||
{
|
||||
if (_serviceProvider == null)
|
||||
{
|
||||
_serviceProvider = _serviceCollection.BuildServiceProvider();
|
||||
}
|
||||
return _serviceProvider.GetService<T>()!;
|
||||
}
|
||||
}
|
||||
}
|
||||
99
FurnitureAssemblyContracts/DI/ServiceProviderLoader.cs
Normal file
99
FurnitureAssemblyContracts/DI/ServiceProviderLoader.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace FurnitureAssemblyContracts.DI
|
||||
{
|
||||
public static partial class ServiceProviderLoader
|
||||
{
|
||||
/// <summary>
|
||||
/// Загрузка всех классов-реализаций IImplementationExtension
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IImplementationExtension? GetImplementationExtensions()
|
||||
{
|
||||
IImplementationExtension? source = null;
|
||||
var files = Directory.GetFiles(TryGetImplementationExtensionsFolder(), "*.dll",
|
||||
SearchOption.AllDirectories);
|
||||
foreach (var file in files.Distinct())
|
||||
{
|
||||
Assembly asm = Assembly.LoadFrom(file);
|
||||
foreach (var t in asm.GetExportedTypes())
|
||||
{
|
||||
if (t.IsClass &&
|
||||
typeof(IImplementationExtension).IsAssignableFrom(t))
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
source = (IImplementationExtension)Activator.CreateInstance(t)!;
|
||||
}
|
||||
else
|
||||
{
|
||||
var newSource = (IImplementationExtension)Activator.CreateInstance(t)!;
|
||||
if (newSource.Priority > source.Priority)
|
||||
{
|
||||
source = newSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return source;
|
||||
}
|
||||
private static string TryGetImplementationExtensionsFolder()
|
||||
{
|
||||
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||
while (directory != null && !directory.GetDirectories("ImplementationExtensions",
|
||||
SearchOption.AllDirectories).Any(x => x.Name == "ImplementationExtensions"))
|
||||
{
|
||||
directory = directory.Parent;
|
||||
}
|
||||
return $"{directory?.FullName}\\ImplementationExtensions";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загрузка всех классов-реализаций IImplementationBLExtension (бизнес-логика)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static IImplementationBusinessLogicExtension? GetImplementationBusinessLogicExtensions()
|
||||
{
|
||||
IImplementationBusinessLogicExtension? source = null;
|
||||
var files = Directory.GetFiles(TryGetImplementationBLExtensionsFolder(), "*.dll",
|
||||
SearchOption.AllDirectories);
|
||||
foreach (var file in files.Distinct())
|
||||
{
|
||||
Assembly asm = Assembly.LoadFrom(file);
|
||||
foreach (var t in asm.GetExportedTypes())
|
||||
{
|
||||
if (t.IsClass &&
|
||||
typeof(IImplementationBusinessLogicExtension).IsAssignableFrom(t))
|
||||
{
|
||||
|
||||
if (source == null)
|
||||
{
|
||||
source = (IImplementationBusinessLogicExtension)Activator.CreateInstance(t)!;
|
||||
}
|
||||
else
|
||||
{
|
||||
var newSource = (IImplementationBusinessLogicExtension)Activator.CreateInstance(t)!;
|
||||
if (newSource.Priority > source.Priority)
|
||||
{
|
||||
source = newSource;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return source;
|
||||
}
|
||||
private static string TryGetImplementationBLExtensionsFolder()
|
||||
{
|
||||
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||
while (directory != null && !directory.GetDirectories("ImplementationBLExtensions",
|
||||
SearchOption.AllDirectories).Any(x => x.Name == "ImplementationBLExtensions"))
|
||||
{
|
||||
directory = directory.Parent;
|
||||
}
|
||||
return $"{directory?.FullName}\\ImplementationBLExtensions";
|
||||
}
|
||||
}
|
||||
}
|
||||
52
FurnitureAssemblyContracts/DI/UnityDependencyContainer.cs
Normal file
52
FurnitureAssemblyContracts/DI/UnityDependencyContainer.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Unity;
|
||||
using Unity.Microsoft.Logging;
|
||||
|
||||
namespace FurnitureAssemblyContracts.DI
|
||||
{
|
||||
public class UnityDependencyContainer : IDependencyContainer
|
||||
{
|
||||
private readonly IUnityContainer container;
|
||||
|
||||
public UnityDependencyContainer()
|
||||
{
|
||||
container = new UnityContainer();
|
||||
}
|
||||
|
||||
public void AddLogging(Action<ILoggingBuilder> configure)
|
||||
{
|
||||
// регистрируем логгер в контейнере
|
||||
var factory = LoggerFactory.Create(configure);
|
||||
container.AddExtension(new LoggingExtension(factory));
|
||||
}
|
||||
|
||||
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>();
|
||||
}
|
||||
|
||||
void IDependencyContainer.RegisterType<T, U>(bool isSingle)
|
||||
{
|
||||
if (isSingle)
|
||||
{
|
||||
container.RegisterSingleton<T, U>();
|
||||
}
|
||||
else
|
||||
{
|
||||
container.RegisterType<T, U>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
14
FurnitureAssemblyContracts/SearchModels/ShopSearchModel.cs
Normal file
14
FurnitureAssemblyContracts/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 FurnitureAssemblyContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ShopName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,6 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
{
|
||||
|
||||
@@ -15,5 +15,7 @@ namespace FurnitureAssemblyContracts.StoragesContracts
|
||||
List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model);
|
||||
MessageInfoViewModel? GetElement(MessageInfoSearchModel model);
|
||||
MessageInfoViewModel? Insert(MessageInfoBindingModel model);
|
||||
MessageInfoViewModel? Update(MessageInfoBindingModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
18
FurnitureAssemblyContracts/StoragesContracts/IShopStorage.cs
Normal file
18
FurnitureAssemblyContracts/StoragesContracts/IShopStorage.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
|
||||
|
||||
namespace FurnitureAssemblyContracts.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 Sell(FurnitureBindingModel furnitureBindingModel, int count);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using FurnitureAssemblyContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -11,11 +12,11 @@ namespace FurnitureAssemblyContracts.ViewModels
|
||||
public class ClientViewModel : IClientModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("ФИО клиента")]
|
||||
[Column(title: "ФИО клиента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Логин (эл. почта)")]
|
||||
[Column(title: "Логин (эл. почта)", width: 150)]
|
||||
public string Email { get; set; } = string.Empty;
|
||||
[DisplayName("Пароль")]
|
||||
[Column(title: "Пароль", width: 150)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using FurnitureAssemblyContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -11,9 +12,9 @@ namespace FurnitureAssemblyContracts.ViewModels
|
||||
public class ComponentViewModel : IComponentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название компонента")]
|
||||
[Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
[Column(title: "Цена", width: 70)]
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using FurnitureAssemblyContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -11,10 +12,11 @@ namespace FurnitureAssemblyContracts.ViewModels
|
||||
public class FurnitureViewModel : IFurnitureModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название изделия")]
|
||||
[Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string FurnitureName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
[Column(title: "Цена", width: 70)]
|
||||
public double Price { get; set; }
|
||||
[Column(visible: false)]
|
||||
public Dictionary<int, (IComponentModel, int)> FurnitureComponents { get; set; } = new();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using FurnitureAssemblyContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -11,14 +12,13 @@ namespace FurnitureAssemblyContracts.ViewModels
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Пароль")]
|
||||
[Column(title: "Пароль", width: 150)]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[DisplayName("Опыт работы")]
|
||||
[Column(title: "Опыт работы", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[DisplayName("Квалификация")]
|
||||
[Column(title: "Квалификация", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using FurnitureAssemblyDataModels.Models;
|
||||
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using FurnitureAssemblyContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -10,8 +12,9 @@ namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class MessageInfoViewModel : IMessageInfoModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
|
||||
[Column(visible: false)]
|
||||
public int? ClientId { get; set; }
|
||||
[DisplayName("Отправитель")]
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
@@ -21,5 +24,9 @@ namespace FurnitureAssemblyContracts.ViewModels
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
[DisplayName("Текст")]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
[DisplayName("Прочитано")]
|
||||
public bool IsRead { get; set; }
|
||||
[DisplayName("Ответ")]
|
||||
public string? Reply { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using AbstractFurnitureAssemblyDataModels.Enums;
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using FurnitureAssemblyContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -11,27 +12,29 @@ namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
[Column(title: "Номер", width: 50)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column(visible: false)]
|
||||
public int FurnitureId { get; set; }
|
||||
[DisplayName("Изделие")]
|
||||
public string FurnitureName { get; set; } //= string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
[Column(title: "Изделие", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string FurnitureName { get; set; } = string.Empty;
|
||||
[Column(title: "Количество", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
[Column(title: "Сумма", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Статус")]
|
||||
[Column(title: "Статус", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[DisplayName("Дата создания")]
|
||||
[Column(title: "Дата создания", width: 100)]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Дата выполнения")]
|
||||
[Column(title: "Дата выполнения", width: 100)]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
[Column(visible: false)]
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Клиент")]
|
||||
[Column(title: "Клиент", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[Column(visible: false)]
|
||||
public int? ImplementerId { get; set; }
|
||||
[DisplayName("Исполнитель")]
|
||||
[Column(title: "Исполнитель", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string? ImplementerFIO { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class ReportCountOrdersViewModel
|
||||
{
|
||||
public DateTime DateCreate { get; set; }
|
||||
public int CountOrders { get; set; }
|
||||
public double TotalSumOrders { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class ReportShopFurnituresViewModel
|
||||
{
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
public int TotalCount { get; set; }
|
||||
public List<Tuple<string, int>> Furnitures { get; set; } = new();
|
||||
}
|
||||
}
|
||||
25
FurnitureAssemblyContracts/ViewModels/ShopViewModel.cs
Normal file
25
FurnitureAssemblyContracts/ViewModels/ShopViewModel.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using AbstractFurnitureAssemblyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название магазина")]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
[DisplayName("Адрес магазина")]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpening { get; set; }
|
||||
[DisplayName("Вместимость")]
|
||||
public int MaxCount { get; set; }
|
||||
|
||||
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ namespace FurnitureAssemblyDatabaseImplement
|
||||
{
|
||||
if (optionsBuilder.IsConfigured == false)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-T89D4FU;Encrypt=False;Integrated Security=True;User ID=DESKTOP-T89D4FU\Alena; Initial Catalog=FurnitureAssemblyDatabase;");
|
||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-T89D4FU;Encrypt=False;Integrated Security=True;User ID=DESKTOP-T89D4FU\Alena; Initial Catalog=FurnitureAssemblyHardDatabase;");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
@@ -26,9 +26,10 @@ namespace FurnitureAssemblyDatabaseImplement
|
||||
public virtual DbSet<FurnitureComponent> FurnitureComponents { set; get; }
|
||||
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<Shop> Shops { set; get; }
|
||||
public virtual DbSet<ShopFurniture> ShopFurniture { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
public virtual DbSet<Implementer> Implementers { set; get; }
|
||||
|
||||
public virtual DbSet<MessageInfo> Messages { set; get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Threading.Tasks;
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class FurnitureStorage : IFurnitureStorage
|
||||
|
||||
{
|
||||
public List<FurnitureViewModel> GetFullList()
|
||||
{
|
||||
@@ -25,87 +26,90 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FurnitureName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Furnitures
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.FurnitureName.Contains(model.FurnitureName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<FurnitureViewModel> GetFilteredList(FurnitureSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FurnitureName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Furnitures
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.FurnitureName.Contains(model.FurnitureName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public FurnitureViewModel? GetElement(FurnitureSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FurnitureName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Furnitures
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.FurnitureName) && x.FurnitureName == model.FurnitureName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public FurnitureViewModel? GetElement(FurnitureSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.FurnitureName) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Furnitures
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.FurnitureName) &&
|
||||
x.FurnitureName == model.FurnitureName) ||
|
||||
(model.Id.HasValue && x.Id ==
|
||||
model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
public FurnitureViewModel? Insert(FurnitureBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var newProduct = Furniture.Create(context, model);
|
||||
if (newProduct == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Furnitures.Add(newProduct);
|
||||
context.SaveChanges();
|
||||
return newProduct.GetViewModel;
|
||||
}
|
||||
public FurnitureViewModel? Update(FurnitureBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var product = context.Furnitures.FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (product == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
product.Update(model);
|
||||
context.SaveChanges();
|
||||
product.UpdateComponents(context, model);
|
||||
transaction.Commit();
|
||||
return product.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public FurnitureViewModel? Delete(FurnitureBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Furnitures.Include(x => x.Components)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Furnitures.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Insert(FurnitureBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var newFurniture = Furniture.Create(context, model);
|
||||
if (newFurniture == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Furnitures.Add(newFurniture);
|
||||
context.SaveChanges();
|
||||
return newFurniture.GetViewModel;
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Update(FurnitureBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var Furniture = context.Furnitures.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (Furniture == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Furniture.Update(model);
|
||||
context.SaveChanges();
|
||||
Furniture.UpdateComponents(context, model);
|
||||
transaction.Commit();
|
||||
return Furniture.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public FurnitureViewModel? Delete(FurnitureBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Furnitures
|
||||
.Include(x => x.Components)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Furnitures.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,6 @@ using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
@@ -33,7 +35,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Messages
|
||||
.Where(x => x.ClientId == (model.ClientId))
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@@ -58,5 +60,18 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return newMessage.GetViewModel;
|
||||
}
|
||||
|
||||
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Messages.FirstOrDefault(x => x.MessageId.Equals(model.MessageId));
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
element.Update(model);
|
||||
context.SaveChanges();
|
||||
return context.Messages.FirstOrDefault(x => x.MessageId.Equals(model.MessageId))?.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,19 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order != null)
|
||||
{
|
||||
context.Orders.Remove(order);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == order.Id)?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue && (!model.ImplementerId.HasValue || !model.Status.HasValue))
|
||||
@@ -22,6 +35,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
return new();
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x =>
|
||||
@@ -38,6 +52,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
|
||||
if (!model.Id.HasValue && (!model.DateFrom.HasValue || !model.DateTo.HasValue) && !model.ClientId.HasValue && !model.Status.HasValue)
|
||||
{
|
||||
return new();
|
||||
@@ -46,7 +61,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
if (model.Id.HasValue)
|
||||
{
|
||||
return context.Orders
|
||||
.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer)
|
||||
.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
@@ -71,7 +86,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
return context.Orders
|
||||
.Include(x => x.Furniture)
|
||||
.Include(x => x.Client)
|
||||
.Include(x => x.Implementer)
|
||||
.Include(x => x.Implementer)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
@@ -86,6 +101,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
}
|
||||
context.Orders.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
|
||||
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == newOrder.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
@@ -101,18 +117,5 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == order.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var order = context.Orders.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order != null)
|
||||
{
|
||||
context.Orders.Remove(order);
|
||||
context.SaveChanges();
|
||||
return context.Orders.Include(x => x.Furniture).Include(x => x.Client).Include(x => x.Implementer).FirstOrDefault(x => x.Id == order.Id)?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
178
FurnitureAssemblyDatabaseImplement/Implements/ShopStorage.cs
Normal file
178
FurnitureAssemblyDatabaseImplement/Implements/ShopStorage.cs
Normal file
@@ -0,0 +1,178 @@
|
||||
using FurnitureAssemblyContracts.BindingModels;
|
||||
using FurnitureAssemblyContracts.SearchModels;
|
||||
using FurnitureAssemblyContracts.StoragesContracts;
|
||||
using FurnitureAssemblyContracts.ViewModels;
|
||||
using FurnitureAssemblyDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) &&
|
||||
!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Shops
|
||||
.Include(x => x.ShopFurnitures)
|
||||
.ThenInclude(x => x.Furniture)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) &&
|
||||
x.ShopName == model.ShopName) ||
|
||||
(model.Id.HasValue && x.Id ==
|
||||
model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Shops
|
||||
.Include(x => x.ShopFurnitures)
|
||||
.ThenInclude(x => x.Furniture)
|
||||
.Where(x => x.ShopName.Contains(model.ShopName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
return context.Shops
|
||||
.Include(x => x.ShopFurnitures)
|
||||
.ThenInclude(x => x.Furniture)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
var element = context.Shops.Include(x => x.ShopFurnitures).FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Shops.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var newShop = Shop.Create(context, model);
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (GetElement(new ShopSearchModel { ShopName = newShop.ShopName }) != null)
|
||||
{
|
||||
throw new Exception("Магазин с таким названием уже есть");
|
||||
}
|
||||
|
||||
context.Shops.Add(newShop);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool Sell(FurnitureBindingModel furniture, int count)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
foreach (var shop in context.Shops.Include(x => x.ShopFurnitures).ThenInclude(x => x.Furniture).ToList())
|
||||
{
|
||||
if (shop.Furnitures.ContainsKey(furniture.Id))
|
||||
{
|
||||
if (shop.Furnitures[furniture.Id].Item2 >= count)
|
||||
{
|
||||
shop.Furnitures[furniture.Id] = (shop.Furnitures[furniture.Id].Item1, shop.Furnitures[furniture.Id].Item2 - count);
|
||||
count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
count -= shop.Furnitures[furniture.Id].Item2;
|
||||
shop.Furnitures[furniture.Id] = (shop.Furnitures[furniture.Id].Item1, 0);
|
||||
}
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = shop.Id,
|
||||
ShopName = shop.ShopName,
|
||||
MaxCount = shop.MaxCount,
|
||||
Furnitures = shop.Furnitures,
|
||||
Address = shop.Address,
|
||||
DateOpening = shop.DateOpening
|
||||
};
|
||||
shop.Update(model);
|
||||
shop.UpdateFurnitures(context, model);
|
||||
if (count == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (count == 0)
|
||||
{
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
using var context = new FurnitureAssemblyDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var shop = context.Shops.FirstOrDefault(rec =>
|
||||
rec.Id == model.Id);
|
||||
if (shop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
shop.Update(model);
|
||||
if (model.Furnitures.Count > 0)
|
||||
{
|
||||
shop.UpdateFurnitures(context, model);
|
||||
}
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FurnitureAssemblyDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(FurnitureAssemblyDatabase))]
|
||||
[Migration("20230226121415_InitMigration")]
|
||||
partial class InitMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FurnitureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Furnitures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Counts")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("FurnitureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("FurnitureComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Furniture", "Furniture")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Furniture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("FurnitureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Cost = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Furnitures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
FurnitureName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Furnitures", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ProductId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "FurnitureComponents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ProductId = table.Column<int>(type: "int", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "int", nullable: false),
|
||||
Counts = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_FurnitureComponents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_FurnitureComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_FurnitureComponents_Furnitures_ProductId",
|
||||
column: x => x.ProductId,
|
||||
principalTable: "Furnitures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FurnitureComponents_ComponentId",
|
||||
table: "FurnitureComponents",
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_FurnitureComponents_ProductId",
|
||||
table: "FurnitureComponents",
|
||||
column: "ProductId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "FurnitureComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Furnitures");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FurnitureAssemblyDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FurnitureAssemblyDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(FurnitureAssemblyDatabase))]
|
||||
[Migration("20230226124904_OrderAddMigration")]
|
||||
partial class OrderAddMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("FurnitureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Furnitures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Counts")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ProductId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("ProductId");
|
||||
|
||||
b.ToTable("FurnitureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.IsRequired()
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("FurnitureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.FurnitureComponent", b =>
|
||||
{
|
||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("FurnitureComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FurnitureAssemblyDatabaseImplement.Models.Furniture", "Furniture")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ProductId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Furniture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("FurnitureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FurnitureAssemblyDatabaseImplement.Models.Furniture", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user