diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Entities/Invoice.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Entities/Invoice.cs index 7034b3c..1b3c818 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Entities/Invoice.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Entities/Invoice.cs @@ -19,7 +19,7 @@ public class Invoice public int SellingPrice { get; set; } - DateTime Data { get; set; } + DateTime DateInvoice { get; set; } public IEnumerable Products { @@ -37,7 +37,7 @@ public class Invoice AvailabilityOfPromotionalCode = availabilityOfPromotionalCode, DiscountPercentage = discountPercentage, SellingPrice = sellingPrice, - Data = DateTime.Now, + DateInvoice = DateTime.Now, Products = products }; } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Entities/InvoiceProduct.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Entities/InvoiceProduct.cs index 4714d20..5af3e74 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Entities/InvoiceProduct.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Entities/InvoiceProduct.cs @@ -14,8 +14,6 @@ public class InvoiceProduct public int Count { get; private set; } - public int SellingPrice { get; private set; } - public static InvoiceProduct CreateElement(int invoiceId, int productID, int count) { return new InvoiceProduct diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.cs index 3bf819a..d131e60 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormClient.cs @@ -55,9 +55,7 @@ namespace ProjectCompanyFurniture.Forms { try { - if (string.IsNullOrWhiteSpace(textBoxName.Text) - || checkBoxOptYes.Checked == false - || comboBoxClientType.SelectedIndex < 1) + if (string.IsNullOrWhiteSpace(textBoxName.Text) || comboBoxClientType.SelectedIndex < 1) { throw new Exception("Имеются незаполненные поля"); } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.Designer.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.Designer.cs index 9979d0d..485291a 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.Designer.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.Designer.cs @@ -129,6 +129,7 @@ // numericUpDownDiscPercentage // numericUpDownDiscPercentage.Location = new Point(213, 141); + numericUpDownDiscPercentage.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); numericUpDownDiscPercentage.Name = "numericUpDownDiscPercentage"; numericUpDownDiscPercentage.Size = new Size(150, 27); numericUpDownDiscPercentage.TabIndex = 20; @@ -154,6 +155,7 @@ // numericUpDownSellingPrice // numericUpDownSellingPrice.Location = new Point(212, 194); + numericUpDownSellingPrice.Maximum = new decimal(new int[] { 10000000, 0, 0, 0 }); numericUpDownSellingPrice.Name = "numericUpDownSellingPrice"; numericUpDownSellingPrice.Size = new Size(151, 27); numericUpDownSellingPrice.TabIndex = 23; diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.cs index 43acdcc..a001695 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormInvoice.cs @@ -24,7 +24,7 @@ namespace ProjectCompanyFurniture.Forms throw new ArgumentNullException(nameof(invoiceRepository)); comboBoxClient.DataSource = clientRepository.ReadClients(); - comboBoxClient.DisplayMember = "FirstName"; + comboBoxClient.DisplayMember = "Name"; comboBoxClient.ValueMember = "ID"; ColumnProduct.DataSource = productRepository.ReadProducts(); @@ -36,7 +36,7 @@ namespace ProjectCompanyFurniture.Forms { try { - if (dataGridViewProducts.RowCount < 1 || comboBoxClient.SelectedIndex < 0 || checkBoxPromYes.Checked == false) + if (dataGridViewProducts.RowCount < 1 || comboBoxClient.SelectedIndex < 0) { throw new Exception("Имеются незаполненные поля"); } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.Designer.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.Designer.cs index 0f033f1..0dbef08 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.Designer.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.Designer.cs @@ -85,6 +85,7 @@ // numericUpDownStartPrice // numericUpDownStartPrice.Location = new Point(211, 220); + numericUpDownStartPrice.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 }); numericUpDownStartPrice.Name = "numericUpDownStartPrice"; numericUpDownStartPrice.Size = new Size(125, 27); numericUpDownStartPrice.TabIndex = 5; diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.cs index b9cf7d5..6befce2 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProduct.cs @@ -42,7 +42,7 @@ namespace ProjectCompanyFurniture.Forms _productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository)); comboBoxManufacturer.DataSource = manufacturerRepository.ReadManufacturers(); - comboBoxManufacturer.DisplayMember = "FirstName"; + comboBoxManufacturer.DisplayMember = "Name"; comboBoxManufacturer.ValueMember = "Id"; } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs index 3f37393..b20d13e 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Forms/FormProducts.cs @@ -59,7 +59,7 @@ namespace ProjectCompanyFurniture.Forms } try { - var form = _container.Resolve(); + var form = _container.Resolve(); form.Id = findId; form.ShowDialog(); LoadList(); diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/ProjectCompanyFurniture.csproj b/ProjectCompanyFurniture/ProjectCompanyFurniture/ProjectCompanyFurniture.csproj index 68c312c..03be343 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/ProjectCompanyFurniture.csproj +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/ProjectCompanyFurniture.csproj @@ -18,6 +18,7 @@ + diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ClientRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ClientRepository.cs index 03d1b66..4f241b1 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ClientRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ClientRepository.cs @@ -1,6 +1,7 @@ using Dapper; using Microsoft.Extensions.Logging; using Newtonsoft.Json; +using Npgsql; using ProjectCompanyFurniture.Entities; using ProjectCompanyFurniture.Entities.Enums; using System; @@ -29,7 +30,7 @@ public class ClientRepository : IClientRepository _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(client)); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryInsert = @"INSERT INTO Clients (Name, ClientType, Optovik) VALUES (@Name, @ClientType, @Optovik)"; connection.Execute(queryInsert, client); @@ -48,7 +49,7 @@ public class ClientRepository : IClientRepository JsonConvert.SerializeObject(client)); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryUpdate = @"UPDATE Clients SET Name=@Name, ClientType=@ClientType, @@ -69,7 +70,7 @@ public class ClientRepository : IClientRepository _logger.LogDebug("Объект: {id}", id); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryDelete = @"DELETE FROM Clients WHERE ID=@id"; connection.Execute(queryDelete, new { id }); } @@ -86,7 +87,7 @@ public class ClientRepository : IClientRepository _logger.LogDebug("Объект: {id}", id); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var querySelect = @"SELECT * FROM Clients WHERE [ID]=@id"; var client = connection.QueryFirst(querySelect, new { @@ -108,7 +109,7 @@ public class ClientRepository : IClientRepository _logger.LogInformation("Получение всех объектов"); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var querySelect = "SELECT * FROM Clients"; var clients = connection.Query(querySelect); _logger.LogDebug("Полученные объекты: {json}", diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ConnectionString.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ConnectionString.cs index 36ec3c1..b29d373 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ConnectionString.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ConnectionString.cs @@ -8,5 +8,8 @@ namespace ProjectCompanyFurniture.Repositories.Implementations; public class ConnectionString : IConnectionString { - string IConnectionString.ConnectionString => "Driver={PostgreSQL};Server=localhost;Port=5432;Database=furnitureotp;Uid=postgres;Pwd=postgres"; + string IConnectionString.ConnectionString => + "Server=localhost, 5432;Database=furnitureotp;Uid=postgres;Pwd=postgres;" + /*"Server=localhost;Port=5432Database=furnitureotp;"*/ + /* "Host=localhost;Port=5432;Database=furnitureotp;Username=postgres;Password=postgres;"*/; } diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs index 451e062..0a45cc7 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/InvoiceRepository.cs @@ -1,6 +1,7 @@ using Dapper; using Microsoft.Extensions.Logging; using Newtonsoft.Json; +using Npgsql; using ProjectCompanyFurniture.Entities; using System; using System.Collections.Generic; @@ -28,14 +29,14 @@ public class InvoiceRepository : IInvoiceRepository _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(invoice)); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); connection.Open(); using var transaction = connection.BeginTransaction(); var queryInsert = @"INSERT INTO Invoices (ClientID, AvailabilityOfPromotionalCode, - DiscountPercentage, SellingPrice, Data) + DiscountPercentage, SellingPrice, DateInvoice) VALUES (@ClientID, @AvailabilityOfPromotionalCode, - @DiscountPercentage, @SellingPrice, @Data); - SELECT MAX(Id) FROM FeedReplenishments"; + @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)"; @@ -63,7 +64,7 @@ public class InvoiceRepository : IInvoiceRepository _logger.LogDebug("Объект: {id}", id); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryDelete = @"DELETE FROM Invoices WHERE ID=@id"; connection.Execute(queryDelete, new { id }); @@ -80,7 +81,7 @@ public class InvoiceRepository : IInvoiceRepository _logger.LogInformation("Получение всех объектов"); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var querySelect = @"SELECT * FROM Invoices"; var invoices = connection.Query(querySelect); _logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(invoices)); diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs index ae5c854..d67bbcc 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ManufacturerRepository.cs @@ -8,6 +8,7 @@ using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; +using Npgsql; namespace ProjectCompanyFurniture.Repositories.Implementations; @@ -28,7 +29,7 @@ public class ManufacturerRepository : IManufacturerRepository _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(manufacturer)); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryInsert = @"INSERT INTO Manufacturers (Name) VALUES (@Name)"; connection.Execute(queryInsert, manufacturer); @@ -47,7 +48,7 @@ public class ManufacturerRepository : IManufacturerRepository JsonConvert.SerializeObject(manufacturer)); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryUpdate = @"UPDATE Manufacturers SET Name=@Name WHERE ID=@id"; @@ -66,7 +67,7 @@ public class ManufacturerRepository : IManufacturerRepository _logger.LogDebug("Объект: {id}", id); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryDelete = @"DELETE FROM Manufacturers WHERE ID=@id"; connection.Execute(queryDelete, new { id }); } @@ -83,7 +84,7 @@ public class ManufacturerRepository : IManufacturerRepository _logger.LogDebug("Объект: {id}", id); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var querySelect = @"SELECT * FROM Manufacturers WHERE [ID]=@id"; var manufacturer = connection.QueryFirst(querySelect, new { @@ -105,8 +106,8 @@ public class ManufacturerRepository : IManufacturerRepository _logger.LogInformation("Получение всех объектов"); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); - var querySelect = "SELECT * FROM Manufacturers"; + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var querySelect = "SELECT * FROM MANUFACTURERS"; var manufacturers = connection.Query(querySelect); _logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(manufacturers)); diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductMovementRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductMovementRepository.cs index db960d5..1c87fab 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductMovementRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductMovementRepository.cs @@ -1,6 +1,7 @@ using Dapper; using Microsoft.Extensions.Logging; using Newtonsoft.Json; +using Npgsql; using ProjectCompanyFurniture.Entities; using ProjectCompanyFurniture.Entities.Enums; using System; @@ -29,7 +30,7 @@ public class ProductMovementRepository : IProductMovementRepository _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(productMovement)); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryInsert = @"INSERT INTO ProductMovements (ProductID, MovementType, Date) VALUES (@ProductID, @MovementType, @Date)"; connection.Execute(queryInsert, productMovement); @@ -46,7 +47,7 @@ public class ProductMovementRepository : IProductMovementRepository _logger.LogInformation("Получение всех объектов"); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var querySelect = "SELECT * FROM ProductMovements"; var productMovements = connection.Query(querySelect); _logger.LogDebug("Полученные объекты: {json}", diff --git a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductRepository.cs b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductRepository.cs index 0a6a839..4fb55cc 100644 --- a/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductRepository.cs +++ b/ProjectCompanyFurniture/ProjectCompanyFurniture/Repositories/Implementations/ProductRepository.cs @@ -1,6 +1,7 @@ using Dapper; using Microsoft.Extensions.Logging; using Newtonsoft.Json; +using Npgsql; using ProjectCompanyFurniture.Entities; using System; using System.Collections.Generic; @@ -28,7 +29,7 @@ public class ProductRepository : IProductRepository _logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(product)); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryInsert = @"INSERT INTO Products (ManufacturerID, Name, Category, StartingPrice) VALUES (@ManufacturerID, @Name, @Category, @StartingPrice)"; connection.Execute(queryInsert, product); @@ -47,7 +48,7 @@ public class ProductRepository : IProductRepository JsonConvert.SerializeObject(product)); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryUpdate = @"UPDATE Products SET ManufacturerID=@ManufacturerID, Name=@Name, @@ -69,7 +70,7 @@ public class ProductRepository : IProductRepository _logger.LogDebug("Объект: {id}", id); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var queryDelete = @"DELETE FROM Productss WHERE ID=@id"; connection.Execute(queryDelete, new { id }); } @@ -86,8 +87,8 @@ public class ProductRepository : IProductRepository _logger.LogDebug("Объект: {id}", id); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); - var querySelect = @"SELECT * FROM Products WHERE [ID]=@id"; + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); + var querySelect = @"SELECT * FROM Products WHERE ID=@id"; var product = connection.QueryFirst(querySelect, new { id @@ -108,7 +109,7 @@ public class ProductRepository : IProductRepository _logger.LogInformation("Получение всех объектов"); try { - using var connection = new SqlConnection(_connectionString.ConnectionString); + using var connection = new NpgsqlConnection(_connectionString.ConnectionString); var querySelect = "SELECT * FROM Products"; var products = connection.Query(querySelect); _logger.LogDebug("Полученные объекты: {json}",