PIbd-22_Chernyshev_G.Y._LabWork05_Hard #13
144
GarmentFactory/FormAddTextile.Designer.cs
generated
Normal file
144
GarmentFactory/FormAddTextile.Designer.cs
generated
Normal file
@ -0,0 +1,144 @@
|
||||
namespace GarmentFactoryView
|
||||
{
|
||||
partial class FormAddTextile
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelShop = new Label();
|
||||
labelCount = new Label();
|
||||
labelTextile = new Label();
|
||||
comboBoxShop = new ComboBox();
|
||||
textBoxCount = new TextBox();
|
||||
comboBoxTextile = new ComboBox();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
labelShop.AutoSize = true;
|
||||
labelShop.Location = new Point(38, 37);
|
||||
labelShop.Name = "labelShop";
|
||||
labelShop.Size = new Size(72, 20);
|
||||
labelShop.TabIndex = 0;
|
||||
labelShop.Text = "Магазин:";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(29, 123);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(93, 20);
|
||||
labelCount.TabIndex = 3;
|
||||
labelCount.Text = "Количество:";
|
||||
//
|
||||
// labelTextile
|
||||
//
|
||||
labelTextile.AutoSize = true;
|
||||
labelTextile.Location = new Point(38, 79);
|
||||
labelTextile.Name = "labelTextile";
|
||||
labelTextile.Size = new Size(71, 20);
|
||||
labelTextile.TabIndex = 2;
|
||||
labelTextile.Text = "Изделие:";
|
||||
//
|
||||
// comboBoxShop
|
||||
//
|
||||
comboBoxShop.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxShop.FormattingEnabled = true;
|
||||
comboBoxShop.Location = new Point(140, 37);
|
||||
comboBoxShop.Name = "comboBoxShop";
|
||||
comboBoxShop.Size = new Size(262, 28);
|
||||
comboBoxShop.TabIndex = 11;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(140, 123);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(262, 27);
|
||||
textBoxCount.TabIndex = 10;
|
||||
//
|
||||
// comboBoxTextile
|
||||
//
|
||||
comboBoxTextile.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxTextile.FormattingEnabled = true;
|
||||
comboBoxTextile.Location = new Point(140, 79);
|
||||
comboBoxTextile.Name = "comboBoxTextile";
|
||||
comboBoxTextile.Size = new Size(262, 28);
|
||||
comboBoxTextile.TabIndex = 9;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(342, 181);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 13;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(242, 181);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 12;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// FormAddTextile
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(455, 222);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(comboBoxShop);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(comboBoxTextile);
|
||||
Controls.Add(labelCount);
|
||||
Controls.Add(labelTextile);
|
||||
Controls.Add(labelShop);
|
||||
Name = "FormAddTextile";
|
||||
Text = "Пополнение магазина";
|
||||
Load += FormAddTextile_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelShop;
|
||||
private Label labelCount;
|
||||
private Label labelTextile;
|
||||
private ComboBox comboBoxShop;
|
||||
private TextBox textBoxCount;
|
||||
private ComboBox comboBoxTextile;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
}
|
||||
}
|
109
GarmentFactory/FormAddTextile.cs
Normal file
109
GarmentFactory/FormAddTextile.cs
Normal file
@ -0,0 +1,109 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.BusinessLogicsContracts;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.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 GarmentFactoryView
|
||||
{
|
||||
public partial class FormAddTextile : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ITextileLogic _logicT;
|
||||
private readonly IShopLogic _logicS;
|
||||
//Списки для ComboBox
|
||||
private List<ShopViewModel> _shopList = new List<ShopViewModel>();
|
||||
private List<TextileViewModel> _textileList = new List<TextileViewModel>();
|
||||
public FormAddTextile(ILogger<FormAddTextile> logger, ITextileLogic logicT, IShopLogic logicS)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicT = logicT;
|
||||
_logicS = logicS;
|
||||
}
|
||||
|
||||
private void FormAddTextile_Load(object sender, EventArgs e)
|
||||
{
|
||||
_shopList = _logicS.ReadList(null);
|
||||
_textileList = _logicT.ReadList(null);
|
||||
|
||||
_logger.LogInformation("Загрузка списка магазинов при пополнении");
|
||||
if (_shopList != null)
|
||||
{
|
||||
comboBoxShop.DisplayMember = "ShopName";
|
||||
comboBoxShop.ValueMember = "Id";
|
||||
comboBoxShop.DataSource = _shopList;
|
||||
comboBoxShop.SelectedItem = null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка списка товаров при пополнении");
|
||||
if (_textileList != null)
|
||||
{
|
||||
comboBoxTextile.DisplayMember = "TextileName";
|
||||
comboBoxTextile.ValueMember = "Id";
|
||||
comboBoxTextile.DataSource = _textileList;
|
||||
comboBoxTextile.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxShop.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxTextile.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле \"Количество\"", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Пополнение магазина");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicS.MakeSupply(new SupplyBindingModel
|
||||
{
|
||||
ShopId = Convert.ToInt32(comboBoxShop.SelectedValue),
|
||||
TextileId = Convert.ToInt32(comboBoxTextile.SelectedValue),
|
||||
Count = Convert.ToInt32(textBoxCount.Text)
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при пополнении магазина. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка поплнения магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
GarmentFactory/FormAddTextile.resx
Normal file
120
GarmentFactory/FormAddTextile.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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>
|
75
GarmentFactory/FormMain.Designer.cs
generated
75
GarmentFactory/FormMain.Designer.cs
generated
@ -38,11 +38,18 @@
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
текстилиToolStripMenuItem = new ToolStripMenuItem();
|
||||
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||
пополнениеМагазинаToolStripMenuItem1 = new ToolStripMenuItem();
|
||||
продажаТовараToolStripMenuItem = new ToolStripMenuItem();
|
||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||
textilesToolStripMenuItem = new ToolStripMenuItem();
|
||||
textileComponentsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ordersToolStripMenuItem = new ToolStripMenuItem();
|
||||
магазиныВDocToolStripMenuItem = new ToolStripMenuItem();
|
||||
загруженностьМагазиновToolStripMenuItem = new ToolStripMenuItem();
|
||||
заказыПоДатамToolStripMenuItem = new ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
@ -121,7 +128,7 @@
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem });
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчётыToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(1380, 28);
|
||||
@ -130,7 +137,7 @@
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, текстилиToolStripMenuItem, клиентыToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, текстилиToolStripMenuItem, магазиныToolStripMenuItem, клиентыToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
@ -149,6 +156,34 @@
|
||||
текстилиToolStripMenuItem.Text = "Текстили";
|
||||
текстилиToolStripMenuItem.Click += текстилиToolStripMenuItem_Click;
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
магазиныToolStripMenuItem.Size = new Size(182, 26);
|
||||
магазиныToolStripMenuItem.Text = "Магазины";
|
||||
магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click;
|
||||
//
|
||||
// операцииToolStripMenuItem
|
||||
//
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { пополнениеМагазинаToolStripMenuItem1, продажаТовараToolStripMenuItem });
|
||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||
операцииToolStripMenuItem.Size = new Size(95, 24);
|
||||
операцииToolStripMenuItem.Text = "Операции";
|
||||
//
|
||||
// пополнениеМагазинаToolStripMenuItem1
|
||||
//
|
||||
пополнениеМагазинаToolStripMenuItem1.Name = "пополнениеМагазинаToolStripMenuItem1";
|
||||
пополнениеМагазинаToolStripMenuItem1.Size = new Size(251, 26);
|
||||
пополнениеМагазинаToolStripMenuItem1.Text = "Пополнение магазина";
|
||||
пополнениеМагазинаToolStripMenuItem1.Click += пополнениеМагазинаToolStripMenuItem1_Click;
|
||||
//
|
||||
// продажаТовараToolStripMenuItem
|
||||
//
|
||||
продажаТовараToolStripMenuItem.Name = "продажаТовараToolStripMenuItem";
|
||||
продажаТовараToolStripMenuItem.Size = new Size(251, 26);
|
||||
продажаТовараToolStripMenuItem.Text = "Продажа товара";
|
||||
продажаТовараToolStripMenuItem.Click += продажаТовараToolStripMenuItem_Click;
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
@ -158,7 +193,7 @@
|
||||
//
|
||||
// отчётыToolStripMenuItem
|
||||
//
|
||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { textilesToolStripMenuItem, textileComponentsToolStripMenuItem, ordersToolStripMenuItem });
|
||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { textilesToolStripMenuItem, textileComponentsToolStripMenuItem, ordersToolStripMenuItem, магазиныВDocToolStripMenuItem, загруженностьМагазиновToolStripMenuItem, заказыПоДатамToolStripMenuItem });
|
||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||
отчётыToolStripMenuItem.Size = new Size(73, 24);
|
||||
отчётыToolStripMenuItem.Text = "Отчёты";
|
||||
@ -166,24 +201,45 @@
|
||||
// textilesToolStripMenuItem
|
||||
//
|
||||
textilesToolStripMenuItem.Name = "textilesToolStripMenuItem";
|
||||
textilesToolStripMenuItem.Size = new Size(274, 26);
|
||||
textilesToolStripMenuItem.Size = new Size(276, 26);
|
||||
textilesToolStripMenuItem.Text = "Текстили";
|
||||
textilesToolStripMenuItem.Click += TextilesToolStripMenuItem_Click;
|
||||
//
|
||||
// textileComponentsToolStripMenuItem
|
||||
//
|
||||
textileComponentsToolStripMenuItem.Name = "textileComponentsToolStripMenuItem";
|
||||
textileComponentsToolStripMenuItem.Size = new Size(274, 26);
|
||||
textileComponentsToolStripMenuItem.Size = new Size(276, 26);
|
||||
textileComponentsToolStripMenuItem.Text = "Текстили с компонентами";
|
||||
textileComponentsToolStripMenuItem.Click += ComponentTextilesToolStripMenuItem_Click;
|
||||
//
|
||||
// ordersToolStripMenuItem
|
||||
//
|
||||
ordersToolStripMenuItem.Name = "ordersToolStripMenuItem";
|
||||
ordersToolStripMenuItem.Size = new Size(274, 26);
|
||||
ordersToolStripMenuItem.Size = new Size(276, 26);
|
||||
ordersToolStripMenuItem.Text = "Заказы";
|
||||
ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
||||
//
|
||||
// магазиныВDocToolStripMenuItem
|
||||
//
|
||||
магазиныВDocToolStripMenuItem.Name = "магазиныВDocToolStripMenuItem";
|
||||
магазиныВDocToolStripMenuItem.Size = new Size(276, 26);
|
||||
магазиныВDocToolStripMenuItem.Text = "Магазины в doc";
|
||||
магазиныВDocToolStripMenuItem.Click += магазиныВDocToolStripMenuItem_Click;
|
||||
//
|
||||
// загруженностьМагазиновToolStripMenuItem
|
||||
//
|
||||
загруженностьМагазиновToolStripMenuItem.Name = "загруженностьМагазиновToolStripMenuItem";
|
||||
загруженностьМагазиновToolStripMenuItem.Size = new Size(276, 26);
|
||||
загруженностьМагазиновToolStripMenuItem.Text = "Загруженность магазинов";
|
||||
загруженностьМагазиновToolStripMenuItem.Click += загруженностьМагазиновToolStripMenuItem_Click;
|
||||
//
|
||||
// заказыПоДатамToolStripMenuItem
|
||||
//
|
||||
заказыПоДатамToolStripMenuItem.Name = "заказыПоДатамToolStripMenuItem";
|
||||
заказыПоДатамToolStripMenuItem.Size = new Size(276, 26);
|
||||
заказыПоДатамToolStripMenuItem.Text = "Заказы по датам";
|
||||
заказыПоДатамToolStripMenuItem.Click += заказыПоДатамToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
@ -219,10 +275,17 @@
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem текстилиToolStripMenuItem;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem1;
|
||||
private ToolStripMenuItem продажаТовараToolStripMenuItem;
|
||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||
private ToolStripMenuItem textilesToolStripMenuItem;
|
||||
private ToolStripMenuItem textileComponentsToolStripMenuItem;
|
||||
private ToolStripMenuItem ordersToolStripMenuItem;
|
||||
private ToolStripMenuItem магазиныВDocToolStripMenuItem;
|
||||
private ToolStripMenuItem загруженностьМагазиновToolStripMenuItem;
|
||||
private ToolStripMenuItem заказыПоДатамToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -103,6 +103,17 @@ namespace GarmentFactoryView
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void магазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||
|
||||
if (service is FormShops form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
@ -184,6 +195,53 @@ namespace GarmentFactoryView
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void пополнениеМагазинаToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormAddTextile));
|
||||
|
||||
if (service is FormAddTextile form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void продажаТовараToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSellTextile));
|
||||
if (service is FormSellTextile form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void магазиныВDocToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveShopsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void загруженностьМагазиновToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportShops));
|
||||
if (service is FormReportShops form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void заказыПоДатамToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupedOrders));
|
||||
if (service is FormReportGroupedOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
|
86
GarmentFactory/FormReportGroupedOrders.Designer.cs
generated
Normal file
86
GarmentFactory/FormReportGroupedOrders.Designer.cs
generated
Normal file
@ -0,0 +1,86 @@
|
||||
namespace GarmentFactoryView
|
||||
{
|
||||
partial class FormReportGroupedOrders
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panel = new System.Windows.Forms.Panel();
|
||||
this.buttonToPDF = new System.Windows.Forms.Button();
|
||||
this.buttonMake = new System.Windows.Forms.Button();
|
||||
this.panel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel
|
||||
//
|
||||
this.panel.Controls.Add(this.buttonToPDF);
|
||||
this.panel.Controls.Add(this.buttonMake);
|
||||
this.panel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel.Name = "panel";
|
||||
this.panel.Size = new System.Drawing.Size(970, 52);
|
||||
this.panel.TabIndex = 1;
|
||||
//
|
||||
// buttonToPDF
|
||||
//
|
||||
this.buttonToPDF.Location = new System.Drawing.Point(486, 12);
|
||||
this.buttonToPDF.Name = "buttonToPDF";
|
||||
this.buttonToPDF.Size = new System.Drawing.Size(411, 29);
|
||||
this.buttonToPDF.TabIndex = 5;
|
||||
this.buttonToPDF.Text = "В PDF";
|
||||
this.buttonToPDF.UseVisualStyleBackColor = true;
|
||||
this.buttonToPDF.Click += new System.EventHandler(this.buttonToPDF_Click);
|
||||
//
|
||||
// buttonMake
|
||||
//
|
||||
this.buttonMake.Location = new System.Drawing.Point(49, 12);
|
||||
this.buttonMake.Name = "buttonMake";
|
||||
this.buttonMake.Size = new System.Drawing.Size(377, 29);
|
||||
this.buttonMake.TabIndex = 4;
|
||||
this.buttonMake.Text = "Сформировать";
|
||||
this.buttonMake.UseVisualStyleBackColor = true;
|
||||
this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click);
|
||||
//
|
||||
// FormReportGroupedOrders
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(970, 450);
|
||||
this.Controls.Add(this.panel);
|
||||
this.Name = "FormReportGroupedOrders";
|
||||
this.Text = "Отчёт по группированным заказам ";
|
||||
this.panel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel;
|
||||
private Button buttonToPDF;
|
||||
private Button buttonMake;
|
||||
}
|
||||
}
|
80
GarmentFactory/FormReportGroupedOrders.cs
Normal file
80
GarmentFactory/FormReportGroupedOrders.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.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 GarmentFactoryView
|
||||
{
|
||||
public partial class FormReportGroupedOrders : Form
|
||||
{
|
||||
private readonly ReportViewer reportViewer;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportLogic _logic;
|
||||
|
||||
public FormReportGroupedOrders(ILogger<FormReportGroupedOrders> logger, IReportLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
reportViewer = new ReportViewer
|
||||
{
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupedOrders.rdlc", FileMode.Open));
|
||||
Controls.Clear();
|
||||
Controls.Add(reportViewer);
|
||||
Controls.Add(panel);
|
||||
}
|
||||
|
||||
private void ButtonMake_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dataSource = _logic.GetGroupedOrders();
|
||||
var source = new ReportDataSource("DataSetGroupedOrders", dataSource);
|
||||
reportViewer.LocalReport.DataSources.Clear();
|
||||
reportViewer.LocalReport.DataSources.Add(source);
|
||||
|
||||
reportViewer.RefreshReport();
|
||||
_logger.LogInformation("Загрузка списка группированных заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка группированных заказов на период");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void buttonToPDF_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveGroupedOrdersToPdfFile(new ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName,
|
||||
});
|
||||
_logger.LogInformation("Сохранение списка группированных заказов");
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка группированных заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
GarmentFactory/FormReportGroupedOrders.resx
Normal file
120
GarmentFactory/FormReportGroupedOrders.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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>
|
112
GarmentFactory/FormReportShops.Designer.cs
generated
Normal file
112
GarmentFactory/FormReportShops.Designer.cs
generated
Normal file
@ -0,0 +1,112 @@
|
||||
namespace GarmentFactoryView
|
||||
{
|
||||
partial class FormReportShops
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonSaveToExcel = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
ColumnShop = new DataGridViewTextBoxColumn();
|
||||
ColumnTextile = new DataGridViewTextBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSaveToExcel
|
||||
//
|
||||
buttonSaveToExcel.Location = new Point(12, 9);
|
||||
buttonSaveToExcel.Name = "buttonSaveToExcel";
|
||||
buttonSaveToExcel.Size = new Size(169, 29);
|
||||
buttonSaveToExcel.TabIndex = 3;
|
||||
buttonSaveToExcel.Text = "Сохранить в Excel";
|
||||
buttonSaveToExcel.UseVisualStyleBackColor = true;
|
||||
buttonSaveToExcel.Click += ButtonSaveToExcel_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToOrderColumns = true;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnShop, ColumnTextile, ColumnCount });
|
||||
dataGridView.Dock = DockStyle.Bottom;
|
||||
dataGridView.Location = new Point(0, 47);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(598, 403);
|
||||
dataGridView.TabIndex = 2;
|
||||
//
|
||||
// ColumnShop
|
||||
//
|
||||
ColumnShop.FillWeight = 130F;
|
||||
ColumnShop.HeaderText = "Магазин";
|
||||
ColumnShop.MinimumWidth = 6;
|
||||
ColumnShop.Name = "ColumnShop";
|
||||
ColumnShop.ReadOnly = true;
|
||||
//
|
||||
// ColumnTextile
|
||||
//
|
||||
ColumnTextile.FillWeight = 140F;
|
||||
ColumnTextile.HeaderText = "Текстиль";
|
||||
ColumnTextile.MinimumWidth = 6;
|
||||
ColumnTextile.Name = "ColumnTextile";
|
||||
ColumnTextile.ReadOnly = true;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.FillWeight = 90F;
|
||||
ColumnCount.HeaderText = "Количество";
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
ColumnCount.ReadOnly = true;
|
||||
//
|
||||
// FormReportShops
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(598, 450);
|
||||
Controls.Add(buttonSaveToExcel);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormReportShops";
|
||||
Text = "Загруженность магазинов";
|
||||
Load += FormReportShops_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSaveToExcel;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn ColumnShop;
|
||||
private DataGridViewTextBoxColumn ColumnTextile;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
}
|
||||
}
|
78
GarmentFactory/FormReportShops.cs
Normal file
78
GarmentFactory/FormReportShops.cs
Normal file
@ -0,0 +1,78 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.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 GarmentFactoryView
|
||||
{
|
||||
public partial class FormReportShops : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportLogic _logic;
|
||||
|
||||
public FormReportShops(ILogger<FormReportShops> logger, IReportLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormReportShops_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var shops = _logic.GetShops();
|
||||
if (shops != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var shop in shops)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { shop.ShopName, "", "" });
|
||||
foreach (var textile in shop.Textiles)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { "", textile.Item1, textile.Item2 });
|
||||
}
|
||||
dataGridView.Rows.Add(new object[] { "Итого", "", shop.TotalCount });
|
||||
dataGridView.Rows.Add(Array.Empty<object>());
|
||||
}
|
||||
}
|
||||
_logger.LogInformation("Загрузка списка текстилей по магазинам");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка текстилей по магазинам");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveShopsToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
_logger.LogInformation("Сохранение списка текстилей по магазинам");
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка текстилей по магазинам");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
GarmentFactory/FormReportShops.resx
Normal file
120
GarmentFactory/FormReportShops.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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
GarmentFactory/FormSellTextile.Designer.cs
generated
Normal file
119
GarmentFactory/FormSellTextile.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
||||
namespace GarmentFactoryView
|
||||
{
|
||||
partial class FormSellTextile
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelTextile = new Label();
|
||||
comboBoxTextile = new ComboBox();
|
||||
labelCount = new Label();
|
||||
textBoxCount = new TextBox();
|
||||
buttonSell = new Button();
|
||||
buttonCancel = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelTextile
|
||||
//
|
||||
labelTextile.AutoSize = true;
|
||||
labelTextile.Location = new Point(12, 14);
|
||||
labelTextile.Name = "labelTextile";
|
||||
labelTextile.Size = new Size(77, 20);
|
||||
labelTextile.TabIndex = 0;
|
||||
labelTextile.Text = "Текстиль: ";
|
||||
//
|
||||
// comboBoxTextile
|
||||
//
|
||||
comboBoxTextile.FormattingEnabled = true;
|
||||
comboBoxTextile.Location = new Point(115, 11);
|
||||
comboBoxTextile.Name = "comboBoxTextile";
|
||||
comboBoxTextile.Size = new Size(239, 28);
|
||||
comboBoxTextile.TabIndex = 1;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(12, 55);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(97, 20);
|
||||
labelCount.TabIndex = 2;
|
||||
labelCount.Text = "Количество: ";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(115, 52);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(239, 27);
|
||||
textBoxCount.TabIndex = 3;
|
||||
//
|
||||
// buttonSell
|
||||
//
|
||||
buttonSell.Location = new Point(128, 99);
|
||||
buttonSell.Name = "buttonSell";
|
||||
buttonSell.Size = new Size(94, 29);
|
||||
buttonSell.TabIndex = 4;
|
||||
buttonSell.Text = "Продать";
|
||||
buttonSell.UseVisualStyleBackColor = true;
|
||||
buttonSell.Click += ButtonSell_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(242, 99);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormSellTextile
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(366, 140);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSell);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(labelCount);
|
||||
Controls.Add(comboBoxTextile);
|
||||
Controls.Add(labelTextile);
|
||||
Name = "FormSellTextile";
|
||||
Text = "Продажа текстиля";
|
||||
Load += FormSellingTextile_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelTextile;
|
||||
private ComboBox comboBoxTextile;
|
||||
private Label labelCount;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonSell;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
87
GarmentFactory/FormSellTextile.cs
Normal file
87
GarmentFactory/FormSellTextile.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using GarmentFactoryContracts.BusinessLogicsContracts;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.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 GarmentFactoryView
|
||||
{
|
||||
public partial class FormSellTextile : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ITextileLogic _logicT;
|
||||
private readonly IShopLogic _logicS;
|
||||
private List<TextileViewModel> _TextileList = new List<TextileViewModel>();
|
||||
|
||||
public FormSellTextile(ILogger<FormSellTextile> logger, ITextileLogic logicT, IShopLogic logicS)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicT = logicT;
|
||||
_logicS = logicS;
|
||||
}
|
||||
|
||||
private void FormSellingTextile_Load(object sender, EventArgs e)
|
||||
{
|
||||
_TextileList = _logicT.ReadList(null);
|
||||
if (_TextileList != null)
|
||||
{
|
||||
comboBoxTextile.DisplayMember = "TextileName";
|
||||
comboBoxTextile.ValueMember = "Id";
|
||||
comboBoxTextile.DataSource = _TextileList;
|
||||
comboBoxTextile.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка пиццы для продажи");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSell_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxTextile.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите пиццу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Создание покупки");
|
||||
try
|
||||
{
|
||||
bool resout = _logicS.Sell(new SupplySearchModel
|
||||
{
|
||||
TextileId = Convert.ToInt32(comboBoxTextile.SelectedValue),
|
||||
Count = Convert.ToInt32(textBoxCount.Text)
|
||||
});
|
||||
if (resout)
|
||||
{
|
||||
_logger.LogInformation("Проверка была выполнена");
|
||||
MessageBox.Show("Продажа выполнена", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("Проверка не пройдена");
|
||||
MessageBox.Show("Продажа не может быть выполнена.", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания покупки");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
GarmentFactory/FormSellTextile.resx
Normal file
120
GarmentFactory/FormSellTextile.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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>
|
230
GarmentFactory/FormShop.Designer.cs
generated
Normal file
230
GarmentFactory/FormShop.Designer.cs
generated
Normal file
@ -0,0 +1,230 @@
|
||||
namespace GarmentFactoryView
|
||||
{
|
||||
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()
|
||||
{
|
||||
labelName = new Label();
|
||||
labelAddress = new Label();
|
||||
labelDateOpen = new Label();
|
||||
textBoxName = new TextBox();
|
||||
textBoxAddress = new TextBox();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
groupBoxTextiles = new GroupBox();
|
||||
dataGridView = new DataGridView();
|
||||
ID = new DataGridViewTextBoxColumn();
|
||||
ColumnTextileName = new DataGridViewTextBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
numericUpTextileMaxCount = new NumericUpDown();
|
||||
label2 = new Label();
|
||||
groupBoxTextiles.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpTextileMaxCount).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(30, 21);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(84, 20);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "Название: ";
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
labelAddress.AutoSize = true;
|
||||
labelAddress.Location = new Point(40, 71);
|
||||
labelAddress.Name = "labelAddress";
|
||||
labelAddress.Size = new Size(58, 20);
|
||||
labelAddress.TabIndex = 1;
|
||||
labelAddress.Text = "Адрес: ";
|
||||
//
|
||||
// labelDateOpen
|
||||
//
|
||||
labelDateOpen.AutoSize = true;
|
||||
labelDateOpen.Location = new Point(12, 118);
|
||||
labelDateOpen.Name = "labelDateOpen";
|
||||
labelDateOpen.Size = new Size(117, 20);
|
||||
labelDateOpen.TabIndex = 2;
|
||||
labelDateOpen.Text = "Дата открытия: ";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(135, 21);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(243, 27);
|
||||
textBoxName.TabIndex = 3;
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
textBoxAddress.Location = new Point(135, 68);
|
||||
textBoxAddress.Name = "textBoxAddress";
|
||||
textBoxAddress.Size = new Size(243, 27);
|
||||
textBoxAddress.TabIndex = 4;
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(135, 113);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(243, 27);
|
||||
dateTimePicker.TabIndex = 5;
|
||||
//
|
||||
// groupBoxTextiles
|
||||
//
|
||||
groupBoxTextiles.Controls.Add(dataGridView);
|
||||
groupBoxTextiles.Location = new Point(12, 209);
|
||||
groupBoxTextiles.Name = "groupBoxTextiles";
|
||||
groupBoxTextiles.Size = new Size(651, 306);
|
||||
groupBoxTextiles.TabIndex = 6;
|
||||
groupBoxTextiles.TabStop = false;
|
||||
groupBoxTextiles.Text = "Изделия";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ID, ColumnTextileName, ColumnCount });
|
||||
dataGridView.Location = new Point(6, 26);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(633, 274);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ID
|
||||
//
|
||||
ID.HeaderText = "ID";
|
||||
ID.MinimumWidth = 6;
|
||||
ID.Name = "ID";
|
||||
ID.ReadOnly = true;
|
||||
ID.Visible = false;
|
||||
//
|
||||
// ColumnTextileName
|
||||
//
|
||||
ColumnTextileName.HeaderText = "Изделие";
|
||||
ColumnTextileName.MinimumWidth = 6;
|
||||
ColumnTextileName.Name = "ColumnTextileName";
|
||||
ColumnTextileName.ReadOnly = true;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.HeaderText = "Количество";
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
ColumnCount.ReadOnly = true;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
buttonCancel.Location = new Point(550, 532);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(103, 40);
|
||||
buttonCancel.TabIndex = 9;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Font = new Font("Segoe UI", 9F, FontStyle.Bold, GraphicsUnit.Point);
|
||||
buttonSave.Location = new Point(432, 532);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(103, 40);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// numericUpTextileMaxCount
|
||||
//
|
||||
numericUpTextileMaxCount.Location = new Point(135, 163);
|
||||
numericUpTextileMaxCount.Maximum = new decimal(new int[] { 10000, 0, 0, 0 });
|
||||
numericUpTextileMaxCount.Name = "numericUpTextileMaxCount";
|
||||
numericUpTextileMaxCount.Size = new Size(243, 27);
|
||||
numericUpTextileMaxCount.TabIndex = 13;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(19, 165);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(103, 20);
|
||||
label2.TabIndex = 12;
|
||||
label2.Text = "Вместимость:";
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(682, 584);
|
||||
Controls.Add(numericUpTextileMaxCount);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(groupBoxTextiles);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(textBoxAddress);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelDateOpen);
|
||||
Controls.Add(labelAddress);
|
||||
Controls.Add(labelName);
|
||||
Name = "FormShop";
|
||||
Text = "Магазин";
|
||||
Load += FormShop_Load;
|
||||
groupBoxTextiles.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpTextileMaxCount).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private Label labelAddress;
|
||||
private Label labelDateOpen;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxAddress;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private GroupBox groupBoxTextiles;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn ID;
|
||||
private DataGridViewTextBoxColumn ColumnTextileName;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private NumericUpDown numericUpTextileMaxCount;
|
||||
private Label label2;
|
||||
}
|
||||
}
|
135
GarmentFactory/FormShop.cs
Normal file
135
GarmentFactory/FormShop.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.BusinessLogicsContracts;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
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 GarmentFactoryView
|
||||
{
|
||||
public partial class FormShop : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
private Dictionary<int, (ITextileModel, int)> _shopTextiles;
|
||||
|
||||
|
||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_shopTextiles = new Dictionary<int, (ITextileModel, int)>();
|
||||
}
|
||||
|
||||
private void FormShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазина");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ShopSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAddress.Text = view.Address.ToString();
|
||||
dateTimePicker.Value = view.DateOpen;
|
||||
numericUpTextileMaxCount.Value = view.TextileMaxCount;
|
||||
_shopTextiles = view.ShopTextiles ?? new Dictionary<int, (ITextileModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий в магазине");
|
||||
try
|
||||
{
|
||||
if (_shopTextiles != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var element in _shopTextiles)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { element.Key, element.Value.Item1.TextileName, element.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий в магазине");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
try
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpen = dateTimePicker.Value.Date,
|
||||
ShopTextiles = _shopTextiles,
|
||||
TextileMaxCount = (int)numericUpTextileMaxCount.Value
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
129
GarmentFactory/FormShop.resx
Normal file
129
GarmentFactory/FormShop.resx
Normal file
@ -0,0 +1,129 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ID.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnTextileName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
116
GarmentFactory/FormShops.Designer.cs
generated
Normal file
116
GarmentFactory/FormShops.Designer.cs
generated
Normal file
@ -0,0 +1,116 @@
|
||||
namespace GarmentFactoryView
|
||||
{
|
||||
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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonRefresh = new Button();
|
||||
buttonDelete = new Button();
|
||||
buttonUpdate = new Button();
|
||||
buttonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(-3, -4);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(640, 455);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(658, 252);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(120, 40);
|
||||
buttonRefresh.TabIndex = 12;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += ButtonRefresh_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(658, 183);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(120, 40);
|
||||
buttonDelete.TabIndex = 11;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += ButtonDelete_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(658, 115);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(120, 40);
|
||||
buttonUpdate.TabIndex = 10;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += ButtonUpdate_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(658, 50);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(120, 40);
|
||||
buttonAdd.TabIndex = 9;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += ButtonAdd_Click;
|
||||
//
|
||||
// FormShops
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(buttonRefresh);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormShops";
|
||||
Text = "Магазины";
|
||||
Load += FormShops_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonRefresh;
|
||||
private Button buttonDelete;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
115
GarmentFactory/FormShops.cs
Normal file
115
GarmentFactory/FormShops.cs
Normal file
@ -0,0 +1,115 @@
|
||||
using GarmentFactory;
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.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 GarmentFactoryView
|
||||
{
|
||||
public partial class FormShops : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormShops_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ShopTextiles"].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 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 ButtonUpdate_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 ButtonDelete_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 ButtonRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
GarmentFactory/FormShops.resx
Normal file
120
GarmentFactory/FormShops.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<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
GarmentFactory/FormTextiles.Designer.cs
generated
3
GarmentFactory/FormTextiles.Designer.cs
generated
@ -38,6 +38,9 @@
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
|
@ -25,9 +25,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GarmentFactoryDatabaseImple
|
||||
{DB84150A-FB0D-4FCB-90DD-2CAC6845E1AF} = {DB84150A-FB0D-4FCB-90DD-2CAC6845E1AF}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GarmentFactoryRestApi", "..\GarmentFactoryRestApi\GarmentFactoryRestApi.csproj", "{5D50174D-BD95-4CE9-AC7E-E81FE1B6D99C}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GarmentFactoryRestApi", "..\GarmentFactoryRestApi\GarmentFactoryRestApi.csproj", "{5D50174D-BD95-4CE9-AC7E-E81FE1B6D99C}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GarmentFactoryClientApp", "..\GarmentFactoryClientApp\GarmentFactoryClientApp.csproj", "{5842FFC0-16D2-4268-841C-CF17396D54BC}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GarmentFactoryClientApp", "..\GarmentFactoryClientApp\GarmentFactoryClientApp.csproj", "{5842FFC0-16D2-4268-841C-CF17396D54BC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GarmentFactoryShopsApp", "..\GarmentFactoryShopsApp\GarmentFactoryShopsApp.csproj", "{FE81CD47-0E12-4992-B839-A58E7C20E394}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -71,6 +73,10 @@ Global
|
||||
{5842FFC0-16D2-4268-841C-CF17396D54BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5842FFC0-16D2-4268-841C-CF17396D54BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5842FFC0-16D2-4268-841C-CF17396D54BC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FE81CD47-0E12-4992-B839-A58E7C20E394}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FE81CD47-0E12-4992-B839-A58E7C20E394}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FE81CD47-0E12-4992-B839-A58E7C20E394}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FE81CD47-0E12-4992-B839-A58E7C20E394}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -44,6 +44,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="ReportGroupedOrders.rdlc">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ReportOrders.rdlc">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
@ -9,7 +9,6 @@ using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
|
||||
|
||||
namespace GarmentFactory
|
||||
{
|
||||
internal static class Program
|
||||
@ -41,12 +40,14 @@ namespace GarmentFactory
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<ITextileStorage, TextileStorage>();
|
||||
services.AddTransient<IShopStorage, ShopStorage>();
|
||||
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<ITextileLogic, TextileLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IShopLogic, ShopLogic>();
|
||||
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
@ -59,8 +60,16 @@ namespace GarmentFactory
|
||||
services.AddTransient<FormTextile>();
|
||||
services.AddTransient<FormTextileComponent>();
|
||||
services.AddTransient<FormTextiles>();
|
||||
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormAddTextile>();
|
||||
services.AddTransient<FormSellTextile>();
|
||||
|
||||
services.AddTransient<FormReportTextileComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormReportShops>();
|
||||
services.AddTransient<FormReportGroupedOrders>();
|
||||
services.AddTransient<FormClients>();
|
||||
}
|
||||
}
|
||||
|
444
GarmentFactory/ReportGroupedOrders.rdlc
Normal file
444
GarmentFactory/ReportGroupedOrders.rdlc
Normal file
@ -0,0 +1,444 @@
|
||||
<?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="GarmentFactoryContractsViewModels">
|
||||
<ConnectionProperties>
|
||||
<DataProvider>System.Data.DataSet</DataProvider>
|
||||
<ConnectString>/* Local Connection */</ConnectString>
|
||||
</ConnectionProperties>
|
||||
<rd:DataSourceID>20791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
|
||||
</DataSource>
|
||||
</DataSources>
|
||||
<DataSets>
|
||||
<DataSet Name="DataSetGroupedOrders">
|
||||
<Query>
|
||||
<DataSourceName>GarmentFactoryContractsViewModels</DataSourceName>
|
||||
<CommandText>/* Local Query */</CommandText>
|
||||
</Query>
|
||||
<Fields>
|
||||
<Field Name="Date">
|
||||
<DataField>Date</DataField>
|
||||
<rd:TypeName>System.DateTime</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="OrdersCount">
|
||||
<DataField>OrdersCount</DataField>
|
||||
<rd:TypeName>System.Int32</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="OrdersSum">
|
||||
<DataField>OrdersSum</DataField>
|
||||
<rd:TypeName>System.Decimal</rd:TypeName>
|
||||
</Field>
|
||||
</Fields>
|
||||
<rd:DataSetInfo>
|
||||
<rd:DataSetName>GarmentFactoryContracts.ViewModels</rd:DataSetName>
|
||||
<rd:TableName>ReportGroupedOrdersViewModel</rd:TableName>
|
||||
<rd:ObjectDataSourceType>GarmentFactoryContracts.ViewModels.ReportGroupedOrdersViewModel, GarmentFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
||||
</rd:DataSetInfo>
|
||||
</DataSet>
|
||||
</DataSets>
|
||||
<ReportSections>
|
||||
<ReportSection>
|
||||
<Body>
|
||||
<ReportItems>
|
||||
<Textbox Name="TextboxTitle">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Отчёт по заказам</Value>
|
||||
<Style>
|
||||
<FontSize>16pt</FontSize>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Center</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>16.51cm</Width>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<VerticalAlign>Middle</VerticalAlign>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Textbox Name="ReportParameterPeriod">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Parameters!ReportParameterPeriod.Value</Value>
|
||||
<Style>
|
||||
<Format>d</Format>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Center</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
|
||||
<Top>0.6cm</Top>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>16.51cm</Width>
|
||||
<ZIndex>1</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Tablix Name="Tablix1">
|
||||
<TablixBody>
|
||||
<TablixColumns>
|
||||
<TablixColumn>
|
||||
<Width>3.90406cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>3.97461cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>3.65711cm</Width>
|
||||
</TablixColumn>
|
||||
</TablixColumns>
|
||||
<TablixRows>
|
||||
<TablixRow>
|
||||
<Height>0.6cm</Height>
|
||||
<TablixCells>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="TextboxDate">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Дата создания</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="TextboxCount">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Количество заказов</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="TextboxSum">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Общая сумма заказов</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
</TablixCells>
|
||||
</TablixRow>
|
||||
<TablixRow>
|
||||
<Height>0.6cm</Height>
|
||||
<TablixCells>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Date">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!Date.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Date</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="OrdersCount">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!OrdersCount.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>OrdersCount</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="OrdersSum">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!OrdersSum.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>OrdersSum</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
</TablixCells>
|
||||
</TablixRow>
|
||||
</TablixRows>
|
||||
</TablixBody>
|
||||
<TablixColumnHierarchy>
|
||||
<TablixMembers>
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
</TablixMembers>
|
||||
</TablixColumnHierarchy>
|
||||
<TablixRowHierarchy>
|
||||
<TablixMembers>
|
||||
<TablixMember>
|
||||
<KeepWithGroup>After</KeepWithGroup>
|
||||
</TablixMember>
|
||||
<TablixMember>
|
||||
<Group Name="Подробности" />
|
||||
</TablixMember>
|
||||
</TablixMembers>
|
||||
</TablixRowHierarchy>
|
||||
<DataSetName>DataSetGroupedOrders</DataSetName>
|
||||
<Top>1.88242cm</Top>
|
||||
<Left>2.68676cm</Left>
|
||||
<Height>1.2cm</Height>
|
||||
<Width>11.53578cm</Width>
|
||||
<ZIndex>2</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
</Style>
|
||||
</Tablix>
|
||||
<Textbox Name="TextboxResout">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Итого:</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Right</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Top>3.29409cm</Top>
|
||||
<Left>8.06542cm</Left>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>2.5cm</Width>
|
||||
<ZIndex>3</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Textbox Name="TextboxFullSum">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Sum(Fields!OrdersSum.Value, "DataSetGroupedOrders")</Value>
|
||||
<Style>
|
||||
<Format>0.00;(0.00)</Format>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Right</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Top>3.29409cm</Top>
|
||||
<Left>10.70653cm</Left>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>3.48072cm</Width>
|
||||
<ZIndex>4</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</ReportItems>
|
||||
<Height>2in</Height>
|
||||
<Style />
|
||||
</Body>
|
||||
<Width>6.5in</Width>
|
||||
<Page>
|
||||
<PageHeight>29.7cm</PageHeight>
|
||||
<PageWidth>21cm</PageWidth>
|
||||
<LeftMargin>2cm</LeftMargin>
|
||||
<RightMargin>2cm</RightMargin>
|
||||
<TopMargin>2cm</TopMargin>
|
||||
<BottomMargin>2cm</BottomMargin>
|
||||
<ColumnSpacing>0.13cm</ColumnSpacing>
|
||||
<Style />
|
||||
</Page>
|
||||
</ReportSection>
|
||||
</ReportSections>
|
||||
<ReportParameters>
|
||||
<ReportParameter Name="ReportParameterPeriod">
|
||||
<DataType>String</DataType>
|
||||
<Nullable>true</Nullable>
|
||||
<Prompt>ReportParameter1</Prompt>
|
||||
</ReportParameter>
|
||||
</ReportParameters>
|
||||
<ReportParametersLayout>
|
||||
<GridLayoutDefinition>
|
||||
<NumberOfColumns>4</NumberOfColumns>
|
||||
<NumberOfRows>2</NumberOfRows>
|
||||
<CellDefinitions>
|
||||
<CellDefinition>
|
||||
<ColumnIndex>0</ColumnIndex>
|
||||
<RowIndex>0</RowIndex>
|
||||
<ParameterName>ReportParameterPeriod</ParameterName>
|
||||
</CellDefinition>
|
||||
</CellDefinitions>
|
||||
</GridLayoutDefinition>
|
||||
</ReportParametersLayout>
|
||||
<rd:ReportUnitType>Cm</rd:ReportUnitType>
|
||||
<rd:ReportID>b5a8ad5e-1151-4687-8576-a5270295c079</rd:ReportID>
|
||||
</Report>
|
@ -19,14 +19,16 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
private readonly ILogger _logger;
|
||||
//Хранение всех заказов
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
}
|
||||
private readonly IShopStorage _shopStorage;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopStorage shopStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_shopStorage = shopStorage;
|
||||
}
|
||||
|
||||
//Чтение всего списка заказов
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
//Чтение всего списка заказов
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. OrderId:{Id}", model?.Id);
|
||||
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
|
||||
@ -133,7 +135,18 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
//Перевод заказа в состояние выдачи (окончательное завершение)
|
||||
public bool DeliveryOrder(OrderBindingModel model)
|
||||
{
|
||||
return ChangeStatus(model, OrderStatus.Выдан);
|
||||
var order = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
|
||||
if (order == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(order));
|
||||
}
|
||||
|
||||
//Если нельзя пополнить магазины таким кол-вом товаров (не хавтает места), то статус не меняем
|
||||
if (!_shopStorage.RestockShops(new SupplyBindingModel { TextileId = order.TextileId, Count = order.Count }))
|
||||
{
|
||||
throw new ArgumentException("Недостаточно места");
|
||||
}
|
||||
return ChangeStatus(model, OrderStatus.Выдан);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
|
||||
namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
{
|
||||
@ -18,16 +19,18 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
private readonly IComponentStorage _componentStorage;
|
||||
private readonly ITextileStorage _textileStorage;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly IShopStorage _shopStorage;
|
||||
private readonly AbstractSaveToExcel _saveToExcel;
|
||||
private readonly AbstractSaveToWord _saveToWord;
|
||||
private readonly AbstractSaveToPdf _saveToPdf;
|
||||
|
||||
public ReportLogic(ITextileStorage textileStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
|
||||
public ReportLogic(ITextileStorage textileStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, IShopStorage shopStorage,
|
||||
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||
{
|
||||
_textileStorage = textileStorage;
|
||||
_componentStorage = componentStorage;
|
||||
_orderStorage = orderStorage;
|
||||
_shopStorage = shopStorage;
|
||||
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
@ -106,5 +109,55 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
Orders = GetOrders(model)
|
||||
});
|
||||
}
|
||||
|
||||
public List<ReportShopsViewModel> GetShops()
|
||||
{
|
||||
return _shopStorage.GetFullList().Select(x => new ReportShopsViewModel
|
||||
{
|
||||
ShopName = x.ShopName,
|
||||
Textiles = x.ShopTextiles.Select(x => (x.Value.Item1.TextileName, x.Value.Item2)).ToList(),
|
||||
TotalCount = x.ShopTextiles.Select(x => x.Value.Item2).Sum()
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public List<ReportGroupedOrdersViewModel> GetGroupedOrders()
|
||||
{
|
||||
return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportGroupedOrdersViewModel
|
||||
{
|
||||
Date = x.Key,
|
||||
OrdersCount = x.Count(),
|
||||
OrdersSum = x.Select(y => y.Sum).Sum()
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public void SaveShopsToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateShopsDoc(new WordShopInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список магазинов",
|
||||
Shops = _shopStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveShopsToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateShopTextilesReport(new ExcelShopInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Загруженность магазинов",
|
||||
ShopTextiles = GetShops()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveGroupedOrdersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateGroupedOrdersDoc(new PdfGroupedOrdersInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список заказов сгруппированных по дате заказов",
|
||||
GroupedOrders = GetGroupedOrders()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
221
GarmentFactoryBusinessLogic/BusinessLogics/ShopLogic.cs
Normal file
221
GarmentFactoryBusinessLogic/BusinessLogics/ShopLogic.cs
Normal file
@ -0,0 +1,221 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.BusinessLogicsContracts;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.StoragesContracts;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ShopLogic : IShopLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
// Хранилище всех магазинов
|
||||
private readonly IShopStorage _shopStorage;
|
||||
|
||||
private readonly ITextileStorage _textileStorage;
|
||||
|
||||
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage, ITextileStorage textileStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_shopStorage = shopStorage;
|
||||
_textileStorage = textileStorage;
|
||||
}
|
||||
|
||||
// Чтение конкретного магазина
|
||||
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 Update(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_shopStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Удаление магазина
|
||||
public bool Delete(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_shopStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Пополнение магазина
|
||||
public bool MakeSupply(SupplyBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (model.Count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество добавляемых изделий должно быть больше 0");
|
||||
}
|
||||
|
||||
var textile = _textileStorage.GetElement(new TextileSearchModel { Id = model.TextileId });
|
||||
if (textile == null)
|
||||
{
|
||||
throw new ArgumentException($"При добавлении товара в магазин товар с id={model.TextileId} не найден");
|
||||
}
|
||||
|
||||
var shop = _shopStorage.GetElement(new ShopSearchModel { Id = model.ShopId });
|
||||
if (shop == null)
|
||||
{
|
||||
throw new ArgumentException($"При добавлении товара в магазин магазин c id={model.ShopId} не найден");
|
||||
}
|
||||
|
||||
int countTextilesInShop = shop.ShopTextiles.Select(x => x.Value.Item2).Sum();
|
||||
|
||||
//Если в текущий магазин помещается столько товаров
|
||||
if (countTextilesInShop + model.Count <= shop.TextileMaxCount)
|
||||
{
|
||||
// Если такой товар есть, то прибавление переданного кол-ва
|
||||
if (shop.ShopTextiles.ContainsKey(model.TextileId))
|
||||
{
|
||||
var oldValue = shop.ShopTextiles[model.TextileId];
|
||||
oldValue.Item2 += model.Count;
|
||||
shop.ShopTextiles[model.TextileId] = oldValue;
|
||||
}
|
||||
// Если такого товара нет, то кол-во такого товара равно переданному кол-ву
|
||||
else
|
||||
{
|
||||
shop.ShopTextiles.Add(model.TextileId, (textile, model.Count));
|
||||
}
|
||||
|
||||
_shopStorage.Update(new()
|
||||
{
|
||||
Id = shop.Id,
|
||||
ShopName = shop.ShopName,
|
||||
Address = shop.Address,
|
||||
DateOpen = shop.DateOpen,
|
||||
ShopTextiles = shop.ShopTextiles,
|
||||
TextileMaxCount = shop.TextileMaxCount,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
//Если не поместилось столько товара
|
||||
_logger.LogWarning("Required shop is overflowed");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Проверка данных магазина при добавлении/удалении/обновлении
|
||||
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));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Shop. ShopName:{ShopName}. Address:{Address}. Id: {Id}", model.ShopName, model.Address, model.Id);
|
||||
|
||||
var element = _shopStorage.GetElement(new ShopSearchModel { ShopName = model.ShopName });
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
|
||||
public bool Sell(SupplySearchModel model)
|
||||
{
|
||||
if (!model.TextileId.HasValue || !model.Count.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_shopStorage.Sell(model))
|
||||
{
|
||||
_logger.LogInformation("Selling sucsess");
|
||||
return true;
|
||||
}
|
||||
_logger.LogInformation("Selling failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -80,9 +80,82 @@ namespace GarmentFactoryBusinessLogic.OfficePackage
|
||||
|
||||
SaveExcel(info);
|
||||
}
|
||||
protected abstract void CreateExcel(ExcelInfo info);
|
||||
|
||||
public void CreateShopTextilesReport(ExcelShopInfo info)
|
||||
{
|
||||
CreateExcel(info);
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = 1,
|
||||
Text = info.Title,
|
||||
StyleInfo = ExcelStyleInfoType.Title
|
||||
});
|
||||
|
||||
MergeCells(new ExcelMergeParameters
|
||||
{
|
||||
CellFromName = "A1",
|
||||
CellToName = "C1"
|
||||
});
|
||||
|
||||
uint rowIndex = 2;
|
||||
foreach (var shop_textile in info.ShopTextiles)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = shop_textile.ShopName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
|
||||
foreach (var (textile, count) in shop_textile.Textiles)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = textile,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = count.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = "Итого",
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = shop_textile.TotalCount.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(info);
|
||||
}
|
||||
|
||||
protected abstract void CreateExcel(IDocumentInfo info);
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
|
||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||
protected abstract void SaveExcel(ExcelInfo info);
|
||||
protected abstract void SaveExcel(IDocumentInfo info);
|
||||
}
|
||||
}
|
||||
|
@ -38,10 +38,41 @@ namespace GarmentFactoryBusinessLogic.OfficePackage
|
||||
|
||||
SavePdf(info);
|
||||
}
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
|
||||
public void CreateGroupedOrdersDoc(PdfGroupedOrdersInfo info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
|
||||
CreateTable(new List<string> { "4cm", "3cm", "2cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Дата заказа", "Кол-во", "Сумма" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
|
||||
foreach (var groupedOrder in info.GroupedOrders)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { groupedOrder.Date.ToShortDateString(), groupedOrder.OrdersCount.ToString(), groupedOrder.OrdersSum.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
|
||||
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.GroupedOrders.Sum(x => x.OrdersSum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
|
||||
SavePdf(info);
|
||||
}
|
||||
|
||||
|
||||
protected abstract void CreatePdf(IDocumentInfo info);
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
protected abstract void SavePdf(IDocumentInfo info);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -43,11 +45,52 @@ namespace GarmentFactoryBusinessLogic.OfficePackage
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
public void CreateShopsDoc(WordShopInfo info)
|
||||
{
|
||||
CreateWord(info);
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
|
||||
CreateTable(new List<string> { "3000", "3000", "3000" });
|
||||
CreateRow(new WordRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Название", "Адрес", "Дата открытия" },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
Bold = true,
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var shop in info.Shops)
|
||||
{
|
||||
CreateRow(new WordRowParameters
|
||||
{
|
||||
Texts = new List<string> { shop.ShopName, shop.Address, shop.DateOpen.ToString() },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "22",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Создание doc-файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void CreateWord(WordInfo info);
|
||||
protected abstract void CreateWord(IDocumentInfo info);
|
||||
|
||||
/// <summary>
|
||||
/// Создание абзаца с текстом
|
||||
@ -60,6 +103,9 @@ namespace GarmentFactoryBusinessLogic.OfficePackage
|
||||
/// Сохранение файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void SaveWord(WordInfo info);
|
||||
protected abstract void SaveWord(IDocumentInfo info);
|
||||
|
||||
protected abstract void CreateTable(List<string> colums);
|
||||
protected abstract void CreateRow(WordRowParameters rowParameters);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfo
|
||||
public class ExcelInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
@ -0,0 +1,16 @@
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelShopInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ReportShopsViewModel> ShopTextiles { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfGroupedOrdersInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ReportGroupedOrdersViewModel> GroupedOrders { get; set; } = new();
|
||||
}
|
||||
}
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfInfo
|
||||
public class PdfInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -7,7 +8,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordInfo
|
||||
public class WordInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
@ -0,0 +1,15 @@
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordRowParameters
|
||||
{
|
||||
public List<string> Texts { get; set; } = new();
|
||||
public WordTextProperties TextProperties { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordShopInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ShopViewModel> Shops { get; set; } = new();
|
||||
}
|
||||
}
|
14
GarmentFactoryBusinessLogic/OfficePackage/IDocument.cs
Normal file
14
GarmentFactoryBusinessLogic/OfficePackage/IDocument.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryBusinessLogic.OfficePackage
|
||||
{
|
||||
public interface IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
@ -159,7 +159,7 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
|
||||
};
|
||||
}
|
||||
|
||||
protected override void CreateExcel(ExcelInfo info)
|
||||
protected override void CreateExcel(IDocumentInfo info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
|
||||
// Создание книги (в ней хранятся листы)
|
||||
@ -288,7 +288,7 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
|
||||
mergeCells.Append(mergeCell);
|
||||
}
|
||||
|
||||
protected override void SaveExcel(ExcelInfo info)
|
||||
protected override void SaveExcel(IDocumentInfo info)
|
||||
{
|
||||
if (_spreadsheetDocument == null)
|
||||
{
|
||||
|
@ -38,7 +38,7 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
|
||||
style.Font.Bold = true;
|
||||
}
|
||||
|
||||
protected override void CreatePdf(PdfInfo info)
|
||||
protected override void CreatePdf(IDocumentInfo info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
@ -100,7 +100,7 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SavePdf(PdfInfo info)
|
||||
protected override void SavePdf(IDocumentInfo info)
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
|
@ -85,7 +85,7 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
|
||||
return properties;
|
||||
}
|
||||
|
||||
protected override void CreateWord(WordInfo info)
|
||||
protected override void CreateWord(IDocumentInfo info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
@ -123,7 +123,7 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
|
||||
_docBody.AppendChild(docParagraph);
|
||||
}
|
||||
|
||||
protected override void SaveWord(WordInfo info)
|
||||
protected override void SaveWord(IDocumentInfo info)
|
||||
{
|
||||
if (_docBody == null || _wordDocument == null)
|
||||
{
|
||||
@ -135,5 +135,81 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
|
||||
|
||||
_wordDocument.Close();
|
||||
}
|
||||
|
||||
private Table? _table;
|
||||
protected override void CreateTable(List<string> columns)
|
||||
{
|
||||
if (_docBody == null)
|
||||
return;
|
||||
|
||||
_table = new Table();
|
||||
|
||||
var tableProp = new TableProperties();
|
||||
//фиксированные значения столбцов/строк
|
||||
tableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
|
||||
//задание всех границ (внешних и внутренних)
|
||||
tableProp.AppendChild(new TableBorders(
|
||||
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 }
|
||||
));
|
||||
_table.AppendChild(tableProp);
|
||||
|
||||
//сетка таблцы(строки/столбцы)
|
||||
TableGrid tableGrid = new TableGrid();
|
||||
//columns - передаваемые размеры (ширина) столбцов
|
||||
foreach (var column in columns)
|
||||
{
|
||||
tableGrid.AppendChild(new GridColumn() { Width = column });
|
||||
}
|
||||
_table.AppendChild(tableGrid);
|
||||
|
||||
_docBody.AppendChild(_table);
|
||||
}
|
||||
|
||||
protected override void CreateRow(WordRowParameters rowParameters)
|
||||
{
|
||||
if (_docBody == null || _table == null)
|
||||
return;
|
||||
|
||||
TableRow docRow = new TableRow();
|
||||
foreach (var column in rowParameters.Texts)
|
||||
{
|
||||
var docParagraph = new Paragraph();
|
||||
WordParagraph paragraph = new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (column, rowParameters.TextProperties) },
|
||||
TextProperties = rowParameters.TextProperties
|
||||
};
|
||||
|
||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||
|
||||
foreach (var run in paragraph.Texts)
|
||||
{
|
||||
//задание свойств для каждого текста в абзаце
|
||||
var docRun = new Run();
|
||||
|
||||
var properties = new RunProperties();
|
||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||
if (run.Item2.Bold)
|
||||
{
|
||||
properties.AppendChild(new Bold());
|
||||
}
|
||||
docRun.AppendChild(properties);
|
||||
|
||||
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||
//добавления текста в абзац
|
||||
docParagraph.AppendChild(docRun);
|
||||
}
|
||||
//добавление абзаца в ячейку, а ячейки в строку
|
||||
TableCell docCell = new TableCell();
|
||||
docCell.AppendChild(docParagraph);
|
||||
docRow.AppendChild(docCell);
|
||||
}
|
||||
_table.AppendChild(docRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
23
GarmentFactoryContracts/BindingModels/ShopBindingModel.cs
Normal file
23
GarmentFactoryContracts/BindingModels/ShopBindingModel.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryContracts.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 DateOpen { get; set; } = DateTime.Now;
|
||||
|
||||
public Dictionary<int, (ITextileModel, int)> ShopTextiles { get; set; } = new();
|
||||
|
||||
public int TextileMaxCount { get; set; }
|
||||
}
|
||||
}
|
16
GarmentFactoryContracts/BindingModels/SupplyBindingModel.cs
Normal file
16
GarmentFactoryContracts/BindingModels/SupplyBindingModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryContracts.BindingModels
|
||||
{
|
||||
public class SupplyBindingModel : ISupplyModel
|
||||
{
|
||||
public int ShopId { get; set; }
|
||||
public int TextileId { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
@ -14,11 +14,19 @@ namespace GarmentFactoryContracts.BusinessLogicsContracts
|
||||
|
||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||
|
||||
List<ReportGroupedOrdersViewModel> GetGroupedOrders();
|
||||
|
||||
List<ReportShopsViewModel> GetShops();
|
||||
|
||||
void SaveTextilesToWordFile(ReportBindingModel model);
|
||||
|
||||
void SaveTextileComponentToExcelFile(ReportBindingModel model);
|
||||
|
||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||
|
||||
void SaveShopsToWordFile(ReportBindingModel model);
|
||||
void SaveShopsToExcelFile(ReportBindingModel model);
|
||||
void SaveGroupedOrdersToPdfFile(ReportBindingModel model);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IShopLogic
|
||||
{
|
||||
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||
|
||||
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||
|
||||
bool Create(ShopBindingModel model);
|
||||
|
||||
bool Update(ShopBindingModel model);
|
||||
|
||||
bool Delete(ShopBindingModel model);
|
||||
|
||||
bool MakeSupply(SupplyBindingModel model);
|
||||
|
||||
bool Sell(SupplySearchModel model);
|
||||
}
|
||||
}
|
14
GarmentFactoryContracts/SearchModels/ShopSearchModel.cs
Normal file
14
GarmentFactoryContracts/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 GarmentFactoryContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ShopName { get; set; }
|
||||
}
|
||||
}
|
14
GarmentFactoryContracts/SearchModels/SupplySearchModel.cs
Normal file
14
GarmentFactoryContracts/SearchModels/SupplySearchModel.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryContracts.SearchModels
|
||||
{
|
||||
public class SupplySearchModel
|
||||
{
|
||||
public int? TextileId { get; set; }
|
||||
public int? Count { get; set; }
|
||||
}
|
||||
}
|
25
GarmentFactoryContracts/StoragesContracts/IShopStorage.cs
Normal file
25
GarmentFactoryContracts/StoragesContracts/IShopStorage.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryContracts.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(SupplySearchModel model);
|
||||
//Пополнение магаз-ов
|
||||
bool RestockShops(SupplyBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryContracts.ViewModels
|
||||
{
|
||||
public class ReportGroupedOrdersViewModel
|
||||
{
|
||||
public DateTime Date { get; set; } = DateTime.Now;
|
||||
public int OrdersCount { get; set; }
|
||||
public double OrdersSum { get; set; }
|
||||
}
|
||||
}
|
15
GarmentFactoryContracts/ViewModels/ReportShopsViewModel.cs
Normal file
15
GarmentFactoryContracts/ViewModels/ReportShopsViewModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryContracts.ViewModels
|
||||
{
|
||||
public class ReportShopsViewModel
|
||||
{
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
public int TotalCount { get; set; }
|
||||
public List<(string textile, int count)> Textiles { get; set; } = new();
|
||||
}
|
||||
}
|
31
GarmentFactoryContracts/ViewModels/ShopViewModel.cs
Normal file
31
GarmentFactoryContracts/ViewModels/ShopViewModel.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryContracts.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 DateOpen { get; set; } = DateTime.Now;
|
||||
|
||||
public Dictionary<int, (ITextileModel, int)> ShopTextiles { get; set; } = new();
|
||||
|
||||
[DisplayName("Вместимость")]
|
||||
public int TextileMaxCount { get; set; }
|
||||
|
||||
public List<Tuple<string, int>>? TextileCount { get; set; } = new();
|
||||
}
|
||||
}
|
19
GarmentFactoryDataModels/Models/IShopModel.cs
Normal file
19
GarmentFactoryDataModels/Models/IShopModel.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryDataModels.Models
|
||||
{
|
||||
public interface IShopModel : IId
|
||||
{
|
||||
string ShopName { get; }
|
||||
string Address { get; }
|
||||
DateTime DateOpen { get; }
|
||||
//Изделия в магазине
|
||||
Dictionary<int, (ITextileModel, int)> ShopTextiles { get; }
|
||||
//макс. кол-во изделий
|
||||
int TextileMaxCount { get; }
|
||||
}
|
||||
}
|
16
GarmentFactoryDataModels/Models/ISupplyModel.cs
Normal file
16
GarmentFactoryDataModels/Models/ISupplyModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryDataModels.Models
|
||||
{
|
||||
//Сущность для связи многие-ко-многим между товарами и магазинами
|
||||
public class ISupplyModel
|
||||
{
|
||||
int ShopId { get; }
|
||||
int TextileId { get; }
|
||||
int Count { get; }
|
||||
}
|
||||
}
|
@ -28,6 +28,10 @@ namespace GarmentFactoryDatabaseImplement
|
||||
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
|
||||
public virtual DbSet<Shop> Shops { get; set; }
|
||||
|
||||
public virtual DbSet<ShopTextile> ShopTextiles { get; set; }
|
||||
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
}
|
||||
}
|
||||
|
246
GarmentFactoryDatabaseImplement/Implements/ShopStorage.cs
Normal file
246
GarmentFactoryDatabaseImplement/Implements/ShopStorage.cs
Normal file
@ -0,0 +1,246 @@
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.StoragesContracts;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryDatabaseImplement.Models;
|
||||
|
||||
namespace GarmentFactoryDatabaseImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
using var context = new GarmentFactoryDatabase();
|
||||
return context.Shops
|
||||
.Include(x => x.Textiles)
|
||||
.ThenInclude(x => x.Textile)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new GarmentFactoryDatabase();
|
||||
|
||||
return context.Shops
|
||||
.Include(x => x.Textiles)
|
||||
.ThenInclude(x => x.Textile)
|
||||
.Where(x => x.ShopName.Contains(model.ShopName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new GarmentFactoryDatabase();
|
||||
|
||||
return context.Shops
|
||||
.Include(x => x.Textiles)
|
||||
.ThenInclude(x => x.Textile)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
using var context = new GarmentFactoryDatabase();
|
||||
|
||||
var newShop = Shop.Create(context, model);
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Shops.Add(newShop);
|
||||
context.SaveChanges();
|
||||
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
using var context = new GarmentFactoryDatabase();
|
||||
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var shop = context.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (shop == null)
|
||||
return null;
|
||||
|
||||
shop.Update(model);
|
||||
context.SaveChanges();
|
||||
if (model.ShopTextiles.Count != 0)
|
||||
{
|
||||
shop.UpdateTextiles(context, model);
|
||||
}
|
||||
|
||||
transaction.Commit();
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
using var context = new GarmentFactoryDatabase();
|
||||
var element = context.Shops
|
||||
.Include(x => x.Textiles)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Shops.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//продажа текстиля из магазинов
|
||||
public bool Sell(SupplySearchModel model)
|
||||
{
|
||||
using var context = new GarmentFactoryDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
//поиск всех магаз-ов, в кот. есть нужный текстиль (сортировка: сначала те, где его больше)
|
||||
var shopsWithThisTextile = context.Shops
|
||||
.Include(x => x.Textiles)
|
||||
.ThenInclude(x => x.Textile)
|
||||
.ToList()
|
||||
.Where(x => x.ShopTextiles.ContainsKey(model.TextileId.Value))
|
||||
.OrderByDescending(x => x.ShopTextiles[model.TextileId.Value].Item2)
|
||||
.ToList();
|
||||
|
||||
foreach (var shop in shopsWithThisTextile)
|
||||
{
|
||||
//сколько надо будет этого текстиля, если продать все из текущего магазина
|
||||
int thisTextileNeeded = model.Count.Value - shop.ShopTextiles[model.TextileId.Value].Item2;
|
||||
|
||||
//если ещё надо будет
|
||||
if (thisTextileNeeded > 0)
|
||||
{
|
||||
//полное удаление этого текстиля из этого магазина
|
||||
shop.ShopTextiles.Remove(model.TextileId.Value);
|
||||
shop.DictionaryTextilesUpdate(context);
|
||||
context.SaveChanges();
|
||||
|
||||
model.Count = thisTextileNeeded;
|
||||
}
|
||||
else
|
||||
{
|
||||
//если в этом магазине ровно столько, сколько надо
|
||||
if (thisTextileNeeded == 0)
|
||||
{
|
||||
shop.ShopTextiles.Remove(model.TextileId.Value);
|
||||
}
|
||||
//если в этом магазине больше, чем надо
|
||||
else
|
||||
{
|
||||
//уменьшение в этом магазине этого текстиля на нужное кол-во
|
||||
var textileAndCount = shop.ShopTextiles[model.TextileId.Value];
|
||||
textileAndCount.Item2 = -thisTextileNeeded;
|
||||
shop.ShopTextiles[model.TextileId.Value] = textileAndCount;
|
||||
}
|
||||
shop.DictionaryTextilesUpdate(context);
|
||||
transaction.Commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//пополнение магазинов текстилем
|
||||
public bool RestockShops(SupplyBindingModel model)
|
||||
{
|
||||
using var context = new GarmentFactoryDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
|
||||
//все магазины, где ещё есть свободное место (занятое кол-во < максимально допустимого)
|
||||
var shops = context.Shops
|
||||
.Include(x => x.Textiles)
|
||||
.ThenInclude(x => x.Textile)
|
||||
.ToList()
|
||||
.Where(x => x.ShopTextiles.Select(x => x.Value.Item2).Sum() < x.TextileMaxCount)
|
||||
.ToList();
|
||||
|
||||
try
|
||||
{
|
||||
foreach (Shop shop in shops)
|
||||
{
|
||||
//свободное место в этом магазине
|
||||
int freeSpace = shop.TextileMaxCount - shop.ShopTextiles.Select(x => x.Value.Item2).Sum();
|
||||
|
||||
//кол-во кот. надо для этого магазина (либо до макс. кол-ва, либо кол-во, кот. осталось в "поставке" (что меньше))
|
||||
int restock = Math.Min(freeSpace, model.Count);
|
||||
model.Count -= restock;
|
||||
|
||||
//если в этом магазине есть этот текстиль, то изменение его кол-ва
|
||||
if (shop.ShopTextiles.ContainsKey(model.TextileId))
|
||||
{
|
||||
var textileAndCount = shop.ShopTextiles[model.TextileId];
|
||||
textileAndCount.Item2 += restock;
|
||||
shop.ShopTextiles[model.TextileId] = textileAndCount;
|
||||
}
|
||||
//если нет, то добавление в этом кол-ве
|
||||
else
|
||||
{
|
||||
var textile = context.Textiles.First(x => x.Id == model.TextileId);
|
||||
shop.ShopTextiles.Add(model.TextileId, (textile, restock));
|
||||
}
|
||||
|
||||
shop.DictionaryTextilesUpdate(context);
|
||||
|
||||
//если в "поставке" закончились товары, то всё ок
|
||||
if (model.Count == 0)
|
||||
{
|
||||
transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
248
GarmentFactoryDatabaseImplement/Migrations/20240515060701_Lab3_Hard_AddedShops.Designer.cs
generated
Normal file
248
GarmentFactoryDatabaseImplement/Migrations/20240515060701_Lab3_Hard_AddedShops.Designer.cs
generated
Normal file
@ -0,0 +1,248 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using GarmentFactoryDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace GarmentFactoryDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(GarmentFactoryDatabase))]
|
||||
[Migration("20240515060701_Lab3_Hard_AddedShops")]
|
||||
partial class Lab3_Hard_AddedShops
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.17")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.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("GarmentFactoryDatabaseImplement.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?>("DateComplete")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<int>("TextileId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TextileId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("DateOpen")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("TextileMaxCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.ShopTextile", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TextileId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.HasIndex("TextileId");
|
||||
|
||||
b.ToTable("ShopTextiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Textile", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("TextileName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Textiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.TextileComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TextileId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("TextileId");
|
||||
|
||||
b.ToTable("TextileComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("GarmentFactoryDatabaseImplement.Models.Textile", "Textile")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("TextileId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Textile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.ShopTextile", b =>
|
||||
{
|
||||
b.HasOne("GarmentFactoryDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Textiles")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("GarmentFactoryDatabaseImplement.Models.Textile", "Textile")
|
||||
.WithMany()
|
||||
.HasForeignKey("TextileId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Shop");
|
||||
|
||||
b.Navigation("Textile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.TextileComponent", b =>
|
||||
{
|
||||
b.HasOne("GarmentFactoryDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("TextileComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("GarmentFactoryDatabaseImplement.Models.Textile", "Textile")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("TextileId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Textile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("TextileComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Textiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Textile", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace GarmentFactoryDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Lab3_Hard_AddedShops : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Shops",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateOpen = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
TextileMaxCount = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ShopTextiles",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
TextileId = table.Column<int>(type: "int", nullable: false),
|
||||
ShopId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ShopTextiles", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopTextiles_Shops_ShopId",
|
||||
column: x => x.ShopId,
|
||||
principalTable: "Shops",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopTextiles_Textiles_TextileId",
|
||||
column: x => x.TextileId,
|
||||
principalTable: "Textiles",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopTextiles_ShopId",
|
||||
table: "ShopTextiles",
|
||||
column: "ShopId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopTextiles_TextileId",
|
||||
table: "ShopTextiles",
|
||||
column: "TextileId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ShopTextiles");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Shops");
|
||||
}
|
||||
}
|
||||
}
|
@ -105,6 +105,59 @@ namespace GarmentFactoryDatabaseImplement.Migrations
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("DateOpen")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("TextileMaxCount")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.ShopTextile", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TextileId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.HasIndex("TextileId");
|
||||
|
||||
b.ToTable("ShopTextiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Textile", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -170,6 +223,25 @@ namespace GarmentFactoryDatabaseImplement.Migrations
|
||||
b.Navigation("Textile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.ShopTextile", b =>
|
||||
{
|
||||
b.HasOne("GarmentFactoryDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Textiles")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("GarmentFactoryDatabaseImplement.Models.Textile", "Textile")
|
||||
.WithMany()
|
||||
.HasForeignKey("TextileId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Shop");
|
||||
|
||||
b.Navigation("Textile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.TextileComponent", b =>
|
||||
{
|
||||
b.HasOne("GarmentFactoryDatabaseImplement.Models.Component", "Component")
|
||||
@ -199,6 +271,11 @@ namespace GarmentFactoryDatabaseImplement.Migrations
|
||||
b.Navigation("TextileComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Textiles");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GarmentFactoryDatabaseImplement.Models.Textile", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
136
GarmentFactoryDatabaseImplement/Models/Shop.cs
Normal file
136
GarmentFactoryDatabaseImplement/Models/Shop.cs
Normal file
@ -0,0 +1,136 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
|
||||
namespace GarmentFactoryDatabaseImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public DateTime DateOpen { get; set; }
|
||||
|
||||
[Required]
|
||||
public int TextileMaxCount { get; set; }
|
||||
|
||||
[ForeignKey("ShopId")]
|
||||
public List<ShopTextile> Textiles { get; set; } = new();
|
||||
|
||||
private Dictionary<int, (ITextileModel, int)>? _shopTextiles = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (ITextileModel, int)> ShopTextiles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_shopTextiles == null)
|
||||
{
|
||||
if (_shopTextiles == null)
|
||||
{
|
||||
_shopTextiles = Textiles.ToDictionary(x => x.TextileId, y => (y.Textile as ITextileModel, y.Count));
|
||||
}
|
||||
return _shopTextiles;
|
||||
}
|
||||
|
||||
return _shopTextiles;
|
||||
}
|
||||
}
|
||||
|
||||
public static Shop Create(GarmentFactoryDatabase context, ShopBindingModel model)
|
||||
{
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpen = model.DateOpen,
|
||||
TextileMaxCount = model.TextileMaxCount,
|
||||
Textiles = model.ShopTextiles.Select(x => new ShopTextile
|
||||
{
|
||||
Textile = context.Textiles.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList(),
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel model)
|
||||
{
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpen = model.DateOpen;
|
||||
TextileMaxCount = model.TextileMaxCount;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpen = DateOpen,
|
||||
ShopTextiles = ShopTextiles,
|
||||
TextileMaxCount = TextileMaxCount
|
||||
};
|
||||
|
||||
public void UpdateTextiles(GarmentFactoryDatabase context, ShopBindingModel model)
|
||||
{
|
||||
var ShopTextiles = context.ShopTextiles
|
||||
.Where(rec => rec.ShopId == model.Id)
|
||||
.ToList();
|
||||
|
||||
if (ShopTextiles != null && ShopTextiles.Count > 0)
|
||||
{
|
||||
context.ShopTextiles.RemoveRange(ShopTextiles.Where(rec => !model.ShopTextiles.ContainsKey(rec.TextileId)));
|
||||
context.SaveChanges();
|
||||
|
||||
ShopTextiles = context.ShopTextiles.Where(rec => rec.ShopId == model.Id).ToList();
|
||||
|
||||
foreach (var textileToUpdate in ShopTextiles)
|
||||
{
|
||||
textileToUpdate.Count = model.ShopTextiles[textileToUpdate.TextileId].Item2;
|
||||
model.ShopTextiles.Remove(textileToUpdate.TextileId);
|
||||
}
|
||||
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
var Shop = context.Shops.First(x => x.Id == Id);
|
||||
|
||||
foreach (var ShopTextile in model.ShopTextiles)
|
||||
{
|
||||
context.ShopTextiles.Add(new ShopTextile
|
||||
{
|
||||
Shop = Shop,
|
||||
Textile = context.Textiles.First(x => x.Id == ShopTextile.Key),
|
||||
Count = ShopTextile.Value.Item2
|
||||
});
|
||||
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
_shopTextiles = null;
|
||||
}
|
||||
|
||||
public void DictionaryTextilesUpdate(GarmentFactoryDatabase context)
|
||||
{
|
||||
UpdateTextiles(context, new ShopBindingModel
|
||||
{
|
||||
Id = Id,
|
||||
ShopTextiles = ShopTextiles
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
27
GarmentFactoryDatabaseImplement/Models/ShopTextile.cs
Normal file
27
GarmentFactoryDatabaseImplement/Models/ShopTextile.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryDatabaseImplement.Models
|
||||
{
|
||||
public class ShopTextile
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int TextileId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ShopId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Shop Shop { get; set; } = new();
|
||||
|
||||
public virtual Textile Textile { get; set; } = new();
|
||||
}
|
||||
}
|
@ -14,10 +14,13 @@ namespace GarmentFactoryFileImplement
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string TextileFileName = "Textile.xml";
|
||||
private readonly string ShopFileName = "Shop.xml";
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Textile> Textiles { get; private set; }
|
||||
public List<Shop> Shops { get; private set; }
|
||||
public List<Client> Clients { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
@ -30,6 +33,7 @@ namespace GarmentFactoryFileImplement
|
||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||
public void SaveTextiles() => SaveData(Textiles, TextileFileName, "Textiles", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||
|
||||
private DataFileSingleton()
|
||||
@ -37,6 +41,7 @@ namespace GarmentFactoryFileImplement
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Textiles = LoadData(TextileFileName, "Textile", x => Textile.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||
}
|
||||
|
||||
|
183
GarmentFactoryFileImplement/Implements/ShopStorage.cs
Normal file
183
GarmentFactoryFileImplement/Implements/ShopStorage.cs
Normal file
@ -0,0 +1,183 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.StoragesContracts;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryFileImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public ShopStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
return source.Shops.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return source.Shops.Where(x => x.ShopName.Contains(model.ShopName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Shops.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
model.Id = source.Shops.Count > 0 ? source.Shops.Max(x => x.Id) + 1 : 1;
|
||||
var newShop = Shop.Create(model);
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Shops.Add(newShop);
|
||||
source.SaveShops();
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (shop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
shop.Update(model);
|
||||
source.SaveShops();
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (shop != null)
|
||||
{
|
||||
source.Shops.Remove(shop);
|
||||
source.SaveShops();
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Sell(SupplySearchModel model)
|
||||
{
|
||||
if (model == null || !model.TextileId.HasValue || !model.Count.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//магазины по степени наполненности (от самого наполненного) с этим текстилем
|
||||
var shopsWithThisTextile = source.Shops.Where(x => x.Textiles.ContainsKey(model.TextileId.Value)).OrderByDescending(x => x.Textiles[model.TextileId.Value]).ToList();
|
||||
|
||||
int thisTextileInShops = shopsWithThisTextile.Select(x => x.Textiles[model.TextileId.Value]).Sum();
|
||||
|
||||
if (thisTextileInShops < model.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var shop in shopsWithThisTextile)
|
||||
{
|
||||
//кол-во необходимых текстилей после возможной продажи всех текстилей
|
||||
int thisTextileNeed = model.Count.Value - shop.Textiles[model.TextileId.Value];
|
||||
|
||||
//Если текстиль ещё нужен будет
|
||||
if (thisTextileNeed > 0)
|
||||
{
|
||||
//удаление всех текстилей в этом магазине
|
||||
shop.Textiles.Remove(model.TextileId.Value);
|
||||
shop.TextilesUpdate();
|
||||
model.Count = thisTextileNeed;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//Если ровно хватает
|
||||
if (thisTextileNeed == 0)
|
||||
{
|
||||
shop.Textiles.Remove(model.TextileId.Value);
|
||||
}
|
||||
//Если нужно меньше, чем есть в магазине
|
||||
else
|
||||
{
|
||||
//уменьшение кол-ва
|
||||
shop.Textiles[model.TextileId.Value] = -thisTextileNeed;
|
||||
}
|
||||
shop.TextilesUpdate();
|
||||
source.SaveShops();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
source.SaveShops();
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool RestockShops(SupplyBindingModel model)
|
||||
{
|
||||
//подсчёт свободных мест через сумму свободных мест в каждом магазине
|
||||
//в каждом магазине кол-во свободных мест = макс. кол-во - занятые места
|
||||
int totalFreeSpace = source.Shops
|
||||
.Select(x => x.TextileMaxCount - x.ShopTextiles.Select(y => y.Value.Item2).Sum())
|
||||
.Sum();
|
||||
|
||||
//если места не хватает
|
||||
if (totalFreeSpace < model.Count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var shopsWithFreeSpace = source.Shops.Where(x => x.TextileMaxCount - x.ShopTextiles.Select(x => x.Value.Item2).Sum() > 0);
|
||||
|
||||
foreach (Shop shop in shopsWithFreeSpace)
|
||||
{
|
||||
int freeSpace = shop.TextileMaxCount - shop.ShopTextiles.Select(x => x.Value.Item2).Sum();
|
||||
|
||||
freeSpace = Math.Min(freeSpace, model.Count);
|
||||
model.Count -= freeSpace;
|
||||
|
||||
if (shop.Textiles.ContainsKey(model.TextileId))
|
||||
{
|
||||
shop.Textiles[model.TextileId] += freeSpace;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
shop.Textiles.Add(model.TextileId, freeSpace);
|
||||
}
|
||||
|
||||
shop.TextilesUpdate();
|
||||
|
||||
if (model.Count == 0)
|
||||
{
|
||||
source.SaveShops();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
111
GarmentFactoryFileImplement/Models/Shop.cs
Normal file
111
GarmentFactoryFileImplement/Models/Shop.cs
Normal file
@ -0,0 +1,111 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace GarmentFactoryFileImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
public DateTime DateOpen { get; private set; }
|
||||
public Dictionary<int, int> Textiles { get; private set; } = new();
|
||||
private Dictionary<int, (ITextileModel, int)>? _shopTextiles = null;
|
||||
|
||||
public Dictionary<int, (ITextileModel, int)> ShopTextiles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_shopTextiles == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_shopTextiles = Textiles.ToDictionary(x => x.Key, y => ((source.Textiles.FirstOrDefault(z => z.Id == y.Key) as ITextileModel)!, y.Value));
|
||||
}
|
||||
return _shopTextiles;
|
||||
}
|
||||
}
|
||||
|
||||
public int TextileMaxCount { get; private set; }
|
||||
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpen = model.DateOpen,
|
||||
Textiles = model.ShopTextiles.ToDictionary(x => x.Key, x => x.Value.Item2),
|
||||
TextileMaxCount = model.TextileMaxCount
|
||||
};
|
||||
}
|
||||
|
||||
public static Shop? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ShopName = element.Element("ShopName")!.Value,
|
||||
Address = element.Element("Address")!.Value,
|
||||
DateOpen = Convert.ToDateTime(element.Element("DateOpen")!.Value),
|
||||
Textiles = element.Element("ShopTextiles")!.Elements("ShopTextile")!.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||
x => Convert.ToInt32(x.Element("Value")?.Value)),
|
||||
TextileMaxCount = Convert.ToInt32(element.Element("TextileMaxCount")!.Value)
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpen = model.DateOpen;
|
||||
TextileMaxCount = model.TextileMaxCount;
|
||||
Textiles = model.ShopTextiles.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
_shopTextiles = null;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpen = DateOpen,
|
||||
ShopTextiles = ShopTextiles,
|
||||
TextileMaxCount = TextileMaxCount
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("Shop",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ShopName", ShopName),
|
||||
new XElement("Address", Address),
|
||||
new XElement("DateOpen", DateOpen.ToString()),
|
||||
new XElement("ShopTextiles", Textiles.Select(
|
||||
x => new XElement("ShopTextile", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray()),
|
||||
new XElement("TextileMaxCount", TextileMaxCount.ToString())
|
||||
);
|
||||
|
||||
public void TextilesUpdate()
|
||||
{
|
||||
_shopTextiles = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,12 +8,14 @@ namespace GarmentFactoryListImplement
|
||||
public List<Component> Components { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Textile> Textiles { get; set; }
|
||||
public List<Shop> Shops { get; set; }
|
||||
public List<Client> Clients { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Textiles = new List<Textile>();
|
||||
Shops = new List<Shop>();
|
||||
Clients = new List<Client>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
|
124
GarmentFactoryListImplement/Implements/ShopStorage.cs
Normal file
124
GarmentFactoryListImplement/Implements/ShopStorage.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.StoragesContracts;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using GarmentFactoryListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryListImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
|
||||
public ShopStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.ShopName.Contains(model.ShopName))
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) ||
|
||||
(model.Id.HasValue && shop.Id == model.Id))
|
||||
{
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (model.Id <= shop.Id)
|
||||
{
|
||||
model.Id = shop.Id + 1;
|
||||
}
|
||||
}
|
||||
var newShop = Shop.Create(model);
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Shops.Add(newShop);
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.Id == model.Id)
|
||||
{
|
||||
shop.Update(model);
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||
{
|
||||
if (_source.Shops[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Shops[i];
|
||||
_source.Shops.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Sell(SupplySearchModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool RestockShops(SupplyBindingModel model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
66
GarmentFactoryListImplement/Models/Shop.cs
Normal file
66
GarmentFactoryListImplement/Models/Shop.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GarmentFactoryListImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
|
||||
public DateTime DateOpen { get; private set; }
|
||||
|
||||
public Dictionary<int, (ITextileModel, int)> ShopTextiles { get; private set; } = new();
|
||||
|
||||
public int TextileMaxCount { get; private set; }
|
||||
|
||||
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpen = model.DateOpen,
|
||||
ShopTextiles = model.ShopTextiles,
|
||||
TextileMaxCount = model.TextileMaxCount
|
||||
};
|
||||
}
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpen = model.DateOpen;
|
||||
ShopTextiles = model.ShopTextiles;
|
||||
TextileMaxCount = model.TextileMaxCount;
|
||||
|
||||
}
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpen = DateOpen,
|
||||
ShopTextiles = ShopTextiles,
|
||||
TextileMaxCount = TextileMaxCount
|
||||
};
|
||||
}
|
||||
}
|
107
GarmentFactoryRestApi/Controllers/ShopController.cs
Normal file
107
GarmentFactoryRestApi/Controllers/ShopController.cs
Normal file
@ -0,0 +1,107 @@
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.BusinessLogicsContracts;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Identity.Client;
|
||||
|
||||
namespace GarmentFactoryRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ShopController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
|
||||
public ShopController(ILogger<ShopController> logger, IShopLogic shopLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_shopLogic = shopLogic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ShopViewModel>? GetShopList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _shopLogic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка магазинов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ShopViewModel? GetShop(int shopId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _shopLogic.ReadElement(new ShopSearchModel { Id = shopId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateShop(ShopBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_shopLogic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateShop(ShopBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_shopLogic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteShop(ShopBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_shopLogic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void MakeSupply(SupplyBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_shopLogic.MakeSupply(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания поставки в магазин");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -13,10 +13,12 @@ builder.Logging.AddLog4Net("log4net.config");
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<ITextileStorage, TextileStorage>();
|
||||
builder.Services.AddTransient<IShopStorage, ShopStorage>();
|
||||
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<ITextileLogic, TextileLogic>();
|
||||
builder.Services.AddTransient<IShopLogic, ShopLogic>();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
|
83
GarmentFactoryShopsApp/APIClient.cs
Normal file
83
GarmentFactoryShopsApp/APIClient.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
||||
namespace GarmentFactoryShopsApp
|
||||
{
|
||||
public class APIClient
|
||||
{
|
||||
private static readonly HttpClient _client = new HttpClient {Timeout = TimeSpan.FromMinutes(10)};
|
||||
|
||||
public static bool isAuth { get; private set; } = false;
|
||||
|
||||
private static string ConfigPassword { get; set; } = string.Empty;
|
||||
|
||||
public static bool Login(string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Enter the password");
|
||||
}
|
||||
|
||||
return isAuth = password.Equals(ConfigPassword);
|
||||
}
|
||||
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
ConfigPassword = configuration["Password"];
|
||||
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
|
||||
public static T? GetRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = _client.GetAsync(requestUrl);
|
||||
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
|
||||
if (response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<T?> GetAsyncRequest<T>(string requestUrl)
|
||||
{
|
||||
var response = await _client.GetAsync(requestUrl);
|
||||
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
public static void PostRequest<T>(string requestUrl, T model)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(model);
|
||||
|
||||
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
var response = _client.PostAsync(requestUrl, data);
|
||||
|
||||
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||
|
||||
if (!response.Result.IsSuccessStatusCode)
|
||||
{
|
||||
throw new Exception(result);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
178
GarmentFactoryShopsApp/Controllers/HomeController.cs
Normal file
178
GarmentFactoryShopsApp/Controllers/HomeController.cs
Normal file
@ -0,0 +1,178 @@
|
||||
using GarmentFactoryBusinessLogic.BusinessLogics;
|
||||
using GarmentFactoryContracts.BindingModels;
|
||||
using GarmentFactoryContracts.BusinessLogicsContracts;
|
||||
using GarmentFactoryContracts.SearchModels;
|
||||
using GarmentFactoryContracts.ViewModels;
|
||||
using GarmentFactoryShopsApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace GarmentFactoryShopsApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger, IShopLogic logic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (!APIClient.isAuth)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(APIClient.GetRequest<List<ShopViewModel>>($"api/shop/getshoplist"));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Enter(string password)
|
||||
{
|
||||
if (!APIClient.Login(password))
|
||||
{
|
||||
throw new Exception("Wrong password");
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Create()
|
||||
{
|
||||
if (!APIClient.isAuth)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(string shopName, string address, DateTime dateOpen, int maxCount)
|
||||
{
|
||||
if (string.IsNullOrEmpty(shopName) || string.IsNullOrEmpty(address))
|
||||
{
|
||||
throw new Exception("Название и адрес не могут быть пустым");
|
||||
}
|
||||
if (dateOpen == default(DateTime))
|
||||
{
|
||||
throw new Exception("Дата открытия не может быть пустой");
|
||||
}
|
||||
|
||||
APIClient.PostRequest($"api/shop/createshop", new ShopBindingModel
|
||||
{
|
||||
ShopName = shopName,
|
||||
Address = address,
|
||||
DateOpen = dateOpen,
|
||||
TextileMaxCount = maxCount
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Update()
|
||||
{
|
||||
ViewBag.Shops = await APIClient.GetAsyncRequest<List<ShopViewModel>>("api/shop/getshoplist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ShopViewModel GetShop(int shopId)
|
||||
{
|
||||
var result = _logic.ReadElement(new ShopSearchModel { Id = shopId });
|
||||
result.TextileCount = result.ShopTextiles.Values.ToList().Select(x => (x.Item1.TextileName, x.Item2).ToTuple()).ToList();
|
||||
return result;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ShopViewModel>? GetShopList()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<ShopViewModel> shops = _logic.ReadList(null);
|
||||
for (int i = 0; i < shops.Count; i++)
|
||||
{
|
||||
shops[i].TextileCount = shops[i].ShopTextiles.Values.ToList().Select(x => (x.Item1.TextileName, x.Item2).ToTuple()).ToList();
|
||||
}
|
||||
return shops;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка магазинов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async void Update(int shop, string shopName, string address, DateTime dateOpen, int maxCount)
|
||||
{
|
||||
if (string.IsNullOrEmpty(shopName) || string.IsNullOrEmpty(address))
|
||||
{
|
||||
throw new Exception("Название или адрес не может быть пустым");
|
||||
}
|
||||
if (dateOpen == default(DateTime))
|
||||
{
|
||||
throw new Exception("Дата открытия не может быть пустой");
|
||||
}
|
||||
APIClient.PostRequest($"api/shop/updateshop", new ShopBindingModel
|
||||
{
|
||||
Id = shop,
|
||||
ShopName = shopName,
|
||||
Address = address,
|
||||
DateOpen = dateOpen,
|
||||
TextileMaxCount = maxCount
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Delete()
|
||||
{
|
||||
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>("api/shop/getshoplist");
|
||||
return View();
|
||||
}
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public void Delete(int shop)
|
||||
{
|
||||
APIClient.PostRequest($"api/shop/deleteshop?shopId", new ShopBindingModel { Id = shop });
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Supply()
|
||||
{
|
||||
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>($"api/shop/getshoplist");
|
||||
ViewBag.Textiles = APIClient.GetRequest<List<TextileViewModel>>($"api/main/gettextilelist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Supply(int shop, int textile, int count)
|
||||
{
|
||||
APIClient.PostRequest($"api/shop/makesupply", new SupplyBindingModel
|
||||
{
|
||||
ShopId = shop,
|
||||
TextileId = textile,
|
||||
Count = count
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
}
|
||||
}
|
19
GarmentFactoryShopsApp/GarmentFactoryShopsApp.csproj
Normal file
19
GarmentFactoryShopsApp/GarmentFactoryShopsApp.csproj
Normal file
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GarmentFactoryBusinessLogic\GarmentFactoryBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\GarmentFactoryContracts\GarmentFactoryContracts.csproj" />
|
||||
<ProjectReference Include="..\GarmentFactoryDatabaseImplement\GarmentFactoryDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
9
GarmentFactoryShopsApp/Models/ErrorViewModel.cs
Normal file
9
GarmentFactoryShopsApp/Models/ErrorViewModel.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace GarmentFactoryShopsApp.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
40
GarmentFactoryShopsApp/Program.cs
Normal file
40
GarmentFactoryShopsApp/Program.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using GarmentFactoryBusinessLogic.BusinessLogics;
|
||||
using GarmentFactoryContracts.BusinessLogicsContracts;
|
||||
using GarmentFactoryContracts.StoragesContracts;
|
||||
using GarmentFactoryDatabaseImplement.Implements;
|
||||
using GarmentFactoryShopsApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Services.AddTransient<IShopStorage, ShopStorage>();
|
||||
builder.Services.AddTransient<ITextileStorage, TextileStorage>();
|
||||
|
||||
builder.Services.AddTransient<IShopLogic, ShopLogic>();
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
APIClient.Connect(builder.Configuration);
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.Run();
|
28
GarmentFactoryShopsApp/Properties/launchSettings.json
Normal file
28
GarmentFactoryShopsApp/Properties/launchSettings.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:33639",
|
||||
"sslPort": 44357
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"GarmentFactoryShopsApp": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7124;http://localhost:5265",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
33
GarmentFactoryShopsApp/Views/Home/Create.cshtml
Normal file
33
GarmentFactoryShopsApp/Views/Home/Create.cshtml
Normal file
@ -0,0 +1,33 @@
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4 mb-5">Создание магазина</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="shopName" id="shopName" /></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Дата открытия:</div>
|
||||
<div class="col-8">
|
||||
<input type="datetime-local" id="dateOpen" name="dateOpen" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Адрес:</div>
|
||||
<div class="col-8"><input type="text" id="address" name="address" /></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-4">Вместимость:</div>
|
||||
<div class="col-8"><input type="number" id="maxCount" name="maxCount" /></div>
|
||||
</div>
|
||||
<div class="row mb-5">
|
||||
<div class="col-8">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Создать" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
17
GarmentFactoryShopsApp/Views/Home/Delete.cshtml
Normal file
17
GarmentFactoryShopsApp/Views/Home/Delete.cshtml
Normal file
@ -0,0 +1,17 @@
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удаление магазина</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8">
|
||||
<select id="shop" name="shop" class="form-control" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Удалить" class="btn btn-danger" />
|
||||
</div>
|
||||
</form>
|
16
GarmentFactoryShopsApp/Views/Home/Enter.cshtml
Normal file
16
GarmentFactoryShopsApp/Views/Home/Enter.cshtml
Normal file
@ -0,0 +1,16 @@
|
||||
@{
|
||||
ViewData["Title"] = "Enter";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Вход в приложение</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
72
GarmentFactoryShopsApp/Views/Home/Index.cshtml
Normal file
72
GarmentFactoryShopsApp/Views/Home/Index.cshtml
Normal file
@ -0,0 +1,72 @@
|
||||
@using GarmentFactoryContracts.ViewModels
|
||||
|
||||
@model List<ShopViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Магазины</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Создать магазин</a>
|
||||
<a asp-action="Update">Обновить магазин</a>
|
||||
<a asp-action="Delete">Удалить магазин</a>
|
||||
<a asp-action="Supply">Пополнить магазин</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Название магазина
|
||||
</th>
|
||||
<th>
|
||||
Адрес
|
||||
</th>
|
||||
<th>
|
||||
Дата открытия
|
||||
</th>
|
||||
<th>
|
||||
Вместимость
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ShopName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Address)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateOpen)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.TextileMaxCount)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
22
GarmentFactoryShopsApp/Views/Home/Supply.cshtml
Normal file
22
GarmentFactoryShopsApp/Views/Home/Supply.cshtml
Normal file
@ -0,0 +1,22 @@
|
||||
@{
|
||||
ViewData["Title"] = "Supply";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Пополнение магазина</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Магазин</label>
|
||||
<select class="form-select form-select-lg" id="shop" name="shop" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Текстиль</label>
|
||||
<select class="form-select form-select-lg" id="textile" name="textile" asp-items="@(new SelectList(@ViewBag.Textiles,"Id", "TextileName"))"></select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Количество</label>
|
||||
<input type="number" min="0" step="1" pattern="[0-9]" class="form-control" name="count" id="count">
|
||||
</div>
|
||||
<input class="btn btn-primary" type="submit" value="Пополнить">
|
||||
<a class="btn btn-primary" href="./Index" role="button">Отмена</a>
|
||||
</form>
|
82
GarmentFactoryShopsApp/Views/Home/Update.cshtml
Normal file
82
GarmentFactoryShopsApp/Views/Home/Update.cshtml
Normal file
@ -0,0 +1,82 @@
|
||||
@{
|
||||
ViewData["Title"] = "Update";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4 mb-5">Изменить магазин</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Выберите магазин для изменения:</label>
|
||||
<select id="shop" name="shop" class="form-control mb-3">
|
||||
<option selected disabled>Выберите магазин</option>
|
||||
@foreach (var shop in ViewBag.Shops)
|
||||
{
|
||||
<option value="@shop.Id">@shop.ShopName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" id="shopName" name="shopName" /></div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Адрес:</div>
|
||||
<div class="col-8"><input type="text" id="address" name="address" /></div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-4"> Дата открытия:</div>
|
||||
<div class="col-8">
|
||||
<input type="datetime-local" id="dateOpen" name="dateOpen" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Максимальная вместимость магазина:</div>
|
||||
<div class="col-8"><input type="number" id="maxCount" name="maxCount" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Текстили в магазине:</label>
|
||||
|
||||
<select multiple disabled size="6" id="currentTextiles" name="currentTextiles" class="form-control">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center mt-3">
|
||||
<input type="submit" value="Обновить" class="btn btn-primary ps-5 pe-5" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$('#shop').on('change', function () {
|
||||
getData();
|
||||
});
|
||||
function getData() {
|
||||
var shop = $('#shop').val();
|
||||
if (shop) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetShop",
|
||||
data: { shopId: shop },
|
||||
success: function (result) {
|
||||
console.log(result);
|
||||
$("#shopName").val(result.shopName);
|
||||
$("#address").val(result.address);
|
||||
$("#dateOpen").val(new Date(result.dateOpen).toISOString().substring(0, 16));
|
||||
$("#maxCount").val(result.textileMaxCount);
|
||||
|
||||
$("#currentTextiles").empty();
|
||||
for (var textile in result.textileCount) {
|
||||
var optionText = result.textileCount[textile].item1 + " - " + result.textileCount[textile].item2 + " шт."
|
||||
$('#currentTextiles').append($('<option>', {
|
||||
value: result.textileCount[textile].item1,
|
||||
text: optionText
|
||||
}));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
</script>
|
25
GarmentFactoryShopsApp/Views/Shared/Error.cshtml
Normal file
25
GarmentFactoryShopsApp/Views/Shared/Error.cshtml
Normal file
@ -0,0 +1,25 @@
|
||||
@model ErrorViewModel
|
||||
@{
|
||||
ViewData["Title"] = "Error";
|
||||
}
|
||||
|
||||
<h1 class="text-danger">Error.</h1>
|
||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||
|
||||
@if (Model.ShowRequestId)
|
||||
{
|
||||
<p>
|
||||
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||
</p>
|
||||
}
|
||||
|
||||
<h3>Development Mode</h3>
|
||||
<p>
|
||||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||
</p>
|
||||
<p>
|
||||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||
It can result in displaying sensitive information from exceptions to end users.
|
||||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||
and restarting the app.
|
||||
</p>
|
46
GarmentFactoryShopsApp/Views/Shared/_Layout.cshtml
Normal file
46
GarmentFactoryShopsApp/Views/Shared/_Layout.cshtml
Normal file
@ -0,0 +1,46 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - GarmentFactoryClientApp</title>
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" />
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Швейная фабрика</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Магазины</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
<div class="container">
|
||||
<main role="main" class="pb-3">
|
||||
@RenderBody()
|
||||
</main>
|
||||
</div>
|
||||
<footer class="border-top footer text-muted">
|
||||
<div class="container">
|
||||
© 2024 - Швейная фабрика - <a asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
@RenderSection("Scripts", required: false)
|
||||
</body>
|
||||
</html>
|
48
GarmentFactoryShopsApp/Views/Shared/_Layout.cshtml.css
Normal file
48
GarmentFactoryShopsApp/Views/Shared/_Layout.cshtml.css
Normal file
@ -0,0 +1,48 @@
|
||||
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||
for details on configuring this project to bundle and minify static web assets. */
|
||||
|
||||
a.navbar-brand {
|
||||
white-space: normal;
|
||||
text-align: center;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0077cc;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
color: #fff;
|
||||
background-color: #1b6ec2;
|
||||
border-color: #1861ac;
|
||||
}
|
||||
|
||||
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
|
||||
color: #fff;
|
||||
background-color: #1b6ec2;
|
||||
border-color: #1861ac;
|
||||
}
|
||||
|
||||
.border-top {
|
||||
border-top: 1px solid #e5e5e5;
|
||||
}
|
||||
.border-bottom {
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
}
|
||||
|
||||
.box-shadow {
|
||||
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
|
||||
}
|
||||
|
||||
button.accept-policy {
|
||||
font-size: 1rem;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
.footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
white-space: nowrap;
|
||||
line-height: 60px;
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
|
||||
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
|
3
GarmentFactoryShopsApp/Views/_ViewImports.cshtml
Normal file
3
GarmentFactoryShopsApp/Views/_ViewImports.cshtml
Normal file
@ -0,0 +1,3 @@
|
||||
@using GarmentFactoryShopsApp
|
||||
@using GarmentFactoryShopsApp.Models
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
3
GarmentFactoryShopsApp/Views/_ViewStart.cshtml
Normal file
3
GarmentFactoryShopsApp/Views/_ViewStart.cshtml
Normal file
@ -0,0 +1,3 @@
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
8
GarmentFactoryShopsApp/appsettings.Development.json
Normal file
8
GarmentFactoryShopsApp/appsettings.Development.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
11
GarmentFactoryShopsApp/appsettings.json
Normal file
11
GarmentFactoryShopsApp/appsettings.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"IPAddress": "http://localhost:5278/",
|
||||
"Password": "1111"
|
||||
}
|
18
GarmentFactoryShopsApp/wwwroot/css/site.css
Normal file
18
GarmentFactoryShopsApp/wwwroot/css/site.css
Normal file
@ -0,0 +1,18 @@
|
||||
html {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
html {
|
||||
font-size: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
html {
|
||||
position: relative;
|
||||
min-height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin-bottom: 60px;
|
||||
}
|
BIN
GarmentFactoryShopsApp/wwwroot/favicon.ico
Normal file
BIN
GarmentFactoryShopsApp/wwwroot/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
4
GarmentFactoryShopsApp/wwwroot/js/site.js
Normal file
4
GarmentFactoryShopsApp/wwwroot/js/site.js
Normal file
@ -0,0 +1,4 @@
|
||||
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||
// for details on configuring this project to bundle and minify static web assets.
|
||||
|
||||
// Write your JavaScript code.
|
22
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/LICENSE
Normal file
22
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/LICENSE
Normal file
@ -0,0 +1,22 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011-2021 Twitter, Inc.
|
||||
Copyright (c) 2011-2021 The Bootstrap Authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
4997
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css
vendored
Normal file
4997
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css.map
vendored
Normal file
1
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css.map
vendored
Normal file
File diff suppressed because one or more lines are too long
7
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css
vendored
Normal file
7
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css.map
vendored
Normal file
1
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css.map
vendored
Normal file
File diff suppressed because one or more lines are too long
4996
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css
vendored
Normal file
4996
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css.map
vendored
Normal file
1
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css.map
vendored
Normal file
File diff suppressed because one or more lines are too long
7
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css
vendored
Normal file
7
GarmentFactoryShopsApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user