From 0c9c6f8496278035f59a65535e27f4d08b68df59 Mon Sep 17 00:00:00 2001 From: egorvasin01 Date: Tue, 3 Dec 2024 22:15:31 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9B=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=20=E2=84=96=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/Client.cs | 17 ++ .../Entities/Contract.cs | 38 +++ .../Entities/Contractor.cs | 17 ++ .../Entities/ContractorVacation.cs | 20 ++ .../Entities/Enums/ContractType.cs | 11 + .../Entities/Enums/Status.cs | 12 + .../Entities/Service.cs | 17 ++ .../Entities/ServiceContract.cs | 20 ++ .../Entities/Vacation.cs | 20 ++ .../Form1.Designer.cs | 39 --- .../ISEbd-22_Vasin_E.D._It_Company/Form1.cs | 10 - .../FormItCompany.Designer.cs | 146 ++++++++++ .../FormItCompany.cs | 88 ++++++ .../FormItCompany.resx | 123 +++++++++ .../Forms/FormClient.Designer.cs | 96 +++++++ .../Forms/FormClient.cs | 71 +++++ .../{Form1.resx => Forms/FormClient.resx} | 54 ++-- .../Forms/FormClients.Designer.cs | 126 +++++++++ .../Forms/FormClients.cs | 96 +++++++ .../Forms/FormClients.resx | 120 +++++++++ .../Forms/FormContract.Designer.cs | 255 ++++++++++++++++++ .../Forms/FormContract.cs | 128 +++++++++ .../Forms/FormContract.resx | 123 +++++++++ .../Forms/FormContractor.Designer.cs | 96 +++++++ .../Forms/FormContractor.cs | 66 +++++ .../Forms/FormContractor.resx | 120 +++++++++ .../Forms/FormContractorVacation.Designer.cs | 120 +++++++++ .../Forms/FormContractorVacation.cs | 57 ++++ .../Forms/FormContractorVacation.resx | 120 +++++++++ .../Forms/FormContractorVacations.Designer.cs | 98 +++++++ .../Forms/FormContractorVacations.cs | 60 +++++ .../Forms/FormContractorVacations.resx | 120 +++++++++ .../Forms/FormContractors.Designer.cs | 126 +++++++++ .../Forms/FormContractors.cs | 96 +++++++ .../Forms/FormContractors.resx | 120 +++++++++ .../Forms/FormContracts.Designer.cs | 112 ++++++++ .../Forms/FormContracts.cs | 77 ++++++ .../Forms/FormContracts.resx | 120 +++++++++ .../Forms/FormService.Designer.cs | 96 +++++++ .../Forms/FormService.cs | 71 +++++ .../Forms/FormService.resx | 120 +++++++++ .../Forms/FormServices.Designer.cs | 126 +++++++++ .../Forms/FormServices.cs | 96 +++++++ .../Forms/FormServices.resx | 120 +++++++++ .../Forms/FormVacation.Designer.cs | 118 ++++++++ .../Forms/FormVacation.cs | 67 +++++ .../Forms/FormVacation.resx | 120 +++++++++ .../Forms/FormVacations.Designer.cs | 126 +++++++++ .../Forms/FormVacations.cs | 96 +++++++ .../Forms/FormVacations.resx | 120 +++++++++ .../ISEbd-22_Vasin_E.D._It_Company.csproj | 4 + .../ISEbd-22_Vasin_E.D._It_Company/Program.cs | 20 +- .../Properties/Resources.Designer.cs | 103 +++++++ .../Properties/Resources.resx | 133 +++++++++ .../Repositories/IClientRepository.cs | 16 ++ .../Repositories/IContractRepository.cs | 17 ++ .../Repositories/IContractorRepository.cs | 16 ++ .../IContractorVacationRepository.cs | 11 + .../Repositories/IServiceRepository.cs | 16 ++ .../Repositories/IVacationRepository.cs | 16 ++ .../Implementations/ClientRepository.cs | 28 ++ .../Implementations/ContractRepository.cs | 27 ++ .../Implementations/ContractorRepository.cs | 28 ++ .../ContractorVacationRepository.cs | 16 ++ .../Implementations/ServiceRepository.cs | 28 ++ .../Implementations/VacationRepository.cs | 28 ++ .../Resources/icon-add.png | Bin 0 -> 14592 bytes .../Resources/icon-edit.png | Bin 0 -> 17914 bytes .../Resources/icon-remove.png | Bin 0 -> 13361 bytes .../Resources/it-company.jpg | Bin 0 -> 501524 bytes 70 files changed, 4861 insertions(+), 77 deletions(-) create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Client.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Contract.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Contractor.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/ContractorVacation.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Enums/ContractType.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Enums/Status.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Service.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/ServiceContract.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Vacation.cs delete mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Form1.Designer.cs delete mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Form1.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClient.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClient.cs rename ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/{Form1.resx => Forms/FormClient.resx} (92%) create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Properties/Resources.Designer.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Properties/Resources.resx create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IClientRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractorRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractorVacationRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IServiceRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IVacationRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ClientRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractorRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractorVacationRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ServiceRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/VacationRepository.cs create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Resources/icon-add.png create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Resources/icon-edit.png create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Resources/icon-remove.png create mode 100644 ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Resources/it-company.jpg diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Client.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Client.cs new file mode 100644 index 0000000..100b7ef --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Client.cs @@ -0,0 +1,17 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Entities; + +public class Client +{ + public int Id { get; private set; } + + public string Name { get; private set; } = string.Empty; + + public static Client CreateEntity(int id, string name) + { + return new Client + { + Id = id, + Name = name ?? string.Empty + }; + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Contract.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Contract.cs new file mode 100644 index 0000000..1b86ee8 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Contract.cs @@ -0,0 +1,38 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities.Enums; + +namespace ISEbd_22_Vasin_E.D._It_Company.Entities; + +public class Contract +{ + public int Id { get; private set; } + + public int ClientId { get; private set; } + + public int ContractorId { get; private set; } + + public int Amount { get; private set; } + + public DateTime Deadline { get; private set; } + + public Status Status { get; private set; } + + public ContractType ContractType { get; private set; } + + public IEnumerable Services { get; private set; } = []; + + public static Contract CreateEntity(int id, int clientId, int contractorId, int amount, + DateTime deadline, Status status, ContractType contractType, IEnumerable services) + { + return new Contract + { + Id = id, + ClientId = clientId, + ContractorId = contractorId, + Amount = amount, + Deadline = deadline, + Status = status, + ContractType = contractType, + Services = services + }; + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Contractor.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Contractor.cs new file mode 100644 index 0000000..4882d70 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Contractor.cs @@ -0,0 +1,17 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Entities; + +public class Contractor +{ + public int Id { get; private set; } + + public string Name { get; private set; } = string.Empty; + + public static Contractor CreateEntity(int id, string name) + { + return new Contractor + { + Id = id, + Name = name ?? string.Empty + }; + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/ContractorVacation.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/ContractorVacation.cs new file mode 100644 index 0000000..d6ff5bc --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/ContractorVacation.cs @@ -0,0 +1,20 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Entities; + +public class ContractorVacation +{ + public int Id { get; private set; } + + public int ContractorId { get; private set; } + + public int VacationId { get; private set; } + + public static ContractorVacation CreateElement(int id, int contractorId, int vacationId) + { + return new ContractorVacation + { + Id = id, + ContractorId = contractorId, + VacationId = vacationId + }; + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Enums/ContractType.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Enums/ContractType.cs new file mode 100644 index 0000000..3b27aa1 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Enums/ContractType.cs @@ -0,0 +1,11 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Entities.Enums; + +[Flags] +public enum ContractType +{ + None = 0, + + Support = 1, + + Development = 2 +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Enums/Status.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Enums/Status.cs new file mode 100644 index 0000000..ac96f0e --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Enums/Status.cs @@ -0,0 +1,12 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Entities.Enums; + +public enum Status +{ + None = 0, + + Started = 1, + + InProgress = 2, + + Finished = 3 +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Service.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Service.cs new file mode 100644 index 0000000..053a170 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Service.cs @@ -0,0 +1,17 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Entities; + +public class Service +{ + public int Id { get; private set; } + + public string Name { get; private set; } = string.Empty; + + public static Service CreateEntity(int id, string name) + { + return new Service + { + Id = id, + Name = name ?? string.Empty, + }; + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/ServiceContract.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/ServiceContract.cs new file mode 100644 index 0000000..f20b687 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/ServiceContract.cs @@ -0,0 +1,20 @@ +namespace OISEbd_22_Vasin_E.D._It_CompanyTP.Entities; + +public class ServiceContract +{ + public int Id { get; private set; } + + public int ServiceId { get; private set; } + + public int ContractId { get; private set; } + + public static ServiceContract CreateElement(int id, int serviceId, int contractId) + { + return new ServiceContract + { + Id = id, + ServiceId = serviceId, + ContractId = contractId + }; + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Vacation.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Vacation.cs new file mode 100644 index 0000000..91d297d --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Entities/Vacation.cs @@ -0,0 +1,20 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Entities; + +public class Vacation +{ + public int Id { get; private set; } + + public DateTime StartDate { get; private set; } + + public DateTime EndDate { get; private set; } + + public static Vacation CreateEntity(int id, DateTime startDate, DateTime endDate) + { + return new Vacation + { + Id = id, + StartDate = startDate, + EndDate = endDate + }; + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Form1.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Form1.Designer.cs deleted file mode 100644 index 1c4cd9b..0000000 --- a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace ISEbd_22_Vasin_E.D._It_Company -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Form1.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Form1.cs deleted file mode 100644 index ef6d115..0000000 --- a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace ISEbd_22_Vasin_E.D._It_Company -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.Designer.cs new file mode 100644 index 0000000..2f294af --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.Designer.cs @@ -0,0 +1,146 @@ +namespace ISEbd_22_Vasin_E.D._It_Company +{ + partial class FormItCompany + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + menuStrip = new MenuStrip(); + entitiesToolStripMenuItem = new ToolStripMenuItem(); + clientsToolStripMenuItem = new ToolStripMenuItem(); + contractorsToolStripMenuItem = new ToolStripMenuItem(); + servicesToolStripMenuItem = new ToolStripMenuItem(); + vacationsToolStripMenuItem = new ToolStripMenuItem(); + operationsToolStripMenuItem = new ToolStripMenuItem(); + contractsToolStripMenuItem = new ToolStripMenuItem(); + contractorVacationsToolStripMenuItem = new ToolStripMenuItem(); + reportsToolStripMenuItem = new ToolStripMenuItem(); + menuStrip.SuspendLayout(); + SuspendLayout(); + // + // menuStrip + // + menuStrip.Items.AddRange(new ToolStripItem[] { entitiesToolStripMenuItem, operationsToolStripMenuItem, reportsToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(800, 24); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; + // + // entitiesToolStripMenuItem + // + entitiesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { clientsToolStripMenuItem, contractorsToolStripMenuItem, servicesToolStripMenuItem, vacationsToolStripMenuItem }); + entitiesToolStripMenuItem.Name = "entitiesToolStripMenuItem"; + entitiesToolStripMenuItem.Size = new Size(94, 20); + entitiesToolStripMenuItem.Text = "Справочники"; + // + // clientsToolStripMenuItem + // + clientsToolStripMenuItem.Name = "clientsToolStripMenuItem"; + clientsToolStripMenuItem.Size = new Size(180, 22); + clientsToolStripMenuItem.Text = "Заказчики"; + clientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; + // + // contractorsToolStripMenuItem + // + contractorsToolStripMenuItem.Name = "contractorsToolStripMenuItem"; + contractorsToolStripMenuItem.Size = new Size(180, 22); + contractorsToolStripMenuItem.Text = "Исполнители"; + contractorsToolStripMenuItem.Click += ContractorsToolStripMenuItem_Click; + // + // servicesToolStripMenuItem + // + servicesToolStripMenuItem.Name = "servicesToolStripMenuItem"; + servicesToolStripMenuItem.Size = new Size(180, 22); + servicesToolStripMenuItem.Text = "Услуги"; + servicesToolStripMenuItem.Click += ServicesToolStripMenuItem_Click; + // + // vacationsToolStripMenuItem + // + vacationsToolStripMenuItem.Name = "vacationsToolStripMenuItem"; + vacationsToolStripMenuItem.Size = new Size(180, 22); + vacationsToolStripMenuItem.Text = "Отпуска"; + vacationsToolStripMenuItem.Click += VacationsToolStripMenuItem_Click; + // + // operationsToolStripMenuItem + // + operationsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { contractsToolStripMenuItem, contractorVacationsToolStripMenuItem }); + operationsToolStripMenuItem.Name = "operationsToolStripMenuItem"; + operationsToolStripMenuItem.Size = new Size(75, 20); + operationsToolStripMenuItem.Text = "Операции"; + // + // contractsToolStripMenuItem + // + contractsToolStripMenuItem.Name = "contractsToolStripMenuItem"; + contractsToolStripMenuItem.Size = new Size(180, 22); + contractsToolStripMenuItem.Text = "Контракты"; + contractsToolStripMenuItem.Click += ContractsToolStripMenuItem_Click; + // + // contractorVacationsToolStripMenuItem + // + contractorVacationsToolStripMenuItem.Name = "contractorVacationsToolStripMenuItem"; + contractorVacationsToolStripMenuItem.Size = new Size(180, 22); + contractorVacationsToolStripMenuItem.Text = "Взятые отпуска"; + contractorVacationsToolStripMenuItem.Click += ContractorVacationsToolStripMenuItem_Click; + // + // reportsToolStripMenuItem + // + reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; + reportsToolStripMenuItem.Size = new Size(60, 20); + reportsToolStripMenuItem.Text = "Отчеты"; + // + // FormItCompany + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources.it_company; + BackgroundImageLayout = ImageLayout.Stretch; + ClientSize = new Size(800, 450); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormItCompany"; + StartPosition = FormStartPosition.CenterScreen; + Text = "IT-компания"; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private MenuStrip menuStrip; + private ToolStripMenuItem entitiesToolStripMenuItem; + private ToolStripMenuItem clientsToolStripMenuItem; + private ToolStripMenuItem contractorsToolStripMenuItem; + private ToolStripMenuItem servicesToolStripMenuItem; + private ToolStripMenuItem vacationsToolStripMenuItem; + private ToolStripMenuItem operationsToolStripMenuItem; + private ToolStripMenuItem contractsToolStripMenuItem; + private ToolStripMenuItem contractorVacationsToolStripMenuItem; + private ToolStripMenuItem reportsToolStripMenuItem; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.cs new file mode 100644 index 0000000..0e5153f --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.cs @@ -0,0 +1,88 @@ +using ISEbd_22_Vasin_E.D._It_Company.Forms; +using Unity; + +namespace ISEbd_22_Vasin_E.D._It_Company +{ + public partial class FormItCompany : Form + { + private readonly IUnityContainer _container; + + public FormItCompany(IUnityContainer container) + { + InitializeComponent(); + _container = container ?? throw new ArgumentNullException(nameof(container)); + } + + private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ContractorsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ServicesToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void VacationsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ContractsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ContractorVacationsToolStripMenuItem_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.resx new file mode 100644 index 0000000..31084d5 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/FormItCompany.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClient.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClient.Designer.cs new file mode 100644 index 0000000..692c8c0 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClient.Designer.cs @@ -0,0 +1,96 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormClient + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelName = new Label(); + textBoxName = new TextBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + SuspendLayout(); + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(11, 15); + labelName.Name = "labelName"; + labelName.Size = new Size(34, 15); + labelName.TabIndex = 0; + labelName.Text = "Имя:"; + // + // textBoxName + // + textBoxName.Location = new Point(51, 12); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(217, 23); + textBoxName.TabIndex = 1; + // + // buttonCancel + // + buttonCancel.Location = new Point(151, 41); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(117, 23); + buttonCancel.TabIndex = 10; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(11, 41); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(117, 23); + buttonSave.TabIndex = 9; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormClient + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(283, 75); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxName); + Controls.Add(labelName); + Name = "FormClient"; + StartPosition = FormStartPosition.CenterParent; + Text = "Заказчик"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelName; + private TextBox textBoxName; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClient.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClient.cs new file mode 100644 index 0000000..6b433e8 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClient.cs @@ -0,0 +1,71 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; +using ISEbd_22_Vasin_E.D._It_Company.Repositories; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormClient : Form + { + private readonly IClientRepository _clientRepository; + + private int? _clientId; + + public int Id + { + set + { + try + { + var client = _clientRepository.ReadClientById(value); + if (client == null) + { + throw new InvalidDataException(nameof(client)); + } + + textBoxName.Text = client.Name; + _clientId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormClient(IClientRepository clientRepository) + { + InitializeComponent(); + _clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_clientId.HasValue) + { + _clientRepository.UpdateClient(Client.CreateEntity(_clientId.Value, + textBoxName.Text)); + } + else + { + _clientRepository.CreateClient(Client.CreateEntity(0, + textBoxName.Text)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Form1.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClient.resx similarity index 92% rename from ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Form1.resx rename to ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClient.resx index 1af7de1..8b2ff64 100644 --- a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Form1.resx +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClient.resx @@ -1,17 +1,17 @@  - diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.Designer.cs new file mode 100644 index 0000000..d637df8 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.Designer.cs @@ -0,0 +1,126 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormClients + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridViewData = new DataGridView(); + panel = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(861, 461); + dataGridViewData.TabIndex = 5; + // + // panel + // + panel.Controls.Add(buttonDel); + panel.Controls.Add(buttonUpd); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(861, 0); + panel.Name = "panel"; + panel.Size = new Size(123, 461); + panel.TabIndex = 4; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.icon_remove; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(16, 204); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(90, 90); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.icon_edit; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(16, 108); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(90, 90); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icon_add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(90, 90); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormClients + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(984, 461); + Controls.Add(dataGridViewData); + Controls.Add(panel); + Name = "FormClients"; + StartPosition = FormStartPosition.CenterParent; + Text = "Заказчики"; + Load += FormClients_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.cs new file mode 100644 index 0000000..92609f2 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.cs @@ -0,0 +1,96 @@ +using ISEbd_22_Vasin_E.D._It_Company.Repositories; +using Unity; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormClients : Form + { + private readonly IUnityContainer _container; + + private readonly IClientRepository _clientRepository; + + public FormClients(IUnityContainer container, IClientRepository clientRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + _clientRepository = clientRepository ?? throw new ArgumentException(nameof(clientRepository)); + } + + private void FormClients_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + return; + + try + { + _clientRepository.DeleteClient(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _clientRepository.ReadClients(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormClients.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.Designer.cs new file mode 100644 index 0000000..824a751 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.Designer.cs @@ -0,0 +1,255 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormContract + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelClient = new Label(); + labelContractor = new Label(); + numericUpDownAmount = new NumericUpDown(); + labelAmount = new Label(); + comboBoxClient = new ComboBox(); + comboBoxContractor = new ComboBox(); + labelDeadline = new Label(); + dateTimePickerDeadline = new DateTimePicker(); + labelStatus = new Label(); + comboBoxStatus = new ComboBox(); + checkedListBoxContractType = new CheckedListBox(); + labelContractType = new Label(); + groupBoxServices = new GroupBox(); + dataGridViewServices = new DataGridView(); + buttonCancel = new Button(); + buttonSave = new Button(); + ColumnServiceName = new DataGridViewComboBoxColumn(); + ((System.ComponentModel.ISupportInitialize)numericUpDownAmount).BeginInit(); + groupBoxServices.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridViewServices).BeginInit(); + SuspendLayout(); + // + // labelClient + // + labelClient.AutoSize = true; + labelClient.Location = new Point(12, 15); + labelClient.Name = "labelClient"; + labelClient.Size = new Size(60, 15); + labelClient.TabIndex = 0; + labelClient.Text = "Заказчик:"; + // + // labelContractor + // + labelContractor.AutoSize = true; + labelContractor.Location = new Point(12, 44); + labelContractor.Name = "labelContractor"; + labelContractor.Size = new Size(84, 15); + labelContractor.TabIndex = 1; + labelContractor.Text = "Исполнитель:"; + // + // numericUpDownAmount + // + numericUpDownAmount.Location = new Point(117, 70); + numericUpDownAmount.Name = "numericUpDownAmount"; + numericUpDownAmount.Size = new Size(199, 23); + numericUpDownAmount.TabIndex = 2; + // + // labelAmount + // + labelAmount.AutoSize = true; + labelAmount.Location = new Point(12, 72); + labelAmount.Name = "labelAmount"; + labelAmount.Size = new Size(70, 15); + labelAmount.TabIndex = 3; + labelAmount.Text = "Стоимость:"; + // + // comboBoxClient + // + comboBoxClient.FormattingEnabled = true; + comboBoxClient.Location = new Point(117, 12); + comboBoxClient.Name = "comboBoxClient"; + comboBoxClient.Size = new Size(200, 23); + comboBoxClient.TabIndex = 4; + // + // comboBoxContractor + // + comboBoxContractor.FormattingEnabled = true; + comboBoxContractor.Location = new Point(117, 41); + comboBoxContractor.Name = "comboBoxContractor"; + comboBoxContractor.Size = new Size(200, 23); + comboBoxContractor.TabIndex = 5; + // + // labelDeadline + // + labelDeadline.AutoSize = true; + labelDeadline.Location = new Point(12, 99); + labelDeadline.Name = "labelDeadline"; + labelDeadline.Size = new Size(38, 15); + labelDeadline.TabIndex = 6; + labelDeadline.Text = "Срок:"; + // + // dateTimePickerDeadline + // + dateTimePickerDeadline.Location = new Point(117, 99); + dateTimePickerDeadline.Name = "dateTimePickerDeadline"; + dateTimePickerDeadline.Size = new Size(200, 23); + dateTimePickerDeadline.TabIndex = 7; + // + // labelStatus + // + labelStatus.AutoSize = true; + labelStatus.Location = new Point(12, 131); + labelStatus.Name = "labelStatus"; + labelStatus.Size = new Size(46, 15); + labelStatus.TabIndex = 8; + labelStatus.Text = "Статус:"; + // + // comboBoxStatus + // + comboBoxStatus.FormattingEnabled = true; + comboBoxStatus.Location = new Point(117, 128); + comboBoxStatus.Name = "comboBoxStatus"; + comboBoxStatus.Size = new Size(200, 23); + comboBoxStatus.TabIndex = 9; + // + // checkedListBoxContractType + // + checkedListBoxContractType.FormattingEnabled = true; + checkedListBoxContractType.Location = new Point(117, 157); + checkedListBoxContractType.Name = "checkedListBoxContractType"; + checkedListBoxContractType.Size = new Size(199, 58); + checkedListBoxContractType.TabIndex = 10; + // + // labelContractType + // + labelContractType.AutoSize = true; + labelContractType.Location = new Point(12, 166); + labelContractType.Name = "labelContractType"; + labelContractType.Size = new Size(89, 15); + labelContractType.TabIndex = 11; + labelContractType.Text = "Тип контракта:"; + // + // groupBoxServices + // + groupBoxServices.Controls.Add(dataGridViewServices); + groupBoxServices.Location = new Point(12, 221); + groupBoxServices.Name = "groupBoxServices"; + groupBoxServices.Size = new Size(305, 246); + groupBoxServices.TabIndex = 12; + groupBoxServices.TabStop = false; + groupBoxServices.Text = "Услуги:"; + // + // dataGridViewServices + // + dataGridViewServices.AllowUserToResizeColumns = false; + dataGridViewServices.AllowUserToResizeRows = false; + dataGridViewServices.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewServices.Columns.AddRange(new DataGridViewColumn[] { ColumnServiceName }); + dataGridViewServices.Dock = DockStyle.Fill; + dataGridViewServices.Location = new Point(3, 19); + dataGridViewServices.Name = "dataGridViewServices"; + dataGridViewServices.RowHeadersVisible = false; + dataGridViewServices.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewServices.Size = new Size(299, 224); + dataGridViewServices.TabIndex = 0; + // + // buttonCancel + // + buttonCancel.Location = new Point(200, 470); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(117, 23); + buttonCancel.TabIndex = 14; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(12, 470); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(117, 23); + buttonSave.TabIndex = 13; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // ColumnServiceName + // + ColumnServiceName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + ColumnServiceName.HeaderText = "Название услуги"; + ColumnServiceName.Name = "ColumnServiceName"; + ColumnServiceName.Resizable = DataGridViewTriState.True; + ColumnServiceName.SortMode = DataGridViewColumnSortMode.Automatic; + // + // FormContract + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(332, 504); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(groupBoxServices); + Controls.Add(labelContractType); + Controls.Add(checkedListBoxContractType); + Controls.Add(comboBoxStatus); + Controls.Add(labelStatus); + Controls.Add(dateTimePickerDeadline); + Controls.Add(labelDeadline); + Controls.Add(comboBoxContractor); + Controls.Add(comboBoxClient); + Controls.Add(labelAmount); + Controls.Add(numericUpDownAmount); + Controls.Add(labelContractor); + Controls.Add(labelClient); + Name = "FormContract"; + StartPosition = FormStartPosition.CenterParent; + Text = "Контракт"; + ((System.ComponentModel.ISupportInitialize)numericUpDownAmount).EndInit(); + groupBoxServices.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)dataGridViewServices).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelClient; + private Label labelContractor; + private NumericUpDown numericUpDownAmount; + private Label labelAmount; + private ComboBox comboBoxClient; + private ComboBox comboBoxContractor; + private Label labelDeadline; + private DateTimePicker dateTimePickerDeadline; + private Label labelStatus; + private ComboBox comboBoxStatus; + private CheckedListBox checkedListBoxContractType; + private Label labelContractType; + private GroupBox groupBoxServices; + private DataGridView dataGridViewServices; + private Button buttonCancel; + private Button buttonSave; + private DataGridViewComboBoxColumn ColumnServiceName; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.cs new file mode 100644 index 0000000..d75e6b3 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.cs @@ -0,0 +1,128 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; +using ISEbd_22_Vasin_E.D._It_Company.Entities.Enums; +using ISEbd_22_Vasin_E.D._It_Company.Repositories; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormContract : Form + { + private readonly IContractRepository _contractRepository; + + private int? _contractId; + + public int Id + { + set + { + try + { + var contract = _contractRepository.ReadContractById(value); + if (contract == null) + { + throw new InvalidDataException(nameof(contract)); + } + + comboBoxClient.SelectedItem = contract.ClientId; + comboBoxContractor.SelectedItem = contract.ContractorId; + numericUpDownAmount.Value = contract.Amount; + dateTimePickerDeadline.Value = contract.Deadline; + comboBoxStatus.SelectedItem = contract.Status; + checkedListBoxContractType.Items.Clear(); + foreach (ContractType type in Enum.GetValues(typeof(ContractType))) + { + checkedListBoxContractType.Items.Add(type, contract.ContractType.HasFlag(type)); + } + _contractId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormContract(IContractRepository contractRepository, IClientRepository clientRepository, + IContractorRepository contractorRepository, IServiceRepository serviceRepository) + { + InitializeComponent(); + _contractRepository = contractRepository ?? throw new ArgumentNullException(nameof(contractRepository)); + + comboBoxClient.DataSource = clientRepository.ReadClients(); + comboBoxClient.DisplayMember = "Name"; + comboBoxClient.ValueMember = "Id"; + + comboBoxContractor.DataSource = contractorRepository.ReadContractors(); + comboBoxContractor.DisplayMember = "Name"; + comboBoxContractor.ValueMember = "Id"; + + ColumnServiceName.DataSource = serviceRepository.ReadServices(); + ColumnServiceName.DisplayMember = "Name"; + ColumnServiceName.ValueMember = "Id"; + + foreach (var elem in Enum.GetValues(typeof(ContractType))) + { + checkedListBoxContractType.Items.Add(elem); + } + + comboBoxStatus.DataSource = Enum.GetValues(typeof(Status)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (checkedListBoxContractType.CheckedItems.Count == 0 || + comboBoxContractor.SelectedIndex < 0 || + comboBoxClient.SelectedIndex < 0 || + comboBoxStatus.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_contractId.HasValue) + { + _contractRepository.UpdateContract(CreateContract(_contractId.Value)); + } + else + { + _contractRepository.CreateContract(CreateContract(0)); + } + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + + private Contract CreateContract(int id) + { + ContractType contractType = ContractType.None; + foreach (var elem in checkedListBoxContractType.CheckedItems) + { + contractType |= (ContractType)elem; + } + + return Contract.CreateEntity(id, (int)comboBoxClient.SelectedValue!, + (int)comboBoxContractor.SelectedValue!, Convert.ToInt32(numericUpDownAmount.Value), + dateTimePickerDeadline.Value, (Status)comboBoxStatus.SelectedItem!, contractType, + CreateListServicesFromDataGrid()); + } + + private List CreateListServicesFromDataGrid() + { + var list = new List(); + + foreach (DataGridViewRow row in dataGridViewServices.Rows) + if (row.Cells["ColumnServiceName"].Value != null && + row.Cells["ColumnServiceDescription"].Value != null) + { + list.Add(Service.CreateEntity(0, Convert.ToString(row.Cells["ColumnServiceName"].Value)!)); + } + return list; + } + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.resx new file mode 100644 index 0000000..b31da98 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContract.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.Designer.cs new file mode 100644 index 0000000..6e4c9c5 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.Designer.cs @@ -0,0 +1,96 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormContractor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonCancel = new Button(); + buttonSave = new Button(); + textBoxName = new TextBox(); + labelName = new Label(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.Location = new Point(150, 41); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(117, 23); + buttonCancel.TabIndex = 14; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(10, 41); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(117, 23); + buttonSave.TabIndex = 13; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // textBoxName + // + textBoxName.Location = new Point(50, 12); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(217, 23); + textBoxName.TabIndex = 12; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(10, 15); + labelName.Name = "labelName"; + labelName.Size = new Size(34, 15); + labelName.TabIndex = 11; + labelName.Text = "Имя:"; + // + // FormContractor + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(286, 79); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxName); + Controls.Add(labelName); + Name = "FormContractor"; + StartPosition = FormStartPosition.CenterParent; + Text = "Исполнитель"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private TextBox textBoxName; + private Label labelName; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.cs new file mode 100644 index 0000000..7e97819 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.cs @@ -0,0 +1,66 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; +using ISEbd_22_Vasin_E.D._It_Company.Repositories; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormContractor : Form + { + private readonly IContractorRepository _contractorRepository; + + private int? _contractorId; + + public int Id + { + set + { + try + { + var contractor = _contractorRepository.ReadContractorById(value); + if (contractor == null) throw new InvalidDataException(nameof(contractor)); + + textBoxName.Text = contractor.Name; + _contractorId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormContractor(IContractorRepository contractorRepository) + { + InitializeComponent(); + _contractorRepository = contractorRepository ?? throw new ArgumentNullException(nameof(contractorRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_contractorId.HasValue) + { + _contractorRepository.UpdateContractor(Contractor.CreateEntity(_contractorId.Value, textBoxName.Text)); + } + else + { + _contractorRepository.CreateContractor(Contractor.CreateEntity(0, textBoxName.Text)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractor.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.Designer.cs new file mode 100644 index 0000000..3cceb63 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.Designer.cs @@ -0,0 +1,120 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormContractorVacation + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelContractor = new Label(); + labelVacation = new Label(); + comboBoxContractor = new ComboBox(); + comboBoxVacation = new ComboBox(); + buttonCancel = new Button(); + buttonSave = new Button(); + SuspendLayout(); + // + // labelContractor + // + labelContractor.AutoSize = true; + labelContractor.Location = new Point(10, 15); + labelContractor.Name = "labelContractor"; + labelContractor.Size = new Size(84, 15); + labelContractor.TabIndex = 0; + labelContractor.Text = "Исполнитель:"; + // + // labelVacation + // + labelVacation.AutoSize = true; + labelVacation.Location = new Point(10, 44); + labelVacation.Name = "labelVacation"; + labelVacation.Size = new Size(49, 15); + labelVacation.TabIndex = 1; + labelVacation.Text = "Отпуск:"; + // + // comboBoxContractor + // + comboBoxContractor.FormattingEnabled = true; + comboBoxContractor.Location = new Point(100, 12); + comboBoxContractor.Name = "comboBoxContractor"; + comboBoxContractor.Size = new Size(167, 23); + comboBoxContractor.TabIndex = 2; + // + // comboBoxVacation + // + comboBoxVacation.FormattingEnabled = true; + comboBoxVacation.Location = new Point(100, 41); + comboBoxVacation.Name = "comboBoxVacation"; + comboBoxVacation.Size = new Size(167, 23); + comboBoxVacation.TabIndex = 3; + // + // buttonCancel + // + buttonCancel.Location = new Point(150, 70); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(117, 23); + buttonCancel.TabIndex = 12; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(10, 70); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(117, 23); + buttonSave.TabIndex = 11; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormContractorVacation + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(283, 109); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(comboBoxVacation); + Controls.Add(comboBoxContractor); + Controls.Add(labelVacation); + Controls.Add(labelContractor); + Name = "FormContractorVacation"; + StartPosition = FormStartPosition.CenterParent; + Text = "Взятый отпуск"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelContractor; + private Label labelVacation; + private ComboBox comboBoxContractor; + private ComboBox comboBoxVacation; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.cs new file mode 100644 index 0000000..a304267 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.cs @@ -0,0 +1,57 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; +using ISEbd_22_Vasin_E.D._It_Company.Repositories; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormContractorVacation : Form + { + private readonly IContractorVacationRepository _contractorVacationRepository; + + public FormContractorVacation(IContractorVacationRepository contractorVacationRepository, + IContractorRepository contractorRepository, IVacationRepository vacationRepository) + { + InitializeComponent(); + _contractorVacationRepository = contractorVacationRepository ?? + throw new ArgumentNullException(nameof(contractorVacationRepository)); + + comboBoxContractor.DataSource = contractorRepository.ReadContractors(); + comboBoxContractor.DisplayMember = "Name"; + comboBoxContractor.ValueMember = "Id"; + + var vacations = vacationRepository.ReadVacations() + .Select(v => new + { + Id = v.Id, + DisplayDate = + $"{v.StartDate.ToString("dd.MM.yyyy")} - {v.EndDate.ToString("dd.MM.yyyy")}" + }) + .ToList(); + comboBoxVacation.DataSource = vacations; + comboBoxVacation.DisplayMember = "DisplayDate"; + comboBoxVacation.ValueMember = "Id"; + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (comboBoxContractor.SelectedIndex < 0 || + comboBoxVacation.SelectedIndex < 0) + { + throw new Exception("Имеются незаполненные поля"); + } + + _contractorVacationRepository.CreateContractorVacation(ContractorVacation.CreateElement(0, + (int)comboBoxContractor.SelectedValue!, (int)comboBoxContractor.SelectedValue!)); + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacation.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.Designer.cs new file mode 100644 index 0000000..4b4f6b8 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.Designer.cs @@ -0,0 +1,98 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormContractorVacations + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridViewData = new DataGridView(); + panel = new Panel(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(861, 461); + dataGridViewData.TabIndex = 7; + // + // panel + // + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(861, 0); + panel.Name = "panel"; + panel.Size = new Size(123, 461); + panel.TabIndex = 6; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icon_add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(90, 90); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormContractorVacations + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(984, 461); + Controls.Add(dataGridViewData); + Controls.Add(panel); + Name = "FormContractorVacations"; + StartPosition = FormStartPosition.CenterParent; + Text = "Взятые отпуска"; + Load += FormContractorVacations_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.cs new file mode 100644 index 0000000..121df2b --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.cs @@ -0,0 +1,60 @@ +using ISEbd_22_Vasin_E.D._It_Company.Repositories; +using Unity; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormContractorVacations : Form + { + private readonly IUnityContainer _container; + + private readonly IContractorVacationRepository _contractorVacationRepository; + + public FormContractorVacations(IUnityContainer container, IContractorVacationRepository contractorVacationRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + _contractorVacationRepository = contractorVacationRepository ?? + throw new ArgumentException(nameof(contractorVacationRepository)); + } + + private void FormContractorVacations_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _contractorVacationRepository.ReadContractorVacations(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractorVacations.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.Designer.cs new file mode 100644 index 0000000..fe6bf01 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.Designer.cs @@ -0,0 +1,126 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormContractors + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridViewData = new DataGridView(); + panel = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(861, 461); + dataGridViewData.TabIndex = 7; + // + // panel + // + panel.Controls.Add(buttonDel); + panel.Controls.Add(buttonUpd); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(861, 0); + panel.Name = "panel"; + panel.Size = new Size(123, 461); + panel.TabIndex = 6; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.icon_remove; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(16, 204); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(90, 90); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.icon_edit; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(16, 108); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(90, 90); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icon_add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(90, 90); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormContractors + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(984, 461); + Controls.Add(dataGridViewData); + Controls.Add(panel); + Name = "FormContractors"; + StartPosition = FormStartPosition.CenterParent; + Text = "Исполнители"; + Load += FormContractors_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.cs new file mode 100644 index 0000000..c2496e6 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.cs @@ -0,0 +1,96 @@ +using ISEbd_22_Vasin_E.D._It_Company.Repositories; +using Unity; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormContractors : Form + { + private readonly IUnityContainer _container; + + private readonly IContractorRepository _contractorRepository; + + public FormContractors(IUnityContainer container, IContractorRepository contractorRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + _contractorRepository = contractorRepository ?? throw new ArgumentException(nameof(contractorRepository)); + } + + private void FormContractors_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + return; + + try + { + _contractorRepository.DeleteContractor(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _contractorRepository.ReadContractors(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContractors.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.Designer.cs new file mode 100644 index 0000000..1d3a67b --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.Designer.cs @@ -0,0 +1,112 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormContracts + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridViewData = new DataGridView(); + panel = new Panel(); + buttonUpd = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(861, 461); + dataGridViewData.TabIndex = 7; + // + // panel + // + panel.Controls.Add(buttonUpd); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(861, 0); + panel.Name = "panel"; + panel.Size = new Size(123, 461); + panel.TabIndex = 6; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.icon_edit; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(16, 108); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(90, 90); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icon_add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(90, 90); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormContracts + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(984, 461); + Controls.Add(dataGridViewData); + Controls.Add(panel); + Name = "FormContracts"; + StartPosition = FormStartPosition.CenterParent; + Text = "Контракты"; + Load += FormContracts_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.cs new file mode 100644 index 0000000..569a236 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.cs @@ -0,0 +1,77 @@ +using ISEbd_22_Vasin_E.D._It_Company.Repositories; +using Unity; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormContracts : Form + { + private readonly IUnityContainer _container; + + private readonly IContractRepository _contractRepository; + + public FormContracts(IUnityContainer container, IContractRepository contractRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + _contractRepository = contractRepository ?? throw new ArgumentException(nameof(contractRepository)); + } + + private void FormContracts_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _contractRepository.ReadContracts(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormContracts.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.Designer.cs new file mode 100644 index 0000000..1b51e61 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.Designer.cs @@ -0,0 +1,96 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormService + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + buttonCancel = new Button(); + buttonSave = new Button(); + textBoxName = new TextBox(); + labelName = new Label(); + SuspendLayout(); + // + // buttonCancel + // + buttonCancel.Location = new Point(150, 41); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(117, 23); + buttonCancel.TabIndex = 14; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(10, 41); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(117, 23); + buttonSave.TabIndex = 13; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // textBoxName + // + textBoxName.Location = new Point(81, 12); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(186, 23); + textBoxName.TabIndex = 12; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(10, 15); + labelName.Name = "labelName"; + labelName.Size = new Size(34, 15); + labelName.TabIndex = 11; + labelName.Text = "Имя:"; + // + // FormService + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(284, 82); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxName); + Controls.Add(labelName); + Name = "FormService"; + StartPosition = FormStartPosition.CenterParent; + Text = "Услуга"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Button buttonCancel; + private Button buttonSave; + private TextBox textBoxName; + private Label labelName; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.cs new file mode 100644 index 0000000..f41023c --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.cs @@ -0,0 +1,71 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; +using ISEbd_22_Vasin_E.D._It_Company.Repositories; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormService : Form + { + private readonly IServiceRepository _serviceRepository; + + private int? _serviceId; + + public int Id + { + set + { + try + { + var executor = _serviceRepository.ReadServiceById(value); + if (executor == null) + { + throw new InvalidDataException(nameof(executor)); + } + + textBoxName.Text = executor.Name; + _serviceId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormService(IServiceRepository serviceRepository) + { + InitializeComponent(); + _serviceRepository = serviceRepository ?? throw new ArgumentNullException(nameof(serviceRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + throw new Exception("Имеются незаполненные поля"); + } + + if (_serviceId.HasValue) + { + _serviceRepository.UpdateService(Service.CreateEntity(_serviceId.Value, + textBoxName.Text)); + } + else + { + _serviceRepository.CreateService(Service.CreateEntity(0, + textBoxName.Text)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormService.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.Designer.cs new file mode 100644 index 0000000..ae9cba1 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.Designer.cs @@ -0,0 +1,126 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormServices + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridViewData = new DataGridView(); + panel = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(861, 461); + dataGridViewData.TabIndex = 7; + // + // panel + // + panel.Controls.Add(buttonDel); + panel.Controls.Add(buttonUpd); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(861, 0); + panel.Name = "panel"; + panel.Size = new Size(123, 461); + panel.TabIndex = 6; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.icon_remove; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(16, 204); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(90, 90); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.icon_edit; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(16, 108); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(90, 90); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icon_add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(90, 90); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormServices + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(984, 461); + Controls.Add(dataGridViewData); + Controls.Add(panel); + Name = "FormServices"; + StartPosition = FormStartPosition.CenterParent; + Text = "Услуги"; + Load += FormServices_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.cs new file mode 100644 index 0000000..e06be63 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.cs @@ -0,0 +1,96 @@ +using ISEbd_22_Vasin_E.D._It_Company.Repositories; +using Unity; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormServices : Form + { + private readonly IUnityContainer _container; + + private readonly IServiceRepository _serviceRepository; + + public FormServices(IUnityContainer container, IServiceRepository serviceRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + _serviceRepository = serviceRepository ?? throw new ArgumentException(nameof(serviceRepository)); + } + + private void FormServices_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + return; + + try + { + _serviceRepository.DeleteService(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _serviceRepository.ReadServices(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormServices.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.Designer.cs new file mode 100644 index 0000000..288a2d1 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.Designer.cs @@ -0,0 +1,118 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormVacation + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + labelStartDate = new Label(); + dateTimePickerStartDate = new DateTimePicker(); + dateTimePickerEndDate = new DateTimePicker(); + labelEndDate = new Label(); + buttonCancel = new Button(); + buttonSave = new Button(); + SuspendLayout(); + // + // labelStartDate + // + labelStartDate.AutoSize = true; + labelStartDate.Location = new Point(12, 18); + labelStartDate.Name = "labelStartDate"; + labelStartDate.Size = new Size(77, 15); + labelStartDate.TabIndex = 0; + labelStartDate.Text = "Дата начала:"; + // + // dateTimePickerStartDate + // + dateTimePickerStartDate.Location = new Point(95, 12); + dateTimePickerStartDate.Name = "dateTimePickerStartDate"; + dateTimePickerStartDate.Size = new Size(200, 23); + dateTimePickerStartDate.TabIndex = 1; + // + // dateTimePickerEndDate + // + dateTimePickerEndDate.Location = new Point(95, 41); + dateTimePickerEndDate.Name = "dateTimePickerEndDate"; + dateTimePickerEndDate.Size = new Size(200, 23); + dateTimePickerEndDate.TabIndex = 3; + // + // labelEndDate + // + labelEndDate.AutoSize = true; + labelEndDate.Location = new Point(12, 47); + labelEndDate.Name = "labelEndDate"; + labelEndDate.Size = new Size(71, 15); + labelEndDate.TabIndex = 2; + labelEndDate.Text = "Дата конца:"; + // + // buttonCancel + // + buttonCancel.Location = new Point(178, 70); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(117, 23); + buttonCancel.TabIndex = 12; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += ButtonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(12, 70); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(117, 23); + buttonSave.TabIndex = 11; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += ButtonSave_Click; + // + // FormVacation + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(310, 102); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(dateTimePickerEndDate); + Controls.Add(labelEndDate); + Controls.Add(dateTimePickerStartDate); + Controls.Add(labelStartDate); + Name = "FormVacation"; + StartPosition = FormStartPosition.CenterParent; + Text = "Отпуск"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private Label labelStartDate; + private DateTimePicker dateTimePickerStartDate; + private DateTimePicker dateTimePickerEndDate; + private Label labelEndDate; + private Button buttonCancel; + private Button buttonSave; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.cs new file mode 100644 index 0000000..8ad1155 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.cs @@ -0,0 +1,67 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; +using ISEbd_22_Vasin_E.D._It_Company.Repositories; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormVacation : Form + { + private readonly IVacationRepository _vacationRepository; + + private int? _vacationId; + + public int Id + { + set + { + try + { + var vacation = _vacationRepository.ReadVacationById(value); + if (vacation == null) + { + throw new InvalidDataException(nameof(vacation)); + } + + dateTimePickerStartDate.Value = vacation.StartDate; + dateTimePickerEndDate.Value = vacation.EndDate; + _vacationId = value; + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + } + } + + public FormVacation(IVacationRepository vacationRepository) + { + InitializeComponent(); + _vacationRepository = vacationRepository ?? throw new ArgumentNullException(nameof(vacationRepository)); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + try + { + if (_vacationId.HasValue) + { + _vacationRepository.UpdateVacation(Vacation.CreateEntity(_vacationId.Value, + dateTimePickerStartDate.Value, dateTimePickerEndDate.Value)); + } + else + { + _vacationRepository.CreateVacation(Vacation.CreateEntity(0, dateTimePickerStartDate.Value, + dateTimePickerEndDate.Value)); + } + + Close(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) => Close(); + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacation.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.Designer.cs new file mode 100644 index 0000000..8bb7fe3 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.Designer.cs @@ -0,0 +1,126 @@ +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + partial class FormVacations + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridViewData = new DataGridView(); + panel = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); + buttonAdd = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit(); + panel.SuspendLayout(); + SuspendLayout(); + // + // dataGridViewData + // + dataGridViewData.AllowUserToAddRows = false; + dataGridViewData.AllowUserToDeleteRows = false; + dataGridViewData.AllowUserToResizeColumns = false; + dataGridViewData.AllowUserToResizeRows = false; + dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewData.Dock = DockStyle.Fill; + dataGridViewData.Location = new Point(0, 0); + dataGridViewData.MultiSelect = false; + dataGridViewData.Name = "dataGridViewData"; + dataGridViewData.ReadOnly = true; + dataGridViewData.RowHeadersVisible = false; + dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewData.Size = new Size(861, 461); + dataGridViewData.TabIndex = 7; + // + // panel + // + panel.Controls.Add(buttonDel); + panel.Controls.Add(buttonUpd); + panel.Controls.Add(buttonAdd); + panel.Dock = DockStyle.Right; + panel.Location = new Point(861, 0); + panel.Name = "panel"; + panel.Size = new Size(123, 461); + panel.TabIndex = 6; + // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.icon_remove; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(16, 204); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(90, 90); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.icon_edit; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(16, 108); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(90, 90); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // + // buttonAdd + // + buttonAdd.BackgroundImage = Properties.Resources.icon_add; + buttonAdd.BackgroundImageLayout = ImageLayout.Stretch; + buttonAdd.Location = new Point(16, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(90, 90); + buttonAdd.TabIndex = 0; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // FormVacations + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(984, 461); + Controls.Add(dataGridViewData); + Controls.Add(panel); + Name = "FormVacations"; + StartPosition = FormStartPosition.CenterParent; + Text = "Отпуска"; + Load += FormVacations_Load; + ((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit(); + panel.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridViewData; + private Panel panel; + private Button buttonDel; + private Button buttonUpd; + private Button buttonAdd; + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.cs new file mode 100644 index 0000000..0aef19f --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.cs @@ -0,0 +1,96 @@ +using ISEbd_22_Vasin_E.D._It_Company.Repositories; +using Unity; + +namespace ISEbd_22_Vasin_E.D._It_Company.Forms +{ + public partial class FormVacations : Form + { + private readonly IUnityContainer _container; + + private readonly IVacationRepository _vacationRepository; + + public FormVacations(IUnityContainer container, IVacationRepository vacationRepository) + { + InitializeComponent(); + _container = container ?? throw new ArgumentException(nameof(container)); + _vacationRepository = vacationRepository ?? throw new ArgumentException(nameof(vacationRepository)); + } + + private void FormVacations_Load(object sender, EventArgs e) + { + try + { + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + try + { + _container.Resolve().ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + try + { + var form = _container.Resolve(); + form.Id = findId; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + return; + + if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes) + return; + + try + { + _vacationRepository.DeleteVacation(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void LoadList() => dataGridViewData.DataSource = _vacationRepository.ReadVacations(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewData.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + + id = Convert.ToInt32(dataGridViewData.SelectedRows[0].Cells["Id"].Value); + return true; + } + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Forms/FormVacations.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company.csproj b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company.csproj index 6936b2f..f6eaf8a 100644 --- a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company.csproj +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company.csproj @@ -9,4 +9,8 @@ enable + + + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Program.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Program.cs index 29f8398..1e10bfb 100644 --- a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Program.cs +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Program.cs @@ -1,3 +1,7 @@ +using ISEbd_22_Vasin_E.D._It_Company; +using ISEbd_22_Vasin_E.D._It_Company.Repositories; +using Unity; + namespace ISEbd_22_Vasin_E.D._It_Company { internal static class Program @@ -11,7 +15,21 @@ namespace ISEbd_22_Vasin_E.D._It_Company // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(CreateContainer().Resolve()); + } + + private static IUnityContainer CreateContainer() + { + var container = new UnityContainer(); + + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + container.RegisterType(); + + return container; } } } \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Properties/Resources.Designer.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Properties/Resources.Designer.cs new file mode 100644 index 0000000..e64622b --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ISEbd_22_Vasin_E.D._It_Company.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ISEbd_22_Vasin_E.D._It_Company.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icon_add { + get { + object obj = ResourceManager.GetObject("icon-add", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icon_edit { + get { + object obj = ResourceManager.GetObject("icon-edit", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap icon_remove { + get { + object obj = ResourceManager.GetObject("icon-remove", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap it_company { + get { + object obj = ResourceManager.GetObject("it-company", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Properties/Resources.resx b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Properties/Resources.resx new file mode 100644 index 0000000..7c87bf4 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Properties/Resources.resx @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\it-company.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icon-edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icon-add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\icon-remove.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IClientRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IClientRepository.cs new file mode 100644 index 0000000..b8540a2 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IClientRepository.cs @@ -0,0 +1,16 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public interface IClientRepository +{ + IEnumerable ReadClients(); + + Client ReadClientById(int id); + + void CreateClient(Client client); + + void UpdateClient(Client client); + + void DeleteClient(int id); +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractRepository.cs new file mode 100644 index 0000000..8c72d6e --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractRepository.cs @@ -0,0 +1,17 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; +using ISEbd_22_Vasin_E.D._It_Company.Entities.Enums; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public interface IContractRepository +{ + IEnumerable ReadContracts(int? clientId = null, int? contractorId = null, int? amountFrom = null, + int? amountTo = null, DateTime? deadlineFrom = null, DateTime? deadlineTo = null, + Status? status = null, ContractType? contractType = null); + + Contract ReadContractById(int id); + + void CreateContract(Contract contract); + + void UpdateContract(Contract contract); +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractorRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractorRepository.cs new file mode 100644 index 0000000..5804880 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractorRepository.cs @@ -0,0 +1,16 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public interface IContractorRepository +{ + IEnumerable ReadContractors(); + + Contractor ReadContractorById(int id); + + void CreateContractor(Contractor contractor); + + void UpdateContractor(Contractor contractor); + + void DeleteContractor(int id); +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractorVacationRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractorVacationRepository.cs new file mode 100644 index 0000000..e10edb3 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IContractorVacationRepository.cs @@ -0,0 +1,11 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public interface IContractorVacationRepository +{ + IEnumerable ReadContractorVacations(int? contractorId = null, + int? vacationId = null); + + void CreateContractorVacation(ContractorVacation contractorVacation); +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IServiceRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IServiceRepository.cs new file mode 100644 index 0000000..a822a15 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IServiceRepository.cs @@ -0,0 +1,16 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public interface IServiceRepository +{ + IEnumerable ReadServices(); + + Service ReadServiceById(int id); + + void CreateService(Service service); + + void UpdateService(Service service); + + void DeleteService(int id); +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IVacationRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IVacationRepository.cs new file mode 100644 index 0000000..d441a68 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/IVacationRepository.cs @@ -0,0 +1,16 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public interface IVacationRepository +{ + IEnumerable ReadVacations(); + + Vacation ReadVacationById(int id); + + void CreateVacation(Vacation vacation); + + void UpdateVacation(Vacation vacation); + + void DeleteVacation(int id); +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ClientRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ClientRepository.cs new file mode 100644 index 0000000..e0c69ea --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ClientRepository.cs @@ -0,0 +1,28 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public class ClientRepository : IClientRepository +{ + public void CreateClient(Client client) + { + } + + public void DeleteClient(int id) + { + } + + public Client ReadClientById(int id) + { + return Client.CreateEntity(0, string.Empty); + } + + public IEnumerable ReadClients() + { + return []; + } + + public void UpdateClient(Client client) + { + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractRepository.cs new file mode 100644 index 0000000..6aa9649 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractRepository.cs @@ -0,0 +1,27 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; +using ISEbd_22_Vasin_E.D._It_Company.Entities.Enums; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public class ContractRepository : IContractRepository +{ + public void CreateContract(Contract contract) + { + } + + public Contract ReadContractById(int id) + { + return Contract.CreateEntity(0, 0, 0, 0, DateTime.Now, Entities.Enums.Status.None, Entities.Enums.ContractType.None, []); + } + + public IEnumerable ReadContracts(int? clientId = null, int? contractorId = null, int? amountFrom = null, + int? amountTo = null, DateTime? deadlineFrom = null, DateTime? deadlineTo = null, + Status? status = null, ContractType? contractType = null) + { + return []; + } + + public void UpdateContract(Contract contract) + { + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractorRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractorRepository.cs new file mode 100644 index 0000000..44c70c6 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractorRepository.cs @@ -0,0 +1,28 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public class ContractorRepository : IContractorRepository +{ + public void CreateContractor(Contractor contractor) + { + } + + public void DeleteContractor(int id) + { + } + + public Contractor ReadContractorById(int id) + { + return Contractor.CreateEntity(0, string.Empty); + } + + public IEnumerable ReadContractors() + { + return []; + } + + public void UpdateContractor(Contractor contractor) + { + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractorVacationRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractorVacationRepository.cs new file mode 100644 index 0000000..8572649 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ContractorVacationRepository.cs @@ -0,0 +1,16 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public class ContractorVacationRepository : IContractorVacationRepository +{ + public void CreateContractorVacation(ContractorVacation contractorVacation) + { + } + + public IEnumerable ReadContractorVacations(int? contractorId = null, + int? vacationId = null) + { + return []; + } +} diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ServiceRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ServiceRepository.cs new file mode 100644 index 0000000..dbd68de --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/ServiceRepository.cs @@ -0,0 +1,28 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public class ServiceRepository : IServiceRepository +{ + public void CreateService(Service service) + { + } + + public void DeleteService(int id) + { + } + + public Service ReadServiceById(int id) + { + return Service.CreateEntity(0, string.Empty); + } + + public IEnumerable ReadServices() + { + return []; + } + + public void UpdateService(Service service) + { + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/VacationRepository.cs b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/VacationRepository.cs new file mode 100644 index 0000000..b6270d2 --- /dev/null +++ b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Repositories/Implementations/VacationRepository.cs @@ -0,0 +1,28 @@ +using ISEbd_22_Vasin_E.D._It_Company.Entities; + +namespace ISEbd_22_Vasin_E.D._It_Company.Repositories; + +public class VacationRepository : IVacationRepository +{ + public void CreateVacation(Vacation vacation) + { + } + + public void DeleteVacation(int id) + { + } + + public Vacation ReadVacationById(int id) + { + return Vacation.CreateEntity(0, DateTime.Now, DateTime.Now); + } + + public IEnumerable ReadVacations() + { + return []; + } + + public void UpdateVacation(Vacation vacation) + { + } +} \ No newline at end of file diff --git a/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Resources/icon-add.png b/ISEbd-22_Vasin_E.D._It_Company/ISEbd-22_Vasin_E.D._It_Company/Resources/icon-add.png new file mode 100644 index 0000000000000000000000000000000000000000..f2e2518e3bdb959e42e4a47529d7f306b3433d6c GIT binary patch literal 14592 zcmY*gcRbbK|387hAm79XA``<>e)8 z@9f}ib?3f~u#1~rB3b%8031O1=5-zKq=gY5?_`hUgM+>uSzhJDSYb@G>Ge}or%CTZ z49;S#r3{r#PT8J%yfpW&oipQ6gH1zfM*HjW%(RE&&NtS19%%i;f9x5v!gWng%~(!# z)i}ZF;l(j_CTsga!Re$9!<6v3rf;|HMkmbj@Oi6NP4{-pB`j!?o2EKV2W+ zd_0MnM<`06Ro&=JqmgY$TywEnp@NuhYl)Iprim&ycgo)A3&B{OC1Sq1^5F98{ErRR zv9bO|B;|zCmJ;>l_iiuCUl(Ay;#IAdy)#s;nhiA64BWnaP0?^UE8}!I`E4yDSg}i| z1e5dc+Dl~wh_jSdv$&N_jyUuwg+Rjay4My>)ViC!2=iFbTj#E$aVgQOj}!KP<|$gQ zzp0cVhKkc`eANv%8ya21&!pkX`AgaPajve0Rzc&a*--X-S@KqW>9*g~h2?ro@+0kU z&pdnJ6uB$wUfHL6BzM@-~KOTq=v= zO2*jx%$USSW!qFJMsVpFmZ{| zVaBq!aSF}G@r+C?v+5=oO6tfJU&3QJm}o#tOG~Rrp21Q}qed80^6av>4fd86CtmnS zWGp_BG{>pXCsX7W#N|yj zaaEspXFPw%r-UZ@CtI72&$jG)ESM(Vpr)95NI`h*_OIPg7gclfnYcmjWZ{%XMT01@ z_fdX!RTjBkBu{Ji8C;zjB=YaQrw+LcQ88~P?~O|aFnyTTKl+Zd=9LV!<_rd4)Pz;n zBvQ|}cEnXF_znm-J-AW&o#Y(8`ZB#?pVcSlG|g!$K$V$Zd#6^dp*?DjGlA}8GIhLU z_ZPPSNvriqhgUmnC(zX1bX4Hej}v`5+@<;wJ|x-+thN>tmNA0zTvWctZ0;YtZjioT zpY;q5G}1Df83g@w(O zW;n~4+OjNuEbWk}!q^q4^|kJWyl<7R2mOc)9)TM~R-TJXAQO)BPluuIqn!H=5<|r{c_gpD;!R1d77yfLtFb!~f zoyF_nOPZl1-utQ^P-mjnvWC`}kqb`T4r0chP@$&+hTY%4pWd5~ADUyDlNU~A!qRKr za4u9zHS6xLeJVp0A;bjQjE(J#C)Xz?u9;Nmbj`_6qf}y4z2XO0%EDd-Sgk(%z63cN z#(?;u()Q9PLk!w+O}nXF3oLM|f7v`{#fK!EDjsqY%3lMEUPNcFpXbWO?I_lNr9V<+ zCHLSUl>fKLUoxug3>6SB-5&h$g1=1YW7CK%#(u2R2S_(cDy>U}0NY0tgb^d3t$OC2 z`Mn7$x5ZP8a+-B1LKI66n-AD>&s7+?Ym*%4Y?0 z@09(?3CZ^;@v^zmc>N9}C0nanUA;7SgZlcfG=L-ObdR{Y(-`(tQoT+P5DY4eM`5T$8)6vqh~+_~KHieKutt<57=V<90&HYmeaH>&Qx*@d4r z874dV>2dMO{egDE4Oh?N)X z=(dBvH$Fd&(;sncU;uaC{-5nH(klMSU8zsnDbntmL|yV5yYel7{wdwV;dBuFMpys6 z(FgD5Le-I7EoI&G6@bAGaRpRiO}7j^83omu2n;%7L&Yst2O(;~PvHzr<<4u5M_bh& zW(HGe-q3oK^T(Ti`xz;SA#n>dr4*AooJNXs{~VE_=YO!6Scy zg}#Jt_!O3ADx5-d0$NP$&GDGj7<}aB0V9rFFBTwmdMlIiC1uBBx<}%CU z^heR+!l)xU-9tKzyct6YyQt^{tKWFM@yL&tc2DTE+P$j;kHq~zk8EC#s^Q7O;xB+> zX+~M@<~!?sLed*+i&cSme2+XezoZF86B0h^jTxiHE@|^aGB8KTe^fWgPM<;iE!cVoV|Cr+81IhG-04% z5#AJ#R+IfpM4p<@Lz*f=K=^Htm3FY&0pETK%0hy(`44^2&fL0x-`rSvEbkGwM}EL9 z&Gus!|E1eLnU$l=$m)`FgBAAkyWeU5ZItKbyTU{ey!N)psl(c>P`@iDy$Ilx@9%Nt zhO$y?Khk&-rlo=bhSBGh&=;~9`&0rA5dJL5o*GFq!-FfDGaQ+aJ#M=V$qOk>{a9sc z#F{djG8IWPp@-Q(H`4DLxoJQKogUQ|Me<%|1DJ4Q8im}&9M>hu*4c(vps;aK%A56Eq`@}#pt7iW!HO`&9*#zeDWX0t@W0!DM|*a6dtf(sR760=-)f3%1_tf}k z9xa+{tR)YS@@}EeDSm%RjD`CNz#L0tEU5MPne^b=4eI9XLVj>^@8ph+Wu;->BSex+ z(PND%SM5n9)89L8b?hSu}Z=*c+{K2J;1j5KgYoEYbZ8ve*Ek)$Z>QwT6nXP}@y40a3AA>$$9YF>R_7 zDp_E@sE-ki>}F63*2#J@r4wJ$<*ikfO(>MsE~hfc`HiH03k0A%T8~tA^2*u)7d~Q( zf1Bd||MC?P?rJ3b;?CWdIVF-LZF`tUw*p6abU;q!kCh#1P+ozCl%x^PuOGD|Y+IVblOEU0I<6m-;Sm$ehJCnJ`V# z)IplL$8%${y2+u_}~MXo{N@aY^i?#P6cOlZ)s0wr!2=hJJTm zx6OD%gR`t!b|<0{0|6qISiG_2AMJFjwtv5yP`sH{PG;jX%I0i20Wbotq#372Le-K_ z>BJZnE+ypEc&@z;c~49JSr!x>)x;_E)+npxrmNXfh)i$)R~~g+9(hI7as$b))Nv5s zc6eMYn!k0s>IbIWKn1ZFutBSWfSkSGuQ}r(Jf% zU0bcn{?zsbT{q5x#{!CpE^DU7M!FPngU**_X_6v{FI}}sIGtd28cQ1?a9njpo;Og_ zu6A3H`(4^WR8kq``c)k7q8HJ5`-{fq6yZ%~EsHz`v1{w5`9agV85tRD*fuK?ON}knG2O#AE