From b8d67df1b287a64ecfd60bb47f8c95d891a2d173 Mon Sep 17 00:00:00 2001 From: Pyro <732603@gmail.com> Date: Thu, 12 Dec 2024 23:56:42 +0400 Subject: [PATCH] wip: lab2 --- .../Implementations/ConnectionString.cs | 6 + .../Entities/Client.cs | 4 +- .../Entities/Supplier.cs | 4 +- .../Forms/FormClient.cs | 5 +- .../Forms/FormClient.resx | 4 +- .../Forms/FormOrder.cs | 8 +- .../Forms/FormProduct.cs | 2 +- .../Forms/FormSupplier.cs | 4 +- .../ProjectConfectioneryFactory.csproj | 1 + .../Implementations/ClientRepository.cs | 124 +++++++++++++-- .../Implementations/ComponentRepository.cs | 123 +++++++++++++-- .../Implementations/OrderRepository.cs | 149 ++++++++++++++++-- .../Implementations/ProductRepository.cs | 148 +++++++++++++++-- .../Implementations/SupplierRepository.cs | 122 ++++++++++++-- .../Implementations/SupplyRepository.cs | 124 +++++++++++++-- 15 files changed, 729 insertions(+), 99 deletions(-) create mode 100644 ProjectConfectionaryFactory/ProjectConfectionaryFactory/Repositories/Implementations/ConnectionString.cs diff --git a/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Repositories/Implementations/ConnectionString.cs b/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Repositories/Implementations/ConnectionString.cs new file mode 100644 index 0000000..27da614 --- /dev/null +++ b/ProjectConfectionaryFactory/ProjectConfectionaryFactory/Repositories/Implementations/ConnectionString.cs @@ -0,0 +1,6 @@ +namespace ProjectConfectionaryFactory.Repositories.Implementations; + +internal class ConnectionString : IConnectionString +{ + string IConnectionString.ConnectionString => "Host=localhost;Username=postgres;Password=postgres;Database=confectioneryfactoryotp;"; +} \ No newline at end of file diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Client.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Client.cs index c9c7d15..fbbb8e8 100644 --- a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Client.cs +++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Client.cs @@ -5,10 +5,10 @@ public class Client public int Id { get; private set; } public string Name { get; private set; } = string.Empty; public string Surname { get; private set; } = string.Empty; - public double Phone { get; private set; } + public string Phone { get; private set; } public string Address { get; private set; } = string.Empty; - public static Client CreateEntity(int id, string name, string surname, double phone, string address) + public static Client CreateEntity(int id, string name, string surname, string phone, string address) { return new Client { diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Supplier.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Supplier.cs index f2d2b1d..134fb04 100644 --- a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Supplier.cs +++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Entities/Supplier.cs @@ -4,10 +4,10 @@ public class Supplier { public int Id { get; private set; } public string Name { get; private set; } = string.Empty; - public double Phone { get; private set; } + public string Phone { get; private set; } public string Address { get; private set; } = string.Empty; - public static Supplier CreateEntity(int id, string name, double phone, string address) + public static Supplier CreateEntity(int id, string name, string phone, string address) { return new Supplier { diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.cs b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.cs index af390ac..685a38f 100644 --- a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.cs +++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.cs @@ -1,5 +1,6 @@ using ProjectConfectioneryFactory.Entities; using ProjectConfectioneryFactory.Repositories; +using System.Text.RegularExpressions; namespace ProjectConfectioneryFactory.Forms { @@ -40,7 +41,7 @@ namespace ProjectConfectioneryFactory.Forms { try { - if (string.IsNullOrWhiteSpace(textBoxClientName.Text) || string.IsNullOrWhiteSpace(textBoxClientSurname.Text) || string.IsNullOrWhiteSpace(maskedTextBoxPhone.Text) || string.IsNullOrWhiteSpace(textBoxAddress.Text)) + if (string.IsNullOrWhiteSpace(textBoxClientName.Text) || string.IsNullOrWhiteSpace(textBoxClientSurname.Text) || !maskedTextBoxPhone.MaskCompleted || string.IsNullOrWhiteSpace(textBoxAddress.Text)) { throw new Exception("Имеются незаполненные поля"); } @@ -66,7 +67,7 @@ namespace ProjectConfectioneryFactory.Forms id, textBoxClientName.Text, textBoxClientSurname.Text, - Double.Parse(maskedTextBoxPhone.Text), + maskedTextBoxPhone.Text, textBoxAddress.Text); } } diff --git a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.resx b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.resx index 8b2ff64..af32865 100644 --- a/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.resx +++ b/ProjectConfectioneryFactory/ProjectConfectioneryFactory/Forms/FormClient.resx @@ -1,7 +1,7 @@