diff --git a/ShoeStore/Entities/Employee.cs b/ShoeStore/Entities/Employee.cs index 2bacd40..54af1f2 100644 --- a/ShoeStore/Entities/Employee.cs +++ b/ShoeStore/Entities/Employee.cs @@ -13,7 +13,7 @@ public class Employee public int NumberStorage { get; private set; } public int StorageSize { get; private set; } - public Employee CreateEntity(int id, int numberStorage, int storageSize) + public static Employee CreateEntity(int id, int numberStorage, int storageSize) { return new Employee { diff --git a/ShoeStore/Entities/Product.cs b/ShoeStore/Entities/Product.cs index 88945de..6d25a6d 100644 --- a/ShoeStore/Entities/Product.cs +++ b/ShoeStore/Entities/Product.cs @@ -12,16 +12,13 @@ public class Product { public int Id { get; private set; } public int StorageProductId { get; private set; } - public string NameOfShoes { get; private set; } - public ManufacturingCompany ManufacturingCompany { get; private set; } - public int Price { get; private set; } public ProductType ProductType { get; private set; } public int StorageSize { get; private set; } - public Product CreateEntity(int id, int storageProductId, string nameOfShoes, ManufacturingCompany manufacturingCompany, int price, + public static Product CreateEntity(int id, int storageProductId, string nameOfShoes, ManufacturingCompany manufacturingCompany, int price, ProductType productType, int storageSize) { return new Product diff --git a/ShoeStore/Entities/ProductSale.cs b/ShoeStore/Entities/ProductSale.cs index fdc258f..e1903d1 100644 --- a/ShoeStore/Entities/ProductSale.cs +++ b/ShoeStore/Entities/ProductSale.cs @@ -12,7 +12,7 @@ public class ProductSale public int SaleId { get; private set; } public int Amount { get; private set; } - public ProductSale CreateEntities(int productId, int saleId, int amount) + public static ProductSale CreateEntities(int productId, int saleId, int amount) { return new ProductSale { ProductId = productId, diff --git a/ShoeStore/Entities/Receipt.cs b/ShoeStore/Entities/Receipt.cs index b851c80..d5edff2 100644 --- a/ShoeStore/Entities/Receipt.cs +++ b/ShoeStore/Entities/Receipt.cs @@ -9,17 +9,19 @@ namespace ShoeStore.Entities; public class Receipt { public int Id { get; private set; } + public int ProductId { get; private set; } public int StorageProductId { get; private set; } public int ReceiptNumber {get; private set; } public DateTime DateOfReceipt { get; private set; } public int NumberOfPairsReceived { get; private set; } public int StorageSize { get; private set; } - public Receipt CreateOperation(int id, int storageProductId, int receiptNumber, int numberOfPairsReceived, int storageSize) + public static Receipt CreateOperation(int id, int productId, int storageProductId, int receiptNumber, int numberOfPairsReceived, int storageSize) { return new Receipt { Id = id, + ProductId = productId, StorageProductId = storageProductId, ReceiptNumber = receiptNumber, DateOfReceipt = DateTime.Now, diff --git a/ShoeStore/Entities/Sale.cs b/ShoeStore/Entities/Sale.cs index 28a760d..c263b8f 100644 --- a/ShoeStore/Entities/Sale.cs +++ b/ShoeStore/Entities/Sale.cs @@ -20,7 +20,7 @@ public class Sale private set; } = []; - public Sale CreateOperation (int id, int productId, int storageProductId, int salesNumber, int storageSize) + public static Sale CreateOperation (int id, int productId, int storageProductId, int salesNumber, int storageSize) { return new Sale { diff --git a/ShoeStore/Entities/Storage.cs b/ShoeStore/Entities/Storage.cs index 1f5eb01..1d0c332 100644 --- a/ShoeStore/Entities/Storage.cs +++ b/ShoeStore/Entities/Storage.cs @@ -11,7 +11,7 @@ public class Storage public int Size { get; private set; } public int QuantityInStock { get; private set; } public int NumberStorage { get; private set; } - public Storage CreateEntity(int size, int quantityInStock, int numberStorage) + public static Storage CreateEntity(int size, int quantityInStock, int numberStorage) { return new Storage { diff --git a/ShoeStore/Forms/FormEmployee.Designer.cs b/ShoeStore/Forms/FormEmployee.Designer.cs new file mode 100644 index 0000000..11be70d --- /dev/null +++ b/ShoeStore/Forms/FormEmployee.Designer.cs @@ -0,0 +1,143 @@ +namespace ShoeStore.Froms +{ + partial class FormEmployee + { + /// + /// 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() + { + dateTimePickerDate = new DateTimePicker(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + numericUpDownNumStorage = new NumericUpDown(); + numericUpDownStorageSize = new NumericUpDown(); + buttonSave = new Button(); + buttonCancel = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownNumStorage).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).BeginInit(); + SuspendLayout(); + // + // dateTimePickerDate + // + dateTimePickerDate.Location = new Point(179, 41); + dateTimePickerDate.Name = "dateTimePickerDate"; + dateTimePickerDate.Size = new Size(132, 23); + dateTimePickerDate.TabIndex = 0; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(40, 47); + label1.Name = "label1"; + label1.Size = new Size(35, 15); + label1.TabIndex = 1; + label1.Text = "Дата:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(40, 115); + label2.Name = "label2"; + label2.Size = new Size(88, 15); + label2.TabIndex = 2; + label2.Text = "Номер склада:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(40, 178); + label3.Name = "label3"; + label3.Size = new Size(106, 15); + label3.TabIndex = 3; + label3.Text = "Размер на складе:"; + // + // numericUpDownNumStorage + // + numericUpDownNumStorage.Location = new Point(179, 107); + numericUpDownNumStorage.Name = "numericUpDownNumStorage"; + numericUpDownNumStorage.Size = new Size(132, 23); + numericUpDownNumStorage.TabIndex = 4; + // + // numericUpDownStorageSize + // + numericUpDownStorageSize.Location = new Point(179, 176); + numericUpDownStorageSize.Name = "numericUpDownStorageSize"; + numericUpDownStorageSize.Size = new Size(132, 23); + numericUpDownStorageSize.TabIndex = 5; + // + // buttonSave + // + buttonSave.Location = new Point(40, 251); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(106, 23); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click_1; + // + // buttonCancel + // + buttonCancel.Location = new Point(205, 251); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(106, 23); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click_1; + // + // FormEmployee + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(352, 316); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(numericUpDownStorageSize); + Controls.Add(numericUpDownNumStorage); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(dateTimePickerDate); + Name = "FormEmployee"; + Text = "Сотрудник"; + ((System.ComponentModel.ISupportInitialize)numericUpDownNumStorage).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private DateTimePicker dateTimePickerDate; + private Label label1; + private Label label2; + private Label label3; + private NumericUpDown numericUpDownNumStorage; + private NumericUpDown numericUpDownStorageSize; + private Button buttonSave; + private Button buttonCancel; + } +} \ No newline at end of file diff --git a/ShoeStore/Forms/FormEmployee.cs b/ShoeStore/Forms/FormEmployee.cs new file mode 100644 index 0000000..53a956e --- /dev/null +++ b/ShoeStore/Forms/FormEmployee.cs @@ -0,0 +1,73 @@ +using ShoeStore.Entities; +using ShoeStore.Repositories; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ShoeStore.Froms; + +public partial class FormEmployee : Form +{ + private readonly IEmployeeRepository _employeeRepository; + private int? _employeeId; + + public int Id + { + set + { + try + { + var employee = _employeeRepository.ReadEmployeeById(value); + if (employee == null) + { + throw new InvalidDataException(nameof(employee)); + } + numericUpDownNumStorage.Value = employee.NumberStorage; + numericUpDownStorageSize.Value = (decimal)employee.StorageSize; + _employeeId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormEmployee() + { + InitializeComponent(); + } + + private void ButtonSave_Click_1(object sender, EventArgs e) + { + try + { + if (_employeeId.HasValue) + { + _employeeRepository.UpdateEmployee(CreateEmployee(_employeeId.Value)); + } + else + { + _employeeRepository.CreateEmployee(CreateEmployee(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click_1(object sender, EventArgs e) => Close(); + + private Employee CreateEmployee(int id) => Employee.CreateEntity(id, Convert.ToInt32(numericUpDownNumStorage.Value), + Convert.ToInt32(numericUpDownStorageSize.Value)); +} diff --git a/ShoeStore/Forms/FormEmployee.resx b/ShoeStore/Forms/FormEmployee.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ShoeStore/Forms/FormEmployee.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ShoeStore/Forms/FormEmployees.Designer.cs b/ShoeStore/Forms/FormEmployees.Designer.cs new file mode 100644 index 0000000..2b47217 --- /dev/null +++ b/ShoeStore/Forms/FormEmployees.Designer.cs @@ -0,0 +1,121 @@ +namespace ShoeStore.Froms +{ + partial class FormEmployees + { + /// + /// 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() + { + dataGridViewData = new DataGridView(); + panel1 = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.Size = new Size(800, 450); + dataGridViewData.TabIndex = 0; + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(676, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(124, 450); + panel1.TabIndex = 1; + // + // buttonDel + // + buttonDel.BackColor = SystemColors.ControlLightLight; + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(14, 233); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(98, 86); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = false; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackColor = SystemColors.ControlLightLight; + buttonUpd.BackgroundImage = Properties.Resources.карандащ; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(14, 132); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(98, 86); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = false; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(14, 31); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 86); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormEmployees + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(dataGridViewData); + Name = "FormEmployees"; + Text = "FormEmployees"; + Load += FormEmployees_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel1; + private Button buttonAdd; + private Button buttonDel; + private Button buttonUpd; + } +} \ No newline at end of file diff --git a/ShoeStore/Forms/FormEmployees.cs b/ShoeStore/Forms/FormEmployees.cs new file mode 100644 index 0000000..a5aed2d --- /dev/null +++ b/ShoeStore/Forms/FormEmployees.cs @@ -0,0 +1,103 @@ +using ShoeStore.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 ShoeStore.Froms; + +public partial class FormEmployees : Form +{ + private readonly IUnityContainer _container; + private readonly IEmployeeRepository _employeeRepository; + public FormEmployees(IUnityContainer container, IEmployeeRepository employeeRepository) + { + InitializeComponent(); + _container = container; + _employeeRepository = employeeRepository; + } + + private void FormEmployees_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 ButtonUpd_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); + } + } + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _employeeRepository.DeleteEmployee(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewData.DataSource = _employeeRepository.ReadEmployees(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } +} diff --git a/ShoeStore/Forms/FormEmployees.resx b/ShoeStore/Forms/FormEmployees.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ShoeStore/Forms/FormEmployees.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ShoeStore/Forms/FormProduct.Designer.cs b/ShoeStore/Forms/FormProduct.Designer.cs new file mode 100644 index 0000000..47296d8 --- /dev/null +++ b/ShoeStore/Forms/FormProduct.Designer.cs @@ -0,0 +1,235 @@ +namespace ShoeStore.Forms +{ + partial class FormProduct + { + /// + /// 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(); + comboBoxProduct = new ComboBox(); + comboBoxStorageProductId = new ComboBox(); + label5 = new Label(); + numericUpDownPrice = new NumericUpDown(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + comboBoxType = new ComboBox(); + label6 = new Label(); + label7 = new Label(); + buttonCancel = new Button(); + buttonSave = new Button(); + checkedListBoxManufactoringCompany = new CheckedListBox(); + textBoxNameShoe = new TextBox(); + numericUpDownStorage = new NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownStorage).BeginInit(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(24, 38); + label1.Name = "label1"; + label1.Size = new Size(76, 15); + label1.TabIndex = 10; + label1.Text = "ID Продукта:"; + // + // comboBoxProduct + // + comboBoxProduct.FormattingEnabled = true; + comboBoxProduct.Location = new Point(244, 38); + comboBoxProduct.Name = "comboBoxProduct"; + comboBoxProduct.Size = new Size(121, 23); + comboBoxProduct.TabIndex = 9; + // + // comboBoxStorageProductId + // + comboBoxStorageProductId.FormattingEnabled = true; + comboBoxStorageProductId.Location = new Point(244, 84); + comboBoxStorageProductId.Name = "comboBoxStorageProductId"; + comboBoxStorageProductId.Size = new Size(121, 23); + comboBoxStorageProductId.TabIndex = 16; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(24, 84); + label5.Name = "label5"; + label5.Size = new Size(132, 15); + label5.TabIndex = 15; + label5.Text = "ID Продуктa на складе:"; + // + // numericUpDownPrice + // + numericUpDownPrice.Location = new Point(241, 297); + numericUpDownPrice.Name = "numericUpDownPrice"; + numericUpDownPrice.Size = new Size(120, 23); + numericUpDownPrice.TabIndex = 18; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(24, 132); + label2.Name = "label2"; + label2.Size = new Size(98, 15); + label2.TabIndex = 20; + label2.Text = "Название обуви:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(24, 182); + label3.Name = "label3"; + label3.Size = new Size(154, 15); + label3.TabIndex = 21; + label3.Text = "Компания-производитель:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(20, 297); + label4.Name = "label4"; + label4.Size = new Size(38, 15); + label4.TabIndex = 22; + label4.Text = "Цена:"; + // + // comboBoxType + // + comboBoxType.FormattingEnabled = true; + comboBoxType.Location = new Point(240, 347); + comboBoxType.Name = "comboBox1"; + comboBoxType.Size = new Size(121, 23); + comboBoxType.TabIndex = 23; + // + // label6 + // + label6.AutoSize = true; + label6.Location = new Point(20, 355); + label6.Name = "label6"; + label6.Size = new Size(83, 15); + label6.TabIndex = 25; + label6.Text = "Тип продукта:"; + // + // label7 + // + label7.AutoSize = true; + label7.Location = new Point(20, 403); + label7.Name = "label7"; + label7.Size = new Size(106, 15); + label7.TabIndex = 26; + label7.Text = "Размер на складе:"; + // + // buttonCancel + // + buttonCancel.Location = new Point(245, 464); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(102, 23); + buttonCancel.TabIndex = 28; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(45, 464); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(100, 23); + buttonSave.TabIndex = 27; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // checkedListBoxManufactoringCompany + // + checkedListBoxManufactoringCompany.FormattingEnabled = true; + checkedListBoxManufactoringCompany.Location = new Point(240, 182); + checkedListBoxManufactoringCompany.Name = "checkedListBoxManufactoringCompany"; + checkedListBoxManufactoringCompany.Size = new Size(120, 94); + checkedListBoxManufactoringCompany.TabIndex = 29; + // + // textBoxNameShoe + // + textBoxNameShoe.Location = new Point(128, 132); + textBoxNameShoe.Name = "textBoxNameShoe"; + textBoxNameShoe.Size = new Size(237, 23); + textBoxNameShoe.TabIndex = 31; + // + // numericUpDownStorage + // + numericUpDownStorage.Location = new Point(240, 401); + numericUpDownStorage.Name = "numericUpDownStorage"; + numericUpDownStorage.Size = new Size(120, 23); + numericUpDownStorage.TabIndex = 32; + // + // FormProduct + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(403, 545); + Controls.Add(numericUpDownStorage); + Controls.Add(textBoxNameShoe); + Controls.Add(checkedListBoxManufactoringCompany); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(label7); + Controls.Add(label6); + Controls.Add(comboBoxType); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(numericUpDownPrice); + Controls.Add(comboBoxStorageProductId); + Controls.Add(label5); + Controls.Add(label1); + Controls.Add(comboBoxProduct); + Name = "FormProduct"; + Text = "FormProduct"; + ((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownStorage).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private ComboBox comboBoxProduct; + private ComboBox comboBoxStorageProductId; + private Label label5; + private NumericUpDown numericUpDownPrice; + private Label label2; + private Label label3; + private Label label4; + private ComboBox comboBoxType; + private Label label6; + private Label label7; + private Button buttonCancel; + private Button buttonSave; + private CheckedListBox checkedListBoxManufactoringCompany; + private TextBox textBoxNameShoe; + private NumericUpDown numericUpDownStorage; + } +} \ No newline at end of file diff --git a/ShoeStore/Forms/FormProduct.cs b/ShoeStore/Forms/FormProduct.cs new file mode 100644 index 0000000..023a462 --- /dev/null +++ b/ShoeStore/Forms/FormProduct.cs @@ -0,0 +1,104 @@ +using Microsoft.VisualBasic.FileIO; +using ShoeStore.Entities; +using ShoeStore.Entities.Enums; +using ShoeStore.Repositories; +using ShoeStore.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Diagnostics.Eventing.Reader; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace ShoeStore.Forms +{ + public partial class FormProduct : Form + { + private readonly IProductRepository _productRepository; + + private int? _productId; + public int Id + { + set + { + try + { + var product = _productRepository.ReadProductById(value); + + if (product == null) + { + throw new InvalidDataException(nameof(product)); + } + + foreach (ManufacturingCompany company in Enum.GetValues(typeof(ManufacturingCompany))) + { + if ((company & product.ManufacturingCompany) != 0) + { + checkedListBoxManufactoringCompany.SetItemChecked( + checkedListBoxManufactoringCompany.Items.IndexOf(company), true); + } + } + + textBoxNameShoe.Text = product.NameOfShoes; + numericUpDownPrice.Value = product.Price; + comboBoxStorageProductId.SelectedItem = product.StorageProductId; + comboBoxType.SelectedItem = product.ProductType; + numericUpDownStorage.Value = product.StorageSize; + + _productId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + public FormProduct(IProductRepository productRepository) + { + InitializeComponent(); + _productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository)); + comboBoxType.DataSource = Enum.GetValues(typeof(ProductType)); + foreach (var elem in Enum.GetValues(typeof(ManufacturingCompany))) + { + checkedListBoxManufactoringCompany.Items.Add(elem); + } + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxProduct.SelectedIndex < 0 || comboBoxStorageProductId.SelectedIndex < 0 || checkedListBoxManufactoringCompany.CheckedItems.Count == 0) + { + throw new Exception("Имеются незаполненные поля"); + } + _productRepository.CreateProduct(CreateProduct(0)); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + Product CreateProduct(int id) + { + ManufacturingCompany manufacturingCompany = ManufacturingCompany.None; + foreach (var elem in checkedListBoxManufactoringCompany.CheckedItems) + { + manufacturingCompany |= (ManufacturingCompany)elem; + } + return Product.CreateEntity(id, (int)comboBoxStorageProductId.SelectedValue!, + textBoxNameShoe.Text, manufacturingCompany, Convert.ToInt32(numericUpDownPrice.Value), (ProductType)comboBoxType.SelectedItem!, (int)numericUpDownStorage.Value!); + } + } +} diff --git a/ShoeStore/Forms/FormProduct.resx b/ShoeStore/Forms/FormProduct.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ShoeStore/Forms/FormProduct.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ShoeStore/Forms/FormProducts.Designer.cs b/ShoeStore/Forms/FormProducts.Designer.cs new file mode 100644 index 0000000..5f1d910 --- /dev/null +++ b/ShoeStore/Forms/FormProducts.Designer.cs @@ -0,0 +1,117 @@ +namespace ShoeStore.Forms +{ + partial class FormProducts + { + /// + /// 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() + { + dataGridViewProduct = new DataGridView(); + panel1 = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewProduct + // + dataGridViewProduct.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewProduct.Dock = DockStyle.Fill; + dataGridViewProduct.Location = new Point(0, 0); + dataGridViewProduct.Name = "dataGridViewProduct"; + dataGridViewProduct.Size = new Size(787, 450); + dataGridViewProduct.TabIndex = 0; + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(611, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(176, 450); + panel1.TabIndex = 1; + // + // buttonDel + // + buttonDel.BackColor = SystemColors.ControlLightLight; + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(42, 251); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(98, 86); + buttonDel.TabIndex = 5; + buttonDel.UseVisualStyleBackColor = false; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.BackColor = SystemColors.ControlLightLight; + buttonUpd.BackgroundImage = Properties.Resources.карандащ; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(42, 150); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(98, 86); + buttonUpd.TabIndex = 4; + buttonUpd.UseVisualStyleBackColor = false; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.плюс1; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(42, 49); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 86); + buttonAdd.TabIndex = 3; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // FormProducts + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(787, 450); + Controls.Add(panel1); + Controls.Add(dataGridViewProduct); + Name = "FormProducts"; + Text = "FormProducts"; + ((System.ComponentModel.ISupportInitialize)dataGridViewProduct).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewProduct; + private Panel panel1; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ShoeStore/Forms/FormProducts.cs b/ShoeStore/Forms/FormProducts.cs new file mode 100644 index 0000000..ea2f38b --- /dev/null +++ b/ShoeStore/Forms/FormProducts.cs @@ -0,0 +1,110 @@ +using ShoeStore.Froms; +using ShoeStore.Repositories; +using ShoeStore.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Linq; +using Unity; + +namespace ShoeStore.Forms +{ + public partial class FormProducts : Form + { + private readonly IUnityContainer _container; + private readonly IProductRepository _productRepository; + public FormProducts(IUnityContainer container, IProductRepository productRepository) + { + InitializeComponent(); + _container = container; + _productRepository = productRepository; + } + + private void FormEmployees_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 buttonUpd_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); + } + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _productRepository.DeleteProduct(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewProduct.DataSource = _productRepository.ReadProducts(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewProduct.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridViewProduct.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ShoeStore/Forms/FormProducts.resx b/ShoeStore/Forms/FormProducts.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ShoeStore/Forms/FormProducts.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ShoeStore/Forms/FormReceipt.Designer.cs b/ShoeStore/Forms/FormReceipt.Designer.cs new file mode 100644 index 0000000..fc0305c --- /dev/null +++ b/ShoeStore/Forms/FormReceipt.Designer.cs @@ -0,0 +1,191 @@ +namespace ShoeStore.Froms +{ + partial class FormReceipt + { + /// + /// 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() + { + comboBoxProduct = new ComboBox(); + label1 = new Label(); + label2 = new Label(); + label3 = new Label(); + label4 = new Label(); + numericUpDownStorageNumber = new NumericUpDown(); + label5 = new Label(); + comboBoxStorageProductId = new ComboBox(); + numericUpDownStorageSize = new NumericUpDown(); + numericUpDownNumOfPairs = new NumericUpDown(); + buttonCancel = new Button(); + buttonSave = new Button(); + ((System.ComponentModel.ISupportInitialize)numericUpDownStorageNumber).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownNumOfPairs).BeginInit(); + SuspendLayout(); + // + // comboBoxProduct + // + comboBoxProduct.FormattingEnabled = true; + comboBoxProduct.Location = new Point(232, 33); + comboBoxProduct.Name = "comboBoxProduct"; + comboBoxProduct.Size = new Size(121, 23); + comboBoxProduct.TabIndex = 7; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(12, 36); + label1.Name = "label1"; + label1.Size = new Size(56, 15); + label1.TabIndex = 8; + label1.Text = "Продукт:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(12, 135); + label2.Name = "label2"; + label2.Size = new Size(122, 15); + label2.TabIndex = 9; + label2.Text = "Номер поступления:"; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(12, 182); + label3.Name = "label3"; + label3.Size = new Size(169, 15); + label3.TabIndex = 10; + label3.Text = "Колиество поступивших пар:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(12, 237); + label4.Name = "label4"; + label4.Size = new Size(106, 15); + label4.TabIndex = 11; + label4.Text = "Размер на складе:"; + // + // numericUpDownStorageNumber + // + numericUpDownStorageNumber.Location = new Point(232, 135); + numericUpDownStorageNumber.Name = "numericUpDownStorageNumber"; + numericUpDownStorageNumber.Size = new Size(120, 23); + numericUpDownStorageNumber.TabIndex = 12; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(12, 80); + label5.Name = "label5"; + label5.Size = new Size(112, 15); + label5.TabIndex = 13; + label5.Text = "Продукт на складе:"; + // + // comboBoxStorageProductId + // + comboBoxStorageProductId.FormattingEnabled = true; + comboBoxStorageProductId.Location = new Point(232, 80); + comboBoxStorageProductId.Name = "comboBoxStorageProductId"; + comboBoxStorageProductId.Size = new Size(121, 23); + comboBoxStorageProductId.TabIndex = 14; + // + // numericUpDownStorageSize + // + numericUpDownStorageSize.Location = new Point(232, 237); + numericUpDownStorageSize.Name = "numericUpDownStorageSize"; + numericUpDownStorageSize.Size = new Size(120, 23); + numericUpDownStorageSize.TabIndex = 15; + // + // numericUpDownNumOfPairs + // + numericUpDownNumOfPairs.Location = new Point(232, 182); + numericUpDownNumOfPairs.Name = "numericUpDownNumOfPairs"; + numericUpDownNumOfPairs.Size = new Size(120, 23); + numericUpDownNumOfPairs.TabIndex = 16; + // + // buttonCancel + // + buttonCancel.Location = new Point(244, 301); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(102, 23); + buttonCancel.TabIndex = 18; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(44, 301); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(100, 23); + buttonSave.TabIndex = 17; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // FormReceipt + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(398, 525); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(numericUpDownNumOfPairs); + Controls.Add(numericUpDownStorageSize); + Controls.Add(comboBoxStorageProductId); + Controls.Add(label5); + Controls.Add(numericUpDownStorageNumber); + Controls.Add(label4); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Controls.Add(comboBoxProduct); + Name = "FormReceipt"; + Text = "FormReceipt"; + ((System.ComponentModel.ISupportInitialize)numericUpDownStorageNumber).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownNumOfPairs).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxProduct; + private Label label1; + private Label label2; + private Label label3; + private Label label4; + private NumericUpDown numericUpDownStorageNumber; + private Label label5; + private ComboBox comboBoxStorageProductId; + private NumericUpDown numericUpDownStorageSize; + private NumericUpDown numericUpDownNumOfPairs; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/ShoeStore/Forms/FormReceipt.cs b/ShoeStore/Forms/FormReceipt.cs new file mode 100644 index 0000000..ac17d34 --- /dev/null +++ b/ShoeStore/Forms/FormReceipt.cs @@ -0,0 +1,53 @@ +using ShoeStore.Entities; +using ShoeStore.Repositories; +using ShoeStore.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ShoeStore.Froms +{ + public partial class FormReceipt : Form + { + private readonly IReceiptRepository _receiptRepository; + //private int? _receiptId; + + + public FormReceipt() + { + InitializeComponent(); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxProduct.SelectedIndex < 0 || + comboBoxStorageProductId.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + _receiptRepository.CreateReceipt(Receipt.CreateOperation( + 0, (int)comboBoxProduct.SelectedValue!, + (int)comboBoxStorageProductId.SelectedValue!, + Convert.ToInt32(numericUpDownStorageNumber.Value), Convert.ToInt32(numericUpDownStorageSize.Value), + Convert.ToInt32(numericUpDownNumOfPairs.Value))); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => +Close(); + } +} diff --git a/ShoeStore/Forms/FormReceipt.resx b/ShoeStore/Forms/FormReceipt.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ShoeStore/Forms/FormReceipt.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ShoeStore/Forms/FormReceipts.Designer.cs b/ShoeStore/Forms/FormReceipts.Designer.cs new file mode 100644 index 0000000..e202ec0 --- /dev/null +++ b/ShoeStore/Forms/FormReceipts.Designer.cs @@ -0,0 +1,90 @@ +namespace ShoeStore.Froms +{ + partial class FormReceipts + { + /// + /// 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() + { + dataGridView1 = new DataGridView(); + panel1 = new Panel(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridView1 + // + dataGridView1.AllowUserToAddRows = false; + dataGridView1.AllowUserToDeleteRows = false; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Dock = DockStyle.Fill; + dataGridView1.Location = new Point(0, 0); + dataGridView1.Name = "dataGridView1"; + dataGridView1.ReadOnly = true; + dataGridView1.Size = new Size(800, 450); + dataGridView1.TabIndex = 0; + // + // panel1 + // + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(644, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(156, 450); + panel1.TabIndex = 1; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(34, 24); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 86); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormReceipts + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(dataGridView1); + Name = "FormReceipts"; + Text = "FormReceipts"; + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView1; + private Panel panel1; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ShoeStore/Forms/FormReceipts.cs b/ShoeStore/Forms/FormReceipts.cs new file mode 100644 index 0000000..4d002b8 --- /dev/null +++ b/ShoeStore/Forms/FormReceipts.cs @@ -0,0 +1,42 @@ +using ShoeStore.Repositories; +using ShoeStore.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Linq; +using Unity; + +namespace ShoeStore.Froms; +public partial class FormReceipts : Form +{ + private readonly IUnityContainer _container; + private readonly IReceiptRepository _receiptRepository; + public FormReceipts(IUnityContainer container, IReceiptRepository receiptRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + _receiptRepository = receiptRepository; + } + + 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() => dataGridView1.DataSource = _receiptRepository.ReadReceipts(); +} diff --git a/ShoeStore/Forms/FormReceipts.resx b/ShoeStore/Forms/FormReceipts.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ShoeStore/Forms/FormReceipts.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ShoeStore/Forms/FormSale.Designer.cs b/ShoeStore/Forms/FormSale.Designer.cs new file mode 100644 index 0000000..d36c18f --- /dev/null +++ b/ShoeStore/Forms/FormSale.Designer.cs @@ -0,0 +1,193 @@ +namespace ShoeStore.Froms +{ + partial class FormSale + { + /// + /// 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(); + label4 = new Label(); + label5 = new Label(); + comboBoxProduct = new ComboBox(); + comboBoxStorageProductId = new ComboBox(); + numericUpDownStorageNumber = new NumericUpDown(); + numericUpDownStorageSize = new NumericUpDown(); + buttonSave = new Button(); + buttonCancel = new Button(); + dataGridView1 = new DataGridView(); + panel1 = new Panel(); + ((System.ComponentModel.ISupportInitialize)numericUpDownStorageNumber).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(38, 37); + label1.Name = "label1"; + label1.Size = new Size(56, 15); + label1.TabIndex = 0; + label1.Text = "Продукт:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(38, 75); + label2.Name = "label2"; + label2.Size = new Size(112, 15); + label2.TabIndex = 1; + label2.Text = "Продукт на складе:"; + // + // label4 + // + label4.AutoSize = true; + label4.Location = new Point(38, 128); + label4.Name = "label4"; + label4.Size = new Size(100, 15); + label4.TabIndex = 3; + label4.Text = "Номер продажи:"; + // + // label5 + // + label5.AutoSize = true; + label5.Location = new Point(38, 173); + label5.Name = "label5"; + label5.Size = new Size(106, 15); + label5.TabIndex = 4; + label5.Text = "Размер на складе:"; + // + // comboBoxProduct + // + comboBoxProduct.FormattingEnabled = true; + comboBoxProduct.Location = new Point(206, 34); + comboBoxProduct.Name = "comboBoxProduct"; + comboBoxProduct.Size = new Size(121, 23); + comboBoxProduct.TabIndex = 6; + // + // comboBoxStorageProductId + // + comboBoxStorageProductId.FormattingEnabled = true; + comboBoxStorageProductId.Location = new Point(206, 75); + comboBoxStorageProductId.Name = "comboBoxStorageProductId"; + comboBoxStorageProductId.Size = new Size(121, 23); + comboBoxStorageProductId.TabIndex = 7; + // + // numericUpDownStorageNumber + // + numericUpDownStorageNumber.Location = new Point(207, 126); + numericUpDownStorageNumber.Name = "numericUpDownStorageNumber"; + numericUpDownStorageNumber.Size = new Size(120, 23); + numericUpDownStorageNumber.TabIndex = 9; + // + // numericUpDownStorageSize + // + numericUpDownStorageSize.Location = new Point(207, 171); + numericUpDownStorageSize.Name = "numericUpDownStorageSize"; + numericUpDownStorageSize.Size = new Size(120, 23); + numericUpDownStorageSize.TabIndex = 10; + // + // buttonSave + // + buttonSave.Location = new Point(25, 455); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(100, 23); + buttonSave.TabIndex = 11; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click_1; + // + // buttonCancel + // + buttonCancel.Location = new Point(225, 455); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(102, 23); + buttonCancel.TabIndex = 12; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click_1; + // + // dataGridView1 + // + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Dock = DockStyle.Fill; + dataGridView1.Location = new Point(0, 0); + dataGridView1.Name = "dataGridView1"; + dataGridView1.Size = new Size(289, 249); + dataGridView1.TabIndex = 13; + // + // panel1 + // + panel1.Controls.Add(dataGridView1); + panel1.Location = new Point(38, 200); + panel1.Name = "panel1"; + panel1.Size = new Size(289, 249); + panel1.TabIndex = 14; + // + // FormSale + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(377, 497); + Controls.Add(panel1); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(numericUpDownStorageSize); + Controls.Add(numericUpDownStorageNumber); + Controls.Add(comboBoxStorageProductId); + Controls.Add(comboBoxProduct); + Controls.Add(label5); + Controls.Add(label4); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormSale"; + Text = "FormSale"; + ((System.ComponentModel.ISupportInitialize)numericUpDownStorageNumber).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).EndInit(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label label1; + private Label label2; + private Label label4; + private Label label5; + private ComboBox comboBoxProduct; + private ComboBox comboBoxStorageProductId; + private NumericUpDown numericUpDownStorageNumber; + private NumericUpDown numericUpDownStorageSize; + private Button buttonSave; + private Button buttonCancel; + private DataGridView dataGridView1; + private Panel panel1; + } +} \ No newline at end of file diff --git a/ShoeStore/Forms/FormSale.cs b/ShoeStore/Forms/FormSale.cs new file mode 100644 index 0000000..01f732f --- /dev/null +++ b/ShoeStore/Forms/FormSale.cs @@ -0,0 +1,58 @@ +using ShoeStore.Entities; +using ShoeStore.Repositories; +using ShoeStore.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ShoeStore.Froms; + +public partial class FormSale : Form +{ + ISaleRepository _saleRepository; + + public FormSale(ISaleRepository saleRepository, IProductRepository productRepository) + { + InitializeComponent(); + _saleRepository = saleRepository ?? throw new ArgumentNullException(nameof(saleRepository)); + + comboBoxProduct.DataSource = productRepository.ReadProducts(); + comboBoxProduct.DisplayMember = "NameOfShoes"; + comboBoxProduct.ValueMember = "Id"; + + //? + } + + private void ButtonSave_Click_1(object sender, EventArgs e) + { + try + { + if (comboBoxProduct.SelectedIndex < 0 || + comboBoxStorageProductId.SelectedIndex < 0 || + comboBoxProduct.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + _saleRepository.CreateSale(Sale.CreateOperation( + 0, + (int)comboBoxProduct.SelectedValue!, + (int)comboBoxProduct.SelectedValue!, + Convert.ToInt32(numericUpDownStorageNumber.Value), Convert.ToInt32(numericUpDownStorageSize.Value))); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click_1(object sender, EventArgs e) => +Close(); +} \ No newline at end of file diff --git a/ShoeStore/Forms/FormSale.resx b/ShoeStore/Forms/FormSale.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ShoeStore/Forms/FormSale.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ShoeStore/Forms/FormSales.Designer.cs b/ShoeStore/Forms/FormSales.Designer.cs new file mode 100644 index 0000000..a378be9 --- /dev/null +++ b/ShoeStore/Forms/FormSales.Designer.cs @@ -0,0 +1,106 @@ +namespace ShoeStore.Froms +{ + partial class FormSales + { + /// + /// 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() + { + dataGridView1 = new DataGridView(); + panel1 = new Panel(); + buttonDel = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + panel1.SuspendLayout(); + SuspendLayout(); + // + // dataGridView1 + // + dataGridView1.AllowUserToAddRows = false; + dataGridView1.AllowUserToDeleteRows = false; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Dock = DockStyle.Fill; + dataGridView1.Location = new Point(0, 0); + dataGridView1.Name = "dataGridView1"; + dataGridView1.ReadOnly = true; + dataGridView1.Size = new Size(800, 450); + dataGridView1.TabIndex = 0; + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(649, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(151, 450); + panel1.TabIndex = 1; + // + // buttonDel + // + buttonDel.BackColor = SystemColors.ControlLightLight; + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(28, 156); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(98, 86); + buttonDel.TabIndex = 3; + buttonDel.UseVisualStyleBackColor = false; + buttonDel.Click += buttonDel_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(28, 30); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 86); + buttonAdd.TabIndex = 1; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormSales + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(panel1); + Controls.Add(dataGridView1); + Name = "FormSales"; + Text = "FormSales"; + Load += FormSales_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + panel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView1; + private Panel panel1; + private Button buttonAdd; + private Button buttonDel; + } +} \ No newline at end of file diff --git a/ShoeStore/Forms/FormSales.cs b/ShoeStore/Forms/FormSales.cs new file mode 100644 index 0000000..79f4477 --- /dev/null +++ b/ShoeStore/Forms/FormSales.cs @@ -0,0 +1,90 @@ +using ShoeStore.Repositories; +using ShoeStore.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using Unity; + +namespace ShoeStore.Froms +{ + public partial class FormSales : Form + { + private readonly IUnityContainer _container; + private readonly ISaleRepository _saleRepository; + + public FormSales(IUnityContainer container, ISaleRepository saleRepository) + { + InitializeComponent(); + _container = container; + _saleRepository = saleRepository; + } + + private void FormSales_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + public 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() => dataGridView1.DataSource = _saleRepository.ReadSales(); + + private void buttonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _saleRepository.DeleteSale(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridView1.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ShoeStore/Forms/FormSales.resx b/ShoeStore/Forms/FormSales.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ShoeStore/Forms/FormSales.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ShoeStore/Forms/FormStorage.Designer.cs b/ShoeStore/Forms/FormStorage.Designer.cs new file mode 100644 index 0000000..e92953a --- /dev/null +++ b/ShoeStore/Forms/FormStorage.Designer.cs @@ -0,0 +1,145 @@ +namespace ShoeStore.Forms +{ + partial class FormStorage + { + /// + /// 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() + { + buttonCancel = new Button(); + buttonSave = new Button(); + numericUpDownNumStorage = new NumericUpDown(); + label3 = new Label(); + label2 = new Label(); + label1 = new Label(); + numericUpDownSize = new NumericUpDown(); + comboBoxNalStorage = new ComboBox(); + ((System.ComponentModel.ISupportInitialize)numericUpDownNumStorage).BeginInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSize).BeginInit(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.Location = new Point(209, 252); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(106, 23); + buttonCancel.TabIndex = 15; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(44, 252); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(106, 23); + buttonSave.TabIndex = 14; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // + // numericUpDownNumStorage + // + numericUpDownNumStorage.Location = new Point(183, 108); + numericUpDownNumStorage.Name = "numericUpDownNumStorage"; + numericUpDownNumStorage.Size = new Size(132, 23); + numericUpDownNumStorage.TabIndex = 12; + // + // label3 + // + label3.AutoSize = true; + label3.Location = new Point(44, 179); + label3.Name = "label3"; + label3.Size = new Size(108, 15); + label3.TabIndex = 11; + label3.Text = "Налиие на складе:"; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(44, 116); + label2.Name = "label2"; + label2.Size = new Size(88, 15); + label2.TabIndex = 10; + label2.Text = "Номер склада:"; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(44, 48); + label1.Name = "label1"; + label1.Size = new Size(50, 15); + label1.TabIndex = 9; + label1.Text = "Размер:"; + // + // numericUpDownSize + // + numericUpDownSize.Location = new Point(183, 48); + numericUpDownSize.Name = "numericUpDownSize"; + numericUpDownSize.Size = new Size(132, 23); + numericUpDownSize.TabIndex = 16; + // + // comboBoxNalStorage + // + comboBoxNalStorage.FormattingEnabled = true; + comboBoxNalStorage.Location = new Point(183, 176); + comboBoxNalStorage.Name = "comboBoxNalStorage"; + comboBoxNalStorage.Size = new Size(121, 23); + comboBoxNalStorage.TabIndex = 17; + // + // FormStorage + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(355, 421); + Controls.Add(comboBoxNalStorage); + Controls.Add(numericUpDownSize); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(numericUpDownNumStorage); + Controls.Add(label3); + Controls.Add(label2); + Controls.Add(label1); + Name = "FormStorage"; + Text = "FormStorage"; + ((System.ComponentModel.ISupportInitialize)numericUpDownNumStorage).EndInit(); + ((System.ComponentModel.ISupportInitialize)numericUpDownSize).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private NumericUpDown numericUpDownStorageSize; + private NumericUpDown numericUpDownNumStorage; + private Label label3; + private Label label2; + private Label label1; + private NumericUpDown numericUpDownSize; + private ComboBox comboBoxNalStorage; + } +} \ No newline at end of file diff --git a/ShoeStore/Forms/FormStorage.cs b/ShoeStore/Forms/FormStorage.cs new file mode 100644 index 0000000..112e552 --- /dev/null +++ b/ShoeStore/Forms/FormStorage.cs @@ -0,0 +1,89 @@ +using ShoeStore.Entities; +using ShoeStore.Entities.Enums; +using ShoeStore.Repositories; +using ShoeStore.Repositories.Implementations; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ShoeStore.Forms +{ + public partial class FormStorage : Form + { + private readonly IStorageRepository _storageRepository; + + private int? _productId; + public int Id + { + set + { + try + { + var storage = _storageRepository.ReadStorageById(value); + + if (storage == null) + { + throw new InvalidDataException(nameof(storage)); + } + + /*foreach (ManufacturingCompany company in Enum.GetValues(typeof(ManufacturingCompany))) + { + if ((company & storage.ManufacturingCompany) != 0) + { + checkedListBoxManufactoringCompany.SetItemChecked( + checkedListBoxManufactoringCompany.Items.IndexOf(company), true); + } + }*/ + + numericUpDownSize.Value = storage.Size; + comboBoxNalStorage.SelectedItem = storage.QuantityInStock; + numericUpDownNumStorage.Value = storage.NumberStorage; + + _productId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormStorage() + { + InitializeComponent(); + } + + private void buttonSave_Click(object sender, EventArgs e) + { + try + { + if ( + comboBoxNalStorage.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + _storageRepository.CreateStorage(Storage.CreateEntity( + (int)comboBoxNalStorage.SelectedValue!, + + Convert.ToInt32(numericUpDownSize.Value), + Convert.ToInt32(numericUpDownNumStorage.Value))); + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCancel_Click(object sender, EventArgs e) => Close(); + + } +} diff --git a/ShoeStore/Forms/FormStorage.resx b/ShoeStore/Forms/FormStorage.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ShoeStore/Forms/FormStorage.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ShoeStore/Forms/FormStorages.Designer.cs b/ShoeStore/Forms/FormStorages.Designer.cs new file mode 100644 index 0000000..e4f7754 --- /dev/null +++ b/ShoeStore/Forms/FormStorages.Designer.cs @@ -0,0 +1,117 @@ +namespace ShoeStore.Forms +{ + partial class FormStorages + { + /// + /// 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(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + dataGridViewStorages = new DataGridView(); + panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewStorages).BeginInit(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(buttonDel); + panel1.Controls.Add(buttonUpd); + panel1.Controls.Add(buttonAdd); + panel1.Dock = DockStyle.Right; + panel1.Location = new Point(600, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(200, 450); + panel1.TabIndex = 0; + // + // buttonDel + // + buttonDel.BackColor = SystemColors.ControlLightLight; + buttonDel.BackgroundImage = Properties.Resources.минус; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(48, 256); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(98, 86); + buttonDel.TabIndex = 8; + buttonDel.UseVisualStyleBackColor = false; + buttonDel.Click += buttonDel_Click; + // + // buttonUpd + // + buttonUpd.BackColor = SystemColors.ControlLightLight; + buttonUpd.BackgroundImage = Properties.Resources.карандащ; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(48, 155); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(98, 86); + buttonUpd.TabIndex = 7; + buttonUpd.UseVisualStyleBackColor = false; + buttonUpd.Click += buttonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.плюс; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(48, 54); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 86); + buttonAdd.TabIndex = 6; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; + // + // dataGridViewStorages + // + dataGridViewStorages.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewStorages.Dock = DockStyle.Fill; + dataGridViewStorages.Location = new Point(0, 0); + dataGridViewStorages.Name = "dataGridViewStorages"; + dataGridViewStorages.Size = new Size(600, 450); + dataGridViewStorages.TabIndex = 1; + // + // FormStorages + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 450); + Controls.Add(dataGridViewStorages); + Controls.Add(panel1); + Name = "FormStorages"; + Text = "FormStorages"; + panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewStorages).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Panel panel1; + private DataGridView dataGridViewStorages; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ShoeStore/Forms/FormStorages.cs b/ShoeStore/Forms/FormStorages.cs new file mode 100644 index 0000000..5851267 --- /dev/null +++ b/ShoeStore/Forms/FormStorages.cs @@ -0,0 +1,99 @@ +using ShoeStore.Repositories; +using Unity; + +namespace ShoeStore.Forms +{ + public partial class FormStorages : Form + { + private readonly IUnityContainer _container; + private readonly IStorageRepository _storageRepository; + + public FormStorages(IUnityContainer container, IStorageRepository storageRepository) + { + InitializeComponent(); + _container = container; + _storageRepository = storageRepository; + } + + private void FormEmployees_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 buttonUpd_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); + } + } + + private void buttonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _storageRepository.DeleteStorage(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewStorages.DataSource = _storageRepository.ReadStorages(); + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewStorages.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridViewStorages.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ShoeStore/Forms/FormStorages.resx b/ShoeStore/Forms/FormStorages.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ShoeStore/Forms/FormStorages.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ShoeStore/Program.cs b/ShoeStore/Program.cs index 408d118..1ce295a 100644 --- a/ShoeStore/Program.cs +++ b/ShoeStore/Program.cs @@ -1,3 +1,8 @@ +using ShoeStore.Repositories.Implementations; +using ShoeStore.Repositories; +using Unity.Lifetime; +using Unity; + namespace ShoeStore { internal static class Program @@ -11,7 +16,18 @@ namespace ShoeStore // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + container.RegisterType(new TransientLifetimeManager()); + return container; } } } \ No newline at end of file diff --git a/ShoeStore/Properties/Resources.Designer.cs b/ShoeStore/Properties/Resources.Designer.cs new file mode 100644 index 0000000..9f1dd31 --- /dev/null +++ b/ShoeStore/Properties/Resources.Designer.cs @@ -0,0 +1,113 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ShoeStore.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("ShoeStore.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 минус { + get { + object obj = ResourceManager.GetObject("минус", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа 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 плюс { + get { + object obj = ResourceManager.GetObject("плюс", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap плюс1 { + get { + object obj = ResourceManager.GetObject("плюс1", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ShoeStore/Properties/Resources.resx b/ShoeStore/Properties/Resources.resx new file mode 100644 index 0000000..ed6050e --- /dev/null +++ b/ShoeStore/Properties/Resources.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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\плюс.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\плюс1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\карандащ.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\минус.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\обувной.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ShoeStore/Repositories/IProductRepository.cs b/ShoeStore/Repositories/IProductRepository.cs index 1f18cf9..9a352c0 100644 --- a/ShoeStore/Repositories/IProductRepository.cs +++ b/ShoeStore/Repositories/IProductRepository.cs @@ -10,7 +10,7 @@ namespace ShoeStore.Repositories; public interface IProductRepository { IEnumerable ReadProducts(); - Employee ReadProductById(int id); + Product ReadProductById(int id); void CreateProduct(Product product); void UpdateProduct(Product product); void DeleteProduct(int id); diff --git a/ShoeStore/Repositories/ISaleRepository.cs b/ShoeStore/Repositories/ISaleRepository.cs index bdc1f8b..2a2b8eb 100644 --- a/ShoeStore/Repositories/ISaleRepository.cs +++ b/ShoeStore/Repositories/ISaleRepository.cs @@ -11,6 +11,6 @@ public interface ISaleRepository { IEnumerable ReadSales(DateTime? dateForm = null, DateTime? dateTo = null, int? productId = null, int? storageSize = null); void CreateSale(Sale sale); - void DeleteSale(Sale sale); + void DeleteSale(int id); } diff --git a/ShoeStore/Repositories/Implementations/EmployeeRepository.cs b/ShoeStore/Repositories/Implementations/EmployeeRepository.cs new file mode 100644 index 0000000..d2e94bf --- /dev/null +++ b/ShoeStore/Repositories/Implementations/EmployeeRepository.cs @@ -0,0 +1,33 @@ +using ShoeStore.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShoeStore.Repositories.Implementations; + +public class EmployeeRepository : IEmployeeRepository +{ + public void CreateEmployee(Employee employee) + { + } + + public void DeleteEmployee(int id) + { + } + + public Employee ReadEmployeeById(int id) + { + return Employee.CreateEntity(0, 0, 0); + } + + public IEnumerable ReadEmployees() + { + return []; + } + + public void UpdateEmployee(Employee employee) + { + } +} diff --git a/ShoeStore/Repositories/Implementations/ProductRepository.cs b/ShoeStore/Repositories/Implementations/ProductRepository.cs new file mode 100644 index 0000000..42604e4 --- /dev/null +++ b/ShoeStore/Repositories/Implementations/ProductRepository.cs @@ -0,0 +1,35 @@ +using ShoeStore.Entities; +using ShoeStore.Entities.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShoeStore.Repositories.Implementations; + +public class ProductRepository : IProductRepository +{ + public void CreateProduct(Product product) + { + } + + public void DeleteProduct(int id) + { + } + + public Product ReadProductById(int id) + { + return Product.CreateEntity(0, 0, String.Empty, ManufacturingCompany.None, 0, ProductType.None, 0); + } + + public IEnumerable ReadProducts() + { + return []; + } + + + public void UpdateProduct(Product product) + { + } +} diff --git a/ShoeStore/Repositories/Implementations/ReceiptRepository.cs b/ShoeStore/Repositories/Implementations/ReceiptRepository.cs new file mode 100644 index 0000000..69890fe --- /dev/null +++ b/ShoeStore/Repositories/Implementations/ReceiptRepository.cs @@ -0,0 +1,20 @@ +using ShoeStore.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShoeStore.Repositories.Implementations; + +public class ReceiptRepository : IReceiptRepository +{ + public void CreateReceipt(Receipt receipt) + { + } + + public IEnumerable ReadReceipts(DateTime? dateForm = null, DateTime? dateTo = null, int? storageProductId = null, int? storageSize = null) + { + return []; + } +} diff --git a/ShoeStore/Repositories/Implementations/SaleRepository.cs b/ShoeStore/Repositories/Implementations/SaleRepository.cs new file mode 100644 index 0000000..a610d18 --- /dev/null +++ b/ShoeStore/Repositories/Implementations/SaleRepository.cs @@ -0,0 +1,24 @@ +using ShoeStore.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShoeStore.Repositories.Implementations; + +public class SaleRepository : ISaleRepository +{ + public void CreateSale(Sale sale) + { + } + + public void DeleteSale(int id) + { + } + + public IEnumerable ReadSales(DateTime? dateForm = null, DateTime? dateTo = null, int? productId = null, int? storageSize = null) + { + return []; + } +} diff --git a/ShoeStore/Repositories/Implementations/StorageRepository.cs b/ShoeStore/Repositories/Implementations/StorageRepository.cs new file mode 100644 index 0000000..a052901 --- /dev/null +++ b/ShoeStore/Repositories/Implementations/StorageRepository.cs @@ -0,0 +1,33 @@ +using ShoeStore.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ShoeStore.Repositories.Implementations; + +public class StorageRepository : IStorageRepository +{ + public void CreateStorage(Storage storage) + { + } + + public void DeleteStorage(int id) + { + } + + public Storage ReadStorageById(int id) + { + return Storage.CreateEntity(0, 0, 0); + } + + public IEnumerable ReadStorages() + { + return []; + } + + public void UpdateStorage(Storage storage) + { + } +} diff --git a/ShoeStore/Resources/карандащ.png b/ShoeStore/Resources/карандащ.png new file mode 100644 index 0000000..14175b5 Binary files /dev/null and b/ShoeStore/Resources/карандащ.png differ diff --git a/ShoeStore/Resources/минус.png b/ShoeStore/Resources/минус.png new file mode 100644 index 0000000..4ffeee1 Binary files /dev/null and b/ShoeStore/Resources/минус.png differ diff --git a/ShoeStore/Resources/обувной.jpg b/ShoeStore/Resources/обувной.jpg new file mode 100644 index 0000000..624ed18 Binary files /dev/null and b/ShoeStore/Resources/обувной.jpg differ diff --git a/ShoeStore/Resources/плюс.png b/ShoeStore/Resources/плюс.png new file mode 100644 index 0000000..5ee4624 Binary files /dev/null and b/ShoeStore/Resources/плюс.png differ diff --git a/ShoeStore/Resources/плюс1.png b/ShoeStore/Resources/плюс1.png new file mode 100644 index 0000000..5ee4624 Binary files /dev/null and b/ShoeStore/Resources/плюс1.png differ diff --git a/ShoeStore/ShoeStore.Designer.cs b/ShoeStore/ShoeStore.Designer.cs new file mode 100644 index 0000000..b3fb8ca --- /dev/null +++ b/ShoeStore/ShoeStore.Designer.cs @@ -0,0 +1,137 @@ +namespace ShoeStore +{ + partial class ShoeStore + { + /// + /// 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() + { + menuStrip1 = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + EployeesToolStripMenuItem = new ToolStripMenuItem(); + ProdctsToolStripMenuItem = new ToolStripMenuItem(); + StoragesToolStripMenuItem = new ToolStripMenuItem(); + операцииToolStripMenuItem = new ToolStripMenuItem(); + ReceiptsToolStripMenuItem = new ToolStripMenuItem(); + SalesToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + SuspendLayout(); + // + // menuStrip1 + // + menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Size = new Size(800, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; + // + // справочникиToolStripMenuItem + // + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { EployeesToolStripMenuItem, ProdctsToolStripMenuItem, StoragesToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; + // + // EployeesToolStripMenuItem + // + EployeesToolStripMenuItem.Name = "EployeesToolStripMenuItem"; + EployeesToolStripMenuItem.Size = new Size(133, 22); + EployeesToolStripMenuItem.Text = "Сотрудник"; + EployeesToolStripMenuItem.Click += EployeesToolStripMenuItem_Click; + // + // ProdctsToolStripMenuItem + // + ProdctsToolStripMenuItem.Name = "ProdctsToolStripMenuItem"; + ProdctsToolStripMenuItem.Size = new Size(133, 22); + ProdctsToolStripMenuItem.Text = "Продукт"; + ProdctsToolStripMenuItem.Click += ProdctsToolStripMenuItem_Click; + // + // StoragesToolStripMenuItem + // + StoragesToolStripMenuItem.Name = "StoragesToolStripMenuItem"; + StoragesToolStripMenuItem.Size = new Size(133, 22); + StoragesToolStripMenuItem.Text = "Склад"; + StoragesToolStripMenuItem.Click += StoragesToolStripMenuItem_Click; + // + // операцииToolStripMenuItem + // + операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ReceiptsToolStripMenuItem, SalesToolStripMenuItem }); + операцииToolStripMenuItem.Name = "операцииToolStripMenuItem"; + операцииToolStripMenuItem.Size = new Size(75, 20); + операцииToolStripMenuItem.Text = "Операции"; + // + // ReceiptsToolStripMenuItem + // + ReceiptsToolStripMenuItem.Name = "ReceiptsToolStripMenuItem"; + ReceiptsToolStripMenuItem.Size = new Size(147, 22); + ReceiptsToolStripMenuItem.Text = "Поступление"; + ReceiptsToolStripMenuItem.Click += ReceiptsToolStripMenuItem_Click; + // + // SalesToolStripMenuItem + // + SalesToolStripMenuItem.Name = "SalesToolStripMenuItem"; + SalesToolStripMenuItem.Size = new Size(147, 22); + SalesToolStripMenuItem.Text = "Продажа"; + SalesToolStripMenuItem.Click += SalesToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // ShoeStore + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackColor = SystemColors.ControlLightLight; + BackgroundImage = Properties.Resources.обувной; + BackgroundImageLayout = ImageLayout.Zoom; + ClientSize = new Size(800, 450); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Name = "ShoeStore"; + Text = "ShoeStore"; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip1; + private ToolStripMenuItem справочникиToolStripMenuItem; + private ToolStripMenuItem EployeesToolStripMenuItem; + private ToolStripMenuItem ProdctsToolStripMenuItem; + private ToolStripMenuItem StoragesToolStripMenuItem; + private ToolStripMenuItem операцииToolStripMenuItem; + private ToolStripMenuItem ReceiptsToolStripMenuItem; + private ToolStripMenuItem SalesToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + } +} \ No newline at end of file diff --git a/ShoeStore/ShoeStore.cs b/ShoeStore/ShoeStore.cs new file mode 100644 index 0000000..1aef8c2 --- /dev/null +++ b/ShoeStore/ShoeStore.cs @@ -0,0 +1,87 @@ +using ShoeStore.Forms; +using ShoeStore.Froms; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using System.Xml.Linq; +using Unity; + +namespace ShoeStore +{ + public partial class ShoeStore : Form + { + private readonly IUnityContainer _container; + + public ShoeStore(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void EployeesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ProdctsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void StoragesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ReceiptsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void SalesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ShoeStore/ShoeStore.csproj b/ShoeStore/ShoeStore.csproj index 965c19f..accbdf0 100644 --- a/ShoeStore/ShoeStore.csproj +++ b/ShoeStore/ShoeStore.csproj @@ -9,7 +9,22 @@ - + + + + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + \ No newline at end of file diff --git a/ShoeStore/ShoeStore.resx b/ShoeStore/ShoeStore.resx new file mode 100644 index 0000000..b48baf1 --- /dev/null +++ b/ShoeStore/ShoeStore.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/ShoeStore/ShoeStore.sln b/ShoeStore/ShoeStore.sln index d2bea35..7575448 100644 --- a/ShoeStore/ShoeStore.sln +++ b/ShoeStore/ShoeStore.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.11.35327.3 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShoeStore", "ShoeStore.csproj", "{0BCD96CD-E5CD-4591-8C0A-5140514BCD51}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShoeStore", "ShoeStore.csproj", "{0BCD96CD-E5CD-4591-8C0A-5140514BCD51}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution