PIbd-22 Alkin_D.V. LabWork_1 #1
@ -15,7 +15,7 @@ public class SaleProduct
|
||||
|
||||
|
||||
|
||||
public static SaleProduct CreateElement(int id, int saleID, int productID, double quantity)
|
||||
public static SaleProduct CreateOperation(int id, int saleID, int productID, double quantity)
|
||||
{
|
||||
return new SaleProduct() { Id = id, SaleID = saleID, ProductID = productID, Quantity = quantity };
|
||||
}
|
||||
|
@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGasStation.Entities;
|
||||
|
||||
public class Shift
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public DateTime DateStart { get; private set; }
|
||||
|
||||
public DateTime DateFinish { get; private set; }
|
||||
|
||||
public int EmployeeID { get; private set; }
|
||||
|
||||
public static Shift CreateElement(int id, DateTime dateStart, DateTime dateFinish, int employeeID)
|
||||
{
|
||||
return new Shift { Id = id, DateStart = dateStart, DateFinish = dateFinish, EmployeeID = employeeID };
|
||||
}
|
||||
}
|
@ -32,14 +32,13 @@
|
||||
contextMenuStrip = new ContextMenuStrip(components);
|
||||
menuStrip1 = new MenuStrip();
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
EmployeeToolStripMenuItem = new ToolStripMenuItem();
|
||||
ProductToolStripMenuItem = new ToolStripMenuItem();
|
||||
SupplierToolStripMenuItem = new ToolStripMenuItem();
|
||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||
SaleToolStripMenuItem = new ToolStripMenuItem();
|
||||
PurchaseToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||
сотрудникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
товарыToolStripMenuItem = new ToolStripMenuItem();
|
||||
сменыToolStripMenuItem = new ToolStripMenuItem();
|
||||
поставщикиToolStripMenuItem = new ToolStripMenuItem();
|
||||
продажаToolStripMenuItem = new ToolStripMenuItem();
|
||||
закупкаToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -61,60 +60,59 @@
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { сотрудникиToolStripMenuItem, товарыToolStripMenuItem, сменыToolStripMenuItem, поставщикиToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { EmployeeToolStripMenuItem, ProductToolStripMenuItem, SupplierToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(99, 21);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// EmployeeToolStripMenuItem
|
||||
//
|
||||
EmployeeToolStripMenuItem.Name = "EmployeeToolStripMenuItem";
|
||||
EmployeeToolStripMenuItem.Size = new Size(198, 24);
|
||||
EmployeeToolStripMenuItem.Text = "Сотрудники";
|
||||
EmployeeToolStripMenuItem.Click += EmployeeToolStripMenuItem_Click;
|
||||
//
|
||||
// ProductToolStripMenuItem
|
||||
//
|
||||
ProductToolStripMenuItem.Name = "ProductToolStripMenuItem";
|
||||
ProductToolStripMenuItem.Size = new Size(198, 24);
|
||||
ProductToolStripMenuItem.Text = "Товары";
|
||||
ProductToolStripMenuItem.Click += ProductToolStripMenuItem_Click;
|
||||
//
|
||||
// SupplierToolStripMenuItem
|
||||
//
|
||||
SupplierToolStripMenuItem.Name = "SupplierToolStripMenuItem";
|
||||
SupplierToolStripMenuItem.Size = new Size(198, 24);
|
||||
SupplierToolStripMenuItem.Text = "Поставщики";
|
||||
SupplierToolStripMenuItem.Click += SupplierToolStripMenuItem_Click;
|
||||
//
|
||||
// операцииToolStripMenuItem
|
||||
//
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { продажаToolStripMenuItem, закупкаToolStripMenuItem });
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SaleToolStripMenuItem, PurchaseToolStripMenuItem });
|
||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||
операцииToolStripMenuItem.Size = new Size(80, 21);
|
||||
операцииToolStripMenuItem.Text = "Операции";
|
||||
//
|
||||
// SaleToolStripMenuItem
|
||||
//
|
||||
SaleToolStripMenuItem.Name = "SaleToolStripMenuItem";
|
||||
SaleToolStripMenuItem.Size = new Size(198, 24);
|
||||
SaleToolStripMenuItem.Text = "Продажа";
|
||||
SaleToolStripMenuItem.Click += SaleToolStripMenuItem_Click;
|
||||
//
|
||||
// PurchaseToolStripMenuItem
|
||||
//
|
||||
PurchaseToolStripMenuItem.Name = "PurchaseToolStripMenuItem";
|
||||
PurchaseToolStripMenuItem.Size = new Size(198, 24);
|
||||
PurchaseToolStripMenuItem.Text = "Закупка";
|
||||
PurchaseToolStripMenuItem.Click += PurchaseToolStripMenuItem_Click;
|
||||
//
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
отчетыToolStripMenuItem.Size = new Size(63, 21);
|
||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
//
|
||||
// сотрудникиToolStripMenuItem
|
||||
//
|
||||
сотрудникиToolStripMenuItem.Name = "сотрудникиToolStripMenuItem";
|
||||
сотрудникиToolStripMenuItem.Size = new Size(198, 24);
|
||||
сотрудникиToolStripMenuItem.Text = "Сотрудники";
|
||||
//
|
||||
// товарыToolStripMenuItem
|
||||
//
|
||||
товарыToolStripMenuItem.Name = "товарыToolStripMenuItem";
|
||||
товарыToolStripMenuItem.Size = new Size(198, 24);
|
||||
товарыToolStripMenuItem.Text = "Товары";
|
||||
//
|
||||
// сменыToolStripMenuItem
|
||||
//
|
||||
сменыToolStripMenuItem.Name = "сменыToolStripMenuItem";
|
||||
сменыToolStripMenuItem.Size = new Size(198, 24);
|
||||
сменыToolStripMenuItem.Text = "Смены";
|
||||
//
|
||||
// поставщикиToolStripMenuItem
|
||||
//
|
||||
поставщикиToolStripMenuItem.Name = "поставщикиToolStripMenuItem";
|
||||
поставщикиToolStripMenuItem.Size = new Size(198, 24);
|
||||
поставщикиToolStripMenuItem.Text = "Поставщики";
|
||||
//
|
||||
// продажаToolStripMenuItem
|
||||
//
|
||||
продажаToolStripMenuItem.Name = "продажаToolStripMenuItem";
|
||||
продажаToolStripMenuItem.Size = new Size(198, 24);
|
||||
продажаToolStripMenuItem.Text = "Продажа";
|
||||
//
|
||||
// закупкаToolStripMenuItem
|
||||
//
|
||||
закупкаToolStripMenuItem.Name = "закупкаToolStripMenuItem";
|
||||
закупкаToolStripMenuItem.Size = new Size(198, 24);
|
||||
закупкаToolStripMenuItem.Text = "Закупка";
|
||||
//
|
||||
// FormGasStation
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
@ -140,11 +138,11 @@
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
private ToolStripMenuItem сотрудникиToolStripMenuItem;
|
||||
private ToolStripMenuItem товарыToolStripMenuItem;
|
||||
private ToolStripMenuItem EmployeeToolStripMenuItem;
|
||||
private ToolStripMenuItem ProductToolStripMenuItem;
|
||||
private ToolStripMenuItem сменыToolStripMenuItem;
|
||||
private ToolStripMenuItem поставщикиToolStripMenuItem;
|
||||
private ToolStripMenuItem продажаToolStripMenuItem;
|
||||
private ToolStripMenuItem закупкаToolStripMenuItem;
|
||||
private ToolStripMenuItem SupplierToolStripMenuItem;
|
||||
private ToolStripMenuItem SaleToolStripMenuItem;
|
||||
private ToolStripMenuItem PurchaseToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -1,10 +1,74 @@
|
||||
namespace ProjectGasStation
|
||||
using ProjectGasStation.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectGasStation;
|
||||
|
||||
public partial class FormGasStation : Form
|
||||
{
|
||||
public partial class FormGasStation : Form
|
||||
private readonly IUnityContainer _container;
|
||||
public FormGasStation(IUnityContainer container)
|
||||
{
|
||||
public FormGasStation()
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
private void EmployeeToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
_container.Resolve<FormEmployees>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 SupplierToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormSuppliers>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void PurchaseToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormPurchases>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaleToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormEmployees>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,12 +28,126 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "FormSale";
|
||||
labelEmployee = new Label();
|
||||
dateTimePicker1 = new DateTimePicker();
|
||||
label1 = new Label();
|
||||
dataGridView1 = new DataGridView();
|
||||
buttonAdd = new Button();
|
||||
buttonCancel = new Button();
|
||||
comboBoxEmployee = new ComboBox();
|
||||
ColumnProduct = new DataGridViewComboBoxColumn();
|
||||
ColumnQuantity = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelEmployee
|
||||
//
|
||||
labelEmployee.AutoSize = true;
|
||||
labelEmployee.Location = new Point(12, 29);
|
||||
labelEmployee.Name = "labelEmployee";
|
||||
labelEmployee.Size = new Size(70, 17);
|
||||
labelEmployee.TabIndex = 0;
|
||||
labelEmployee.Text = "Сотрудник";
|
||||
//
|
||||
// dateTimePicker1
|
||||
//
|
||||
dateTimePicker1.Location = new Point(58, 73);
|
||||
dateTimePicker1.Name = "dateTimePicker1";
|
||||
dateTimePicker1.Size = new Size(221, 25);
|
||||
dateTimePicker1.TabIndex = 1;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 73);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(36, 17);
|
||||
label1.TabIndex = 2;
|
||||
label1.Text = "Дата";
|
||||
//
|
||||
// dataGridView1
|
||||
//
|
||||
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnQuantity });
|
||||
dataGridView1.Location = new Point(12, 197);
|
||||
dataGridView1.Name = "dataGridView1";
|
||||
dataGridView1.RowHeadersWidth = 45;
|
||||
dataGridView1.Size = new Size(267, 329);
|
||||
dataGridView1.TabIndex = 3;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(12, 555);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(115, 43);
|
||||
buttonAdd.TabIndex = 4;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(164, 555);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(115, 43);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// comboBoxEmployee
|
||||
//
|
||||
comboBoxEmployee.FormattingEnabled = true;
|
||||
comboBoxEmployee.Location = new Point(88, 29);
|
||||
comboBoxEmployee.Name = "comboBoxEmployee";
|
||||
comboBoxEmployee.Size = new Size(193, 25);
|
||||
comboBoxEmployee.TabIndex = 6;
|
||||
//
|
||||
// ColumnProduct
|
||||
//
|
||||
ColumnProduct.HeaderText = "Товар";
|
||||
ColumnProduct.MinimumWidth = 6;
|
||||
ColumnProduct.Name = "ColumnProduct";
|
||||
ColumnProduct.Resizable = DataGridViewTriState.True;
|
||||
ColumnProduct.SortMode = DataGridViewColumnSortMode.Automatic;
|
||||
ColumnProduct.Width = 110;
|
||||
//
|
||||
// ColumnQuantity
|
||||
//
|
||||
ColumnQuantity.HeaderText = "Количество";
|
||||
ColumnQuantity.MinimumWidth = 6;
|
||||
ColumnQuantity.Name = "ColumnQuantity";
|
||||
ColumnQuantity.Width = 110;
|
||||
//
|
||||
// FormSale
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(293, 622);
|
||||
Controls.Add(comboBoxEmployee);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView1);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(dateTimePicker1);
|
||||
Controls.Add(labelEmployee);
|
||||
Name = "FormSale";
|
||||
Text = "FormSale";
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelEmployee;
|
||||
private DateTimePicker dateTimePicker1;
|
||||
private Label label1;
|
||||
private DataGridView dataGridView1;
|
||||
private Button buttonAdd;
|
||||
private Button buttonCancel;
|
||||
private ComboBox comboBoxEmployee;
|
||||
private DataGridViewComboBoxColumn ColumnProduct;
|
||||
private DataGridViewTextBoxColumn ColumnQuantity;
|
||||
}
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using ProjectGasStation.Entities;
|
||||
using ProjectGasStation.Implementations;
|
||||
using ProjectGasStation.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@ -8,13 +11,55 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ProjectGasStation.Forms
|
||||
namespace ProjectGasStation.Forms;
|
||||
|
||||
public partial class FormSale : Form
|
||||
{
|
||||
public partial class FormSale : Form
|
||||
private readonly ISaleRepository _saleRepository;
|
||||
public FormSale(ISaleRepository saleRepository, IProductRepository productRepository, IEmployeeRepository employeeRepository)
|
||||
{
|
||||
public FormSale()
|
||||
InitializeComponent();
|
||||
_saleRepository = saleRepository ?? throw new ArgumentNullException(nameof(saleRepository));
|
||||
|
||||
comboBoxEmployee.DataSource = employeeRepository.ReadEmployees();
|
||||
comboBoxEmployee.DisplayMember = "Name";
|
||||
comboBoxEmployee.ValueMember = "Id";
|
||||
|
||||
ColumnProduct.DataSource = productRepository.ReadProducts();
|
||||
ColumnProduct.DisplayMember = "ServiceType";
|
||||
ColumnProduct.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView1.RowCount < 1 || comboBoxEmployee.SelectedIndex < 0 || dateTimePicker1.CustomFormat != " ")
|
||||
{
|
||||
InitializeComponent();
|
||||
throw new Exception("Имеются незаполненны поля");
|
||||
}
|
||||
try
|
||||
{
|
||||
_saleRepository.CreateSale(Sale.CreateOperation(0, comboBoxEmployee.SelectedIndex, dateTimePicker1.Value, CreateListServiceFromDataGrid()));
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private List<SaleProduct> CreateListServiceFromDataGrid()
|
||||
{
|
||||
var list = new List<SaleProduct>();
|
||||
foreach (DataGridViewRow row in dataGridView1.Rows)
|
||||
{
|
||||
if (row.Cells["ColumService"].Value == null || row.Cells["ColumQuantity"].Value == null || row.Cells["ColumnExecutionDate"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(SaleProduct.CreateOperation(0, 0, Convert.ToInt32(row.Cells["ColumnProduct"].Value), Convert.ToDouble(row.Cells["ColumnQuantity"].Value)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
<?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
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
|
||||
Example:
|
||||
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
@ -26,36 +26,36 @@
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
@ -117,4 +117,10 @@
|
||||
<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>
|
88
ProjectGasStation/ProjectGasStation/Forms/FormSales.Designer.cs
generated
Normal file
88
ProjectGasStation/ProjectGasStation/Forms/FormSales.Designer.cs
generated
Normal file
@ -0,0 +1,88 @@
|
||||
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()
|
||||
{
|
||||
panel1 = new Panel();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(626, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(174, 450);
|
||||
panel1.TabIndex = 0;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = Properties.Resources.plus1;
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAdd.Location = new Point(42, 50);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(96, 94);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Fill;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 45;
|
||||
dataGridView.Size = new Size(626, 450);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// FormSales
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormSales";
|
||||
Text = "Sales";
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
63
ProjectGasStation/ProjectGasStation/Forms/FormSales.cs
Normal file
63
ProjectGasStation/ProjectGasStation/Forms/FormSales.cs
Normal file
@ -0,0 +1,63 @@
|
||||
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 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 LoadList() => dataGridView.DataSource = _saleRepository.ReadSales();
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
if (dataGridView.SelectedRows.Count < 1)
|
||||
{
|
||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
120
ProjectGasStation/ProjectGasStation/Forms/FormSales.resx
Normal file
120
ProjectGasStation/ProjectGasStation/Forms/FormSales.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1,22 +0,0 @@
|
||||
using ProjectGasStation.Entities;
|
||||
using ProjectGasStation.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGasStation.Implementations;
|
||||
|
||||
public class ShiftRepository : IShiftRepository
|
||||
{
|
||||
public void CreateShift(Shift shift)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<Shift> ReadShifts(DateTime? dateFrom = null, DateTime? dateTo = null, int? employeeId = null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
@ -26,7 +26,6 @@ namespace ProjectGasStation
|
||||
container.RegisterType<IProductRepository, ProductRepository>();
|
||||
container.RegisterType<IPurchaseRepository, PurchaseRepository>();
|
||||
container.RegisterType<ISaleRepository, SaleRepository>();
|
||||
container.RegisterType<IShiftRepository, ShiftRepository>();
|
||||
container.RegisterType<ISupplierRepository, SupplierRepository>();
|
||||
|
||||
return container;
|
||||
|
@ -11,5 +11,7 @@ public interface ISaleRepository
|
||||
{
|
||||
IEnumerable<Sale> ReadSales(DateTime? dateFrom = null, DateTime? dateTo = null, int? employeeId = null);
|
||||
|
||||
|
||||
void CreateSale(Sale sale);
|
||||
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
using ProjectGasStation.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectGasStation.Repositories;
|
||||
|
||||
public interface IShiftRepository
|
||||
{
|
||||
IEnumerable<Shift> ReadShifts(DateTime? dateFrom = null, DateTime? dateTo = null, int? employeeId = null);
|
||||
|
||||
void CreateShift(Shift shift);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user