This commit is contained in:
Anitonchik 2024-12-16 23:12:08 +04:00
parent 0d70b198b1
commit 755bdc2a06
7 changed files with 38 additions and 14 deletions

View File

@ -34,6 +34,9 @@
buttonSave = new Button(); buttonSave = new Button();
checkedListBoxMovement = new CheckedListBox(); checkedListBoxMovement = new CheckedListBox();
comboBoxProduct = new ComboBox(); comboBoxProduct = new ComboBox();
label1 = new Label();
numericUpDownCount = new NumericUpDown();
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// labelProductID // labelProductID
@ -48,7 +51,7 @@
// labelMovement // labelMovement
// //
labelMovement.AutoSize = true; labelMovement.AutoSize = true;
labelMovement.Location = new Point(31, 71); labelMovement.Location = new Point(31, 139);
labelMovement.Name = "labelMovement"; labelMovement.Name = "labelMovement";
labelMovement.Size = new Size(112, 20); labelMovement.Size = new Size(112, 20);
labelMovement.TabIndex = 1; labelMovement.TabIndex = 1;
@ -58,7 +61,7 @@
// //
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.BackColor = Color.FromArgb(255, 192, 192); buttonCancel.BackColor = Color.FromArgb(255, 192, 192);
buttonCancel.Location = new Point(286, 232); buttonCancel.Location = new Point(286, 296);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(162, 29); buttonCancel.Size = new Size(162, 29);
buttonCancel.TabIndex = 6; buttonCancel.TabIndex = 6;
@ -70,7 +73,7 @@
// //
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonSave.BackColor = Color.FromArgb(255, 192, 192); buttonSave.BackColor = Color.FromArgb(255, 192, 192);
buttonSave.Location = new Point(31, 232); buttonSave.Location = new Point(31, 296);
buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(162, 29); buttonSave.Size = new Size(162, 29);
buttonSave.TabIndex = 7; buttonSave.TabIndex = 7;
@ -81,7 +84,7 @@
// checkedListBoxMovement // checkedListBoxMovement
// //
checkedListBoxMovement.FormattingEnabled = true; checkedListBoxMovement.FormattingEnabled = true;
checkedListBoxMovement.Location = new Point(267, 71); checkedListBoxMovement.Location = new Point(267, 139);
checkedListBoxMovement.Name = "checkedListBoxMovement"; checkedListBoxMovement.Name = "checkedListBoxMovement";
checkedListBoxMovement.Size = new Size(181, 136); checkedListBoxMovement.Size = new Size(181, 136);
checkedListBoxMovement.TabIndex = 8; checkedListBoxMovement.TabIndex = 8;
@ -95,11 +98,29 @@
comboBoxProduct.Size = new Size(181, 28); comboBoxProduct.Size = new Size(181, 28);
comboBoxProduct.TabIndex = 9; 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 // FormProductMovement
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(485, 290); ClientSize = new Size(485, 354);
Controls.Add(numericUpDownCount);
Controls.Add(label1);
Controls.Add(comboBoxProduct); Controls.Add(comboBoxProduct);
Controls.Add(checkedListBoxMovement); Controls.Add(checkedListBoxMovement);
Controls.Add(buttonSave); Controls.Add(buttonSave);
@ -109,6 +130,7 @@
Name = "FormProductMovement"; Name = "FormProductMovement";
StartPosition = FormStartPosition.CenterScreen; StartPosition = FormStartPosition.CenterScreen;
Text = "Движение товара"; Text = "Движение товара";
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
@ -121,5 +143,7 @@
private Button buttonSave; private Button buttonSave;
private CheckedListBox checkedListBoxMovement; private CheckedListBox checkedListBoxMovement;
private ComboBox comboBoxProduct; private ComboBox comboBoxProduct;
private Label label1;
private NumericUpDown numericUpDownCount;
} }
} }

View File

@ -50,7 +50,7 @@ namespace ProjectCompanyFurniture.Forms
movement |= (Movement)elem; movement |= (Movement)elem;
} }
_productMovementRepository.CreateProductMovement(ProductMovement.CreateOperation(0, _productMovementRepository.CreateProductMovement(ProductMovement.CreateOperation(0,
(int)comboBoxProduct.SelectedValue!, movement)); (int)comboBoxProduct.SelectedValue!, (int)numericUpDownCount.Value, movement));
Close(); Close();
} }

View File

@ -9,6 +9,6 @@ namespace ProjectCompanyFurniture.Repositories;
public interface IProductMovementRepository public interface IProductMovementRepository
{ {
IEnumerable<ProductMovement> ReadProductMovements(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null); IEnumerable<ProductMovement> ReadProductMovements(DateTime? dateForm = null, DateTime? dateTo = null, int? productId = null);
void CreateProductMovement(ProductMovement productMovement); void CreateProductMovement(ProductMovement productMovement);
} }

View File

@ -88,7 +88,7 @@ public class ClientRepository : IClientRepository
try try
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); 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<Client>(querySelect, new var client = connection.QueryFirst<Client>(querySelect, new
{ {
id id

View File

@ -38,8 +38,8 @@ public class InvoiceRepository : IInvoiceRepository
@DiscountPercentage, @SellingPrice, @DateInvoice); @DiscountPercentage, @SellingPrice, @DateInvoice);
SELECT MAX(Id) FROM Invoices"; SELECT MAX(Id) FROM Invoices";
var invoiceID = connection.QueryFirst<int>(queryInsert, invoice, transaction); var invoiceID = connection.QueryFirst<int>(queryInsert, invoice, transaction);
var querySubInsert = @"INSERT INTO InvoiceProducts (InvoiceId, ProductId, Count, SellingPrice) var querySubInsert = @"INSERT INTO InvoiceProducts (InvoiceId, ProductId, Count)
VALUES (@InvoiceId, @ProductId, @Count, @SellingPrice)"; VALUES (@InvoiceId, @ProductId, @Count)";
foreach (var elem in invoice.Products) foreach (var elem in invoice.Products)
{ {
connection.Execute(querySubInsert, new connection.Execute(querySubInsert, new

View File

@ -85,7 +85,7 @@ public class ManufacturerRepository : IManufacturerRepository
try try
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); 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<Manufacturer>(querySelect, new var manufacturer = connection.QueryFirst<Manufacturer>(querySelect, new
{ {
id id

View File

@ -31,8 +31,8 @@ public class ProductMovementRepository : IProductMovementRepository
try try
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var queryInsert = @"INSERT INTO ProductMovements (ProductID, MovementType, Date) var queryInsert = @"INSERT INTO ProductMovements (ProductID, Count, MovementType, Date)
VALUES (@ProductID, @MovementType, @Date)"; VALUES (@ProductID, @Count, @MovementType, @Date)";
connection.Execute(queryInsert, productMovement); connection.Execute(queryInsert, productMovement);
} }
catch (Exception ex) catch (Exception ex)
@ -42,7 +42,7 @@ public class ProductMovementRepository : IProductMovementRepository
} }
} }
public IEnumerable<ProductMovement> ReadProductMovements(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null) public IEnumerable<ProductMovement> ReadProductMovements(DateTime? dateForm = null, DateTime? dateTo = null, int? productId = null)
{ {
_logger.LogInformation("Получение всех объектов"); _logger.LogInformation("Получение всех объектов");
try try