Первая усложненная работа
This commit is contained in:
parent
f7eb3ff8ab
commit
78c2459fd0
71
PlumbingRepair/PlumbingRepair/FormMain.Designer.cs
generated
71
PlumbingRepair/PlumbingRepair/FormMain.Designer.cs
generated
@ -32,25 +32,25 @@
|
|||||||
this.СправочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.СправочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.ИзделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.ИзделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.StoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.CreateOrderButton = new System.Windows.Forms.Button();
|
this.CreateOrderButton = new System.Windows.Forms.Button();
|
||||||
this.TakeOrderInWorkButton = new System.Windows.Forms.Button();
|
this.TakeOrderInWorkButton = new System.Windows.Forms.Button();
|
||||||
this.OrderReadyButton = new System.Windows.Forms.Button();
|
this.OrderReadyButton = new System.Windows.Forms.Button();
|
||||||
this.IssuedOrderButton = new System.Windows.Forms.Button();
|
this.IssuedOrderButton = new System.Windows.Forms.Button();
|
||||||
this.UpdateListButton = new System.Windows.Forms.Button();
|
this.UpdateListButton = new System.Windows.Forms.Button();
|
||||||
|
this.StoreReplenishment = new System.Windows.Forms.Button();
|
||||||
this.MenuStrip.SuspendLayout();
|
this.MenuStrip.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// MenuStrip
|
// MenuStrip
|
||||||
//
|
//
|
||||||
this.MenuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
|
||||||
this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.СправочникиToolStripMenuItem});
|
this.СправочникиToolStripMenuItem});
|
||||||
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
|
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
|
||||||
this.MenuStrip.Name = "MenuStrip";
|
this.MenuStrip.Name = "MenuStrip";
|
||||||
this.MenuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3);
|
this.MenuStrip.Size = new System.Drawing.Size(865, 24);
|
||||||
this.MenuStrip.Size = new System.Drawing.Size(989, 30);
|
|
||||||
this.MenuStrip.TabIndex = 0;
|
this.MenuStrip.TabIndex = 0;
|
||||||
this.MenuStrip.Text = "menuStrip1";
|
this.MenuStrip.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
@ -58,42 +58,47 @@
|
|||||||
//
|
//
|
||||||
this.СправочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.СправочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.ИзделияToolStripMenuItem,
|
this.ИзделияToolStripMenuItem,
|
||||||
this.КомпонентыToolStripMenuItem});
|
this.КомпонентыToolStripMenuItem,
|
||||||
|
this.StoreToolStripMenuItem});
|
||||||
this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
|
this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
|
||||||
this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
|
this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
||||||
this.СправочникиToolStripMenuItem.Text = "Cправочники";
|
this.СправочникиToolStripMenuItem.Text = "Cправочники";
|
||||||
//
|
//
|
||||||
// ИзделияToolStripMenuItem
|
// ИзделияToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
||||||
this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
|
this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
this.ИзделияToolStripMenuItem.Text = "Изделия";
|
this.ИзделияToolStripMenuItem.Text = "Изделия";
|
||||||
this.ИзделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
|
this.ИзделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// КомпонентыToolStripMenuItem
|
// КомпонентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
||||||
this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
|
this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
this.КомпонентыToolStripMenuItem.Text = "Компоненты";
|
this.КомпонентыToolStripMenuItem.Text = "Компоненты";
|
||||||
this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// StoreToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.StoreToolStripMenuItem.Name = "StoreToolStripMenuItem";
|
||||||
|
this.StoreToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||||
|
this.StoreToolStripMenuItem.Text = "Магазины";
|
||||||
|
this.StoreToolStripMenuItem.Click += new System.EventHandler(this.StoreToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// DataGridView
|
// DataGridView
|
||||||
//
|
//
|
||||||
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.DataGridView.Location = new System.Drawing.Point(0, 36);
|
this.DataGridView.Location = new System.Drawing.Point(0, 27);
|
||||||
this.DataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.DataGridView.Name = "DataGridView";
|
this.DataGridView.Name = "DataGridView";
|
||||||
this.DataGridView.RowHeadersWidth = 51;
|
|
||||||
this.DataGridView.RowTemplate.Height = 25;
|
this.DataGridView.RowTemplate.Height = 25;
|
||||||
this.DataGridView.Size = new System.Drawing.Size(825, 561);
|
this.DataGridView.Size = new System.Drawing.Size(722, 421);
|
||||||
this.DataGridView.TabIndex = 1;
|
this.DataGridView.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// CreateOrderButton
|
// CreateOrderButton
|
||||||
//
|
//
|
||||||
this.CreateOrderButton.Location = new System.Drawing.Point(832, 37);
|
this.CreateOrderButton.Location = new System.Drawing.Point(728, 28);
|
||||||
this.CreateOrderButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.CreateOrderButton.Name = "CreateOrderButton";
|
this.CreateOrderButton.Name = "CreateOrderButton";
|
||||||
this.CreateOrderButton.Size = new System.Drawing.Size(143, 44);
|
this.CreateOrderButton.Size = new System.Drawing.Size(125, 33);
|
||||||
this.CreateOrderButton.TabIndex = 2;
|
this.CreateOrderButton.TabIndex = 2;
|
||||||
this.CreateOrderButton.Text = "Создать заказ";
|
this.CreateOrderButton.Text = "Создать заказ";
|
||||||
this.CreateOrderButton.UseVisualStyleBackColor = true;
|
this.CreateOrderButton.UseVisualStyleBackColor = true;
|
||||||
@ -101,10 +106,9 @@
|
|||||||
//
|
//
|
||||||
// TakeOrderInWorkButton
|
// TakeOrderInWorkButton
|
||||||
//
|
//
|
||||||
this.TakeOrderInWorkButton.Location = new System.Drawing.Point(832, 111);
|
this.TakeOrderInWorkButton.Location = new System.Drawing.Point(728, 83);
|
||||||
this.TakeOrderInWorkButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.TakeOrderInWorkButton.Name = "TakeOrderInWorkButton";
|
this.TakeOrderInWorkButton.Name = "TakeOrderInWorkButton";
|
||||||
this.TakeOrderInWorkButton.Size = new System.Drawing.Size(143, 52);
|
this.TakeOrderInWorkButton.Size = new System.Drawing.Size(125, 39);
|
||||||
this.TakeOrderInWorkButton.TabIndex = 3;
|
this.TakeOrderInWorkButton.TabIndex = 3;
|
||||||
this.TakeOrderInWorkButton.Text = "Отдать на выполнение";
|
this.TakeOrderInWorkButton.Text = "Отдать на выполнение";
|
||||||
this.TakeOrderInWorkButton.UseVisualStyleBackColor = true;
|
this.TakeOrderInWorkButton.UseVisualStyleBackColor = true;
|
||||||
@ -112,10 +116,9 @@
|
|||||||
//
|
//
|
||||||
// OrderReadyButton
|
// OrderReadyButton
|
||||||
//
|
//
|
||||||
this.OrderReadyButton.Location = new System.Drawing.Point(832, 195);
|
this.OrderReadyButton.Location = new System.Drawing.Point(728, 146);
|
||||||
this.OrderReadyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.OrderReadyButton.Name = "OrderReadyButton";
|
this.OrderReadyButton.Name = "OrderReadyButton";
|
||||||
this.OrderReadyButton.Size = new System.Drawing.Size(143, 44);
|
this.OrderReadyButton.Size = new System.Drawing.Size(125, 33);
|
||||||
this.OrderReadyButton.TabIndex = 4;
|
this.OrderReadyButton.TabIndex = 4;
|
||||||
this.OrderReadyButton.Text = "Заказ готов";
|
this.OrderReadyButton.Text = "Заказ готов";
|
||||||
this.OrderReadyButton.UseVisualStyleBackColor = true;
|
this.OrderReadyButton.UseVisualStyleBackColor = true;
|
||||||
@ -123,10 +126,9 @@
|
|||||||
//
|
//
|
||||||
// IssuedOrderButton
|
// IssuedOrderButton
|
||||||
//
|
//
|
||||||
this.IssuedOrderButton.Location = new System.Drawing.Point(832, 272);
|
this.IssuedOrderButton.Location = new System.Drawing.Point(728, 204);
|
||||||
this.IssuedOrderButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.IssuedOrderButton.Name = "IssuedOrderButton";
|
this.IssuedOrderButton.Name = "IssuedOrderButton";
|
||||||
this.IssuedOrderButton.Size = new System.Drawing.Size(143, 44);
|
this.IssuedOrderButton.Size = new System.Drawing.Size(125, 33);
|
||||||
this.IssuedOrderButton.TabIndex = 5;
|
this.IssuedOrderButton.TabIndex = 5;
|
||||||
this.IssuedOrderButton.Text = "Заказ выдан";
|
this.IssuedOrderButton.Text = "Заказ выдан";
|
||||||
this.IssuedOrderButton.UseVisualStyleBackColor = true;
|
this.IssuedOrderButton.UseVisualStyleBackColor = true;
|
||||||
@ -134,20 +136,30 @@
|
|||||||
//
|
//
|
||||||
// UpdateListButton
|
// UpdateListButton
|
||||||
//
|
//
|
||||||
this.UpdateListButton.Location = new System.Drawing.Point(832, 349);
|
this.UpdateListButton.Location = new System.Drawing.Point(728, 262);
|
||||||
this.UpdateListButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.UpdateListButton.Name = "UpdateListButton";
|
this.UpdateListButton.Name = "UpdateListButton";
|
||||||
this.UpdateListButton.Size = new System.Drawing.Size(143, 44);
|
this.UpdateListButton.Size = new System.Drawing.Size(125, 33);
|
||||||
this.UpdateListButton.TabIndex = 6;
|
this.UpdateListButton.TabIndex = 6;
|
||||||
this.UpdateListButton.Text = "Обновить список";
|
this.UpdateListButton.Text = "Обновить список";
|
||||||
this.UpdateListButton.UseVisualStyleBackColor = true;
|
this.UpdateListButton.UseVisualStyleBackColor = true;
|
||||||
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
|
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
|
||||||
//
|
//
|
||||||
|
// StoreReplenishment
|
||||||
|
//
|
||||||
|
this.StoreReplenishment.Location = new System.Drawing.Point(728, 317);
|
||||||
|
this.StoreReplenishment.Name = "StoreReplenishment";
|
||||||
|
this.StoreReplenishment.Size = new System.Drawing.Size(125, 50);
|
||||||
|
this.StoreReplenishment.TabIndex = 7;
|
||||||
|
this.StoreReplenishment.Text = "Пополнение магазина";
|
||||||
|
this.StoreReplenishment.UseVisualStyleBackColor = true;
|
||||||
|
this.StoreReplenishment.Click += new System.EventHandler(this.StoreReplenishment_Click);
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(989, 600);
|
this.ClientSize = new System.Drawing.Size(865, 450);
|
||||||
|
this.Controls.Add(this.StoreReplenishment);
|
||||||
this.Controls.Add(this.UpdateListButton);
|
this.Controls.Add(this.UpdateListButton);
|
||||||
this.Controls.Add(this.IssuedOrderButton);
|
this.Controls.Add(this.IssuedOrderButton);
|
||||||
this.Controls.Add(this.OrderReadyButton);
|
this.Controls.Add(this.OrderReadyButton);
|
||||||
@ -156,7 +168,6 @@
|
|||||||
this.Controls.Add(this.DataGridView);
|
this.Controls.Add(this.DataGridView);
|
||||||
this.Controls.Add(this.MenuStrip);
|
this.Controls.Add(this.MenuStrip);
|
||||||
this.MainMenuStrip = this.MenuStrip;
|
this.MainMenuStrip = this.MenuStrip;
|
||||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
|
||||||
this.Name = "FormMain";
|
this.Name = "FormMain";
|
||||||
this.Text = "Ремонт сантехники";
|
this.Text = "Ремонт сантехники";
|
||||||
this.MenuStrip.ResumeLayout(false);
|
this.MenuStrip.ResumeLayout(false);
|
||||||
@ -179,5 +190,7 @@
|
|||||||
private Button OrderReadyButton;
|
private Button OrderReadyButton;
|
||||||
private Button IssuedOrderButton;
|
private Button IssuedOrderButton;
|
||||||
private Button UpdateListButton;
|
private Button UpdateListButton;
|
||||||
|
private ToolStripMenuItem StoreToolStripMenuItem;
|
||||||
|
private Button StoreReplenishment;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -186,5 +186,25 @@ namespace PlumbingRepair
|
|||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void StoreReplenishment_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormStoreReplenishment));
|
||||||
|
|
||||||
|
if (service is FormStoreReplenishment form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StoreToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormStores));
|
||||||
|
|
||||||
|
if (service is FormStores form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,64 @@
|
|||||||
<root>
|
<?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: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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
@ -57,7 +117,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="MenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
183
PlumbingRepair/PlumbingRepair/FormStore.Designer.cs
generated
Normal file
183
PlumbingRepair/PlumbingRepair/FormStore.Designer.cs
generated
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
namespace PlumbingRepair
|
||||||
|
{
|
||||||
|
partial class FormStore
|
||||||
|
{
|
||||||
|
/// <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.StoreNameLabel = new System.Windows.Forms.Label();
|
||||||
|
this.StoreAdressLabel = new System.Windows.Forms.Label();
|
||||||
|
this.OpeningDateLabel = new System.Windows.Forms.Label();
|
||||||
|
this.NameComboBox = new System.Windows.Forms.ComboBox();
|
||||||
|
this.AdressTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.PackageName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.PackagePrice = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.PackageCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.SaveButton = new System.Windows.Forms.Button();
|
||||||
|
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.OpeningDatePicker = new System.Windows.Forms.DateTimePicker();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// StoreNameLabel
|
||||||
|
//
|
||||||
|
this.StoreNameLabel.AutoSize = true;
|
||||||
|
this.StoreNameLabel.Location = new System.Drawing.Point(12, 9);
|
||||||
|
this.StoreNameLabel.Name = "StoreNameLabel";
|
||||||
|
this.StoreNameLabel.Size = new System.Drawing.Size(119, 15);
|
||||||
|
this.StoreNameLabel.TabIndex = 0;
|
||||||
|
this.StoreNameLabel.Text = "Название магазина: ";
|
||||||
|
//
|
||||||
|
// StoreAdressLabel
|
||||||
|
//
|
||||||
|
this.StoreAdressLabel.AutoSize = true;
|
||||||
|
this.StoreAdressLabel.Location = new System.Drawing.Point(12, 40);
|
||||||
|
this.StoreAdressLabel.Name = "StoreAdressLabel";
|
||||||
|
this.StoreAdressLabel.Size = new System.Drawing.Size(100, 15);
|
||||||
|
this.StoreAdressLabel.TabIndex = 1;
|
||||||
|
this.StoreAdressLabel.Text = "Адрес магазина: ";
|
||||||
|
//
|
||||||
|
// OpeningDateLabel
|
||||||
|
//
|
||||||
|
this.OpeningDateLabel.AutoSize = true;
|
||||||
|
this.OpeningDateLabel.Location = new System.Drawing.Point(12, 72);
|
||||||
|
this.OpeningDateLabel.Name = "OpeningDateLabel";
|
||||||
|
this.OpeningDateLabel.Size = new System.Drawing.Size(93, 15);
|
||||||
|
this.OpeningDateLabel.TabIndex = 2;
|
||||||
|
this.OpeningDateLabel.Text = "Дата открытия: ";
|
||||||
|
//
|
||||||
|
// NameComboBox
|
||||||
|
//
|
||||||
|
this.NameComboBox.FormattingEnabled = true;
|
||||||
|
this.NameComboBox.Location = new System.Drawing.Point(137, 6);
|
||||||
|
this.NameComboBox.Name = "NameComboBox";
|
||||||
|
this.NameComboBox.Size = new System.Drawing.Size(174, 23);
|
||||||
|
this.NameComboBox.TabIndex = 3;
|
||||||
|
this.NameComboBox.SelectedIndexChanged += new System.EventHandler(this.NameComboBox_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// AdressTextBox
|
||||||
|
//
|
||||||
|
this.AdressTextBox.Location = new System.Drawing.Point(137, 37);
|
||||||
|
this.AdressTextBox.Name = "AdressTextBox";
|
||||||
|
this.AdressTextBox.Size = new System.Drawing.Size(174, 23);
|
||||||
|
this.AdressTextBox.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// DataGridView
|
||||||
|
//
|
||||||
|
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.DataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.PackageName,
|
||||||
|
this.PackagePrice,
|
||||||
|
this.PackageCount});
|
||||||
|
this.DataGridView.Location = new System.Drawing.Point(12, 109);
|
||||||
|
this.DataGridView.Name = "DataGridView";
|
||||||
|
this.DataGridView.RowTemplate.Height = 25;
|
||||||
|
this.DataGridView.Size = new System.Drawing.Size(776, 288);
|
||||||
|
this.DataGridView.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// PackageName
|
||||||
|
//
|
||||||
|
this.PackageName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
this.PackageName.HeaderText = "Название изделия";
|
||||||
|
this.PackageName.Name = "PackageName";
|
||||||
|
//
|
||||||
|
// PackagePrice
|
||||||
|
//
|
||||||
|
this.PackagePrice.HeaderText = "Цена";
|
||||||
|
this.PackagePrice.Name = "PackagePrice";
|
||||||
|
//
|
||||||
|
// PackageCount
|
||||||
|
//
|
||||||
|
this.PackageCount.HeaderText = "Количество";
|
||||||
|
this.PackageCount.Name = "PackageCount";
|
||||||
|
//
|
||||||
|
// SaveButton
|
||||||
|
//
|
||||||
|
this.SaveButton.Location = new System.Drawing.Point(552, 403);
|
||||||
|
this.SaveButton.Name = "SaveButton";
|
||||||
|
this.SaveButton.Size = new System.Drawing.Size(115, 35);
|
||||||
|
this.SaveButton.TabIndex = 7;
|
||||||
|
this.SaveButton.Text = "Сохранить";
|
||||||
|
this.SaveButton.UseVisualStyleBackColor = true;
|
||||||
|
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||||
|
//
|
||||||
|
// ButtonCancel
|
||||||
|
//
|
||||||
|
this.ButtonCancel.Location = new System.Drawing.Point(673, 403);
|
||||||
|
this.ButtonCancel.Name = "ButtonCancel";
|
||||||
|
this.ButtonCancel.Size = new System.Drawing.Size(115, 35);
|
||||||
|
this.ButtonCancel.TabIndex = 8;
|
||||||
|
this.ButtonCancel.Text = "Отменить";
|
||||||
|
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// OpeningDatePicker
|
||||||
|
//
|
||||||
|
this.OpeningDatePicker.Location = new System.Drawing.Point(137, 66);
|
||||||
|
this.OpeningDatePicker.Name = "OpeningDatePicker";
|
||||||
|
this.OpeningDatePicker.Size = new System.Drawing.Size(174, 23);
|
||||||
|
this.OpeningDatePicker.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// FormStore
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.OpeningDatePicker);
|
||||||
|
this.Controls.Add(this.ButtonCancel);
|
||||||
|
this.Controls.Add(this.SaveButton);
|
||||||
|
this.Controls.Add(this.DataGridView);
|
||||||
|
this.Controls.Add(this.AdressTextBox);
|
||||||
|
this.Controls.Add(this.NameComboBox);
|
||||||
|
this.Controls.Add(this.OpeningDateLabel);
|
||||||
|
this.Controls.Add(this.StoreAdressLabel);
|
||||||
|
this.Controls.Add(this.StoreNameLabel);
|
||||||
|
this.Name = "FormStore";
|
||||||
|
this.Text = "Изделия магазина";
|
||||||
|
this.Load += new System.EventHandler(this.FormStore_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label StoreNameLabel;
|
||||||
|
private Label StoreAdressLabel;
|
||||||
|
private Label OpeningDateLabel;
|
||||||
|
private ComboBox NameComboBox;
|
||||||
|
private TextBox AdressTextBox;
|
||||||
|
private DataGridView DataGridView;
|
||||||
|
private Button SaveButton;
|
||||||
|
private Button ButtonCancel;
|
||||||
|
private DataGridViewTextBoxColumn PackageName;
|
||||||
|
private DataGridViewTextBoxColumn PackagePrice;
|
||||||
|
private DataGridViewTextBoxColumn PackageCount;
|
||||||
|
private DateTimePicker OpeningDatePicker;
|
||||||
|
}
|
||||||
|
}
|
142
PlumbingRepair/PlumbingRepair/FormStore.cs
Normal file
142
PlumbingRepair/PlumbingRepair/FormStore.cs
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairDataModels.Models;
|
||||||
|
|
||||||
|
namespace PlumbingRepair
|
||||||
|
{
|
||||||
|
public partial class FormStore : Form
|
||||||
|
{
|
||||||
|
private readonly List<StoreViewModel>? _listStores;
|
||||||
|
private readonly IStoreLogic _logic;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public FormStore(ILogger<FormStore> logger, IStoreLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_listStores = logic.ReadList(null);
|
||||||
|
_logic = logic;
|
||||||
|
if (_listStores != null)
|
||||||
|
{
|
||||||
|
NameComboBox.DisplayMember = "StoreName";
|
||||||
|
NameComboBox.ValueMember = "Id";
|
||||||
|
NameComboBox.DataSource = _listStores;
|
||||||
|
NameComboBox.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private IStoreModel? GetStore(int id)
|
||||||
|
{
|
||||||
|
if (_listStores == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var elem in _listStores)
|
||||||
|
{
|
||||||
|
if (elem.Id == id)
|
||||||
|
{
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(NameComboBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(AdressTextBox.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Сохранение изделия");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DateTime.TryParse(OpeningDatePicker.Text, out var dateTime);
|
||||||
|
StoreBindingModel model = new()
|
||||||
|
{
|
||||||
|
StoreName = NameComboBox.Text,
|
||||||
|
StoreAdress = AdressTextBox.Text,
|
||||||
|
OpeningDate = dateTime
|
||||||
|
};
|
||||||
|
var vmodel = GetStore(Id);
|
||||||
|
bool operationResult = false;
|
||||||
|
|
||||||
|
if (vmodel != null)
|
||||||
|
{
|
||||||
|
model.Id = vmodel.Id;
|
||||||
|
operationResult = _logic.Update(model);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
operationResult = _logic.Create(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения изделия");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormStore_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
private void LoadData(bool extendDate = true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = GetStore(extendDate ? Id : Convert.ToInt32(NameComboBox.SelectedValue));
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
NameComboBox.Text = model.StoreName;
|
||||||
|
AdressTextBox.Text = model.StoreAdress;
|
||||||
|
OpeningDatePicker.Text = Convert.ToString(model.OpeningDate);
|
||||||
|
DataGridView.Rows.Clear();
|
||||||
|
foreach (var el in model.Works.Values)
|
||||||
|
{
|
||||||
|
DataGridView.Rows.Add(new object[] { el.Item1.WorkName, el.Item1.Price, el.Item2 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка магазинов");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NameComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
PlumbingRepair/PlumbingRepair/FormStore.resx
Normal file
120
PlumbingRepair/PlumbingRepair/FormStore.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>
|
148
PlumbingRepair/PlumbingRepair/FormStoreReplenishment.Designer.cs
generated
Normal file
148
PlumbingRepair/PlumbingRepair/FormStoreReplenishment.Designer.cs
generated
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
namespace PlumbingRepair
|
||||||
|
{
|
||||||
|
partial class FormStoreReplenishment
|
||||||
|
{
|
||||||
|
/// <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.StoreNameLabel = new System.Windows.Forms.Label();
|
||||||
|
this.WorkNameLabel = new System.Windows.Forms.Label();
|
||||||
|
this.CountLabel = new System.Windows.Forms.Label();
|
||||||
|
this.StoreNameComboBox = new System.Windows.Forms.ComboBox();
|
||||||
|
this.WorkNameComboBox = new System.Windows.Forms.ComboBox();
|
||||||
|
this.CountTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.SaveButton = new System.Windows.Forms.Button();
|
||||||
|
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// StoreNameLabel
|
||||||
|
//
|
||||||
|
this.StoreNameLabel.AutoSize = true;
|
||||||
|
this.StoreNameLabel.Location = new System.Drawing.Point(14, 12);
|
||||||
|
this.StoreNameLabel.Name = "StoreNameLabel";
|
||||||
|
this.StoreNameLabel.Size = new System.Drawing.Size(154, 20);
|
||||||
|
this.StoreNameLabel.TabIndex = 0;
|
||||||
|
this.StoreNameLabel.Text = "Название магазина: ";
|
||||||
|
//
|
||||||
|
// WorkNameLabel
|
||||||
|
//
|
||||||
|
this.WorkNameLabel.AutoSize = true;
|
||||||
|
this.WorkNameLabel.Location = new System.Drawing.Point(14, 49);
|
||||||
|
this.WorkNameLabel.Name = "WorkNameLabel";
|
||||||
|
this.WorkNameLabel.Size = new System.Drawing.Size(145, 20);
|
||||||
|
this.WorkNameLabel.TabIndex = 1;
|
||||||
|
this.WorkNameLabel.Text = "Название изделия: ";
|
||||||
|
//
|
||||||
|
// CountLabel
|
||||||
|
//
|
||||||
|
this.CountLabel.AutoSize = true;
|
||||||
|
this.CountLabel.Location = new System.Drawing.Point(14, 88);
|
||||||
|
this.CountLabel.Name = "CountLabel";
|
||||||
|
this.CountLabel.Size = new System.Drawing.Size(97, 20);
|
||||||
|
this.CountLabel.TabIndex = 2;
|
||||||
|
this.CountLabel.Text = "Количество: ";
|
||||||
|
//
|
||||||
|
// StoreNameComboBox
|
||||||
|
//
|
||||||
|
this.StoreNameComboBox.FormattingEnabled = true;
|
||||||
|
this.StoreNameComboBox.Location = new System.Drawing.Point(157, 8);
|
||||||
|
this.StoreNameComboBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.StoreNameComboBox.Name = "StoreNameComboBox";
|
||||||
|
this.StoreNameComboBox.Size = new System.Drawing.Size(170, 28);
|
||||||
|
this.StoreNameComboBox.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// WorkNameComboBox
|
||||||
|
//
|
||||||
|
this.WorkNameComboBox.FormattingEnabled = true;
|
||||||
|
this.WorkNameComboBox.Location = new System.Drawing.Point(157, 47);
|
||||||
|
this.WorkNameComboBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.WorkNameComboBox.Name = "WorkNameComboBox";
|
||||||
|
this.WorkNameComboBox.Size = new System.Drawing.Size(170, 28);
|
||||||
|
this.WorkNameComboBox.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// CountTextBox
|
||||||
|
//
|
||||||
|
this.CountTextBox.Location = new System.Drawing.Point(157, 85);
|
||||||
|
this.CountTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.CountTextBox.Name = "CountTextBox";
|
||||||
|
this.CountTextBox.Size = new System.Drawing.Size(170, 27);
|
||||||
|
this.CountTextBox.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// SaveButton
|
||||||
|
//
|
||||||
|
this.SaveButton.Location = new System.Drawing.Point(138, 144);
|
||||||
|
this.SaveButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.SaveButton.Name = "SaveButton";
|
||||||
|
this.SaveButton.Size = new System.Drawing.Size(97, 31);
|
||||||
|
this.SaveButton.TabIndex = 6;
|
||||||
|
this.SaveButton.Text = "Сохранить";
|
||||||
|
this.SaveButton.UseVisualStyleBackColor = true;
|
||||||
|
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||||
|
//
|
||||||
|
// ButtonCancel
|
||||||
|
//
|
||||||
|
this.ButtonCancel.Location = new System.Drawing.Point(241, 144);
|
||||||
|
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.ButtonCancel.Name = "ButtonCancel";
|
||||||
|
this.ButtonCancel.Size = new System.Drawing.Size(86, 31);
|
||||||
|
this.ButtonCancel.TabIndex = 7;
|
||||||
|
this.ButtonCancel.Text = "Отмена";
|
||||||
|
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// FormStoreReplenishment
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(343, 200);
|
||||||
|
this.Controls.Add(this.ButtonCancel);
|
||||||
|
this.Controls.Add(this.SaveButton);
|
||||||
|
this.Controls.Add(this.CountTextBox);
|
||||||
|
this.Controls.Add(this.WorkNameComboBox);
|
||||||
|
this.Controls.Add(this.StoreNameComboBox);
|
||||||
|
this.Controls.Add(this.CountLabel);
|
||||||
|
this.Controls.Add(this.WorkNameLabel);
|
||||||
|
this.Controls.Add(this.StoreNameLabel);
|
||||||
|
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||||
|
this.Name = "FormStoreReplenishment";
|
||||||
|
this.Text = "Пополнение магазина";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label StoreNameLabel;
|
||||||
|
private Label WorkNameLabel;
|
||||||
|
private Label CountLabel;
|
||||||
|
private ComboBox StoreNameComboBox;
|
||||||
|
private ComboBox WorkNameComboBox;
|
||||||
|
private TextBox CountTextBox;
|
||||||
|
private Button SaveButton;
|
||||||
|
private Button ButtonCancel;
|
||||||
|
}
|
||||||
|
}
|
104
PlumbingRepair/PlumbingRepair/FormStoreReplenishment.cs
Normal file
104
PlumbingRepair/PlumbingRepair/FormStoreReplenishment.cs
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace PlumbingRepair
|
||||||
|
{
|
||||||
|
public partial class FormStoreReplenishment : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IStoreLogic _storeLogic;
|
||||||
|
private readonly IWorkLogic _workLogic;
|
||||||
|
private readonly List<StoreViewModel>? _listStores;
|
||||||
|
private readonly List<WorkViewModel>? _listWorks;
|
||||||
|
public FormStoreReplenishment(ILogger<FormStoreReplenishment> logger, IStoreLogic storeLogic, IWorkLogic workLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_storeLogic = storeLogic;
|
||||||
|
_workLogic = workLogic;
|
||||||
|
_logger = logger;
|
||||||
|
_listStores = storeLogic.ReadList(null);
|
||||||
|
if (_listStores != null)
|
||||||
|
{
|
||||||
|
StoreNameComboBox.DisplayMember = "StoreName";
|
||||||
|
StoreNameComboBox.ValueMember = "Id";
|
||||||
|
StoreNameComboBox.DataSource = _listStores;
|
||||||
|
StoreNameComboBox.SelectedItem = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_listWorks = workLogic.ReadList(null);
|
||||||
|
if (_listWorks != null)
|
||||||
|
{
|
||||||
|
WorkNameComboBox.DisplayMember = "WorkName";
|
||||||
|
WorkNameComboBox.ValueMember = "Id";
|
||||||
|
WorkNameComboBox.DataSource = _listWorks;
|
||||||
|
WorkNameComboBox.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (StoreNameComboBox.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (WorkNameComboBox.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Добавление изделия в магазин");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var work = _workLogic.ReadElement(new()
|
||||||
|
{
|
||||||
|
Id = (int)WorkNameComboBox.SelectedValue
|
||||||
|
});
|
||||||
|
|
||||||
|
if (work == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Не найдено изделие. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var resultOperation = _storeLogic.AddPackage(
|
||||||
|
model: new() { Id = (int)StoreNameComboBox.SelectedValue },
|
||||||
|
work: work,
|
||||||
|
quantity: Convert.ToInt32(CountTextBox.Text)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!resultOperation)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при добавлении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения изделия");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
PlumbingRepair/PlumbingRepair/FormStoreReplenishment.resx
Normal file
60
PlumbingRepair/PlumbingRepair/FormStoreReplenishment.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
114
PlumbingRepair/PlumbingRepair/FormStores.Designer.cs
generated
Normal file
114
PlumbingRepair/PlumbingRepair/FormStores.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
namespace PlumbingRepair
|
||||||
|
{
|
||||||
|
partial class FormStores
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.AddButton = new System.Windows.Forms.Button();
|
||||||
|
this.ChangeButton = new System.Windows.Forms.Button();
|
||||||
|
this.DeleteButton = new System.Windows.Forms.Button();
|
||||||
|
this.UpdateButton = new System.Windows.Forms.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// DataGridView
|
||||||
|
//
|
||||||
|
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.DataGridView.Location = new System.Drawing.Point(1, 1);
|
||||||
|
this.DataGridView.Name = "DataGridView";
|
||||||
|
this.DataGridView.RowTemplate.Height = 25;
|
||||||
|
this.DataGridView.Size = new System.Drawing.Size(550, 447);
|
||||||
|
this.DataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// AddButton
|
||||||
|
//
|
||||||
|
this.AddButton.Location = new System.Drawing.Point(585, 12);
|
||||||
|
this.AddButton.Name = "AddButton";
|
||||||
|
this.AddButton.Size = new System.Drawing.Size(121, 40);
|
||||||
|
this.AddButton.TabIndex = 1;
|
||||||
|
this.AddButton.Text = "Добавить";
|
||||||
|
this.AddButton.UseVisualStyleBackColor = true;
|
||||||
|
this.AddButton.Click += new System.EventHandler(this.AddButton_Click);
|
||||||
|
//
|
||||||
|
// ChangeButton
|
||||||
|
//
|
||||||
|
this.ChangeButton.Location = new System.Drawing.Point(585, 67);
|
||||||
|
this.ChangeButton.Name = "ChangeButton";
|
||||||
|
this.ChangeButton.Size = new System.Drawing.Size(121, 40);
|
||||||
|
this.ChangeButton.TabIndex = 2;
|
||||||
|
this.ChangeButton.Text = "Изменить";
|
||||||
|
this.ChangeButton.UseVisualStyleBackColor = true;
|
||||||
|
this.ChangeButton.Click += new System.EventHandler(this.ChangeButton_Click);
|
||||||
|
//
|
||||||
|
// DeleteButton
|
||||||
|
//
|
||||||
|
this.DeleteButton.Location = new System.Drawing.Point(585, 122);
|
||||||
|
this.DeleteButton.Name = "DeleteButton";
|
||||||
|
this.DeleteButton.Size = new System.Drawing.Size(121, 40);
|
||||||
|
this.DeleteButton.TabIndex = 3;
|
||||||
|
this.DeleteButton.Text = "Удалить";
|
||||||
|
this.DeleteButton.UseVisualStyleBackColor = true;
|
||||||
|
this.DeleteButton.Click += new System.EventHandler(this.DeleteButton_Click);
|
||||||
|
//
|
||||||
|
// UpdateButton
|
||||||
|
//
|
||||||
|
this.UpdateButton.Location = new System.Drawing.Point(585, 179);
|
||||||
|
this.UpdateButton.Name = "UpdateButton";
|
||||||
|
this.UpdateButton.Size = new System.Drawing.Size(121, 40);
|
||||||
|
this.UpdateButton.TabIndex = 4;
|
||||||
|
this.UpdateButton.Text = "Обновить";
|
||||||
|
this.UpdateButton.UseVisualStyleBackColor = true;
|
||||||
|
this.UpdateButton.Click += new System.EventHandler(this.UpdateButton_Click);
|
||||||
|
//
|
||||||
|
// FormStores
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(718, 450);
|
||||||
|
this.Controls.Add(this.UpdateButton);
|
||||||
|
this.Controls.Add(this.DeleteButton);
|
||||||
|
this.Controls.Add(this.ChangeButton);
|
||||||
|
this.Controls.Add(this.AddButton);
|
||||||
|
this.Controls.Add(this.DataGridView);
|
||||||
|
this.Name = "FormStores";
|
||||||
|
this.Text = "Магазины";
|
||||||
|
this.Load += new System.EventHandler(this.FormStores_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView DataGridView;
|
||||||
|
private Button AddButton;
|
||||||
|
private Button ChangeButton;
|
||||||
|
private Button DeleteButton;
|
||||||
|
private Button UpdateButton;
|
||||||
|
}
|
||||||
|
}
|
113
PlumbingRepair/PlumbingRepair/FormStores.cs
Normal file
113
PlumbingRepair/PlumbingRepair/FormStores.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||||
|
|
||||||
|
namespace PlumbingRepair
|
||||||
|
{
|
||||||
|
public partial class FormStores : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IStoreLogic _logic;
|
||||||
|
public FormStores(ILogger<FormStores> logger, IStoreLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormStores_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["StoreName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
DataGridView.Columns["Works"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Загрузка магазинов");
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DeleteButton_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 StoreBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления изделия");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ChangeButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (DataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormStore));
|
||||||
|
|
||||||
|
if (service is FormStore form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddButton_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormStore));
|
||||||
|
|
||||||
|
if (service is FormStore form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
PlumbingRepair/PlumbingRepair/FormStores.resx
Normal file
120
PlumbingRepair/PlumbingRepair/FormStores.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>
|
@ -37,9 +37,11 @@ namespace PlumbingRepair
|
|||||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
services.AddTransient<IWorkStorage, WorkStorage>();
|
services.AddTransient<IWorkStorage, WorkStorage>();
|
||||||
|
services.AddTransient<IStoreStorage, StoreStorage>();
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<IWorkLogic, WorkLogic>();
|
services.AddTransient<IWorkLogic, WorkLogic>();
|
||||||
|
services.AddTransient<IStoreLogic, StoreLogic>();
|
||||||
services.AddTransient<FormMain>();
|
services.AddTransient<FormMain>();
|
||||||
services.AddTransient<FormComponent>();
|
services.AddTransient<FormComponent>();
|
||||||
services.AddTransient<FormComponents>();
|
services.AddTransient<FormComponents>();
|
||||||
@ -47,6 +49,9 @@ namespace PlumbingRepair
|
|||||||
services.AddTransient<FormWork>();
|
services.AddTransient<FormWork>();
|
||||||
services.AddTransient<FormWorkComponent>();
|
services.AddTransient<FormWorkComponent>();
|
||||||
services.AddTransient<FormWorks>();
|
services.AddTransient<FormWorks>();
|
||||||
|
services.AddTransient<FormStores>();
|
||||||
|
services.AddTransient<FormStore>();
|
||||||
|
services.AddTransient<FormStoreReplenishment>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,175 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.StoragesContracts;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairDataModels.Models;
|
||||||
|
|
||||||
|
namespace PlumbingRepairBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class StoreLogic : IStoreLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IStoreStorage _storeStorage;
|
||||||
|
public StoreLogic(ILogger<StoreLogic> logger, IStoreStorage storeStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_storeStorage = storeStorage;
|
||||||
|
}
|
||||||
|
public bool AddPackage(StoreSearchModel model, IWorkModel work, int quantity)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quantity <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Количество добавляемого изделия должно быть больше 0", nameof(quantity));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("AddWorkInStore. StoreName:{StoreName}.Id:{ Id}", model.StoreName, model.Id);
|
||||||
|
var element = _storeStorage.GetElement(model);
|
||||||
|
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("AddWorkInStore element not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("AddWorkInStore find. Id:{Id}", element.Id);
|
||||||
|
|
||||||
|
if (element.Works.TryGetValue(work.Id, out var pair))
|
||||||
|
{
|
||||||
|
element.Works[work.Id] = (work, quantity + pair.Item2);
|
||||||
|
_logger.LogInformation("AddWorkInStore. Has been added {quantity} {work} in {StoreName}", quantity, work.WorkName, element.StoreName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
element.Works[work.Id] = (work, quantity);
|
||||||
|
_logger.LogInformation("AddWorkInShop. Has been added {quantity} new Work {work} in {StoreName}", quantity, work.WorkName, element.StoreName);
|
||||||
|
}
|
||||||
|
|
||||||
|
_storeStorage.Update(new()
|
||||||
|
{
|
||||||
|
Id = element.Id,
|
||||||
|
StoreAdress = element.StoreAdress,
|
||||||
|
StoreName = element.StoreName,
|
||||||
|
OpeningDate = element.OpeningDate,
|
||||||
|
Works = element.Works
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(StoreBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
model.Works = new();
|
||||||
|
|
||||||
|
if (_storeStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(StoreBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
|
||||||
|
if (_storeStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreViewModel? ReadElement(StoreSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadElement. StoreName:{StoreName}.Id:{ Id}", model.StoreName, model.Id);
|
||||||
|
var element = _storeStorage.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<StoreViewModel>? ReadList(StoreSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. StoreName:{StoreName}.Id:{ Id} ", model?.StoreName, model?.Id);
|
||||||
|
|
||||||
|
var list = (model == null) ? _storeStorage.GetFullList() : _storeStorage.GetFilteredList(model);
|
||||||
|
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(StoreBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(model.StoreName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия магазина", nameof(model.StoreName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_storeStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(StoreBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(model.StoreName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия магазина", nameof(model.StoreName));
|
||||||
|
}
|
||||||
|
|
||||||
|
_logger.LogInformation("Store. StoreName:{0}.StoreAdress:{1}. Id: {2}", model.StoreName, model.StoreAdress, model.Id);
|
||||||
|
var element = _storeStorage.GetElement(new StoreSearchModel
|
||||||
|
{
|
||||||
|
StoreName = model.StoreName
|
||||||
|
});
|
||||||
|
|
||||||
|
if (element != null && element.Id != model.Id && element.StoreName == model.StoreName)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using PlumbingRepairDataModels.Models;
|
||||||
|
|
||||||
|
namespace PlumbingRepairContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class StoreBindingModel : IStoreModel
|
||||||
|
{
|
||||||
|
public string StoreName { get; set; } = string.Empty;
|
||||||
|
public string StoreAdress { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
public Dictionary<int, (IWorkModel, int)> Works { get; set; } = new();
|
||||||
|
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairDataModels.Models;
|
||||||
|
|
||||||
|
namespace PlumbingRepairContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IStoreLogic
|
||||||
|
{
|
||||||
|
List<StoreViewModel>? ReadList(StoreSearchModel? model);
|
||||||
|
StoreViewModel? ReadElement(StoreSearchModel model);
|
||||||
|
bool Create(StoreBindingModel model);
|
||||||
|
bool Update(StoreBindingModel model);
|
||||||
|
bool Delete(StoreBindingModel model);
|
||||||
|
bool AddPackage(StoreSearchModel model, IWorkModel work, int quantity);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PlumbingRepairContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class StoreSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? StoreName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace PlumbingRepairContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IStoreStorage
|
||||||
|
{
|
||||||
|
List<StoreViewModel> GetFullList();
|
||||||
|
List<StoreViewModel> GetFilteredList(StoreSearchModel model);
|
||||||
|
StoreViewModel? GetElement(StoreSearchModel model);
|
||||||
|
StoreViewModel? Insert(StoreBindingModel model);
|
||||||
|
StoreViewModel? Update(StoreBindingModel model);
|
||||||
|
StoreViewModel? Delete(StoreBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using PlumbingRepairDataModels.Models;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace PlumbingRepairContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class StoreViewModel : IStoreModel
|
||||||
|
{
|
||||||
|
public Dictionary<int, (IWorkModel, int)> Works { get; set; } = new();
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("Название магазина")]
|
||||||
|
public string StoreName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Адрес магазина")]
|
||||||
|
public string StoreAdress { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Дата открытия")]
|
||||||
|
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
namespace PlumbingRepairDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IStoreModel : IId
|
||||||
|
{
|
||||||
|
public string StoreName { get; }
|
||||||
|
public string StoreAdress { get; }
|
||||||
|
DateTime OpeningDate { get; }
|
||||||
|
Dictionary<int, (IWorkModel, int)> Works { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using PlumbingRepairListImplement.Models;
|
using PlumbingRepairListImplement.Models;
|
||||||
|
using static System.Formats.Asn1.AsnWriter;
|
||||||
|
|
||||||
namespace PlumbingRepairListImplement
|
namespace PlumbingRepairListImplement
|
||||||
{
|
{
|
||||||
@ -8,12 +9,14 @@ namespace PlumbingRepairListImplement
|
|||||||
public List<Component> Components { get; set; }
|
public List<Component> Components { get; set; }
|
||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<Work> Works { get; set; }
|
public List<Work> Works { get; set; }
|
||||||
|
public List<Store> Stores { get; set; }
|
||||||
|
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Components = new List<Component>();
|
Components = new List<Component>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Works = new List<Work>();
|
Works = new List<Work>();
|
||||||
|
Stores = new List<Store>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
|
@ -0,0 +1,119 @@
|
|||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.SearchModels;
|
||||||
|
using PlumbingRepairContracts.StoragesContracts;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairListImplement.Models;
|
||||||
|
using static System.Formats.Asn1.AsnWriter;
|
||||||
|
|
||||||
|
namespace PlumbingRepairListImplement.Implements
|
||||||
|
{
|
||||||
|
public class StoreStorage : IStoreStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
public StoreStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
public StoreViewModel? Delete(StoreBindingModel model)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _source.Stores.Count; ++i)
|
||||||
|
{
|
||||||
|
if (_source.Stores[i].Id == model.Id)
|
||||||
|
{
|
||||||
|
var element = _source.Stores[i];
|
||||||
|
_source.Stores.RemoveAt(i);
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreViewModel? GetElement(StoreSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.StoreName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var store in _source.Stores)
|
||||||
|
{
|
||||||
|
if ((!string.IsNullOrEmpty(model.StoreName) && store.StoreName == model.StoreName) || (model.Id.HasValue && store.Id == model.Id))
|
||||||
|
{
|
||||||
|
return store.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StoreViewModel> GetFilteredList(StoreSearchModel model)
|
||||||
|
{
|
||||||
|
var result = new List<StoreViewModel>();
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(model.StoreName))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var store in _source.Stores)
|
||||||
|
{
|
||||||
|
if (store.StoreName.Contains(model.StoreName))
|
||||||
|
{
|
||||||
|
result.Add(store.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<StoreViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<StoreViewModel>();
|
||||||
|
|
||||||
|
foreach (var store in _source.Stores)
|
||||||
|
{
|
||||||
|
result.Add(store.GetViewModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreViewModel? Insert(StoreBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = 1;
|
||||||
|
|
||||||
|
foreach (var store in _source.Stores)
|
||||||
|
{
|
||||||
|
if (model.Id <= store.Id)
|
||||||
|
{
|
||||||
|
model.Id = store.Id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var newStore = Store.Create(model);
|
||||||
|
|
||||||
|
if (newStore == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_source.Stores.Add(newStore);
|
||||||
|
|
||||||
|
return newStore.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreViewModel? Update(StoreBindingModel model)
|
||||||
|
{
|
||||||
|
foreach (var store in _source.Stores)
|
||||||
|
{
|
||||||
|
if (store.Id == model.Id)
|
||||||
|
{
|
||||||
|
store.Update(model);
|
||||||
|
return store.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
57
PlumbingRepair/PlumbingRepairListImplement/Models/Store.cs
Normal file
57
PlumbingRepair/PlumbingRepairListImplement/Models/Store.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using PlumbingRepairContracts.BindingModels;
|
||||||
|
using PlumbingRepairContracts.ViewModels;
|
||||||
|
using PlumbingRepairDataModels.Models;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace PlumbingRepairListImplement.Models
|
||||||
|
{
|
||||||
|
public class Store : IStoreModel
|
||||||
|
{
|
||||||
|
public string StoreName { get; private set; } = string.Empty;
|
||||||
|
public string StoreAdress { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime OpeningDate { get; private set; }
|
||||||
|
|
||||||
|
public Dictionary<int, (IWorkModel, int)> Works { get; private set; } = new();
|
||||||
|
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public static Store? Create(StoreBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Store()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
StoreName = model.StoreName,
|
||||||
|
StoreAdress = model.StoreAdress,
|
||||||
|
OpeningDate = model.OpeningDate,
|
||||||
|
Works = new()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(StoreBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StoreName = model.StoreName;
|
||||||
|
StoreAdress = model.StoreAdress;
|
||||||
|
OpeningDate = model.OpeningDate;
|
||||||
|
Works = model.Works;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StoreViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
StoreName = StoreName,
|
||||||
|
StoreAdress = StoreAdress,
|
||||||
|
OpeningDate = OpeningDate,
|
||||||
|
Works = Works
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user