From 33659c851ef0441c24985871f8f24c5ae1a307d7 Mon Sep 17 00:00:00 2001 From: Anitonchik Date: Wed, 13 Nov 2024 17:27:50 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=20=E2=84=961?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Forms/FormClient.Designer.cs | 16 +++---- .../Forms/FormInvoices.cs | 2 +- .../Forms/FormManufacturer.Designer.cs | 8 ++-- .../Forms/FormManufacturers.cs | 4 +- .../Forms/FormProduct.Designer.cs | 48 +++++++++---------- .../Forms/FormProduct.cs | 15 ++++-- .../Forms/FormProductMovement.Designer.cs | 16 +++---- .../Forms/FormProductMovement.cs | 2 +- .../Forms/FormProducts.cs | 2 +- .../Repositories/IInvoiceRepository.cs | 2 +- .../Repositories/IManufacturerRepository.cs | 2 +- .../Implementations/InvoiceRepository.cs | 2 +- .../Implementations/ManufacturerRepository.cs | 2 +- 13 files changed, 63 insertions(+), 58 deletions(-) diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.Designer.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.Designer.cs index d2c0722..8032931 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.Designer.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.Designer.cs @@ -44,27 +44,27 @@ labelName.AutoSize = true; labelName.Location = new Point(38, 39); labelName.Name = "labelName"; - labelName.Size = new Size(42, 20); + labelName.Size = new Size(45, 20); labelName.TabIndex = 0; - labelName.Text = "ФИО"; + labelName.Text = "ФИО:"; // // labelType // labelType.AutoSize = true; labelType.Location = new Point(38, 106); labelType.Name = "labelType"; - labelType.Size = new Size(94, 20); + labelType.Size = new Size(97, 20); labelType.TabIndex = 1; - labelType.Text = "Тип клиента"; + labelType.Text = "Тип клиента:"; // // labelOptovik // labelOptovik.AutoSize = true; labelOptovik.Location = new Point(38, 179); labelOptovik.Name = "labelOptovik"; - labelOptovik.Size = new Size(68, 20); + labelOptovik.Size = new Size(75, 20); labelOptovik.TabIndex = 2; - labelOptovik.Text = "Оптовик"; + labelOptovik.Text = "Оптовик?"; // // textBoxName // @@ -75,7 +75,7 @@ // // buttonSave // - buttonSave.BackColor = Color.FromArgb(255, 192, 128); + buttonSave.BackColor = Color.FromArgb(255, 224, 192); buttonSave.Location = new Point(38, 255); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(94, 29); @@ -86,7 +86,7 @@ // // buttonCancel // - buttonCancel.BackColor = Color.FromArgb(255, 192, 128); + buttonCancel.BackColor = Color.FromArgb(255, 224, 192); buttonCancel.Location = new Point(188, 255); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(94, 29); diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoices.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoices.cs index c296a30..b5541c6 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoices.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoices.cs @@ -70,7 +70,7 @@ namespace ProjectCompanyFurniture.Forms } } - private void LoadList() => dataGridViewData.DataSource = _invoiceRepository.ReadInvoice(); + private void LoadList() => dataGridViewData.DataSource = _invoiceRepository.ReadInvoices(); private bool TryGetIdentifierFromSelectedRow(out int id) { diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormManufacturer.Designer.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormManufacturer.Designer.cs index 0a06609..be46c02 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormManufacturer.Designer.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormManufacturer.Designer.cs @@ -39,9 +39,9 @@ labelName.AutoSize = true; labelName.Location = new Point(25, 28); labelName.Name = "labelName"; - labelName.Size = new Size(77, 20); + labelName.Size = new Size(80, 20); labelName.TabIndex = 0; - labelName.Text = "Название"; + labelName.Text = "Название:"; // // textBoxName // @@ -76,14 +76,14 @@ // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(342, 171); + ClientSize = new Size(318, 158); Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(textBoxName); Controls.Add(labelName); Name = "FormManufacturer"; StartPosition = FormStartPosition.CenterScreen; - Text = "FormManufacturer"; + Text = "Производитель"; ResumeLayout(false); PerformLayout(); } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormManufacturers.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormManufacturers.cs index 03834eb..8ac6c35 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormManufacturers.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormManufacturers.cs @@ -31,7 +31,7 @@ namespace ProjectCompanyFurniture.Forms { try { - _container.Resolve().ShowDialog(); + _container.Resolve().ShowDialog(); LoadList(); } catch (Exception ex) @@ -80,7 +80,7 @@ namespace ProjectCompanyFurniture.Forms } } - private void LoadList() => dataGridViewData.DataSource = _manufacturerRepository.ReadManufacturer(); + private void LoadList() => dataGridViewData.DataSource = _manufacturerRepository.ReadManufacturers(); private bool TryGetIdentifierFromSelectedRow(out int id) { id = 0; diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.Designer.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.Designer.cs index fb83fdc..0f033f1 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.Designer.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.Designer.cs @@ -37,48 +37,47 @@ buttonSave = new Button(); buttonCancel = new Button(); labelIDManuf = new Label(); - numericUpDownIDManuf = new NumericUpDown(); + comboBoxManufacturer = new ComboBox(); ((System.ComponentModel.ISupportInitialize)numericUpDownStartPrice).BeginInit(); - ((System.ComponentModel.ISupportInitialize)numericUpDownIDManuf).BeginInit(); SuspendLayout(); // // labelName // labelName.AutoSize = true; - labelName.Location = new Point(35, 88); + labelName.Location = new Point(35, 94); labelName.Name = "labelName"; - labelName.Size = new Size(77, 20); + labelName.Size = new Size(80, 20); labelName.TabIndex = 0; - labelName.Text = "Название"; + labelName.Text = "Название:"; // // labelCategory // labelCategory.AutoSize = true; - labelCategory.Location = new Point(35, 153); + labelCategory.Location = new Point(35, 161); labelCategory.Name = "labelCategory"; - labelCategory.Size = new Size(81, 20); + labelCategory.Size = new Size(84, 20); labelCategory.TabIndex = 1; - labelCategory.Text = "Категория"; + labelCategory.Text = "Категория:"; // // labelStartPrice // labelStartPrice.AutoSize = true; labelStartPrice.Location = new Point(35, 222); labelStartPrice.Name = "labelStartPrice"; - labelStartPrice.Size = new Size(123, 20); + labelStartPrice.Size = new Size(126, 20); labelStartPrice.TabIndex = 2; - labelStartPrice.Text = "Начальная цена"; + labelStartPrice.Text = "Начальная цена:"; // // textBoxName // - textBoxName.Location = new Point(211, 85); + textBoxName.Location = new Point(211, 91); textBoxName.Name = "textBoxName"; textBoxName.Size = new Size(125, 27); textBoxName.TabIndex = 3; // // textBoxCategory // - textBoxCategory.Location = new Point(211, 150); + textBoxCategory.Location = new Point(211, 158); textBoxCategory.Name = "textBoxCategory"; textBoxCategory.Size = new Size(125, 27); textBoxCategory.TabIndex = 4; @@ -92,7 +91,7 @@ // // buttonSave // - buttonSave.BackColor = Color.FromArgb(192, 255, 192); + buttonSave.BackColor = Color.FromArgb(255, 192, 255); buttonSave.Location = new Point(33, 307); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(125, 29); @@ -103,7 +102,7 @@ // // buttonCancel // - buttonCancel.BackColor = Color.FromArgb(192, 255, 192); + buttonCancel.BackColor = Color.FromArgb(255, 192, 255); buttonCancel.Location = new Point(211, 307); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(125, 29); @@ -117,23 +116,25 @@ labelIDManuf.AutoSize = true; labelIDManuf.Location = new Point(35, 31); labelIDManuf.Name = "labelIDManuf"; - labelIDManuf.Size = new Size(135, 20); + labelIDManuf.Size = new Size(121, 20); labelIDManuf.TabIndex = 8; - labelIDManuf.Text = "ID производителя"; + labelIDManuf.Text = "Производитель:"; // - // numericUpDownIDManuf + // comboBoxManufacturer // - numericUpDownIDManuf.Location = new Point(211, 29); - numericUpDownIDManuf.Name = "numericUpDownIDManuf"; - numericUpDownIDManuf.Size = new Size(125, 27); - numericUpDownIDManuf.TabIndex = 9; + comboBoxManufacturer.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxManufacturer.FormattingEnabled = true; + comboBoxManufacturer.Location = new Point(211, 31); + comboBoxManufacturer.Name = "comboBoxManufacturer"; + comboBoxManufacturer.Size = new Size(125, 28); + comboBoxManufacturer.TabIndex = 9; // // FormProduct // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(363, 394); - Controls.Add(numericUpDownIDManuf); + Controls.Add(comboBoxManufacturer); Controls.Add(labelIDManuf); Controls.Add(buttonCancel); Controls.Add(buttonSave); @@ -147,7 +148,6 @@ StartPosition = FormStartPosition.CenterScreen; Text = "Продукт"; ((System.ComponentModel.ISupportInitialize)numericUpDownStartPrice).EndInit(); - ((System.ComponentModel.ISupportInitialize)numericUpDownIDManuf).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -163,6 +163,6 @@ private Button buttonSave; private Button buttonCancel; private Label labelIDManuf; - private NumericUpDown numericUpDownIDManuf; + private ComboBox comboBoxManufacturer; } } \ No newline at end of file diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.cs index ba49e73..b9cf7d5 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.cs @@ -22,10 +22,10 @@ namespace ProjectCompanyFurniture.Forms { throw new InvalidDataException(nameof(product)); } - numericUpDownIDManuf.Value = product.ManufacturerID; + comboBoxManufacturer.SelectedValue = product.ManufacturerID; textBoxName.Text = product.Name; textBoxCategory.Text = product.Category; - numericUpDownIDManuf.Value = product.StartingPrice; + numericUpDownStartPrice.Value = product.StartingPrice; _productId = value; } catch (Exception ex) @@ -36,10 +36,14 @@ namespace ProjectCompanyFurniture.Forms } } - public FormProduct(IProductRepository productRepository) + public FormProduct(IProductRepository productRepository, IManufacturerRepository manufacturerRepository) { InitializeComponent(); _productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository)); + + comboBoxManufacturer.DataSource = manufacturerRepository.ReadManufacturers(); + comboBoxManufacturer.DisplayMember = "FirstName"; + comboBoxManufacturer.ValueMember = "Id"; } private void ButtonSave_Click(object sender, EventArgs e) @@ -47,7 +51,8 @@ namespace ProjectCompanyFurniture.Forms try { if (string.IsNullOrWhiteSpace(textBoxName.Text) - || string.IsNullOrEmpty(textBoxCategory.Text)) + || string.IsNullOrEmpty(textBoxCategory.Text) + || comboBoxManufacturer.SelectedIndex < 0) { throw new Exception("Имеются незаполненные поля"); } @@ -70,7 +75,7 @@ namespace ProjectCompanyFurniture.Forms private void ButtonCancel_Click(object sender, EventArgs e) => Close(); - private Product CreateProduct(int id) => Product.CreateEntity(id, Convert.ToInt32(numericUpDownIDManuf.Value), + private Product CreateProduct(int id) => Product.CreateEntity(id, Convert.ToInt32((int)comboBoxManufacturer.SelectedValue!), textBoxName.Text, textBoxCategory.Text, Convert.ToInt32(numericUpDownStartPrice.Value)); } } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs index f07428b..3fd8de1 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs @@ -43,27 +43,27 @@ labelProductID.AutoSize = true; labelProductID.Location = new Point(31, 28); labelProductID.Name = "labelProductID"; - labelProductID.Size = new Size(66, 20); + labelProductID.Size = new Size(69, 20); labelProductID.TabIndex = 0; - labelProductID.Text = "Продукт"; + labelProductID.Text = "Продукт:"; // // labelMovement // labelMovement.AutoSize = true; - labelMovement.Location = new Point(31, 90); + labelMovement.Location = new Point(31, 71); labelMovement.Name = "labelMovement"; - labelMovement.Size = new Size(109, 20); + labelMovement.Size = new Size(112, 20); labelMovement.TabIndex = 1; - labelMovement.Text = "Тип движения"; + labelMovement.Text = "Тип движения:"; // // labelDate // labelDate.AutoSize = true; labelDate.Location = new Point(31, 232); labelDate.Name = "labelDate"; - labelDate.Size = new Size(41, 20); + labelDate.Size = new Size(44, 20); labelDate.TabIndex = 2; - labelDate.Text = "Дата"; + labelDate.Text = "Дата:"; // // dateTimePickerProductMovementDate // @@ -100,7 +100,7 @@ checkedListBoxMovement.FormattingEnabled = true; checkedListBoxMovement.Location = new Point(267, 71); checkedListBoxMovement.Name = "checkedListBoxMovement"; - checkedListBoxMovement.Size = new Size(181, 114); + checkedListBoxMovement.Size = new Size(181, 136); checkedListBoxMovement.TabIndex = 8; // // comboBoxProduct diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs index 89b19e6..5e1c41e 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs @@ -30,7 +30,7 @@ namespace ProjectCompanyFurniture.Forms comboBoxProduct.DisplayMember = "Name"; comboBoxProduct.ValueMember = "ID"; - foreach (var elem in Enum.GetValues(typeof(ProductMovement))) + foreach (var elem in Enum.GetValues(typeof(Movement))) { checkedListBoxMovement.Items.Add(elem); } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs index c31c413..f737ca2 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs @@ -29,7 +29,7 @@ namespace ProjectCompanyFurniture.Forms { try { - _container.Resolve().ShowDialog(); + _container.Resolve().ShowDialog(); LoadList(); } catch (Exception ex) diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IInvoiceRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IInvoiceRepository.cs index 51f9871..c19e15b 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IInvoiceRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IInvoiceRepository.cs @@ -9,7 +9,7 @@ namespace ProjectCompanyFurniture.Repositories; public interface IInvoiceRepository { - IEnumerable ReadInvoice(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null); + IEnumerable ReadInvoices (DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null); void CreateInvoice(Invoice invoice); void DeleteInvoice(int id); diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IManufacturerRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IManufacturerRepository.cs index d3f6944..9ba4fcf 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IManufacturerRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IManufacturerRepository.cs @@ -9,7 +9,7 @@ namespace ProjectCompanyFurniture.Repositories; public interface IManufacturerRepository { - IEnumerable ReadManufacturer(); + IEnumerable ReadManufacturers(); Manufacturer ReadManufacturerById(int id); void CreateManufacturer(Manufacturer manufacturer); void UpdateManufacturer(Manufacturer manufacturer); diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs index 4571f04..1bdfddc 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs @@ -17,7 +17,7 @@ public class InvoiceRepository : IInvoiceRepository { } - public IEnumerable ReadInvoice(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null) + public IEnumerable ReadInvoices(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null) { return []; } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs index e598099..934d720 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs @@ -17,7 +17,7 @@ public class ManufacturerRepository : IManufacturerRepository { } - public IEnumerable ReadManufacturer() + public IEnumerable ReadManufacturers() { return []; }