PIbd-21_Andrianova_E.N._CompShop_LabWork01 #1
@ -8,4 +8,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
21
CompShop/CompShop/Entites/Check.cs
Normal file
21
CompShop/CompShop/Entites/Check.cs
Normal file
@ -0,0 +1,21 @@
|
||||
namespace CompShop.Entites
|
||||
{
|
||||
public class Check
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public List<ProductInCheck> Products { get; set; }
|
||||
public Client Client { get; set; }
|
||||
public DateTime PurchaseDate { get; set; }
|
||||
|
||||
public static Check CreateEntity(int id, List<ProductInCheck> products, Client client, DateTime purchaseDate)
|
||||
{
|
||||
return new Check
|
||||
{
|
||||
Id = id,
|
||||
Products = products,
|
||||
Client = client,
|
||||
PurchaseDate = purchaseDate
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
22
CompShop/CompShop/Entites/Client.cs
Normal file
22
CompShop/CompShop/Entites/Client.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using CompShop.Entites.Enums;
|
||||
namespace CompShop.Entites
|
||||
{
|
||||
public class Client
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string PhoneNumber { get; set; }
|
||||
public ClientType ClientType { get; set; }
|
||||
|
||||
public static Client CreateEntity(int id, string name, string phoneNumber, ClientType clientType)
|
||||
{
|
||||
return new Client
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
PhoneNumber = phoneNumber,
|
||||
ClientType = clientType
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
9
CompShop/CompShop/Entites/Enums/ClientType.cs
Normal file
9
CompShop/CompShop/Entites/Enums/ClientType.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace CompShop.Entites.Enums
|
||||
{
|
||||
public enum ClientType
|
||||
{
|
||||
None = 0,
|
||||
Individual = 1,
|
||||
Business = 2
|
||||
}
|
||||
}
|
17
CompShop/CompShop/Entites/Enums/ProductType.cs
Normal file
17
CompShop/CompShop/Entites/Enums/ProductType.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace CompShop.Entites.Enums
|
||||
{
|
||||
[Flags]
|
||||
public enum ProductType
|
||||
{
|
||||
None = 0,
|
||||
Laptop = 1,
|
||||
Desktop = 2, // Настольный компьютер
|
||||
Monitor = 4, // Монитор
|
||||
Keyboard = 8, // Клавиатура
|
||||
Mouse = 16, // Мышь
|
||||
Headset = 32, // Наушники
|
||||
Webcam = 64, // Веб-камера
|
||||
Printer = 128, // Принтер
|
||||
Software = 256 // Программное обеспечение
|
||||
}
|
||||
}
|
22
CompShop/CompShop/Entites/Product.cs
Normal file
22
CompShop/CompShop/Entites/Product.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using CompShop.Entites.Enums;
|
||||
|
||||
namespace CompShop.Entites
|
||||
{
|
||||
public class Product
|
||||
{
|
||||
public int ID { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public decimal Price { get; private set; }
|
||||
public ProductType ProductType { get; private set; }
|
||||
|
||||
public static Product CreateEntity(int id, string name, string desc, decimal price, ProductType productType)
|
||||
{
|
||||
return new Product { ID = id,
|
||||
Name = name ?? string.Empty,
|
||||
Description = desc ?? string.Empty,
|
||||
Price = price,
|
||||
ProductType = productType };
|
||||
}
|
||||
}
|
||||
}
|
12
CompShop/CompShop/Entites/ProductInCheck.cs
Normal file
12
CompShop/CompShop/Entites/ProductInCheck.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace CompShop.Entites
|
||||
{
|
||||
public class ProductInCheck
|
||||
{
|
||||
public int ID { get; set; }
|
||||
public int Count { get; set; }
|
||||
public static ProductInCheck CreateElement(int id, int count)
|
||||
{
|
||||
return new ProductInCheck { ID = id, Count = count};
|
||||
}
|
||||
}
|
||||
}
|
15
CompShop/CompShop/Entites/ProductsOnStorage.cs
Normal file
15
CompShop/CompShop/Entites/ProductsOnStorage.cs
Normal file
@ -0,0 +1,15 @@
|
||||
namespace CompShop.Entites
|
||||
{
|
||||
public class ProductsOnStorage
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public Product Product { get; set; }
|
||||
public Storage Storage { get; set; }
|
||||
public int Count { get; set; }
|
||||
|
||||
public static ProductsOnStorage CreateEntity(int id, Product product, Storage storage, int count)
|
||||
{
|
||||
return new ProductsOnStorage { Storage = storage, Id = id, Product = product, Count = count };
|
||||
}
|
||||
}
|
||||
}
|
14
CompShop/CompShop/Entites/Storage.cs
Normal file
14
CompShop/CompShop/Entites/Storage.cs
Normal file
@ -0,0 +1,14 @@
|
||||
namespace CompShop.Entites
|
||||
{
|
||||
public class Storage
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int Size { get; set; } // Вместимость
|
||||
public string Adress { get; set; }
|
||||
|
||||
public static Storage CreateEntity(int id, int size, string adress)
|
||||
{
|
||||
return new Storage { Id = id, Size = size, Adress = adress };
|
||||
}
|
||||
}
|
||||
}
|
39
CompShop/CompShop/Form1.Designer.cs
generated
39
CompShop/CompShop/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace CompShop
|
||||
{
|
||||
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
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace CompShop
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
<?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>
|
103
CompShop/CompShop/Forms/Clients/ClientForm.Designer.cs
generated
Normal file
103
CompShop/CompShop/Forms/Clients/ClientForm.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
namespace CompShop.Forms
|
||||
{
|
||||
partial class ClientForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
deleteButton = new Button();
|
||||
editButton = new Button();
|
||||
addButton = new Button();
|
||||
productsDataGridView = new DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)productsDataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// deleteButton
|
||||
//
|
||||
deleteButton.Location = new Point(869, 144);
|
||||
deleteButton.Name = "deleteButton";
|
||||
deleteButton.Size = new Size(161, 60);
|
||||
deleteButton.TabIndex = 7;
|
||||
deleteButton.Text = "Удалить";
|
||||
deleteButton.UseVisualStyleBackColor = true;
|
||||
deleteButton.Click += deleteButton_Click;
|
||||
//
|
||||
// editButton
|
||||
//
|
||||
editButton.Location = new Point(869, 78);
|
||||
editButton.Name = "editButton";
|
||||
editButton.Size = new Size(161, 60);
|
||||
editButton.TabIndex = 6;
|
||||
editButton.Text = "Редактировать";
|
||||
editButton.UseVisualStyleBackColor = true;
|
||||
editButton.Click += editButton_Click;
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
addButton.BackColor = SystemColors.Control;
|
||||
addButton.Location = new Point(869, 12);
|
||||
addButton.Name = "addButton";
|
||||
addButton.Size = new Size(161, 60);
|
||||
addButton.TabIndex = 5;
|
||||
addButton.Text = "Добавить";
|
||||
addButton.UseVisualStyleBackColor = false;
|
||||
addButton.Click += addButton_Click;
|
||||
//
|
||||
// productsDataGridView
|
||||
//
|
||||
productsDataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
productsDataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
productsDataGridView.Location = new Point(12, 12);
|
||||
productsDataGridView.Name = "productsDataGridView";
|
||||
productsDataGridView.RowHeadersWidth = 51;
|
||||
productsDataGridView.RowTemplate.Height = 29;
|
||||
productsDataGridView.Size = new Size(851, 400);
|
||||
productsDataGridView.TabIndex = 4;
|
||||
//
|
||||
// ClientForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1056, 424);
|
||||
Controls.Add(deleteButton);
|
||||
Controls.Add(editButton);
|
||||
Controls.Add(addButton);
|
||||
Controls.Add(productsDataGridView);
|
||||
Name = "ClientForm";
|
||||
Text = "Клиенты";
|
||||
Load += ClientForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)productsDataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button deleteButton;
|
||||
private Button editButton;
|
||||
private Button addButton;
|
||||
private DataGridView productsDataGridView;
|
||||
}
|
||||
}
|
102
CompShop/CompShop/Forms/Clients/ClientForm.cs
Normal file
102
CompShop/CompShop/Forms/Clients/ClientForm.cs
Normal file
@ -0,0 +1,102 @@
|
||||
using CompShop.Forms.Clients;
|
||||
using CompShop.Repos;
|
||||
using Unity;
|
||||
|
||||
namespace CompShop.Forms
|
||||
{
|
||||
public partial class ClientForm : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IClientRepository _repository;
|
||||
|
||||
public ClientForm(IUnityContainer unityContainer, IClientRepository clientRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_container = unityContainer ?? throw new ArgumentNullException(nameof(unityContainer));
|
||||
_repository = clientRepository ?? throw new ArgumentNullException(nameof(_repository));
|
||||
}
|
||||
|
||||
private void ClientForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => productsDataGridView.DataSource = _repository.ReadAll();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (productsDataGridView.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
id = Convert.ToInt32(productsDataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<ClientFormSettings>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void editButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<ClientFormSettings>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_repository.Delete(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
CompShop/CompShop/Forms/Clients/ClientForm.resx
Normal file
60
CompShop/CompShop/Forms/Clients/ClientForm.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
132
CompShop/CompShop/Forms/Clients/ClientFormSettings.Designer.cs
generated
Normal file
132
CompShop/CompShop/Forms/Clients/ClientFormSettings.Designer.cs
generated
Normal file
@ -0,0 +1,132 @@
|
||||
namespace CompShop.Forms.Clients
|
||||
{
|
||||
partial class ClientFormSettings
|
||||
{
|
||||
/// <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();
|
||||
label1 = new Label();
|
||||
nameTextbox = new TextBox();
|
||||
saveButton = new Button();
|
||||
phoneNumberTextbox = new TextBox();
|
||||
typeCombobox = new ComboBox();
|
||||
label4 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(13, 59);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(130, 20);
|
||||
label2.TabIndex = 13;
|
||||
label2.Text = "Номер телефона:";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(13, 12);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(122, 20);
|
||||
label1.TabIndex = 11;
|
||||
label1.Text = "Имя покупателя";
|
||||
//
|
||||
// nameTextbox
|
||||
//
|
||||
nameTextbox.Location = new Point(153, 12);
|
||||
nameTextbox.Name = "nameTextbox";
|
||||
nameTextbox.Size = new Size(210, 27);
|
||||
nameTextbox.TabIndex = 10;
|
||||
//
|
||||
// saveButton
|
||||
//
|
||||
saveButton.Anchor = AnchorStyles.Bottom;
|
||||
saveButton.Location = new Point(153, 229);
|
||||
saveButton.Name = "saveButton";
|
||||
saveButton.Size = new Size(94, 29);
|
||||
saveButton.TabIndex = 9;
|
||||
saveButton.Text = "Сохранить";
|
||||
saveButton.UseVisualStyleBackColor = true;
|
||||
saveButton.Click += saveButton_Click;
|
||||
//
|
||||
// phoneNumberTextbox
|
||||
//
|
||||
phoneNumberTextbox.Location = new Point(153, 59);
|
||||
phoneNumberTextbox.Name = "phoneNumberTextbox";
|
||||
phoneNumberTextbox.Size = new Size(210, 27);
|
||||
phoneNumberTextbox.TabIndex = 18;
|
||||
//
|
||||
// typeCombobox
|
||||
//
|
||||
typeCombobox.FormattingEnabled = true;
|
||||
typeCombobox.Location = new Point(153, 101);
|
||||
typeCombobox.Name = "typeCombobox";
|
||||
typeCombobox.Size = new Size(151, 28);
|
||||
typeCombobox.TabIndex = 20;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(13, 104);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(38, 20);
|
||||
label4.TabIndex = 19;
|
||||
label4.Text = "Вид:";
|
||||
//
|
||||
// ClientFormSettings
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(388, 270);
|
||||
Controls.Add(typeCombobox);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(phoneNumberTextbox);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(nameTextbox);
|
||||
Controls.Add(saveButton);
|
||||
Name = "ClientFormSettings";
|
||||
Text = "Регистрация клиента";
|
||||
Load += ClientFormSettings_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox typeCombobox;
|
||||
private Label label4;
|
||||
private Label label3;
|
||||
private NumericUpDown priceNumeric;
|
||||
private Label label2;
|
||||
private TextBox descriptionTextbox;
|
||||
private Label label1;
|
||||
private TextBox nameTextbox;
|
||||
private Button saveButton;
|
||||
private TextBox phoneNumberTextbox;
|
||||
}
|
||||
}
|
87
CompShop/CompShop/Forms/Clients/ClientFormSettings.cs
Normal file
87
CompShop/CompShop/Forms/Clients/ClientFormSettings.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using CompShop.Entites.Enums;
|
||||
using CompShop.Entites;
|
||||
using CompShop.Repos;
|
||||
|
||||
namespace CompShop.Forms.Clients
|
||||
{
|
||||
public partial class ClientFormSettings : Form
|
||||
{
|
||||
private readonly IClientRepository _repository;
|
||||
|
||||
private int? _clientId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = _repository.Read(value);
|
||||
if (client != null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(client));
|
||||
}
|
||||
nameTextbox.Text = client.Name;
|
||||
phoneNumberTextbox.Text = client.PhoneNumber;
|
||||
typeCombobox.SelectedItem = client.ClientType;
|
||||
|
||||
_clientId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ClientFormSettings(IClientRepository clientRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_repository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
|
||||
typeCombobox.DataSource = Enum.GetValues(typeof(ClientType));
|
||||
|
||||
}
|
||||
|
||||
private void ClientFormSettings_Load(object sender, EventArgs e)
|
||||
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void saveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(nameTextbox.Text) ||
|
||||
string.IsNullOrWhiteSpace(phoneNumberTextbox.Text) || typeCombobox.SelectedIndex < 1
|
||||
|| typeCombobox.SelectedIndex < 1)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
if (_clientId.HasValue)
|
||||
{
|
||||
|
||||
_repository.Update(CreateClient(_clientId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
_repository.Update(CreateClient(0));
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private Client CreateClient(int id)
|
||||
{
|
||||
return Client.CreateEntity(id, nameTextbox.Text, phoneNumberTextbox.Text, (ClientType)typeCombobox.SelectedValue);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
60
CompShop/CompShop/Forms/Clients/ClientFormSettings.resx
Normal file
60
CompShop/CompShop/Forms/Clients/ClientFormSettings.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
130
CompShop/CompShop/Forms/Form1.Designer.cs
generated
Normal file
130
CompShop/CompShop/Forms/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,130 @@
|
||||
namespace CompShop
|
||||
{
|
||||
partial class ShopForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ShopForm));
|
||||
menuStrip1 = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
товарыToolStripMenuItem = new ToolStripMenuItem();
|
||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
складыToolStripMenuItem = new ToolStripMenuItem();
|
||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||
товарыНаСкаледToolStripMenuItem = new ToolStripMenuItem();
|
||||
чекиToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(800, 28);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { товарыToolStripMenuItem, клиентыToolStripMenuItem, складыToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(126, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники...";
|
||||
//
|
||||
// товарыToolStripMenuItem
|
||||
//
|
||||
товарыToolStripMenuItem.Name = "товарыToolStripMenuItem";
|
||||
товарыToolStripMenuItem.Size = new Size(152, 26);
|
||||
товарыToolStripMenuItem.Text = "Товары";
|
||||
товарыToolStripMenuItem.Click += товарыToolStripMenuItem_Click;
|
||||
//
|
||||
// клиентыToolStripMenuItem
|
||||
//
|
||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||
клиентыToolStripMenuItem.Size = new Size(152, 26);
|
||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
||||
//
|
||||
// складыToolStripMenuItem
|
||||
//
|
||||
складыToolStripMenuItem.Name = "складыToolStripMenuItem";
|
||||
складыToolStripMenuItem.Size = new Size(152, 26);
|
||||
складыToolStripMenuItem.Text = "Склады";
|
||||
складыToolStripMenuItem.Click += складыToolStripMenuItem_Click;
|
||||
//
|
||||
// операцииToolStripMenuItem
|
||||
//
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { товарыНаСкаледToolStripMenuItem, чекиToolStripMenuItem });
|
||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||
операцииToolStripMenuItem.Size = new Size(104, 24);
|
||||
операцииToolStripMenuItem.Text = "Операции...";
|
||||
//
|
||||
// товарыНаСкаледToolStripMenuItem
|
||||
//
|
||||
товарыНаСкаледToolStripMenuItem.Name = "товарыНаСкаледToolStripMenuItem";
|
||||
товарыНаСкаледToolStripMenuItem.Size = new Size(224, 26);
|
||||
товарыНаСкаледToolStripMenuItem.Text = "Товары на складе";
|
||||
товарыНаСкаледToolStripMenuItem.Click += товарыНаСкаледToolStripMenuItem_Click;
|
||||
//
|
||||
// чекиToolStripMenuItem
|
||||
//
|
||||
чекиToolStripMenuItem.Name = "чекиToolStripMenuItem";
|
||||
чекиToolStripMenuItem.Size = new Size(224, 26);
|
||||
чекиToolStripMenuItem.Text = "Чеки...";
|
||||
чекиToolStripMenuItem.Click += чекиToolStripMenuItem_Click;
|
||||
//
|
||||
// ShopForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackgroundImage = (Image)resources.GetObject("$this.BackgroundImage");
|
||||
BackgroundImageLayout = ImageLayout.Stretch;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "ShopForm";
|
||||
Text = "Магазин электроники";
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem товарыToolStripMenuItem;
|
||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||
private ToolStripMenuItem складыToolStripMenuItem;
|
||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||
private ToolStripMenuItem товарыНаСкаледToolStripMenuItem;
|
||||
private ToolStripMenuItem чекиToolStripMenuItem;
|
||||
}
|
||||
}
|
48
CompShop/CompShop/Forms/Form1.cs
Normal file
48
CompShop/CompShop/Forms/Form1.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using CompShop.Forms;
|
||||
using CompShop.Forms.ProductsOnStorage;
|
||||
using CompShop.Forms.Receipt;
|
||||
using CompShop.Forms.Storage;
|
||||
using Unity;
|
||||
|
||||
namespace CompShop
|
||||
{
|
||||
public partial class ShopForm : Form
|
||||
eegov
commented
Имя файла не соответствует имени элемента проекта Имя файла не соответствует имени элемента проекта
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
public ShopForm(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
private void òîâàðûToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_container.Resolve<ProductForm>().ShowDialog();
|
||||
}
|
||||
|
||||
private void êëèåíòûToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_container.Resolve<ClientForm>().ShowDialog();
|
||||
}
|
||||
|
||||
private void ñêëàäûToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_container.Resolve<StorageForm>().ShowDialog();
|
||||
|
||||
}
|
||||
|
||||
private void òîâàðûÍàÑêàëåäToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_container.Resolve<ProductsOnStorageForm>().ShowDialog();
|
||||
|
||||
}
|
||||
|
||||
private void ÷åêèToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
_container.Resolve<CheckForm>().ShowDialog();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
1758
CompShop/CompShop/Forms/Form1.resx
Normal file
1758
CompShop/CompShop/Forms/Form1.resx
Normal file
File diff suppressed because it is too large
Load Diff
103
CompShop/CompShop/Forms/Products/ProductForm.Designer.cs
generated
Normal file
103
CompShop/CompShop/Forms/Products/ProductForm.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
namespace CompShop
|
||||
{
|
||||
partial class ProductForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
productsDataGridView = new DataGridView();
|
||||
addButton = new Button();
|
||||
editButton = new Button();
|
||||
deleteButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)productsDataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// productsDataGridView
|
||||
//
|
||||
productsDataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
productsDataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
productsDataGridView.Location = new Point(12, 12);
|
||||
productsDataGridView.Name = "productsDataGridView";
|
||||
productsDataGridView.RowHeadersWidth = 51;
|
||||
productsDataGridView.RowTemplate.Height = 29;
|
||||
productsDataGridView.Size = new Size(851, 399);
|
||||
productsDataGridView.TabIndex = 0;
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
addButton.BackColor = SystemColors.Control;
|
||||
addButton.Location = new Point(878, 12);
|
||||
addButton.Name = "addButton";
|
||||
addButton.Size = new Size(161, 60);
|
||||
addButton.TabIndex = 1;
|
||||
addButton.Text = "Добавить";
|
||||
addButton.UseVisualStyleBackColor = false;
|
||||
addButton.Click += addButton_Click;
|
||||
//
|
||||
// editButton
|
||||
//
|
||||
editButton.Location = new Point(878, 87);
|
||||
editButton.Name = "editButton";
|
||||
editButton.Size = new Size(161, 60);
|
||||
editButton.TabIndex = 2;
|
||||
editButton.Text = "Редактировать";
|
||||
editButton.UseVisualStyleBackColor = true;
|
||||
editButton.Click += editButton_Click;
|
||||
//
|
||||
// deleteButton
|
||||
//
|
||||
deleteButton.Location = new Point(878, 163);
|
||||
deleteButton.Name = "deleteButton";
|
||||
deleteButton.Size = new Size(161, 60);
|
||||
deleteButton.TabIndex = 3;
|
||||
deleteButton.Text = "Удалить";
|
||||
deleteButton.UseVisualStyleBackColor = true;
|
||||
deleteButton.Click += deleteButton_Click;
|
||||
//
|
||||
// ProductForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1051, 423);
|
||||
Controls.Add(deleteButton);
|
||||
Controls.Add(editButton);
|
||||
Controls.Add(addButton);
|
||||
Controls.Add(productsDataGridView);
|
||||
Name = "ProductForm";
|
||||
Text = "Товары";
|
||||
Load += ProductForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)productsDataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView productsDataGridView;
|
||||
private Button addButton;
|
||||
private Button editButton;
|
||||
private Button deleteButton;
|
||||
}
|
||||
}
|
101
CompShop/CompShop/Forms/Products/ProductForm.cs
Normal file
101
CompShop/CompShop/Forms/Products/ProductForm.cs
Normal file
@ -0,0 +1,101 @@
|
||||
using CompShop.Repos;
|
||||
using Unity;
|
||||
|
||||
namespace CompShop
|
||||
{
|
||||
public partial class ProductForm : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IProductRepository _productRepository;
|
||||
|
||||
public ProductForm(IUnityContainer unityContainer, IProductRepository productRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_container = unityContainer ?? throw new ArgumentNullException(nameof(unityContainer));
|
||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(_productRepository));
|
||||
}
|
||||
|
||||
private void ProductForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => productsDataGridView.DataSource = _productRepository.ReadAll();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (productsDataGridView.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
id = Convert.ToInt32(productsDataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<ProductSettingsForm>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void editButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<ProductSettingsForm>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_productRepository.Delete(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
CompShop/CompShop/Forms/Products/ProductForm.resx
Normal file
60
CompShop/CompShop/Forms/Products/ProductForm.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
156
CompShop/CompShop/Forms/Products/ProductSettingsForm.Designer.cs
generated
Normal file
156
CompShop/CompShop/Forms/Products/ProductSettingsForm.Designer.cs
generated
Normal file
@ -0,0 +1,156 @@
|
||||
namespace CompShop
|
||||
{
|
||||
partial class ProductSettingsForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
saveButton = new Button();
|
||||
productNameTextbox = new TextBox();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
descriptionTextbox = new TextBox();
|
||||
priceNumeric = new NumericUpDown();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
typeCheckedListBox = new CheckedListBox();
|
||||
((System.ComponentModel.ISupportInitialize)priceNumeric).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// saveButton
|
||||
//
|
||||
saveButton.Anchor = AnchorStyles.Bottom;
|
||||
saveButton.Location = new Point(157, 436);
|
||||
saveButton.Name = "saveButton";
|
||||
saveButton.Size = new Size(94, 29);
|
||||
saveButton.TabIndex = 0;
|
||||
saveButton.Text = "Сохранить";
|
||||
saveButton.UseVisualStyleBackColor = true;
|
||||
saveButton.Click += saveButton_Click;
|
||||
//
|
||||
// productNameTextbox
|
||||
//
|
||||
productNameTextbox.Location = new Point(152, 36);
|
||||
productNameTextbox.Name = "productNameTextbox";
|
||||
productNameTextbox.Size = new Size(210, 27);
|
||||
productNameTextbox.TabIndex = 1;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 36);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(94, 20);
|
||||
label1.TabIndex = 2;
|
||||
label1.Text = "Имя товара:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 83);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(134, 20);
|
||||
label2.TabIndex = 4;
|
||||
label2.Text = "Описание товара:";
|
||||
//
|
||||
// descriptionTextbox
|
||||
//
|
||||
descriptionTextbox.Location = new Point(152, 83);
|
||||
descriptionTextbox.Multiline = true;
|
||||
descriptionTextbox.Name = "descriptionTextbox";
|
||||
descriptionTextbox.Size = new Size(210, 132);
|
||||
descriptionTextbox.TabIndex = 3;
|
||||
//
|
||||
// priceNumeric
|
||||
//
|
||||
priceNumeric.DecimalPlaces = 2;
|
||||
priceNumeric.Location = new Point(152, 233);
|
||||
priceNumeric.Name = "priceNumeric";
|
||||
priceNumeric.Size = new Size(99, 27);
|
||||
priceNumeric.TabIndex = 5;
|
||||
priceNumeric.ThousandsSeparator = true;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(12, 235);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(48, 20);
|
||||
label3.TabIndex = 6;
|
||||
label3.Text = "Цена:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(12, 285);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(38, 20);
|
||||
label4.TabIndex = 7;
|
||||
label4.Text = "Вид:";
|
||||
//
|
||||
// typeCheckedListBox
|
||||
//
|
||||
typeCheckedListBox.FormattingEnabled = true;
|
||||
typeCheckedListBox.Location = new Point(152, 285);
|
||||
typeCheckedListBox.Name = "typeCheckedListBox";
|
||||
typeCheckedListBox.Size = new Size(150, 114);
|
||||
typeCheckedListBox.TabIndex = 8;
|
||||
//
|
||||
// ProductSettingsForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(409, 477);
|
||||
Controls.Add(typeCheckedListBox);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(priceNumeric);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(descriptionTextbox);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(productNameTextbox);
|
||||
Controls.Add(saveButton);
|
||||
Name = "ProductSettingsForm";
|
||||
Text = "Настройка товара...";
|
||||
Load += ProductSettingsForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)priceNumeric).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button saveButton;
|
||||
private TextBox productNameTextbox;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private TextBox descriptionTextbox;
|
||||
private NumericUpDown priceNumeric;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private CheckedListBox typeCheckedListBox;
|
||||
}
|
||||
}
|
104
CompShop/CompShop/Forms/Products/ProductSettingsForm.cs
Normal file
104
CompShop/CompShop/Forms/Products/ProductSettingsForm.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using CompShop.Entites;
|
||||
using CompShop.Entites.Enums;
|
||||
using CompShop.Repos;
|
||||
|
||||
namespace CompShop
|
||||
{
|
||||
public partial class ProductSettingsForm : Form
|
||||
{
|
||||
private readonly IProductRepository _productRepository;
|
||||
|
||||
private int? _productId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var product = _productRepository.Read(value);
|
||||
if (product != null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(product));
|
||||
}
|
||||
productNameTextbox.Text = product.Name;
|
||||
descriptionTextbox.Text = product.Description;
|
||||
foreach (ProductType elem in Enum.GetValues(typeof(ProductType)))
|
||||
{
|
||||
if ((elem & product.ProductType) != 0)
|
||||
{
|
||||
|
||||
typeCheckedListBox.SetItemChecked(typeCheckedListBox.Items.IndexOf(elem), true);
|
||||
}
|
||||
}
|
||||
priceNumeric.Value = product.Price;
|
||||
_productId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ProductSettingsForm(IProductRepository productRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
||||
|
||||
|
||||
foreach (var elem in Enum.GetValues(typeof(ProductType)))
|
||||
{
|
||||
typeCheckedListBox.Items.Add(elem);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ProductSettingsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void saveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(productNameTextbox.Text) ||
|
||||
string.IsNullOrWhiteSpace(descriptionTextbox.Text) || typeCheckedListBox.CheckedItems.Count == 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
if (_productId.HasValue)
|
||||
{
|
||||
|
||||
_productRepository.Update(CreateProduct(_productId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
_productRepository.Create(CreateProduct(0));
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private Product CreateProduct(int id)
|
||||
{
|
||||
ProductType type = ProductType.None;
|
||||
foreach (var elem in typeCheckedListBox.CheckedItems)
|
||||
{
|
||||
type |= (ProductType)elem;
|
||||
}
|
||||
|
||||
return Product.CreateEntity(id, productNameTextbox.Text, descriptionTextbox.Text, priceNumeric.Value, type);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
60
CompShop/CompShop/Forms/Products/ProductSettingsForm.resx
Normal file
60
CompShop/CompShop/Forms/Products/ProductSettingsForm.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
90
CompShop/CompShop/Forms/ProductsOnStorage/ProductsOnStorageForm.Designer.cs
generated
Normal file
90
CompShop/CompShop/Forms/ProductsOnStorage/ProductsOnStorageForm.Designer.cs
generated
Normal file
@ -0,0 +1,90 @@
|
||||
namespace CompShop.Forms.ProductsOnStorage
|
||||
{
|
||||
partial class ProductsOnStorageForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
addButton = new Button();
|
||||
productsDataGridView = new DataGridView();
|
||||
editButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)productsDataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
addButton.BackColor = SystemColors.Control;
|
||||
addButton.Location = new Point(881, 12);
|
||||
addButton.Name = "addButton";
|
||||
addButton.Size = new Size(161, 60);
|
||||
addButton.TabIndex = 9;
|
||||
addButton.Text = "Добавить";
|
||||
addButton.UseVisualStyleBackColor = false;
|
||||
addButton.Click += addButton_Click;
|
||||
//
|
||||
// productsDataGridView
|
||||
//
|
||||
productsDataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
productsDataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
productsDataGridView.Location = new Point(12, 12);
|
||||
productsDataGridView.Name = "productsDataGridView";
|
||||
productsDataGridView.RowHeadersWidth = 51;
|
||||
productsDataGridView.RowTemplate.Height = 29;
|
||||
productsDataGridView.Size = new Size(851, 400);
|
||||
productsDataGridView.TabIndex = 8;
|
||||
//
|
||||
// editButton
|
||||
//
|
||||
editButton.Location = new Point(881, 78);
|
||||
editButton.Name = "editButton";
|
||||
editButton.Size = new Size(161, 60);
|
||||
editButton.TabIndex = 10;
|
||||
editButton.Text = "Редактировать";
|
||||
editButton.UseVisualStyleBackColor = true;
|
||||
editButton.Click += editButton_Click;
|
||||
//
|
||||
// ProductsOnStorageForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1064, 450);
|
||||
Controls.Add(editButton);
|
||||
Controls.Add(addButton);
|
||||
Controls.Add(productsDataGridView);
|
||||
Name = "ProductsOnStorageForm";
|
||||
Text = "Товары на складе";
|
||||
Load += ProductsOnStorage_Load;
|
||||
((System.ComponentModel.ISupportInitialize)productsDataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button addButton;
|
||||
private DataGridView productsDataGridView;
|
||||
private Button editButton;
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
using CompShop.Repos;
|
||||
using Unity;
|
||||
|
||||
namespace CompShop.Forms.ProductsOnStorage
|
||||
{
|
||||
public partial class ProductsOnStorageForm : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IProductOnStorageRepository _productOnStorageRepository;
|
||||
|
||||
public ProductsOnStorageForm(IUnityContainer unityContainer, IProductOnStorageRepository productOnStorageRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_container = unityContainer ?? throw new ArgumentNullException(nameof(unityContainer));
|
||||
_productOnStorageRepository = productOnStorageRepository ?? throw new ArgumentNullException(nameof(productOnStorageRepository));
|
||||
}
|
||||
|
||||
private void ProductsOnStorage_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => productsDataGridView.DataSource = _productOnStorageRepository.ReadAll();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (productsDataGridView.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
id = Convert.ToInt32(productsDataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<ProductsOnStorageSettingsForm>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void editButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<ProductsOnStorageSettingsForm>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
133
CompShop/CompShop/Forms/ProductsOnStorage/ProductsOnStorageSettingsForm.Designer.cs
generated
Normal file
133
CompShop/CompShop/Forms/ProductsOnStorage/ProductsOnStorageSettingsForm.Designer.cs
generated
Normal file
@ -0,0 +1,133 @@
|
||||
namespace CompShop.Forms.ProductsOnStorage
|
||||
{
|
||||
partial class ProductsOnStorageSettingsForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
productCombobox = new ComboBox();
|
||||
label4 = new Label();
|
||||
label3 = new Label();
|
||||
countNumeric = new NumericUpDown();
|
||||
storageCombobox = new ComboBox();
|
||||
label1 = new Label();
|
||||
saveButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)countNumeric).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// productCombobox
|
||||
//
|
||||
productCombobox.FormattingEnabled = true;
|
||||
productCombobox.Location = new Point(155, 12);
|
||||
productCombobox.Name = "productCombobox";
|
||||
productCombobox.Size = new Size(151, 28);
|
||||
productCombobox.TabIndex = 12;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(15, 15);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(54, 20);
|
||||
label4.TabIndex = 11;
|
||||
label4.Text = "Товар:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(15, 82);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(103, 20);
|
||||
label3.TabIndex = 10;
|
||||
label3.Text = "В количестве:";
|
||||
//
|
||||
// countNumeric
|
||||
//
|
||||
countNumeric.Location = new Point(155, 80);
|
||||
countNumeric.Name = "countNumeric";
|
||||
countNumeric.Size = new Size(99, 27);
|
||||
countNumeric.TabIndex = 9;
|
||||
countNumeric.ThousandsSeparator = true;
|
||||
//
|
||||
// storageCombobox
|
||||
//
|
||||
storageCombobox.FormattingEnabled = true;
|
||||
storageCombobox.Location = new Point(155, 46);
|
||||
storageCombobox.Name = "storageCombobox";
|
||||
storageCombobox.Size = new Size(151, 28);
|
||||
storageCombobox.TabIndex = 14;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(15, 49);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(81, 20);
|
||||
label1.TabIndex = 13;
|
||||
label1.Text = "На складе:";
|
||||
//
|
||||
// saveButton
|
||||
//
|
||||
saveButton.Anchor = AnchorStyles.Bottom;
|
||||
saveButton.Location = new Point(155, 175);
|
||||
saveButton.Name = "saveButton";
|
||||
saveButton.Size = new Size(94, 29);
|
||||
saveButton.TabIndex = 15;
|
||||
saveButton.Text = "Сохранить";
|
||||
saveButton.UseVisualStyleBackColor = true;
|
||||
saveButton.Click += saveButton_Click;
|
||||
//
|
||||
// ProductsOnStorageSettingsForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(411, 216);
|
||||
Controls.Add(saveButton);
|
||||
Controls.Add(storageCombobox);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(productCombobox);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(countNumeric);
|
||||
Name = "ProductsOnStorageSettingsForm";
|
||||
Text = "Продукт на складе...";
|
||||
Load += ProductsOnStorageSettingsForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)countNumeric).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox productCombobox;
|
||||
private Label label4;
|
||||
private Label label3;
|
||||
private NumericUpDown countNumeric;
|
||||
private ComboBox storageCombobox;
|
||||
private Label label1;
|
||||
private Button saveButton;
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
using CompShop.Entites;
|
||||
using CompShop.Repos;
|
||||
|
||||
namespace CompShop.Forms.ProductsOnStorage
|
||||
{
|
||||
public partial class ProductsOnStorageSettingsForm : Form
|
||||
{
|
||||
private readonly IProductOnStorageRepository _productOnStorageRepository;
|
||||
private readonly IProductRepository _productRepository;
|
||||
private readonly IStorageRepository _storageRepository;
|
||||
|
||||
private int? _recordId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var record = _productOnStorageRepository.Read(value);
|
||||
if (record == null)
|
||||
{
|
||||
throw new InvalidDataException("Record not found");
|
||||
}
|
||||
|
||||
productCombobox.SelectedItem = record.Product;
|
||||
storageCombobox.SelectedItem = record.Storage;
|
||||
countNumeric.Value = record.Count;
|
||||
_recordId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ProductsOnStorageSettingsForm(
|
||||
IProductOnStorageRepository productOnStorageRepository,
|
||||
IProductRepository productRepository,
|
||||
IStorageRepository storageRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_productOnStorageRepository = productOnStorageRepository ?? throw new ArgumentNullException(nameof(productOnStorageRepository));
|
||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
||||
_storageRepository = storageRepository ?? throw new ArgumentNullException(nameof(storageRepository));
|
||||
|
||||
LoadComboboxes();
|
||||
}
|
||||
private void ProductsOnStorageSettingsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
private void LoadComboboxes()
|
||||
{
|
||||
productCombobox.DataSource = _productRepository.ReadAll().ToList();
|
||||
productCombobox.DisplayMember = "Name";
|
||||
productCombobox.ValueMember = "Id";
|
||||
|
||||
storageCombobox.DataSource = _storageRepository.ReadAll().ToList();
|
||||
storageCombobox.DisplayMember = "Name";
|
||||
storageCombobox.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void saveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (productCombobox.SelectedItem == null || storageCombobox.SelectedItem == null || countNumeric.Value < 1)
|
||||
{
|
||||
throw new Exception("Заполните все поля");
|
||||
}
|
||||
|
||||
var selectedProduct = (Product)productCombobox.SelectedItem;
|
||||
var selectedStorage = (Entites.Storage)storageCombobox.SelectedItem;
|
||||
var count = (int)countNumeric.Value;
|
||||
|
||||
if (_recordId.HasValue)
|
||||
{
|
||||
_productOnStorageRepository.Update(CreateProductOnStorage(_recordId.Value, selectedProduct, selectedStorage, count));
|
||||
}
|
||||
else
|
||||
{
|
||||
_productOnStorageRepository.Create(CreateProductOnStorage(0, selectedProduct, selectedStorage, count));
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private Entites.ProductsOnStorage CreateProductOnStorage(int id, Product product, Entites.Storage storage, int count)
|
||||
{
|
||||
return Entites.ProductsOnStorage.CreateEntity(id, product, storage, count);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
77
CompShop/CompShop/Forms/Receipt/CheckForm.Designer.cs
generated
Normal file
77
CompShop/CompShop/Forms/Receipt/CheckForm.Designer.cs
generated
Normal file
@ -0,0 +1,77 @@
|
||||
namespace CompShop.Forms.Receipt
|
||||
{
|
||||
partial class CheckForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
addButton = new Button();
|
||||
checksDataGridView = new DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)checksDataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
addButton.BackColor = SystemColors.Control;
|
||||
addButton.Location = new Point(878, 12);
|
||||
addButton.Name = "addButton";
|
||||
addButton.Size = new Size(161, 60);
|
||||
addButton.TabIndex = 3;
|
||||
addButton.Text = "Добавить";
|
||||
addButton.UseVisualStyleBackColor = false;
|
||||
addButton.Click += addButton_Click;
|
||||
//
|
||||
// checksDataGridView
|
||||
//
|
||||
checksDataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
checksDataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
checksDataGridView.Location = new Point(12, 12);
|
||||
checksDataGridView.Name = "checksDataGridView";
|
||||
checksDataGridView.RowHeadersWidth = 51;
|
||||
checksDataGridView.RowTemplate.Height = 29;
|
||||
checksDataGridView.Size = new Size(851, 399);
|
||||
checksDataGridView.TabIndex = 2;
|
||||
//
|
||||
// CheckForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1056, 450);
|
||||
Controls.Add(addButton);
|
||||
Controls.Add(checksDataGridView);
|
||||
Name = "CheckForm";
|
||||
Text = "Чеки";
|
||||
Load += CheckForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)checksDataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button addButton;
|
||||
private DataGridView checksDataGridView;
|
||||
}
|
||||
}
|
46
CompShop/CompShop/Forms/Receipt/CheckForm.cs
Normal file
46
CompShop/CompShop/Forms/Receipt/CheckForm.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using CompShop.Repos;
|
||||
using Unity;
|
||||
|
||||
namespace CompShop.Forms.Receipt
|
||||
{
|
||||
public partial class CheckForm : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly ICheckRepository _checkRepository;
|
||||
|
||||
public CheckForm(IUnityContainer unityContainer, ICheckRepository checkRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_container = unityContainer ?? throw new ArgumentNullException(nameof(unityContainer));
|
||||
_checkRepository = checkRepository ?? throw new ArgumentNullException(nameof(checkRepository));
|
||||
}
|
||||
|
||||
private void CheckForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => checksDataGridView.DataSource = _checkRepository.ReadAll();
|
||||
|
||||
private void addButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<CheckSettingsForm>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
CompShop/CompShop/Forms/Receipt/CheckForm.resx
Normal file
60
CompShop/CompShop/Forms/Receipt/CheckForm.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
134
CompShop/CompShop/Forms/Receipt/CheckSettingsForm .Designer.cs
generated
Normal file
134
CompShop/CompShop/Forms/Receipt/CheckSettingsForm .Designer.cs
generated
Normal file
@ -0,0 +1,134 @@
|
||||
namespace CompShop.Forms.Receipt
|
||||
{
|
||||
partial class CheckSettingsForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
customerComboBox = new ComboBox();
|
||||
label1 = new Label();
|
||||
saveButton = new Button();
|
||||
label4 = new Label();
|
||||
productsDataGridView = new DataGridView();
|
||||
ProductColoumn = new DataGridViewComboBoxColumn();
|
||||
ProductCount = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)productsDataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// customerComboBox
|
||||
//
|
||||
customerComboBox.FormattingEnabled = true;
|
||||
customerComboBox.Location = new Point(152, 6);
|
||||
customerComboBox.Name = "customerComboBox";
|
||||
customerComboBox.Size = new Size(151, 28);
|
||||
customerComboBox.TabIndex = 18;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 9);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(97, 20);
|
||||
label1.TabIndex = 17;
|
||||
label1.Text = "Покупатель: ";
|
||||
//
|
||||
// saveButton
|
||||
//
|
||||
saveButton.Anchor = AnchorStyles.Bottom;
|
||||
saveButton.Location = new Point(125, 297);
|
||||
saveButton.Name = "saveButton";
|
||||
saveButton.Size = new Size(94, 29);
|
||||
saveButton.TabIndex = 19;
|
||||
saveButton.Text = "Сохранить";
|
||||
saveButton.UseVisualStyleBackColor = true;
|
||||
saveButton.Click += saveButton_Click;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(12, 44);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(54, 20);
|
||||
label4.TabIndex = 15;
|
||||
label4.Text = "Товар:";
|
||||
//
|
||||
// productsDataGridView
|
||||
//
|
||||
productsDataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
productsDataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
productsDataGridView.Columns.AddRange(new DataGridViewColumn[] { ProductColoumn, ProductCount });
|
||||
productsDataGridView.Location = new Point(12, 67);
|
||||
productsDataGridView.Name = "productsDataGridView";
|
||||
productsDataGridView.RowHeadersWidth = 51;
|
||||
productsDataGridView.RowTemplate.Height = 29;
|
||||
productsDataGridView.Size = new Size(336, 224);
|
||||
productsDataGridView.TabIndex = 20;
|
||||
//
|
||||
// ProductColoumn
|
||||
//
|
||||
ProductColoumn.HeaderText = "Товары";
|
||||
ProductColoumn.MinimumWidth = 6;
|
||||
ProductColoumn.Name = "ProductColoumn";
|
||||
ProductColoumn.Resizable = DataGridViewTriState.True;
|
||||
ProductColoumn.SortMode = DataGridViewColumnSortMode.Automatic;
|
||||
ProductColoumn.Width = 125;
|
||||
//
|
||||
// ProductCount
|
||||
//
|
||||
ProductCount.HeaderText = "Количество";
|
||||
ProductCount.MinimumWidth = 6;
|
||||
ProductCount.Name = "ProductCount";
|
||||
ProductCount.Width = 125;
|
||||
//
|
||||
// CheckSettingsForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(360, 338);
|
||||
Controls.Add(productsDataGridView);
|
||||
Controls.Add(saveButton);
|
||||
Controls.Add(customerComboBox);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(label4);
|
||||
Name = "CheckSettingsForm";
|
||||
Text = "Новый чек";
|
||||
Load += CheckSettingsForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)productsDataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox customerComboBox;
|
||||
private Label label1;
|
||||
private Button saveButton;
|
||||
private Label label4;
|
||||
private DataGridView productsDataGridView;
|
||||
private DataGridViewComboBoxColumn ProductColoumn;
|
||||
private DataGridViewTextBoxColumn ProductCount;
|
||||
}
|
||||
}
|
74
CompShop/CompShop/Forms/Receipt/CheckSettingsForm .cs
Normal file
74
CompShop/CompShop/Forms/Receipt/CheckSettingsForm .cs
Normal file
@ -0,0 +1,74 @@
|
||||
using CompShop.Entites;
|
||||
using CompShop.Repos;
|
||||
|
||||
namespace CompShop.Forms.Receipt
|
||||
{
|
||||
public partial class CheckSettingsForm : Form
|
||||
{
|
||||
private readonly ICheckRepository _checkRepository;
|
||||
private readonly IProductRepository _productRepository;
|
||||
private readonly IClientRepository _customerRepository;
|
||||
|
||||
public CheckSettingsForm(ICheckRepository checkRepository, IProductRepository productRepository, IClientRepository customerRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_checkRepository = checkRepository ?? throw new ArgumentNullException(nameof(checkRepository));
|
||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
||||
_customerRepository = customerRepository ?? throw new ArgumentNullException(nameof(customerRepository));
|
||||
|
||||
|
||||
ProductColoumn.DataSource = _productRepository.ReadAll().ToList();
|
||||
ProductColoumn.DisplayMember = "Name";
|
||||
ProductColoumn.ValueMember = "Id";
|
||||
|
||||
customerComboBox.DataSource = _customerRepository.ReadAll().ToList();
|
||||
customerComboBox.DisplayMember = "Name";
|
||||
customerComboBox.ValueMember = "Id";
|
||||
}
|
||||
|
||||
public void CheckSettingsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void saveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (productsDataGridView.RowCount < 1 || customerComboBox.SelectedItem == null)
|
||||
{
|
||||
throw new Exception("Необходимо выбрать товар и клиента");
|
||||
}
|
||||
|
||||
var products = CreateListProducts();
|
||||
var customer = (Client)customerComboBox.SelectedItem;
|
||||
|
||||
var check = Check.CreateEntity(0, products, customer, DateTime.Now);
|
||||
_checkRepository.Create(check);
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании чека", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private List<ProductInCheck> CreateListProducts()
|
||||
{
|
||||
var list = new List<ProductInCheck>();
|
||||
foreach (DataGridViewRow row in productsDataGridView.Rows)
|
||||
{
|
||||
if (row.Cells["ProductColoumn"].Value == null || row.Cells["ColumnCount"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
list.Add(ProductInCheck.CreateElement(Convert.ToInt32(row.Cells["ProductColoumn"].Value), Convert.ToInt32(row.Cells["ProductCount"].Value)));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
66
CompShop/CompShop/Forms/Receipt/CheckSettingsForm .resx
Normal file
66
CompShop/CompShop/Forms/Receipt/CheckSettingsForm .resx
Normal file
@ -0,0 +1,66 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ProductColoumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ProductCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
103
CompShop/CompShop/Forms/Storage/StorageForm.Designer.cs
generated
Normal file
103
CompShop/CompShop/Forms/Storage/StorageForm.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
namespace CompShop.Forms.Storage
|
||||
{
|
||||
partial class StorageForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
deleteButton = new Button();
|
||||
editButton = new Button();
|
||||
addButton = new Button();
|
||||
storagesDataGridView = new DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)storagesDataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// deleteButton
|
||||
//
|
||||
deleteButton.Location = new Point(869, 144);
|
||||
deleteButton.Name = "deleteButton";
|
||||
deleteButton.Size = new Size(161, 60);
|
||||
deleteButton.TabIndex = 11;
|
||||
deleteButton.Text = "Удалить";
|
||||
deleteButton.UseVisualStyleBackColor = true;
|
||||
deleteButton.Click += deleteButton_Click;
|
||||
//
|
||||
// editButton
|
||||
//
|
||||
editButton.Location = new Point(869, 78);
|
||||
editButton.Name = "editButton";
|
||||
editButton.Size = new Size(161, 60);
|
||||
editButton.TabIndex = 10;
|
||||
editButton.Text = "Редактировать";
|
||||
editButton.UseVisualStyleBackColor = true;
|
||||
editButton.Click += editButton_Click;
|
||||
//
|
||||
// addButton
|
||||
//
|
||||
addButton.BackColor = SystemColors.Control;
|
||||
addButton.Location = new Point(869, 12);
|
||||
addButton.Name = "addButton";
|
||||
addButton.Size = new Size(161, 60);
|
||||
addButton.TabIndex = 9;
|
||||
addButton.Text = "Добавить";
|
||||
addButton.UseVisualStyleBackColor = false;
|
||||
addButton.Click += addButton_Click;
|
||||
//
|
||||
// storagesDataGridView
|
||||
//
|
||||
storagesDataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
storagesDataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
storagesDataGridView.Location = new Point(12, 12);
|
||||
storagesDataGridView.Name = "storagesDataGridView";
|
||||
storagesDataGridView.RowHeadersWidth = 51;
|
||||
storagesDataGridView.RowTemplate.Height = 29;
|
||||
storagesDataGridView.Size = new Size(851, 416);
|
||||
storagesDataGridView.TabIndex = 8;
|
||||
//
|
||||
// StorageForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1058, 440);
|
||||
Controls.Add(deleteButton);
|
||||
Controls.Add(editButton);
|
||||
Controls.Add(addButton);
|
||||
Controls.Add(storagesDataGridView);
|
||||
Name = "StorageForm";
|
||||
Text = "Склады";
|
||||
Load += StorageForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)storagesDataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button deleteButton;
|
||||
private Button editButton;
|
||||
private Button addButton;
|
||||
private DataGridView storagesDataGridView;
|
||||
}
|
||||
}
|
102
CompShop/CompShop/Forms/Storage/StorageForm.cs
Normal file
102
CompShop/CompShop/Forms/Storage/StorageForm.cs
Normal file
@ -0,0 +1,102 @@
|
||||
|
||||
using CompShop.Repos;
|
||||
using Unity;
|
||||
|
||||
namespace CompShop.Forms.Storage
|
||||
{
|
||||
public partial class StorageForm : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IStorageRepository _repository;
|
||||
|
||||
public StorageForm(IUnityContainer unityContainer, IStorageRepository repository)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_container = unityContainer ?? throw new ArgumentNullException(nameof(unityContainer));
|
||||
_repository = repository ?? throw new ArgumentNullException(nameof(_repository));
|
||||
}
|
||||
|
||||
private void StorageForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => storagesDataGridView.DataSource = _repository.ReadAll();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (storagesDataGridView.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
id = Convert.ToInt32(storagesDataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void addButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<StorageSettingsForm>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void editButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var form = _container.Resolve<StorageSettingsForm>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_repository.Delete(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
60
CompShop/CompShop/Forms/Storage/StorageForm.resx
Normal file
60
CompShop/CompShop/Forms/Storage/StorageForm.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
109
CompShop/CompShop/Forms/Storage/StorageSettingsForm.Designer.cs
generated
Normal file
109
CompShop/CompShop/Forms/Storage/StorageSettingsForm.Designer.cs
generated
Normal file
@ -0,0 +1,109 @@
|
||||
namespace CompShop.Forms.Storage
|
||||
{
|
||||
partial class StorageSettingsForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label3 = new Label();
|
||||
sizeNumeric = new NumericUpDown();
|
||||
label1 = new Label();
|
||||
adressTextbox = new TextBox();
|
||||
saveButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)sizeNumeric).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(12, 67);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(100, 20);
|
||||
label3.TabIndex = 11;
|
||||
label3.Text = "Вместимость";
|
||||
//
|
||||
// sizeNumeric
|
||||
//
|
||||
sizeNumeric.Location = new Point(119, 65);
|
||||
sizeNumeric.Name = "sizeNumeric";
|
||||
sizeNumeric.Size = new Size(99, 27);
|
||||
sizeNumeric.TabIndex = 10;
|
||||
sizeNumeric.ThousandsSeparator = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 22);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(104, 20);
|
||||
label1.TabIndex = 9;
|
||||
label1.Text = "Адрес склада:";
|
||||
//
|
||||
// adressTextbox
|
||||
//
|
||||
adressTextbox.Location = new Point(119, 19);
|
||||
adressTextbox.Name = "adressTextbox";
|
||||
adressTextbox.Size = new Size(210, 27);
|
||||
adressTextbox.TabIndex = 8;
|
||||
//
|
||||
// saveButton
|
||||
//
|
||||
saveButton.Anchor = AnchorStyles.Bottom;
|
||||
saveButton.Location = new Point(129, 117);
|
||||
saveButton.Name = "saveButton";
|
||||
saveButton.Size = new Size(94, 29);
|
||||
saveButton.TabIndex = 7;
|
||||
saveButton.Text = "Сохранить";
|
||||
saveButton.UseVisualStyleBackColor = true;
|
||||
saveButton.Click += saveButton_Click;
|
||||
//
|
||||
// StorageSettingsForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(364, 158);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(sizeNumeric);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(adressTextbox);
|
||||
Controls.Add(saveButton);
|
||||
Name = "StorageSettingsForm";
|
||||
Text = "Настройки склада";
|
||||
Load += StorageFormSettings_Load;
|
||||
((System.ComponentModel.ISupportInitialize)sizeNumeric).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label3;
|
||||
private NumericUpDown sizeNumeric;
|
||||
private Label label1;
|
||||
private TextBox adressTextbox;
|
||||
private Button saveButton;
|
||||
}
|
||||
}
|
80
CompShop/CompShop/Forms/Storage/StorageSettingsForm.cs
Normal file
80
CompShop/CompShop/Forms/Storage/StorageSettingsForm.cs
Normal file
@ -0,0 +1,80 @@
|
||||
using CompShop.Repos;
|
||||
|
||||
|
||||
namespace CompShop.Forms.Storage
|
||||
{
|
||||
public partial class StorageSettingsForm : Form
|
||||
{
|
||||
private readonly IStorageRepository _repository;
|
||||
|
||||
private int? _storageID;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var storage = _repository.Read(value);
|
||||
if (storage != null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(storage));
|
||||
}
|
||||
adressTextbox.Text = storage.Adress;
|
||||
sizeNumeric.Value = storage.Size;
|
||||
_storageID = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public StorageSettingsForm(IStorageRepository repository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_repository = repository ?? throw new ArgumentNullException(nameof(repository));
|
||||
|
||||
}
|
||||
|
||||
private void StorageFormSettings_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void saveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(adressTextbox.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
if (_storageID.HasValue)
|
||||
{
|
||||
|
||||
_repository.Update(CreateStorage(_storageID.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
_repository.Update(CreateStorage(0));
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private Entites.Storage CreateStorage(int id)
|
||||
{
|
||||
return Entites.Storage.CreateEntity(id, (int)sizeNumeric.Value, adressTextbox.Text);
|
||||
}
|
||||
}
|
||||
}
|
60
CompShop/CompShop/Forms/Storage/StorageSettingsForm.resx
Normal file
60
CompShop/CompShop/Forms/Storage/StorageSettingsForm.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1,3 +1,8 @@
|
||||
using CompShop.Repos;
|
||||
using CompShop.Repos.Impements;
|
||||
using Unity;
|
||||
using Unity.Lifetime;
|
||||
|
||||
namespace CompShop
|
||||
{
|
||||
internal static class Program
|
||||
@ -8,10 +13,20 @@ namespace CompShop
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// 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<ShopForm>());
|
||||
}
|
||||
private static IUnityContainer CreateContainer()
|
||||
{
|
||||
var container = new UnityContainer();
|
||||
|
||||
container.RegisterType<IProductRepository, ProductRepo>(new TransientLifetimeManager());
|
||||
container.RegisterType<IClientRepository, ClientRepo>(new TransientLifetimeManager());
|
||||
container.RegisterType<IStorageRepository, StorageRepo>(new TransientLifetimeManager());
|
||||
container.RegisterType<IProductOnStorageRepository, ProductsOnStorageRepo>(new TransientLifetimeManager());
|
||||
container.RegisterType<ICheckRepository, CheckRepo>(new TransientLifetimeManager());
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
}
|
11
CompShop/CompShop/Repos/ICheckRepository.cs
Normal file
11
CompShop/CompShop/Repos/ICheckRepository.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using CompShop.Entites;
|
||||
|
||||
namespace CompShop.Repos
|
||||
{
|
||||
public interface ICheckRepository
|
||||
{
|
||||
IEnumerable<Check> ReadAll();
|
||||
Check Read(int id);
|
||||
void Create(Check check);
|
||||
}
|
||||
}
|
13
CompShop/CompShop/Repos/IClientRepository.cs
Normal file
13
CompShop/CompShop/Repos/IClientRepository.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using CompShop.Entites;
|
||||
|
||||
namespace CompShop.Repos
|
||||
{
|
||||
public interface IClientRepository
|
||||
{
|
||||
IEnumerable<Client> ReadAll();
|
||||
Client Read(int id);
|
||||
void Create(Client client);
|
||||
Client Update(Client client);
|
||||
void Delete(int id);
|
||||
}
|
||||
}
|
11
CompShop/CompShop/Repos/IProductOnStorageRepository.cs
Normal file
11
CompShop/CompShop/Repos/IProductOnStorageRepository.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using CompShop.Entites;
|
||||
namespace CompShop.Repos
|
||||
{
|
||||
public interface IProductOnStorageRepository
|
||||
{
|
||||
IEnumerable<ProductsOnStorage> ReadAll();
|
||||
ProductsOnStorage Read(int id);
|
||||
void Create(ProductsOnStorage ps);
|
||||
ProductsOnStorage Update(ProductsOnStorage storage);
|
||||
}
|
||||
}
|
13
CompShop/CompShop/Repos/IProductRepository.cs
Normal file
13
CompShop/CompShop/Repos/IProductRepository.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using CompShop.Entites;
|
||||
|
||||
namespace CompShop.Repos
|
||||
{
|
||||
public interface IProductRepository
|
||||
{
|
||||
IEnumerable<Product> ReadAll();
|
||||
Product Read(int id);
|
||||
void Create(Product product);
|
||||
Product Update(Product product);
|
||||
void Delete(int id);
|
||||
}
|
||||
}
|
13
CompShop/CompShop/Repos/IStorageRepository.cs
Normal file
13
CompShop/CompShop/Repos/IStorageRepository.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using CompShop.Entites;
|
||||
|
||||
namespace CompShop.Repos
|
||||
{
|
||||
public interface IStorageRepository
|
||||
{
|
||||
IEnumerable<Storage> ReadAll();
|
||||
Storage Read(int id);
|
||||
void Create(Storage storage);
|
||||
Storage Update(Storage storage);
|
||||
void Delete(int id);
|
||||
}
|
||||
}
|
23
CompShop/CompShop/Repos/Impements/CheckRepo.cs
Normal file
23
CompShop/CompShop/Repos/Impements/CheckRepo.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using CompShop.Entites;
|
||||
|
||||
namespace CompShop.Repos.Impements
|
||||
{
|
||||
public class CheckRepo : ICheckRepository
|
||||
{
|
||||
|
||||
public void Create(Check check)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Check Read(int id)
|
||||
{
|
||||
return Check.CreateEntity(0, new List<ProductInCheck>(), new Client(), DateTime.Now);
|
||||
}
|
||||
|
||||
public IEnumerable<Check> ReadAll()
|
||||
{
|
||||
return new List<Check>();
|
||||
}
|
||||
}
|
||||
}
|
33
CompShop/CompShop/Repos/Impements/ClientRepo.cs
Normal file
33
CompShop/CompShop/Repos/Impements/ClientRepo.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using CompShop.Entites;
|
||||
using CompShop.Entites.Enums;
|
||||
|
||||
namespace CompShop.Repos.Impements
|
||||
{
|
||||
public class ClientRepo : IClientRepository
|
||||
{
|
||||
public void Create(Client client)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Client Read(int id)
|
||||
{
|
||||
return Client.CreateEntity(0, string.Empty, string.Empty, ClientType.Individual);
|
||||
}
|
||||
|
||||
public IEnumerable<Client> ReadAll()
|
||||
{
|
||||
return new List<Client>();
|
||||
}
|
||||
|
||||
public Client Update(Client client)
|
||||
{
|
||||
return Client.CreateEntity(0, string.Empty, string.Empty, ClientType.Individual);
|
||||
}
|
||||
}
|
||||
}
|
33
CompShop/CompShop/Repos/Impements/ProductRepo.cs
Normal file
33
CompShop/CompShop/Repos/Impements/ProductRepo.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using CompShop.Entites;
|
||||
using CompShop.Entites.Enums;
|
||||
|
||||
namespace CompShop.Repos.Impements
|
||||
{
|
||||
public class ProductRepo : IProductRepository
|
||||
{
|
||||
public void Create(Product product)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Product Read(int id)
|
||||
{
|
||||
return Product.CreateEntity(0, string.Empty, string.Empty, 0, ProductType.None);
|
||||
}
|
||||
|
||||
public IEnumerable<Product> ReadAll()
|
||||
{
|
||||
return new List<Product>();
|
||||
}
|
||||
|
||||
public Product Update(Product product)
|
||||
{
|
||||
return Product.CreateEntity(0, string.Empty, string.Empty, 0, ProductType.None);
|
||||
}
|
||||
}
|
||||
}
|
27
CompShop/CompShop/Repos/Impements/ProductsOnStorageRepo.cs
Normal file
27
CompShop/CompShop/Repos/Impements/ProductsOnStorageRepo.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using CompShop.Entites;
|
||||
|
||||
namespace CompShop.Repos.Impements
|
||||
{
|
||||
public class ProductsOnStorageRepo : IProductOnStorageRepository
|
||||
{
|
||||
public void Create(ProductsOnStorage ps)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ProductsOnStorage Read(int id)
|
||||
{
|
||||
return ProductsOnStorage.CreateEntity(0, new Product(), new Storage(), 0);
|
||||
}
|
||||
|
||||
public IEnumerable<ProductsOnStorage> ReadAll()
|
||||
{
|
||||
return new List<ProductsOnStorage>();
|
||||
}
|
||||
|
||||
public ProductsOnStorage Update(ProductsOnStorage storage)
|
||||
{
|
||||
return ProductsOnStorage.CreateEntity(0, new Product(), new Storage(), 0);
|
||||
}
|
||||
}
|
||||
}
|
32
CompShop/CompShop/Repos/Impements/StorageRepo.cs
Normal file
32
CompShop/CompShop/Repos/Impements/StorageRepo.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using CompShop.Entites;
|
||||
|
||||
namespace CompShop.Repos.Impements
|
||||
{
|
||||
public class StorageRepo: IStorageRepository
|
||||
{
|
||||
public void Create(Storage storage)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Delete(int id)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Storage Read(int id)
|
||||
{
|
||||
return Storage.CreateEntity(0, 0, string.Empty);
|
||||
}
|
||||
|
||||
public IEnumerable<Storage> ReadAll()
|
||||
{
|
||||
return new List<Storage>();
|
||||
}
|
||||
|
||||
public Storage Update(Storage storage)
|
||||
{
|
||||
return Storage.CreateEntity(0, 0, string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
BIN
CompShop/CompShop/photo_2024-10-27_23-57-36.jpg
Normal file
BIN
CompShop/CompShop/photo_2024-10-27_23-57-36.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 99 KiB |
Loading…
x
Reference in New Issue
Block a user
Пустых методов быть не должно