From 755bdc2a06f5e806ffac5f2b97bd4fe67e9b6c64 Mon Sep 17 00:00:00 2001 From: Anitonchik Date: Mon, 16 Dec 2024 23:12:08 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B0=D1=83=D1=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Forms/FormProductMovement.Designer.cs | 34 ++++++++++++++++--- .../Forms/FormProductMovement.cs | 2 +- .../IProductMovementRepository.cs | 2 +- .../Implementations/ClientRepository.cs | 2 +- .../Implementations/InvoiceRepository.cs | 4 +-- .../Implementations/ManufacturerRepository.cs | 2 +- .../ProductMovementRepository.cs | 6 ++-- 7 files changed, 38 insertions(+), 14 deletions(-) diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs index ba704f8..69db287 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.Designer.cs @@ -34,6 +34,9 @@ buttonSave = new Button(); checkedListBoxMovement = new CheckedListBox(); comboBoxProduct = new ComboBox(); + label1 = new Label(); + numericUpDownCount = new NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit(); SuspendLayout(); // // labelProductID @@ -48,7 +51,7 @@ // labelMovement // labelMovement.AutoSize = true; - labelMovement.Location = new Point(31, 71); + labelMovement.Location = new Point(31, 139); labelMovement.Name = "labelMovement"; labelMovement.Size = new Size(112, 20); labelMovement.TabIndex = 1; @@ -58,7 +61,7 @@ // buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonCancel.BackColor = Color.FromArgb(255, 192, 192); - buttonCancel.Location = new Point(286, 232); + buttonCancel.Location = new Point(286, 296); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(162, 29); buttonCancel.TabIndex = 6; @@ -70,7 +73,7 @@ // buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonSave.BackColor = Color.FromArgb(255, 192, 192); - buttonSave.Location = new Point(31, 232); + buttonSave.Location = new Point(31, 296); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(162, 29); buttonSave.TabIndex = 7; @@ -81,7 +84,7 @@ // checkedListBoxMovement // checkedListBoxMovement.FormattingEnabled = true; - checkedListBoxMovement.Location = new Point(267, 71); + checkedListBoxMovement.Location = new Point(267, 139); checkedListBoxMovement.Name = "checkedListBoxMovement"; checkedListBoxMovement.Size = new Size(181, 136); checkedListBoxMovement.TabIndex = 8; @@ -95,11 +98,29 @@ comboBoxProduct.Size = new Size(181, 28); comboBoxProduct.TabIndex = 9; // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(31, 83); + label1.Name = "label1"; + label1.Size = new Size(93, 20); + label1.TabIndex = 10; + label1.Text = "Количество:"; + // + // numericUpDownCount + // + numericUpDownCount.Location = new Point(267, 81); + numericUpDownCount.Name = "numericUpDownCount"; + numericUpDownCount.Size = new Size(181, 27); + numericUpDownCount.TabIndex = 11; + // // FormProductMovement // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(485, 290); + ClientSize = new Size(485, 354); + Controls.Add(numericUpDownCount); + Controls.Add(label1); Controls.Add(comboBoxProduct); Controls.Add(checkedListBoxMovement); Controls.Add(buttonSave); @@ -109,6 +130,7 @@ Name = "FormProductMovement"; StartPosition = FormStartPosition.CenterScreen; Text = "Движение товара"; + ((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit(); ResumeLayout(false); PerformLayout(); } @@ -121,5 +143,7 @@ private Button buttonSave; private CheckedListBox checkedListBoxMovement; private ComboBox comboBoxProduct; + private Label label1; + private NumericUpDown numericUpDownCount; } } \ No newline at end of file diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs index 1ab5ff5..12515ce 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProductMovement.cs @@ -50,7 +50,7 @@ namespace ProjectCompanyFurniture.Forms movement |= (Movement)elem; } _productMovementRepository.CreateProductMovement(ProductMovement.CreateOperation(0, - (int)comboBoxProduct.SelectedValue!, movement)); + (int)comboBoxProduct.SelectedValue!, (int)numericUpDownCount.Value, movement)); Close(); } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IProductMovementRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IProductMovementRepository.cs index dc586a4..bf1f0f7 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IProductMovementRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/IProductMovementRepository.cs @@ -9,6 +9,6 @@ namespace ProjectCompanyFurniture.Repositories; public interface IProductMovementRepository { - IEnumerable ReadProductMovements(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null); + IEnumerable ReadProductMovements(DateTime? dateForm = null, DateTime? dateTo = null, int? productId = null); void CreateProductMovement(ProductMovement productMovement); } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ClientRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ClientRepository.cs index 4f241b1..29112fb 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ClientRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ClientRepository.cs @@ -88,7 +88,7 @@ public class ClientRepository : IClientRepository try { using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = @"SELECT * FROM Clients WHERE [ID]=@id"; + var querySelect = @"SELECT * FROM Clients WHERE ID=@id"; var client = connection.QueryFirst(querySelect, new { id diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs index 2513927..14d988d 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs @@ -38,8 +38,8 @@ public class InvoiceRepository : IInvoiceRepository @DiscountPercentage, @SellingPrice, @DateInvoice); SELECT MAX(Id) FROM Invoices"; var invoiceID = connection.QueryFirst(queryInsert, invoice, transaction); - var querySubInsert = @"INSERT INTO InvoiceProducts (InvoiceId, ProductId, Count, SellingPrice) - VALUES (@InvoiceId, @ProductId, @Count, @SellingPrice)"; + var querySubInsert = @"INSERT INTO InvoiceProducts (InvoiceId, ProductId, Count) + VALUES (@InvoiceId, @ProductId, @Count)"; foreach (var elem in invoice.Products) { connection.Execute(querySubInsert, new diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs index d67bbcc..77fd4bf 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs @@ -85,7 +85,7 @@ public class ManufacturerRepository : IManufacturerRepository try { using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var querySelect = @"SELECT * FROM Manufacturers WHERE [ID]=@id"; + var querySelect = @"SELECT * FROM Manufacturers WHERE ID=@id"; var manufacturer = connection.QueryFirst(querySelect, new { id diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductMovementRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductMovementRepository.cs index 1c87fab..ed0bab5 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductMovementRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductMovementRepository.cs @@ -31,8 +31,8 @@ public class ProductMovementRepository : IProductMovementRepository try { using var connection = new NpgsqlConnection(_connectionString.ConnectionString); - var queryInsert = @"INSERT INTO ProductMovements (ProductID, MovementType, Date) - VALUES (@ProductID, @MovementType, @Date)"; + var queryInsert = @"INSERT INTO ProductMovements (ProductID, Count, MovementType, Date) + VALUES (@ProductID, @Count, @MovementType, @Date)"; connection.Execute(queryInsert, productMovement); } catch (Exception ex) @@ -42,7 +42,7 @@ public class ProductMovementRepository : IProductMovementRepository } } - public IEnumerable ReadProductMovements(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null) + public IEnumerable ReadProductMovements(DateTime? dateForm = null, DateTime? dateTo = null, int? productId = null) { _logger.LogInformation("Получение всех объектов"); try