diff --git a/ProjectShoeShop/ProjectShoeShop/Entities/Client.cs b/ProjectShoeShop/ProjectShoeShop/Entities/Client.cs deleted file mode 100644 index f570732..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Entities/Client.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectShoeShop.Entities; - -public class Client -{ - public int Id { get; private set; } - - public string Name { get; private set; } = string.Empty; - - public static Client CreateEntity(int id, string name) - { - return new Client - { - Id = id, - Name = name, - }; - - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Entities/Enums/ShoesType.cs b/ProjectShoeShop/ProjectShoeShop/Entities/Enums/ShoesType.cs deleted file mode 100644 index f6f143e..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Entities/Enums/ShoesType.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectShoeShop.Entities.Enums; - -[Flags] -public enum ShoesType -{ - None = 0, - - Winter = 1, - - Spring = 2, - - Summer = 4, - - Autumn = 8 -} diff --git a/ProjectShoeShop/ProjectShoeShop/Entities/Enums/SupplyType.cs b/ProjectShoeShop/ProjectShoeShop/Entities/Enums/SupplyType.cs deleted file mode 100644 index 915564c..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Entities/Enums/SupplyType.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectShoeShop.Entities.Enums; - -public enum SupplyType -{ - None = 0, - - Small = 1, - - Medium = 2, - - Large = 3 -} diff --git a/ProjectShoeShop/ProjectShoeShop/Entities/Order.cs b/ProjectShoeShop/ProjectShoeShop/Entities/Order.cs deleted file mode 100644 index e663f2f..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Entities/Order.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectShoeShop.Entities; - -public class Order -{ - public int Id { get; private set; } - - public int ClientId { get; private set;} - - public DateTime OrderDate { get; private set; } - - public IEnumerable OrderItems { get; private set; } = []; - - public static Order CreateOperation(int id, int clientid, DateTime date, IEnumerable orderItems) - { - return new Order - { - Id = id, - ClientId = clientid, - OrderDate = date, - OrderItems = orderItems - }; - } - - public static Order CreateOperation(TempOrderItem tempOrderItem, IEnumerable orderItems) - { - return new Order - { - Id = tempOrderItem.Id, - ClientId = tempOrderItem.ClientId, - OrderDate = tempOrderItem.OrderDate, - OrderItems = orderItems - }; - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Entities/OrderItem.cs b/ProjectShoeShop/ProjectShoeShop/Entities/OrderItem.cs deleted file mode 100644 index 558c2ff..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Entities/OrderItem.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectShoeShop.Entities; - -public class OrderItem -{ - public int Id { get; set; } - - public int ShoesId { get; set; } - - public int NumberOfPairs { get; set; } - - public int Size { get; set; } - - public static OrderItem CreateElement(int id, int shoesId, int numberOfPairs, int size) - { - return new OrderItem - { - Id = id, - ShoesId = shoesId, - NumberOfPairs = numberOfPairs, - Size = size - }; - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Entities/Shoes.cs b/ProjectShoeShop/ProjectShoeShop/Entities/Shoes.cs deleted file mode 100644 index 5035981..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Entities/Shoes.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ProjectShoeShop.Entities.Enums; - -namespace ProjectShoeShop.Entities; - -public class Shoes -{ - public int Id { get; private set; } - - public string Name { get; private set; } = string.Empty; - - public int Price { get; private set; } - - public ShoesType ShoesType { get; private set;} - - public static Shoes CreateEntity(int id, string name, int price, ShoesType shoestype) - { - return new Shoes - { - Id = id, - Name = name, - Price = price, - ShoesType = shoestype - }; - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Entities/Supply.cs b/ProjectShoeShop/ProjectShoeShop/Entities/Supply.cs deleted file mode 100644 index 94377c5..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Entities/Supply.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ProjectShoeShop.Entities.Enums; - -namespace ProjectShoeShop.Entities; - -public class Supply -{ - public int Id { get; private set; } - - public DateTime DateOfReceipt { get; private set; } - - public SupplyType SupplyType { get; private set; } - - public IEnumerable SupplyShoes { get; private set; } = []; - - public static Supply CreateEntity(int id, SupplyType supplytype, DateTime date,IEnumerable supplyShoes) - { - return new Supply - { - Id = id, - DateOfReceipt = date, - SupplyType = supplytype, - SupplyShoes = supplyShoes - }; - } - - public static Supply CreateEntity(TempSupplyShoes tempSupplyShoes, IEnumerable supplyShoes) - { - return new Supply - { - Id = tempSupplyShoes.Id, - DateOfReceipt = tempSupplyShoes.DateOfReceipt, - SupplyType = tempSupplyShoes.SupplyType, - SupplyShoes = supplyShoes - }; - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Entities/SupplyShoes.cs b/ProjectShoeShop/ProjectShoeShop/Entities/SupplyShoes.cs deleted file mode 100644 index 9193579..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Entities/SupplyShoes.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectShoeShop.Entities; - -public class SupplyShoes -{ - public int Id { get; private set; } - - public int ShoesId { get; private set; } - - public int Size { get; private set; } - - public int NumberOfPairs { get; private set; } - - public static SupplyShoes CreateElement(int id, int shoesid, int size, int numberofpairs) - { - return new SupplyShoes - { - Id = id, - ShoesId = shoesid, - Size = size, - NumberOfPairs = numberofpairs, - }; - } - - -} diff --git a/ProjectShoeShop/ProjectShoeShop/Entities/TempOrderItem.cs b/ProjectShoeShop/ProjectShoeShop/Entities/TempOrderItem.cs deleted file mode 100644 index 50da0ac..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Entities/TempOrderItem.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectShoeShop.Entities; - -public class TempOrderItem -{ - public int Id { get; private set; } - - public int ClientId { get; private set; } - - public DateTime OrderDate { get; private set; } - - public int ShoesId { get; set; } - - public int NumberOfPairs { get; set; } - - public int Size { get; set; } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Entities/TempSupplyShoes.cs b/ProjectShoeShop/ProjectShoeShop/Entities/TempSupplyShoes.cs deleted file mode 100644 index 16e8bc0..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Entities/TempSupplyShoes.cs +++ /dev/null @@ -1,23 +0,0 @@ -using ProjectShoeShop.Entities.Enums; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectShoeShop.Entities; - -public class TempSupplyShoes -{ - public int Id { get; private set; } - - public DateTime DateOfReceipt { get; private set; } - - public SupplyType SupplyType { get; private set; } - - public int ShoesId { get; private set; } - - public int Size { get; private set; } - - public int NumberOfPairs { get; private set; } -} diff --git a/ProjectShoeShop/ProjectShoeShop/FormShoesShop.Designer.cs b/ProjectShoeShop/ProjectShoeShop/FormShoesShop.Designer.cs deleted file mode 100644 index 7583a69..0000000 --- a/ProjectShoeShop/ProjectShoeShop/FormShoesShop.Designer.cs +++ /dev/null @@ -1,156 +0,0 @@ -namespace ProjectShoeShop -{ - partial class FormShoesShop - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - menuStrip = new MenuStrip(); - справочникиToolStripMenuItem = new ToolStripMenuItem(); - clientToolStripMenuItem = new ToolStripMenuItem(); - shoeToolStripMenuItem = new ToolStripMenuItem(); - операцииToolStripMenuItem = new ToolStripMenuItem(); - orderToolStripMenuItem = new ToolStripMenuItem(); - supplyshoeToolStripMenuItem = new ToolStripMenuItem(); - отчетыToolStripMenuItem = new ToolStripMenuItem(); - toolStripMenuItemDocReport = new ToolStripMenuItem(); - toolStripMenuItemShoesReport = new ToolStripMenuItem(); - toolStripMenuItemOrderDistribution = new ToolStripMenuItem(); - menuStrip.SuspendLayout(); - SuspendLayout(); - // - // menuStrip - // - menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); - menuStrip.Location = new Point(0, 0); - menuStrip.Name = "menuStrip"; - menuStrip.Size = new Size(800, 24); - menuStrip.TabIndex = 0; - menuStrip.Text = "menuStrip1"; - // - // справочникиToolStripMenuItem - // - справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { clientToolStripMenuItem, shoeToolStripMenuItem }); - справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; - справочникиToolStripMenuItem.Size = new Size(94, 20); - справочникиToolStripMenuItem.Text = "Справочники"; - // - // clientToolStripMenuItem - // - clientToolStripMenuItem.Name = "clientToolStripMenuItem"; - clientToolStripMenuItem.Size = new Size(113, 22); - clientToolStripMenuItem.Text = "Клиент"; - clientToolStripMenuItem.Click += clientToolStripMenuItem_Click; - // - // shoeToolStripMenuItem - // - shoeToolStripMenuItem.Name = "shoeToolStripMenuItem"; - shoeToolStripMenuItem.Size = new Size(113, 22); - shoeToolStripMenuItem.Text = "Обувь"; - shoeToolStripMenuItem.Click += shoeToolStripMenuItem_Click; - // - // операцииToolStripMenuItem - // - операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { orderToolStripMenuItem, supplyshoeToolStripMenuItem }); - операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; - операцииToolStripMenuItem.Size = new Size(75, 20); - операцииToolStripMenuItem.Text = "Операции"; - // - // orderToolStripMenuItem - // - orderToolStripMenuItem.Name = "orderToolStripMenuItem"; - orderToolStripMenuItem.Size = new Size(184, 22); - orderToolStripMenuItem.Text = "Заказ"; - orderToolStripMenuItem.Click += orderToolStripMenuItem_Click; - // - // supplyshoeToolStripMenuItem - // - supplyshoeToolStripMenuItem.Name = "supplyshoeToolStripMenuItem"; - supplyshoeToolStripMenuItem.Size = new Size(184, 22); - supplyshoeToolStripMenuItem.Text = "Пополнение товара"; - supplyshoeToolStripMenuItem.Click += supplyshoeToolStripMenuItem_Click; - // - // отчетыToolStripMenuItem - // - отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItemDocReport, toolStripMenuItemShoesReport, toolStripMenuItemOrderDistribution }); - отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; - отчетыToolStripMenuItem.Size = new Size(60, 20); - отчетыToolStripMenuItem.Text = "Отчеты"; - // - // toolStripMenuItemDocReport - // - toolStripMenuItemDocReport.Name = "toolStripMenuItemDocReport"; - toolStripMenuItemDocReport.Size = new Size(207, 22); - toolStripMenuItemDocReport.Text = "Отчет по справочникам"; - toolStripMenuItemDocReport.Click += toolStripMenuItemDocReport_Click; - // - // toolStripMenuItemShoesReport - // - toolStripMenuItemShoesReport.Name = "toolStripMenuItemShoesReport"; - toolStripMenuItemShoesReport.Size = new Size(207, 22); - toolStripMenuItemShoesReport.Text = "Отчет по товару"; - toolStripMenuItemShoesReport.Click += toolStripMenuItemShoesReport_Click; - // - // toolStripMenuItemOrderDistribution - // - toolStripMenuItemOrderDistribution.Name = "toolStripMenuItemOrderDistribution"; - toolStripMenuItemOrderDistribution.Size = new Size(207, 22); - toolStripMenuItemOrderDistribution.Text = "Отчет по продажам"; - toolStripMenuItemOrderDistribution.Click += toolStripMenuItemOrderDistribution_Click; - // - // FormShoesShop - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - BackgroundImage = Properties.Resources.orig; - BackgroundImageLayout = ImageLayout.Stretch; - ClientSize = new Size(800, 450); - Controls.Add(menuStrip); - MainMenuStrip = menuStrip; - Name = "FormShoesShop"; - StartPosition = FormStartPosition.CenterScreen; - Text = "Магазин обуви"; - menuStrip.ResumeLayout(false); - menuStrip.PerformLayout(); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private MenuStrip menuStrip; - private ToolStripMenuItem справочникиToolStripMenuItem; - private ToolStripMenuItem clientToolStripMenuItem; - private ToolStripMenuItem shoeToolStripMenuItem; - private ToolStripMenuItem операцииToolStripMenuItem; - private ToolStripMenuItem orderToolStripMenuItem; - private ToolStripMenuItem отчетыToolStripMenuItem; - private ToolStripMenuItem supplyshoeToolStripMenuItem; - private ToolStripMenuItem toolStripMenuItemDocReport; - private ToolStripMenuItem toolStripMenuItemShoesReport; - private ToolStripMenuItem toolStripMenuItemOrderDistribution; - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/FormShoesShop.cs b/ProjectShoeShop/ProjectShoeShop/FormShoesShop.cs deleted file mode 100644 index 1675648..0000000 --- a/ProjectShoeShop/ProjectShoeShop/FormShoesShop.cs +++ /dev/null @@ -1,112 +0,0 @@ -using ProjectShoeShop.Forms; -using Unity; - -namespace ProjectShoeShop -{ - public partial class FormShoesShop : Form - { - private readonly IUnityContainer _container; - public FormShoesShop(IUnityContainer container) - { - InitializeComponent(); - _container = container ?? - throw new ArgumentNullException(nameof(container)); - } - - private void clientToolStripMenuItem_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void shoeToolStripMenuItem_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void supplyToolStripMenuItem_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void orderToolStripMenuItem_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void supplyshoeToolStripMenuItem_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void toolStripMenuItemDocReport_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void toolStripMenuItemShoesReport_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void toolStripMenuItemOrderDistribution_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().ShowDialog(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/FormShoesShop.resx b/ProjectShoeShop/ProjectShoeShop/FormShoesShop.resx deleted file mode 100644 index 6c82d08..0000000 --- a/ProjectShoeShop/ProjectShoeShop/FormShoesShop.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormClient.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormClient.Designer.cs deleted file mode 100644 index d6a0056..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormClient.Designer.cs +++ /dev/null @@ -1,96 +0,0 @@ -namespace ProjectShoeShop.Forms -{ - partial class FormClient - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - labelName = new Label(); - buttonSave = new Button(); - buttonCancel = new Button(); - textBoxName = new TextBox(); - SuspendLayout(); - // - // labelName - // - labelName.AutoSize = true; - labelName.Location = new Point(12, 23); - labelName.Name = "labelName"; - labelName.Size = new Size(31, 15); - labelName.TabIndex = 0; - labelName.Text = "Имя"; - // - // buttonSave - // - buttonSave.Location = new Point(12, 66); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(75, 23); - buttonSave.TabIndex = 1; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += ButtonSave_Click; - // - // buttonCancel - // - buttonCancel.Location = new Point(93, 66); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(75, 23); - buttonCancel.TabIndex = 2; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += ButtonCancel_Click; - // - // textBoxName - // - textBoxName.Location = new Point(49, 20); - textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(119, 23); - textBoxName.TabIndex = 3; - // - // FormClient - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(187, 109); - Controls.Add(textBoxName); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Controls.Add(labelName); - Name = "FormClient"; - StartPosition = FormStartPosition.CenterScreen; - Text = "Клиенты"; - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private Label labelName; - private Button buttonSave; - private Button buttonCancel; - private TextBox textBoxName; - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormClient.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormClient.cs deleted file mode 100644 index d24d947..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormClient.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ProjectShoeShop.Entities; -using ProjectShoeShop.Repositories; -using ProjectShoeShop.Repositories.Implementations; - -namespace ProjectShoeShop.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)); - } - - textBoxName.Text = client.Name; - _clientId = value; - - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - } - } - public FormClient(ClientRepository clientRepository) - { - InitializeComponent(); - _clientRepository = clientRepository ?? - throw new ArgumentNullException(nameof(clientRepository)); - } - - private void ButtonSave_Click(object sender, EventArgs e) - { - try - { - if (string.IsNullOrEmpty(textBoxName.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, textBoxName.Text); - - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormClient.resx b/ProjectShoeShop/ProjectShoeShop/Forms/FormClient.resx deleted file mode 100644 index af32865..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormClient.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormClients.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormClients.Designer.cs deleted file mode 100644 index 4f5b8bf..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormClients.Designer.cs +++ /dev/null @@ -1,126 +0,0 @@ -namespace ProjectShoeShop.Forms -{ - partial class FormClients - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - panel1 = new Panel(); - buttonUpdate = new Button(); - buttonDelete = new Button(); - buttonAdd = new Button(); - dataGridView = new DataGridView(); - panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // panel1 - // - panel1.Controls.Add(buttonUpdate); - panel1.Controls.Add(buttonDelete); - panel1.Controls.Add(buttonAdd); - panel1.Dock = DockStyle.Right; - panel1.Location = new Point(604, 0); - panel1.Name = "panel1"; - panel1.Size = new Size(196, 450); - panel1.TabIndex = 0; - // - // buttonUpdate - // - buttonUpdate.BackgroundImage = Properties.Resources._0_4348_objects_pencil_png; - buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; - buttonUpdate.Location = new Point(65, 199); - buttonUpdate.Name = "buttonUpdate"; - buttonUpdate.Size = new Size(75, 67); - buttonUpdate.TabIndex = 2; - buttonUpdate.UseVisualStyleBackColor = true; - buttonUpdate.Click += ButtonUpdate_Click; - // - // buttonDelete - // - buttonDelete.BackgroundImage = Properties.Resources._; - buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; - buttonDelete.Location = new Point(65, 117); - buttonDelete.Name = "buttonDelete"; - buttonDelete.Size = new Size(75, 67); - buttonDelete.TabIndex = 1; - buttonDelete.UseVisualStyleBackColor = true; - buttonDelete.Click += ButtonDelete_Click; - // - // buttonAdd - // - buttonAdd.BackgroundImage = Properties.Resources._jpg; - buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; - buttonAdd.Location = new Point(65, 35); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(75, 64); - buttonAdd.TabIndex = 0; - buttonAdd.UseVisualStyleBackColor = true; - buttonAdd.Click += ButtonAdd_Click; - // - // dataGridView - // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.AllowUserToResizeColumns = false; - dataGridView.AllowUserToResizeRows = false; - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Fill; - dataGridView.Location = new Point(0, 0); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersVisible = false; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(604, 450); - dataGridView.TabIndex = 1; - // - // FormClients - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Controls.Add(dataGridView); - Controls.Add(panel1); - Name = "FormClients"; - StartPosition = FormStartPosition.CenterScreen; - Text = "Клиенты"; - Load += FormClients_Load; - panel1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - } - - #endregion - - private Panel panel1; - private Button buttonDelete; - private Button buttonAdd; - private DataGridView dataGridView; - private Button buttonUpdate; - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormClients.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormClients.cs deleted file mode 100644 index 2d9bd09..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormClients.cs +++ /dev/null @@ -1,115 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ProjectShoeShop.Repositories; -using Unity; - -namespace ProjectShoeShop.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 ButtonAdd_Click(object sender, EventArgs e) - { - try - { - _container.Resolve().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 FormClients_Load(object sender, EventArgs e) - { - try - { - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void LoadList() => dataGridView.DataSource = _clientRepository.ReadClient(); - - private bool TryGetIdentifierFromSelectedRow(out int id) - { - id = 0; - if (dataGridView.SelectedRows.Count < 1) - { - MessageBox.Show("Нет выбранной записи", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; - } - - id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - return true; - } - - private void ButtonUpdate_Click(object sender, EventArgs e) - { - if (!TryGetIdentifierFromSelectedRow(out var findId)) - { - return; - } - try - { - var form = _container.Resolve(); - form.Id = findId; - form.ShowDialog(); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при изменении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormClients.resx b/ProjectShoeShop/ProjectShoeShop/Forms/FormClients.resx deleted file mode 100644 index af32865..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormClients.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormDirectoryReport.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormDirectoryReport.Designer.cs deleted file mode 100644 index 87f9500..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormDirectoryReport.Designer.cs +++ /dev/null @@ -1,86 +0,0 @@ -namespace ProjectShoeShop.Forms -{ - partial class FormDirectoryReport - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - checkBoxClients = new CheckBox(); - checkBoxShoes = new CheckBox(); - buttonBuild = new Button(); - SuspendLayout(); - // - // checkBoxClients - // - checkBoxClients.AutoSize = true; - checkBoxClients.Location = new Point(12, 12); - checkBoxClients.Name = "checkBoxClients"; - checkBoxClients.Size = new Size(74, 19); - checkBoxClients.TabIndex = 0; - checkBoxClients.Text = "Клиенты"; - checkBoxClients.UseVisualStyleBackColor = true; - // - // checkBoxShoes - // - checkBoxShoes.AutoSize = true; - checkBoxShoes.Location = new Point(12, 60); - checkBoxShoes.Name = "checkBoxShoes"; - checkBoxShoes.Size = new Size(60, 19); - checkBoxShoes.TabIndex = 1; - checkBoxShoes.Text = "Обувь"; - checkBoxShoes.UseVisualStyleBackColor = true; - // - // buttonBuild - // - buttonBuild.Location = new Point(12, 151); - buttonBuild.Name = "buttonBuild"; - buttonBuild.Size = new Size(172, 23); - buttonBuild.TabIndex = 2; - buttonBuild.Text = "Сформировать"; - buttonBuild.UseVisualStyleBackColor = true; - buttonBuild.Click += buttonBuild_Click; - // - // FormDirectoryReport - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(196, 195); - Controls.Add(buttonBuild); - Controls.Add(checkBoxShoes); - Controls.Add(checkBoxClients); - Name = "FormDirectoryReport"; - Text = "Отчет по справочникам"; - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private CheckBox checkBoxClients; - private CheckBox checkBoxShoes; - private Button buttonBuild; - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormDirectoryReport.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormDirectoryReport.cs deleted file mode 100644 index 68650a9..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormDirectoryReport.cs +++ /dev/null @@ -1,53 +0,0 @@ -using ProjectShoeShop.Reports; -using Unity; - -namespace ProjectShoeShop.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 && !checkBoxShoes.Checked) - { - throw new Exception("Не выбран ни один справочник для выгрузки"); - } - var sfd = new SaveFileDialog() - { - Filter = "Docx Files | *.docx" - }; - if (sfd.ShowDialog() != DialogResult.OK) - { - throw new Exception("Не выбран файла для отчета"); - } - if - (_container.Resolve().CreateDoc(sfd.FileName, checkBoxClients.Checked, checkBoxShoes.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); - } - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormDirectoryReport.resx b/ProjectShoeShop/ProjectShoeShop/Forms/FormDirectoryReport.resx deleted file mode 100644 index af32865..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormDirectoryReport.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrder.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormOrder.Designer.cs deleted file mode 100644 index cf711af..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrder.Designer.cs +++ /dev/null @@ -1,153 +0,0 @@ -namespace ProjectShoeShop.Forms -{ - partial class FormOrder - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - labelClient = new Label(); - buttonSave = new Button(); - buttonCancel = new Button(); - comboBox = new ComboBox(); - groupBox1 = new GroupBox(); - dataGridView = new DataGridView(); - ColumnShoe = new DataGridViewComboBoxColumn(); - ColumnNumberOfPairs = new DataGridViewTextBoxColumn(); - ColumnSize = new DataGridViewTextBoxColumn(); - groupBox1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // labelClient - // - labelClient.AutoSize = true; - labelClient.Location = new Point(66, 25); - labelClient.Name = "labelClient"; - labelClient.Size = new Size(46, 15); - labelClient.TabIndex = 0; - labelClient.Text = "Клиент"; - // - // buttonSave - // - buttonSave.Location = new Point(15, 262); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(75, 23); - buttonSave.TabIndex = 2; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += ButtonSave_Click; - // - // buttonCancel - // - buttonCancel.Location = new Point(310, 262); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(75, 23); - buttonCancel.TabIndex = 3; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += ButtonCancel_Click; - // - // comboBox - // - comboBox.DropDownStyle = ComboBoxStyle.DropDownList; - comboBox.FormattingEnabled = true; - comboBox.Location = new Point(118, 22); - comboBox.Name = "comboBox"; - comboBox.Size = new Size(264, 23); - comboBox.TabIndex = 4; - // - // groupBox1 - // - groupBox1.Controls.Add(dataGridView); - groupBox1.Location = new Point(12, 63); - groupBox1.Name = "groupBox1"; - groupBox1.Size = new Size(373, 193); - groupBox1.TabIndex = 5; - groupBox1.TabStop = false; - groupBox1.Text = "Обувь"; - // - // dataGridView - // - dataGridView.AllowUserToResizeColumns = false; - dataGridView.AllowUserToResizeRows = false; - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnShoe, ColumnNumberOfPairs, ColumnSize }); - dataGridView.Dock = DockStyle.Fill; - dataGridView.Location = new Point(3, 19); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.RowHeadersVisible = false; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(367, 171); - dataGridView.TabIndex = 0; - // - // ColumnShoe - // - ColumnShoe.HeaderText = "Обувь"; - ColumnShoe.Name = "ColumnShoe"; - // - // ColumnNumberOfPairs - // - ColumnNumberOfPairs.HeaderText = "Количество"; - ColumnNumberOfPairs.Name = "ColumnNumberOfPairs"; - // - // ColumnSize - // - ColumnSize.HeaderText = "Размер обуви"; - ColumnSize.Name = "ColumnSize"; - // - // FormOrder - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(397, 297); - Controls.Add(groupBox1); - Controls.Add(comboBox); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Controls.Add(labelClient); - Name = "FormOrder"; - Text = "FormOrder"; - groupBox1.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private Label labelClient; - private Button buttonSave; - private Button buttonCancel; - private ComboBox comboBox; - private GroupBox groupBox1; - private DataGridView dataGridView; - private DataGridViewComboBoxColumn ColumnShoe; - private DataGridViewTextBoxColumn ColumnNumberOfPairs; - private DataGridViewTextBoxColumn ColumnSize; - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrder.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormOrder.cs deleted file mode 100644 index 291a7f7..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrder.cs +++ /dev/null @@ -1,67 +0,0 @@ -using ProjectShoeShop.Entities; -using ProjectShoeShop.Repositories; - -namespace ProjectShoeShop.Forms -{ - public partial class FormOrder : Form - { - private readonly IOrderRepository _orderRepository; - public FormOrder(IOrderRepository orderRepository, IClientRepository clientRepository, IShoesRepository shoesRepository) - { - InitializeComponent(); - _orderRepository = orderRepository ?? - throw new ArgumentNullException(nameof(orderRepository)); - - comboBox.DataSource = clientRepository.ReadClient(); - comboBox.DisplayMember = "Name"; - comboBox.ValueMember = "Id"; - - ColumnShoe.DataSource = shoesRepository.ReadShoes(); - ColumnShoe.DisplayMember = "Name"; - ColumnShoe.ValueMember = "Id"; - } - - private void ButtonSave_Click(object sender, EventArgs e) - { - try - { - if (comboBox.SelectedIndex < 0 || dataGridView.RowCount < 1) - { - throw new Exception("Имеется незаполненное поле"); - } - - _orderRepository.CreateOrder(Order.CreateOperation(0,(int)comboBox.SelectedValue!, DateTime.Now, CreateListOrderItemFromDataGrid())); - - Close(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибкв при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void ButtonCancel_Click(object sender, EventArgs e) - { - Close(); - } - - private List CreateListOrderItemFromDataGrid() - { - var list = new List(); - foreach (DataGridViewRow row in dataGridView.Rows) - { - if (row.Cells["ColumnShoe"].Value == null || - row.Cells["ColumnSize"].Value == null || - row.Cells["ColumnNumberOfPairs"].Value == null) - { - continue; - } - list.Add(OrderItem.CreateElement(0, - Convert.ToInt32(row.Cells["ColumnShoe"].Value), - Convert.ToInt32(row.Cells["ColumnNumberOfPairs"].Value), - Convert.ToInt32(row.Cells["ColumnSize"].Value))); - } - return list; - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrder.resx b/ProjectShoeShop/ProjectShoeShop/Forms/FormOrder.resx deleted file mode 100644 index 736d239..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrder.resx +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - True - - - True - - - True - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrderDistribution.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormOrderDistribution.Designer.cs deleted file mode 100644 index 5400355..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrderDistribution.Designer.cs +++ /dev/null @@ -1,107 +0,0 @@ -namespace ProjectShoeShop.Forms -{ - partial class FormOrderDistribution - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - buttonFile = new Button(); - buttonBuild = new Button(); - label1 = new Label(); - labelFileName = new Label(); - dateTimePicker = new DateTimePicker(); - SuspendLayout(); - // - // buttonFile - // - buttonFile.Location = new Point(12, 12); - buttonFile.Name = "buttonFile"; - buttonFile.Size = new Size(75, 23); - buttonFile.TabIndex = 0; - buttonFile.Text = "Выбрать"; - buttonFile.UseVisualStyleBackColor = true; - buttonFile.Click += buttonFile_Click; - // - // buttonBuild - // - buttonBuild.Location = new Point(12, 82); - buttonBuild.Name = "buttonBuild"; - buttonBuild.Size = new Size(244, 23); - buttonBuild.TabIndex = 1; - buttonBuild.Text = "Сформировать"; - buttonBuild.UseVisualStyleBackColor = true; - buttonBuild.Click += buttonBuild_Click; - // - // label1 - // - label1.AutoSize = true; - label1.Location = new Point(12, 50); - label1.Name = "label1"; - label1.Size = new Size(35, 15); - label1.TabIndex = 2; - label1.Text = "Дата:"; - // - // labelFileName - // - labelFileName.AutoSize = true; - labelFileName.Location = new Point(93, 16); - labelFileName.Name = "labelFileName"; - labelFileName.Size = new Size(36, 15); - labelFileName.TabIndex = 3; - labelFileName.Text = "Файл"; - // - // dateTimePicker - // - dateTimePicker.Location = new Point(56, 44); - dateTimePicker.Name = "dateTimePicker"; - dateTimePicker.Size = new Size(200, 23); - dateTimePicker.TabIndex = 4; - // - // FormOrderDistribution - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(268, 117); - Controls.Add(dateTimePicker); - Controls.Add(labelFileName); - Controls.Add(label1); - Controls.Add(buttonBuild); - Controls.Add(buttonFile); - Name = "FormOrderDistribution"; - Text = "Отчет по продажам"; - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private Button buttonFile; - private Button buttonBuild; - private Label label1; - private Label labelFileName; - private DateTimePicker dateTimePicker; - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrderDistribution.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormOrderDistribution.cs deleted file mode 100644 index fd6e675..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrderDistribution.cs +++ /dev/null @@ -1,68 +0,0 @@ -using ProjectShoeShop.Reports; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using Unity; - -namespace ProjectShoeShop.Forms -{ - public partial class FormOrderDistribution : Form - { - private string _fileName = string.Empty; - private readonly IUnityContainer _container; - public FormOrderDistribution(IUnityContainer container) - { - InitializeComponent(); - _container = container ?? throw new ArgumentNullException(nameof(container)); - } - - private void buttonBuild_Click(object sender, EventArgs e) - { - try - { - if (string.IsNullOrWhiteSpace(_fileName)) - { - throw new Exception("Отсутствует имя файла для отчета"); - } - if - (_container.Resolve().CreateChart(_fileName, dateTimePicker.Value)) - { - MessageBox.Show("Документ сформирован", - "Формирование документа", - MessageBoxButtons.OK, - MessageBoxIcon.Information); - } - else - { - MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", - "Формирование документа", - MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при создании очета", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void buttonFile_Click(object sender, EventArgs e) - { - var sfd = new SaveFileDialog() - { - Filter = "Pdf Files | *.pdf" - }; - if (sfd.ShowDialog() == DialogResult.OK) - { - _fileName = sfd.FileName; - labelFileName.Text = Path.GetFileName(_fileName); - } - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrderDistribution.resx b/ProjectShoeShop/ProjectShoeShop/Forms/FormOrderDistribution.resx deleted file mode 100644 index af32865..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrderDistribution.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrders.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormOrders.Designer.cs deleted file mode 100644 index 41006f8..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrders.Designer.cs +++ /dev/null @@ -1,97 +0,0 @@ -namespace ProjectShoeShop.Forms -{ - partial class FormOrders - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - dataGridView = new DataGridView(); - panel1 = new Panel(); - buttonAdd = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - panel1.SuspendLayout(); - SuspendLayout(); - // - // dataGridView - // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.AllowUserToResizeColumns = false; - dataGridView.AllowUserToResizeRows = false; - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Fill; - dataGridView.Location = new Point(0, 0); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersVisible = false; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(604, 450); - dataGridView.TabIndex = 3; - // - // panel1 - // - panel1.Controls.Add(buttonAdd); - panel1.Dock = DockStyle.Right; - panel1.Location = new Point(604, 0); - panel1.Name = "panel1"; - panel1.Size = new Size(196, 450); - panel1.TabIndex = 2; - // - // buttonAdd - // - buttonAdd.BackgroundImage = Properties.Resources._jpg; - buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; - buttonAdd.Location = new Point(65, 35); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(75, 64); - buttonAdd.TabIndex = 0; - buttonAdd.UseVisualStyleBackColor = true; - buttonAdd.Click += ButtonAdd_Click; - // - // FormOrders - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Controls.Add(dataGridView); - Controls.Add(panel1); - Name = "FormOrders"; - Text = "FormOrders"; - Load += FormOrders_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - panel1.ResumeLayout(false); - ResumeLayout(false); - } - - #endregion - - private DataGridView dataGridView; - private Panel panel1; - private Button buttonAdd; - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrders.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormOrders.cs deleted file mode 100644 index b016e37..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrders.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ProjectShoeShop.Repositories; -using ProjectShoeShop.Repositories.Implementations; -using Unity; - -namespace ProjectShoeShop.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().ShowDialog(); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при добавлении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void LoadList() => dataGridView.DataSource = _orderRepository.ReadOrder(); - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrders.resx b/ProjectShoeShop/ProjectShoeShop/Forms/FormOrders.resx deleted file mode 100644 index af32865..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormOrders.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoe.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormShoe.Designer.cs deleted file mode 100644 index 13c12cb..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoe.Designer.cs +++ /dev/null @@ -1,145 +0,0 @@ -namespace ProjectShoeShop.Forms -{ - partial class FormShoe - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - checkedListBox = new CheckedListBox(); - labelType = new Label(); - labelName = new Label(); - textBoxName = new TextBox(); - labelPrice = new Label(); - numericUpDown = new NumericUpDown(); - buttonSave = new Button(); - buttonCancel = new Button(); - ((System.ComponentModel.ISupportInitialize)numericUpDown).BeginInit(); - SuspendLayout(); - // - // checkedListBox - // - checkedListBox.FormattingEnabled = true; - checkedListBox.Location = new Point(81, 12); - checkedListBox.Name = "checkedListBox"; - checkedListBox.Size = new Size(120, 94); - checkedListBox.TabIndex = 0; - // - // labelType - // - labelType.AutoSize = true; - labelType.Location = new Point(12, 12); - labelType.Name = "labelType"; - labelType.Size = new Size(63, 15); - labelType.TabIndex = 1; - labelType.Text = "Тип обуви"; - // - // labelName - // - labelName.AutoSize = true; - labelName.Location = new Point(12, 129); - labelName.Name = "labelName"; - labelName.Size = new Size(59, 15); - labelName.TabIndex = 2; - labelName.Text = "Название"; - // - // textBoxName - // - textBoxName.Location = new Point(81, 129); - textBoxName.Name = "textBoxName"; - textBoxName.Size = new Size(120, 23); - textBoxName.TabIndex = 3; - // - // labelPrice - // - labelPrice.AutoSize = true; - labelPrice.Location = new Point(12, 169); - labelPrice.Name = "labelPrice"; - labelPrice.Size = new Size(35, 15); - labelPrice.TabIndex = 4; - labelPrice.Text = "Цена"; - // - // numericUpDown - // - numericUpDown.Location = new Point(81, 167); - numericUpDown.Maximum = new decimal(new int[] { 100000, 0, 0, 0 }); - numericUpDown.Minimum = new decimal(new int[] { 100, 0, 0, 0 }); - numericUpDown.Name = "numericUpDown"; - numericUpDown.Size = new Size(120, 23); - numericUpDown.TabIndex = 5; - numericUpDown.Value = new decimal(new int[] { 100, 0, 0, 0 }); - // - // buttonSave - // - buttonSave.Location = new Point(12, 219); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(90, 23); - buttonSave.TabIndex = 6; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += ButtonSave_Click; - // - // buttonCancel - // - buttonCancel.Location = new Point(106, 219); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(95, 23); - buttonCancel.TabIndex = 7; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += ButtonCancel_Click; - // - // FormShoe - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(251, 280); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Controls.Add(numericUpDown); - Controls.Add(labelPrice); - Controls.Add(textBoxName); - Controls.Add(labelName); - Controls.Add(labelType); - Controls.Add(checkedListBox); - Name = "FormShoe"; - Text = "Обувь"; - ((System.ComponentModel.ISupportInitialize)numericUpDown).EndInit(); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private CheckedListBox checkedListBox; - private Label labelType; - private Label labelName; - private TextBox textBoxName; - private Label labelPrice; - private NumericUpDown numericUpDown; - private Button buttonSave; - private Button buttonCancel; - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoe.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormShoe.cs deleted file mode 100644 index 4abb6bf..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoe.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ProjectShoeShop.Entities; -using ProjectShoeShop.Entities.Enums; -using ProjectShoeShop.Repositories; -using ProjectShoeShop.Repositories.Implementations; - -namespace ProjectShoeShop.Forms -{ - public partial class FormShoe : Form - { - private readonly IShoesRepository _shoesRepository; - private int? _shoesId; - - public int Id - { - set - { - try - { - var shoe = _shoesRepository.ReadShoesById(value); - if (shoe == null) - { - throw new InvalidDataException(nameof(shoe)); - } - - foreach (ShoesType elem in Enum.GetValues(typeof(ShoesType))) - { - if ((elem & shoe.ShoesType) != 0) - { - checkedListBox.SetItemChecked(checkedListBox.Items.IndexOf(elem), true); - } - } - - textBoxName.Text = shoe.Name; - numericUpDown.Value = shoe.Price; - _shoesId = value; - - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); - return; - } - } - } - public FormShoe(IShoesRepository shoesRepository) - { - InitializeComponent(); - _shoesRepository = shoesRepository ?? - throw new ArgumentNullException(nameof(shoesRepository)); - - foreach (var elem in Enum.GetValues(typeof (ShoesType))) - { - checkedListBox.Items.Add(elem); - } - } - - private void ButtonSave_Click(object sender, EventArgs e) - { - try - { - if (string.IsNullOrEmpty(textBoxName.Text) || - checkedListBox.CheckedItems.Count == 0 || numericUpDown.Value < 1) - { - throw new Exception("Имеется незаполненное поле"); - } - - if (_shoesId.HasValue) - { - _shoesRepository.UpdateShoes(CreateShoes(_shoesId.Value)); - } - else - { - _shoesRepository.CreateShoes(CreateShoes(0)); - } - - Close(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибкв при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void ButtonCancel_Click(object sender, EventArgs e) - { - Close(); - } - - private Shoes CreateShoes(int id) - { - ShoesType shoesType = ShoesType.None; - foreach (var elem in checkedListBox.CheckedItems) - { - shoesType |= (ShoesType)elem; - } - - return Shoes.CreateEntity(id, textBoxName.Text, (int)numericUpDown.Value, shoesType); - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoe.resx b/ProjectShoeShop/ProjectShoeShop/Forms/FormShoe.resx deleted file mode 100644 index af32865..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoe.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoes.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormShoes.Designer.cs deleted file mode 100644 index ea2cf52..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoes.Designer.cs +++ /dev/null @@ -1,125 +0,0 @@ -namespace ProjectShoeShop.Forms -{ - partial class FormShoes - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - dataGridView = new DataGridView(); - panel1 = new Panel(); - buttonDelete = new Button(); - buttonAdd = new Button(); - buttonUpdate = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - panel1.SuspendLayout(); - SuspendLayout(); - // - // dataGridView - // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.AllowUserToResizeColumns = false; - dataGridView.AllowUserToResizeRows = false; - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Fill; - dataGridView.Location = new Point(0, 0); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersVisible = false; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(604, 450); - dataGridView.TabIndex = 3; - // - // panel1 - // - panel1.Controls.Add(buttonUpdate); - panel1.Controls.Add(buttonDelete); - panel1.Controls.Add(buttonAdd); - panel1.Dock = DockStyle.Right; - panel1.Location = new Point(604, 0); - panel1.Name = "panel1"; - panel1.Size = new Size(196, 450); - panel1.TabIndex = 2; - // - // buttonDelete - // - buttonDelete.BackgroundImage = Properties.Resources._; - buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; - buttonDelete.Location = new Point(65, 117); - buttonDelete.Name = "buttonDelete"; - buttonDelete.Size = new Size(75, 67); - buttonDelete.TabIndex = 1; - buttonDelete.UseVisualStyleBackColor = true; - buttonDelete.Click += ButtonDelete_Click; - // - // buttonAdd - // - buttonAdd.BackgroundImage = Properties.Resources._jpg; - buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; - buttonAdd.Location = new Point(65, 35); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(75, 64); - buttonAdd.TabIndex = 0; - buttonAdd.UseVisualStyleBackColor = true; - buttonAdd.Click += ButtonAdd_Click; - // - // buttonUpdate - // - buttonUpdate.BackgroundImage = Properties.Resources._0_4348_objects_pencil_png; - buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch; - buttonUpdate.Location = new Point(65, 202); - buttonUpdate.Name = "buttonUpdate"; - buttonUpdate.Size = new Size(75, 67); - buttonUpdate.TabIndex = 2; - buttonUpdate.UseVisualStyleBackColor = true; - buttonUpdate.Click += ButtonUpdate_Click; - // - // FormShoes - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Controls.Add(dataGridView); - Controls.Add(panel1); - Name = "FormShoes"; - Text = "Обувь"; - Load += FormShoes_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - panel1.ResumeLayout(false); - ResumeLayout(false); - } - - #endregion - - private DataGridView dataGridView; - private Panel panel1; - private Button buttonDelete; - private Button buttonAdd; - private Button buttonUpdate; - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoes.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormShoes.cs deleted file mode 100644 index 9e37f04..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoes.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ProjectShoeShop.Repositories; -using ProjectShoeShop.Repositories.Implementations; -using Unity; - -namespace ProjectShoeShop.Forms -{ - public partial class FormShoes : Form - { - - private readonly IUnityContainer _container; - private readonly IShoesRepository _shoesRepository; - public FormShoes(IUnityContainer container, IShoesRepository shoesRepository) - { - InitializeComponent(); - _container = container ?? - throw new ArgumentNullException(nameof(container)); - _shoesRepository = shoesRepository ?? - throw new ArgumentNullException(nameof(shoesRepository)); - } - - private void FormShoes_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().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 - { - _shoesRepository.DeleteShoes(findId); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при удалении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - private void LoadList() => dataGridView.DataSource = _shoesRepository.ReadShoes(); - - private bool TryGetIdentifierFromSelectedRow(out int id) - { - id = 0; - if (dataGridView.SelectedRows.Count < 1) - { - MessageBox.Show("Нет выбранной записи", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; - } - - id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - return true; - } - - private void ButtonUpdate_Click(object sender, EventArgs e) - { - if (!TryGetIdentifierFromSelectedRow(out var findId)) - { - return; - } - try - { - var form = _container.Resolve(); - form.Id = findId; - form.ShowDialog(); - LoadList(); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при изменении", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoes.resx b/ProjectShoeShop/ProjectShoeShop/Forms/FormShoes.resx deleted file mode 100644 index af32865..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoes.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoesReport.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormShoesReport.Designer.cs deleted file mode 100644 index a18df07..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoesReport.Designer.cs +++ /dev/null @@ -1,162 +0,0 @@ -namespace ProjectShoeShop.Forms -{ - partial class FormShoesReport - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - label1 = new Label(); - label2 = new Label(); - label3 = new Label(); - label4 = new Label(); - buttonFile = new Button(); - buttonBuild = new Button(); - comboBoxShoes = new ComboBox(); - dateTimePickerStart = new DateTimePicker(); - dateTimePickerEnd = new DateTimePicker(); - textBoxFilePath = new TextBox(); - SuspendLayout(); - // - // label1 - // - label1.AutoSize = true; - label1.Location = new Point(12, 49); - label1.Name = "label1"; - label1.Size = new Size(44, 15); - label1.TabIndex = 0; - label1.Text = "Обувь:"; - // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(12, 9); - label2.Name = "label2"; - label2.Size = new Size(90, 15); - label2.TabIndex = 1; - label2.Text = "Путь до файла:"; - // - // label3 - // - label3.AutoSize = true; - label3.Location = new Point(12, 88); - label3.Name = "label3"; - label3.Size = new Size(77, 15); - label3.TabIndex = 2; - label3.Text = "Дата начала:"; - // - // label4 - // - label4.AutoSize = true; - label4.Location = new Point(12, 127); - label4.Name = "label4"; - label4.Size = new Size(71, 15); - label4.TabIndex = 3; - label4.Text = "Дата конца:"; - // - // buttonFile - // - buttonFile.Location = new Point(251, 6); - buttonFile.Name = "buttonFile"; - buttonFile.Size = new Size(29, 23); - buttonFile.TabIndex = 4; - buttonFile.Text = "..."; - buttonFile.UseVisualStyleBackColor = true; - buttonFile.Click += buttonFile_Click; - // - // buttonBuild - // - buttonBuild.Location = new Point(12, 161); - buttonBuild.Name = "buttonBuild"; - buttonBuild.Size = new Size(268, 23); - buttonBuild.TabIndex = 5; - buttonBuild.Text = "Сформировать"; - buttonBuild.UseVisualStyleBackColor = true; - buttonBuild.Click += buttonBuild_Click; - // - // comboBoxShoes - // - comboBoxShoes.FormattingEnabled = true; - comboBoxShoes.Location = new Point(108, 46); - comboBoxShoes.Name = "comboBoxShoes"; - comboBoxShoes.Size = new Size(172, 23); - comboBoxShoes.TabIndex = 6; - // - // dateTimePickerStart - // - dateTimePickerStart.Location = new Point(108, 82); - dateTimePickerStart.Name = "dateTimePickerStart"; - dateTimePickerStart.Size = new Size(172, 23); - dateTimePickerStart.TabIndex = 7; - // - // dateTimePickerEnd - // - dateTimePickerEnd.Location = new Point(108, 121); - dateTimePickerEnd.Name = "dateTimePickerEnd"; - dateTimePickerEnd.Size = new Size(172, 23); - dateTimePickerEnd.TabIndex = 8; - // - // textBoxFilePath - // - textBoxFilePath.Location = new Point(108, 6); - textBoxFilePath.Name = "textBoxFilePath"; - textBoxFilePath.Size = new Size(137, 23); - textBoxFilePath.TabIndex = 9; - // - // FormShoesReport - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(293, 197); - Controls.Add(textBoxFilePath); - Controls.Add(dateTimePickerEnd); - Controls.Add(dateTimePickerStart); - Controls.Add(comboBoxShoes); - Controls.Add(buttonBuild); - Controls.Add(buttonFile); - Controls.Add(label4); - Controls.Add(label3); - Controls.Add(label2); - Controls.Add(label1); - Name = "FormShoesReport"; - Text = "Отчет по обуви"; - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private Label label1; - private Label label2; - private Label label3; - private Label label4; - private Button buttonFile; - private Button buttonBuild; - private ComboBox comboBoxShoes; - private DateTimePicker dateTimePickerStart; - private DateTimePicker dateTimePickerEnd; - private TextBox textBoxFilePath; - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoesReport.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormShoesReport.cs deleted file mode 100644 index 73cbf6d..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoesReport.cs +++ /dev/null @@ -1,81 +0,0 @@ -using ProjectShoeShop.Reports; -using ProjectShoeShop.Repositories; -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using Unity; - -namespace ProjectShoeShop.Forms -{ - public partial class FormShoesReport : Form - { - private readonly IUnityContainer _container; - - public FormShoesReport(IUnityContainer container, IShoesRepository shoesRepository) - { - InitializeComponent(); - - _container = container ?? throw new ArgumentNullException(nameof(container)); - - comboBoxShoes.DataSource = shoesRepository.ReadShoes(); - comboBoxShoes.DisplayMember = "Name"; - comboBoxShoes.ValueMember = "Id"; - } - - private void buttonFile_Click(object sender, EventArgs e) - { - var sfd = new SaveFileDialog() - { - Filter = "Excel Files | *.xlsx" - }; - if (sfd.ShowDialog() != DialogResult.OK) - { - return; - } - textBoxFilePath.Text = sfd.FileName; - } - - private void buttonBuild_Click(object sender, EventArgs e) - { - try - { - if (string.IsNullOrWhiteSpace(textBoxFilePath.Text)) - { - throw new Exception("Отсутствует имя файла для отчета"); - } - if (comboBoxShoes.SelectedIndex < 0) - { - throw new Exception("Не выбрана обувь"); - } - if (dateTimePickerEnd.Value <= dateTimePickerStart.Value) - { - throw new Exception("Дата начала должна быть раньше даты окончания"); - } - if (_container.Resolve().CreateTable(textBoxFilePath.Text, (int)comboBoxShoes.SelectedValue!, dateTimePickerStart.Value, dateTimePickerEnd.Value)) - { - MessageBox.Show("Документ сформирован", - "Формирование документа", - MessageBoxButtons.OK, - MessageBoxIcon.Information); - } - else - { - MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", - "Формирование документа", - MessageBoxButtons.OK, MessageBoxIcon.Information); - } - } - catch (Exception ex) - { - MessageBox.Show(ex.Message, "Ошибка при создании очета", - MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoesReport.resx b/ProjectShoeShop/ProjectShoeShop/Forms/FormShoesReport.resx deleted file mode 100644 index af32865..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormShoesReport.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupply.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormSupply.Designer.cs deleted file mode 100644 index 8bcd752..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupply.Designer.cs +++ /dev/null @@ -1,153 +0,0 @@ -namespace ProjectShoeShop.Forms -{ - partial class FormSupply - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - comboBox = new ComboBox(); - labelVolume = new Label(); - buttonSave = new Button(); - buttonCancel = new Button(); - groupBox = new GroupBox(); - dataGridView = new DataGridView(); - ColumnShoe = new DataGridViewComboBoxColumn(); - ColumnNumberOfPairs = new DataGridViewTextBoxColumn(); - ColumnSize = new DataGridViewTextBoxColumn(); - groupBox.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // comboBox - // - comboBox.DropDownStyle = ComboBoxStyle.DropDownList; - comboBox.FormattingEnabled = true; - comboBox.Location = new Point(116, 9); - comboBox.Name = "comboBox"; - comboBox.Size = new Size(283, 23); - comboBox.TabIndex = 0; - // - // labelVolume - // - labelVolume.AutoSize = true; - labelVolume.Location = new Point(12, 9); - labelVolume.Name = "labelVolume"; - labelVolume.Size = new Size(98, 15); - labelVolume.TabIndex = 1; - labelVolume.Text = "Объем поставки"; - // - // buttonSave - // - buttonSave.Location = new Point(12, 216); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(75, 23); - buttonSave.TabIndex = 2; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += ButtonSave_Click; - // - // buttonCancel - // - buttonCancel.Location = new Point(324, 216); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(75, 23); - buttonCancel.TabIndex = 3; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += ButtonCancel_Click; - // - // groupBox - // - groupBox.Controls.Add(dataGridView); - groupBox.Location = new Point(12, 38); - groupBox.Name = "groupBox"; - groupBox.Size = new Size(390, 172); - groupBox.TabIndex = 4; - groupBox.TabStop = false; - groupBox.Text = "Обувь"; - // - // dataGridView - // - dataGridView.AllowUserToResizeColumns = false; - dataGridView.AllowUserToResizeRows = false; - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnShoe, ColumnNumberOfPairs, ColumnSize }); - dataGridView.Dock = DockStyle.Fill; - dataGridView.Location = new Point(3, 19); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.RowHeadersVisible = false; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(384, 150); - dataGridView.TabIndex = 0; - // - // ColumnShoe - // - ColumnShoe.HeaderText = "Обувь"; - ColumnShoe.Name = "ColumnShoe"; - // - // ColumnNumberOfPairs - // - ColumnNumberOfPairs.HeaderText = "Количество"; - ColumnNumberOfPairs.Name = "ColumnNumberOfPairs"; - // - // ColumnSize - // - ColumnSize.HeaderText = "Размер"; - ColumnSize.Name = "ColumnSize"; - // - // FormSupply - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(414, 251); - Controls.Add(groupBox); - Controls.Add(buttonCancel); - Controls.Add(buttonSave); - Controls.Add(labelVolume); - Controls.Add(comboBox); - Name = "FormSupply"; - Text = "Поставка"; - groupBox.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); - } - - #endregion - - private ComboBox comboBox; - private Label labelVolume; - private Button buttonSave; - private Button buttonCancel; - private GroupBox groupBox; - private DataGridView dataGridView; - private DataGridViewComboBoxColumn ColumnShoe; - private DataGridViewTextBoxColumn ColumnNumberOfPairs; - private DataGridViewTextBoxColumn ColumnSize; - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupply.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormSupply.cs deleted file mode 100644 index 0758606..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupply.cs +++ /dev/null @@ -1,68 +0,0 @@ -using ProjectShoeShop.Entities; -using ProjectShoeShop.Entities.Enums; -using ProjectShoeShop.Repositories; - -namespace ProjectShoeShop.Forms -{ - public partial class FormSupply : Form - { - private readonly ISupplyRepository _supplyRepository; - - public FormSupply(ISupplyRepository supplyRepository, IShoesRepository shoesRepository) - { - InitializeComponent(); - _supplyRepository = supplyRepository ?? - throw new ArgumentNullException(nameof(supplyRepository)); - - comboBox.DataSource = Enum.GetValues(typeof(SupplyType)); - - ColumnShoe.DataSource = shoesRepository.ReadShoes(); - ColumnShoe.DisplayMember = "Name"; - ColumnShoe.ValueMember = "Id"; - } - - private void ButtonSave_Click(object sender, EventArgs e) - { - try - { - if (comboBox.SelectedIndex < 1 || dataGridView.RowCount < 1) - { - throw new Exception("Имеется незаполненное поле"); - } - _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.CreateEntity(id,(SupplyType)comboBox.SelectedItem!, DateTime.Now, CreateListSupplyShoesFromDataGrid()); - - private List CreateListSupplyShoesFromDataGrid() - { - var list = new List(); - foreach (DataGridViewRow row in dataGridView.Rows) - { - if (row.Cells["ColumnShoe"].Value == null || - row.Cells["ColumnSize"].Value == null || - row.Cells["ColumnNumberOfPairs"].Value == null) - { - continue; - } - list.Add(SupplyShoes.CreateElement(0, - Convert.ToInt32(row.Cells["ColumnShoe"].Value), - Convert.ToInt32(row.Cells["ColumnSize"].Value), - Convert.ToInt32(row.Cells["ColumnNumberOfPairs"].Value))); - } - return list; - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupply.resx b/ProjectShoeShop/ProjectShoeShop/Forms/FormSupply.resx deleted file mode 100644 index 8da65c4..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupply.resx +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - True - - - True - - - True - - - True - - - True - - - True - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupplys.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormSupplys.Designer.cs deleted file mode 100644 index da5438d..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupplys.Designer.cs +++ /dev/null @@ -1,111 +0,0 @@ -namespace ProjectShoeShop.Forms -{ - partial class FormSupplys - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - dataGridView = new DataGridView(); - panel1 = new Panel(); - buttonDelete = new Button(); - buttonAdd = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - panel1.SuspendLayout(); - SuspendLayout(); - // - // dataGridView - // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.AllowUserToResizeColumns = false; - dataGridView.AllowUserToResizeRows = false; - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Fill; - dataGridView.Location = new Point(0, 0); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersVisible = false; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(604, 450); - dataGridView.TabIndex = 3; - // - // panel1 - // - panel1.Controls.Add(buttonDelete); - panel1.Controls.Add(buttonAdd); - panel1.Dock = DockStyle.Right; - panel1.Location = new Point(604, 0); - panel1.Name = "panel1"; - panel1.Size = new Size(196, 450); - panel1.TabIndex = 2; - // - // buttonDelete - // - buttonDelete.BackgroundImage = Properties.Resources._; - buttonDelete.BackgroundImageLayout = ImageLayout.Stretch; - buttonDelete.Location = new Point(65, 117); - buttonDelete.Name = "buttonDelete"; - buttonDelete.Size = new Size(75, 67); - buttonDelete.TabIndex = 1; - buttonDelete.UseVisualStyleBackColor = true; - buttonDelete.Click += ButtonDelete_Click; - // - // buttonAdd - // - buttonAdd.BackgroundImage = Properties.Resources._jpg; - buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; - buttonAdd.Location = new Point(65, 35); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(75, 64); - buttonAdd.TabIndex = 0; - buttonAdd.UseVisualStyleBackColor = true; - buttonAdd.Click += ButtonAdd_Click; - // - // FormSupplys - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Controls.Add(dataGridView); - Controls.Add(panel1); - Name = "FormSupplys"; - Text = "Поставка"; - Load += FormSupplys_Load; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - panel1.ResumeLayout(false); - ResumeLayout(false); - } - - #endregion - - private DataGridView dataGridView; - private Panel panel1; - private Button buttonDelete; - private Button buttonAdd; - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupplys.cs b/ProjectShoeShop/ProjectShoeShop/Forms/FormSupplys.cs deleted file mode 100644 index 6581566..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupplys.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -using ProjectShoeShop.Repositories; -using ProjectShoeShop.Repositories.Implementations; -using Unity; - -namespace ProjectShoeShop.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().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() => dataGridView.DataSource = _supplyRepository.ReadSupply(); - - private bool TryGetIdentifierFromSelectedRow(out int id) - { - id = 0; - if (dataGridView.SelectedRows.Count < 1) - { - MessageBox.Show("Нет выбранной записи", "Ошибка", - MessageBoxButtons.OK, MessageBoxIcon.Error); - return false; - } - - id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); - return true; - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupplys.resx b/ProjectShoeShop/ProjectShoeShop/Forms/FormSupplys.resx deleted file mode 100644 index af32865..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Forms/FormSupplys.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Program.cs b/ProjectShoeShop/ProjectShoeShop/Program.cs deleted file mode 100644 index 272c33f..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Program.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; -using ProjectShoeShop.Repositories; -using ProjectShoeShop.Repositories.Implementations; -using Serilog; -using Unity; -using Unity.Microsoft.Logging; - -namespace ProjectShoeShop -{ - internal static class Program - { - /// - /// The main entry point for the application. - /// - [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()); - } - - private static IUnityContainer CreateContainer() - { - var container = new UnityContainer(); - container.AddExtension(new LoggingExtension(CreateLoggerFactory())); - - container.RegisterType(); - container.RegisterType(); - container.RegisterType(); - container.RegisterType(); - container.RegisterType(); - - 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; - } - } -} \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/ProjectShoeShop.csproj b/ProjectShoeShop/ProjectShoeShop/ProjectShoeShop.csproj deleted file mode 100644 index 206e222..0000000 --- a/ProjectShoeShop/ProjectShoeShop/ProjectShoeShop.csproj +++ /dev/null @@ -1,44 +0,0 @@ - - - - WinExe - net8.0-windows - enable - true - enable - - - - - - - - - - - - - - - - - - - - - - - True - True - Resources.resx - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/ProjectShoeShop.sln b/ProjectShoeShop/ProjectShoeShop/ProjectShoeShop.sln deleted file mode 100644 index 1f2d69e..0000000 --- a/ProjectShoeShop/ProjectShoeShop/ProjectShoeShop.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34525.116 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectShoeShop", "ProjectShoeShop\ProjectShoeShop.csproj", "{95CE577A-0BCC-430A-B9C0-447B0542AE11}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {95CE577A-0BCC-430A-B9C0-447B0542AE11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {95CE577A-0BCC-430A-B9C0-447B0542AE11}.Debug|Any CPU.Build.0 = Debug|Any CPU - {95CE577A-0BCC-430A-B9C0-447B0542AE11}.Release|Any CPU.ActiveCfg = Release|Any CPU - {95CE577A-0BCC-430A-B9C0-447B0542AE11}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {1470F707-2372-4B36-B363-24D3557220BA} - EndGlobalSection -EndGlobal diff --git a/ProjectShoeShop/ProjectShoeShop/Properties/Resources.Designer.cs b/ProjectShoeShop/ProjectShoeShop/Properties/Resources.Designer.cs deleted file mode 100644 index 0b12aa3..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Properties/Resources.Designer.cs +++ /dev/null @@ -1,103 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Этот код создан программой. -// Исполняемая версия:4.0.30319.42000 -// -// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае -// повторной генерации кода. -// -//------------------------------------------------------------------------------ - -namespace ProjectShoeShop.Properties { - using System; - - - /// - /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. - /// - // Этот класс создан автоматически классом 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() { - } - - /// - /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. - /// - [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("ProjectShoeShop.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Перезаписывает свойство CurrentUICulture текущего потока для всех - /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Поиск локализованного ресурса типа System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap _ { - get { - object obj = ResourceManager.GetObject("-", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Поиск локализованного ресурса типа System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap _0_4348_objects_pencil_png { - get { - object obj = ResourceManager.GetObject("0-4348_objects-pencil-png", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Поиск локализованного ресурса типа System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap _jpg { - get { - object obj = ResourceManager.GetObject("+jpg", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Поиск локализованного ресурса типа System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap orig { - get { - object obj = ResourceManager.GetObject("orig", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Properties/Resources.resx b/ProjectShoeShop/ProjectShoeShop/Properties/Resources.resx deleted file mode 100644 index 161de46..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Properties/Resources.resx +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - ..\Resources\-.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\orig.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\+jpg.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\0-4348_objects-pencil-png.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - \ No newline at end of file diff --git a/ProjectShoeShop/ProjectShoeShop/Reports/ChartReport.cs b/ProjectShoeShop/ProjectShoeShop/Reports/ChartReport.cs deleted file mode 100644 index ad9e9d8..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Reports/ChartReport.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Microsoft.Extensions.Logging; -using ProjectShoeShop.Repositories; -using ProjectShoeShop.Repositories.Implementations; - -namespace ProjectShoeShop.Reports; - -internal class ChartReport -{ - private readonly IOrderRepository _orderRepository; - private readonly IShoesRepository _shoesRepository; - private readonly ILogger _logger; - - public ChartReport(IOrderRepository orderRepository, IShoesRepository shoesRepository, ILogger logger) - { - _orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository)); - _shoesRepository = shoesRepository ?? throw new ArgumentNullException(nameof(shoesRepository)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } - - public bool CreateChart(string filePath, DateTime dateTime) - { - try - { - new PdfBuilder(filePath) - .AddHeader("Продажи обуви") - .AddPieChart("Обувь", GetData(dateTime)) - .Build(); - return true; - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при формировании документа"); - return false; - } - } - private List<(string Caption, double Value)> GetData(DateTime dateTime) - { - var fuelNames = _shoesRepository.ReadShoes() - .ToDictionary(f => f.Id, f => f.Name); - - return _orderRepository - .ReadOrder() - .Where(x => x.OrderDate.Date == dateTime.Date) - .SelectMany(x => x.OrderItems) - .GroupBy(x => x.ShoesId) - .Select(g => (Caption: fuelNames[g.Key].ToString(), Value: (double)g.Sum(x => x.NumberOfPairs))) - .ToList(); - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Reports/DocReport.cs b/ProjectShoeShop/ProjectShoeShop/Reports/DocReport.cs deleted file mode 100644 index b8301d2..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Reports/DocReport.cs +++ /dev/null @@ -1,61 +0,0 @@ -using Microsoft.Extensions.Logging; -using ProjectShoeShop.Repositories; - -namespace ProjectShoeShop.Reports; - -public class DocReport -{ - private readonly IClientRepository _clientRepository; - private readonly IShoesRepository _shoesRepository; - private readonly ILogger _logger; - - public DocReport(IClientRepository clientRepository, IShoesRepository shoesRepository, ILogger logger) - { - _clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository)); - _shoesRepository = shoesRepository ?? throw new ArgumentNullException(nameof(shoesRepository)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } - - public bool CreateDoc(string filePath, bool includeClients, bool includeShoes) - { - try - { - var builder = new WordBuilder(filePath).AddHeader("Документ со справочниками"); - if (includeClients) - { - builder.AddParagraph("Клиенты").AddTable([2400], GetClients()); - } - if (includeShoes) - { - builder.AddParagraph("Обувь").AddTable([2400, 2400, 2400], GetShoes()); - } - builder.Build(); - return true; - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при формировании документа"); - return false; - } - } - - private List GetClients() - { - return [ - ["Имя"], - .. _clientRepository - .ReadClient() - .Select(x => new string[] { x.Name }), - ]; - } - - private List GetShoes() - { - return [ - ["Название", "Цена", "Тип"], - .. _shoesRepository - .ReadShoes() - .Select(x => new string[] { x.Name, x.Price.ToString(), x.ShoesType.ToString() }), - ]; - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Reports/ExcelBuilder.cs b/ProjectShoeShop/ProjectShoeShop/Reports/ExcelBuilder.cs deleted file mode 100644 index 78e7af7..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Reports/ExcelBuilder.cs +++ /dev/null @@ -1,311 +0,0 @@ -using DocumentFormat.OpenXml.Packaging; -using DocumentFormat.OpenXml.Spreadsheet; -using DocumentFormat.OpenXml; - -namespace ProjectShoeShop.Reports; - -internal class ExcelBuilder -{ - private readonly string _filePath; - private readonly SheetData _sheetData; - private readonly MergeCells _mergeCells; - private readonly Columns _columns; - private uint _rowIndex = 0; - - public ExcelBuilder(string filePath) - { - if (string.IsNullOrWhiteSpace(filePath)) - { - throw new ArgumentNullException(nameof(filePath)); - } - if (File.Exists(filePath)) - { - File.Delete(filePath); - } - _filePath = filePath; - _sheetData = new SheetData(); - _mergeCells = new MergeCells(); - _columns = new Columns(); - _rowIndex = 1; - } - - public ExcelBuilder AddHeader(string header, int startIndex, int count) - { - CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder); - for (int i = startIndex + 1; i < startIndex + count; ++i) - { - CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder); - } - _mergeCells.Append(new MergeCell() - { - Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}") - }); - _rowIndex++; - return this; - } - - public ExcelBuilder AddParagraph(string text, int columnIndex) - { - CreateCell(columnIndex, _rowIndex++, text, StyleIndex.SimpleTextWithoutBorder); - return this; - } - - public ExcelBuilder AddTable(int[] columnsWidths, List data) - { - if (columnsWidths == null || columnsWidths.Length == 0) - { - throw new ArgumentNullException(nameof(columnsWidths)); - } - if (data == null || data.Count == 0) - { - throw new ArgumentNullException(nameof(data)); - } - if (data.Any(x => x.Length != columnsWidths.Length)) - { - throw new InvalidOperationException("widths.Length != data.Length"); - } - - uint counter = 1; - int coef = 2; - _columns.Append(columnsWidths.Select(x => new Column - { - Min = counter, - Max = counter++, - Width = x * coef, - CustomWidth = true - })); - for (var j = 0; j < data.First().Length; ++j) - { - CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder); - } - _rowIndex++; - - for (var i = 1; i < data.Count - 1; ++i) - { - for (var j = 0; j < data[i].Length; ++j) - { - CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder); - } - _rowIndex++; - } - for (var j = 0; j < data.Last().Length; ++j) - { - CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder); - } - _rowIndex++; - return this; - } - - public void Build() - { - using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath, SpreadsheetDocumentType.Workbook); - var workbookpart = spreadsheetDocument.AddWorkbookPart(); - GenerateStyle(workbookpart); - workbookpart.Workbook = new Workbook(); - var worksheetPart = workbookpart.AddNewPart(); - worksheetPart.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().First()); - } - } - - private static void GenerateStyle(WorkbookPart workbookPart) - { - var workbookStylesPart = workbookPart.AddNewPart(); - 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.Minor) - } - }); - 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.Minor) - }, - Bold = new Bold() { Val = true } - }); - workbookStylesPart.Stylesheet.Append(fonts); - - // Default Fill - var fills = new Fills() { Count = 1 }; - fills.Append(new Fill - { - PatternFill = new PatternFill() - { - PatternType = new EnumValue(PatternValues.None) - } - }); - workbookStylesPart.Stylesheet.Append(fills); - - // Default Border - var borders = new Borders() { Count = 2 }; - borders.Append(new Border - { - LeftBorder = new LeftBorder(), - RightBorder = new RightBorder(), - TopBorder = new TopBorder(), - BottomBorder = new BottomBorder(), - DiagonalBorder = new DiagonalBorder() - }); - borders.Append(new Border - { - LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin }, - RightBorder = new RightBorder() { Style = BorderStyleValues.Thin }, - TopBorder = new TopBorder() { Style = BorderStyleValues.Thin }, - BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin }, - DiagonalBorder = new DiagonalBorder() - }); - workbookStylesPart.Stylesheet.Append(borders); - - // Default cell format and a date cell format - var cellFormats = new CellFormats() { Count = 4 }; - cellFormats.Append(new CellFormat - { - NumberFormatId = 0, - FormatId = 0, - FontId = 0, - BorderId = 0, - FillId = 0, - Alignment = new Alignment() - { - Horizontal = HorizontalAlignmentValues.Left, - Vertical = VerticalAlignmentValues.Center, - WrapText = true - } - }); - cellFormats.Append(new CellFormat - { - NumberFormatId = 0, - FormatId = 0, - FontId = 0, - BorderId = 1, - FillId = 0, - Alignment = new Alignment() - { - Horizontal = HorizontalAlignmentValues.Right, - Vertical = VerticalAlignmentValues.Center, - WrapText = true - } - }); - cellFormats.Append(new CellFormat - { - NumberFormatId = 0, - FormatId = 0, - FontId = 1, - BorderId = 0, - FillId = 0, - Alignment = new Alignment() - { - Horizontal = HorizontalAlignmentValues.Center, - Vertical = VerticalAlignmentValues.Center, - WrapText = true - } - }); - cellFormats.Append(new CellFormat - { - NumberFormatId = 0, - FormatId = 0, - FontId = 1, - BorderId = 1, - FillId = 0, - Alignment = new Alignment() - { - Horizontal = HorizontalAlignmentValues.Center, - Vertical = VerticalAlignmentValues.Center, - WrapText = true - } - }); - workbookStylesPart.Stylesheet.Append(cellFormats); - } - - private enum StyleIndex - { - SimpleTextWithoutBorder = 0, - SimpleTextWithBorder = 1, - BoldTextWithoutBorder = 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().FirstOrDefault(r => r.RowIndex! == rowIndex); - if (row == null) - { - row = new Row() { RowIndex = rowIndex }; - _sheetData.Append(row); - } - var newCell = row.Elements().FirstOrDefault(c => c.CellReference != null && - c.CellReference.Value == columnName + rowIndex); - if (newCell == null) - { - Cell? refCell = null; - foreach (Cell cell in row.Elements()) - { - 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; - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Reports/PdfBuilder.cs b/ProjectShoeShop/ProjectShoeShop/Reports/PdfBuilder.cs deleted file mode 100644 index 3a43c2d..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Reports/PdfBuilder.cs +++ /dev/null @@ -1,76 +0,0 @@ -using MigraDoc.DocumentObjectModel; -using MigraDoc.DocumentObjectModel.Shapes.Charts; -using MigraDoc.Rendering; -using System.Text; - -namespace ProjectShoeShop.Reports; - -internal class PdfBuilder -{ - private readonly string _filePath; - private readonly Document _document; - - public PdfBuilder(string filePath) - { - if (string.IsNullOrWhiteSpace(filePath)) - { - throw new ArgumentNullException(nameof(filePath)); - } - if (File.Exists(filePath)) - { - File.Delete(filePath); - } - _filePath = filePath; - _document = new Document(); - DefineStyles(); - } - - public PdfBuilder AddHeader(string header) - { - _document.AddSection().AddParagraph(header, "NormalBold"); - return this; - } - - public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data) - { - if (data == null || data.Count == 0) - { - return this; - } - var chart = new Chart(ChartType.Pie2D); - var series = chart.SeriesCollection.AddSeries(); - series.Add(data.Select(x => x.Value).ToArray()); - var xseries = chart.XValues.AddXSeries(); - xseries.Add(data.Select(x => x.Caption).ToArray()); - chart.DataLabel.Type = DataLabelType.Percent; - chart.DataLabel.Position = DataLabelPosition.OutsideEnd; - chart.Width = Unit.FromCentimeter(16); - chart.Height = Unit.FromCentimeter(12); - chart.TopArea.AddParagraph(title); - chart.XAxis.MajorTickMark = TickMarkType.Outside; - chart.YAxis.MajorTickMark = TickMarkType.Outside; - chart.YAxis.HasMajorGridlines = true; - chart.PlotArea.LineFormat.Width = 1; - chart.PlotArea.LineFormat.Visible = true; - chart.TopArea.AddLegend(); - _document.LastSection.Add(chart); - return this; - } - - public void Build() - { - Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); - var renderer = new PdfDocumentRenderer(true) - { - Document = _document - }; - renderer.RenderDocument(); - renderer.PdfDocument.Save(_filePath); - } - private void DefineStyles() - { - var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal"); - headerStyle.Font.Bold = true; - headerStyle.Font.Size = 14; - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Reports/TableReport.cs b/ProjectShoeShop/ProjectShoeShop/Reports/TableReport.cs deleted file mode 100644 index b535d22..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Reports/TableReport.cs +++ /dev/null @@ -1,70 +0,0 @@ -using Microsoft.Extensions.Logging; -using ProjectShoeShop.Repositories; - -namespace ProjectShoeShop.Reports; - -internal class TableReport -{ - private readonly IOrderRepository _orderRepository; - private readonly ISupplyRepository _supplyRepository; - private readonly ILogger _logger; - internal static readonly string[] item = ["Дата", "Количество пришло", "Количество ушло"]; - - public TableReport(IOrderRepository orderRepository, ISupplyRepository supplyRepository, ILogger logger) - { - _orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository)); - _supplyRepository = supplyRepository ?? throw new ArgumentNullException(nameof(supplyRepository)); - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - } - - public bool CreateTable(string filePath, int shoesId, DateTime startDate, DateTime endDate) - { - try - { - new ExcelBuilder(filePath) - .AddHeader("Сводка по движению товара", 0, 3) - .AddParagraph("за период", 0) - .AddTable([10, 15, 15], GetData(shoesId, startDate, endDate)) - .Build(); - return true; - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при формировании документа"); - return false; - } - } - - private List GetData(int shoesId, DateTime startDate, DateTime endDate) - { - var data = _orderRepository - .ReadOrder() - .Where(x => x.OrderDate >= startDate && x.OrderDate <= endDate && x.OrderItems.Any(y => y.ShoesId == shoesId)) - .Select(x => new { Date = x.OrderDate.Date, CountIn = (int?)null, CountOut = x.OrderItems.FirstOrDefault(y => y.ShoesId == shoesId)?.NumberOfPairs }) - .Union( - _supplyRepository - .ReadSupply() - .Where(x => x.DateOfReceipt >= startDate && x.DateOfReceipt <= endDate && x.SupplyShoes.Any(y => y.ShoesId == shoesId)) - .Select(x => new { Date = x.DateOfReceipt.Date, CountIn = x.SupplyShoes.FirstOrDefault(y => y.ShoesId == shoesId)?.NumberOfPairs, CountOut = (int?)null }) - ) - .OrderBy(x => x.Date); - - var groupedData = data - .GroupBy(x => x.Date) - .Select(g => new - { - Date = g.Key, - TotalIn = g.Sum(x => x.CountIn), - TotalOut = g.Sum(x => x.CountOut) - }) - .OrderBy(x => x.Date); - return - new List() { item } - .Union(groupedData - .Select(x => new string[] { x.Date.ToString("dd.MM.yyyy"), x.TotalIn.ToString()!, x.TotalOut.ToString()! })) - .Union( - new[] { new string[] { "Всего", groupedData.Sum(x => x.TotalIn).ToString()!, groupedData.Sum(x => x.TotalOut).ToString()! } } - ) - .ToList(); - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Reports/WordBuilder.cs b/ProjectShoeShop/ProjectShoeShop/Reports/WordBuilder.cs deleted file mode 100644 index 38b51c8..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Reports/WordBuilder.cs +++ /dev/null @@ -1,130 +0,0 @@ -using DocumentFormat.OpenXml.Drawing.Charts; -using DocumentFormat.OpenXml; -using DocumentFormat.OpenXml.Wordprocessing; -using DocumentFormat.OpenXml.Packaging; - -namespace ProjectShoeShop.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()); - var runProperties = run.AppendChild(new RunProperties()); - runProperties.AppendChild(new Bold()); - run.AppendChild(new Text(header)); - return this; - } - - public WordBuilder AddParagraph(string text) - { - var paragraph = _body.AppendChild(new Paragraph()); - var run = paragraph.AppendChild(new Run()); - run.AppendChild(new Text(text)); - return this; - } - - public WordBuilder AddTable(int[] widths, List 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.Single), - Size = 12 - }, - new BottomBorder() - { - Val = new - EnumValue(BorderValues.Single), - Size = 12 - }, - new LeftBorder() - { - Val = new - EnumValue(BorderValues.Single), - Size = 12 - }, - new RightBorder() - { - Val = new - EnumValue(BorderValues.Single), - Size = 12 - }, - new InsideHorizontalBorder() - { - Val = new - EnumValue(BorderValues.Single), - Size = 12 - }, - new InsideVerticalBorder() - { - Val = new - EnumValue(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; - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/IClientRepository.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/IClientRepository.cs deleted file mode 100644 index 9b24477..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/IClientRepository.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ProjectShoeShop.Entities; - -namespace ProjectShoeShop.Repositories; - -public interface IClientRepository -{ - IEnumerable ReadClient(); - - Client ReadClientById(int id); - - void CreateClient(Client client); - - void DeleteClient(int id); - - void UpdateClient(Client client); -} diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/IConnectionString.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/IConnectionString.cs deleted file mode 100644 index 5fd0fe4..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/IConnectionString.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectShoeShop.Repositories; - -public interface IConnectionString -{ - public string ConnectionString { get; } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/IOrderRepository.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/IOrderRepository.cs deleted file mode 100644 index 80d3706..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/IOrderRepository.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ProjectShoeShop.Entities; - -namespace ProjectShoeShop.Repositories; - -public interface IOrderRepository -{ - IEnumerable ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null); - - void CreateOrder(Order order); -} diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/IShoesRepository.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/IShoesRepository.cs deleted file mode 100644 index e924551..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/IShoesRepository.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ProjectShoeShop.Entities; - -namespace ProjectShoeShop.Repositories; - -public interface IShoesRepository -{ - IEnumerable ReadShoes(); - - Shoes ReadShoesById(int id); - - void CreateShoes(Shoes shoes); - - void UpdateShoes(Shoes shoes); - - void DeleteShoes(int id); -} diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/ISupplyRepository.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/ISupplyRepository.cs deleted file mode 100644 index e85f9a2..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/ISupplyRepository.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ProjectShoeShop.Entities; - -namespace ProjectShoeShop.Repositories; - -public interface ISupplyRepository -{ - IEnumerable ReadSupply(DateTime? dateForm = null, DateTime? dateTo = null); - - void CreateSupply(Supply supply); - - void DeleteSupply(int id); -} - diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/ISupplyShoesRepository.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/ISupplyShoesRepository.cs deleted file mode 100644 index 624a676..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/ISupplyShoesRepository.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using ProjectShoeShop.Entities; - -namespace ProjectShoeShop.Repositories; - -public interface ISupplyShoesRepository -{ - IEnumerable ReadSupplyShoes(int? supplyId = null, int? shoesId = null); - - void CreateSupplyShoes(SupplyShoes supplyShoes); - - void DeleteSupplyShoes(int id); -} diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/ClientRepository.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/ClientRepository.cs deleted file mode 100644 index 625cd0e..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/ClientRepository.cs +++ /dev/null @@ -1,121 +0,0 @@ -using Dapper; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using Npgsql; -using ProjectShoeShop.Entities; - -namespace ProjectShoeShop.Repositories.Implementations; - -public class ClientRepository : IClientRepository -{ - private readonly IConnectionString _connectionString; - private readonly ILogger _logger; - - public ClientRepository(IConnectionString connectionString, ILogger 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 Client (Name) - VALUES (@Name)"; - connection.Execute(queryInsert, 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 Client - WHERE Id=@id"; - connection.Execute(queryDelete, new { id }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при удалении объекта"); - throw; - } - } - - public IEnumerable ReadClient() - { - _logger.LogInformation("Получение всех объектов"); - try - { - using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = "SELECT * FROM Client"; - var clients = connection.Query(querySelect); - _logger.LogDebug("Полученные объекты: {json}", - JsonConvert.SerializeObject(clients)); - return clients; - } - 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 Client - WHERE Id=@id"; - var client = connection.QueryFirst(querySelect, new { id }); - _logger.LogDebug("Найденный объект: {json}", - JsonConvert.SerializeObject(client)); - return 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 Client - SET - Name=@Name - WHERE Id=@Id"; - connection.Execute(queryUpdate, client); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при редактировании объекта"); - throw; - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/ConnectionString.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/ConnectionString.cs deleted file mode 100644 index e2d2d2e..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/ConnectionString.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectShoeShop.Repositories.Implementations; - -public class ConnectionString : IConnectionString -{ - string IConnectionString.ConnectionString => "Host=localhost;Port=5432;Username=postgres;Password=030405;Database=OTP_shoes"; -} diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/OrderRepository.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/OrderRepository.cs deleted file mode 100644 index 69c9407..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/OrderRepository.cs +++ /dev/null @@ -1,78 +0,0 @@ -using Dapper; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using Npgsql; -using ProjectShoeShop.Entities; - -namespace ProjectShoeShop.Repositories.Implementations; - -public class OrderRepository : IOrderRepository -{ - private readonly IConnectionString _connectionString; - private readonly ILogger _logger; - - public OrderRepository(IConnectionString connectionString, ILogger 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 ""Order"" (ClientId, OrderDate) - VALUES (@ClientId, @OrderDate); - SELECT MAX(Id) FROM ""Order"""; - var orderId = - connection.QueryFirst(queryInsert, order, transaction); - var querySubInsert = @" - INSERT INTO OrderItem (OrderId, ShoesId, NumberOfPairs, Size) - VALUES (@OrderId, @ShoesId, @NumberOfPairs, @Size)"; - foreach (var elem in order.OrderItems) - { - connection.Execute(querySubInsert, new - { - orderId, - elem.ShoesId, - elem.NumberOfPairs, - elem.Size - }, transaction); - } - transaction.Commit(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при добавлении объекта"); - throw; - } - } - - public IEnumerable ReadOrder(DateTime? dateForm = null, DateTime? dateTo = null) - { - _logger.LogInformation("Получение всех объектов"); - try - { - using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = @"SELECT ord.*, ordi.ShoesId, ordi.NumberOfPairs, ordi.Size FROM ""Order"" ord - INNER JOIN OrderItem ordi on ord.Id = ordi.OrderId"; - var contractorFuels = connection.Query(querySelect); - _logger.LogDebug("Полученные объекты: {json}", - JsonConvert.SerializeObject(contractorFuels)); - return contractorFuels.GroupBy(x => x.Id, y => y, (key, value) => Order.CreateOperation(value.First(), value.Select(z => OrderItem.CreateElement(0, z.ShoesId, z.NumberOfPairs, z.Size)))).ToList(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при чтении объектов"); - throw; - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/ShoesRepository.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/ShoesRepository.cs deleted file mode 100644 index 45242bc..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/ShoesRepository.cs +++ /dev/null @@ -1,123 +0,0 @@ -using Dapper; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using Npgsql; -using ProjectShoeShop.Entities; - -namespace ProjectShoeShop.Repositories.Implementations; - -public class ShoesRepository : IShoesRepository -{ - private readonly IConnectionString _connectionString; - private readonly ILogger _logger; - - public ShoesRepository(IConnectionString connectionString, ILogger logger) - { - _connectionString = connectionString; - _logger = logger; - } - - public void CreateShoes(Shoes shoes) - { - _logger.LogInformation("Добавление объекта"); - _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(shoes)); - - try - { - using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var queryInsert = @" - INSERT INTO Shoes (Name, Price, ShoesType) - VALUES (@Name, @Price, @ShoesType)"; - connection.Execute(queryInsert, shoes); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при добавлении объекта"); - throw; - } - } - - public void DeleteShoes(int id) - { - _logger.LogInformation("Удаление объекта"); - _logger.LogDebug("Объект: {id}", id); - try - { - using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var queryDelete = @" - DELETE FROM Shoes - WHERE Id=@id"; - connection.Execute(queryDelete, new { id }); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при удалении объекта"); - throw; - } - } - - public IEnumerable ReadShoes() - { - _logger.LogInformation("Получение всех объектов"); - try - { - using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = "SELECT * FROM Shoes"; - var shoeses = connection.Query(querySelect); - _logger.LogDebug("Полученные объекты: {json}", - JsonConvert.SerializeObject(shoeses)); - return shoeses; - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при чтении объектов"); - throw; - } - } - - public Shoes ReadShoesById(int id) - { - _logger.LogInformation("Получение объекта по идентификатору"); - _logger.LogDebug("Объект: {id}", id); - try - { - using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = @" - SELECT * FROM Shoes - WHERE Id=@id"; - var shoes = connection.QueryFirst(querySelect, new { id }); - _logger.LogDebug("Найденный объект: {json}", - JsonConvert.SerializeObject(shoes)); - return shoes; - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при поиске объекта"); - throw; - } - } - - public void UpdateShoes(Shoes shoes) - { - _logger.LogInformation("Редактирование объекта"); - _logger.LogDebug("Объект: {json}", - JsonConvert.SerializeObject(shoes)); - try - { - using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var queryUpdate = @" - UPDATE Shoes - SET - Name=@Name, - Price=@Price, - ShoesType=@ShoesType - WHERE Id=@Id"; - connection.Execute(queryUpdate, shoes); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при редактировании объекта"); - throw; - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/SupplyRepository.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/SupplyRepository.cs deleted file mode 100644 index cc3452f..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/SupplyRepository.cs +++ /dev/null @@ -1,107 +0,0 @@ -using Dapper; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using Npgsql; -using ProjectShoeShop.Entities; - -namespace ProjectShoeShop.Repositories.Implementations; - -public class SupplyRepository : ISupplyRepository -{ - private readonly IConnectionString _connectionString; - private readonly ILogger _logger; - - public SupplyRepository(IConnectionString connectionString, ILogger 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); - connection.Open(); - using var transaction = connection.BeginTransaction(); - var queryInsert = @" - INSERT INTO Supply (SupplyType, DateOfReceipt) - VALUES (@SupplyType, @DateOfReceipt); - SELECT MAX(Id) FROM Supply"; - var supplyId = - connection.QueryFirst(queryInsert, supply, transaction); - var querySubInsert = @" - INSERT INTO SupplyShoes (SupplyId, ShoesId, NumberOfPairs, Size) - VALUES (@SupplyId, @ShoesId, @NumberOfPairs, @Size)"; - foreach (var elem in supply.SupplyShoes) - { - connection.Execute(querySubInsert, new - { - supplyId, - elem.ShoesId, - elem.NumberOfPairs, - elem.Size - }, transaction); - } - transaction.Commit(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при добавлении объекта"); - throw; - } - } - - public IEnumerable ReadSupply(DateTime? dateForm = null, DateTime? dateTo = null) - { - _logger.LogInformation("Получение всех объектов"); - try - { - using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = @"SELECT sup.*, sups.ShoesId, sups.Size, sups.NumberOfPairs FROM Supply sup - INNER JOIN SupplyShoes sups on sup.Id = sups.SupplyId"; - var supplies = connection.Query(querySelect); - _logger.LogDebug("Полученные объекты: {json}", - JsonConvert.SerializeObject(supplies)); - return supplies.GroupBy(x => x.Id, y => y, (key, value) => Supply.CreateEntity(value.First(), value.Select(z => SupplyShoes.CreateElement(0, z.ShoesId, z.Size, z.NumberOfPairs)))).ToList(); - } - 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); - connection.Open(); - using var transaction = connection.BeginTransaction(); - var queryDeleteSub = @" - DELETE FROM SupplyShoes - WHERE SupplyId = @id"; - connection.Execute(queryDeleteSub, new { id }, transaction); - - var queryDelete = @" - DELETE FROM Supply - WHERE Id = @id"; - connection.Execute(queryDelete, new { id }, transaction); - - transaction.Commit(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка при удалении объекта"); - throw; - } - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/SupplyShoes.cs b/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/SupplyShoes.cs deleted file mode 100644 index 2ebc0fc..0000000 --- a/ProjectShoeShop/ProjectShoeShop/Repositories/Implementations/SupplyShoes.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace ProjectShoeShop.Repositories.Implementations; - -public class SupplyShoes : ISupplyShoesRepository -{ - public void CreateSupplyShoes(Entities.SupplyShoes supplyShoes) - { - - } - - public void DeleteSupplyShoes(int id) - { - - } - - public IEnumerable ReadSupplyShoes(int? supplyId = null, int? shoesId = null) - { - return []; - } -} diff --git a/ProjectShoeShop/ProjectShoeShop/Resources/+jpg.jpg b/ProjectShoeShop/ProjectShoeShop/Resources/+jpg.jpg deleted file mode 100644 index fadf25c..0000000 Binary files a/ProjectShoeShop/ProjectShoeShop/Resources/+jpg.jpg and /dev/null differ diff --git a/ProjectShoeShop/ProjectShoeShop/Resources/-.jpg b/ProjectShoeShop/ProjectShoeShop/Resources/-.jpg deleted file mode 100644 index 5afc292..0000000 Binary files a/ProjectShoeShop/ProjectShoeShop/Resources/-.jpg and /dev/null differ diff --git a/ProjectShoeShop/ProjectShoeShop/Resources/0-4348_objects-pencil-png.jpg b/ProjectShoeShop/ProjectShoeShop/Resources/0-4348_objects-pencil-png.jpg deleted file mode 100644 index 9808512..0000000 Binary files a/ProjectShoeShop/ProjectShoeShop/Resources/0-4348_objects-pencil-png.jpg and /dev/null differ diff --git a/ProjectShoeShop/ProjectShoeShop/Resources/orig.jpg b/ProjectShoeShop/ProjectShoeShop/Resources/orig.jpg deleted file mode 100644 index c05e7f5..0000000 Binary files a/ProjectShoeShop/ProjectShoeShop/Resources/orig.jpg and /dev/null differ diff --git a/ProjectShoeShop/ProjectShoeShop/appsettings.json b/ProjectShoeShop/ProjectShoeShop/appsettings.json deleted file mode 100644 index 2f734b4..0000000 --- a/ProjectShoeShop/ProjectShoeShop/appsettings.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "Serilog": { - "Using": [ "Serilog.Sinks.File" ], - "MinimumLevel": "Debug", - "WriteTo": [ - { - "Name": "File", - "Args": { - "path": "Logs/log.txt", - "rollingInterval": "Day" - } - } - ] - } -} \ No newline at end of file