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();
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;
}
}

View File

@ -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();
}

View File

@ -9,6 +9,6 @@ namespace ProjectCompanyFurniture.Repositories;
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);
}

View File

@ -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<Client>(querySelect, new
{
id

View File

@ -38,8 +38,8 @@ public class InvoiceRepository : IInvoiceRepository
@DiscountPercentage, @SellingPrice, @DateInvoice);
SELECT MAX(Id) FROM Invoices";
var invoiceID = connection.QueryFirst<int>(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

View File

@ -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<Manufacturer>(querySelect, new
{
id

View File

@ -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<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("Получение всех объектов");
try