Compare commits
No commits in common. "lab3" and "main" have entirely different histories.
@ -1,11 +0,0 @@
|
|||||||
namespace GasStation.Entities.Enums;
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum Post
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
|
|
||||||
Gasman = 1,
|
|
||||||
|
|
||||||
Cashier = 2
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
namespace GasStation.Entities.Enums;
|
|
||||||
|
|
||||||
public enum ProductType
|
|
||||||
{
|
|
||||||
None = 0 ,
|
|
||||||
|
|
||||||
Gas = 1 ,
|
|
||||||
|
|
||||||
Oil = 2 ,
|
|
||||||
|
|
||||||
Antifreeze = 3
|
|
||||||
}
|
|
@ -1,25 +0,0 @@
|
|||||||
using GasStation.Entities.Enums;
|
|
||||||
|
|
||||||
namespace GasStation.Entities;
|
|
||||||
|
|
||||||
public class Gasman
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public string GasmanName { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public string PhoneNumber { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public Post Post { get; private set; }
|
|
||||||
|
|
||||||
public static Gasman CreateGasman(int id, string gasmanName, string phoneNumber, Post post)
|
|
||||||
{
|
|
||||||
return new Gasman
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
GasmanName = gasmanName,
|
|
||||||
PhoneNumber = phoneNumber,
|
|
||||||
Post = post
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
using GasStation.Entities.Enums;
|
|
||||||
|
|
||||||
namespace GasStation.Entities;
|
|
||||||
|
|
||||||
public class Product
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public int ProductCost { get; private set; }
|
|
||||||
|
|
||||||
public ProductType ProductType { get; private set; }
|
|
||||||
|
|
||||||
public static Product CreateProduct(int id, int productCost, ProductType productType)
|
|
||||||
{
|
|
||||||
return new Product
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
ProductCost = productCost,
|
|
||||||
ProductType = productType
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
namespace GasStation.Entities;
|
|
||||||
|
|
||||||
public class ProductSelling
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public int ProductID { get; private set; }
|
|
||||||
|
|
||||||
public int Count { get; private set; }
|
|
||||||
|
|
||||||
public static ProductSelling CreateSelling(int id, int productID, int count)
|
|
||||||
{
|
|
||||||
return new ProductSelling
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
ProductID = productID,
|
|
||||||
Count = count
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
|
|
||||||
namespace GasStation.Entities;
|
|
||||||
|
|
||||||
public class Selling
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public int GasmanId { get; private set; }
|
|
||||||
|
|
||||||
public IEnumerable<ProductSelling> ProdutcSellings { get; private set; } = [];
|
|
||||||
|
|
||||||
public DateTime SellingDateTime { get; private set; }
|
|
||||||
|
|
||||||
public static Selling CreateSelling(int id, int gasmanId, IEnumerable<ProductSelling> produtcSellings)
|
|
||||||
{
|
|
||||||
return new Selling
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
GasmanId = gasmanId,
|
|
||||||
SellingDateTime = DateTime.Now,
|
|
||||||
ProdutcSellings = produtcSellings
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Selling CreateSelling(TempProductSelling tempProductSelling, IEnumerable<ProductSelling> produtcSellings)
|
|
||||||
{
|
|
||||||
return new Selling
|
|
||||||
{
|
|
||||||
Id = tempProductSelling.Id,
|
|
||||||
GasmanId = tempProductSelling.GasmanId,
|
|
||||||
SellingDateTime = tempProductSelling.SellingDateTime,
|
|
||||||
ProdutcSellings = produtcSellings
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
namespace GasStation.Entities;
|
|
||||||
|
|
||||||
public class Supplier
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public string SupplierName { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public static Supplier CreateSupplier(int id, string supplierName)
|
|
||||||
{
|
|
||||||
return new Supplier
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
SupplierName = supplierName
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
namespace GasStation.Entities;
|
|
||||||
|
|
||||||
public class Supply
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public int SupplierID { get; private set; }
|
|
||||||
|
|
||||||
public int ProductID { get; private set; }
|
|
||||||
|
|
||||||
public int Count { get; private set; }
|
|
||||||
|
|
||||||
public DateTime SupplyDate { get; private set; }
|
|
||||||
|
|
||||||
public static Supply CreateSupply(int id, int supplierID, int productID, int count)
|
|
||||||
{
|
|
||||||
return new Supply
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
SupplierID = supplierID,
|
|
||||||
ProductID = productID,
|
|
||||||
Count = count,
|
|
||||||
SupplyDate = DateTime.Now
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
namespace GasStation.Entities;
|
|
||||||
|
|
||||||
public class TempProductSelling
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public int GasmanId { get; private set; }
|
|
||||||
|
|
||||||
public int Count { get; private set; }
|
|
||||||
|
|
||||||
public DateTime SellingDateTime { get; private set; }
|
|
||||||
|
|
||||||
public int ProductID { get; private set; }
|
|
||||||
}
|
|
39
GasStation/Form1.Designer.cs
generated
Normal file
39
GasStation/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace GasStation
|
||||||
|
{
|
||||||
|
partial class Form1
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Text = "Form1";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
10
GasStation/Form1.cs
Normal file
10
GasStation/Form1.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace GasStation
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -117,8 +117,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
|
||||||
<data name="заправка" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\заправка.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
</root>
|
169
GasStation/FormGasstation.Designer.cs
generated
169
GasStation/FormGasstation.Designer.cs
generated
@ -1,169 +0,0 @@
|
|||||||
namespace GasStation
|
|
||||||
{
|
|
||||||
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()
|
|
||||||
{
|
|
||||||
menuStrip1 = new MenuStrip();
|
|
||||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
GasmanToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
SupplierToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
ProductToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
SupplyToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
SellingToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
ProductReportToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
productDistToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
menuStrip1.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// menuStrip1
|
|
||||||
//
|
|
||||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчётыToolStripMenuItem });
|
|
||||||
menuStrip1.Location = new Point(0, 0);
|
|
||||||
menuStrip1.Name = "menuStrip1";
|
|
||||||
menuStrip1.Size = new Size(800, 24);
|
|
||||||
menuStrip1.TabIndex = 0;
|
|
||||||
menuStrip1.Text = "menuStrip1";
|
|
||||||
//
|
|
||||||
// справочникиToolStripMenuItem
|
|
||||||
//
|
|
||||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { GasmanToolStripMenuItem, SupplierToolStripMenuItem, ProductToolStripMenuItem });
|
|
||||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
|
||||||
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
|
||||||
справочникиToolStripMenuItem.Text = "Справочники";
|
|
||||||
//
|
|
||||||
// GasmanToolStripMenuItem
|
|
||||||
//
|
|
||||||
GasmanToolStripMenuItem.Name = "GasmanToolStripMenuItem";
|
|
||||||
GasmanToolStripMenuItem.Size = new Size(137, 22);
|
|
||||||
GasmanToolStripMenuItem.Text = "Заправщик";
|
|
||||||
GasmanToolStripMenuItem.Click += GasmanToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// SupplierToolStripMenuItem
|
|
||||||
//
|
|
||||||
SupplierToolStripMenuItem.Name = "SupplierToolStripMenuItem";
|
|
||||||
SupplierToolStripMenuItem.Size = new Size(137, 22);
|
|
||||||
SupplierToolStripMenuItem.Text = "Поставщик";
|
|
||||||
SupplierToolStripMenuItem.Click += SupplierToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// ProductToolStripMenuItem
|
|
||||||
//
|
|
||||||
ProductToolStripMenuItem.Name = "ProductToolStripMenuItem";
|
|
||||||
ProductToolStripMenuItem.Size = new Size(137, 22);
|
|
||||||
ProductToolStripMenuItem.Text = "Товар";
|
|
||||||
ProductToolStripMenuItem.Click += ProductToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// операцииToolStripMenuItem
|
|
||||||
//
|
|
||||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SupplyToolStripMenuItem, SellingToolStripMenuItem });
|
|
||||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
|
||||||
операцииToolStripMenuItem.Size = new Size(75, 20);
|
|
||||||
операцииToolStripMenuItem.Text = "Операции";
|
|
||||||
//
|
|
||||||
// SupplyToolStripMenuItem
|
|
||||||
//
|
|
||||||
SupplyToolStripMenuItem.Name = "SupplyToolStripMenuItem";
|
|
||||||
SupplyToolStripMenuItem.Size = new Size(125, 22);
|
|
||||||
SupplyToolStripMenuItem.Text = "Поставка";
|
|
||||||
SupplyToolStripMenuItem.Click += SupplyToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// SellingToolStripMenuItem
|
|
||||||
//
|
|
||||||
SellingToolStripMenuItem.Name = "SellingToolStripMenuItem";
|
|
||||||
SellingToolStripMenuItem.Size = new Size(125, 22);
|
|
||||||
SellingToolStripMenuItem.Text = "Продажа";
|
|
||||||
SellingToolStripMenuItem.Click += SellingToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// отчётыToolStripMenuItem
|
|
||||||
//
|
|
||||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, ProductReportToolStripMenuItem, productDistToolStripMenuItem });
|
|
||||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
|
||||||
отчётыToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
|
||||||
отчётыToolStripMenuItem.Size = new Size(60, 20);
|
|
||||||
отчётыToolStripMenuItem.Text = "Отчёты";
|
|
||||||
//
|
|
||||||
// DirectoryReportToolStripMenuItem
|
|
||||||
//
|
|
||||||
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
|
|
||||||
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
|
||||||
DirectoryReportToolStripMenuItem.Size = new Size(280, 22);
|
|
||||||
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
|
|
||||||
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// ProductReportToolStripMenuItem
|
|
||||||
//
|
|
||||||
ProductReportToolStripMenuItem.Name = "ProductReportToolStripMenuItem";
|
|
||||||
ProductReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
|
||||||
ProductReportToolStripMenuItem.Size = new Size(280, 22);
|
|
||||||
ProductReportToolStripMenuItem.Text = "Движение товаров";
|
|
||||||
ProductReportToolStripMenuItem.Click += ProductReportToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// productDistToolStripMenuItem
|
|
||||||
//
|
|
||||||
productDistToolStripMenuItem.Name = "productDistToolStripMenuItem";
|
|
||||||
productDistToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
|
||||||
productDistToolStripMenuItem.Size = new Size(280, 22);
|
|
||||||
productDistToolStripMenuItem.Text = "Распределение товара";
|
|
||||||
productDistToolStripMenuItem.Click += ProductDistToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// FormGasStation
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
BackgroundImage = Properties.Resources.заправка;
|
|
||||||
BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
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 GasmanToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem SupplierToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem ProductToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem SupplyToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem SellingToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem ProductReportToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem productDistToolStripMenuItem;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,114 +0,0 @@
|
|||||||
using GasStation.Forms;
|
|
||||||
using GasStation.Reports;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace GasStation
|
|
||||||
{
|
|
||||||
public partial class FormGasStation : System.Windows.Forms.Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
public FormGasStation(IUnityContainer container)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ??
|
|
||||||
throw new ArgumentNullException(nameof(container));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GasmanToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormGasmen>().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 ProductToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormProducts>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè äîáàâëåíèè", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SupplyToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormSupplies>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè äîáàâëåíèè", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SellingToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormSellings>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè äîáàâëåíèè", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DirectoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormDirectoryReport>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè äîáàâëåíèè", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProductReportToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormProductReport>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè äîáàâëåíèè", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProductDistToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormSupplyDistRep>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè äîáàâëåíèè", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,123 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
|
||||||
<value>17, 17</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
99
GasStation/Forms/FormDirectoryReport.Designer.cs
generated
99
GasStation/Forms/FormDirectoryReport.Designer.cs
generated
@ -1,99 +0,0 @@
|
|||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
partial class FormDirectoryReport
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
checkBoxGasmen = new CheckBox();
|
|
||||||
checkBoxSuppliers = new CheckBox();
|
|
||||||
checkBoxProducts = new CheckBox();
|
|
||||||
buttonBuild = new Button();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// checkBoxGasmen
|
|
||||||
//
|
|
||||||
checkBoxGasmen.AutoSize = true;
|
|
||||||
checkBoxGasmen.Location = new Point(50, 52);
|
|
||||||
checkBoxGasmen.Name = "checkBoxGasmen";
|
|
||||||
checkBoxGasmen.Size = new Size(85, 19);
|
|
||||||
checkBoxGasmen.TabIndex = 0;
|
|
||||||
checkBoxGasmen.Text = "Работники";
|
|
||||||
checkBoxGasmen.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxSuppliers
|
|
||||||
//
|
|
||||||
checkBoxSuppliers.AutoSize = true;
|
|
||||||
checkBoxSuppliers.Location = new Point(50, 119);
|
|
||||||
checkBoxSuppliers.Name = "checkBoxSuppliers";
|
|
||||||
checkBoxSuppliers.Size = new Size(96, 19);
|
|
||||||
checkBoxSuppliers.TabIndex = 1;
|
|
||||||
checkBoxSuppliers.Text = "Поставщики";
|
|
||||||
checkBoxSuppliers.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxProducts
|
|
||||||
//
|
|
||||||
checkBoxProducts.AutoSize = true;
|
|
||||||
checkBoxProducts.Location = new Point(50, 185);
|
|
||||||
checkBoxProducts.Name = "checkBoxProducts";
|
|
||||||
checkBoxProducts.Size = new Size(67, 19);
|
|
||||||
checkBoxProducts.TabIndex = 2;
|
|
||||||
checkBoxProducts.Text = "Товары";
|
|
||||||
checkBoxProducts.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// buttonBuild
|
|
||||||
//
|
|
||||||
buttonBuild.Location = new Point(212, 115);
|
|
||||||
buttonBuild.Name = "buttonBuild";
|
|
||||||
buttonBuild.Size = new Size(128, 23);
|
|
||||||
buttonBuild.TabIndex = 3;
|
|
||||||
buttonBuild.Text = "Сформировать";
|
|
||||||
buttonBuild.UseVisualStyleBackColor = true;
|
|
||||||
buttonBuild.Click += ButtonBuild_Click;
|
|
||||||
//
|
|
||||||
// FormDirectoryReport
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(410, 265);
|
|
||||||
Controls.Add(buttonBuild);
|
|
||||||
Controls.Add(checkBoxProducts);
|
|
||||||
Controls.Add(checkBoxSuppliers);
|
|
||||||
Controls.Add(checkBoxGasmen);
|
|
||||||
Name = "FormDirectoryReport";
|
|
||||||
Text = "FormDirectoryReport";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private CheckBox checkBoxGasmen;
|
|
||||||
private CheckBox checkBoxSuppliers;
|
|
||||||
private CheckBox checkBoxProducts;
|
|
||||||
private Button buttonBuild;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
using GasStation.Reports;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace GasStation.Forms;
|
|
||||||
|
|
||||||
public partial class FormDirectoryReport : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
public FormDirectoryReport(IUnityContainer container)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ??
|
|
||||||
throw new ArgumentNullException(nameof(container));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonBuild_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (!checkBoxGasmen.Checked && !checkBoxSuppliers.Checked && !checkBoxProducts.Checked)
|
|
||||||
{
|
|
||||||
throw new Exception("Не выбран ни один справочник для выгрузки");
|
|
||||||
}
|
|
||||||
|
|
||||||
var sfd = new SaveFileDialog()
|
|
||||||
{
|
|
||||||
Filter = "Docx Files | *.docx"
|
|
||||||
};
|
|
||||||
|
|
||||||
if (sfd.ShowDialog() != DialogResult.OK)
|
|
||||||
{
|
|
||||||
throw new Exception("Не выбран файла для отчета");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxGasmen.Checked, checkBoxSuppliers.Checked, checkBoxProducts.Checked))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
140
GasStation/Forms/FormGasman.Designer.cs
generated
140
GasStation/Forms/FormGasman.Designer.cs
generated
@ -1,140 +0,0 @@
|
|||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
partial class FormGasman
|
|
||||||
{
|
|
||||||
/// <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();
|
|
||||||
labelNumber = new Label();
|
|
||||||
textBoxName = new TextBox();
|
|
||||||
textBoxNumber = new TextBox();
|
|
||||||
buttonSave = new Button();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
label1 = new Label();
|
|
||||||
checkedListBoxPost = new CheckedListBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelName
|
|
||||||
//
|
|
||||||
labelName.AutoSize = true;
|
|
||||||
labelName.Location = new Point(52, 44);
|
|
||||||
labelName.Name = "labelName";
|
|
||||||
labelName.Size = new Size(31, 15);
|
|
||||||
labelName.TabIndex = 0;
|
|
||||||
labelName.Text = "Имя";
|
|
||||||
//
|
|
||||||
// labelNumber
|
|
||||||
//
|
|
||||||
labelNumber.AutoSize = true;
|
|
||||||
labelNumber.Location = new Point(34, 89);
|
|
||||||
labelNumber.Name = "labelNumber";
|
|
||||||
labelNumber.Size = new Size(101, 15);
|
|
||||||
labelNumber.TabIndex = 1;
|
|
||||||
labelNumber.Text = "Номер телефона";
|
|
||||||
//
|
|
||||||
// textBoxName
|
|
||||||
//
|
|
||||||
textBoxName.Location = new Point(141, 41);
|
|
||||||
textBoxName.Name = "textBoxName";
|
|
||||||
textBoxName.Size = new Size(153, 23);
|
|
||||||
textBoxName.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// textBoxNumber
|
|
||||||
//
|
|
||||||
textBoxNumber.Location = new Point(141, 86);
|
|
||||||
textBoxNumber.Name = "textBoxNumber";
|
|
||||||
textBoxNumber.Size = new Size(153, 23);
|
|
||||||
textBoxNumber.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
buttonSave.Location = new Point(52, 243);
|
|
||||||
buttonSave.Name = "buttonSave";
|
|
||||||
buttonSave.Size = new Size(75, 23);
|
|
||||||
buttonSave.TabIndex = 4;
|
|
||||||
buttonSave.Text = "Сохранить";
|
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonSave.Click += ButtonSave_Click;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Location = new Point(219, 243);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(75, 23);
|
|
||||||
buttonCancel.TabIndex = 5;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(34, 133);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(69, 15);
|
|
||||||
label1.TabIndex = 6;
|
|
||||||
label1.Text = "Должность";
|
|
||||||
//
|
|
||||||
// checkedListBoxPost
|
|
||||||
//
|
|
||||||
checkedListBoxPost.FormattingEnabled = true;
|
|
||||||
checkedListBoxPost.Location = new Point(141, 133);
|
|
||||||
checkedListBoxPost.Name = "checkedListBoxPost";
|
|
||||||
checkedListBoxPost.Size = new Size(153, 94);
|
|
||||||
checkedListBoxPost.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// FormGasman
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(421, 291);
|
|
||||||
Controls.Add(checkedListBoxPost);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonSave);
|
|
||||||
Controls.Add(textBoxNumber);
|
|
||||||
Controls.Add(textBoxName);
|
|
||||||
Controls.Add(labelNumber);
|
|
||||||
Controls.Add(labelName);
|
|
||||||
Name = "FormGasman";
|
|
||||||
Text = "Заправщик";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label labelName;
|
|
||||||
private Label labelNumber;
|
|
||||||
private TextBox textBoxName;
|
|
||||||
private TextBox textBoxNumber;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Label label1;
|
|
||||||
private CheckedListBox checkedListBoxPost;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,98 +0,0 @@
|
|||||||
using GasStation.Entities;
|
|
||||||
using GasStation.Entities.Enums;
|
|
||||||
using GasStation.Repositories;
|
|
||||||
|
|
||||||
|
|
||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
public partial class FormGasman : Form
|
|
||||||
{
|
|
||||||
private readonly IGasmanRepository _gasmanRepository;
|
|
||||||
|
|
||||||
private int? _gasmanId;
|
|
||||||
|
|
||||||
public FormGasman(IGasmanRepository gasmanRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_gasmanRepository = gasmanRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(gasmanRepository));
|
|
||||||
|
|
||||||
foreach (var elem in Enum.GetValues(typeof(Post)))
|
|
||||||
{
|
|
||||||
checkedListBoxPost.Items.Add(elem);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ID
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var gasman = _gasmanRepository.ReadGasmanByID(value);
|
|
||||||
if (gasman == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(gasman));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (Post elem in Enum.GetValues(typeof(Post)))
|
|
||||||
{
|
|
||||||
if ((elem & gasman.Post) != 0)
|
|
||||||
{
|
|
||||||
checkedListBoxPost.SetItemChecked(checkedListBoxPost.Items.IndexOf(elem), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
textBoxName.Text = gasman.GasmanName;
|
|
||||||
textBoxNumber.Text = gasman.PhoneNumber;
|
|
||||||
_gasmanId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
|
|
||||||
string.IsNullOrWhiteSpace(textBoxNumber.Text) ||
|
|
||||||
checkedListBoxPost.Items.Count == 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненые поля");
|
|
||||||
}
|
|
||||||
if (_gasmanId.HasValue)
|
|
||||||
{
|
|
||||||
_gasmanRepository.UpdateGasman(CreateGasman(_gasmanId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_gasmanRepository.CreateGasman(CreateGasman(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private Gasman CreateGasman(int id)
|
|
||||||
{
|
|
||||||
Post post = Post.None;
|
|
||||||
foreach (var elem in checkedListBoxPost.CheckedItems)
|
|
||||||
{
|
|
||||||
post |= (Post)elem;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Gasman.CreateGasman(id, textBoxName.Text, textBoxNumber.Text, post);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
122
GasStation/Forms/FormGasmen.Designer.cs
generated
122
GasStation/Forms/FormGasmen.Designer.cs
generated
@ -1,122 +0,0 @@
|
|||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
partial class FormGasmen
|
|
||||||
{
|
|
||||||
/// <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();
|
|
||||||
buttonUpd = new Button();
|
|
||||||
buttonDel = new Button();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
dataGridViewData = new DataGridView();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(buttonUpd);
|
|
||||||
panel1.Controls.Add(buttonDel);
|
|
||||||
panel1.Controls.Add(buttonAdd);
|
|
||||||
panel1.Dock = DockStyle.Right;
|
|
||||||
panel1.Location = new Point(657, 0);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(143, 449);
|
|
||||||
panel1.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonUpd
|
|
||||||
//
|
|
||||||
buttonUpd.Location = new Point(35, 343);
|
|
||||||
buttonUpd.Name = "buttonUpd";
|
|
||||||
buttonUpd.Size = new Size(75, 69);
|
|
||||||
buttonUpd.TabIndex = 3;
|
|
||||||
buttonUpd.Text = "Редактировать";
|
|
||||||
buttonUpd.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpd.Click += ButtonUpd_Click;
|
|
||||||
//
|
|
||||||
// buttonDel
|
|
||||||
//
|
|
||||||
buttonDel.Location = new Point(33, 188);
|
|
||||||
buttonDel.Name = "buttonDel";
|
|
||||||
buttonDel.Size = new Size(77, 73);
|
|
||||||
buttonDel.TabIndex = 2;
|
|
||||||
buttonDel.Text = "Удалить";
|
|
||||||
buttonDel.UseVisualStyleBackColor = true;
|
|
||||||
buttonDel.Click += ButtonDel_Click;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.Location = new Point(32, 30);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(75, 73);
|
|
||||||
buttonAdd.TabIndex = 1;
|
|
||||||
buttonAdd.Text = "Добавить";
|
|
||||||
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewData.Size = new Size(657, 449);
|
|
||||||
dataGridViewData.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// FormGasmen
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 449);
|
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Name = "FormGasmen";
|
|
||||||
Text = "FormGasmen";
|
|
||||||
Load += FormGasmen_Load;
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Panel panel1;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Button buttonDel;
|
|
||||||
private Button buttonUpd;
|
|
||||||
private DataGridView dataGridViewData;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
using GasStation.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
public partial class FormGasmen : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
private readonly IGasmanRepository _gasmanRepository;
|
|
||||||
|
|
||||||
public FormGasmen(IUnityContainer container, IGasmanRepository gasmanRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ??
|
|
||||||
throw new ArgumentNullException(nameof(container));
|
|
||||||
_gasmanRepository = gasmanRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(gasmanRepository));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormGasman>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIDFromSelectedRow(out var findID))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_gasmanRepository.DeleteGasman(findID);
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка удаления", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIDFromSelectedRow(out var findID))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormGasman>();
|
|
||||||
form.ID = findID;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormGasmen_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _gasmanRepository.ReadGasman();
|
|
||||||
|
|
||||||
private bool TryGetIDFromSelectedRow(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
122
GasStation/Forms/FormProduct.Designer.cs
generated
122
GasStation/Forms/FormProduct.Designer.cs
generated
@ -1,122 +0,0 @@
|
|||||||
namespace GasStation.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()
|
|
||||||
{
|
|
||||||
label2 = new Label();
|
|
||||||
label3 = new Label();
|
|
||||||
numericUpDownCost = new NumericUpDown();
|
|
||||||
comboBoxProduct = new ComboBox();
|
|
||||||
buttonSave = new Button();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownCost).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(33, 29);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(39, 15);
|
|
||||||
label2.TabIndex = 1;
|
|
||||||
label2.Text = "Товар";
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
label3.AutoSize = true;
|
|
||||||
label3.Location = new Point(33, 99);
|
|
||||||
label3.Name = "label3";
|
|
||||||
label3.Size = new Size(67, 15);
|
|
||||||
label3.TabIndex = 2;
|
|
||||||
label3.Text = "Стоимость";
|
|
||||||
//
|
|
||||||
// numericUpDownCost
|
|
||||||
//
|
|
||||||
numericUpDownCost.Location = new Point(178, 99);
|
|
||||||
numericUpDownCost.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
numericUpDownCost.Name = "numericUpDownCost";
|
|
||||||
numericUpDownCost.Size = new Size(169, 23);
|
|
||||||
numericUpDownCost.TabIndex = 3;
|
|
||||||
numericUpDownCost.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// comboBoxProduct
|
|
||||||
//
|
|
||||||
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxProduct.FormattingEnabled = true;
|
|
||||||
comboBoxProduct.Location = new Point(179, 29);
|
|
||||||
comboBoxProduct.Name = "comboBoxProduct";
|
|
||||||
comboBoxProduct.Size = new Size(168, 23);
|
|
||||||
comboBoxProduct.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
buttonSave.Location = new Point(33, 166);
|
|
||||||
buttonSave.Name = "buttonSave";
|
|
||||||
buttonSave.Size = new Size(88, 25);
|
|
||||||
buttonSave.TabIndex = 6;
|
|
||||||
buttonSave.Text = "Сохранить";
|
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonSave.Click += ButtonSave_Click;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Location = new Point(254, 166);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(93, 25);
|
|
||||||
buttonCancel.TabIndex = 7;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
|
||||||
//
|
|
||||||
// FormProduct
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(414, 246);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonSave);
|
|
||||||
Controls.Add(comboBoxProduct);
|
|
||||||
Controls.Add(numericUpDownCost);
|
|
||||||
Controls.Add(label3);
|
|
||||||
Controls.Add(label2);
|
|
||||||
Name = "FormProduct";
|
|
||||||
Text = "Товар";
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownCost).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
private Label label2;
|
|
||||||
private Label label3;
|
|
||||||
private NumericUpDown numericUpDownCost;
|
|
||||||
private ComboBox comboBoxProduct;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,77 +0,0 @@
|
|||||||
using GasStation.Entities.Enums;
|
|
||||||
using GasStation.Repositories;
|
|
||||||
using GasStation.Entities;
|
|
||||||
|
|
||||||
namespace GasStation.Forms;
|
|
||||||
|
|
||||||
public partial class FormProduct : Form
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly IProductRepository _productRepository;
|
|
||||||
|
|
||||||
private int? _productId;
|
|
||||||
|
|
||||||
public FormProduct(IProductRepository productRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_productRepository = productRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(productRepository));
|
|
||||||
|
|
||||||
comboBoxProduct.DataSource = Enum.GetValues(typeof(ProductType));
|
|
||||||
}
|
|
||||||
|
|
||||||
public int ID
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var product = _productRepository.ReadProductByID(value);
|
|
||||||
if (product == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(product));
|
|
||||||
}
|
|
||||||
|
|
||||||
comboBoxProduct.SelectedItem = product.ProductType;
|
|
||||||
_productId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (comboBoxProduct.SelectedIndex < 1)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненые поля");
|
|
||||||
}
|
|
||||||
if (_productId.HasValue)
|
|
||||||
{
|
|
||||||
_productRepository.UpdateProduct(CreateProduct(_productId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_productRepository.CreateProduct(CreateProduct(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private Product CreateProduct(int id) =>
|
|
||||||
Product.CreateProduct(id, Convert.ToInt32(numericUpDownCost.Value),
|
|
||||||
(ProductType)comboBoxProduct.SelectedItem!);
|
|
||||||
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
162
GasStation/Forms/FormProductReport.Designer.cs
generated
162
GasStation/Forms/FormProductReport.Designer.cs
generated
@ -1,162 +0,0 @@
|
|||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
partial class FormProductReport
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
dateTimePickerEnd = new DateTimePicker();
|
|
||||||
dateTimePickerBegin = new DateTimePicker();
|
|
||||||
label1 = new Label();
|
|
||||||
label2 = new Label();
|
|
||||||
label3 = new Label();
|
|
||||||
label4 = new Label();
|
|
||||||
buttonMakeReport = new Button();
|
|
||||||
comboBoxProduct = new ComboBox();
|
|
||||||
buttonSelectFilePath = new Button();
|
|
||||||
textBoxFilePath = new TextBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// dateTimePickerEnd
|
|
||||||
//
|
|
||||||
dateTimePickerEnd.Location = new Point(176, 221);
|
|
||||||
dateTimePickerEnd.Name = "dateTimePickerEnd";
|
|
||||||
dateTimePickerEnd.Size = new Size(200, 23);
|
|
||||||
dateTimePickerEnd.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// dateTimePickerBegin
|
|
||||||
//
|
|
||||||
dateTimePickerBegin.Location = new Point(176, 156);
|
|
||||||
dateTimePickerBegin.Name = "dateTimePickerBegin";
|
|
||||||
dateTimePickerBegin.Size = new Size(200, 23);
|
|
||||||
dateTimePickerBegin.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(51, 156);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(74, 15);
|
|
||||||
label1.TabIndex = 2;
|
|
||||||
label1.Text = "Дата начала";
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(51, 221);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(68, 15);
|
|
||||||
label2.TabIndex = 3;
|
|
||||||
label2.Text = "Дата конца";
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
label3.AutoSize = true;
|
|
||||||
label3.Location = new Point(51, 99);
|
|
||||||
label3.Name = "label3";
|
|
||||||
label3.Size = new Size(39, 15);
|
|
||||||
label3.TabIndex = 4;
|
|
||||||
label3.Text = "Товар";
|
|
||||||
//
|
|
||||||
// label4
|
|
||||||
//
|
|
||||||
label4.AutoSize = true;
|
|
||||||
label4.Location = new Point(51, 42);
|
|
||||||
label4.Name = "label4";
|
|
||||||
label4.Size = new Size(87, 15);
|
|
||||||
label4.TabIndex = 5;
|
|
||||||
label4.Text = "Путь до файла";
|
|
||||||
//
|
|
||||||
// buttonMakeReport
|
|
||||||
//
|
|
||||||
buttonMakeReport.Location = new Point(162, 290);
|
|
||||||
buttonMakeReport.Name = "buttonMakeReport";
|
|
||||||
buttonMakeReport.Size = new Size(114, 23);
|
|
||||||
buttonMakeReport.TabIndex = 6;
|
|
||||||
buttonMakeReport.Text = "Сформировать";
|
|
||||||
buttonMakeReport.UseVisualStyleBackColor = true;
|
|
||||||
buttonMakeReport.Click += ButtonMakeReport_Click;
|
|
||||||
//
|
|
||||||
// comboBoxProduct
|
|
||||||
//
|
|
||||||
comboBoxProduct.FormattingEnabled = true;
|
|
||||||
comboBoxProduct.Location = new Point(176, 96);
|
|
||||||
comboBoxProduct.Name = "comboBoxProduct";
|
|
||||||
comboBoxProduct.Size = new Size(200, 23);
|
|
||||||
comboBoxProduct.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonSelectFilePath
|
|
||||||
//
|
|
||||||
buttonSelectFilePath.Location = new Point(337, 39);
|
|
||||||
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
|
||||||
buttonSelectFilePath.Size = new Size(39, 23);
|
|
||||||
buttonSelectFilePath.TabIndex = 8;
|
|
||||||
buttonSelectFilePath.Text = "...";
|
|
||||||
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
|
||||||
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
|
||||||
//
|
|
||||||
// textBoxFilePath
|
|
||||||
//
|
|
||||||
textBoxFilePath.Location = new Point(176, 39);
|
|
||||||
textBoxFilePath.Name = "textBoxFilePath";
|
|
||||||
textBoxFilePath.Size = new Size(155, 23);
|
|
||||||
textBoxFilePath.TabIndex = 9;
|
|
||||||
//
|
|
||||||
// FormProductReport
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(484, 370);
|
|
||||||
Controls.Add(textBoxFilePath);
|
|
||||||
Controls.Add(buttonSelectFilePath);
|
|
||||||
Controls.Add(comboBoxProduct);
|
|
||||||
Controls.Add(buttonMakeReport);
|
|
||||||
Controls.Add(label4);
|
|
||||||
Controls.Add(label3);
|
|
||||||
Controls.Add(label2);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Controls.Add(dateTimePickerBegin);
|
|
||||||
Controls.Add(dateTimePickerEnd);
|
|
||||||
Name = "FormProductReport";
|
|
||||||
Text = "FormProductReport";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DateTimePicker dateTimePickerEnd;
|
|
||||||
private DateTimePicker dateTimePickerBegin;
|
|
||||||
private Label label1;
|
|
||||||
private Label label2;
|
|
||||||
private Label label3;
|
|
||||||
private Label label4;
|
|
||||||
private Button buttonMakeReport;
|
|
||||||
private ComboBox comboBoxProduct;
|
|
||||||
private Button buttonSelectFilePath;
|
|
||||||
private TextBox textBoxFilePath;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,74 +0,0 @@
|
|||||||
using GasStation.Reports;
|
|
||||||
using GasStation.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
public partial class FormProductReport : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
public FormProductReport(IUnityContainer container, IProductRepository productRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ??
|
|
||||||
throw new ArgumentNullException(nameof(container));
|
|
||||||
comboBoxProduct.DataSource = productRepository.ReadProduct();
|
|
||||||
comboBoxProduct.DisplayMember = "ProductType";
|
|
||||||
comboBoxProduct.ValueMember = "Id";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSelectFilePath_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var sfd = new SaveFileDialog()
|
|
||||||
{
|
|
||||||
Filter = "Excel Files | *.xlsx"
|
|
||||||
};
|
|
||||||
if (sfd.ShowDialog() != DialogResult.OK)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
textBoxFilePath.Text = sfd.FileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonMakeReport_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
|
||||||
{
|
|
||||||
throw new Exception("Отсутствует имя файла для отчета");
|
|
||||||
}
|
|
||||||
if (comboBoxProduct.SelectedIndex < 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Не выбран товар");
|
|
||||||
}
|
|
||||||
if (dateTimePickerEnd.Value <= dateTimePickerBegin.Value)
|
|
||||||
{
|
|
||||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
|
||||||
}
|
|
||||||
if
|
|
||||||
(_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxProduct.SelectedValue!,
|
|
||||||
dateTimePickerBegin.Value, dateTimePickerEnd.Value))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Документ сформирован",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
122
GasStation/Forms/FormProducts.Designer.cs
generated
122
GasStation/Forms/FormProducts.Designer.cs
generated
@ -1,122 +0,0 @@
|
|||||||
namespace GasStation.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()
|
|
||||||
{
|
|
||||||
panel1 = new Panel();
|
|
||||||
buttonUpd = new Button();
|
|
||||||
buttonDel = new Button();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
dataGridViewData = new DataGridView();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(buttonUpd);
|
|
||||||
panel1.Controls.Add(buttonDel);
|
|
||||||
panel1.Controls.Add(buttonAdd);
|
|
||||||
panel1.Dock = DockStyle.Right;
|
|
||||||
panel1.Location = new Point(657, 0);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(143, 450);
|
|
||||||
panel1.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// buttonUpd
|
|
||||||
//
|
|
||||||
buttonUpd.Location = new Point(35, 343);
|
|
||||||
buttonUpd.Name = "buttonUpd";
|
|
||||||
buttonUpd.Size = new Size(75, 69);
|
|
||||||
buttonUpd.TabIndex = 3;
|
|
||||||
buttonUpd.Text = "Редактировать";
|
|
||||||
buttonUpd.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpd.Click += ButtonUpd_Click;
|
|
||||||
//
|
|
||||||
// buttonDel
|
|
||||||
//
|
|
||||||
buttonDel.Location = new Point(33, 188);
|
|
||||||
buttonDel.Name = "buttonDel";
|
|
||||||
buttonDel.Size = new Size(77, 73);
|
|
||||||
buttonDel.TabIndex = 2;
|
|
||||||
buttonDel.Text = "Удалить";
|
|
||||||
buttonDel.UseVisualStyleBackColor = true;
|
|
||||||
buttonDel.Click += ButtonDel_Click;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.Location = new Point(32, 30);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(75, 73);
|
|
||||||
buttonAdd.TabIndex = 1;
|
|
||||||
buttonAdd.Text = "Добавить";
|
|
||||||
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewData.Size = new Size(657, 450);
|
|
||||||
dataGridViewData.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// FormProducts
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Name = "FormProducts";
|
|
||||||
Text = "Товары";
|
|
||||||
Load += FormProducts_Load;
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Panel panel1;
|
|
||||||
private Button buttonUpd;
|
|
||||||
private Button buttonDel;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridViewData;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
using GasStation.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace GasStation.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 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 (!TryGetIDFromSelectedRow(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 (!TryGetIDFromSelectedRow(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 bool TryGetIDFromSelectedRow(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void FormProducts_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _productRepository.ReadProduct();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
151
GasStation/Forms/FormSelling.Designer.cs
generated
151
GasStation/Forms/FormSelling.Designer.cs
generated
@ -1,151 +0,0 @@
|
|||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
partial class FormSelling
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
label1 = new Label();
|
|
||||||
comboBoxGasman = new ComboBox();
|
|
||||||
buttonSave = new Button();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
groupBoxSelling = new GroupBox();
|
|
||||||
dataGridViewSelling = new DataGridView();
|
|
||||||
ColumnProduct = new DataGridViewComboBoxColumn();
|
|
||||||
ColumnCount = new DataGridViewTextBoxColumn();
|
|
||||||
groupBoxSelling.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewSelling).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(47, 35);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(70, 15);
|
|
||||||
label1.TabIndex = 0;
|
|
||||||
label1.Text = "Заправщик";
|
|
||||||
//
|
|
||||||
// comboBoxGasman
|
|
||||||
//
|
|
||||||
comboBoxGasman.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxGasman.FormattingEnabled = true;
|
|
||||||
comboBoxGasman.Location = new Point(147, 35);
|
|
||||||
comboBoxGasman.Name = "comboBoxGasman";
|
|
||||||
comboBoxGasman.Size = new Size(200, 23);
|
|
||||||
comboBoxGasman.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonSave.Location = new Point(47, 358);
|
|
||||||
buttonSave.Name = "buttonSave";
|
|
||||||
buttonSave.Size = new Size(75, 23);
|
|
||||||
buttonSave.TabIndex = 6;
|
|
||||||
buttonSave.Text = "Сохранить";
|
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonSave.Click += ButtonSave_Click;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonCancel.Location = new Point(279, 358);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(75, 23);
|
|
||||||
buttonCancel.TabIndex = 7;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
|
||||||
//
|
|
||||||
// groupBoxSelling
|
|
||||||
//
|
|
||||||
groupBoxSelling.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
groupBoxSelling.Controls.Add(dataGridViewSelling);
|
|
||||||
groupBoxSelling.Location = new Point(47, 91);
|
|
||||||
groupBoxSelling.Name = "groupBoxSelling";
|
|
||||||
groupBoxSelling.Size = new Size(307, 211);
|
|
||||||
groupBoxSelling.TabIndex = 8;
|
|
||||||
groupBoxSelling.TabStop = false;
|
|
||||||
groupBoxSelling.Text = "Продажа";
|
|
||||||
//
|
|
||||||
// dataGridViewSelling
|
|
||||||
//
|
|
||||||
dataGridViewSelling.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewSelling.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewSelling.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewSelling.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewSelling.Columns.AddRange(new DataGridViewColumn[] { ColumnProduct, ColumnCount });
|
|
||||||
dataGridViewSelling.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewSelling.Location = new Point(3, 19);
|
|
||||||
dataGridViewSelling.MultiSelect = false;
|
|
||||||
dataGridViewSelling.Name = "dataGridViewSelling";
|
|
||||||
dataGridViewSelling.RowHeadersVisible = false;
|
|
||||||
dataGridViewSelling.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewSelling.Size = new Size(301, 189);
|
|
||||||
dataGridViewSelling.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ColumnProduct
|
|
||||||
//
|
|
||||||
ColumnProduct.HeaderText = "Товар";
|
|
||||||
ColumnProduct.Name = "ColumnProduct";
|
|
||||||
ColumnProduct.Resizable = DataGridViewTriState.True;
|
|
||||||
ColumnProduct.SortMode = DataGridViewColumnSortMode.Automatic;
|
|
||||||
//
|
|
||||||
// ColumnCount
|
|
||||||
//
|
|
||||||
ColumnCount.HeaderText = "Количество";
|
|
||||||
ColumnCount.Name = "ColumnCount";
|
|
||||||
//
|
|
||||||
// FormSelling
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(458, 432);
|
|
||||||
Controls.Add(groupBoxSelling);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonSave);
|
|
||||||
Controls.Add(comboBoxGasman);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Name = "FormSelling";
|
|
||||||
Text = "Продажа";
|
|
||||||
groupBoxSelling.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewSelling).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private ComboBox comboBoxGasman;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private GroupBox groupBoxSelling;
|
|
||||||
private DataGridView dataGridViewSelling;
|
|
||||||
private DataGridViewComboBoxColumn ColumnProduct;
|
|
||||||
private DataGridViewTextBoxColumn ColumnCount;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,68 +0,0 @@
|
|||||||
using GasStation.Entities;
|
|
||||||
using GasStation.Repositories;
|
|
||||||
|
|
||||||
|
|
||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
public partial class FormSelling : Form
|
|
||||||
{
|
|
||||||
private readonly ISellingRepository _sellingRepository;
|
|
||||||
|
|
||||||
public FormSelling(ISellingRepository sellingRepository, IGasmanRepository gasmanRepository, IProductRepository productRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_sellingRepository = sellingRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(sellingRepository));
|
|
||||||
|
|
||||||
comboBoxGasman.DataSource = gasmanRepository.ReadGasman();
|
|
||||||
comboBoxGasman.DisplayMember = "GasmanName";
|
|
||||||
comboBoxGasman.ValueMember = "ID";
|
|
||||||
|
|
||||||
ColumnProduct.DataSource = productRepository.ReadProduct();
|
|
||||||
ColumnProduct.DisplayMember = "ProductType";
|
|
||||||
ColumnProduct.ValueMember = "ID";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (comboBoxGasman.SelectedIndex < 0 ||
|
|
||||||
dataGridViewSelling.RowCount < 1)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненые поля");
|
|
||||||
}
|
|
||||||
|
|
||||||
_sellingRepository.CreateSelling(Selling.CreateSelling(0, (int)comboBoxGasman.SelectedValue!, CreateProductSellingsFromDataGrid()));
|
|
||||||
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private List<ProductSelling> CreateProductSellingsFromDataGrid()
|
|
||||||
{
|
|
||||||
var list = new List<ProductSelling>();
|
|
||||||
foreach (DataGridViewRow row in dataGridViewSelling.Rows)
|
|
||||||
{
|
|
||||||
if (row.Cells["ColumnProduct"].Value == null || row.Cells["ColumnCount"].Value == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
list.Add(ProductSelling.CreateSelling(0, Convert.ToInt32(row.Cells["ColumnProduct"].Value),
|
|
||||||
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
|
||||||
}
|
|
||||||
|
|
||||||
return list.GroupBy(x => x.ProductID, x => x.Count, (id, counts) => ProductSelling.CreateSelling(0, id,counts.Sum())).ToList();
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,132 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<metadata name="ColumnProduct.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnCount.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="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
96
GasStation/Forms/FormSellings.Designer.cs
generated
96
GasStation/Forms/FormSellings.Designer.cs
generated
@ -1,96 +0,0 @@
|
|||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
partial class FormSellings
|
|
||||||
{
|
|
||||||
/// <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();
|
|
||||||
dataGridViewData = new DataGridView();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(buttonAdd);
|
|
||||||
panel1.Dock = DockStyle.Right;
|
|
||||||
panel1.Location = new Point(657, 0);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(143, 450);
|
|
||||||
panel1.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.Location = new Point(35, 166);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(75, 73);
|
|
||||||
buttonAdd.TabIndex = 1;
|
|
||||||
buttonAdd.Text = "Добавить";
|
|
||||||
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewData.Size = new Size(657, 450);
|
|
||||||
dataGridViewData.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// FormSellings
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Name = "FormSellings";
|
|
||||||
Text = "Продажи";
|
|
||||||
Load += FormSellings_Load;
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Panel panel1;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridViewData;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
using GasStation.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
public partial class FormSellings : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
private readonly ISellingRepository _sellingRepository;
|
|
||||||
|
|
||||||
public FormSellings(IUnityContainer container, ISellingRepository sellingRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ??
|
|
||||||
throw new ArgumentNullException(nameof(container));
|
|
||||||
_sellingRepository = sellingRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(sellingRepository));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormSelling>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _sellingRepository.ReadSelling();
|
|
||||||
|
|
||||||
private void FormSellings_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
95
GasStation/Forms/FormSupplier.Designer.cs
generated
95
GasStation/Forms/FormSupplier.Designer.cs
generated
@ -1,95 +0,0 @@
|
|||||||
namespace GasStation.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()
|
|
||||||
{
|
|
||||||
labelSupplier = new Label();
|
|
||||||
buttonSave = new Button();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
textBoxSupplier = new TextBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// labelSupplier
|
|
||||||
//
|
|
||||||
labelSupplier.AutoSize = true;
|
|
||||||
labelSupplier.Location = new Point(12, 15);
|
|
||||||
labelSupplier.Name = "labelSupplier";
|
|
||||||
labelSupplier.Size = new Size(70, 15);
|
|
||||||
labelSupplier.TabIndex = 1;
|
|
||||||
labelSupplier.Text = "Поставщик";
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
buttonSave.Location = new Point(100, 52);
|
|
||||||
buttonSave.Name = "buttonSave";
|
|
||||||
buttonSave.Size = new Size(75, 23);
|
|
||||||
buttonSave.TabIndex = 2;
|
|
||||||
buttonSave.Text = "Сохранить";
|
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonSave.Click += ButtonSave_Click;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Location = new Point(315, 52);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(75, 23);
|
|
||||||
buttonCancel.TabIndex = 3;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
|
||||||
//
|
|
||||||
// textBoxSupplier
|
|
||||||
//
|
|
||||||
textBoxSupplier.Location = new Point(112, 9);
|
|
||||||
textBoxSupplier.Name = "textBoxSupplier";
|
|
||||||
textBoxSupplier.Size = new Size(278, 23);
|
|
||||||
textBoxSupplier.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// FormSupplier
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(438, 122);
|
|
||||||
Controls.Add(textBoxSupplier);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonSave);
|
|
||||||
Controls.Add(labelSupplier);
|
|
||||||
Name = "FormSupplier";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "FormSupplier";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
private Label labelSupplier;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private TextBox textBoxSupplier;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,71 +0,0 @@
|
|||||||
using GasStation.Entities;
|
|
||||||
using GasStation.Repositories;
|
|
||||||
|
|
||||||
namespace GasStation.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));
|
|
||||||
}
|
|
||||||
|
|
||||||
textBoxSupplier.Text = supplier.SupplierName;
|
|
||||||
_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 (textBoxSupplier.Text == "")
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненые поля");
|
|
||||||
}
|
|
||||||
if (_supplierId.HasValue)
|
|
||||||
{
|
|
||||||
_supplierRepository.UpdateSupplier(CreateSupplier(_supplierId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_supplierRepository.CreateSupplier(CreateSupplier(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Supplier CreateSupplier(int id) => Supplier.CreateSupplier(id, textBoxSupplier.Text);
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
123
GasStation/Forms/FormSuppliers.Designer.cs
generated
123
GasStation/Forms/FormSuppliers.Designer.cs
generated
@ -1,123 +0,0 @@
|
|||||||
namespace GasStation.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()
|
|
||||||
{
|
|
||||||
panel1 = new Panel();
|
|
||||||
buttonUpd = new Button();
|
|
||||||
buttonDel = new Button();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
dataGridViewData = new DataGridView();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(buttonUpd);
|
|
||||||
panel1.Controls.Add(buttonDel);
|
|
||||||
panel1.Controls.Add(buttonAdd);
|
|
||||||
panel1.Dock = DockStyle.Right;
|
|
||||||
panel1.Location = new Point(631, 0);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(170, 477);
|
|
||||||
panel1.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonUpd
|
|
||||||
//
|
|
||||||
buttonUpd.Location = new Point(47, 324);
|
|
||||||
buttonUpd.Name = "buttonUpd";
|
|
||||||
buttonUpd.Size = new Size(75, 69);
|
|
||||||
buttonUpd.TabIndex = 2;
|
|
||||||
buttonUpd.Text = "Редактировать";
|
|
||||||
buttonUpd.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpd.Click += ButtonUpd_Click;
|
|
||||||
//
|
|
||||||
// buttonDel
|
|
||||||
//
|
|
||||||
buttonDel.Location = new Point(45, 178);
|
|
||||||
buttonDel.Name = "buttonDel";
|
|
||||||
buttonDel.Size = new Size(77, 73);
|
|
||||||
buttonDel.TabIndex = 1;
|
|
||||||
buttonDel.Text = "Удалить";
|
|
||||||
buttonDel.UseVisualStyleBackColor = true;
|
|
||||||
buttonDel.Click += ButtonDel_Click;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.Location = new Point(47, 41);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(75, 73);
|
|
||||||
buttonAdd.TabIndex = 0;
|
|
||||||
buttonAdd.Text = "Добавить";
|
|
||||||
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewData.Size = new Size(631, 477);
|
|
||||||
dataGridViewData.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// FormSuppliers
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(801, 477);
|
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Name = "FormSuppliers";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "Поставщики";
|
|
||||||
Load += FormSuppliers_Load;
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Panel panel1;
|
|
||||||
private Button buttonUpd;
|
|
||||||
private Button buttonDel;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridViewData;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
using GasStation.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace GasStation.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 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 (!TryGetIDFromSelectedRow(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 (!TryGetIDFromSelectedRow(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 FormSuppliers_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _supplierRepository.ReadSupplier();
|
|
||||||
|
|
||||||
private bool TryGetIDFromSelectedRow(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
108
GasStation/Forms/FormSupplies.Designer.cs
generated
108
GasStation/Forms/FormSupplies.Designer.cs
generated
@ -1,108 +0,0 @@
|
|||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
partial class FormSupplies
|
|
||||||
{
|
|
||||||
/// <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();
|
|
||||||
buttonDel = new Button();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
dataGridViewData = new DataGridView();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(buttonDel);
|
|
||||||
panel1.Controls.Add(buttonAdd);
|
|
||||||
panel1.Dock = DockStyle.Right;
|
|
||||||
panel1.Location = new Point(630, 0);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(170, 450);
|
|
||||||
panel1.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// buttonDel
|
|
||||||
//
|
|
||||||
buttonDel.Location = new Point(45, 296);
|
|
||||||
buttonDel.Name = "buttonDel";
|
|
||||||
buttonDel.Size = new Size(77, 73);
|
|
||||||
buttonDel.TabIndex = 1;
|
|
||||||
buttonDel.Text = "Удалить";
|
|
||||||
buttonDel.UseVisualStyleBackColor = true;
|
|
||||||
buttonDel.Click += ButtonDel_Click;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.Location = new Point(47, 41);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(75, 73);
|
|
||||||
buttonAdd.TabIndex = 0;
|
|
||||||
buttonAdd.Text = "Добавить";
|
|
||||||
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.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewData.Size = new Size(630, 450);
|
|
||||||
dataGridViewData.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// FormSupplies
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Name = "FormSupplies";
|
|
||||||
Load += FormSupplies_Load;
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Panel panel1;
|
|
||||||
private Button buttonDel;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridViewData;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,84 +0,0 @@
|
|||||||
using GasStation.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
public partial class FormSupplies : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
private readonly ISupplyRepository _supplyRepository;
|
|
||||||
|
|
||||||
public FormSupplies(IUnityContainer container, ISupplyRepository supplyRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ??
|
|
||||||
throw new ArgumentNullException(nameof(container));
|
|
||||||
_supplyRepository = supplyRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(supplyRepository));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormSupply>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIDFromSelectedRow(out var findID))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_supplyRepository.DeleteSupply(findID);
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка удаления", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _supplyRepository.ReadSupply();
|
|
||||||
|
|
||||||
private void FormSupplies_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool TryGetIDFromSelectedRow(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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
149
GasStation/Forms/FormSupply.Designer.cs
generated
149
GasStation/Forms/FormSupply.Designer.cs
generated
@ -1,149 +0,0 @@
|
|||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
partial class FormSupply
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
buttonSave = new Button();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
labelSupplier = new Label();
|
|
||||||
comboBoxSupplier = new ComboBox();
|
|
||||||
label1 = new Label();
|
|
||||||
numericUpDownCount = new NumericUpDown();
|
|
||||||
label2 = new Label();
|
|
||||||
comboBoxProduct = new ComboBox();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonSave.Location = new Point(21, 236);
|
|
||||||
buttonSave.Name = "buttonSave";
|
|
||||||
buttonSave.Size = new Size(89, 24);
|
|
||||||
buttonSave.TabIndex = 1;
|
|
||||||
buttonSave.Text = "Сохранить";
|
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonSave.Click += ButtonSave_Click;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonCancel.Location = new Point(221, 236);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(92, 24);
|
|
||||||
buttonCancel.TabIndex = 2;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
|
||||||
//
|
|
||||||
// labelSupplier
|
|
||||||
//
|
|
||||||
labelSupplier.AutoSize = true;
|
|
||||||
labelSupplier.Location = new Point(21, 23);
|
|
||||||
labelSupplier.Name = "labelSupplier";
|
|
||||||
labelSupplier.Size = new Size(70, 15);
|
|
||||||
labelSupplier.TabIndex = 5;
|
|
||||||
labelSupplier.Text = "Поставщик";
|
|
||||||
//
|
|
||||||
// comboBoxSupplier
|
|
||||||
//
|
|
||||||
comboBoxSupplier.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxSupplier.FormattingEnabled = true;
|
|
||||||
comboBoxSupplier.Location = new Point(97, 23);
|
|
||||||
comboBoxSupplier.Name = "comboBoxSupplier";
|
|
||||||
comboBoxSupplier.Size = new Size(216, 23);
|
|
||||||
comboBoxSupplier.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(21, 91);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(66, 15);
|
|
||||||
label1.TabIndex = 8;
|
|
||||||
label1.Text = "Количесто";
|
|
||||||
//
|
|
||||||
// numericUpDownCount
|
|
||||||
//
|
|
||||||
numericUpDownCount.Location = new Point(97, 89);
|
|
||||||
numericUpDownCount.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
numericUpDownCount.Name = "numericUpDownCount";
|
|
||||||
numericUpDownCount.Size = new Size(216, 23);
|
|
||||||
numericUpDownCount.TabIndex = 9;
|
|
||||||
numericUpDownCount.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(21, 147);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(39, 15);
|
|
||||||
label2.TabIndex = 10;
|
|
||||||
label2.Text = "Товар";
|
|
||||||
//
|
|
||||||
// comboBoxProduct
|
|
||||||
//
|
|
||||||
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxProduct.FormattingEnabled = true;
|
|
||||||
comboBoxProduct.Location = new Point(96, 147);
|
|
||||||
comboBoxProduct.Name = "comboBoxProduct";
|
|
||||||
comboBoxProduct.Size = new Size(217, 23);
|
|
||||||
comboBoxProduct.TabIndex = 11;
|
|
||||||
//
|
|
||||||
// FormSupply
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(435, 326);
|
|
||||||
Controls.Add(comboBoxProduct);
|
|
||||||
Controls.Add(label2);
|
|
||||||
Controls.Add(numericUpDownCount);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Controls.Add(comboBoxSupplier);
|
|
||||||
Controls.Add(labelSupplier);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonSave);
|
|
||||||
Name = "FormSupply";
|
|
||||||
Text = "Поставки";
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Label labelSupplier;
|
|
||||||
private ComboBox comboBoxSupplier;
|
|
||||||
private Label label1;
|
|
||||||
private NumericUpDown numericUpDownCount;
|
|
||||||
private Label label2;
|
|
||||||
private ComboBox comboBoxProduct;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,50 +0,0 @@
|
|||||||
using GasStation.Repositories;
|
|
||||||
using GasStation.Entities;
|
|
||||||
|
|
||||||
namespace GasStation.Forms
|
|
||||||
{
|
|
||||||
public partial class FormSupply : Form
|
|
||||||
{
|
|
||||||
private readonly ISupplyRepository _supplyRepository;
|
|
||||||
|
|
||||||
public FormSupply(ISupplyRepository supplyRepository, ISupplierRepository supplierRepository, IProductRepository productRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_supplyRepository = supplyRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(supplyRepository));
|
|
||||||
|
|
||||||
comboBoxSupplier.DataSource = supplierRepository.ReadSupplier();
|
|
||||||
comboBoxSupplier.DisplayMember = "SupplierName";
|
|
||||||
comboBoxSupplier.ValueMember = "ID";
|
|
||||||
|
|
||||||
comboBoxProduct.DataSource = productRepository.ReadProduct();
|
|
||||||
comboBoxProduct.DisplayMember = "ProductType";
|
|
||||||
comboBoxProduct.ValueMember = "ID";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (comboBoxProduct.SelectedIndex < 0 ||
|
|
||||||
comboBoxSupplier.SelectedIndex < 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненые поля");
|
|
||||||
}
|
|
||||||
|
|
||||||
_supplyRepository.CreateSupply(Supply.CreateSupply(0, (int)comboBoxSupplier.SelectedValue!,
|
|
||||||
(int)comboBoxProduct.SelectedValue!, Convert.ToInt32(numericUpDownCount.Value)));
|
|
||||||
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
107
GasStation/Forms/FormSupplyDistRep.Designer.cs
generated
107
GasStation/Forms/FormSupplyDistRep.Designer.cs
generated
@ -1,107 +0,0 @@
|
|||||||
namespace GasStation.Reports
|
|
||||||
{
|
|
||||||
partial class FormSupplyDistRep
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
buttonSelectFileName = new Button();
|
|
||||||
buttonCreate = new Button();
|
|
||||||
dateTimePicker = new DateTimePicker();
|
|
||||||
label1 = new Label();
|
|
||||||
labelFileName = new Label();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonSelectFileName
|
|
||||||
//
|
|
||||||
buttonSelectFileName.Location = new Point(37, 42);
|
|
||||||
buttonSelectFileName.Name = "buttonSelectFileName";
|
|
||||||
buttonSelectFileName.Size = new Size(75, 23);
|
|
||||||
buttonSelectFileName.TabIndex = 0;
|
|
||||||
buttonSelectFileName.Text = "Выбрать";
|
|
||||||
buttonSelectFileName.UseVisualStyleBackColor = true;
|
|
||||||
buttonSelectFileName.Click += ButtonSelectFileName_Click;
|
|
||||||
//
|
|
||||||
// buttonCreate
|
|
||||||
//
|
|
||||||
buttonCreate.Location = new Point(92, 143);
|
|
||||||
buttonCreate.Name = "buttonCreate";
|
|
||||||
buttonCreate.Size = new Size(124, 25);
|
|
||||||
buttonCreate.TabIndex = 1;
|
|
||||||
buttonCreate.Text = "Сформировать";
|
|
||||||
buttonCreate.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreate.Click += ButtonCreate_Click;
|
|
||||||
//
|
|
||||||
// dateTimePicker
|
|
||||||
//
|
|
||||||
dateTimePicker.Location = new Point(92, 86);
|
|
||||||
dateTimePicker.Name = "dateTimePicker";
|
|
||||||
dateTimePicker.Size = new Size(213, 23);
|
|
||||||
dateTimePicker.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(37, 86);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(32, 15);
|
|
||||||
label1.TabIndex = 3;
|
|
||||||
label1.Text = "Дата";
|
|
||||||
//
|
|
||||||
// labelFileName
|
|
||||||
//
|
|
||||||
labelFileName.AutoSize = true;
|
|
||||||
labelFileName.Location = new Point(150, 50);
|
|
||||||
labelFileName.Name = "labelFileName";
|
|
||||||
labelFileName.Size = new Size(36, 15);
|
|
||||||
labelFileName.TabIndex = 4;
|
|
||||||
labelFileName.Text = "Файл";
|
|
||||||
//
|
|
||||||
// FormSupplyDistRep
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(343, 218);
|
|
||||||
Controls.Add(labelFileName);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Controls.Add(dateTimePicker);
|
|
||||||
Controls.Add(buttonCreate);
|
|
||||||
Controls.Add(buttonSelectFileName);
|
|
||||||
Name = "FormSupplyDistRep";
|
|
||||||
Text = "Поступление товара";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonSelectFileName;
|
|
||||||
private Button buttonCreate;
|
|
||||||
private DateTimePicker dateTimePicker;
|
|
||||||
private Label label1;
|
|
||||||
private Label labelFileName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
using Unity;
|
|
||||||
|
|
||||||
namespace GasStation.Reports;
|
|
||||||
|
|
||||||
public partial class FormSupplyDistRep : Form
|
|
||||||
{
|
|
||||||
private string _fileName = string.Empty;
|
|
||||||
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
public FormSupplyDistRep(IUnityContainer container)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSelectFileName_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var sfd = new SaveFileDialog()
|
|
||||||
{
|
|
||||||
Filter = "Pdf Files | *.pdf"
|
|
||||||
};
|
|
||||||
if (sfd.ShowDialog() == DialogResult.OK)
|
|
||||||
{
|
|
||||||
_fileName = sfd.FileName;
|
|
||||||
labelFileName.Text = Path.GetFileName(_fileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(_fileName))
|
|
||||||
{
|
|
||||||
throw new Exception("Отсутствует имя файла для отчета");
|
|
||||||
}
|
|
||||||
if
|
|
||||||
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.Value))
|
|
||||||
{
|
|
||||||
MessageBox.Show("Документ сформирован",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK,
|
|
||||||
MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
|
||||||
"Формирование документа",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,120 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<root>
|
|
||||||
<!--
|
|
||||||
Microsoft ResX Schema
|
|
||||||
|
|
||||||
Version 2.0
|
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
|
||||||
that is mostly human readable. The generation and parsing of the
|
|
||||||
various data types are done through the TypeConverter classes
|
|
||||||
associated with the data types.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
|
||||||
<resheader name="version">2.0</resheader>
|
|
||||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
|
||||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
|
||||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
|
||||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
|
||||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
|
||||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
|
||||||
</data>
|
|
||||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
|
||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
|
||||||
<comment>This is a comment</comment>
|
|
||||||
</data>
|
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
|
||||||
name/value pairs.
|
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
|
||||||
text/value conversion through the TypeConverter architecture.
|
|
||||||
Classes that don't support this are serialized and stored with the
|
|
||||||
mimetype set.
|
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
|
||||||
read any of the formats listed below.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
|
||||||
value : The object must be serialized with
|
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
|
||||||
value : The object must be serialized into a byte array
|
|
||||||
: using a System.ComponentModel.TypeConverter
|
|
||||||
: and then encoded with base64 encoding.
|
|
||||||
-->
|
|
||||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
|
||||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
|
||||||
<xsd:element name="root" msdata:IsDataSet="true">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:choice maxOccurs="unbounded">
|
|
||||||
<xsd:element name="metadata">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="assembly">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:attribute name="alias" type="xsd:string" />
|
|
||||||
<xsd:attribute name="name" type="xsd:string" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="data">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
|
||||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
|
||||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
|
||||||
<xsd:attribute ref="xml:space" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
<xsd:element name="resheader">
|
|
||||||
<xsd:complexType>
|
|
||||||
<xsd:sequence>
|
|
||||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
|
||||||
</xsd:sequence>
|
|
||||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:choice>
|
|
||||||
</xsd:complexType>
|
|
||||||
</xsd:element>
|
|
||||||
</xsd:schema>
|
|
||||||
<resheader name="resmimetype">
|
|
||||||
<value>text/microsoft-resx</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="version">
|
|
||||||
<value>2.0</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="reader">
|
|
||||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
<resheader name="writer">
|
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</resheader>
|
|
||||||
</root>
|
|
@ -8,42 +8,4 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
|
||||||
<PackageReference Include="Npgsql" Version="9.0.2" />
|
|
||||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
|
||||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
|
||||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
|
||||||
<PackageReference Include="Unity" Version="5.11.10" />
|
|
||||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Update="Properties\Resources.Designer.cs">
|
|
||||||
<DesignTime>True</DesignTime>
|
|
||||||
<AutoGen>True</AutoGen>
|
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<EmbeddedResource Update="Properties\Resources.resx">
|
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
|
||||||
</EmbeddedResource>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Update="appsettings.json">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
@ -1,53 +1,17 @@
|
|||||||
using GasStation.Repositories;
|
namespace GasStation
|
||||||
using GasStation.Repositories.Implementations;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Serilog;
|
|
||||||
using Unity.Microsoft.Logging;
|
|
||||||
using System.Drawing.Text;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace GasStation;
|
|
||||||
|
|
||||||
internal static class Program
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
internal static class Program
|
||||||
/// 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,
|
/// <summary>
|
||||||
// see https://aka.ms/applicationconfiguration.
|
/// The main entry point for the application.
|
||||||
ApplicationConfiguration.Initialize();
|
/// </summary>
|
||||||
Application.Run(CreateContainer().Resolve<FormGasStation>());
|
[STAThread]
|
||||||
}
|
static void Main()
|
||||||
|
{
|
||||||
private static IUnityContainer CreateContainer()
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
{
|
// see https://aka.ms/applicationconfiguration.
|
||||||
var container = new UnityContainer();
|
ApplicationConfiguration.Initialize();
|
||||||
|
Application.Run(new Form1());
|
||||||
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
}
|
||||||
|
|
||||||
container.RegisterType<IGasmanRepository, GasmanRepository>();
|
|
||||||
container.RegisterType<ISellingRepository,SellingRepository>();
|
|
||||||
container.RegisterType<ISupplierRepository, SupplierRepository>();
|
|
||||||
container.RegisterType<ISupplyRepository, SupplyRepository>();
|
|
||||||
container.RegisterType<IProductRepository, ProductRepository>();
|
|
||||||
container.RegisterType<IConnectionString, ConnectionString>();
|
|
||||||
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static LoggerFactory CreateLoggerFactory()
|
|
||||||
{
|
|
||||||
var loggerFactory = new LoggerFactory();
|
|
||||||
loggerFactory.AddSerilog(new LoggerConfiguration()
|
|
||||||
.ReadFrom.Configuration(new ConfigurationBuilder()
|
|
||||||
.SetBasePath(Directory.GetCurrentDirectory())
|
|
||||||
.AddJsonFile("appsettings.json")
|
|
||||||
.Build())
|
|
||||||
.CreateLogger());
|
|
||||||
return loggerFactory;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
73
GasStation/Properties/Resources.Designer.cs
generated
73
GasStation/Properties/Resources.Designer.cs
generated
@ -1,73 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace GasStation.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("GasStation.Properties.Resources", typeof(Resources).Assembly);
|
|
||||||
resourceMan = temp;
|
|
||||||
}
|
|
||||||
return resourceMan;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
|
||||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
|
||||||
/// </summary>
|
|
||||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
|
||||||
internal static global::System.Globalization.CultureInfo Culture {
|
|
||||||
get {
|
|
||||||
return resourceCulture;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
resourceCulture = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap заправка {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("заправка", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
using GasStation.Repositories;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace GasStation.Reports;
|
|
||||||
|
|
||||||
internal class ChartReport
|
|
||||||
{
|
|
||||||
private readonly ISupplyRepository _supplyRepository;
|
|
||||||
private readonly ILogger<ChartReport> _logger;
|
|
||||||
public ChartReport(ISupplyRepository supplyRepository, ILogger<ChartReport> logger)
|
|
||||||
{
|
|
||||||
_supplyRepository = supplyRepository ??
|
|
||||||
throw new
|
|
||||||
ArgumentNullException(nameof(supplyRepository));
|
|
||||||
_logger = logger ??
|
|
||||||
throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
public bool CreateChart(string filePath, DateTime dateTime)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
new PdfBuilder(filePath)
|
|
||||||
.AddHeader("Поступление продукта")
|
|
||||||
.AddPieChart("Поступивший товар", GetData(dateTime))
|
|
||||||
.Build();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
|
||||||
{
|
|
||||||
return _supplyRepository
|
|
||||||
.ReadSupply()
|
|
||||||
.Where(x => x.SupplyDate.Date == dateTime.Date)
|
|
||||||
.GroupBy(x => x.ProductID, (key, group) => new { Id = key, Count = group.Sum(x => x.Count)})
|
|
||||||
.Select(x => (x.Id.ToString(), (double)x.Count)).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,89 +0,0 @@
|
|||||||
using GasStation.Repositories;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace GasStation.Reports;
|
|
||||||
|
|
||||||
internal class DocReport
|
|
||||||
{
|
|
||||||
private readonly IGasmanRepository _gasmanRepository;
|
|
||||||
private readonly ISupplierRepository _supplierRepository;
|
|
||||||
private readonly IProductRepository _productRepository;
|
|
||||||
private readonly ILogger<DocReport> _logger;
|
|
||||||
|
|
||||||
public DocReport(IGasmanRepository gasmanRepository, ISupplierRepository supplierRepository,
|
|
||||||
IProductRepository productRepository, ILogger<DocReport> logger)
|
|
||||||
{
|
|
||||||
_gasmanRepository = gasmanRepository ??
|
|
||||||
throw new
|
|
||||||
ArgumentNullException(nameof(gasmanRepository));
|
|
||||||
_supplierRepository = supplierRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(supplierRepository));
|
|
||||||
_productRepository = productRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(productRepository));
|
|
||||||
_logger = logger ??
|
|
||||||
throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CreateDoc(string filePath, bool includeGasmen, bool includeSuppliers, bool includeProducts)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var builder = new WordBuilder(filePath)
|
|
||||||
.AddHeader("Документ со справочниками");
|
|
||||||
if (includeGasmen)
|
|
||||||
{
|
|
||||||
builder.AddParagraph("Запрвщики")
|
|
||||||
.AddTable([2400, 2400, 2400],
|
|
||||||
GetGasmen());
|
|
||||||
}
|
|
||||||
if (includeSuppliers)
|
|
||||||
{
|
|
||||||
builder.AddParagraph("Поставщики")
|
|
||||||
.AddTable([2400], GetSuppliers());
|
|
||||||
}
|
|
||||||
if (includeProducts)
|
|
||||||
{
|
|
||||||
builder.AddParagraph("Товары")
|
|
||||||
.AddTable([2400, 2400], GetProducts());
|
|
||||||
}
|
|
||||||
builder.Build();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetGasmen()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
["Имя работника", "Телефон", "Должность"],
|
|
||||||
.. _gasmanRepository
|
|
||||||
.ReadGasman()
|
|
||||||
.Select(x => new string[] { x.GasmanName, x.PhoneNumber, x.Post.ToString() }),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetSuppliers()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
["Название поставщика"],
|
|
||||||
.. _supplierRepository
|
|
||||||
.ReadSupplier()
|
|
||||||
.Select(x => new string[] { x.SupplierName }),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetProducts()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
["Стоимость товара", "Тип товара"],
|
|
||||||
.. _productRepository
|
|
||||||
.ReadProduct()
|
|
||||||
.Select(x => new string[] { x.ProductCost.ToString(), x.ProductType.ToString() }),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,307 +0,0 @@
|
|||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
|
||||||
using DocumentFormat.OpenXml;
|
|
||||||
|
|
||||||
namespace GasStation.Reports;
|
|
||||||
|
|
||||||
internal class ExcelBuilder
|
|
||||||
{
|
|
||||||
private readonly string _filePath;
|
|
||||||
private readonly SheetData _sheetData;
|
|
||||||
private readonly MergeCells _mergeCells;
|
|
||||||
private readonly Columns _columns;
|
|
||||||
private uint _rowIndex = 0;
|
|
||||||
public ExcelBuilder(string filePath)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(filePath))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(filePath));
|
|
||||||
}
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
{
|
|
||||||
File.Delete(filePath);
|
|
||||||
}
|
|
||||||
_filePath = filePath;
|
|
||||||
_sheetData = new SheetData();
|
|
||||||
_mergeCells = new MergeCells();
|
|
||||||
_columns = new Columns();
|
|
||||||
_rowIndex = 1;
|
|
||||||
}
|
|
||||||
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
|
||||||
{
|
|
||||||
CreateCell(startIndex, _rowIndex, header,
|
|
||||||
StyleIndex.BoldTextWithoutBorder);
|
|
||||||
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
|
||||||
{
|
|
||||||
CreateCell(i, _rowIndex, "",
|
|
||||||
StyleIndex.SimpleTextWithoutBorder);
|
|
||||||
}
|
|
||||||
_mergeCells.Append(new MergeCell()
|
|
||||||
{
|
|
||||||
Reference =
|
|
||||||
new
|
|
||||||
StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
|
|
||||||
});
|
|
||||||
_rowIndex++;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public ExcelBuilder AddParagraph(string text, int columnIndex)
|
|
||||||
{
|
|
||||||
CreateCell(columnIndex, _rowIndex++, text,
|
|
||||||
StyleIndex.SimpleTextWithoutBorder);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
|
|
||||||
{
|
|
||||||
if (columnsWidths == null || columnsWidths.Length == 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(columnsWidths));
|
|
||||||
}
|
|
||||||
if (data == null || data.Count == 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(data));
|
|
||||||
}
|
|
||||||
if (data.Any(x => x.Length != columnsWidths.Length))
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("widths.Length != data.Length");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint counter = 1;
|
|
||||||
int coef = 2;
|
|
||||||
|
|
||||||
_columns.Append(columnsWidths.Select(x => new Column
|
|
||||||
{
|
|
||||||
Min = counter,
|
|
||||||
Max = counter++,
|
|
||||||
Width = x * coef,
|
|
||||||
CustomWidth = true
|
|
||||||
}));
|
|
||||||
for (var j = 0; j < data.First().Length; ++j)
|
|
||||||
{
|
|
||||||
CreateCell(j, _rowIndex, data.First()[j],
|
|
||||||
StyleIndex.BoldTextWithBorder);
|
|
||||||
}
|
|
||||||
_rowIndex++;
|
|
||||||
for (var i = 1; i < data.Count - 1; ++i)
|
|
||||||
{
|
|
||||||
for (var j = 0; j < data[i].Length; ++j)
|
|
||||||
{
|
|
||||||
CreateCell(j, _rowIndex, data[i][j],
|
|
||||||
StyleIndex.SimpleTextWithBorder);
|
|
||||||
}
|
|
||||||
_rowIndex++;
|
|
||||||
}
|
|
||||||
for (var j = 0; j < data.Last().Length; ++j)
|
|
||||||
{
|
|
||||||
CreateCell(j, _rowIndex, data.Last()[j],
|
|
||||||
StyleIndex.BoldTextWithBorder);
|
|
||||||
}
|
|
||||||
_rowIndex++;
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public void Build()
|
|
||||||
{
|
|
||||||
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath, SpreadsheetDocumentType.Workbook);
|
|
||||||
var workbookpart = spreadsheetDocument.AddWorkbookPart();
|
|
||||||
GenerateStyle(workbookpart);
|
|
||||||
workbookpart.Workbook = new Workbook();
|
|
||||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
|
||||||
worksheetPart.Worksheet = new Worksheet();
|
|
||||||
if (_columns.HasChildren)
|
|
||||||
{
|
|
||||||
worksheetPart.Worksheet.Append(_columns);
|
|
||||||
}
|
|
||||||
worksheetPart.Worksheet.Append(_sheetData);
|
|
||||||
var sheets =
|
|
||||||
spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
|
||||||
var sheet = new Sheet()
|
|
||||||
{
|
|
||||||
Id =
|
|
||||||
spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
|
||||||
SheetId = 1,
|
|
||||||
Name = "Лист 1"
|
|
||||||
};
|
|
||||||
sheets.Append(sheet);
|
|
||||||
if (_mergeCells.HasChildren)
|
|
||||||
{
|
|
||||||
worksheetPart.Worksheet.InsertAfter(_mergeCells,
|
|
||||||
worksheetPart.Worksheet.Elements<SheetData>().First());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private static void GenerateStyle(WorkbookPart workbookPart)
|
|
||||||
{
|
|
||||||
var workbookStylesPart =
|
|
||||||
workbookPart.AddNewPart<WorkbookStylesPart>();
|
|
||||||
workbookStylesPart.Stylesheet = new Stylesheet();
|
|
||||||
var fonts = new Fonts()
|
|
||||||
{
|
|
||||||
Count = 2,
|
|
||||||
KnownFonts =
|
|
||||||
BooleanValue.FromBoolean(true)
|
|
||||||
};
|
|
||||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
|
||||||
{
|
|
||||||
FontSize = new FontSize() { Val = 11 },
|
|
||||||
FontName = new FontName() { Val = "Calibri" },
|
|
||||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
|
||||||
FontScheme = new FontScheme()
|
|
||||||
{
|
|
||||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
|
||||||
},
|
|
||||||
Bold = new Bold() { Val = true }
|
|
||||||
});
|
|
||||||
workbookStylesPart.Stylesheet.Append(fonts);
|
|
||||||
|
|
||||||
// Default Fill
|
|
||||||
var fills = new Fills() { Count = 1 };
|
|
||||||
fills.Append(new Fill
|
|
||||||
{
|
|
||||||
PatternFill = new PatternFill()
|
|
||||||
{
|
|
||||||
PatternType = new EnumValue<PatternValues>(PatternValues.None)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
workbookStylesPart.Stylesheet.Append(fills);
|
|
||||||
|
|
||||||
// Default Border
|
|
||||||
var borders = new Borders() { Count = 2 };
|
|
||||||
borders.Append(new Border
|
|
||||||
{
|
|
||||||
LeftBorder = new LeftBorder(),
|
|
||||||
RightBorder = new RightBorder(),
|
|
||||||
TopBorder = new TopBorder(),
|
|
||||||
BottomBorder = new BottomBorder(),
|
|
||||||
DiagonalBorder = new DiagonalBorder()
|
|
||||||
});
|
|
||||||
borders.Append(new Border
|
|
||||||
{
|
|
||||||
LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin },
|
|
||||||
RightBorder = new RightBorder() { Style = BorderStyleValues.Thin },
|
|
||||||
TopBorder = new TopBorder() { Style = BorderStyleValues.Thin },
|
|
||||||
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin },
|
|
||||||
DiagonalBorder = new DiagonalBorder()
|
|
||||||
});
|
|
||||||
workbookStylesPart.Stylesheet.Append(borders);
|
|
||||||
|
|
||||||
// Default cell format and a date cell format
|
|
||||||
var cellFormats = new CellFormats() { Count = 4 };
|
|
||||||
cellFormats.Append(new CellFormat
|
|
||||||
{
|
|
||||||
NumberFormatId = 0,
|
|
||||||
FormatId = 0,
|
|
||||||
FontId = 0,
|
|
||||||
BorderId = 0,
|
|
||||||
FillId = 0,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Horizontal = HorizontalAlignmentValues.Left,
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cellFormats.Append(new CellFormat
|
|
||||||
{
|
|
||||||
NumberFormatId = 0,
|
|
||||||
FormatId = 0,
|
|
||||||
FontId = 1,
|
|
||||||
BorderId = 0,
|
|
||||||
FillId = 0,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Horizontal = HorizontalAlignmentValues.Left,
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cellFormats.Append(new CellFormat
|
|
||||||
{
|
|
||||||
NumberFormatId = 0,
|
|
||||||
FormatId = 0,
|
|
||||||
FontId = 0,
|
|
||||||
BorderId = 1,
|
|
||||||
FillId = 0,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Horizontal = HorizontalAlignmentValues.Left,
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cellFormats.Append(new CellFormat
|
|
||||||
{
|
|
||||||
NumberFormatId = 0,
|
|
||||||
FormatId = 0,
|
|
||||||
FontId = 1,
|
|
||||||
BorderId = 1,
|
|
||||||
FillId = 0,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Horizontal = HorizontalAlignmentValues.Left,
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
workbookStylesPart.Stylesheet.Append(cellFormats);
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum StyleIndex
|
|
||||||
{
|
|
||||||
SimpleTextWithoutBorder = 0,
|
|
||||||
BoldTextWithoutBorder = 1,
|
|
||||||
SimpleTextWithBorder = 2,
|
|
||||||
BoldTextWithBorder = 3,
|
|
||||||
}
|
|
||||||
private void CreateCell(int columnIndex, uint rowIndex, string text,
|
|
||||||
StyleIndex styleIndex)
|
|
||||||
{
|
|
||||||
var columnName = GetExcelColumnName(columnIndex);
|
|
||||||
var cellReference = columnName + rowIndex;
|
|
||||||
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex!
|
|
||||||
== rowIndex);
|
|
||||||
if (row == null)
|
|
||||||
{
|
|
||||||
row = new Row() { RowIndex = rowIndex };
|
|
||||||
_sheetData.Append(row);
|
|
||||||
}
|
|
||||||
var newCell = row.Elements<Cell>()
|
|
||||||
.FirstOrDefault(c => c.CellReference != null &&
|
|
||||||
c.CellReference.Value == columnName + rowIndex);
|
|
||||||
if (newCell == null)
|
|
||||||
{
|
|
||||||
Cell? refCell = null;
|
|
||||||
foreach (Cell cell in row.Elements<Cell>())
|
|
||||||
{
|
|
||||||
if (cell.CellReference?.Value != null &&
|
|
||||||
cell.CellReference.Value.Length == cellReference.Length)
|
|
||||||
{
|
|
||||||
if (string.Compare(cell.CellReference.Value,
|
|
||||||
cellReference, true) > 0)
|
|
||||||
{
|
|
||||||
refCell = cell;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newCell = new Cell() { CellReference = cellReference };
|
|
||||||
row.InsertBefore(newCell, refCell);
|
|
||||||
}
|
|
||||||
newCell.CellValue = new CellValue(text);
|
|
||||||
newCell.DataType = CellValues.String;
|
|
||||||
newCell.StyleIndex = (uint)styleIndex;
|
|
||||||
}
|
|
||||||
private static string GetExcelColumnName(int columnNumber)
|
|
||||||
{
|
|
||||||
columnNumber += 1;
|
|
||||||
int dividend = columnNumber;
|
|
||||||
string columnName = string.Empty;
|
|
||||||
int modulo;
|
|
||||||
while (dividend > 0)
|
|
||||||
{
|
|
||||||
modulo = (dividend - 1) % 26;
|
|
||||||
columnName = Convert.ToChar(65 + modulo).ToString() +
|
|
||||||
columnName;
|
|
||||||
dividend = (dividend - modulo) / 26;
|
|
||||||
}
|
|
||||||
return columnName;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
using MigraDoc.DocumentObjectModel;
|
|
||||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
|
||||||
using MigraDoc.Rendering;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace GasStation.Reports;
|
|
||||||
|
|
||||||
internal class PdfBuilder
|
|
||||||
{
|
|
||||||
private readonly string _filePath;
|
|
||||||
|
|
||||||
private readonly Document _document;
|
|
||||||
|
|
||||||
public PdfBuilder(string filePath)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(filePath))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(filePath));
|
|
||||||
}
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
{
|
|
||||||
File.Delete(filePath);
|
|
||||||
}
|
|
||||||
_filePath = filePath;
|
|
||||||
_document = new Document();
|
|
||||||
DefineStyles();
|
|
||||||
}
|
|
||||||
|
|
||||||
public PdfBuilder AddHeader(string header)
|
|
||||||
{
|
|
||||||
_document.AddSection().AddParagraph(header, "NormalBold");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PdfBuilder AddPieChart(string title, List<(string Caption, double
|
|
||||||
Value)> data)
|
|
||||||
{
|
|
||||||
if (data == null || data.Count == 0)
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
var chart = new Chart(ChartType.Pie2D);
|
|
||||||
var series = chart.SeriesCollection.AddSeries();
|
|
||||||
series.Add(data.Select(x => x.Value).ToArray());
|
|
||||||
var xseries = chart.XValues.AddXSeries();
|
|
||||||
xseries.Add(data.Select(x => x.Caption).ToArray());
|
|
||||||
chart.DataLabel.Type = DataLabelType.Percent;
|
|
||||||
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
|
||||||
chart.Width = Unit.FromCentimeter(16);
|
|
||||||
chart.Height = Unit.FromCentimeter(12);
|
|
||||||
chart.TopArea.AddParagraph(title);
|
|
||||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
|
||||||
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
|
||||||
chart.YAxis.HasMajorGridlines = true;
|
|
||||||
chart.PlotArea.LineFormat.Width = 1;
|
|
||||||
chart.PlotArea.LineFormat.Visible = true;
|
|
||||||
chart.TopArea.AddLegend();
|
|
||||||
_document.LastSection.Add(chart);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public void Build()
|
|
||||||
{
|
|
||||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
|
||||||
var renderer = new PdfDocumentRenderer(true)
|
|
||||||
{
|
|
||||||
Document = _document
|
|
||||||
};
|
|
||||||
renderer.RenderDocument();
|
|
||||||
renderer.PdfDocument.Save(_filePath);
|
|
||||||
}
|
|
||||||
private void DefineStyles()
|
|
||||||
{
|
|
||||||
var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
|
|
||||||
headerStyle.Font.Bold = true;
|
|
||||||
headerStyle.Font.Size = 14;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,54 +0,0 @@
|
|||||||
using GasStation.Repositories;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
|
|
||||||
namespace GasStation.Reports;
|
|
||||||
|
|
||||||
internal class TableReport
|
|
||||||
{
|
|
||||||
private readonly ISellingRepository _sellingRepository;
|
|
||||||
private readonly ILogger<TableReport> _logger;
|
|
||||||
|
|
||||||
internal static readonly string[] item = ["Сотрудник", "Дата", "Продажа"];
|
|
||||||
public TableReport(ISellingRepository sellingRepository,
|
|
||||||
ILogger<TableReport> logger)
|
|
||||||
{
|
|
||||||
_sellingRepository = sellingRepository ??
|
|
||||||
throw new ArgumentNullException(nameof(sellingRepository));
|
|
||||||
_logger = logger ??
|
|
||||||
throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
public bool CreateTable(string filePath, int productId, DateTime startDate, DateTime endDate)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
new ExcelBuilder(filePath)
|
|
||||||
.AddHeader("Сводка по движению товара", 0, 3)
|
|
||||||
.AddParagraph("за период", 0)
|
|
||||||
.AddTable([10, 10, 15], GetData(productId, startDate, endDate))
|
|
||||||
.Build();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetData(int productId, DateTime startDate, DateTime endDate)
|
|
||||||
{
|
|
||||||
var data = _sellingRepository
|
|
||||||
.ReadSelling()
|
|
||||||
.Where(x => x.SellingDateTime >= startDate && x.SellingDateTime <= endDate && x.ProdutcSellings.Any(y => y.ProductID == productId))
|
|
||||||
.Select(x => new {x.GasmanId, Date = x.SellingDateTime,
|
|
||||||
CountOut = x.ProdutcSellings.FirstOrDefault(y => y.ProductID == productId)?.Count })
|
|
||||||
.OrderBy(x => x.Date);
|
|
||||||
|
|
||||||
return new List<string[]>() { item }.Union(data
|
|
||||||
.Select(x =>
|
|
||||||
new string[] { x.GasmanId.ToString(), x.Date.ToString(), x.CountOut?.ToString() ?? string.Empty}))
|
|
||||||
.Union(
|
|
||||||
[["Всего", "", data.Sum(x => x.CountOut ?? 0).ToString()]]
|
|
||||||
).ToList();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,104 +0,0 @@
|
|||||||
using DocumentFormat.OpenXml;
|
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
|
||||||
|
|
||||||
namespace GasStation.Reports;
|
|
||||||
|
|
||||||
internal class WordBuilder
|
|
||||||
{
|
|
||||||
private readonly string _filePath;
|
|
||||||
|
|
||||||
private readonly Document _document;
|
|
||||||
|
|
||||||
private readonly Body _body;
|
|
||||||
|
|
||||||
public WordBuilder(string filePath)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(filePath))
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(filePath));
|
|
||||||
}
|
|
||||||
if (File.Exists(filePath))
|
|
||||||
{
|
|
||||||
File.Delete(filePath);
|
|
||||||
}
|
|
||||||
_filePath = filePath;
|
|
||||||
_document = new Document();
|
|
||||||
_body = _document.AppendChild(new Body());
|
|
||||||
}
|
|
||||||
|
|
||||||
public WordBuilder AddHeader(string header)
|
|
||||||
{
|
|
||||||
var paragraph = _body.AppendChild(new Paragraph());
|
|
||||||
var run = paragraph.AppendChild(new Run());
|
|
||||||
var runProperties = run.AppendChild(new RunProperties());
|
|
||||||
runProperties.AppendChild(new Bold());
|
|
||||||
run.AppendChild(new Text(header));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WordBuilder AddParagraph(string text)
|
|
||||||
{
|
|
||||||
var paragraph = _body.AppendChild(new Paragraph());
|
|
||||||
var run = paragraph.AppendChild(new Run());
|
|
||||||
run.AppendChild(new Text(text));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WordBuilder AddTable(int[] widths, List<string[]> data)
|
|
||||||
{
|
|
||||||
if (widths == null || widths.Length == 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(widths));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data == null || data.Count == 0)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(data));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.Any(x => x.Length != widths.Length))
|
|
||||||
{
|
|
||||||
throw new InvalidOperationException("widths.Length != data.Length");
|
|
||||||
}
|
|
||||||
|
|
||||||
var table = new Table();
|
|
||||||
|
|
||||||
table.AppendChild(new TableProperties(
|
|
||||||
new TableBorders(
|
|
||||||
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
|
||||||
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
|
||||||
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
|
||||||
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
|
||||||
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
|
||||||
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 }
|
|
||||||
)
|
|
||||||
));
|
|
||||||
// Заголовок
|
|
||||||
var tr = new TableRow();
|
|
||||||
for (var j = 0; j < widths.Length; ++j)
|
|
||||||
{
|
|
||||||
tr.Append(new TableCell(
|
|
||||||
new TableCellProperties(new TableCellWidth()
|
|
||||||
{
|
|
||||||
Width =
|
|
||||||
widths[j].ToString()
|
|
||||||
}),
|
|
||||||
new Paragraph(new Run(new RunProperties(new Bold()), new
|
|
||||||
Text(data.First()[j])))));
|
|
||||||
}
|
|
||||||
table.Append(tr);
|
|
||||||
// Данные
|
|
||||||
table.Append(data.Skip(1).Select(x => new TableRow(x.Select(y => new TableCell(new Paragraph(new Run(new Text(y))))))));
|
|
||||||
_body.Append(table);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
public void Build()
|
|
||||||
{
|
|
||||||
using var wordDocument = WordprocessingDocument.Create(_filePath,
|
|
||||||
WordprocessingDocumentType.Document);
|
|
||||||
var mainPart = wordDocument.AddMainDocumentPart();
|
|
||||||
mainPart.Document = _document;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
namespace GasStation.Repositories;
|
|
||||||
|
|
||||||
public interface IConnectionString
|
|
||||||
{
|
|
||||||
public string ConnectionString { get; }
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using GasStation.Entities;
|
|
||||||
|
|
||||||
namespace GasStation.Repositories;
|
|
||||||
|
|
||||||
public interface IGasmanRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Gasman> ReadGasman();
|
|
||||||
|
|
||||||
Gasman ReadGasmanByID(int id);
|
|
||||||
|
|
||||||
void CreateGasman(Gasman gasman);
|
|
||||||
|
|
||||||
void UpdateGasman(Gasman gasman);
|
|
||||||
|
|
||||||
void DeleteGasman(int id);
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using GasStation.Entities;
|
|
||||||
|
|
||||||
namespace GasStation.Repositories;
|
|
||||||
|
|
||||||
public interface IProductRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Product> ReadProduct();
|
|
||||||
|
|
||||||
Product ReadProductByID(int id);
|
|
||||||
|
|
||||||
void CreateProduct(Product product);
|
|
||||||
|
|
||||||
void UpdateProduct(Product product);
|
|
||||||
|
|
||||||
void DeleteProduct(int id);
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
using GasStation.Entities;
|
|
||||||
|
|
||||||
namespace GasStation.Repositories;
|
|
||||||
|
|
||||||
public interface ISellingRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Selling> ReadSelling(DateTime? dateTime = null, int? count = null, int? gasmanID = null);
|
|
||||||
|
|
||||||
void CreateSelling(Selling selling);
|
|
||||||
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using GasStation.Entities;
|
|
||||||
|
|
||||||
namespace GasStation.Repositories;
|
|
||||||
|
|
||||||
public interface ISupplierRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Supplier> ReadSupplier();
|
|
||||||
|
|
||||||
Supplier ReadSupplierByID(int id);
|
|
||||||
|
|
||||||
void CreateSupplier(Supplier supplier);
|
|
||||||
|
|
||||||
void UpdateSupplier(Supplier supplier);
|
|
||||||
|
|
||||||
void DeleteSupplier(int id);
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
using GasStation.Entities;
|
|
||||||
|
|
||||||
namespace GasStation.Repositories;
|
|
||||||
|
|
||||||
public interface ISupplyRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Supply> ReadSupply(DateTime? supplyDate = null, int? supplierID = null, int? productID = null, int? count = null);
|
|
||||||
|
|
||||||
void CreateSupply(Supply supply);
|
|
||||||
|
|
||||||
void DeleteSupply(int id);
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
namespace GasStation.Repositories.Implementations;
|
|
||||||
|
|
||||||
internal class ConnectionString : IConnectionString
|
|
||||||
{
|
|
||||||
string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=postgres;Password=postgres;Database=normis";
|
|
||||||
}
|
|
@ -1,127 +0,0 @@
|
|||||||
using GasStation.Entities;
|
|
||||||
using GasStation.Entities.Enums;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
using Dapper;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace GasStation.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class GasmanRepository : IGasmanRepository
|
|
||||||
{
|
|
||||||
private readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<GasmanRepository> _logger;
|
|
||||||
|
|
||||||
public GasmanRepository(IConnectionString connectionString, ILogger<GasmanRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateGasman(Gasman gasman)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(gasman));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO gasman (gasmanName, phoneNumber, post)
|
|
||||||
VALUES (@GasmanName, @PhoneNumber, @Post)";
|
|
||||||
connection.Execute(queryInsert, gasman);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteGasman(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM gasman
|
|
||||||
WHERE id=@id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Gasman ReadGasmanByID(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT * FROM gasman
|
|
||||||
WHERE id=@id";
|
|
||||||
var gasman = connection.QueryFirst<Gasman>(querySelect, new { id });
|
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(gasman));
|
|
||||||
|
|
||||||
return gasman;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Gasman> ReadGasman()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"SELECT * FROM gasman";
|
|
||||||
var gasman = connection.Query<Gasman>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(gasman));
|
|
||||||
return gasman;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateGasman(Gasman gasman)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Редактирование объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(gasman));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE gasman
|
|
||||||
SET
|
|
||||||
gasmanName=@GasmanName,
|
|
||||||
phoneNumber=@PhoneNumber,
|
|
||||||
post=@Post
|
|
||||||
WHERE id=@Id";
|
|
||||||
connection.Execute(queryUpdate, gasman);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using GasStation.Entities;
|
|
||||||
using GasStation.Entities.Enums;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
|
|
||||||
namespace GasStation.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class ProductRepository : IProductRepository
|
|
||||||
{
|
|
||||||
private readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<ProductRepository> _logger;
|
|
||||||
|
|
||||||
public ProductRepository(IConnectionString connectionString, ILogger<ProductRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateProduct(Product product)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(product));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO product (productCost, productType)
|
|
||||||
VALUES (@ProductCost, @ProductType)";
|
|
||||||
connection.Execute(queryInsert, product);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteProduct(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM product
|
|
||||||
WHERE id=@Id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Product> ReadProduct()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"SELECT * FROM product";
|
|
||||||
var product = connection.Query<Product>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(product));
|
|
||||||
return product;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Product ReadProductByID(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT * FROM product
|
|
||||||
WHERE id=@Id";
|
|
||||||
var product = connection.QueryFirst<Product>(querySelect, new { id });
|
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(product));
|
|
||||||
|
|
||||||
return product;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateProduct(Product product)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Редактирование объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(product));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE product
|
|
||||||
SET
|
|
||||||
productCost=@ProductCost,
|
|
||||||
productType=@ProductType
|
|
||||||
WHERE id=@Id";
|
|
||||||
connection.Execute(queryUpdate, product);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using GasStation.Entities;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
|
|
||||||
namespace GasStation.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class SellingRepository : ISellingRepository
|
|
||||||
{
|
|
||||||
private readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<SellingRepository> _logger;
|
|
||||||
|
|
||||||
public SellingRepository(IConnectionString connectionString, ILogger<SellingRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateSelling(Selling selling)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(selling));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
connection.Open();
|
|
||||||
using var transaction = connection.BeginTransaction();
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO selling (sellingDateTime, gasmanId)
|
|
||||||
VALUES (@SellingDateTime, @GasmanId);
|
|
||||||
SELECT MAX(Id) FROM selling";
|
|
||||||
var Id = connection.QueryFirst<int>(queryInsert, selling, transaction);
|
|
||||||
var querySubInsert = @"
|
|
||||||
INSERT INTO product_selling (id, productID, count)
|
|
||||||
VALUES (@Id, @ProductID, @Count)";
|
|
||||||
foreach (var elem in selling.ProdutcSellings)
|
|
||||||
{
|
|
||||||
connection.Execute(querySubInsert, new { Id, elem.ProductID, elem.Count }, transaction);
|
|
||||||
}
|
|
||||||
transaction.Commit();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Selling> ReadSelling(DateTime? dateTime = null, int? count = null, int? gasmanID = null)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT s.*, ps.ProductID, ps.Count FROM selling s
|
|
||||||
INNER JOIN Product_Selling ps ON ps.Id = s.Id";
|
|
||||||
var selling = connection.Query<TempProductSelling>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(selling));
|
|
||||||
return selling.GroupBy(x => x.Id, y => y, (key, value) =>
|
|
||||||
Selling.CreateSelling(value.First(), value.Select(z => ProductSelling.CreateSelling(0, z.ProductID, z.Count)))).ToList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,123 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using GasStation.Entities;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
|
|
||||||
namespace GasStation.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class SupplierRepository : ISupplierRepository
|
|
||||||
{
|
|
||||||
private readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<SupplierRepository> _logger;
|
|
||||||
|
|
||||||
public SupplierRepository(IConnectionString connectionString, ILogger<SupplierRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateSupplier(Supplier supplier)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(supplier));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO supplier (supplierName)
|
|
||||||
VALUES (@SupplierName)";
|
|
||||||
connection.Execute(queryInsert, supplier);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteSupplier(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM supplier
|
|
||||||
WHERE id=@Id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Supplier ReadSupplierByID(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT * FROM supplier
|
|
||||||
WHERE id=@Id";
|
|
||||||
var supplier = connection.QueryFirst<Supplier>(querySelect, new { id });
|
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(supplier));
|
|
||||||
|
|
||||||
return supplier;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Supplier> ReadSupplier()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"SELECT * FROM supplier";
|
|
||||||
var supplier = connection.Query<Supplier>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(supplier));
|
|
||||||
return supplier;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateSupplier(Supplier supplier)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Редактирование объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(supplier));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE supplier
|
|
||||||
SET
|
|
||||||
supplierName=@SupplierName
|
|
||||||
WHERE id=@Id";
|
|
||||||
connection.Execute(queryUpdate, supplier);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using GasStation.Entities;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
|
|
||||||
namespace GasStation.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class SupplyRepository : ISupplyRepository
|
|
||||||
{
|
|
||||||
private readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<SupplyRepository> _logger;
|
|
||||||
|
|
||||||
public SupplyRepository(IConnectionString connectionString, ILogger<SupplyRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateSupply(Supply supply)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(supply));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO supply (productID, supplierID, count, supplyDate)
|
|
||||||
VALUES (@ProductID, @SupplierID, @Count, @SupplyDate)";
|
|
||||||
connection.Execute(queryInsert, supply);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteSupply(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM supply
|
|
||||||
WHERE id=@Id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Supply> ReadSupply(DateTime? supplyDate = null, int? supplierID = null, int? productID = null, int? count = null)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"SELECT * FROM supply";
|
|
||||||
var supply = connection.Query<Supply>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(supply));
|
|
||||||
return supply;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 239 KiB |
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"Serilog": {
|
|
||||||
"Using": [ "Serilog.Sinks.File" ],
|
|
||||||
"MinimumLevel": "Debug",
|
|
||||||
"WriteTo": [
|
|
||||||
{
|
|
||||||
"Name": "File",
|
|
||||||
"Args": {
|
|
||||||
"path": "C:\\Users\\rozko\\Documents\\log.txt",
|
|
||||||
"rollinInterval": "Day"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user