Compare commits

...

1 Commits

Author SHA1 Message Date
kirkorovka
553ddc7711 Lab1 2024-11-25 12:42:06 +04:00
56 changed files with 20544 additions and 0 deletions

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34525.116
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectGasStation", "ProjectGasStation\ProjectGasStation.csproj", "{4C4A42F9-B3C9-4BC4-A2DF-B24467227150}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4C4A42F9-B3C9-4BC4-A2DF-B24467227150}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4C4A42F9-B3C9-4BC4-A2DF-B24467227150}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4C4A42F9-B3C9-4BC4-A2DF-B24467227150}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4C4A42F9-B3C9-4BC4-A2DF-B24467227150}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2AE1223C-095E-4AD1-BD25-D734E57F3D98}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities.Enums;
[Flags]
public enum Category
{
Fuel = 0,
Gas = 1,
LiquidFuel = 2,
Chemicals = 4,
Oils = 8,
CareProducts = 16,
CareForInterior = 32,
CareForBody = 64,
MineralOils = 128,
SyntheticOils = 256,
None = 512
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities.Enums;
public enum JobTitle
{
None = 0,
Ordinary = 1,
Senior = 2,
Head = 3
}

View File

@ -0,0 +1,29 @@
using ProjectGasStation.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities;
public class Product
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public decimal Price { get; private set; }
public Category Category { get; private set; }
public static Product CreatEntity(int id, string name, decimal price, Category category)
{
return new Product
{
Id = id,
Name = name,
Price = price,
Category = category
};
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.Pkcs;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities;
public class Receipt
{
public int Id { get; set; }
public DateTime DateTime { get; set; }
public int SupplierId { get; set; }
public IEnumerable<SaleReceiptProduct> ReceiptProducts { get; set; } = [];
public static Receipt CreateOperation (int id, int supplierID, IEnumerable<SaleReceiptProduct> receiptProducts)
{
return new Receipt
{
Id = id,
DateTime = DateTime.Now,
SupplierId = supplierID,
ReceiptProducts = receiptProducts
};
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities;
public class Sale
{
public int Id { get; set; }
public DateTime DateTime { get; set; }
public int WorkerId { get; set; }
public IEnumerable<SaleReceiptProduct> SaleProduct { get; set; } = [];
public static Sale CreateOperation(int id, int workerId, IEnumerable<SaleReceiptProduct> saleProduct)
{
return new Sale
{
Id = id,
DateTime = DateTime.Now,
WorkerId = workerId,
SaleProduct = saleProduct
};
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities;
public class SaleReceiptProduct
{
public int Id { get; set; }
public int ProductId { get; set; }
public int Quantity { get; set; }
public static SaleReceiptProduct CreateElement(int id, int productId, int quantity)
{
return new SaleReceiptProduct
{
Id = id,
ProductId = productId,
Quantity = quantity
};
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities;
public class Supplier
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public string PhoneNumber { get; private set; }
public string Address { get; private set; } = string.Empty;
public static Supplier CreateEntity(int id, string name, string phoneNumber, string address)
{
return new Supplier
{
Id = id,
Name = name,
PhoneNumber = phoneNumber,
Address = address
};
}
}

View File

@ -0,0 +1,26 @@
using ProjectGasStation.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Entities;
public class Worker
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public JobTitle JobTitle { get; private set; }
public static Worker CreateEntity (int id, string name, JobTitle jobTitle)
{
return new Worker
{
Id = id,
Name = name,
JobTitle = jobTitle
};
}
}

View File

@ -0,0 +1,139 @@
namespace ProjectGasStation
{
partial class FormGasStation
{
/// <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(FormGasStation));
menuStrip1 = new MenuStrip();
спрафочникиToolStripMenuItem = new ToolStripMenuItem();
ProductToolStripMenuItem = new ToolStripMenuItem();
WorkerToolStripMenuItem = new ToolStripMenuItem();
SupplierToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
ReceiptToolStripMenuItem = new ToolStripMenuItem();
SaleToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
SuspendLayout();
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
menuStrip1.Items.AddRange(new ToolStripItem[] { спрафочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(782, 28);
menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip";
//
// спрафочникиToolStripMenuItem
//
спрафочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ProductToolStripMenuItem, WorkerToolStripMenuItem, SupplierToolStripMenuItem });
спрафочникиToolStripMenuItem.Name = "спрафочникиToolStripMenuItem";
спрафочникиToolStripMenuItem.Size = new Size(117, 24);
спрафочникиToolStripMenuItem.Text = "Справочники";
//
// ProductToolStripMenuItem
//
ProductToolStripMenuItem.Name = "ProductToolStripMenuItem";
ProductToolStripMenuItem.Size = new Size(224, 26);
ProductToolStripMenuItem.Text = "Товары";
ProductToolStripMenuItem.Click += ProductToolStripMenuItem_Click;
//
// WorkerToolStripMenuItem
//
WorkerToolStripMenuItem.Name = "WorkerToolStripMenuItem";
WorkerToolStripMenuItem.Size = new Size(224, 26);
WorkerToolStripMenuItem.Text = "Работники";
WorkerToolStripMenuItem.Click += WorkerToolStripMenuItem_Click;
//
// SupplierToolStripMenuItem
//
SupplierToolStripMenuItem.Name = "SupplierToolStripMenuItem";
SupplierToolStripMenuItem.Size = new Size(224, 26);
SupplierToolStripMenuItem.Text = "Поставщики";
SupplierToolStripMenuItem.Click += SupplierToolStripMenuItem_Click;
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ReceiptToolStripMenuItem, SaleToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции";
//
// ReceiptToolStripMenuItem
//
ReceiptToolStripMenuItem.Name = "ReceiptToolStripMenuItem";
ReceiptToolStripMenuItem.Size = new Size(244, 26);
ReceiptToolStripMenuItem.Text = "Поступление товаров";
ReceiptToolStripMenuItem.Click += ReceiptToolStripMenuItem_Click;
//
// SaleToolStripMenuItem
//
SaleToolStripMenuItem.Name = "SaleToolStripMenuItem";
SaleToolStripMenuItem.Size = new Size(244, 26);
SaleToolStripMenuItem.Text = "Продажи";
SaleToolStripMenuItem.Click += SaleToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(73, 24);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// FormGasStation
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = (Image)resources.GetObject("$this.BackgroundImage");
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(782, 453);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "FormGasStation";
StartPosition = FormStartPosition.CenterScreen;
Text = "АЗС";
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip1;
private ToolStripMenuItem спрафочникиToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem ProductToolStripMenuItem;
private ToolStripMenuItem WorkerToolStripMenuItem;
private ToolStripMenuItem SupplierToolStripMenuItem;
private ToolStripMenuItem ReceiptToolStripMenuItem;
private ToolStripMenuItem SaleToolStripMenuItem;
}
}

View File

@ -0,0 +1,89 @@
using ProjectGasStation.Forms;
using System.ComponentModel;
using Unity;
namespace ProjectGasStation
{
public partial class FormGasStation : Form
{
private readonly IUnityContainer _container;
public FormGasStation(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void ProductToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormProducts>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void WorkerToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormWorkers>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void SupplierToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormSuppliers>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ReceiptToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormReceipts>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void SaleToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormSales>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,146 @@
namespace ProjectGasStation.Forms
{
partial class FormProduct
{
/// <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()
{
checkedListBoxCategory = new CheckedListBox();
labelName = new Label();
labelCategory = new Label();
labelPrice = new Label();
numericUpDownPrice = new NumericUpDown();
textBoxName = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
SuspendLayout();
//
// checkedListBoxCategory
//
checkedListBoxCategory.FormattingEnabled = true;
checkedListBoxCategory.Location = new Point(172, 76);
checkedListBoxCategory.Name = "checkedListBoxCategory";
checkedListBoxCategory.Size = new Size(205, 114);
checkedListBoxCategory.TabIndex = 0;
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(28, 30);
labelName.Name = "labelName";
labelName.Size = new Size(120, 20);
labelName.TabIndex = 1;
labelName.Text = "Наименование ";
//
// labelCategory
//
labelCategory.AutoSize = true;
labelCategory.Location = new Point(28, 76);
labelCategory.Name = "labelCategory";
labelCategory.Size = new Size(81, 20);
labelCategory.TabIndex = 2;
labelCategory.Text = "Категория";
//
// labelPrice
//
labelPrice.AutoSize = true;
labelPrice.Location = new Point(28, 207);
labelPrice.Name = "labelPrice";
labelPrice.Size = new Size(45, 20);
labelPrice.TabIndex = 3;
labelPrice.Text = "Цена";
//
// numericUpDownPrice
//
numericUpDownPrice.DecimalPlaces = 2;
numericUpDownPrice.Location = new Point(172, 207);
numericUpDownPrice.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
numericUpDownPrice.Minimum = new decimal(new int[] { 10, 0, 0, 0 });
numericUpDownPrice.Name = "numericUpDownPrice";
numericUpDownPrice.Size = new Size(205, 27);
numericUpDownPrice.TabIndex = 4;
numericUpDownPrice.Value = new decimal(new int[] { 10, 0, 0, 0 });
//
// textBoxName
//
textBoxName.Location = new Point(172, 30);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(205, 27);
textBoxName.TabIndex = 5;
//
// buttonSave
//
buttonSave.Location = new Point(28, 259);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(157, 48);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(220, 259);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(157, 48);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// FormProduct
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(402, 332);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxName);
Controls.Add(numericUpDownPrice);
Controls.Add(labelPrice);
Controls.Add(labelCategory);
Controls.Add(labelName);
Controls.Add(checkedListBoxCategory);
Name = "FormProduct";
Text = "Товар";
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckedListBox checkedListBoxCategory;
private Label labelName;
private Label labelCategory;
private Label labelPrice;
private NumericUpDown numericUpDownPrice;
private TextBox textBoxName;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,108 @@
using Microsoft.VisualBasic.FileIO;
using ProjectGasStation.Entities;
using ProjectGasStation.Entities.Enums;
using ProjectGasStation.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectGasStation.Forms
{
public partial class FormProduct : Form
{
private readonly IProductRepository _productRepository;
private int? _productId;
public int Id
{
set
{
try
{
var product = _productRepository.ReadProductById(value);
if (product == null)
{
throw new
InvalidDataException(nameof(product));
}
foreach (Category elem in Enum.GetValues(typeof(Category)))
{
if ((elem & product.Category) != 0)
{
checkedListBoxCategory.SetItemChecked(checkedListBoxCategory.Items.IndexOf(elem), true);
}
}
textBoxName.Text = product.Name;
numericUpDownPrice.Value = product.Price;
_productId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormProduct(IProductRepository productRepository)
{
InitializeComponent();
_productRepository = productRepository ??
throw new ArgumentNullException(nameof(productRepository));
foreach (var elem in Enum.GetValues(typeof(Category)))
{
checkedListBoxCategory.Items.Add(elem);
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
checkedListBoxCategory.CheckedItems.Count == 0)
{
throw new Exception("Имеются незаполненные поля");
}
if (_productId.HasValue)
{
_productRepository.UpdateProduct(CreateProduct(_productId.Value));
}
else
{
_productRepository.CreateProduct(CreateProduct(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Product CreateProduct(int id)
{
Category category = Category.None;
foreach (var elem in checkedListBoxCategory.CheckedItems)
{
category |= (Category)elem;
}
return Product.CreatEntity(id, textBoxName.Text, numericUpDownPrice.Value, category);
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,127 @@
namespace ProjectGasStation.Forms
{
partial class FormProducts
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormProducts));
panel = new Panel();
buttonUpd = new Button();
buttonDel = new Button();
buttonAdd = new Button();
dataGridViewData = new DataGridView();
panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// panel
//
panel.Controls.Add(buttonUpd);
panel.Controls.Add(buttonDel);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(690, 0);
panel.Name = "panel";
panel.Size = new Size(110, 450);
panel.TabIndex = 9;
//
// buttonUpd
//
buttonUpd.BackgroundImage = (Image)resources.GetObject("buttonUpd.BackgroundImage");
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(13, 192);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(85, 82);
buttonUpd.TabIndex = 2;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonDel
//
buttonDel.BackgroundImage = (Image)resources.GetObject("buttonDel.BackgroundImage");
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(13, 104);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(85, 82);
buttonDel.TabIndex = 1;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = (Image)resources.GetObject("buttonAdd.BackgroundImage");
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(13, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(85, 86);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.RowHeadersWidth = 51;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(690, 450);
dataGridViewData.TabIndex = 10;
//
// FormProducts
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormProducts";
Text = "Товар";
Load += FormProducts_Load;
panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel;
private Button buttonUpd;
private Button buttonDel;
private Button buttonAdd;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,118 @@
using ProjectGasStation.Repositories;
using ProjectGasStation.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectGasStation.Forms
{
public partial class FormProducts : Form
{
private readonly IUnityContainer _container;
private readonly IProductRepository _productRepository;
public FormProducts(IUnityContainer container, IProductRepository productRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_productRepository = productRepository ??
throw new ArgumentNullException(nameof(productRepository));
}
private void FormProducts_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormProduct>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление",
MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_productRepository.DeleteProduct(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormProduct>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _productRepository.ReadProduct();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,152 @@
namespace ProjectGasStation.Forms
{
partial class FormReceipt
{
/// <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()
{
comboBoxSupplier = new ComboBox();
labelSupplier = new Label();
groupBoxProducts = new GroupBox();
dataGridViewProducts = new DataGridView();
ColumnProduct = new DataGridViewComboBoxColumn();
ColumnQuantity = new DataGridViewTextBoxColumn();
buttonSave = new Button();
buttonCancel = new Button();
groupBoxProducts.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewProducts).BeginInit();
SuspendLayout();
//
// comboBoxSupplier
//
comboBoxSupplier.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxSupplier.FormattingEnabled = true;
comboBoxSupplier.Location = new Point(160, 28);
comboBoxSupplier.Name = "comboBoxSupplier";
comboBoxSupplier.Size = new Size(243, 28);
comboBoxSupplier.TabIndex = 6;
//
// labelSupplier
//
labelSupplier.AutoSize = true;
labelSupplier.Location = new Point(29, 28);
labelSupplier.Name = "labelSupplier";
labelSupplier.Size = new Size(86, 20);
labelSupplier.TabIndex = 5;
labelSupplier.Text = "Поставщик";
//
// groupBoxProducts
//
groupBoxProducts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxProducts.Controls.Add(dataGridViewProducts);
groupBoxProducts.Location = new Point(29, 79);
groupBoxProducts.Name = "groupBoxProducts";
groupBoxProducts.Size = new Size(377, 465);
groupBoxProducts.TabIndex = 7;
groupBoxProducts.TabStop = false;
groupBoxProducts.Text = "Товары";
//
// dataGridViewProducts
//
dataGridViewProducts.AllowUserToResizeColumns = false;
dataGridViewProducts.AllowUserToResizeRows = false;
dataGridViewProducts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewProducts.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnQuantity });
dataGridViewProducts.Dock = DockStyle.Fill;
dataGridViewProducts.Location = new Point(3, 23);
dataGridViewProducts.MultiSelect = false;
dataGridViewProducts.Name = "dataGridViewProducts";
dataGridViewProducts.RowHeadersVisible = false;
dataGridViewProducts.RowHeadersWidth = 51;
dataGridViewProducts.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewProducts.Size = new Size(371, 439);
dataGridViewProducts.TabIndex = 0;
//
// ColumnProduct
//
ColumnProduct.HeaderText = "Товар";
ColumnProduct.MinimumWidth = 6;
ColumnProduct.Name = "ColumnProduct";
//
// ColumnQuantity
//
ColumnQuantity.HeaderText = "Количество";
ColumnQuantity.MinimumWidth = 6;
ColumnQuantity.Name = "ColumnQuantity";
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonSave.Location = new Point(32, 559);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(142, 45);
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранение";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(261, 559);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(142, 42);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// FormReceipts
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(439, 622);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(groupBoxProducts);
Controls.Add(comboBoxSupplier);
Controls.Add(labelSupplier);
Name = "FormReceipts";
Text = "Поставка";
groupBoxProducts.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewProducts).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBoxSupplier;
private Label labelSupplier;
private GroupBox groupBoxProducts;
private DataGridView dataGridViewProducts;
private DataGridViewComboBoxColumn ColumnProduct;
private DataGridViewTextBoxColumn ColumnQuantity;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,76 @@
using ProjectGasStation.Entities;
using ProjectGasStation.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using Unity;
namespace ProjectGasStation.Forms
{
public partial class FormReceipt : Form
{
private readonly IReceiptRepository _receiptRepository;
public FormReceipt(IReceiptRepository receiptRepository, ISupplierRepository supplierRepository, IProductRepository productRepository)
{
InitializeComponent();
_receiptRepository = receiptRepository ??
throw new ArgumentNullException(nameof(receiptRepository));
comboBoxSupplier.DataSource = supplierRepository.ReadSupplier();
comboBoxSupplier.DisplayMember = "Name";
comboBoxSupplier.ValueMember = "Id";
ColumnProduct.DataSource = productRepository.ReadProduct();
ColumnProduct.DisplayMember = "Name";
ColumnProduct.ValueMember = "Id";
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (dataGridViewProducts.RowCount < 1 ||
comboBoxSupplier.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
_receiptRepository.CreateReceipt(Receipt.CreateOperation(0, (int)comboBoxSupplier.SelectedValue!, CreateListReceiptFromDataGrid()));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private List<SaleReceiptProduct> CreateListReceiptFromDataGrid()
{
var list = new List<SaleReceiptProduct>();
foreach (DataGridViewRow row in dataGridViewProducts.Rows)
{
if (row.Cells["ColumnProduct"].Value == null || row.Cells["ColumnQuantity"].Value == null)
{
continue;
}
list.Add(SaleReceiptProduct.CreateElement(0, Convert.ToInt32(row.Cells["ColumnProduct"].Value), Convert.ToInt32(row.Cells["ColumnQuantity"].Value)));
}
return list;
}
}
}

View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ColumnProduct.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnQuantity.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,113 @@
namespace ProjectGasStation.Forms
{
partial class FormReceipts
{
/// <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(FormReceipts));
panel = new Panel();
buttonDel = new Button();
buttonAdd = new Button();
dataGridViewData = new DataGridView();
panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// panel
//
panel.Controls.Add(buttonDel);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(690, 0);
panel.Name = "panel";
panel.Size = new Size(110, 450);
panel.TabIndex = 9;
//
// buttonDel
//
buttonDel.BackgroundImage = (Image)resources.GetObject("buttonDel.BackgroundImage");
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(13, 104);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(85, 82);
buttonDel.TabIndex = 1;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = (Image)resources.GetObject("buttonAdd.BackgroundImage");
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(13, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(85, 86);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.RowHeadersWidth = 51;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(690, 450);
dataGridViewData.TabIndex = 10;
//
// FormReceipts
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormReceipts";
Text = "FormReceipts";
Load += FormReceipts_Load;
panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel;
private Button buttonDel;
private Button buttonAdd;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,103 @@
using ProjectGasStation.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectGasStation.Forms
{
public partial class FormReceipts : Form
{
private readonly IUnityContainer _container;
private readonly IReceiptRepository _receiptRepository;
public FormReceipts(IUnityContainer container, IReceiptRepository receiptRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_receiptRepository = receiptRepository ??
throw new ArgumentNullException(nameof(receiptRepository));
}
private void FormReceipts_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormReceipt>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление",
MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_receiptRepository.DeleteReceipt(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _receiptRepository.ReadReceipt();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id =
Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,152 @@
namespace ProjectGasStation.Forms
{
partial class FormSale
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
buttonCancel = new Button();
buttonSave = new Button();
groupBoxProducts = new GroupBox();
dataGridViewProducts = new DataGridView();
ColumnProduct = new DataGridViewComboBoxColumn();
ColumnQuantity = new DataGridViewTextBoxColumn();
comboBoxWorker = new ComboBox();
labelWorker = new Label();
groupBoxProducts.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewProducts).BeginInit();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(256, 457);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(142, 42);
buttonCancel.TabIndex = 14;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonSave.Location = new Point(27, 457);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(142, 45);
buttonSave.TabIndex = 13;
buttonSave.Text = "Сохранение";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// groupBoxProducts
//
groupBoxProducts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBoxProducts.Controls.Add(dataGridViewProducts);
groupBoxProducts.Location = new Point(24, 92);
groupBoxProducts.Name = "groupBoxProducts";
groupBoxProducts.Size = new Size(377, 350);
groupBoxProducts.TabIndex = 12;
groupBoxProducts.TabStop = false;
groupBoxProducts.Text = "Товары";
//
// dataGridViewProducts
//
dataGridViewProducts.AllowUserToResizeColumns = false;
dataGridViewProducts.AllowUserToResizeRows = false;
dataGridViewProducts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewProducts.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnQuantity });
dataGridViewProducts.Dock = DockStyle.Fill;
dataGridViewProducts.Location = new Point(3, 23);
dataGridViewProducts.MultiSelect = false;
dataGridViewProducts.Name = "dataGridViewProducts";
dataGridViewProducts.RowHeadersVisible = false;
dataGridViewProducts.RowHeadersWidth = 51;
dataGridViewProducts.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewProducts.Size = new Size(371, 324);
dataGridViewProducts.TabIndex = 0;
//
// ColumnProduct
//
ColumnProduct.HeaderText = "Товар";
ColumnProduct.MinimumWidth = 6;
ColumnProduct.Name = "ColumnProduct";
//
// ColumnQuantity
//
ColumnQuantity.HeaderText = "Количество";
ColumnQuantity.MinimumWidth = 6;
ColumnQuantity.Name = "ColumnQuantity";
//
// comboBoxWorker
//
comboBoxWorker.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxWorker.FormattingEnabled = true;
comboBoxWorker.Location = new Point(155, 41);
comboBoxWorker.Name = "comboBoxWorker";
comboBoxWorker.Size = new Size(243, 28);
comboBoxWorker.TabIndex = 11;
//
// labelWorker
//
labelWorker.AutoSize = true;
labelWorker.Location = new Point(24, 41);
labelWorker.Name = "labelWorker";
labelWorker.Size = new Size(74, 20);
labelWorker.TabIndex = 10;
labelWorker.Text = "Работник";
//
// FormSale
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(425, 542);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(groupBoxProducts);
Controls.Add(comboBoxWorker);
Controls.Add(labelWorker);
Name = "FormSale";
Text = "FormSale";
groupBoxProducts.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewProducts).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private GroupBox groupBoxProducts;
private DataGridView dataGridViewProducts;
private DataGridViewComboBoxColumn ColumnProduct;
private DataGridViewTextBoxColumn ColumnQuantity;
private ComboBox comboBoxWorker;
private Label labelWorker;
}
}

View File

@ -0,0 +1,69 @@
using ProjectGasStation.Entities;
using ProjectGasStation.Repositories;
using ProjectGasStation.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectGasStation.Forms
{
public partial class FormSale : Form
{
private readonly ISaleRepository _saleRepository;
public FormSale(ISaleRepository saleRepository, IWorkerRepository workerRepository, IProductRepository productRepository)
{
InitializeComponent();
_saleRepository = saleRepository ??
throw new ArgumentNullException(nameof(saleRepository));
comboBoxWorker.DataSource = workerRepository.ReadWorker();
comboBoxWorker.DisplayMember = "Name";
comboBoxWorker.ValueMember = "Id";
ColumnProduct.DataSource = productRepository.ReadProduct();
ColumnProduct.DisplayMember = "Name";
ColumnProduct.ValueMember = "Id";
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (dataGridViewProducts.RowCount < 1 ||
comboBoxWorker.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
_saleRepository.CreateSale(Sale.CreateOperation(0, (int)comboBoxWorker.SelectedValue!, CreateListSaleFromDataGrid()));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private List<SaleReceiptProduct> CreateListSaleFromDataGrid()
{
var list = new List<SaleReceiptProduct>();
foreach (DataGridViewRow row in dataGridViewProducts.Rows)
{
if (row.Cells["ColumnProduct"].Value == null || row.Cells["ColumnQuantity"].Value == null)
{
continue;
}
list.Add(SaleReceiptProduct.CreateElement(0, Convert.ToInt32(row.Cells["ColumnProduct"].Value), Convert.ToInt32(row.Cells["ColumnQuantity"].Value)));
}
return list;
}
}
}

View File

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ColumnProduct.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnQuantity.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnProduct.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnQuantity.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,113 @@
namespace ProjectGasStation.Forms
{
partial class FormSales
{
/// <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(FormSales));
panel = new Panel();
buttonDel = new Button();
buttonAdd = new Button();
dataGridViewData = new DataGridView();
panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// panel
//
panel.Controls.Add(buttonDel);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(690, 0);
panel.Name = "panel";
panel.Size = new Size(110, 450);
panel.TabIndex = 10;
//
// buttonDel
//
buttonDel.BackgroundImage = (Image)resources.GetObject("buttonDel.BackgroundImage");
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(13, 104);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(85, 82);
buttonDel.TabIndex = 1;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = (Image)resources.GetObject("buttonAdd.BackgroundImage");
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(13, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(85, 86);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.RowHeadersWidth = 51;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(690, 450);
dataGridViewData.TabIndex = 11;
//
// FormSales
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormSales";
Text = "FormSales";
Load += FormSales_Load;
panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel;
private Button buttonDel;
private Button buttonAdd;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,96 @@
using ProjectGasStation.Repositories;
using ProjectGasStation.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Unity;
namespace ProjectGasStation.Forms
{
public partial class FormSales : Form
{
private readonly IUnityContainer _container;
private readonly ISaleRepository _saleRepository;
public FormSales(IUnityContainer container, ISaleRepository saleRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_saleRepository = saleRepository ??
throw new ArgumentNullException(nameof(saleRepository));
}
private void FormSales_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormSale>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление",
MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_saleRepository.DeleteSale(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _saleRepository.ReadSale();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id =
Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,140 @@
namespace ProjectGasStation.Forms
{
partial class FormSupplier
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
labelName = new Label();
labelPhoneNumber = new Label();
labelAddress = new Label();
buttonCancel = new Button();
buttonSave = new Button();
textBoxSupplierName = new TextBox();
textBoxSupplierPhoneNumber = new TextBox();
textBoxSupplierAddress = new TextBox();
SuspendLayout();
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(37, 35);
labelName.Name = "labelName";
labelName.Size = new Size(42, 20);
labelName.TabIndex = 0;
labelName.Text = "ФИО";
//
// labelPhoneNumber
//
labelPhoneNumber.AutoSize = true;
labelPhoneNumber.Location = new Point(37, 95);
labelPhoneNumber.Name = "labelPhoneNumber";
labelPhoneNumber.Size = new Size(86, 20);
labelPhoneNumber.TabIndex = 1;
labelPhoneNumber.Text = "Тел. номер";
//
// labelAddress
//
labelAddress.AutoSize = true;
labelAddress.Location = new Point(37, 164);
labelAddress.Name = "labelAddress";
labelAddress.Size = new Size(51, 20);
labelAddress.TabIndex = 2;
labelAddress.Text = "Адрес";
//
// buttonCancel
//
buttonCancel.Location = new Point(244, 220);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(180, 46);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(37, 220);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(180, 46);
buttonSave.TabIndex = 4;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// textBoxSupplierName
//
textBoxSupplierName.Location = new Point(161, 32);
textBoxSupplierName.Name = "textBoxSupplierName";
textBoxSupplierName.Size = new Size(263, 27);
textBoxSupplierName.TabIndex = 5;
//
// textBoxSupplierPhoneNumber
//
textBoxSupplierPhoneNumber.Location = new Point(161, 88);
textBoxSupplierPhoneNumber.Name = "textBoxSupplierPhoneNumber";
textBoxSupplierPhoneNumber.Size = new Size(263, 27);
textBoxSupplierPhoneNumber.TabIndex = 6;
//
// textBoxSupplierAddress
//
textBoxSupplierAddress.Location = new Point(161, 157);
textBoxSupplierAddress.Name = "textBoxSupplierAddress";
textBoxSupplierAddress.Size = new Size(263, 27);
textBoxSupplierAddress.TabIndex = 7;
//
// FormSupplier
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(467, 298);
Controls.Add(textBoxSupplierAddress);
Controls.Add(textBoxSupplierPhoneNumber);
Controls.Add(textBoxSupplierName);
Controls.Add(buttonSave);
Controls.Add(buttonCancel);
Controls.Add(labelAddress);
Controls.Add(labelPhoneNumber);
Controls.Add(labelName);
Name = "FormSupplier";
StartPosition = FormStartPosition.CenterParent;
Text = "Поставщик";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelName;
private Label labelPhoneNumber;
private Label labelAddress;
private Button buttonCancel;
private Button buttonSave;
private TextBox textBoxSupplierName;
private TextBox textBoxSupplierPhoneNumber;
private TextBox textBoxSupplierAddress;
}
}

View File

@ -0,0 +1,86 @@
using ProjectGasStation.Entities.Enums;
using ProjectGasStation.Entities;
using ProjectGasStation.Repositories;
using ProjectGasStation.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectGasStation.Forms
{
public partial class FormSupplier : Form
{
private readonly ISupplierRepository _supplierRepository;
private int? _supplierId;
public int Id
{
set
{
try
{
var supplier = _supplierRepository.ReadSupplierById(value);
if (supplier == null)
{
throw new InvalidDataException(nameof(supplier));
textBoxSupplierName.Text = supplier.Name;
textBoxSupplierPhoneNumber.Text = supplier.PhoneNumber;
textBoxSupplierAddress.Text = supplier.Address;
_supplierId = value;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormSupplier(ISupplierRepository supplierRepository)
{
InitializeComponent();
_supplierRepository = supplierRepository ??
throw new ArgumentNullException(nameof(supplierRepository));
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxSupplierName.Text) ||
string.IsNullOrWhiteSpace(textBoxSupplierPhoneNumber.Text) ||
string.IsNullOrWhiteSpace(textBoxSupplierAddress.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_supplierId.HasValue)
{
_supplierRepository.UpdateSupplier(CreateSupplier(_supplierId.Value));
}
else
{
_supplierRepository.CreateSupplier(CreateSupplier(0));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Supplier CreateSupplier(int id) => Supplier.CreateEntity(id,
textBoxSupplierName.Text, textBoxSupplierPhoneNumber.Text, textBoxSupplierAddress.Text);
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,127 @@
namespace ProjectGasStation.Forms
{
partial class FormSuppliers
{
/// <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(FormSuppliers));
panel = new Panel();
buttonUpd = new Button();
buttonDel = new Button();
buttonAdd = new Button();
dataGridViewData = new DataGridView();
panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// panel
//
panel.Controls.Add(buttonUpd);
panel.Controls.Add(buttonDel);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(626, 0);
panel.Name = "panel";
panel.Size = new Size(110, 477);
panel.TabIndex = 8;
//
// buttonUpd
//
buttonUpd.BackgroundImage = (Image)resources.GetObject("buttonUpd.BackgroundImage");
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(13, 192);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(85, 82);
buttonUpd.TabIndex = 2;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonDel
//
buttonDel.BackgroundImage = (Image)resources.GetObject("buttonDel.BackgroundImage");
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(13, 104);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(85, 82);
buttonDel.TabIndex = 1;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = (Image)resources.GetObject("buttonAdd.BackgroundImage");
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(13, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(85, 86);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.RowHeadersWidth = 51;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(626, 477);
dataGridViewData.TabIndex = 9;
//
// FormSuppliers
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(736, 477);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormSuppliers";
StartPosition = FormStartPosition.CenterParent;
Text = "Поставщик";
Load += FormSuppliers_Load;
panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel;
private Button buttonUpd;
private Button buttonAdd;
private Button buttonDel;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,120 @@
using ProjectGasStation.Entities;
using ProjectGasStation.Repositories;
using ProjectGasStation.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using Unity;
namespace ProjectGasStation.Forms
{
public partial class FormSuppliers : Form
{
private readonly IUnityContainer _container;
private readonly ISupplierRepository _supplierRepository;
public FormSuppliers(IUnityContainer container, ISupplierRepository supplierRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_supplierRepository = supplierRepository ??
throw new ArgumentNullException(nameof(supplierRepository));
}
private void FormSuppliers_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormSupplier>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_supplierRepository.DeleteSupplier(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormSupplier>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _supplierRepository.ReadSupplier();
private bool TryGetIdentifierFromSelectRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,119 @@
namespace ProjectGasStation.Forms
{
partial class FormWorker
{
/// <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()
{
comboBoxJobTitle = new ComboBox();
labelName = new Label();
labelJobTitle = new Label();
textBoxName = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// comboBoxJobTitle
//
comboBoxJobTitle.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxJobTitle.FormattingEnabled = true;
comboBoxJobTitle.Location = new Point(164, 92);
comboBoxJobTitle.Name = "comboBoxJobTitle";
comboBoxJobTitle.Size = new Size(151, 28);
comboBoxJobTitle.TabIndex = 0;
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(30, 31);
labelName.Name = "labelName";
labelName.Size = new Size(42, 20);
labelName.TabIndex = 1;
labelName.Text = "ФИО";
//
// labelJobTitle
//
labelJobTitle.AutoSize = true;
labelJobTitle.Location = new Point(30, 95);
labelJobTitle.Name = "labelJobTitle";
labelJobTitle.Size = new Size(86, 20);
labelJobTitle.TabIndex = 2;
labelJobTitle.Text = "Должность";
//
// textBoxName
//
textBoxName.Location = new Point(164, 24);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(151, 27);
textBoxName.TabIndex = 4;
//
// buttonSave
//
buttonSave.Location = new Point(30, 149);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(119, 46);
buttonSave.TabIndex = 5;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(196, 149);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(119, 46);
buttonCancel.TabIndex = 6;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// FormWorker
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(352, 228);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxName);
Controls.Add(labelJobTitle);
Controls.Add(labelName);
Controls.Add(comboBoxJobTitle);
Name = "FormWorker";
Text = "Работник";
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBoxJobTitle;
private Label labelName;
private Label labelJobTitle;
private TextBox textBoxName;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,87 @@
using ProjectGasStation.Entities;
using ProjectGasStation.Entities.Enums;
using ProjectGasStation.Repositories;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProjectGasStation.Forms
{
public partial class FormWorker : Form
{
private readonly IWorkerRepository _workerRepository;
private int? _workerId;
public int Id
{
set
{
try
{
var worker = _workerRepository.ReadWorkerById(value);
if (worker == null)
{
throw new
InvalidDataException(nameof(worker));
}
textBoxName.Text = worker.Name;
comboBoxJobTitle.SelectedItem = worker.JobTitle;
_workerId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormWorker(IWorkerRepository workerRepository)
{
InitializeComponent();
_workerRepository = workerRepository ??
throw new ArgumentNullException(nameof(workerRepository));
comboBoxJobTitle.DataSource = Enum.GetValues(typeof(JobTitle));
}
private void buttonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textBoxName.Text)
|| comboBoxJobTitle.SelectedIndex < 1)
{
throw new Exception("Имеются незаполненные поля");
}
if (_workerId.HasValue)
{
_workerRepository.UpdateWorker(CreateWorker(_workerId.Value));
}
else
{
_workerRepository.CreateWorker(CreateWorker(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) => Close();
private Worker CreateWorker(int id) => Worker.CreateEntity(id, textBoxName.Text, (JobTitle)comboBoxJobTitle.SelectedItem!);
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,127 @@
namespace ProjectGasStation.Forms
{
partial class FormWorkers
{
/// <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(FormWorkers));
panel = new Panel();
buttonUpd = new Button();
buttonDel = new Button();
buttonAdd = new Button();
dataGridViewData = new DataGridView();
panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// panel
//
panel.Controls.Add(buttonUpd);
panel.Controls.Add(buttonDel);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(690, 0);
panel.Name = "panel";
panel.Size = new Size(110, 450);
panel.TabIndex = 0;
//
// buttonUpd
//
buttonUpd.BackgroundImage = (Image)resources.GetObject("buttonUpd.BackgroundImage");
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(13, 192);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(85, 82);
buttonUpd.TabIndex = 3;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonDel
//
buttonDel.BackgroundImage = (Image)resources.GetObject("buttonDel.BackgroundImage");
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(13, 104);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(85, 82);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = (Image)resources.GetObject("buttonAdd.BackgroundImage");
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(13, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(85, 86);
buttonAdd.TabIndex = 1;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.RowHeadersWidth = 51;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(690, 450);
dataGridViewData.TabIndex = 10;
//
// FormWorkers
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormWorkers";
Text = "Работник";
Load += FormWorkers_Load;
panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel;
private Button buttonAdd;
private Button buttonDel;
private Button buttonUpd;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,115 @@
using ProjectGasStation.Repositories;
using ProjectGasStation.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using Unity;
namespace ProjectGasStation.Forms
{
public partial class FormWorkers : Form
{
private readonly IUnityContainer _container;
private readonly IWorkerRepository _workerRepository;
public FormWorkers(IUnityContainer container, IWorkerRepository workerRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_workerRepository = workerRepository ??
throw new ArgumentNullException(nameof(workerRepository));
}
private void FormWorkers_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormWorker>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectRow(out var findId))
{
return;
}
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
{
return;
}
try
{
_workerRepository.DeleteWorker(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectRow(out var findId))
{
return;
}
try
{
var form = _container.Resolve<FormWorker>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _workerRepository.ReadWorker();
private bool TryGetIdentifierFromSelectRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
return true;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
using ProjectGasStation.Repositories;
using ProjectGasStation.Repositories.Implementations;
using Unity;
namespace ProjectGasStation
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[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(CreateUnityContainer().Resolve<FormGasStation>());
}
private static IUnityContainer CreateUnityContainer()
{
var container = new UnityContainer();
container.RegisterType<IProductRepository, ProductRepository>();
container.RegisterType<IReceiptRepository, ReceiptRepository>();
container.RegisterType<ISaleRepository, SaleRepository>();
container.RegisterType<ISupplierRepository, SupplierRepository>();
container.RegisterType<IWorkerRepository, WorkerRepository>();
return container;
}
}
}

View File

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity" Version="5.11.10" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

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

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

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

View File

@ -0,0 +1,17 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories;
public interface IReceiptRepository
{
IEnumerable<Receipt> ReadReceipt(DateTime? dateForm = null, DateTime? dateTo = null, int? productId = null, int? supplierId = null);
void CreateReceipt(Receipt receipt);
void DeleteReceipt(int id);
}

View File

@ -0,0 +1,17 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories;
public interface ISaleRepository
{
IEnumerable<Sale> ReadSale(DateTime? dateForm = null, DateTime? dateTo = null, int? productId = null, int? workerId = null);
void CreateSale(Sale sale);
void DeleteSale(int id);
}

View File

@ -0,0 +1,22 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories;
public interface ISupplierRepository
{
IEnumerable<Supplier> ReadSupplier();
Supplier ReadSupplierById(int id);
void CreateSupplier(Supplier supplier);
void UpdateSupplier(Supplier supplier);
void DeleteSupplier(int id);
}

View File

@ -0,0 +1,20 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories;
public interface IWorkerRepository
{
IEnumerable<Worker> ReadWorker();
Worker ReadWorkerById(int id);
void CreateWorker(Worker worker);
void UpdateWorker(Worker worker);
void DeleteWorker(int id);
}

View File

@ -0,0 +1,35 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories.Implementations;
internal class ProductRepository : IProductRepository
{
public void CreateProduct(Product product)
{
}
public void DeleteProduct(int id)
{
}
public IEnumerable<Product> ReadProduct()
{
return [];
}
public Product ReadProductById(int id)
{
return Product.CreatEntity(0, string.Empty, 0, Entities.Enums.Category.None);
}
public void UpdateProduct(Product product)
{
}
}

View File

@ -0,0 +1,24 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories.Implementations;
internal class ReceiptRepository : IReceiptRepository
{
public void CreateReceipt(Receipt receipt)
{
}
public void DeleteReceipt(int id)
{
}
public IEnumerable<Receipt> ReadReceipt(DateTime? dateForm = null, DateTime? dateTo = null, int? productId = null, int? supplierId = null)
{
return [];
}
}

View File

@ -0,0 +1,24 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories.Implementations;
internal class SaleRepository : ISaleRepository
{
public void CreateSale(Sale sale)
{
}
public void DeleteSale(int id)
{
}
public IEnumerable<Sale> ReadSale(DateTime? dateForm = null, DateTime? dateTo = null, int? productId = null, int? workerId = null)
{
return [];
}
}

View File

@ -0,0 +1,34 @@
using ProjectGasStation.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories.Implementations;
public class SupplierRepository : ISupplierRepository
{
public void CreateSupplier(Supplier supplier)
{
}
public void DeleteSupplier(int id)
{
}
public Supplier ReadSupplierById(int id)
{
return Supplier.CreateEntity(0, string.Empty, string.Empty, string.Empty);
}
public IEnumerable<Supplier> ReadSupplier()
{
return [];
}
public void UpdateSupplier(Supplier supplier)
{
}
}

View File

@ -0,0 +1,34 @@
using ProjectGasStation.Entities;
using ProjectGasStation.Entities.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectGasStation.Repositories.Implementations;
public class WorkerRepository : IWorkerRepository
{
public void CreateWorker(Worker worker)
{
}
public void DeleteWorker(int id)
{
}
public IEnumerable<Worker> ReadWorker()
{
return [];
}
public Worker ReadWorkerById(int id)
{
return Worker.CreateEntity(0, string.Empty, JobTitle.None);
}
public void UpdateWorker(Worker worker)
{
}
}