Compare commits
No commits in common. "Lab3" and "main" have entirely different histories.
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.11.35222.181
|
VisualStudioVersion = 17.11.35222.181
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectConfectioneryFactory", "ProjectConfectioneryFactory\ProjectConfectioneryFactory.csproj", "{B7790CDB-40A9-4462-AA15-04C10DCFCF7B}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectConfectionaryFactory", "ProjectConfectionaryFactory\ProjectConfectionaryFactory.csproj", "{B7790CDB-40A9-4462-AA15-04C10DCFCF7B}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
39
ProjectConfectionaryFactory/ProjectConfectionaryFactory/Form1.Designer.cs
generated
Normal file
39
ProjectConfectionaryFactory/ProjectConfectionaryFactory/Form1.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace ProjectConfectionaryFactory
|
||||||
|
{
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
namespace ProjectConfectionaryFactory
|
||||||
|
{
|
||||||
|
public partial class Form1 : Form
|
||||||
|
{
|
||||||
|
public Form1()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
namespace ProjectConfectionaryFactory
|
||||||
|
{
|
||||||
|
internal static class Program
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point for the application.
|
||||||
|
/// </summary>
|
||||||
|
[STAThread]
|
||||||
|
static void Main()
|
||||||
|
{
|
||||||
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
|
// see https://aka.ms/applicationconfiguration.
|
||||||
|
ApplicationConfiguration.Initialize();
|
||||||
|
Application.Run(new Form1());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -1,22 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
public class Client
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string Name { get; private set; } = string.Empty;
|
|
||||||
public string Surname { get; private set; } = string.Empty;
|
|
||||||
public string Phone { get; private set; }
|
|
||||||
public string Address { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public static Client CreateEntity(int id, string name, string surname, string phone, string address)
|
|
||||||
{
|
|
||||||
return new Client
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
Name = name ?? string.Empty,
|
|
||||||
Surname = surname ?? string.Empty,
|
|
||||||
Phone = phone,
|
|
||||||
Address = address ?? string.Empty,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
public class Component
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string Name { get; private set; } = string.Empty;
|
|
||||||
public double Price { get; private set; }
|
|
||||||
public double Weight { get; private set; }
|
|
||||||
|
|
||||||
public static Component CreateEntity(int id, string name, double price, double weight)
|
|
||||||
{
|
|
||||||
return new Component
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
Name = name ?? string.Empty,
|
|
||||||
Price = price,
|
|
||||||
Weight = weight
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Entities.Enums;
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum ConfectioneryType
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Cake = 1,
|
|
||||||
Roll = 2,
|
|
||||||
Cupcake = 4,
|
|
||||||
Cookie = 8
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
public class Order
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public int ClientId { get; private set; }
|
|
||||||
public bool Completed { get; private set; }
|
|
||||||
public DateTime Date { get; private set; }
|
|
||||||
public IEnumerable<OrderProduct> OrderProducts { get; private set; } = [];
|
|
||||||
|
|
||||||
public static Order CreateOperation(int id, int clientid, bool completed, IEnumerable<OrderProduct> orderProducts)
|
|
||||||
{
|
|
||||||
return new Order
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
ClientId = clientid,
|
|
||||||
Completed = completed,
|
|
||||||
Date = DateTime.Now,
|
|
||||||
OrderProducts = orderProducts
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
public class OrderProduct
|
|
||||||
{
|
|
||||||
public int OrderId { get; private set; }
|
|
||||||
public int ProductId { get; private set; }
|
|
||||||
public int Count { get; private set; }
|
|
||||||
|
|
||||||
public static OrderProduct CreateEntity(int orderid, int productid, int count)
|
|
||||||
{
|
|
||||||
return new OrderProduct
|
|
||||||
{
|
|
||||||
OrderId = orderid,
|
|
||||||
ProductId = productid,
|
|
||||||
Count = count
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities.Enums;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
public class Product
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public ConfectioneryType ConfectioneryType { get; private set; }
|
|
||||||
public string Name { get; private set; } = string.Empty;
|
|
||||||
public double Price { get; private set; }
|
|
||||||
public IEnumerable<ProductComponent> ProductComponents { get; private set; } = [];
|
|
||||||
|
|
||||||
public static Product CreateEntity(int id, ConfectioneryType сonfectioneryType, string name, double price, IEnumerable<ProductComponent> productComponents)
|
|
||||||
{
|
|
||||||
return new Product
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
ConfectioneryType = сonfectioneryType,
|
|
||||||
Name = name ?? string.Empty,
|
|
||||||
Price = price,
|
|
||||||
ProductComponents = productComponents
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
public class ProductComponent
|
|
||||||
{
|
|
||||||
public int ProductId { get; private set; }
|
|
||||||
public int ComponentId { get; private set; }
|
|
||||||
public double Weight { get; private set; }
|
|
||||||
|
|
||||||
public static ProductComponent CreateEntity(int productid, int componentid, double weight)
|
|
||||||
{
|
|
||||||
return new ProductComponent
|
|
||||||
{
|
|
||||||
ProductId = productid,
|
|
||||||
ComponentId = componentid,
|
|
||||||
Weight = weight
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
public class Supplier
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public string Name { get; private set; } = string.Empty;
|
|
||||||
public string Phone { get; private set; }
|
|
||||||
public string Address { get; private set; } = string.Empty;
|
|
||||||
|
|
||||||
public static Supplier CreateEntity(int id, string name, string phone, string address)
|
|
||||||
{
|
|
||||||
return new Supplier
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
Name = name ?? string.Empty,
|
|
||||||
Phone = phone,
|
|
||||||
Address = address ?? string.Empty
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
public class Supply
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
public int SupplierId { get; private set; }
|
|
||||||
public int ComponentId { get; private set; }
|
|
||||||
public double Weight { get; private set; }
|
|
||||||
public bool Completed { get; private set; }
|
|
||||||
public DateTime Date { get; private set; }
|
|
||||||
|
|
||||||
public static Supply CreateOperation(int id, int supplierid, int componentid, double weight, bool completed)
|
|
||||||
{
|
|
||||||
return new Supply
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
SupplierId = supplierid,
|
|
||||||
ComponentId = componentid,
|
|
||||||
Weight = weight,
|
|
||||||
Completed = completed,
|
|
||||||
Date = DateTime.Now
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,157 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory
|
|
||||||
{
|
|
||||||
partial class FormConfectioneryFactory
|
|
||||||
{
|
|
||||||
/// <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();
|
|
||||||
ClientsToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
ComponentsToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
ProductsToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
SuppliersToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
OrdersToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
SupplysToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
directoryReportToolStripMenuItem = 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(784, 24);
|
|
||||||
menuStrip1.TabIndex = 0;
|
|
||||||
menuStrip1.Text = "menuStrip1";
|
|
||||||
//
|
|
||||||
// справочникиToolStripMenuItem
|
|
||||||
//
|
|
||||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ClientsToolStripMenuItem, ComponentsToolStripMenuItem, ProductsToolStripMenuItem, SuppliersToolStripMenuItem });
|
|
||||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
|
||||||
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
|
||||||
справочникиToolStripMenuItem.Text = "Справочники";
|
|
||||||
//
|
|
||||||
// ClientsToolStripMenuItem
|
|
||||||
//
|
|
||||||
ClientsToolStripMenuItem.Name = "ClientsToolStripMenuItem";
|
|
||||||
ClientsToolStripMenuItem.Size = new Size(145, 22);
|
|
||||||
ClientsToolStripMenuItem.Text = "Клиенты";
|
|
||||||
ClientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// ComponentsToolStripMenuItem
|
|
||||||
//
|
|
||||||
ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem";
|
|
||||||
ComponentsToolStripMenuItem.Size = new Size(145, 22);
|
|
||||||
ComponentsToolStripMenuItem.Text = "Компоненты";
|
|
||||||
ComponentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// ProductsToolStripMenuItem
|
|
||||||
//
|
|
||||||
ProductsToolStripMenuItem.Name = "ProductsToolStripMenuItem";
|
|
||||||
ProductsToolStripMenuItem.Size = new Size(145, 22);
|
|
||||||
ProductsToolStripMenuItem.Text = "Продукты";
|
|
||||||
ProductsToolStripMenuItem.Click += ProductsToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// SuppliersToolStripMenuItem
|
|
||||||
//
|
|
||||||
SuppliersToolStripMenuItem.Name = "SuppliersToolStripMenuItem";
|
|
||||||
SuppliersToolStripMenuItem.Size = new Size(145, 22);
|
|
||||||
SuppliersToolStripMenuItem.Text = "Поставщики";
|
|
||||||
SuppliersToolStripMenuItem.Click += SuppliersToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// операцииToolStripMenuItem
|
|
||||||
//
|
|
||||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { OrdersToolStripMenuItem, SupplysToolStripMenuItem });
|
|
||||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
|
||||||
операцииToolStripMenuItem.Size = new Size(75, 20);
|
|
||||||
операцииToolStripMenuItem.Text = "Операции";
|
|
||||||
//
|
|
||||||
// OrdersToolStripMenuItem
|
|
||||||
//
|
|
||||||
OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
|
|
||||||
OrdersToolStripMenuItem.Size = new Size(126, 22);
|
|
||||||
OrdersToolStripMenuItem.Text = "Заказы";
|
|
||||||
OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// SupplysToolStripMenuItem
|
|
||||||
//
|
|
||||||
SupplysToolStripMenuItem.Name = "SupplysToolStripMenuItem";
|
|
||||||
SupplysToolStripMenuItem.Size = new Size(126, 22);
|
|
||||||
SupplysToolStripMenuItem.Text = "Поставки";
|
|
||||||
SupplysToolStripMenuItem.Click += SupplysToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// отчётыToolStripMenuItem
|
|
||||||
//
|
|
||||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { directoryReportToolStripMenuItem });
|
|
||||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
|
||||||
отчёты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;
|
|
||||||
//
|
|
||||||
// FormConfectioneryFactory
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
BackgroundImage = Properties.Resources.Croissant;
|
|
||||||
BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
ClientSize = new Size(784, 411);
|
|
||||||
Controls.Add(menuStrip1);
|
|
||||||
MainMenuStrip = menuStrip1;
|
|
||||||
Name = "FormConfectioneryFactory";
|
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
|
||||||
Text = "Кондитерская фабрика";
|
|
||||||
menuStrip1.ResumeLayout(false);
|
|
||||||
menuStrip1.PerformLayout();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private MenuStrip menuStrip1;
|
|
||||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem ClientsToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem ProductsToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem ComponentsToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem SuppliersToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem OrdersToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem SupplysToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem directoryReportToolStripMenuItem;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,100 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Forms;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory
|
|
||||||
{
|
|
||||||
public partial class FormConfectioneryFactory : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
|
|
||||||
public FormConfectioneryFactory(IUnityContainer container)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormClients>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ProductsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormProducts>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormComponents>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SuppliersToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormSuppliers>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormOrders>().ShowDialog();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SupplysToolStripMenuItem_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormSupplys>().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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,165 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
partial class FormClient
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
buttonCancel = new Button();
|
|
||||||
buttonSave = new Button();
|
|
||||||
textBoxClientName = new TextBox();
|
|
||||||
label3 = new Label();
|
|
||||||
label2 = new Label();
|
|
||||||
label1 = new Label();
|
|
||||||
textBoxClientSurname = new TextBox();
|
|
||||||
label4 = new Label();
|
|
||||||
textBoxAddress = new TextBox();
|
|
||||||
maskedTextBoxPhone = new MaskedTextBox();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonCancel.Location = new Point(297, 216);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(75, 23);
|
|
||||||
buttonCancel.TabIndex = 15;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonSave.Location = new Point(216, 216);
|
|
||||||
buttonSave.Name = "buttonSave";
|
|
||||||
buttonSave.Size = new Size(75, 23);
|
|
||||||
buttonSave.TabIndex = 14;
|
|
||||||
buttonSave.Text = "Сохранить";
|
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonSave.Click += ButtonSave_Click;
|
|
||||||
//
|
|
||||||
// textBoxClientName
|
|
||||||
//
|
|
||||||
textBoxClientName.Location = new Point(115, 30);
|
|
||||||
textBoxClientName.Name = "textBoxClientName";
|
|
||||||
textBoxClientName.Size = new Size(207, 23);
|
|
||||||
textBoxClientName.TabIndex = 11;
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
label3.AutoSize = true;
|
|
||||||
label3.Location = new Point(66, 161);
|
|
||||||
label3.Name = "label3";
|
|
||||||
label3.Size = new Size(43, 15);
|
|
||||||
label3.TabIndex = 10;
|
|
||||||
label3.Text = "Адрес:";
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(51, 117);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(58, 15);
|
|
||||||
label2.TabIndex = 9;
|
|
||||||
label2.Text = "Телефон:";
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(75, 33);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(34, 15);
|
|
||||||
label1.TabIndex = 8;
|
|
||||||
label1.Text = "Имя:";
|
|
||||||
//
|
|
||||||
// textBoxClientSurname
|
|
||||||
//
|
|
||||||
textBoxClientSurname.Location = new Point(115, 71);
|
|
||||||
textBoxClientSurname.Name = "textBoxClientSurname";
|
|
||||||
textBoxClientSurname.Size = new Size(207, 23);
|
|
||||||
textBoxClientSurname.TabIndex = 17;
|
|
||||||
//
|
|
||||||
// label4
|
|
||||||
//
|
|
||||||
label4.AutoSize = true;
|
|
||||||
label4.Location = new Point(48, 74);
|
|
||||||
label4.Name = "label4";
|
|
||||||
label4.Size = new Size(61, 15);
|
|
||||||
label4.TabIndex = 16;
|
|
||||||
label4.Text = "Фамилия:";
|
|
||||||
//
|
|
||||||
// textBoxAddress
|
|
||||||
//
|
|
||||||
textBoxAddress.Location = new Point(115, 158);
|
|
||||||
textBoxAddress.Name = "textBoxAddress";
|
|
||||||
textBoxAddress.Size = new Size(207, 23);
|
|
||||||
textBoxAddress.TabIndex = 18;
|
|
||||||
//
|
|
||||||
// maskedTextBoxPhone
|
|
||||||
//
|
|
||||||
maskedTextBoxPhone.Location = new Point(115, 114);
|
|
||||||
maskedTextBoxPhone.Mask = "+7 (999) 000-0000";
|
|
||||||
maskedTextBoxPhone.Name = "maskedTextBoxPhone";
|
|
||||||
maskedTextBoxPhone.Size = new Size(207, 23);
|
|
||||||
maskedTextBoxPhone.TabIndex = 19;
|
|
||||||
//
|
|
||||||
// FormClient
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(384, 251);
|
|
||||||
Controls.Add(maskedTextBoxPhone);
|
|
||||||
Controls.Add(textBoxAddress);
|
|
||||||
Controls.Add(textBoxClientSurname);
|
|
||||||
Controls.Add(label4);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonSave);
|
|
||||||
Controls.Add(textBoxClientName);
|
|
||||||
Controls.Add(label3);
|
|
||||||
Controls.Add(label2);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Name = "FormClient";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "Клиент";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private TextBox textBoxClientName;
|
|
||||||
private Label label3;
|
|
||||||
private Label label2;
|
|
||||||
private Label label1;
|
|
||||||
private TextBox textBoxClientSurname;
|
|
||||||
private Label label4;
|
|
||||||
private TextBox textBoxAddress;
|
|
||||||
private MaskedTextBox maskedTextBoxPhone;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,73 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormClient : Form
|
|
||||||
{
|
|
||||||
private readonly IClientRepository _clientRepository;
|
|
||||||
|
|
||||||
private int? _clientId;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var client = _clientRepository.ReadClientById(value);
|
|
||||||
if (client == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(client));
|
|
||||||
}
|
|
||||||
textBoxClientName.Text = client.Name;
|
|
||||||
textBoxClientSurname.Text = client.Surname;
|
|
||||||
maskedTextBoxPhone.Text = client.Phone.ToString();
|
|
||||||
textBoxAddress.Text = client.Address;
|
|
||||||
_clientId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormClient(IClientRepository clientRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(textBoxClientName.Text) || string.IsNullOrWhiteSpace(textBoxClientSurname.Text) || !maskedTextBoxPhone.MaskCompleted || string.IsNullOrWhiteSpace(textBoxAddress.Text))
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
if (_clientId.HasValue)
|
|
||||||
{
|
|
||||||
_clientRepository.UpdateClient(CreateClient(_clientId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_clientRepository.CreateClient(CreateClient(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private Client CreateClient(int id) => Client.CreateEntity(
|
|
||||||
id,
|
|
||||||
textBoxClientName.Text,
|
|
||||||
textBoxClientSurname.Text,
|
|
||||||
maskedTextBoxPhone.Text,
|
|
||||||
textBoxAddress.Text);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,126 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
partial class FormClients
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
dataGridViewData = new DataGridView();
|
|
||||||
buttonUpdate = new Button();
|
|
||||||
buttonDelete = new Button();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
panel1 = new Panel();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// 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(709, 450);
|
|
||||||
dataGridViewData.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
buttonUpdate.BackgroundImage = Properties.Resources.Update;
|
|
||||||
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUpdate.Location = new Point(14, 83);
|
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
|
||||||
buttonUpdate.Size = new Size(65, 65);
|
|
||||||
buttonUpdate.TabIndex = 1;
|
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdate.Click += ButtonUpdate_Click;
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
buttonDelete.BackgroundImage = Properties.Resources.Delete;
|
|
||||||
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDelete.Location = new Point(14, 154);
|
|
||||||
buttonDelete.Name = "buttonDelete";
|
|
||||||
buttonDelete.Size = new Size(65, 65);
|
|
||||||
buttonDelete.TabIndex = 1;
|
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
buttonDelete.Click += ButtonDelete_Click;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.BackgroundImage = Properties.Resources.Add;
|
|
||||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAdd.Location = new Point(14, 12);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(65, 65);
|
|
||||||
buttonAdd.TabIndex = 0;
|
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(buttonUpdate);
|
|
||||||
panel1.Controls.Add(buttonDelete);
|
|
||||||
panel1.Controls.Add(buttonAdd);
|
|
||||||
panel1.Dock = DockStyle.Right;
|
|
||||||
panel1.Location = new Point(709, 0);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(91, 450);
|
|
||||||
panel1.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// FormClients
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Name = "FormClients";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "Клиенты";
|
|
||||||
Load += FormClients_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridViewData;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Panel panel1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormClients : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly IClientRepository _clientRepository;
|
|
||||||
public FormClients(IUnityContainer container, IClientRepository clientRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
|
|
||||||
}
|
|
||||||
private void FormClients_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormClient>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormClient>();
|
|
||||||
form.Id = findId;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; }
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_clientRepository.DeleteClient(findId); LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _clientRepository.ReadClients();
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridViewData.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,152 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
partial class FormComponent
|
|
||||||
{
|
|
||||||
/// <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();
|
|
||||||
label2 = new Label();
|
|
||||||
label3 = new Label();
|
|
||||||
textBoxComponentName = new TextBox();
|
|
||||||
numericUpDownPrice = new NumericUpDown();
|
|
||||||
numericUpDownWeight = new NumericUpDown();
|
|
||||||
buttonSave = new Button();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(12, 38);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(132, 15);
|
|
||||||
label1.TabIndex = 0;
|
|
||||||
label1.Text = "Название компонента:";
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(106, 84);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(38, 15);
|
|
||||||
label2.TabIndex = 1;
|
|
||||||
label2.Text = "Цена:";
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
label3.AutoSize = true;
|
|
||||||
label3.Location = new Point(115, 130);
|
|
||||||
label3.Name = "label3";
|
|
||||||
label3.Size = new Size(29, 15);
|
|
||||||
label3.TabIndex = 2;
|
|
||||||
label3.Text = "Вес:";
|
|
||||||
//
|
|
||||||
// textBoxComponentName
|
|
||||||
//
|
|
||||||
textBoxComponentName.Location = new Point(150, 35);
|
|
||||||
textBoxComponentName.Name = "textBoxComponentName";
|
|
||||||
textBoxComponentName.Size = new Size(207, 23);
|
|
||||||
textBoxComponentName.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// numericUpDownPrice
|
|
||||||
//
|
|
||||||
numericUpDownPrice.DecimalPlaces = 2;
|
|
||||||
numericUpDownPrice.Location = new Point(150, 82);
|
|
||||||
numericUpDownPrice.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
|
|
||||||
numericUpDownPrice.Name = "numericUpDownPrice";
|
|
||||||
numericUpDownPrice.Size = new Size(96, 23);
|
|
||||||
numericUpDownPrice.TabIndex = 4;
|
|
||||||
numericUpDownPrice.Value = new decimal(new int[] { 1, 0, 0, 131072 });
|
|
||||||
//
|
|
||||||
// numericUpDownWeight
|
|
||||||
//
|
|
||||||
numericUpDownWeight.DecimalPlaces = 3;
|
|
||||||
numericUpDownWeight.Location = new Point(150, 128);
|
|
||||||
numericUpDownWeight.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
|
|
||||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
|
||||||
numericUpDownWeight.Size = new Size(96, 23);
|
|
||||||
numericUpDownWeight.TabIndex = 5;
|
|
||||||
numericUpDownWeight.Value = new decimal(new int[] { 1, 0, 0, 196608 });
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonSave.Location = new Point(211, 200);
|
|
||||||
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(292, 200);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(75, 23);
|
|
||||||
buttonCancel.TabIndex = 7;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
|
||||||
//
|
|
||||||
// FormComponent
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(384, 236);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonSave);
|
|
||||||
Controls.Add(numericUpDownWeight);
|
|
||||||
Controls.Add(numericUpDownPrice);
|
|
||||||
Controls.Add(textBoxComponentName);
|
|
||||||
Controls.Add(label3);
|
|
||||||
Controls.Add(label2);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Name = "FormComponent";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "Компонент";
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label1;
|
|
||||||
private Label label2;
|
|
||||||
private Label label3;
|
|
||||||
private TextBox textBoxComponentName;
|
|
||||||
private NumericUpDown numericUpDownPrice;
|
|
||||||
private NumericUpDown numericUpDownWeight;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Button buttonCancel;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormComponent : Form
|
|
||||||
{
|
|
||||||
private readonly IComponentRepository _componentRepository;
|
|
||||||
|
|
||||||
private int? _componentId;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var component = _componentRepository.ReadComponentById(value);
|
|
||||||
if (component == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(component));
|
|
||||||
}
|
|
||||||
textBoxComponentName.Text = component.Name;
|
|
||||||
numericUpDownPrice.Value = (decimal)component.Price;
|
|
||||||
numericUpDownWeight.Value = (decimal)component.Weight;
|
|
||||||
_componentId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormComponent(IComponentRepository componentRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_componentRepository = componentRepository ?? throw new ArgumentNullException(nameof(componentRepository));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(textBoxComponentName.Text))
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
if (_componentId.HasValue)
|
|
||||||
{
|
|
||||||
_componentRepository.UpdateComponent(CreateComponent(_componentId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_componentRepository.CreateComponent(CreateComponent(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private Component CreateComponent(int id) => Component.CreateEntity(
|
|
||||||
id,
|
|
||||||
textBoxComponentName.Text,
|
|
||||||
Convert.ToInt32(numericUpDownPrice.Value),
|
|
||||||
Convert.ToDouble(numericUpDownWeight.Value));
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,126 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
partial class FormComponents
|
|
||||||
{
|
|
||||||
/// <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();
|
|
||||||
buttonUpdate = new Button();
|
|
||||||
buttonDelete = new Button();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
dataGridViewData = new DataGridView();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(buttonUpdate);
|
|
||||||
panel1.Controls.Add(buttonDelete);
|
|
||||||
panel1.Controls.Add(buttonAdd);
|
|
||||||
panel1.Dock = DockStyle.Right;
|
|
||||||
panel1.Location = new Point(709, 0);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(91, 450);
|
|
||||||
panel1.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
buttonUpdate.BackgroundImage = Properties.Resources.Update;
|
|
||||||
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUpdate.Location = new Point(14, 83);
|
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
|
||||||
buttonUpdate.Size = new Size(65, 65);
|
|
||||||
buttonUpdate.TabIndex = 1;
|
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdate.Click += ButtonUpdate_Click;
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
buttonDelete.BackgroundImage = Properties.Resources.Delete;
|
|
||||||
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDelete.Location = new Point(14, 154);
|
|
||||||
buttonDelete.Name = "buttonDelete";
|
|
||||||
buttonDelete.Size = new Size(65, 65);
|
|
||||||
buttonDelete.TabIndex = 1;
|
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
buttonDelete.Click += ButtonDelete_Click;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.BackgroundImage = Properties.Resources.Add;
|
|
||||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAdd.Location = new Point(14, 12);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(65, 65);
|
|
||||||
buttonAdd.TabIndex = 0;
|
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
|
||||||
//
|
|
||||||
// dataGridViewData
|
|
||||||
//
|
|
||||||
dataGridViewData.AllowUserToAddRows = false;
|
|
||||||
dataGridViewData.AllowUserToDeleteRows = false;
|
|
||||||
dataGridViewData.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewData.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewData.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewData.Location = new Point(0, 0);
|
|
||||||
dataGridViewData.MultiSelect = false;
|
|
||||||
dataGridViewData.Name = "dataGridViewData";
|
|
||||||
dataGridViewData.ReadOnly = true;
|
|
||||||
dataGridViewData.RowHeadersVisible = false;
|
|
||||||
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewData.Size = new Size(709, 450);
|
|
||||||
dataGridViewData.TabIndex = 1;
|
|
||||||
//
|
|
||||||
// FormComponents
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Name = "FormComponents";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "Компоненты";
|
|
||||||
Load += FormComponents_Load;
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Panel panel1;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private DataGridView dataGridViewData;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormComponents : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly IComponentRepository _componentRepository;
|
|
||||||
public FormComponents(IUnityContainer container, IComponentRepository componentRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_componentRepository = componentRepository ?? throw new ArgumentNullException(nameof(componentRepository));
|
|
||||||
}
|
|
||||||
private void FormComponents_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormComponent>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormComponent>();
|
|
||||||
form.Id = findId;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; }
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_componentRepository.DeleteComponent(findId); LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _componentRepository.ReadComponents();
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridViewData.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,113 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.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()
|
|
||||||
{
|
|
||||||
checkBoxClients = new CheckBox();
|
|
||||||
checkBoxComponents = new CheckBox();
|
|
||||||
checkBoxProducts = new CheckBox();
|
|
||||||
checkBoxSuppliers = new CheckBox();
|
|
||||||
buttonBuild = new Button();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// checkBoxClients
|
|
||||||
//
|
|
||||||
checkBoxClients.AutoSize = true;
|
|
||||||
checkBoxClients.Location = new Point(23, 12);
|
|
||||||
checkBoxClients.Name = "checkBoxClients";
|
|
||||||
checkBoxClients.Size = new Size(74, 19);
|
|
||||||
checkBoxClients.TabIndex = 0;
|
|
||||||
checkBoxClients.Text = "Клиенты";
|
|
||||||
checkBoxClients.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxComponents
|
|
||||||
//
|
|
||||||
checkBoxComponents.AutoSize = true;
|
|
||||||
checkBoxComponents.Location = new Point(23, 37);
|
|
||||||
checkBoxComponents.Name = "checkBoxComponents";
|
|
||||||
checkBoxComponents.Size = new Size(97, 19);
|
|
||||||
checkBoxComponents.TabIndex = 1;
|
|
||||||
checkBoxComponents.Text = "Компоненты";
|
|
||||||
checkBoxComponents.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxProducts
|
|
||||||
//
|
|
||||||
checkBoxProducts.AutoSize = true;
|
|
||||||
checkBoxProducts.Location = new Point(23, 62);
|
|
||||||
checkBoxProducts.Name = "checkBoxProducts";
|
|
||||||
checkBoxProducts.Size = new Size(81, 19);
|
|
||||||
checkBoxProducts.TabIndex = 2;
|
|
||||||
checkBoxProducts.Text = "Продукты";
|
|
||||||
checkBoxProducts.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// checkBoxSuppliers
|
|
||||||
//
|
|
||||||
checkBoxSuppliers.AutoSize = true;
|
|
||||||
checkBoxSuppliers.Location = new Point(23, 87);
|
|
||||||
checkBoxSuppliers.Name = "checkBoxSuppliers";
|
|
||||||
checkBoxSuppliers.Size = new Size(96, 19);
|
|
||||||
checkBoxSuppliers.TabIndex = 3;
|
|
||||||
checkBoxSuppliers.Text = "Поставщики";
|
|
||||||
checkBoxSuppliers.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// buttonBuild
|
|
||||||
//
|
|
||||||
buttonBuild.Location = new Point(164, 48);
|
|
||||||
buttonBuild.Name = "buttonBuild";
|
|
||||||
buttonBuild.Size = new Size(114, 23);
|
|
||||||
buttonBuild.TabIndex = 4;
|
|
||||||
buttonBuild.Text = "Сформировать";
|
|
||||||
buttonBuild.UseVisualStyleBackColor = true;
|
|
||||||
buttonBuild.Click += ButtonBuild_Click;
|
|
||||||
//
|
|
||||||
// FormDirectoryReport
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(332, 130);
|
|
||||||
Controls.Add(buttonBuild);
|
|
||||||
Controls.Add(checkBoxSuppliers);
|
|
||||||
Controls.Add(checkBoxProducts);
|
|
||||||
Controls.Add(checkBoxComponents);
|
|
||||||
Controls.Add(checkBoxClients);
|
|
||||||
Name = "FormDirectoryReport";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "Выгрузка справочников";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private CheckBox checkBoxClients;
|
|
||||||
private CheckBox checkBoxComponents;
|
|
||||||
private CheckBox checkBoxProducts;
|
|
||||||
private CheckBox checkBoxSuppliers;
|
|
||||||
private Button buttonBuild;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,51 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Reports;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.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 (!checkBoxClients.Checked && !checkBoxComponents.Checked
|
|
||||||
&& !checkBoxProducts.Checked && !checkBoxSuppliers.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, checkBoxClients.Checked,
|
|
||||||
checkBoxComponents.Checked, checkBoxProducts.Checked, checkBoxSuppliers.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>
|
|
@ -1,197 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
partial class FormOrder
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
label4 = new Label();
|
|
||||||
label1 = new Label();
|
|
||||||
checkBoxCompleted = new CheckBox();
|
|
||||||
comboBoxClient = new ComboBox();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
buttonSave = new Button();
|
|
||||||
label2 = new Label();
|
|
||||||
dateTimePickerOrderDate = new DateTimePicker();
|
|
||||||
groupBox1 = new GroupBox();
|
|
||||||
dataGridViewProducts = new DataGridView();
|
|
||||||
ColumnProductName = new DataGridViewComboBoxColumn();
|
|
||||||
ColumnProductCount = new DataGridViewTextBoxColumn();
|
|
||||||
groupBox1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewProducts).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// label4
|
|
||||||
//
|
|
||||||
label4.AutoSize = true;
|
|
||||||
label4.Location = new Point(49, 64);
|
|
||||||
label4.Name = "label4";
|
|
||||||
label4.Size = new Size(67, 15);
|
|
||||||
label4.TabIndex = 18;
|
|
||||||
label4.Text = "Выполнен:";
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(67, 24);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(49, 15);
|
|
||||||
label1.TabIndex = 17;
|
|
||||||
label1.Text = "Клиент:";
|
|
||||||
//
|
|
||||||
// checkBoxCompleted
|
|
||||||
//
|
|
||||||
checkBoxCompleted.AutoSize = true;
|
|
||||||
checkBoxCompleted.Location = new Point(122, 65);
|
|
||||||
checkBoxCompleted.Name = "checkBoxCompleted";
|
|
||||||
checkBoxCompleted.Size = new Size(15, 14);
|
|
||||||
checkBoxCompleted.TabIndex = 19;
|
|
||||||
checkBoxCompleted.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// comboBoxClient
|
|
||||||
//
|
|
||||||
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxClient.FormattingEnabled = true;
|
|
||||||
comboBoxClient.Location = new Point(122, 21);
|
|
||||||
comboBoxClient.Name = "comboBoxClient";
|
|
||||||
comboBoxClient.Size = new Size(210, 23);
|
|
||||||
comboBoxClient.TabIndex = 20;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonCancel.Location = new Point(297, 416);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(75, 23);
|
|
||||||
buttonCancel.TabIndex = 22;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonSave.Location = new Point(216, 416);
|
|
||||||
buttonSave.Name = "buttonSave";
|
|
||||||
buttonSave.Size = new Size(75, 23);
|
|
||||||
buttonSave.TabIndex = 21;
|
|
||||||
buttonSave.Text = "Сохранить";
|
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonSave.Click += ButtonSave_Click;
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(81, 104);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(35, 15);
|
|
||||||
label2.TabIndex = 23;
|
|
||||||
label2.Text = "Дата:";
|
|
||||||
//
|
|
||||||
// dateTimePickerOrderDate
|
|
||||||
//
|
|
||||||
dateTimePickerOrderDate.Enabled = false;
|
|
||||||
dateTimePickerOrderDate.Location = new Point(122, 98);
|
|
||||||
dateTimePickerOrderDate.Name = "dateTimePickerOrderDate";
|
|
||||||
dateTimePickerOrderDate.Size = new Size(200, 23);
|
|
||||||
dateTimePickerOrderDate.TabIndex = 24;
|
|
||||||
//
|
|
||||||
// groupBox1
|
|
||||||
//
|
|
||||||
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
groupBox1.Controls.Add(dataGridViewProducts);
|
|
||||||
groupBox1.Location = new Point(12, 137);
|
|
||||||
groupBox1.Name = "groupBox1";
|
|
||||||
groupBox1.Size = new Size(360, 263);
|
|
||||||
groupBox1.TabIndex = 25;
|
|
||||||
groupBox1.TabStop = false;
|
|
||||||
groupBox1.Text = "Продукты";
|
|
||||||
//
|
|
||||||
// dataGridViewProducts
|
|
||||||
//
|
|
||||||
dataGridViewProducts.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewProducts.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewProducts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
dataGridViewProducts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewProducts.Columns.AddRange(new DataGridViewColumn[] { ColumnProductName, ColumnProductCount });
|
|
||||||
dataGridViewProducts.Location = new Point(6, 22);
|
|
||||||
dataGridViewProducts.MultiSelect = false;
|
|
||||||
dataGridViewProducts.Name = "dataGridViewProducts";
|
|
||||||
dataGridViewProducts.RowHeadersVisible = false;
|
|
||||||
dataGridViewProducts.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewProducts.Size = new Size(354, 242);
|
|
||||||
dataGridViewProducts.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ColumnProductName
|
|
||||||
//
|
|
||||||
ColumnProductName.HeaderText = "Продукт";
|
|
||||||
ColumnProductName.Name = "ColumnProductName";
|
|
||||||
//
|
|
||||||
// ColumnProductCount
|
|
||||||
//
|
|
||||||
ColumnProductCount.HeaderText = "Количество";
|
|
||||||
ColumnProductCount.Name = "ColumnProductCount";
|
|
||||||
//
|
|
||||||
// FormOrder
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(384, 451);
|
|
||||||
Controls.Add(groupBox1);
|
|
||||||
Controls.Add(dateTimePickerOrderDate);
|
|
||||||
Controls.Add(label2);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonSave);
|
|
||||||
Controls.Add(comboBoxClient);
|
|
||||||
Controls.Add(checkBoxCompleted);
|
|
||||||
Controls.Add(label4);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Name = "FormOrder";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "Заказ";
|
|
||||||
groupBox1.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewProducts).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Label label4;
|
|
||||||
private Label label1;
|
|
||||||
private CheckBox checkBoxCompleted;
|
|
||||||
private ComboBox comboBoxClient;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private Label label2;
|
|
||||||
private DateTimePicker dateTimePickerOrderDate;
|
|
||||||
private GroupBox groupBox1;
|
|
||||||
private DataGridView dataGridViewProducts;
|
|
||||||
private DataGridViewComboBoxColumn ColumnProductName;
|
|
||||||
private DataGridViewTextBoxColumn ColumnProductCount;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,94 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
using ProjectConfectioneryFactory.Repositories.Implementations;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormOrder : Form
|
|
||||||
{
|
|
||||||
private readonly IOrderRepository _orderRepository;
|
|
||||||
|
|
||||||
private int? _orderId;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var order = _orderRepository.ReadOrderById(value);
|
|
||||||
if (order == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(order));
|
|
||||||
}
|
|
||||||
checkBoxCompleted.Checked = order.Completed;
|
|
||||||
_orderId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormOrder(IOrderRepository orderRepository, IClientRepository clientRepository, IProductRepository productRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
|
||||||
comboBoxClient.DataSource = clientRepository.ReadClients();
|
|
||||||
comboBoxClient.DisplayMember = "Phone";
|
|
||||||
comboBoxClient.ValueMember = "Id";
|
|
||||||
|
|
||||||
ColumnProductName.DataSource = productRepository.ReadProducts();
|
|
||||||
ColumnProductName.DisplayMember = "Name";
|
|
||||||
ColumnProductName.ValueMember = "Id";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (dataGridViewProducts.RowCount <= 1 || comboBoxClient.SelectedIndex < 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
if (_orderId.HasValue)
|
|
||||||
{
|
|
||||||
_orderRepository.UpdateOrder(CreateOrder(_orderId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_orderRepository.CreateOrder(CreateOrder(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private List<OrderProduct>CreateListOrderProductFromDataGrid()
|
|
||||||
{
|
|
||||||
var list = new List<OrderProduct>();
|
|
||||||
foreach (DataGridViewRow row in dataGridViewProducts.Rows)
|
|
||||||
{
|
|
||||||
if (row.Cells["ColumnProductName"].Value == null ||
|
|
||||||
row.Cells["ColumnProductCount"].Value == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
list.Add(OrderProduct.CreateEntity(0,
|
|
||||||
Convert.ToInt32(row.Cells["ColumnProductName"].Value),
|
|
||||||
Convert.ToInt32(row.Cells["ColumnProductCount"].Value)));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Order CreateOrder(int id) => Order.CreateOperation(0,
|
|
||||||
(int)comboBoxClient.SelectedValue!,
|
|
||||||
checkBoxCompleted.Checked,
|
|
||||||
CreateListOrderProductFromDataGrid());
|
|
||||||
}
|
|
||||||
}
|
|
@ -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="ColumnProductName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnProductCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnProductName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnProductCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
@ -1,126 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
partial class FormOrders
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Required designer variable.
|
|
||||||
/// </summary>
|
|
||||||
private System.ComponentModel.IContainer components = null;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Clean up any resources being used.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Required method for Designer support - do not modify
|
|
||||||
/// the contents of this method with the code editor.
|
|
||||||
/// </summary>
|
|
||||||
private void InitializeComponent()
|
|
||||||
{
|
|
||||||
buttonAdd = new Button();
|
|
||||||
dataGridViewData = new DataGridView();
|
|
||||||
buttonUpdate = new Button();
|
|
||||||
buttonDelete = new Button();
|
|
||||||
panel1 = new Panel();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.BackgroundImage = Properties.Resources.Add;
|
|
||||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAdd.Location = new Point(14, 12);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(65, 65);
|
|
||||||
buttonAdd.TabIndex = 0;
|
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
|
||||||
//
|
|
||||||
// dataGridViewData
|
|
||||||
//
|
|
||||||
dataGridViewData.AllowUserToAddRows = false;
|
|
||||||
dataGridViewData.AllowUserToDeleteRows = false;
|
|
||||||
dataGridViewData.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewData.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewData.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewData.Location = new Point(0, 0);
|
|
||||||
dataGridViewData.MultiSelect = false;
|
|
||||||
dataGridViewData.Name = "dataGridViewData";
|
|
||||||
dataGridViewData.ReadOnly = true;
|
|
||||||
dataGridViewData.RowHeadersVisible = false;
|
|
||||||
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewData.Size = new Size(709, 450);
|
|
||||||
dataGridViewData.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
buttonUpdate.BackgroundImage = Properties.Resources.Update;
|
|
||||||
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUpdate.Location = new Point(14, 83);
|
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
|
||||||
buttonUpdate.Size = new Size(65, 65);
|
|
||||||
buttonUpdate.TabIndex = 1;
|
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdate.Click += ButtonUpdate_Click;
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
buttonDelete.BackgroundImage = Properties.Resources.Delete;
|
|
||||||
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDelete.Location = new Point(14, 154);
|
|
||||||
buttonDelete.Name = "buttonDelete";
|
|
||||||
buttonDelete.Size = new Size(65, 65);
|
|
||||||
buttonDelete.TabIndex = 1;
|
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
buttonDelete.Click += ButtonDelete_Click;
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(buttonUpdate);
|
|
||||||
panel1.Controls.Add(buttonDelete);
|
|
||||||
panel1.Controls.Add(buttonAdd);
|
|
||||||
panel1.Dock = DockStyle.Right;
|
|
||||||
panel1.Location = new Point(709, 0);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(91, 450);
|
|
||||||
panel1.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// FormOrders
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Name = "FormOrders";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "FormOrders";
|
|
||||||
Load += FormOrders_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridViewData;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Panel panel1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormOrders : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly IOrderRepository _orderRepository;
|
|
||||||
public FormOrders(IUnityContainer container, IOrderRepository orderRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
|
||||||
}
|
|
||||||
private void FormOrders_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormOrder>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormOrder>();
|
|
||||||
form.Id = findId;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; }
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_orderRepository.DeleteOrder(findId); LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _orderRepository.ReadOrders();
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridViewData.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,198 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.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()
|
|
||||||
{
|
|
||||||
numericUpDownPrice = new NumericUpDown();
|
|
||||||
textBoxProductName = new TextBox();
|
|
||||||
label2 = new Label();
|
|
||||||
label1 = new Label();
|
|
||||||
label3 = new Label();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
buttonSave = new Button();
|
|
||||||
checkedListBoxConfectioneryType = new CheckedListBox();
|
|
||||||
groupBox1 = new GroupBox();
|
|
||||||
dataGridViewComponents = new DataGridView();
|
|
||||||
ColumnComponent = new DataGridViewComboBoxColumn();
|
|
||||||
ColumnWeight = new DataGridViewTextBoxColumn();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
|
||||||
groupBox1.SuspendLayout();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewComponents).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// numericUpDownPrice
|
|
||||||
//
|
|
||||||
numericUpDownPrice.DecimalPlaces = 2;
|
|
||||||
numericUpDownPrice.Location = new Point(150, 201);
|
|
||||||
numericUpDownPrice.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
|
|
||||||
numericUpDownPrice.Name = "numericUpDownPrice";
|
|
||||||
numericUpDownPrice.Size = new Size(96, 23);
|
|
||||||
numericUpDownPrice.TabIndex = 8;
|
|
||||||
numericUpDownPrice.Value = new decimal(new int[] { 1, 0, 0, 131072 });
|
|
||||||
//
|
|
||||||
// textBoxProductName
|
|
||||||
//
|
|
||||||
textBoxProductName.Location = new Point(150, 161);
|
|
||||||
textBoxProductName.Name = "textBoxProductName";
|
|
||||||
textBoxProductName.Size = new Size(207, 23);
|
|
||||||
textBoxProductName.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(106, 203);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(38, 15);
|
|
||||||
label2.TabIndex = 6;
|
|
||||||
label2.Text = "Цена:";
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(29, 164);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(115, 15);
|
|
||||||
label1.TabIndex = 5;
|
|
||||||
label1.Text = "Название продукта:";
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
label3.AutoSize = true;
|
|
||||||
label3.Location = new Point(61, 31);
|
|
||||||
label3.Name = "label3";
|
|
||||||
label3.Size = new Size(83, 15);
|
|
||||||
label3.TabIndex = 9;
|
|
||||||
label3.Text = "Вид продукта:";
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonCancel.Location = new Point(297, 544);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(75, 23);
|
|
||||||
buttonCancel.TabIndex = 11;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonSave.Location = new Point(216, 544);
|
|
||||||
buttonSave.Name = "buttonSave";
|
|
||||||
buttonSave.Size = new Size(75, 23);
|
|
||||||
buttonSave.TabIndex = 10;
|
|
||||||
buttonSave.Text = "Сохранить";
|
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonSave.Click += ButtonSave_Click;
|
|
||||||
//
|
|
||||||
// checkedListBoxConfectioneryType
|
|
||||||
//
|
|
||||||
checkedListBoxConfectioneryType.FormattingEnabled = true;
|
|
||||||
checkedListBoxConfectioneryType.Location = new Point(150, 31);
|
|
||||||
checkedListBoxConfectioneryType.Name = "checkedListBoxConfectioneryType";
|
|
||||||
checkedListBoxConfectioneryType.Size = new Size(207, 112);
|
|
||||||
checkedListBoxConfectioneryType.TabIndex = 12;
|
|
||||||
//
|
|
||||||
// groupBox1
|
|
||||||
//
|
|
||||||
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
|
||||||
groupBox1.Controls.Add(dataGridViewComponents);
|
|
||||||
groupBox1.Location = new Point(12, 241);
|
|
||||||
groupBox1.Name = "groupBox1";
|
|
||||||
groupBox1.Size = new Size(360, 273);
|
|
||||||
groupBox1.TabIndex = 26;
|
|
||||||
groupBox1.TabStop = false;
|
|
||||||
groupBox1.Text = "Компоненты";
|
|
||||||
//
|
|
||||||
// dataGridViewComponents
|
|
||||||
//
|
|
||||||
dataGridViewComponents.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewComponents.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewComponents.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewComponents.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewComponents.Columns.AddRange(new DataGridViewColumn[] { ColumnComponent, ColumnWeight });
|
|
||||||
dataGridViewComponents.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewComponents.Location = new Point(3, 19);
|
|
||||||
dataGridViewComponents.MultiSelect = false;
|
|
||||||
dataGridViewComponents.Name = "dataGridViewComponents";
|
|
||||||
dataGridViewComponents.RowHeadersVisible = false;
|
|
||||||
dataGridViewComponents.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewComponents.Size = new Size(354, 251);
|
|
||||||
dataGridViewComponents.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// ColumnComponent
|
|
||||||
//
|
|
||||||
ColumnComponent.HeaderText = "Компонент";
|
|
||||||
ColumnComponent.Name = "ColumnComponent";
|
|
||||||
//
|
|
||||||
// ColumnWeight
|
|
||||||
//
|
|
||||||
ColumnWeight.HeaderText = "Вес";
|
|
||||||
ColumnWeight.MaxInputLength = 7;
|
|
||||||
ColumnWeight.Name = "ColumnWeight";
|
|
||||||
//
|
|
||||||
// FormProduct
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(384, 579);
|
|
||||||
Controls.Add(groupBox1);
|
|
||||||
Controls.Add(checkedListBoxConfectioneryType);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonSave);
|
|
||||||
Controls.Add(label3);
|
|
||||||
Controls.Add(numericUpDownPrice);
|
|
||||||
Controls.Add(textBoxProductName);
|
|
||||||
Controls.Add(label2);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Name = "FormProduct";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "FormProduct";
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
|
||||||
groupBox1.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewComponents).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
private NumericUpDown numericUpDownPrice;
|
|
||||||
private TextBox textBoxProductName;
|
|
||||||
private Label label2;
|
|
||||||
private Label label1;
|
|
||||||
private Label label3;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private CheckedListBox checkedListBoxConfectioneryType;
|
|
||||||
private GroupBox groupBox1;
|
|
||||||
private DataGridView dataGridViewComponents;
|
|
||||||
private DataGridViewComboBoxColumn ColumnComponent;
|
|
||||||
private DataGridViewTextBoxColumn ColumnWeight;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,116 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
using ProjectConfectioneryFactory.Entities.Enums;
|
|
||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormProduct : Form
|
|
||||||
{
|
|
||||||
private readonly IProductRepository _productRepository;
|
|
||||||
|
|
||||||
private int? _productId;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var product = _productRepository.ReadProductById(value);
|
|
||||||
if (product == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(product));
|
|
||||||
}
|
|
||||||
foreach (ConfectioneryType elem in Enum.GetValues(typeof(ConfectioneryType)))
|
|
||||||
{
|
|
||||||
if ((elem & product.ConfectioneryType) != 0)
|
|
||||||
{
|
|
||||||
checkedListBoxConfectioneryType.SetItemChecked(checkedListBoxConfectioneryType.Items.IndexOf(elem), true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
textBoxProductName.Text = product.Name;
|
|
||||||
numericUpDownPrice.Value = (decimal)product.Price;
|
|
||||||
_productId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormProduct(IProductRepository productRepository, IComponentRepository componentRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
|
||||||
|
|
||||||
foreach (var elem in Enum.GetValues(typeof(ConfectioneryType)))
|
|
||||||
{
|
|
||||||
checkedListBoxConfectioneryType.Items.Add(elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
ColumnComponent.DataSource = componentRepository.ReadComponents();
|
|
||||||
ColumnComponent.DisplayMember = "Name";
|
|
||||||
ColumnComponent.ValueMember = "Id";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (checkedListBoxConfectioneryType.CheckedItems.Count == 0 || string.IsNullOrWhiteSpace(textBoxProductName.Text) || dataGridViewComponents.RowCount <= 1)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
if (_productId.HasValue)
|
|
||||||
{
|
|
||||||
_productRepository.UpdateProduct(CreateProduct(_productId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_productRepository.CreateProduct(CreateProduct(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private List<ProductComponent> CreateListProductComponentFromDataGrid()
|
|
||||||
{
|
|
||||||
var list = new List<ProductComponent>();
|
|
||||||
foreach (DataGridViewRow row in dataGridViewComponents.Rows)
|
|
||||||
{
|
|
||||||
if (row.Cells["ColumnComponent"].Value == null ||
|
|
||||||
row.Cells["ColumnWeight"].Value == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
list.Add(ProductComponent.CreateEntity(0,
|
|
||||||
Convert.ToInt32(row.Cells["ColumnComponent"].Value),
|
|
||||||
Convert.ToDouble(row.Cells["ColumnWeight"].Value)));
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Product CreateProduct(int id)
|
|
||||||
{
|
|
||||||
ConfectioneryType confectioneryType = ConfectioneryType.None;
|
|
||||||
foreach (var elem in checkedListBoxConfectioneryType.CheckedItems)
|
|
||||||
{
|
|
||||||
confectioneryType |= (ConfectioneryType)elem;
|
|
||||||
}
|
|
||||||
return Product.CreateEntity(
|
|
||||||
id,
|
|
||||||
confectioneryType,
|
|
||||||
textBoxProductName.Text,
|
|
||||||
(double)numericUpDownPrice.Value,
|
|
||||||
CreateListProductComponentFromDataGrid());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,126 +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="ColumnComponent.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="ColumnWeight.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
|
@ -1,126 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.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()
|
|
||||||
{
|
|
||||||
buttonUpdate = new Button();
|
|
||||||
buttonDelete = new Button();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
dataGridViewData = new DataGridView();
|
|
||||||
panel1 = new Panel();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
buttonUpdate.BackgroundImage = Properties.Resources.Update;
|
|
||||||
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUpdate.Location = new Point(14, 83);
|
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
|
||||||
buttonUpdate.Size = new Size(65, 65);
|
|
||||||
buttonUpdate.TabIndex = 1;
|
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdate.Click += ButtonUpdate_Click;
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
buttonDelete.BackgroundImage = Properties.Resources.Delete;
|
|
||||||
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDelete.Location = new Point(14, 154);
|
|
||||||
buttonDelete.Name = "buttonDelete";
|
|
||||||
buttonDelete.Size = new Size(65, 65);
|
|
||||||
buttonDelete.TabIndex = 1;
|
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
buttonDelete.Click += ButtonDelete_Click;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.BackgroundImage = Properties.Resources.Add;
|
|
||||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAdd.Location = new Point(14, 12);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(65, 65);
|
|
||||||
buttonAdd.TabIndex = 0;
|
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
|
||||||
//
|
|
||||||
// dataGridViewData
|
|
||||||
//
|
|
||||||
dataGridViewData.AllowUserToAddRows = false;
|
|
||||||
dataGridViewData.AllowUserToDeleteRows = false;
|
|
||||||
dataGridViewData.AllowUserToResizeColumns = false;
|
|
||||||
dataGridViewData.AllowUserToResizeRows = false;
|
|
||||||
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
|
||||||
dataGridViewData.Dock = DockStyle.Fill;
|
|
||||||
dataGridViewData.Location = new Point(0, 0);
|
|
||||||
dataGridViewData.MultiSelect = false;
|
|
||||||
dataGridViewData.Name = "dataGridViewData";
|
|
||||||
dataGridViewData.ReadOnly = true;
|
|
||||||
dataGridViewData.RowHeadersVisible = false;
|
|
||||||
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
|
||||||
dataGridViewData.Size = new Size(709, 450);
|
|
||||||
dataGridViewData.TabIndex = 3;
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(buttonUpdate);
|
|
||||||
panel1.Controls.Add(buttonDelete);
|
|
||||||
panel1.Controls.Add(buttonAdd);
|
|
||||||
panel1.Dock = DockStyle.Right;
|
|
||||||
panel1.Location = new Point(709, 0);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(91, 450);
|
|
||||||
panel1.TabIndex = 2;
|
|
||||||
//
|
|
||||||
// FormProducts
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Name = "FormProducts";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "FormProducts";
|
|
||||||
Load += FormProducts_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private Button buttonUpdate;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private DataGridView dataGridViewData;
|
|
||||||
private Panel panel1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormProducts : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly IProductRepository _productRepository;
|
|
||||||
public FormProducts(IUnityContainer container, IProductRepository productRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
|
||||||
}
|
|
||||||
private void FormProducts_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormProduct>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormProduct>();
|
|
||||||
form.Id = findId;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) { return; }
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_productRepository.DeleteProduct(findId); LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void LoadList() => dataGridViewData.DataSource = _productRepository.ReadProducts();
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridViewData.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,143 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.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()
|
|
||||||
{
|
|
||||||
maskedTextBoxPhone = new MaskedTextBox();
|
|
||||||
textBoxAddress = new TextBox();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
buttonSave = new Button();
|
|
||||||
textBoxSupplierName = new TextBox();
|
|
||||||
label3 = new Label();
|
|
||||||
label2 = new Label();
|
|
||||||
label1 = new Label();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// maskedTextBoxPhone
|
|
||||||
//
|
|
||||||
maskedTextBoxPhone.Location = new Point(121, 56);
|
|
||||||
maskedTextBoxPhone.Mask = "+7 (999) 000-0000";
|
|
||||||
maskedTextBoxPhone.Name = "maskedTextBoxPhone";
|
|
||||||
maskedTextBoxPhone.Size = new Size(207, 23);
|
|
||||||
maskedTextBoxPhone.TabIndex = 27;
|
|
||||||
//
|
|
||||||
// textBoxAddress
|
|
||||||
//
|
|
||||||
textBoxAddress.Location = new Point(121, 93);
|
|
||||||
textBoxAddress.Name = "textBoxAddress";
|
|
||||||
textBoxAddress.Size = new Size(207, 23);
|
|
||||||
textBoxAddress.TabIndex = 26;
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonCancel.Location = new Point(297, 156);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(75, 23);
|
|
||||||
buttonCancel.TabIndex = 25;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonSave.Location = new Point(216, 156);
|
|
||||||
buttonSave.Name = "buttonSave";
|
|
||||||
buttonSave.Size = new Size(75, 23);
|
|
||||||
buttonSave.TabIndex = 24;
|
|
||||||
buttonSave.Text = "Сохранить";
|
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonSave.Click += ButtonSave_Click;
|
|
||||||
//
|
|
||||||
// textBoxSupplierName
|
|
||||||
//
|
|
||||||
textBoxSupplierName.Location = new Point(121, 20);
|
|
||||||
textBoxSupplierName.Name = "textBoxSupplierName";
|
|
||||||
textBoxSupplierName.Size = new Size(207, 23);
|
|
||||||
textBoxSupplierName.TabIndex = 23;
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
label3.AutoSize = true;
|
|
||||||
label3.Location = new Point(72, 96);
|
|
||||||
label3.Name = "label3";
|
|
||||||
label3.Size = new Size(43, 15);
|
|
||||||
label3.TabIndex = 22;
|
|
||||||
label3.Text = "Адрес:";
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(57, 59);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(58, 15);
|
|
||||||
label2.TabIndex = 21;
|
|
||||||
label2.Text = "Телефон:";
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(81, 23);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(34, 15);
|
|
||||||
label1.TabIndex = 20;
|
|
||||||
label1.Text = "Имя:";
|
|
||||||
//
|
|
||||||
// FormSupplier
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(384, 191);
|
|
||||||
Controls.Add(maskedTextBoxPhone);
|
|
||||||
Controls.Add(textBoxAddress);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonSave);
|
|
||||||
Controls.Add(textBoxSupplierName);
|
|
||||||
Controls.Add(label3);
|
|
||||||
Controls.Add(label2);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Name = "FormSupplier";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "FormSupplier";
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private MaskedTextBox maskedTextBoxPhone;
|
|
||||||
private TextBox textBoxAddress;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private TextBox textBoxSupplierName;
|
|
||||||
private Label label3;
|
|
||||||
private Label label2;
|
|
||||||
private Label label1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormSupplier : Form
|
|
||||||
{
|
|
||||||
private readonly ISupplierRepository _supplierRepository;
|
|
||||||
|
|
||||||
private int? _supplierId;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var supplier = _supplierRepository.ReadSupplierById(value);
|
|
||||||
if (supplier == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(supplier));
|
|
||||||
}
|
|
||||||
textBoxSupplierName.Text = supplier.Name;
|
|
||||||
maskedTextBoxPhone.Text = supplier.Phone.ToString();
|
|
||||||
textBoxAddress.Text = supplier.Address;
|
|
||||||
_supplierId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormSupplier(ISupplierRepository supplierRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_supplierRepository = supplierRepository ?? throw new ArgumentNullException(nameof(supplierRepository));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(textBoxSupplierName.Text) || !maskedTextBoxPhone.MaskCompleted || string.IsNullOrWhiteSpace(textBoxAddress.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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private Supplier CreateSupplier(int id) => Supplier.CreateEntity(
|
|
||||||
id,
|
|
||||||
textBoxSupplierName.Text,
|
|
||||||
maskedTextBoxPhone.Text,
|
|
||||||
textBoxAddress.Text);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,126 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.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()
|
|
||||||
{
|
|
||||||
dataGridViewData = new DataGridView();
|
|
||||||
buttonUpdate = new Button();
|
|
||||||
buttonDelete = new Button();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
panel1 = new Panel();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// 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(709, 450);
|
|
||||||
dataGridViewData.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
buttonUpdate.BackgroundImage = Properties.Resources.Update;
|
|
||||||
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUpdate.Location = new Point(14, 83);
|
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
|
||||||
buttonUpdate.Size = new Size(65, 65);
|
|
||||||
buttonUpdate.TabIndex = 1;
|
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdate.Click += ButtonUpdate_Click;
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
buttonDelete.BackgroundImage = Properties.Resources.Delete;
|
|
||||||
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDelete.Location = new Point(14, 154);
|
|
||||||
buttonDelete.Name = "buttonDelete";
|
|
||||||
buttonDelete.Size = new Size(65, 65);
|
|
||||||
buttonDelete.TabIndex = 1;
|
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
buttonDelete.Click += ButtonDelete_Click;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.BackgroundImage = Properties.Resources.Add;
|
|
||||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAdd.Location = new Point(14, 12);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(65, 65);
|
|
||||||
buttonAdd.TabIndex = 0;
|
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(buttonUpdate);
|
|
||||||
panel1.Controls.Add(buttonDelete);
|
|
||||||
panel1.Controls.Add(buttonAdd);
|
|
||||||
panel1.Dock = DockStyle.Right;
|
|
||||||
panel1.Location = new Point(709, 0);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(91, 450);
|
|
||||||
panel1.TabIndex = 4;
|
|
||||||
//
|
|
||||||
// FormSuppliers
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Name = "FormSuppliers";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "FormSuppliers";
|
|
||||||
Load += FormSuppliers_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridViewData;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Panel panel1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormSuppliers : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly ISupplierRepository _supplierRepository;
|
|
||||||
public FormSuppliers(IUnityContainer container, ISupplierRepository supplierRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_supplierRepository = supplierRepository ?? throw new ArgumentNullException(nameof(supplierRepository));
|
|
||||||
}
|
|
||||||
private void FormSuppliers_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormSupplier>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(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 ButtonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(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 LoadList() => dataGridViewData.DataSource = _supplierRepository.ReadSuppliers();
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridViewData.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,198 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.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()
|
|
||||||
{
|
|
||||||
dateTimePicker1 = new DateTimePicker();
|
|
||||||
label2 = new Label();
|
|
||||||
buttonCancel = new Button();
|
|
||||||
buttonSave = new Button();
|
|
||||||
comboBoxSupplier = new ComboBox();
|
|
||||||
checkBoxCompleted = new CheckBox();
|
|
||||||
label4 = new Label();
|
|
||||||
label1 = new Label();
|
|
||||||
comboBoxComponent = new ComboBox();
|
|
||||||
label3 = new Label();
|
|
||||||
numericUpDownWeight = new NumericUpDown();
|
|
||||||
label5 = new Label();
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).BeginInit();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// dateTimePicker1
|
|
||||||
//
|
|
||||||
dateTimePicker1.Enabled = false;
|
|
||||||
dateTimePicker1.Location = new Point(108, 183);
|
|
||||||
dateTimePicker1.Name = "dateTimePicker1";
|
|
||||||
dateTimePicker1.Size = new Size(200, 23);
|
|
||||||
dateTimePicker1.TabIndex = 32;
|
|
||||||
//
|
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(67, 189);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(35, 15);
|
|
||||||
label2.TabIndex = 31;
|
|
||||||
label2.Text = "Дата:";
|
|
||||||
//
|
|
||||||
// buttonCancel
|
|
||||||
//
|
|
||||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonCancel.Location = new Point(297, 251);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
|
||||||
buttonCancel.Size = new Size(75, 23);
|
|
||||||
buttonCancel.TabIndex = 30;
|
|
||||||
buttonCancel.Text = "Отмена";
|
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
|
||||||
//
|
|
||||||
// buttonSave
|
|
||||||
//
|
|
||||||
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
|
||||||
buttonSave.Location = new Point(216, 251);
|
|
||||||
buttonSave.Name = "buttonSave";
|
|
||||||
buttonSave.Size = new Size(75, 23);
|
|
||||||
buttonSave.TabIndex = 29;
|
|
||||||
buttonSave.Text = "Сохранить";
|
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
|
||||||
buttonSave.Click += ButtonSave_Click;
|
|
||||||
//
|
|
||||||
// comboBoxSupplier
|
|
||||||
//
|
|
||||||
comboBoxSupplier.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxSupplier.FormattingEnabled = true;
|
|
||||||
comboBoxSupplier.Location = new Point(108, 25);
|
|
||||||
comboBoxSupplier.Name = "comboBoxSupplier";
|
|
||||||
comboBoxSupplier.Size = new Size(210, 23);
|
|
||||||
comboBoxSupplier.TabIndex = 28;
|
|
||||||
//
|
|
||||||
// checkBoxCompleted
|
|
||||||
//
|
|
||||||
checkBoxCompleted.AutoSize = true;
|
|
||||||
checkBoxCompleted.Location = new Point(108, 150);
|
|
||||||
checkBoxCompleted.Name = "checkBoxCompleted";
|
|
||||||
checkBoxCompleted.Size = new Size(15, 14);
|
|
||||||
checkBoxCompleted.TabIndex = 27;
|
|
||||||
checkBoxCompleted.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// label4
|
|
||||||
//
|
|
||||||
label4.AutoSize = true;
|
|
||||||
label4.Location = new Point(35, 149);
|
|
||||||
label4.Name = "label4";
|
|
||||||
label4.Size = new Size(67, 15);
|
|
||||||
label4.TabIndex = 26;
|
|
||||||
label4.Text = "Выполнен:";
|
|
||||||
//
|
|
||||||
// label1
|
|
||||||
//
|
|
||||||
label1.AutoSize = true;
|
|
||||||
label1.Location = new Point(29, 28);
|
|
||||||
label1.Name = "label1";
|
|
||||||
label1.Size = new Size(73, 15);
|
|
||||||
label1.TabIndex = 25;
|
|
||||||
label1.Text = "Поставщик:";
|
|
||||||
//
|
|
||||||
// comboBoxComponent
|
|
||||||
//
|
|
||||||
comboBoxComponent.DropDownStyle = ComboBoxStyle.DropDownList;
|
|
||||||
comboBoxComponent.FormattingEnabled = true;
|
|
||||||
comboBoxComponent.Location = new Point(108, 66);
|
|
||||||
comboBoxComponent.Name = "comboBoxComponent";
|
|
||||||
comboBoxComponent.Size = new Size(210, 23);
|
|
||||||
comboBoxComponent.TabIndex = 34;
|
|
||||||
//
|
|
||||||
// label3
|
|
||||||
//
|
|
||||||
label3.AutoSize = true;
|
|
||||||
label3.Location = new Point(30, 69);
|
|
||||||
label3.Name = "label3";
|
|
||||||
label3.Size = new Size(72, 15);
|
|
||||||
label3.TabIndex = 33;
|
|
||||||
label3.Text = "Компонент:";
|
|
||||||
//
|
|
||||||
// numericUpDownWeight
|
|
||||||
//
|
|
||||||
numericUpDownWeight.DecimalPlaces = 3;
|
|
||||||
numericUpDownWeight.Location = new Point(108, 105);
|
|
||||||
numericUpDownWeight.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
|
|
||||||
numericUpDownWeight.Name = "numericUpDownWeight";
|
|
||||||
numericUpDownWeight.Size = new Size(96, 23);
|
|
||||||
numericUpDownWeight.TabIndex = 36;
|
|
||||||
numericUpDownWeight.Value = new decimal(new int[] { 1, 0, 0, 196608 });
|
|
||||||
//
|
|
||||||
// label5
|
|
||||||
//
|
|
||||||
label5.AutoSize = true;
|
|
||||||
label5.Location = new Point(73, 107);
|
|
||||||
label5.Name = "label5";
|
|
||||||
label5.Size = new Size(29, 15);
|
|
||||||
label5.TabIndex = 35;
|
|
||||||
label5.Text = "Вес:";
|
|
||||||
//
|
|
||||||
// FormSupply
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(384, 286);
|
|
||||||
Controls.Add(numericUpDownWeight);
|
|
||||||
Controls.Add(label5);
|
|
||||||
Controls.Add(comboBoxComponent);
|
|
||||||
Controls.Add(label3);
|
|
||||||
Controls.Add(dateTimePicker1);
|
|
||||||
Controls.Add(label2);
|
|
||||||
Controls.Add(buttonCancel);
|
|
||||||
Controls.Add(buttonSave);
|
|
||||||
Controls.Add(comboBoxSupplier);
|
|
||||||
Controls.Add(checkBoxCompleted);
|
|
||||||
Controls.Add(label4);
|
|
||||||
Controls.Add(label1);
|
|
||||||
Name = "FormSupply";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "FormSupply";
|
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownWeight).EndInit();
|
|
||||||
ResumeLayout(false);
|
|
||||||
PerformLayout();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DateTimePicker dateTimePicker1;
|
|
||||||
private Label label2;
|
|
||||||
private Button buttonCancel;
|
|
||||||
private Button buttonSave;
|
|
||||||
private ComboBox comboBoxSupplier;
|
|
||||||
private CheckBox checkBoxCompleted;
|
|
||||||
private Label label4;
|
|
||||||
private Label label1;
|
|
||||||
private ComboBox comboBoxComponent;
|
|
||||||
private Label label3;
|
|
||||||
private NumericUpDown numericUpDownWeight;
|
|
||||||
private Label label5;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormSupply : Form
|
|
||||||
{
|
|
||||||
private readonly ISupplyRepository _supplyRepository;
|
|
||||||
|
|
||||||
private int? _supplyId;
|
|
||||||
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var supply = _supplyRepository.ReadSupplyById(value);
|
|
||||||
if (supply == null)
|
|
||||||
{
|
|
||||||
throw new InvalidDataException(nameof(supply));
|
|
||||||
}
|
|
||||||
numericUpDownWeight.Value = (decimal)supply.Weight;
|
|
||||||
checkBoxCompleted.Checked = supply.Completed;
|
|
||||||
_supplyId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); return; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public FormSupply(ISupplyRepository supplyRepository, ISupplierRepository supplierRepository, IComponentRepository componentRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_supplyRepository = supplyRepository ?? throw new ArgumentNullException(nameof(supplyRepository));
|
|
||||||
|
|
||||||
comboBoxSupplier.DataSource = supplierRepository.ReadSuppliers();
|
|
||||||
comboBoxSupplier.DisplayMember = "Name";
|
|
||||||
comboBoxSupplier.ValueMember = "Id";
|
|
||||||
|
|
||||||
comboBoxComponent.DataSource = componentRepository.ReadComponents();
|
|
||||||
comboBoxComponent.DisplayMember = "Name";
|
|
||||||
comboBoxComponent.ValueMember = "Id";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (comboBoxSupplier.SelectedIndex < 0 || comboBoxComponent.SelectedIndex < 0)
|
|
||||||
{
|
|
||||||
throw new Exception("Имеются незаполненные поля");
|
|
||||||
}
|
|
||||||
if (_supplyId.HasValue)
|
|
||||||
{
|
|
||||||
_supplyRepository.UpdateSupply(CreateSupply(_supplyId.Value));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_supplyRepository.CreateSupply(CreateSupply(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
|
|
||||||
private Supply CreateSupply(int id) => Supply.CreateOperation(
|
|
||||||
id,
|
|
||||||
(int)comboBoxSupplier.SelectedValue!,
|
|
||||||
(int)comboBoxComponent.SelectedValue!,
|
|
||||||
Convert.ToDouble(numericUpDownWeight.Value),
|
|
||||||
checkBoxCompleted.Checked);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,126 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
partial class FormSupplys
|
|
||||||
{
|
|
||||||
/// <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()
|
|
||||||
{
|
|
||||||
dataGridViewData = new DataGridView();
|
|
||||||
buttonUpdate = new Button();
|
|
||||||
buttonDelete = new Button();
|
|
||||||
buttonAdd = new Button();
|
|
||||||
panel1 = new Panel();
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
|
|
||||||
panel1.SuspendLayout();
|
|
||||||
SuspendLayout();
|
|
||||||
//
|
|
||||||
// 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(709, 450);
|
|
||||||
dataGridViewData.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonUpdate
|
|
||||||
//
|
|
||||||
buttonUpdate.BackgroundImage = Properties.Resources.Update;
|
|
||||||
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonUpdate.Location = new Point(14, 83);
|
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
|
||||||
buttonUpdate.Size = new Size(65, 65);
|
|
||||||
buttonUpdate.TabIndex = 1;
|
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
|
||||||
buttonUpdate.Click += ButtonUpdate_Click;
|
|
||||||
//
|
|
||||||
// buttonDelete
|
|
||||||
//
|
|
||||||
buttonDelete.BackgroundImage = Properties.Resources.Delete;
|
|
||||||
buttonDelete.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonDelete.Location = new Point(14, 154);
|
|
||||||
buttonDelete.Name = "buttonDelete";
|
|
||||||
buttonDelete.Size = new Size(65, 65);
|
|
||||||
buttonDelete.TabIndex = 1;
|
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
|
||||||
buttonDelete.Click += ButtonDelete_Click;
|
|
||||||
//
|
|
||||||
// buttonAdd
|
|
||||||
//
|
|
||||||
buttonAdd.BackgroundImage = Properties.Resources.Add;
|
|
||||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
|
||||||
buttonAdd.Location = new Point(14, 12);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
|
||||||
buttonAdd.Size = new Size(65, 65);
|
|
||||||
buttonAdd.TabIndex = 0;
|
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
|
||||||
//
|
|
||||||
// panel1
|
|
||||||
//
|
|
||||||
panel1.Controls.Add(buttonUpdate);
|
|
||||||
panel1.Controls.Add(buttonDelete);
|
|
||||||
panel1.Controls.Add(buttonAdd);
|
|
||||||
panel1.Dock = DockStyle.Right;
|
|
||||||
panel1.Location = new Point(709, 0);
|
|
||||||
panel1.Name = "panel1";
|
|
||||||
panel1.Size = new Size(91, 450);
|
|
||||||
panel1.TabIndex = 6;
|
|
||||||
//
|
|
||||||
// FormSupplys
|
|
||||||
//
|
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
|
||||||
ClientSize = new Size(800, 450);
|
|
||||||
Controls.Add(dataGridViewData);
|
|
||||||
Controls.Add(panel1);
|
|
||||||
Name = "FormSupplys";
|
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
|
||||||
Text = "FormSupplys";
|
|
||||||
Load += FormSupplys_Load;
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
|
|
||||||
panel1.ResumeLayout(false);
|
|
||||||
ResumeLayout(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
private DataGridView dataGridViewData;
|
|
||||||
private Button buttonUpdate;
|
|
||||||
private Button buttonDelete;
|
|
||||||
private Button buttonAdd;
|
|
||||||
private Panel panel1;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,80 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
using Unity;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Forms
|
|
||||||
{
|
|
||||||
public partial class FormSupplys : Form
|
|
||||||
{
|
|
||||||
private readonly IUnityContainer _container;
|
|
||||||
private readonly ISupplyRepository _supplyRepository;
|
|
||||||
public FormSupplys(IUnityContainer container, ISupplyRepository supplyRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
|
||||||
_supplyRepository = supplyRepository ?? throw new ArgumentNullException(nameof(supplyRepository));
|
|
||||||
}
|
|
||||||
private void FormSupplys_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormSupply>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonUpdate_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId)) { return; }
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormSupply>();
|
|
||||||
form.Id = findId;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void ButtonDelete_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(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.ReadSupplys();
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridViewData.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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>
|
|
@ -1,56 +0,0 @@
|
|||||||
using Unity.Lifetime;
|
|
||||||
using Unity;
|
|
||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
using ProjectConfectioneryFactory.Repositories.Implementations;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Serilog;
|
|
||||||
using Unity.Microsoft.Logging;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory
|
|
||||||
{
|
|
||||||
internal static class Program
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The main entry point for the application.
|
|
||||||
/// </summary>
|
|
||||||
[STAThread]
|
|
||||||
static void Main()
|
|
||||||
{
|
|
||||||
// To customize application configuration such as set high DPI settings or default font,
|
|
||||||
// see https://aka.ms/applicationconfiguration.
|
|
||||||
ApplicationConfiguration.Initialize();
|
|
||||||
Application.Run(CreateContainer().Resolve<FormConfectioneryFactory>());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static IUnityContainer CreateContainer()
|
|
||||||
{
|
|
||||||
var container = new UnityContainer();
|
|
||||||
|
|
||||||
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
|
||||||
|
|
||||||
container.RegisterType<IClientRepository, ClientRepository>(new TransientLifetimeManager());
|
|
||||||
container.RegisterType<IComponentRepository, ComponentRepository>(new TransientLifetimeManager());
|
|
||||||
container.RegisterType<IOrderRepository, OrderRepository>(new TransientLifetimeManager());
|
|
||||||
container.RegisterType<IProductRepository, ProductRepository>(new TransientLifetimeManager());
|
|
||||||
container.RegisterType<ISupplierRepository, SupplierRepository>(new TransientLifetimeManager());
|
|
||||||
container.RegisterType<ISupplyRepository, SupplyRepository>(new TransientLifetimeManager());
|
|
||||||
|
|
||||||
container.RegisterType<IConnectionString, ConnectionString>(new SingletonLifetimeManager());
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>WinExe</OutputType>
|
|
||||||
<TargetFramework>net8.0-windows</TargetFramework>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
|
||||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.1" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
|
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
|
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
|
||||||
<PackageReference Include="Npgsql" Version="9.0.2" />
|
|
||||||
<PackageReference Include="Serilog" Version="4.0.2" />
|
|
||||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
|
||||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.9.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>
|
|
@ -1,103 +0,0 @@
|
|||||||
//------------------------------------------------------------------------------
|
|
||||||
// <auto-generated>
|
|
||||||
// Этот код создан программой.
|
|
||||||
// Исполняемая версия:4.0.30319.42000
|
|
||||||
//
|
|
||||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
|
||||||
// повторной генерации кода.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.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("ProjectConfectioneryFactory.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 Add {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Add", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap Croissant {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Croissant", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap Delete {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Delete", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
|
||||||
/// </summary>
|
|
||||||
internal static System.Drawing.Bitmap Update {
|
|
||||||
get {
|
|
||||||
object obj = ResourceManager.GetObject("Update", resourceCulture);
|
|
||||||
return ((System.Drawing.Bitmap)(obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,133 +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>
|
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
|
||||||
<data name="Delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="Croissant" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Croissant.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="Add" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
<data name="Update" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>..\Resources\Update.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
|
||||||
</data>
|
|
||||||
</root>
|
|
@ -1,87 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Reports;
|
|
||||||
|
|
||||||
public class DocReport
|
|
||||||
{
|
|
||||||
private readonly IClientRepository _clientRepository;
|
|
||||||
private readonly IComponentRepository _componentRepository;
|
|
||||||
private readonly IProductRepository _productRepository;
|
|
||||||
private readonly ISupplierRepository _supplierRepository;
|
|
||||||
|
|
||||||
private readonly ILogger<DocReport> _logger;
|
|
||||||
|
|
||||||
public DocReport(IClientRepository clientRepository, IComponentRepository componentRepository,
|
|
||||||
IProductRepository productRepository, ISupplierRepository supplierRepository, ILogger<DocReport> logger)
|
|
||||||
{
|
|
||||||
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
|
|
||||||
_componentRepository = componentRepository ?? throw new ArgumentNullException(nameof(componentRepository));
|
|
||||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
|
||||||
_supplierRepository = supplierRepository ?? throw new ArgumentNullException(nameof(supplierRepository));
|
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
public bool CreateDoc(string filePath, bool includeClients, bool includeComponents, bool includeProducts, bool includeSuppliers)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var builder = new WordBuilder(filePath)
|
|
||||||
.AddHeader("Документ со справочниками");
|
|
||||||
if (includeClients)
|
|
||||||
{
|
|
||||||
builder.AddParagraph("Клиенты")
|
|
||||||
.AddTable([2400, 2400, 1200, 1200], GetClients());
|
|
||||||
}
|
|
||||||
if (includeComponents)
|
|
||||||
{
|
|
||||||
builder.AddParagraph("Компоненты")
|
|
||||||
.AddTable([2400, 2400, 2400], GetComponents());
|
|
||||||
}
|
|
||||||
if (includeProducts)
|
|
||||||
{
|
|
||||||
builder.AddParagraph("Продукты")
|
|
||||||
.AddTable([2400, 2400, 2400], GetProducts());
|
|
||||||
}
|
|
||||||
if (includeSuppliers)
|
|
||||||
{
|
|
||||||
builder.AddParagraph("Поставщики")
|
|
||||||
.AddTable([2400, 2400, 2400], GetSuppliers());
|
|
||||||
}
|
|
||||||
builder.Build();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetClients() => [
|
|
||||||
["Имя", "Фамилия", "Телефон", "Адрес"],
|
|
||||||
.. _clientRepository
|
|
||||||
.ReadClients()
|
|
||||||
.Select(x => new string[] { x.Name, x.Surname, x.Phone, x.Address }),
|
|
||||||
];
|
|
||||||
|
|
||||||
private List<string[]> GetComponents() => [
|
|
||||||
["Название", "Цена", "Вес"],
|
|
||||||
.. _componentRepository
|
|
||||||
.ReadComponents()
|
|
||||||
.Select(x => new string[] { x.Name, x.Price.ToString(), x.Weight.ToString() }),
|
|
||||||
];
|
|
||||||
|
|
||||||
private List<string[]> GetProducts() => [
|
|
||||||
["Тип продукта", "Название", "Цена"],
|
|
||||||
.. _productRepository
|
|
||||||
.ReadProducts()
|
|
||||||
.Select(x => new string[] { x.ConfectioneryType.ToString(), x.Name, x.Price.ToString() }),
|
|
||||||
];
|
|
||||||
|
|
||||||
private List<string[]> GetSuppliers() => [
|
|
||||||
["Имя", "Телефон", "Адрес"],
|
|
||||||
.. _supplierRepository
|
|
||||||
.ReadSuppliers()
|
|
||||||
.Select(x => new string[] { x.Name, x.Phone, x.Address }),
|
|
||||||
];
|
|
||||||
}
|
|
@ -1,326 +0,0 @@
|
|||||||
using DocumentFormat.OpenXml;
|
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Spreadsheet;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Reports;
|
|
||||||
|
|
||||||
public 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.SimpleTextWithoutBorder);
|
|
||||||
|
|
||||||
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.SimpleTextWithoutBorder);
|
|
||||||
}
|
|
||||||
|
|
||||||
_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.SimpleTextWithoutBorder);
|
|
||||||
}
|
|
||||||
_rowIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var j = 0; j < data.Last().Length; ++j)
|
|
||||||
{
|
|
||||||
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.SimpleTextWithoutBorder);
|
|
||||||
}
|
|
||||||
_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)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// шрифт с жирным
|
|
||||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
|
||||||
{
|
|
||||||
FontSize = new FontSize() { Val = 11 },
|
|
||||||
FontName = new FontName() { Val = "Calibri" },
|
|
||||||
Bold = new Bold() { Val = true },
|
|
||||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
|
||||||
FontScheme = new FontScheme()
|
|
||||||
{
|
|
||||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
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.Dashed },
|
|
||||||
RightBorder = new RightBorder() { Style = BorderStyleValues.Dashed },
|
|
||||||
TopBorder = new TopBorder() { Style = BorderStyleValues.Dashed },
|
|
||||||
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Dashed },
|
|
||||||
DiagonalBorder = new DiagonalBorder() { Style = BorderStyleValues.Dashed }
|
|
||||||
});
|
|
||||||
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 = 1,
|
|
||||||
FormatId = 0,
|
|
||||||
FontId = 1,
|
|
||||||
BorderId = 0,
|
|
||||||
FillId = 0,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Horizontal = HorizontalAlignmentValues.Left,
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cellFormats.Append(new CellFormat
|
|
||||||
{
|
|
||||||
NumberFormatId = 2,
|
|
||||||
FormatId = 0,
|
|
||||||
FontId = 0,
|
|
||||||
BorderId = 1,
|
|
||||||
FillId = 0,
|
|
||||||
Alignment = new Alignment()
|
|
||||||
{
|
|
||||||
Horizontal = HorizontalAlignmentValues.Left,
|
|
||||||
Vertical = VerticalAlignmentValues.Center,
|
|
||||||
WrapText = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
cellFormats.Append(new CellFormat
|
|
||||||
{
|
|
||||||
NumberFormatId = 3,
|
|
||||||
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,103 +0,0 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Reports;
|
|
||||||
|
|
||||||
public class TableReport
|
|
||||||
{
|
|
||||||
private readonly IOrderRepository _orderRepository;
|
|
||||||
private readonly ISupplyRepository _supplyRepository;
|
|
||||||
private readonly IProductRepository _productRepository;
|
|
||||||
private readonly ILogger<TableReport> _logger;
|
|
||||||
internal static readonly string[] item = ["Сотрудник", "Дата", "Количество пришло", "Количество ушло"];
|
|
||||||
public TableReport(IOrderRepository orderRepository, ISupplyRepository supplyRepository, IProductRepository productRepository, ILogger<TableReport> logger)
|
|
||||||
{
|
|
||||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
|
||||||
_supplyRepository = supplyRepository ?? throw new ArgumentNullException(nameof(supplyRepository));
|
|
||||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CreateTable(string filePath, int componentId, DateTime startDate, DateTime endDate)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
new ExcelBuilder(filePath)
|
|
||||||
.AddHeader("Сводка по движению компонентов", 0, 4)
|
|
||||||
.AddParagraph("за период", 0)
|
|
||||||
.AddTable([10, 10, 15, 15], GetData(componentId, startDate, endDate))
|
|
||||||
.Build();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetData(int feedId, DateTime startDate, DateTime endDate)
|
|
||||||
{
|
|
||||||
var data = _supplyRepository
|
|
||||||
.ReadSupplys()
|
|
||||||
.Where(x => x.Date >= startDate && x.Date <= endDate && x.ComponentId == componentId)
|
|
||||||
.Select(x => new
|
|
||||||
{
|
|
||||||
EmployeeId = x.SupplierId, // Идентификатор поставщика
|
|
||||||
Date = x.Date,
|
|
||||||
CountIn = x.Weight, // Вес поставленного компонента
|
|
||||||
CountOut = (decimal?)null
|
|
||||||
})
|
|
||||||
.Union(
|
|
||||||
_orderRepository
|
|
||||||
.ReadOrders()
|
|
||||||
.Where(x => x.Date >= startDate && x.Date <= endDate && x.Completed)
|
|
||||||
.SelectMany(x => _orderRepository
|
|
||||||
.ReadOrders()
|
|
||||||
.SelectMany(y => _productRepository
|
|
||||||
.ReadProducts()
|
|
||||||
.Where(z => z.ProductComponents == componentId)
|
|
||||||
.Select(z => new
|
|
||||||
{
|
|
||||||
EmployeeId = x.ClientId,
|
|
||||||
Date = x.Date,
|
|
||||||
CountIn = (decimal?)null,
|
|
||||||
CountOut = z.Weight * (decimal)y.Count
|
|
||||||
})
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.OrderBy(x => x.Date);
|
|
||||||
return
|
|
||||||
new List<string[]>() { item }
|
|
||||||
.Union(
|
|
||||||
data
|
|
||||||
.Select(x => new string[] { x.EmployeeId.ToString(), x.Date.ToString(), x.CountIn?.ToString() ?? string.Empty, x.CountOut?.ToString() ?? string.Empty }))
|
|
||||||
.Union(
|
|
||||||
[["Всего", "", data.Sum(x => x.CountIn ?? 0).ToString(), data.Sum(x => x.CountOut ?? 0).ToString()]])
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<string[]> GetData(int feedId, DateTime startDate, DateTime endDate)
|
|
||||||
{
|
|
||||||
var data = _feedReplenishmentRepository
|
|
||||||
.ReadFeedReplenishment()
|
|
||||||
.Where(x => x.DateReceipt >= startDate && x.DateReceipt <= endDate && x.FeedFeedReplenishments.Any(y => y.FeedId == feedId))
|
|
||||||
.Select(x => new { x.EmployeeId, Date = x.DateReceipt, CountIn = x.FeedFeedReplenishments.FirstOrDefault(y => y.FeedId == feedId)?.Count, CountOut = (int?)null })
|
|
||||||
.Union(
|
|
||||||
_feedingAnimalRepository
|
|
||||||
.ReadFeedingAnimals()
|
|
||||||
.Where(x => x.FeedingDate >= startDate && x.FeedingDate <= endDate && x.FeedId == feedId)
|
|
||||||
.Select(x => new { x.EmployeeId, Date =x.FeedingDate,CountIn = (int?)null, CountOut = (int?)x.Ration }))
|
|
||||||
.OrderBy(x => x.Date);
|
|
||||||
return
|
|
||||||
new List<string[]>() { item }
|
|
||||||
.Union(
|
|
||||||
data
|
|
||||||
.Select(x => new string[] { x.EmployeeId.ToString(), x.Date.ToString(), x.CountIn?.ToString() ?? string.Empty, x.CountOut?.ToString() ?? string.Empty }))
|
|
||||||
.Union(
|
|
||||||
[["Всего", "", data.Sum(x => x.CountIn ?? 0).ToString(), data.Sum(x => x.CountOut ?? 0).ToString()]])
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
|||||||
using DocumentFormat.OpenXml;
|
|
||||||
using DocumentFormat.OpenXml.Packaging;
|
|
||||||
using DocumentFormat.OpenXml.Wordprocessing;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Reports;
|
|
||||||
|
|
||||||
public 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());
|
|
||||||
RunProperties runProperties = run.AppendChild(new RunProperties());
|
|
||||||
Bold bold = new Bold { Val = true };
|
|
||||||
runProperties.AppendChild(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,16 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
public interface IClientRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Client> ReadClients();
|
|
||||||
|
|
||||||
Client ReadClientById(int id);
|
|
||||||
|
|
||||||
void CreateClient(Client client);
|
|
||||||
|
|
||||||
void UpdateClient(Client client);
|
|
||||||
|
|
||||||
void DeleteClient(int id);
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
public interface IComponentRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Component> ReadComponents();
|
|
||||||
|
|
||||||
Component ReadComponentById(int id);
|
|
||||||
|
|
||||||
void CreateComponent(Component component);
|
|
||||||
|
|
||||||
void UpdateComponent(Component component);
|
|
||||||
|
|
||||||
void DeleteComponent(int id);
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
public interface IConnectionString
|
|
||||||
{
|
|
||||||
public string ConnectionString { get; }
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
public interface IOrderRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Order> ReadOrders();
|
|
||||||
|
|
||||||
Order ReadOrderById(int id);
|
|
||||||
|
|
||||||
void CreateOrder(Order order);
|
|
||||||
|
|
||||||
void UpdateOrder(Order order);
|
|
||||||
|
|
||||||
void DeleteOrder(int id);
|
|
||||||
}
|
|
@ -1,16 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
public interface IProductRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Product> ReadProducts();
|
|
||||||
|
|
||||||
Product ReadProductById(int id);
|
|
||||||
|
|
||||||
void CreateProduct(Product product);
|
|
||||||
|
|
||||||
void UpdateProduct(Product product);
|
|
||||||
|
|
||||||
void DeleteProduct(int id);
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Repositories;
|
|
||||||
|
|
||||||
public interface ISupplierRepository
|
|
||||||
{
|
|
||||||
|
|
||||||
IEnumerable<Supplier> ReadSuppliers();
|
|
||||||
|
|
||||||
Supplier ReadSupplierById(int id);
|
|
||||||
|
|
||||||
void CreateSupplier(Supplier supplier);
|
|
||||||
|
|
||||||
void UpdateSupplier(Supplier supplier);
|
|
||||||
|
|
||||||
void DeleteSupplier(int id);
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Repositories;
|
|
||||||
public interface ISupplyRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Supply> ReadSupplys();
|
|
||||||
|
|
||||||
Supply ReadSupplyById(int id);
|
|
||||||
|
|
||||||
void CreateSupply(Supply supply);
|
|
||||||
|
|
||||||
void UpdateSupply(Supply supply);
|
|
||||||
|
|
||||||
void DeleteSupply(int id);
|
|
||||||
}
|
|
@ -1,124 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
using Npgsql;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class ClientRepository : IClientRepository
|
|
||||||
{
|
|
||||||
private readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<ClientRepository> _logger;
|
|
||||||
|
|
||||||
public ClientRepository(IConnectionString connectionString, ILogger<ClientRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateClient(Client client)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO Clients (Name, Surname, Phone, Address)
|
|
||||||
VALUES (@Name, @Surname, @Phone, @Address)";
|
|
||||||
connection.Execute(queryInsert, client);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateClient(Client client)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Редактирование объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE Clients
|
|
||||||
SET
|
|
||||||
Name=@Name,
|
|
||||||
Surname=@Surname,
|
|
||||||
Phone=@Phone,
|
|
||||||
Address=@Address
|
|
||||||
WHERE Id=@Id";
|
|
||||||
connection.Execute(queryUpdate, client);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
_logger.LogError(ex, "Ошибка при редактировании объекта"); throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteClient(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM Clients
|
|
||||||
WHERE Id=@id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта"); throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Client ReadClientById(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT *
|
|
||||||
FROM Clients
|
|
||||||
WHERE Id=@id";
|
|
||||||
var client = connection.QueryFirst<Client>(querySelect, new { id });
|
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(client));
|
|
||||||
return client;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Client> ReadClients()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = "SELECT * FROM Clients";
|
|
||||||
var clients = connection.Query<Client>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(clients));
|
|
||||||
return clients;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,123 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class ComponentRepository : IComponentRepository
|
|
||||||
{
|
|
||||||
private readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<ComponentRepository> _logger;
|
|
||||||
|
|
||||||
public ComponentRepository(IConnectionString connectionString, ILogger<ComponentRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateComponent(Component component)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(component));
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO Components (Name, Price, Weight)
|
|
||||||
VALUES (@Name, @Price, @Weight)";
|
|
||||||
connection.Execute(queryInsert, component);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateComponent(Component component)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Редактирование объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(component));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE Components
|
|
||||||
SET
|
|
||||||
Name=@Name,
|
|
||||||
Price=@Price,
|
|
||||||
Weight=@Weight
|
|
||||||
WHERE Id=@Id";
|
|
||||||
connection.Execute(queryUpdate, component);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
_logger.LogError(ex, "Ошибка при редактировании объекта"); throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteComponent(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM Components
|
|
||||||
WHERE Id=@id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта"); throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Component ReadComponentById(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT *
|
|
||||||
FROM Components
|
|
||||||
WHERE Id=@id";
|
|
||||||
var component = connection.QueryFirst<Component>(querySelect, new { id });
|
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(component));
|
|
||||||
return component;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Component> ReadComponents()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = "SELECT * FROM Components";
|
|
||||||
var components = connection.Query<Component>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(components));
|
|
||||||
return components;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
namespace ProjectConfectioneryFactory.Repositories.Implementations;
|
|
||||||
|
|
||||||
internal class ConnectionString : IConnectionString
|
|
||||||
{
|
|
||||||
string IConnectionString.ConnectionString => "Host=localhost;Username=postgres;Password=postgres;Database=confectioneryfactoryotp;";
|
|
||||||
}
|
|
@ -1,149 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Npgsql;
|
|
||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class OrderRepository : IOrderRepository
|
|
||||||
{
|
|
||||||
private readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<OrderRepository> _logger;
|
|
||||||
|
|
||||||
public OrderRepository(IConnectionString connectionString, ILogger<OrderRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateOrder(Order order)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(order));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
connection.Open();
|
|
||||||
using var transaction = connection.BeginTransaction();
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO Orders (ClientId, Completed, Date)
|
|
||||||
VALUES (@ClientId, @Completed, @Date);
|
|
||||||
SELECT MAX(Id)
|
|
||||||
FROM Orders";
|
|
||||||
var orderId = connection.QueryFirst<int>(queryInsert, order, transaction);
|
|
||||||
|
|
||||||
var querySubInsert = @"
|
|
||||||
INSERT INTO OrderProducts (OrderId, ProductId, Count)
|
|
||||||
VALUES (@OrderId, @ProductId, @Count)";
|
|
||||||
foreach (var elem in order.OrderProducts)
|
|
||||||
{
|
|
||||||
connection.Execute(querySubInsert, new { orderId, elem.ProductId, elem.Count }, transaction);
|
|
||||||
}
|
|
||||||
transaction.Commit();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateOrder(Order order)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Редактирование объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(order));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
connection.Open();
|
|
||||||
using var transaction = connection.BeginTransaction();
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE Orders
|
|
||||||
SET
|
|
||||||
ClientId=@ClientId,
|
|
||||||
Completed=@Completed,
|
|
||||||
Date=@Date
|
|
||||||
WHERE Id=@Id";
|
|
||||||
var orderId = connection.QueryFirst<int>(queryUpdate, order, transaction);
|
|
||||||
|
|
||||||
var querySubUpdate = @"
|
|
||||||
UPDATE OrderProducts
|
|
||||||
SET
|
|
||||||
OrderId=@OrderId,
|
|
||||||
ProductId=@ProductId,
|
|
||||||
Count=@Count
|
|
||||||
WHERE Id=@Id";
|
|
||||||
foreach (var elem in order.OrderProducts)
|
|
||||||
{
|
|
||||||
connection.Execute(querySubUpdate, new { orderId, elem.ProductId, elem.Count }, transaction);
|
|
||||||
}
|
|
||||||
transaction.Commit();
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteOrder(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM Orders
|
|
||||||
WHERE Id=@id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта"); throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Order ReadOrderById(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT *
|
|
||||||
FROM Orders
|
|
||||||
WHERE Id=@id";
|
|
||||||
var order = connection.QueryFirst<Order>(querySelect, new { id });
|
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(order));
|
|
||||||
return order;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Order> ReadOrders()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = "SELECT * FROM Orders";
|
|
||||||
var orders = connection.Query<Order>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(orders));
|
|
||||||
return orders;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,149 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
using ProjectConfectioneryFactory.Entities.Enums;
|
|
||||||
using Npgsql;
|
|
||||||
using System.Transactions;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.Repositories.Implementations;
|
|
||||||
|
|
||||||
public class ProductRepository : IProductRepository
|
|
||||||
{
|
|
||||||
private readonly IConnectionString _connectionString;
|
|
||||||
|
|
||||||
private readonly ILogger<ProductRepository> _logger;
|
|
||||||
|
|
||||||
public ProductRepository(IConnectionString connectionString, ILogger<ProductRepository> logger)
|
|
||||||
{
|
|
||||||
_connectionString = connectionString;
|
|
||||||
_logger = logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateProduct(Product product)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Добавление объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(product));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
connection.Open();
|
|
||||||
using var transaction = connection.BeginTransaction();
|
|
||||||
var queryInsert = @"
|
|
||||||
INSERT INTO Products (ConfectioneryType, Name, Price)
|
|
||||||
VALUES (@ConfectioneryType, @Name, @Price);
|
|
||||||
SELECT MAX(Id)
|
|
||||||
FROM Products;";
|
|
||||||
var productId = connection.QueryFirst<int>(queryInsert, product, transaction);
|
|
||||||
|
|
||||||
var querySubInsert = @"
|
|
||||||
INSERT INTO ProductComponents (ProductId, ComponentId, Weight)
|
|
||||||
VALUES (@ProductId, @ComponentId, @Weight)";
|
|
||||||
foreach (var elem in product.ProductComponents)
|
|
||||||
{
|
|
||||||
connection.Execute(querySubInsert, new { productId, elem.ComponentId, elem.Weight }, transaction);
|
|
||||||
}
|
|
||||||
transaction.Commit();
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
connection.Open();
|
|
||||||
using var transaction = connection.BeginTransaction();
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE Products
|
|
||||||
SET
|
|
||||||
ConfectioneryType=@ConfectioneryType,
|
|
||||||
Name=@Name,
|
|
||||||
Price=@Price
|
|
||||||
WHERE Id=@Id";
|
|
||||||
var productId = connection.QueryFirst<int>(queryUpdate, product, transaction);
|
|
||||||
|
|
||||||
var querySubUpdate = @"
|
|
||||||
UPDATE ProductComponents
|
|
||||||
SET
|
|
||||||
ProductId=@ProductId,
|
|
||||||
ComponentId=@ComponentId,
|
|
||||||
Weight=@Weight
|
|
||||||
WHERE Id=@Id";
|
|
||||||
foreach (var elem in product.ProductComponents)
|
|
||||||
{
|
|
||||||
connection.Execute(querySubUpdate, new { productId, elem.ComponentId, elem.Weight }, transaction);
|
|
||||||
}
|
|
||||||
transaction.Commit();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при редактировании объекта"); throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteProduct(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Удаление объекта");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryDelete = @"
|
|
||||||
DELETE FROM Products
|
|
||||||
WHERE Id=@id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта"); throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Product ReadProductById(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT *
|
|
||||||
FROM Products
|
|
||||||
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 IEnumerable<Product> ReadProducts()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"SELECT * FROM Products";
|
|
||||||
var products = connection.Query<Product>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(products));
|
|
||||||
return products;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,122 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
using Npgsql;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.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 Suppliers (Name, Phone, Address)
|
|
||||||
VALUES (@Name, @Phone, @Address)";
|
|
||||||
connection.Execute(queryInsert, 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 Suppliers
|
|
||||||
SET
|
|
||||||
Name=@Name,
|
|
||||||
Phone=@Phone,
|
|
||||||
Address=@Address
|
|
||||||
WHERE Id=@Id";
|
|
||||||
connection.Execute(queryUpdate, 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 Suppliers
|
|
||||||
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 Suppliers
|
|
||||||
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> ReadSuppliers()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = "SELECT * FROM Suppliers";
|
|
||||||
var suppliers = connection.Query<Supplier>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(suppliers));
|
|
||||||
return suppliers;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,124 +0,0 @@
|
|||||||
using Dapper;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using ProjectConfectioneryFactory.Entities;
|
|
||||||
using Npgsql;
|
|
||||||
|
|
||||||
namespace ProjectConfectioneryFactory.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 Supplys (SupplierId, ComponentId, Weight, Completed, Date)
|
|
||||||
VALUES (@SupplierId, @ComponentId, @Weight, @Completed, @Date)";
|
|
||||||
connection.Execute(queryInsert, supply);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateSupply(Supply supply)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Редактирование объекта");
|
|
||||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(supply));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var queryUpdate = @"
|
|
||||||
UPDATE Supplys
|
|
||||||
SET
|
|
||||||
SupplierId=@SupplierId,
|
|
||||||
ComponentId=@ComponentId,
|
|
||||||
Weight=@Weight,
|
|
||||||
Completed=@Completed,
|
|
||||||
Date=@Date
|
|
||||||
WHERE Id=@Id";
|
|
||||||
connection.Execute(queryUpdate, 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 Supplys
|
|
||||||
WHERE Id=@id";
|
|
||||||
connection.Execute(queryDelete, new { id });
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при удалении объекта"); throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Supply ReadSupplyById(int id)
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение объекта по идентификатору");
|
|
||||||
_logger.LogDebug("Объект: {id}", id);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = @"
|
|
||||||
SELECT *
|
|
||||||
FROM Supplys
|
|
||||||
WHERE Id=@id";
|
|
||||||
var supply = connection.QueryFirst<Supply>(querySelect, new { id });
|
|
||||||
_logger.LogDebug("Найденный объект: {json}", JsonConvert.SerializeObject(supply));
|
|
||||||
return supply;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Supply> ReadSupplys()
|
|
||||||
{
|
|
||||||
_logger.LogInformation("Получение всех объектов");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
|
||||||
var querySelect = "SELECT * FROM Supplys";
|
|
||||||
var supplys = connection.Query<Supply>(querySelect);
|
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(supplys));
|
|
||||||
return supplys;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB |
Binary file not shown.
Before Width: | Height: | Size: 736 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.9 KiB |
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"Serilog": {
|
|
||||||
"Using": [ "Serilog.Sinks.File" ],
|
|
||||||
"MinimumLevel": "Debug",
|
|
||||||
"WriteTo": [
|
|
||||||
{
|
|
||||||
"Name": "File",
|
|
||||||
"Args": {
|
|
||||||
"path": "Logs/confectionery_log.txt",
|
|
||||||
"rollingInterval": "Day"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user