Compare commits

...

3 Commits

Author SHA1 Message Date
7b9bda4714 правки по 2 2024-12-06 11:39:51 +03:00
273c081f0e лабораторная 2 2024-11-25 14:33:39 +03:00
d1c9cd4ecc Лабораторная работа 1 2024-11-10 13:47:45 +03:00
73 changed files with 5248 additions and 77 deletions

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Entities;
public class Client
{
public int Id { get; set; }
public string Name { get; private set; } = string.Empty;
public string Phone { get; private set; } = string.Empty;
public Gender Gender { get; private set; } // Используем flag Gender
public static Client CreateEntity(int id, string name, string phone, Gender gender)
{
return new Client
{
Id = id,
Name = name,
Phone = phone,
Gender = gender,
};
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Entities;
public class Material
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public int UseCount { get; private set; }
public int CountInWareHouse { get; private set; }
public static Material CreateEntity(int id, string name,int usecount, int countInWarehouse)
{
return new Material
{
Id = id,
Name = name,
UseCount = usecount,
CountInWareHouse = countInWarehouse
};
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Entities;
public class MaterialReplenishment
{
public int Id { get; private set; }
public int Count { get; private set; }
public DateTime DataTime { get; private set; }
public int IDMaterial { get; private set; }
public static MaterialReplenishment CreateOperation(int id, int count, DateTime dataTime, int idmaterial)
{
return new MaterialReplenishment
{
Id = id,
Count = count,
DataTime = dataTime,
IDMaterial = idmaterial
};
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
namespace ProjectAtelier.Entities;
public class Order
{
public int Id { get; private set; }
public DateTime DataTime { get; private set; }
public OrderStatus Status { get; private set; }
public string Characteristic { get; private set; } = string.Empty;
public IEnumerable<OrderProduct> OrderProduct { get; private set; } = [];
public int IdClient { get; private set; }
public static Order CreateOperation(int id, OrderStatus status, string characteristic, IEnumerable<OrderProduct> orderProduct, int idClient, DateTime dateTime)
{
return new Order
{
Id = id,
DataTime = dateTime,
Status = status,
Characteristic = characteristic,
OrderProduct = orderProduct,
IdClient = idClient
};
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Entities;
public class OrderProduct
{
public int Id { get; private set; }
public int ProductId { get; private set; }
public int Count { get; private set; }
public static OrderProduct CreateOperation(int id, int productId, int count)
{
return new OrderProduct
{
Id = id,
ProductId = productId,
Count = count
};
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Entities;
public class Product
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public ProductView View{ get; set; }
public int CountMaterial { get; set; }
public IEnumerable<ProductMaterial> ProductMaterial { get; set; } = [];
public static Product CreateEntity(int id, string name, ProductView view, int countmaterial, IEnumerable<ProductMaterial> productMaterial)
{
return new Product
{
Id = id,
Name = name,
View = view,
CountMaterial = countmaterial,
ProductMaterial = productMaterial
};
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Entities;
public class ProductMaterial
{
public int Id { get; private set; }
//public int ProductId { get; private set; }
public int MaterialId { get; set; }
public int Count { get; set; }
public static ProductMaterial CreateOperation(int id, /*int productId*/ int materialid, int count)
{
return new ProductMaterial
{
Id = id,
//ProductId = productId,
MaterialId = materialid,
Count = count
};
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Entities;
[Flags]
public enum Gender
{
None = 0,
M = 1,
F = 2,
Other = 4
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Entities;
public enum OrderStatus
{
None = 0,
Обработка = 1,
Пошив = 2,
Готово = 3
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Entities;
public enum ProductView
{
None = 0,
Рубашка = 1,
Брюки = 2,
Пиджак = 3,
Халат= 4,
Футболка= 5
}

View File

@ -1,39 +0,0 @@
namespace ProjectAtelier
{
partial class Form1
{
/// <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.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace ProjectAtelier
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

138
ProjectAtelier/FormAtelier.Designer.cs generated Normal file
View File

@ -0,0 +1,138 @@
namespace ProjectAtelier
{
partial class FormAtelier
{
/// <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()
{
menuStrip = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem();
ProductsToolStripMenuItem = new ToolStripMenuItem();
MaterialsToolStripMenuItem = new ToolStripMenuItem();
ClientToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
MaterialConsumptionToolStripMenuItem = new ToolStripMenuItem();
OrderToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
SuspendLayout();
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(782, 28);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ProductsToolStripMenuItem, MaterialsToolStripMenuItem, ClientToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
//
// ProductsToolStripMenuItem
//
ProductsToolStripMenuItem.Name = "ProductsToolStripMenuItem";
ProductsToolStripMenuItem.Size = new Size(149, 26);
ProductsToolStripMenuItem.Text = "Продукт";
ProductsToolStripMenuItem.Click += ProductsToolStripMenuItem_Click;
//
// MaterialsToolStripMenuItem
//
MaterialsToolStripMenuItem.Name = "MaterialsToolStripMenuItem";
MaterialsToolStripMenuItem.Size = new Size(149, 26);
MaterialsToolStripMenuItem.Text = "Ткань";
MaterialsToolStripMenuItem.Click += MaterialsToolStripMenuItem_Click;
//
// ClientToolStripMenuItem
//
ClientToolStripMenuItem.Name = "ClientToolStripMenuItem";
ClientToolStripMenuItem.Size = new Size(149, 26);
ClientToolStripMenuItem.Text = "Клиент";
ClientToolStripMenuItem.Click += ClientToolStripMenuItem_Click;
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { MaterialConsumptionToolStripMenuItem, OrderToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции";
//
// MaterialConsumptionToolStripMenuItem
//
MaterialConsumptionToolStripMenuItem.Name = "MaterialConsumptionToolStripMenuItem";
MaterialConsumptionToolStripMenuItem.Size = new Size(215, 26);
MaterialConsumptionToolStripMenuItem.Text = "Пополение ткани";
MaterialConsumptionToolStripMenuItem.Click += MaterialConsumptionToolStripMenuItem_Click;
//
// OrderToolStripMenuItem
//
OrderToolStripMenuItem.Name = "OrderToolStripMenuItem";
OrderToolStripMenuItem.Size = new Size(215, 26);
OrderToolStripMenuItem.Text = "Заказ продукта";
OrderToolStripMenuItem.Click += OrderToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(73, 24);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// FormAtelier
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.i;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(782, 403);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormAtelier";
StartPosition = FormStartPosition.CenterParent;
Text = "Ателье";
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem ProductsToolStripMenuItem;
private ToolStripMenuItem MaterialsToolStripMenuItem;
private ToolStripMenuItem ClientToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem MaterialConsumptionToolStripMenuItem;
private ToolStripMenuItem OrderToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
}
}

View File

@ -0,0 +1,76 @@
using ProjectAtelier.Forms;
using Unity;
namespace ProjectAtelier
{
public partial class FormAtelier : Form
{
private readonly IUnityContainer _container;
public FormAtelier(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void ProductsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormProducts>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void MaterialsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormMaterialS>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void OrderToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormOrderS>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void MaterialConsumptionToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormMaterialSReplenishmentS>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormClientS>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,123 @@
<?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="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,140 @@
namespace ProjectAtelier.Forms
{
partial class FormClient
{
/// <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()
{
buttonCancel = new Button();
buttonAdd = new Button();
textBoxName = new TextBox();
labelName = new Label();
labelGender = new Label();
textBoxPhone = new TextBox();
labelPhone = new Label();
checkedListBoxGender = new CheckedListBox();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(267, 388);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(103, 59);
buttonCancel.TabIndex = 14;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(75, 388);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(96, 59);
buttonAdd.TabIndex = 13;
buttonAdd.Text = "Сохранить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// textBoxName
//
textBoxName.Location = new Point(213, 78);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(174, 27);
textBoxName.TabIndex = 11;
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(55, 85);
labelName.Name = "labelName";
labelName.Size = new Size(43, 20);
labelName.TabIndex = 9;
labelName.Text = "Имя ";
//
// labelGender
//
labelGender.AutoSize = true;
labelGender.Location = new Point(55, 180);
labelGender.Name = "labelGender";
labelGender.Size = new Size(58, 20);
labelGender.TabIndex = 15;
labelGender.Text = "Гендер";
//
// textBoxPhone
//
textBoxPhone.Location = new Point(213, 118);
textBoxPhone.Name = "textBoxPhone";
textBoxPhone.Size = new Size(174, 27);
textBoxPhone.TabIndex = 18;
//
// labelPhone
//
labelPhone.AutoSize = true;
labelPhone.Location = new Point(55, 125);
labelPhone.Name = "labelPhone";
labelPhone.Size = new Size(69, 20);
labelPhone.TabIndex = 17;
labelPhone.Text = "Телефон";
//
// checkedListBoxGender
//
checkedListBoxGender.FormattingEnabled = true;
checkedListBoxGender.Location = new Point(213, 168);
checkedListBoxGender.Name = "checkedListBoxGender";
checkedListBoxGender.Size = new Size(174, 114);
checkedListBoxGender.TabIndex = 19;
//
// FormClient
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(502, 528);
Controls.Add(checkedListBoxGender);
Controls.Add(textBoxPhone);
Controls.Add(labelPhone);
Controls.Add(labelGender);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(textBoxName);
Controls.Add(labelName);
Name = "FormClient";
Text = "Клиент";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonAdd;
private TextBox textBoxName;
private Label labelName;
private Label labelGender;
private TextBox textBoxPhone;
private Label labelPhone;
private CheckedListBox checkedListBoxGender;
}
}

View File

@ -0,0 +1,110 @@
using Microsoft.VisualBasic.FileIO;
using ProjectAtelier.Entities;
using ProjectAtelier.Repositories;
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 ProjectAtelier.Forms
{
public partial class FormClient : Form
{
private readonly IClientRepository _clientRepository;
private int? _clientId;
public int Id
{
set
{
try
{
var client = _clientRepository.ReadClientById(value);
if (client == null)
{
throw new InvalidDataException(nameof(client));
}
//textBoxName.Text = client.Name;
//textBoxPhone.Text = client.Phone;
//SetCheckedListBoxGender(client.Gender); // Устанавливаем выбранные элементы
//_clientId = value;///////////////////////////////
foreach (Gender elem in Enum.GetValues(typeof(Gender)))
{
if ((elem & client.Gender) != 0)
{
checkedListBoxGender.SetItemChecked(checkedListBoxGender.Items.IndexOf(
elem), true);
}
}
textBoxName.Text = client.Name;
textBoxPhone.Text = client.Phone;
_clientId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormClient(IClientRepository clientRepository)
{
InitializeComponent();
_clientRepository = clientRepository ??
throw new ArgumentNullException(nameof(clientRepository));
foreach (var elem in Enum.GetValues(typeof(Gender)))
{
checkedListBoxGender.Items.Add(elem);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
string.IsNullOrWhiteSpace(textBoxPhone.Text) ||
checkedListBoxGender.CheckedItems.Count == 0)
{
throw new Exception("Имеются незаполненные поля");
}
if (_clientId.HasValue)
{
_clientRepository.UpdateClient(CreateClient(_clientId.Value));
}
else
{
_clientRepository.CreateClient(CreateClient(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) =>Close();
private Client CreateClient(int id)
{
Gender gender = Gender.None;
foreach (var elem in checkedListBoxGender.CheckedItems)
{
gender |= (Gender)elem;
}
return Client.CreateEntity(id, textBoxName.Text, textBoxPhone.Text, gender);
}
}
}

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -0,0 +1,127 @@
namespace ProjectAtelier.Forms
{
partial class FormClientS
{
/// <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();
panel = new Panel();
buttonUpdate = new Button();
buttonRemove = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
panel.SuspendLayout();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Left;
dataGridView.Location = new Point(0, 0);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(558, 450);
dataGridView.TabIndex = 3;
//
// panel
//
panel.Anchor = AnchorStyles.Right;
panel.Controls.Add(buttonUpdate);
panel.Controls.Add(buttonRemove);
panel.Controls.Add(buttonAdd);
panel.Location = new Point(556, 1);
panel.Name = "panel";
panel.Size = new Size(205, 448);
panel.TabIndex = 2;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.pencil1;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(37, 326);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(94, 92);
buttonUpdate.TabIndex = 2;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonRemove
//
buttonRemove.BackgroundImage = Properties.Resources._;
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
buttonRemove.Location = new Point(37, 163);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(94, 92);
buttonRemove.TabIndex = 1;
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += ButtonRemove_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources._77_;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(37, 28);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 92);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormClientS
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(761, 450);
Controls.Add(dataGridView);
Controls.Add(panel);
Name = "FormClientS";
Text = "Клиенты";
Load += FormClientS_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Panel panel;
private Button buttonUpdate;
private Button buttonRemove;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,94 @@
using ProjectAtelier.Repositories;
using Unity;
namespace ProjectAtelier.Forms
{
public partial class FormClientS : Form
{
private readonly IUnityContainer _container;
private readonly IClientRepository _clientRepository;
public FormClientS(IUnityContainer container, IClientRepository clientRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
}
private void FormClientS_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormClient>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_clientRepository.DeleteClient(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormClient>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _clientRepository.ReadClients();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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>

View File

@ -0,0 +1,156 @@
namespace ProjectAtelier.Forms
{
partial class FormMaterial
{
/// <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();
labelCountUse = new Label();
label3 = new Label();
textBoxName = new TextBox();
numericUpDownUseCount = new NumericUpDown();
buttonAdd = new Button();
buttonCancel = new Button();
labelCountInWareHouse = new Label();
numericUpDownCountInWareHouse = new NumericUpDown();
((System.ComponentModel.ISupportInitialize)numericUpDownUseCount).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCountInWareHouse).BeginInit();
SuspendLayout();
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(12, 52);
labelName.Name = "labelName";
labelName.Size = new Size(156, 20);
labelName.TabIndex = 0;
labelName.Text = "Название материала";
//
// labelCountUse
//
labelCountUse.AutoSize = true;
labelCountUse.Location = new Point(12, 95);
labelCountUse.Name = "labelCountUse";
labelCountUse.Size = new Size(230, 20);
labelCountUse.TabIndex = 1;
labelCountUse.Text = "Количество для использования";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(33, 173);
label3.Name = "label3";
label3.Size = new Size(0, 20);
label3.TabIndex = 2;
//
// textBoxName
//
textBoxName.Location = new Point(269, 45);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(174, 27);
textBoxName.TabIndex = 3;
//
// numericUpDownUseCount
//
numericUpDownUseCount.Location = new Point(269, 93);
numericUpDownUseCount.Name = "numericUpDownUseCount";
numericUpDownUseCount.Size = new Size(175, 27);
numericUpDownUseCount.TabIndex = 4;
numericUpDownUseCount.Value = new decimal(new int[] { 1, 0, 0, 0 });
//
// buttonAdd
//
buttonAdd.Location = new Point(72, 230);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(96, 59);
buttonAdd.TabIndex = 5;
buttonAdd.Text = "Сохранить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(269, 230);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(103, 59);
buttonCancel.TabIndex = 6;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// labelCountInWareHouse
//
labelCountInWareHouse.AutoSize = true;
labelCountInWareHouse.Location = new Point(12, 143);
labelCountInWareHouse.Name = "labelCountInWareHouse";
labelCountInWareHouse.Size = new Size(161, 20);
labelCountInWareHouse.TabIndex = 7;
labelCountInWareHouse.Text = "Количество на складе";
//
// numericUpDownCountInWareHouse
//
numericUpDownCountInWareHouse.Location = new Point(268, 143);
numericUpDownCountInWareHouse.Name = "numericUpDownCountInWareHouse";
numericUpDownCountInWareHouse.Size = new Size(175, 27);
numericUpDownCountInWareHouse.TabIndex = 8;
//
// FormMaterial
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(489, 331);
Controls.Add(numericUpDownCountInWareHouse);
Controls.Add(labelCountInWareHouse);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(numericUpDownUseCount);
Controls.Add(textBoxName);
Controls.Add(label3);
Controls.Add(labelCountUse);
Controls.Add(labelName);
Name = "FormMaterial";
StartPosition = FormStartPosition.CenterParent;
Text = "Ткань";
((System.ComponentModel.ISupportInitialize)numericUpDownUseCount).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCountInWareHouse).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelName;
private Label labelCountUse;
private Label label3;
private TextBox textBoxName;
private NumericUpDown numericUpDownUseCount;
private Button buttonAdd;
private Button buttonCancel;
private Label labelCountInWareHouse;
private NumericUpDown numericUpDownCountInWareHouse;
}
}

View File

@ -0,0 +1,80 @@
using ProjectAtelier.Entities;
using ProjectAtelier.Repositories;
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 ProjectAtelier.Forms
{
public partial class FormMaterial : Form
{
private readonly IMaterialRepository _materialRepository;
private int? _materialId;
public int Id
{
set
{
try
{
var material = _materialRepository.ReadMaterialById(value);
if (material == null)
{
throw new InvalidDataException(nameof(material));
}
textBoxName.Text = material.Name;
numericUpDownUseCount.Value = material.UseCount;
numericUpDownCountInWareHouse.Value = material.CountInWareHouse;
_materialId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormMaterial(IMaterialRepository materialRepository)
{
InitializeComponent();
_materialRepository = materialRepository ?? throw new ArgumentNullException(nameof(materialRepository));
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (numericUpDownCountInWareHouse.Value < numericUpDownUseCount.Value)
{
throw new Exception("Нельзя использовать больше чем храниться на складе");
}
if (_materialId.HasValue)
{
_materialRepository.UpdateMaterial(CreateMaterial(_materialId.Value));
}
else
{
_materialRepository.CreateMaterial(CreateMaterial(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Material CreateMaterial(int id) => Material.CreateEntity(id, textBoxName.Text, Convert.ToInt32(numericUpDownUseCount.Value), Convert.ToInt32(numericUpDownCountInWareHouse.Value));
}
}

View 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>

View File

@ -0,0 +1,148 @@
namespace ProjectAtelier.Forms
{
partial class FormMaterialReplenishment
{
/// <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()
{
label2 = new Label();
numericUpDownCount = new NumericUpDown();
buttonAdd = new Button();
buttonCancel = new Button();
comboBoxMaterial = new ComboBox();
label1 = new Label();
dateTimePicker = new DateTimePicker();
label3 = new Label();
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
SuspendLayout();
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(77, 130);
label2.Name = "label2";
label2.Size = new Size(90, 20);
label2.TabIndex = 1;
label2.Text = "Количество";
//
// numericUpDownCount
//
numericUpDownCount.Location = new Point(212, 123);
numericUpDownCount.Name = "numericUpDownCount";
numericUpDownCount.Size = new Size(150, 27);
numericUpDownCount.TabIndex = 3;
//
// buttonAdd
//
buttonAdd.Location = new Point(77, 197);
buttonAdd.Margin = new Padding(3, 4, 3, 4);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(107, 53);
buttonAdd.TabIndex = 4;
buttonAdd.Text = "Сохранить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click_1;
//
// buttonCancel
//
buttonCancel.Location = new Point(231, 197);
buttonCancel.Margin = new Padding(3, 4, 3, 4);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(117, 53);
buttonCancel.TabIndex = 5;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click_1;
//
// comboBoxMaterial
//
comboBoxMaterial.FormattingEnabled = true;
comboBoxMaterial.Location = new Point(210, 76);
comboBoxMaterial.Name = "comboBoxMaterial";
comboBoxMaterial.Size = new Size(151, 28);
comboBoxMaterial.TabIndex = 6;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(77, 76);
label1.Name = "label1";
label1.Size = new Size(103, 20);
label1.TabIndex = 7;
label1.Text = "ID материала";
//
// dateTimePicker
//
dateTimePicker.Location = new Point(210, 26);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(152, 27);
dateTimePicker.TabIndex = 8;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(77, 33);
label3.Name = "label3";
label3.Size = new Size(41, 20);
label3.TabIndex = 9;
label3.Text = "Дата";
//
// FormMaterialReplenishment
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(411, 273);
Controls.Add(label3);
Controls.Add(dateTimePicker);
Controls.Add(label1);
Controls.Add(comboBoxMaterial);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(numericUpDownCount);
Controls.Add(label2);
Name = "FormMaterialReplenishment";
Text = "Пополнение ткани";
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
ResumeLayout(false);
PerformLayout();
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
#endregion
private Label label2;
private NumericUpDown numericUpDownCount;
private Button buttonAdd;
private Button buttonCancel;
private ComboBox comboBoxMaterial;
private Label label1;
private DateTimePicker dateTimePicker;
private Label label3;
}
}

View File

@ -0,0 +1,93 @@
using ProjectAtelier.Entities;
using ProjectAtelier.Repositories;
using ProjectAtelier.REPOSITORY;
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 ProjectAtelier.Forms
{
public partial class FormMaterialReplenishment : Form
{
private readonly IMaterialReplenishmentRepository _materialReplenishmentRepository;
private readonly IMaterialRepository _materialRepository; // Добавляем репозиторий для материалов
private int? _materialReplenishmentId;
public int Id
{
set
{
try
{
var materialReplenishment = _materialReplenishmentRepository.ReadMaterialSpentById(value);
if (materialReplenishment == null)
{
throw new InvalidDataException(nameof(materialReplenishment));
}
numericUpDownCount.Value = materialReplenishment.Count;
comboBoxMaterial.SelectedValue = materialReplenishment.IDMaterial; // Устанавливаем выбранный материал
dateTimePicker.Value = materialReplenishment.DataTime; // Устанавливаем выбранную дату и время
_materialReplenishmentId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormMaterialReplenishment(IMaterialReplenishmentRepository materialReplenishmentRepository, IMaterialRepository materialRepository)
{
InitializeComponent();
_materialReplenishmentRepository = materialReplenishmentRepository ?? throw new ArgumentNullException(nameof(materialReplenishmentRepository));
_materialRepository = materialRepository ?? throw new ArgumentNullException(nameof(materialRepository));
// Заполняем ComboBox для выбора материала
comboBoxMaterial.DataSource = _materialRepository.ReadMaterials();
comboBoxMaterial.DisplayMember = "Name";
comboBoxMaterial.ValueMember = "Id";
}
private MaterialReplenishment CreateMaterialReplenishment(int id)
{
int selectedMaterialId = (int)comboBoxMaterial.SelectedValue;
DateTime selectedDateTime = dateTimePicker.Value;
return MaterialReplenishment.CreateOperation(id, Convert.ToInt32(numericUpDownCount.Value), selectedDateTime, selectedMaterialId);
}
private void ButtonAdd_Click_1(object sender, EventArgs e)
{
try
{
if (comboBoxMaterial.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
if (_materialReplenishmentId.HasValue)
{
_materialReplenishmentRepository.UpdateMaterialSpent(CreateMaterialReplenishment(_materialReplenishmentId.Value));
}
else
{
_materialReplenishmentRepository.CreateMaterialSpent(CreateMaterialReplenishment(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click_1(object sender, EventArgs e) => Close();
}
}

View 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>

View File

@ -0,0 +1,127 @@
namespace ProjectAtelier.Forms
{
partial class FormMaterialS
{
/// <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()
{
panel = new Panel();
buttonUpdate = new Button();
buttonRemove = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel
//
panel.Anchor = AnchorStyles.Right;
panel.Controls.Add(buttonUpdate);
panel.Controls.Add(buttonRemove);
panel.Controls.Add(buttonAdd);
panel.Location = new Point(555, 1);
panel.Name = "panel";
panel.Size = new Size(154, 448);
panel.TabIndex = 0;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.pencil1;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(37, 326);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(94, 92);
buttonUpdate.TabIndex = 2;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonRemove
//
buttonRemove.BackgroundImage = Properties.Resources._;
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
buttonRemove.Location = new Point(37, 163);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(94, 92);
buttonRemove.TabIndex = 1;
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += ButtonRemove_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources._77_;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(37, 28);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 92);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Left;
dataGridView.Location = new Point(0, 0);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(558, 450);
dataGridView.TabIndex = 1;
//
// FormMaterialS
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(707, 450);
Controls.Add(dataGridView);
Controls.Add(panel);
Name = "FormMaterialS";
Text = "Ткани";
Load += FormMaterialS_Load;
panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel;
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonUpdate;
private Button buttonRemove;
}
}

View File

@ -0,0 +1,104 @@
using ProjectAtelier.Repositories;
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;
using Unity;
namespace ProjectAtelier.Forms
{
public partial class FormMaterialS : Form
{
private readonly IUnityContainer _container;
private readonly IMaterialRepository _materialRepository;
public FormMaterialS(IUnityContainer container, IMaterialRepository materiallRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_materialRepository = materiallRepository ?? throw new ArgumentNullException(nameof(materiallRepository));
}
private void FormMaterialS_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormMaterial>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_materialRepository.DeleteMaterial(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormMaterial>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _materialRepository.ReadMaterials();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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>

View File

@ -0,0 +1,113 @@
namespace ProjectAtelier.Forms
{
partial class FormMaterialSReplenishmentS
{
/// <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();
panel = new Panel();
buttonUpdate = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
panel.SuspendLayout();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Left;
dataGridView.Location = new Point(0, 0);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(605, 450);
dataGridView.TabIndex = 2;
//
// panel
//
panel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
panel.Controls.Add(buttonUpdate);
panel.Controls.Add(buttonAdd);
panel.Location = new Point(603, 0);
panel.Name = "panel";
panel.Size = new Size(195, 450);
panel.TabIndex = 3;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.pencil1;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(52, 244);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(94, 104);
buttonUpdate.TabIndex = 1;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += buttonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources._77_;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(52, 67);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 101);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// FormMaterialSReplenishmentS
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel);
Controls.Add(dataGridView);
Name = "FormMaterialSReplenishmentS";
Text = "Пополнение ткани";
Load += FormMaterialSReplenishmentS_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Panel panel;
private Button buttonUpdate;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,83 @@
using ProjectAtelier.REPOSITORY;
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;
using Unity;
namespace ProjectAtelier.Forms
{
public partial class FormMaterialSReplenishmentS : Form
{
private readonly IUnityContainer _container;
private readonly IMaterialReplenishmentRepository _materialSpentRepository;
public FormMaterialSReplenishmentS(IUnityContainer container, IMaterialReplenishmentRepository materialSpentRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_materialSpentRepository = materialSpentRepository ?? throw new ArgumentNullException(nameof(materialSpentRepository));
}
private void FormMaterialSReplenishmentS_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormMaterialReplenishment>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormMaterialReplenishment>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _materialSpentRepository.ReadMaterialsSpent();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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>

View File

@ -0,0 +1,113 @@
namespace ProjectAtelier.Forms
{
partial class FormOrderS
{
/// <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();
panel = new Panel();
ButtonRemove = new Button();
ButtonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
panel.SuspendLayout();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Left;
dataGridView.Location = new Point(0, 0);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(706, 511);
dataGridView.TabIndex = 2;
//
// panel
//
panel.Anchor = AnchorStyles.Right;
panel.Controls.Add(ButtonRemove);
panel.Controls.Add(ButtonAdd);
panel.Location = new Point(712, 0);
panel.Name = "panel";
panel.Size = new Size(186, 511);
panel.TabIndex = 4;
//
// ButtonRemove
//
ButtonRemove.BackgroundImage = Properties.Resources._;
ButtonRemove.BackgroundImageLayout = ImageLayout.Stretch;
ButtonRemove.Location = new Point(37, 245);
ButtonRemove.Name = "ButtonRemove";
ButtonRemove.Size = new Size(94, 92);
ButtonRemove.TabIndex = 1;
ButtonRemove.UseVisualStyleBackColor = true;
ButtonRemove.Click += ButtonRemove_Click;
//
// ButtonAdd
//
ButtonAdd.BackgroundImage = Properties.Resources._77_;
ButtonAdd.BackgroundImageLayout = ImageLayout.Stretch;
ButtonAdd.Location = new Point(37, 84);
ButtonAdd.Name = "ButtonAdd";
ButtonAdd.Size = new Size(94, 92);
ButtonAdd.TabIndex = 0;
ButtonAdd.UseVisualStyleBackColor = true;
ButtonAdd.Click += ButtonAdd_Click;
//
// FormOrderS
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(901, 511);
Controls.Add(panel);
Controls.Add(dataGridView);
Name = "FormOrderS";
Text = "Заказы";
Load += FormOrderS_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Panel panel;
private Button ButtonRemove;
private Button ButtonAdd;
}
}

View File

@ -0,0 +1,75 @@
using ProjectAtelier.Repositories;
using Unity;
namespace ProjectAtelier.Forms
{
public partial class FormOrderS : Form
{
private readonly IUnityContainer _container;
private readonly IOrderRepository _orderRepository;
public FormOrderS(IUnityContainer container, IOrderRepository orderRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
}
private void FormOrderS_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormProductOrder>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_orderRepository.DeleteOrder(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _orderRepository.ReadOrders();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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>

View File

@ -0,0 +1,205 @@
namespace ProjectAtelier.Forms
{
partial class FormProductMaterial
{
/// <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()
{
groupBox = new GroupBox();
dataGridView = new DataGridView();
ColumnMaterial = new DataGridViewComboBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
buttonAdd = new Button();
buttonCancel = new Button();
labelName = new Label();
labelType = new Label();
labelCountInWarehouse = new Label();
textBoxName = new TextBox();
comboBoxProduct = new ComboBox();
numericUpDownCount = new NumericUpDown();
groupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
SuspendLayout();
//
// groupBox
//
groupBox.Controls.Add(dataGridView);
groupBox.Location = new Point(14, 228);
groupBox.Margin = new Padding(3, 4, 3, 4);
groupBox.Name = "groupBox";
groupBox.Padding = new Padding(3, 4, 3, 4);
groupBox.Size = new Size(648, 356);
groupBox.TabIndex = 0;
groupBox.TabStop = false;
//
// dataGridView
//
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnMaterial, ColumnCount });
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(3, 24);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(642, 328);
dataGridView.TabIndex = 0;
//
// ColumnMaterial
//
ColumnMaterial.HeaderText = "Materials";
ColumnMaterial.MinimumWidth = 6;
ColumnMaterial.Name = "ColumnMaterial";
ColumnMaterial.Resizable = DataGridViewTriState.True;
ColumnMaterial.SortMode = DataGridViewColumnSortMode.Automatic;
//
// ColumnCount
//
ColumnCount.HeaderText = "Count";
ColumnCount.MinimumWidth = 6;
ColumnCount.Name = "ColumnCount";
//
// buttonAdd
//
buttonAdd.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonAdd.Location = new Point(96, 596);
buttonAdd.Margin = new Padding(3, 4, 3, 4);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(143, 31);
buttonAdd.TabIndex = 1;
buttonAdd.Text = "Сохранить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(406, 596);
buttonCancel.Margin = new Padding(3, 4, 3, 4);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(143, 31);
buttonCancel.TabIndex = 2;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(35, 41);
labelName.Name = "labelName";
labelName.Size = new Size(77, 20);
labelName.TabIndex = 3;
labelName.Text = "Название";
//
// labelType
//
labelType.AutoSize = true;
labelType.Location = new Point(35, 109);
labelType.Name = "labelType";
labelType.Size = new Size(96, 20);
labelType.TabIndex = 4;
labelType.Text = "Вид изделия";
//
// labelCountInWarehouse
//
labelCountInWarehouse.AutoSize = true;
labelCountInWarehouse.Location = new Point(35, 173);
labelCountInWarehouse.Name = "labelCountInWarehouse";
labelCountInWarehouse.Size = new Size(161, 20);
labelCountInWarehouse.TabIndex = 5;
labelCountInWarehouse.Text = "Количество на складе";
//
// textBoxName
//
textBoxName.Location = new Point(215, 37);
textBoxName.Margin = new Padding(3, 4, 3, 4);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(161, 27);
textBoxName.TabIndex = 6;
//
// comboBoxProduct
//
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxProduct.FormattingEnabled = true;
comboBoxProduct.Location = new Point(215, 101);
comboBoxProduct.Margin = new Padding(3, 4, 3, 4);
comboBoxProduct.Name = "comboBoxProduct";
comboBoxProduct.Size = new Size(161, 28);
comboBoxProduct.TabIndex = 7;
//
// numericUpDownCount
//
numericUpDownCount.Location = new Point(215, 173);
numericUpDownCount.Margin = new Padding(3, 4, 3, 4);
numericUpDownCount.Name = "numericUpDownCount";
numericUpDownCount.Size = new Size(161, 27);
numericUpDownCount.TabIndex = 8;
//
// FormProductMaterial
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(675, 643);
Controls.Add(numericUpDownCount);
Controls.Add(comboBoxProduct);
Controls.Add(textBoxName);
Controls.Add(labelCountInWarehouse);
Controls.Add(labelType);
Controls.Add(labelName);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Controls.Add(groupBox);
Margin = new Padding(3, 4, 3, 4);
Name = "FormProductMaterial";
Text = "Материал и изделие";
groupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private GroupBox groupBox;
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonCancel;
private Label labelName;
private Label labelType;
private Label labelCountInWarehouse;
private TextBox textBoxName;
private ComboBox comboBoxProduct;
private NumericUpDown numericUpDownCount;
private DataGridViewComboBoxColumn ColumnMaterial;
private DataGridViewTextBoxColumn ColumnCount;
}
}

View File

@ -0,0 +1,113 @@
using ProjectAtelier.Entities;
using ProjectAtelier.Repositories;
using ProjectAtelier.Repositories.Implementations;
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 ProjectAtelier.Forms
{
public partial class FormProductMaterial : Form
{
private readonly IProductRepository _productRepository;
private readonly IMaterialRepository _materialRepository;
private int? _productId;
public int Id
{
set
{
try
{
var product = _productRepository.ReadProductById(value);
if (product == null)
{
throw new InvalidDataException(nameof(product));
}
textBoxName.Text = product.Name;
comboBoxProduct.SelectedItem = product.View;
numericUpDownCount.Value = product.CountMaterial;
_productId = value;
dataGridView.Rows.Clear();
var rows = new List<DataGridViewRow>();
foreach (var productMaterial in product.ProductMaterial)
{
var material = _materialRepository.ReadMaterialById(productMaterial.MaterialId);
if (material != null)
{
var row = new DataGridViewRow();
row.CreateCells(dataGridView, material.Id, productMaterial.Count);
rows.Add(row);
}
}
dataGridView.Rows.AddRange(rows.ToArray());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при полученииданных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormProductMaterial(IProductRepository productRepository, IMaterialRepository materialRepository)
{
InitializeComponent();
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
_materialRepository = materialRepository ?? throw new ArgumentNullException(nameof(materialRepository));
comboBoxProduct.DataSource = Enum.GetValues(typeof(ProductView));
ColumnMaterial.DataSource = materialRepository.ReadMaterials();
ColumnMaterial.DisplayMember = "Name";
ColumnMaterial.ValueMember = "Id";
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (dataGridView.RowCount < 1)
{
throw new Exception("Имеются незаполненны поля");
}
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text) || comboBoxProduct.SelectedIndex < 1)
{
throw new Exception("Имеются незаполненные поля");
}
if (_productId.HasValue)
{
_productRepository.UpdateProduct(CreateProduct(_productId.Value));
}
else
{
_productRepository.CreateProduct(CreateProduct(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private List<ProductMaterial> CreateListMaterialFromDataGrid()
{
var list = new List<ProductMaterial>();
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells["ColumnMaterial"].Value == null || row.Cells["ColumnCount"].Value == null)
{
continue;
}
list.Add(ProductMaterial.CreateOperation(0, Convert.ToInt32(row.Cells["ColumnMaterial"].Value), Convert.ToInt32(row.Cells["ColumnCount"].Value)));
}
return list;
}
private Product CreateProduct(int id) => Product.CreateEntity(id, textBoxName.Text, (ProductView)comboBoxProduct.SelectedItem!, Convert.ToInt32(numericUpDownCount.Value), CreateListMaterialFromDataGrid());
}
}

View 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>

View File

@ -0,0 +1,223 @@
namespace ProjectAtelier.Forms
{
partial class FormProductOrder
{
/// <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()
{
buttonAdd = new Button();
buttonCancel = new Button();
labelStatus = new Label();
labelCharacteristic = new Label();
textBoxCharacteristic = new TextBox();
comboBoxStatus = new ComboBox();
groupBox = new GroupBox();
dataGridView = new DataGridView();
comboBoxClient = new ComboBox();
labelClient = new Label();
dateTimePicker = new DateTimePicker();
label1 = new Label();
ColumProduct = new DataGridViewComboBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
groupBox.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonAdd
//
buttonAdd.Location = new Point(36, 682);
buttonAdd.Margin = new Padding(3, 4, 3, 4);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(107, 31);
buttonAdd.TabIndex = 0;
buttonAdd.Text = "Сохранить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(197, 682);
buttonCancel.Margin = new Padding(3, 4, 3, 4);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(98, 31);
buttonCancel.TabIndex = 1;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// labelStatus
//
labelStatus.AutoSize = true;
labelStatus.Location = new Point(24, 65);
labelStatus.Name = "labelStatus";
labelStatus.Size = new Size(134, 20);
labelStatus.TabIndex = 2;
labelStatus.Text = "Статус готовности";
//
// labelCharacteristic
//
labelCharacteristic.AutoSize = true;
labelCharacteristic.Location = new Point(24, 194);
labelCharacteristic.Name = "labelCharacteristic";
labelCharacteristic.Size = new Size(119, 20);
labelCharacteristic.TabIndex = 3;
labelCharacteristic.Text = "Характеристика";
//
// textBoxCharacteristic
//
textBoxCharacteristic.Location = new Point(178, 157);
textBoxCharacteristic.Margin = new Padding(3, 4, 3, 4);
textBoxCharacteristic.Multiline = true;
textBoxCharacteristic.Name = "textBoxCharacteristic";
textBoxCharacteristic.Size = new Size(267, 57);
textBoxCharacteristic.TabIndex = 4;
//
// comboBoxStatus
//
comboBoxStatus.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxStatus.FormattingEnabled = true;
comboBoxStatus.Location = new Point(178, 62);
comboBoxStatus.Margin = new Padding(3, 4, 3, 4);
comboBoxStatus.Name = "comboBoxStatus";
comboBoxStatus.Size = new Size(267, 28);
comboBoxStatus.TabIndex = 5;
//
// groupBox
//
groupBox.Controls.Add(dataGridView);
groupBox.Location = new Point(12, 238);
groupBox.Margin = new Padding(3, 4, 3, 4);
groupBox.Name = "groupBox";
groupBox.Padding = new Padding(3, 4, 3, 4);
groupBox.Size = new Size(505, 436);
groupBox.TabIndex = 6;
groupBox.TabStop = false;
//
// dataGridView
//
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumProduct, ColumnCount });
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(3, 24);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(499, 408);
dataGridView.TabIndex = 0;
//
// comboBoxClient
//
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxClient.FormattingEnabled = true;
comboBoxClient.Location = new Point(178, 106);
comboBoxClient.Margin = new Padding(3, 4, 3, 4);
comboBoxClient.Name = "comboBoxClient";
comboBoxClient.Size = new Size(267, 28);
comboBoxClient.TabIndex = 8;
//
// labelClient
//
labelClient.AutoSize = true;
labelClient.Location = new Point(24, 123);
labelClient.Name = "labelClient";
labelClient.Size = new Size(83, 20);
labelClient.TabIndex = 9;
labelClient.Text = "ID клиента";
//
// dateTimePicker
//
dateTimePicker.Location = new Point(178, 17);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(267, 27);
dateTimePicker.TabIndex = 10;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(24, 22);
label1.Name = "label1";
label1.Size = new Size(41, 20);
label1.TabIndex = 11;
label1.Text = "Дата";
//
// ColumProduct
//
ColumProduct.HeaderText = "Изделие";
ColumProduct.MinimumWidth = 6;
ColumProduct.Name = "ColumProduct";
//
// ColumnCount
//
ColumnCount.HeaderText = "Количество";
ColumnCount.MinimumWidth = 6;
ColumnCount.Name = "ColumnCount";
//
// FormProductOrder
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(612, 738);
Controls.Add(label1);
Controls.Add(dateTimePicker);
Controls.Add(labelClient);
Controls.Add(comboBoxClient);
Controls.Add(groupBox);
Controls.Add(comboBoxStatus);
Controls.Add(textBoxCharacteristic);
Controls.Add(labelCharacteristic);
Controls.Add(labelStatus);
Controls.Add(buttonCancel);
Controls.Add(buttonAdd);
Margin = new Padding(3, 4, 3, 4);
Name = "FormProductOrder";
Text = "Заказ";
groupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonAdd;
private Button buttonCancel;
private Label labelStatus;
private Label labelCharacteristic;
private TextBox textBoxCharacteristic;
private ComboBox comboBoxStatus;
private GroupBox groupBox;
private DataGridView dataGridView;
private ComboBox comboBoxClient;
private Label labelClient;
private DateTimePicker dateTimePicker;
private Label label1;
private DataGridViewComboBoxColumn ColumProduct;
private DataGridViewTextBoxColumn ColumnCount;
}
}

View File

@ -0,0 +1,77 @@
using ProjectAtelier.Entities;
using ProjectAtelier.Repositories;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Windows.Forms;
namespace ProjectAtelier.Forms
{
public partial class FormProductOrder : Form
{
private readonly IOrderRepository _orderRepository;
private readonly IProductRepository _productRepository;
private readonly IClientRepository _clientRepository; // Добавляем репозиторий для клиентов
public FormProductOrder(IOrderRepository orderRepository, IProductRepository productRepository, IClientRepository clientRepository)
{
InitializeComponent();
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
comboBoxStatus.DataSource = Enum.GetValues(typeof(OrderStatus));
// Заполняем ComboBox для выбора клиента
comboBoxClient.DataSource = clientRepository.ReadClients();
comboBoxClient.DisplayMember = "Name";
comboBoxClient.ValueMember = "Id";
ColumProduct.DataSource = productRepository.ReadProducts();
ColumProduct.DisplayMember = "View";
ColumProduct.ValueMember = "Id";
// Инициализация DateTimePicker
dateTimePicker.Format = DateTimePickerFormat.Custom;
dateTimePicker.CustomFormat = "yyyy-MM-dd HH:mm:ss";
dateTimePicker.Value = DateTime.Now; // Устанавливаем текущую дату и время по умолчанию
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
if (dataGridView.RowCount < 1 || textBoxCharacteristic.Text == null || comboBoxStatus.SelectedIndex < 0 || comboBoxClient.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
try
{
int clientId = (int)comboBoxClient.SelectedValue;
DateTime selectedDateTime = dateTimePicker.Value; // Получаем выбранную дату и время
_orderRepository.CreateOrder(Order.CreateOperation(0, (OrderStatus)comboBoxStatus.SelectedValue!, textBoxCharacteristic.Text, CreateListProductFromDataGrid(), clientId, selectedDateTime));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private List<OrderProduct> CreateListProductFromDataGrid()
{
var list = new List<OrderProduct>();
foreach (DataGridViewRow row in dataGridView.Rows)
{
if (row.Cells["ColumProduct"].Value == null ||
row.Cells["ColumnCount"].Value == null)
{
continue;
}
list.Add(OrderProduct.CreateOperation(0,Convert.ToInt32(row.Cells["ColumProduct"].Value), Convert.ToInt32(row.Cells["ColumnCount"].Value)));
}
return list;
}
}
}

View 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>

View File

@ -0,0 +1,127 @@
namespace ProjectAtelier.Forms
{
partial class FormProducts
{
/// <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();
panel = new Panel();
buttonUpdate = new Button();
buttonRemove = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
panel.SuspendLayout();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Left;
dataGridView.Location = new Point(0, 0);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(628, 450);
dataGridView.TabIndex = 2;
//
// panel
//
panel.Anchor = AnchorStyles.Right;
panel.Controls.Add(buttonUpdate);
panel.Controls.Add(buttonRemove);
panel.Controls.Add(buttonAdd);
panel.Location = new Point(625, 0);
panel.Name = "panel";
panel.Size = new Size(173, 448);
panel.TabIndex = 3;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.pencil1;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(37, 326);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(94, 92);
buttonUpdate.TabIndex = 2;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += buttonUpdate_Click;
//
// buttonRemove
//
buttonRemove.BackgroundImage = Properties.Resources._;
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
buttonRemove.Location = new Point(37, 163);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(94, 92);
buttonRemove.TabIndex = 1;
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += buttonRemove_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources._77_;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(37, 28);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(94, 92);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// FormProducts
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(804, 450);
Controls.Add(panel);
Controls.Add(dataGridView);
Name = "FormProducts";
Text = "Изделия";
Load += FormProductS_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Panel panel;
private Button buttonUpdate;
private Button buttonRemove;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,102 @@
using ProjectAtelier.Repositories;
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;
using Unity;
namespace ProjectAtelier.Forms
{
public partial class FormProducts : Form
{
private readonly IUnityContainer _container;
private readonly IProductRepository _productRepository;
public FormProducts(IUnityContainer container, IProductRepository productRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
}
private void FormProductS_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormProductMaterial>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_productRepository.DeleteProduct(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormProductMaterial>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _productRepository.ReadProducts();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridView.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

View 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>

View File

@ -1,3 +1,13 @@
using ProjectAtelier.Repositories.Implementations;
using ProjectAtelier.Repositories;
using ProjectAtelier.REPOSITORY.Implementations;
using ProjectAtelier.REPOSITORY;
using Unity;
using Unity.Microsoft.Logging;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Serilog;
namespace ProjectAtelier
{
internal static class Program
@ -11,7 +21,33 @@ namespace ProjectAtelier
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
Application.Run(CreateContainer().Resolve<FormAtelier>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
container.RegisterType<IOrderRepository, OrderRepository>();
container.RegisterType<IMaterialRepository, MaterialRepository>();
container.RegisterType<IProductRepository, ProductRepository>();
container.RegisterType<IClientRepository, ClientRepository>();
container.RegisterType<IProductMaterialRepository, ProductMaterialRepository>();
container.RegisterType<IMaterialReplenishmentRepository, MaterialReplenishmentRepository>();
container.RegisterType<IConnectionString, ConnectionString>();
return container;
}
private static LoggerFactory CreateLoggerFactory()
{
var loggerFactory = new LoggerFactory();
loggerFactory.AddSerilog(new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build())
.CreateLogger());
return loggerFactory;
}
}
}

View File

@ -8,4 +8,40 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="8.0.5" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@ -0,0 +1,153 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectAtelier.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectAtelier.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap _ {
get {
object obj = ResourceManager.GetObject("-", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap _14 {
get {
object obj = ResourceManager.GetObject("14", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap _77_ {
get {
object obj = ResourceManager.GetObject("77+", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap _99999 {
get {
object obj = ResourceManager.GetObject("99999", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap i {
get {
object obj = ResourceManager.GetObject("i", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap pencil1 {
get {
object obj = ResourceManager.GetObject("pencil1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap XXL {
get {
object obj = ResourceManager.GetObject("XXL", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap XXL_height {
get {
object obj = ResourceManager.GetObject("XXL_height", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap ателье1 {
get {
object obj = ResourceManager.GetObject("ателье1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,148 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="-" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\-.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="ателье1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\ателье1.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="i" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\i.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pencil1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\pencil1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="XXL" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\XXL.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="14" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\14.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="XXL_height" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\XXL_height.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="77+" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\77+.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="99999" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\99999.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,16 @@
using ProjectAtelier.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.REPOSITORY;
public interface IMaterialReplenishmentRepository
{
IEnumerable<MaterialReplenishment> ReadMaterialsSpent();
MaterialReplenishment ReadMaterialSpentById(int id);
void CreateMaterialSpent(MaterialReplenishment material);
void UpdateMaterialSpent(MaterialReplenishment material);
}

View File

@ -0,0 +1,106 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectAtelier.Entities;
using ProjectAtelier.Repositories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.REPOSITORY.Implementations;
public class MaterialReplenishmentRepository : IMaterialReplenishmentRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<Material> _logger;
public MaterialReplenishmentRepository(IConnectionString connectionString, ILogger<Material> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateMaterialSpent(MaterialReplenishment material)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(material));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO MaterialReplenishment (Count, DataTime, IDMaterial)
VALUES (@Count, @DataTime, @IDMaterial)";
connection.Execute(queryInsert, material);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public MaterialReplenishment ReadMaterialSpentById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM MaterialReplenishment
WHERE Id=@id";
var material = connection.QueryFirst<MaterialReplenishment>(querySelect, new
{
id
});
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(material));
return material;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<MaterialReplenishment> ReadMaterialsSpent()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM MaterialReplenishment";
var materials = connection.Query<MaterialReplenishment>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(materials));
return materials;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public void UpdateMaterialSpent(MaterialReplenishment material)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(material));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE MaterialReplenishment
SET
Count=@Count,
DataTime=@DataTime,
IDMaterial=@IDMaterial
WHERE Id=@Id";
connection.Execute(queryUpdate, material);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

View File

@ -0,0 +1,17 @@
using ProjectAtelier.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Repositories;
public interface IClientRepository
{
IEnumerable<Client> ReadClients();
Client ReadClientById(int id);
void CreateClient(Client client);
void UpdateClient(Client client);
void DeleteClient(int id);
}

View File

@ -0,0 +1,5 @@
namespace ProjectAtelier.Repositories;
public interface IConnectionString
{
public string ConnectionString { get; }
}

View File

@ -0,0 +1,17 @@
using ProjectAtelier.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Repositories;
public interface IMaterialRepository
{
IEnumerable<Material> ReadMaterials();
Material ReadMaterialById(int id);
void CreateMaterial(Material material);
void UpdateMaterial(Material material);
void DeleteMaterial(int id);
}

View File

@ -0,0 +1,15 @@
using ProjectAtelier.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Repositories;
public interface IOrderRepository
{
IEnumerable<Order> ReadOrders(DateTime? dateForm = null, DateTime? dateTo = null, int? orderStatus = null, int? orderId = null);
void CreateOrder(Order order);
void DeleteOrder(int id);
}

View File

@ -0,0 +1,16 @@
using ProjectAtelier.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Repositories;
public interface IProductMaterialRepository
{
IEnumerable<ProductMaterial> ReadMaterialsConsumption();
ProductMaterial ReadMaterialConsumptionById(int id);
void CreateMaterialConsumption(ProductMaterial materialConsumption);
}

View File

@ -0,0 +1,17 @@
using ProjectAtelier.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Repositories;
public interface IProductRepository
{
IEnumerable<Product> ReadProducts();
Product ReadProductById(int id);
void CreateProduct(Product product);
void UpdateProduct(Product product);
void DeleteProduct(int id);
}

View File

@ -0,0 +1,126 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectAtelier.Entities;
namespace ProjectAtelier.Repositories.Implementations;
public class ClientRepository : IClientRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<Client> _logger;
public ClientRepository(IConnectionString connectionString, ILogger<Client> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateClient(Client client)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(client));
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Clients (Name, Phone, Gender)
VALUES (@Name, @Phone, @Gender)";
connection.Execute(queryInsert, client);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void UpdateClient(Client client)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}",
JsonConvert.SerializeObject(client));
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Clients
SET
Name=@Name,
Phone=@Phone,
Gender=@Gender
WHERE Id=@Id";
connection.Execute(queryUpdate, client);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteClient(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Clients
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Client ReadClientById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Clients
WHERE Id=@id";
var client = connection.QueryFirst<Client>(querySelect, new
{
id
});
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(client));
return client;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Client> ReadClients()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new
NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Clients";
var Client = connection.Query<Client>(querySelect);
_logger.LogDebug("Полученные объекты: {json}",
JsonConvert.SerializeObject(Client));
return Client;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Repositories.Implementations;
public class ConnectionString : IConnectionString
{
string IConnectionString.ConnectionString => "Server=localhost; Port=5432;Database=atelier;User Id=postgres; Password=postgres";
}

View File

@ -0,0 +1,125 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectAtelier.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Repositories.Implementations;
public class MaterialRepository : IMaterialRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<Material> _logger;
public MaterialRepository(IConnectionString connectionString, ILogger<Material> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateMaterial(Material material)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(material));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"
INSERT INTO Materials (Name, UseCount, CountInWareHouse)
VALUES (@Name, @UseCount, @CountInWareHouse)";
connection.Execute(queryInsert, material);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void UpdateMaterial(Material material)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(material));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryUpdate = @"
UPDATE Materials
SET
Name=@Name,
UseCount=@UseCount,
CountInWareHouse=@CountInWareHouse
WHERE Id=@Id";
connection.Execute(queryUpdate, material);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteMaterial(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Materials
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Material> ReadMaterials()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = "SELECT * FROM Materials";
var materials = connection.Query<Material>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(materials));
return materials;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Material ReadMaterialById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Materials
WHERE Id=@id";
var material = connection.QueryFirst<Material>(querySelect, new
{
id
});
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(material));
return material;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
}

View File

@ -0,0 +1,95 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectAtelier.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Repositories.Implementations;
public class OrderRepository : IOrderRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<ProductRepository> _logger;
public OrderRepository(IConnectionString connectionString, ILogger<ProductRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateOrder(Order order)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(order));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); ///Создается объект NpgsqlConnection с использованием строки подключения из _connectionString.
connection.Open(); ////открытие соединения
using var transaction = connection.BeginTransaction(); ///начинаем транзакцию
///Выполнение запросов в рамках транзакции:
var queryInsert = @"
INSERT INTO Orders (DataTime, Status, Characteristic, IdClient)
VALUES (@DataTime, @Status, @Characteristic, @IdClient);
SELECT MAX(Id) FROM Orders";
var orderId = connection.QueryFirst<int>(queryInsert, order, transaction);
var querySubInsert = @"
INSERT INTO Order_Products (OrderId, ProductId, Count)
VALUES (@OrderId, @ProductId, @Count)";
foreach (var elem in order.OrderProduct)
{
connection.Execute(querySubInsert, new
{
orderId,
elem.ProductId,
elem.Count
}, transaction);///добавляем в транзакцию зпросы
}
transaction.Commit(); ///Если все запросы выполнены успешно, транзакция фиксируется с помощью метода
}
catch (Exception ex)/// исключение логируется.
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteOrder(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Orders
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Order> ReadOrders(DateTime? dateForm = null, DateTime? dateTo = null, int? orderStatus = null, int? orderId = null)
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"SELECT * FROM Orders";
var order = connection.Query<Order>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(order));
return order;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,25 @@
using ProjectAtelier.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Repositories.Implementations;
public class ProductMaterialRepository : IProductMaterialRepository
{
public void CreateMaterialConsumption(ProductMaterial materialConsumption)
{
}
public IEnumerable<ProductMaterial> ReadMaterialsConsumption()
{
return [];
}
public ProductMaterial ReadMaterialConsumptionById(int id)
{
return ProductMaterial.CreateOperation(id, 0, 0);
}
}

View File

@ -0,0 +1,169 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectAtelier.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectAtelier.Repositories.Implementations;
public class ProductRepository : IProductRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<ProductRepository> _logger;
public ProductRepository(IConnectionString connectionString, ILogger<ProductRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateProduct(Product product)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(product));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryInsert = @"
INSERT INTO Products (Name, View, CountMaterial)
VALUES (@Name, @View, @CountMaterial);
SELECT MAX(Id) FROM Products";
var productId = connection.QueryFirst<int>(queryInsert, product, transaction);
var querySubInsert = @"
INSERT INTO Product_Materials (ProductId, MaterialId, Count)
VALUES (@ProductId, @MaterialId, @Count)";
foreach (var elem in product.ProductMaterial)
{
connection.Execute(querySubInsert, new
{
productId,
elem.MaterialId,
elem.Count
}, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteProduct(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryDelete = @"
DELETE FROM Products
WHERE Id=@id";
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Product> ReadProducts()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"SELECT * FROM Products";
var product = connection.Query<Product>(querySelect);
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(product));
return product;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Product ReadProductById(int id)
{
_logger.LogInformation("Получение объекта по ID: {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @"
SELECT * FROM Products WHERE Id = @Id;
SELECT m.*, pm.Count FROM Materials m
JOIN Product_Materials pm ON m.Id = pm.MaterialId
WHERE pm.ProductId = @Id";
using var multi = connection.QueryMultiple(querySelect, new { Id = id });
var product = multi.Read<Product>().FirstOrDefault();
if (product != null)
{
var materials = multi.Read<Material>().ToList();
product.ProductMaterial = materials.Select(m => new ProductMaterial
{
MaterialId = m.Id,
Count = m.UseCount // Исправлено здесь
}).ToList();
}
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(product));
return product;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объекта по ID: {id}", id);
throw;
}
}
public void UpdateProduct(Product product)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(product));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryUpdate = @"
UPDATE Products
SET Name = @Name, View = @View, CountMaterial = @CountMaterial
WHERE Id = @Id";
connection.Execute(queryUpdate, product, transaction);
var queryDelete = @"
DELETE FROM Product_Materials
WHERE ProductId = @ProductId";
connection.Execute(queryDelete, new { ProductId = product.Id }, transaction);
var querySubInsert = @"
INSERT INTO Product_Materials (ProductId, MaterialId, Count)
VALUES (@ProductId, @MaterialId, @Count)";
foreach (var elem in product.ProductMaterial)
{
connection.Execute(querySubInsert, new
{
ProductId = product.Id,
elem.MaterialId,
elem.Count
}, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -0,0 +1,15 @@
{
"Serilog": {
"Using": [ "Serilog.Sinks.File" ],
"MinimumLevel": "Debug",
"WriteTo": [
{
"Name": "File",
"Args": {
"path": "Logs.txt",
"rollingInterval": "Day"
}
}
]
}
}