Добавьте файлы проекта.

This commit is contained in:
sardq 2024-05-13 21:34:38 +04:00
parent eca1c17cd9
commit 3699d306cf
88 changed files with 6031 additions and 0 deletions

49
ClientDataBase.sln Normal file
View File

@ -0,0 +1,49 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33110.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SYBDView", "SYBDView\SYBDView.csproj", "{9B281F88-62FF-4293-B076-B05C297E0C0E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SYBDDataModels", "SYBDDataModels\SYBDDataModels.csproj", "{32D4AD2F-8068-4F3D-B1F3-A2AEA3777D95}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SYBDContracts", "SYBDContracts\SYBDContracts.csproj", "{EA21505A-306B-426C-8A08-30EA1101757C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SYBDBusinessLogic", "SYBDBusinessLogic\SYBDBusinessLogic.csproj", "{F653B97F-956A-4533-A54D-6EB96AEAD388}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SYBDDatabaseImplement", "SYBDDatabaseImplement\SYBDDatabaseImplement.csproj", "{9EDE2CAB-922C-40EB-8B8B-CD69502EEC66}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9B281F88-62FF-4293-B076-B05C297E0C0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B281F88-62FF-4293-B076-B05C297E0C0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B281F88-62FF-4293-B076-B05C297E0C0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B281F88-62FF-4293-B076-B05C297E0C0E}.Release|Any CPU.Build.0 = Release|Any CPU
{32D4AD2F-8068-4F3D-B1F3-A2AEA3777D95}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32D4AD2F-8068-4F3D-B1F3-A2AEA3777D95}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32D4AD2F-8068-4F3D-B1F3-A2AEA3777D95}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32D4AD2F-8068-4F3D-B1F3-A2AEA3777D95}.Release|Any CPU.Build.0 = Release|Any CPU
{EA21505A-306B-426C-8A08-30EA1101757C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EA21505A-306B-426C-8A08-30EA1101757C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EA21505A-306B-426C-8A08-30EA1101757C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EA21505A-306B-426C-8A08-30EA1101757C}.Release|Any CPU.Build.0 = Release|Any CPU
{F653B97F-956A-4533-A54D-6EB96AEAD388}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F653B97F-956A-4533-A54D-6EB96AEAD388}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F653B97F-956A-4533-A54D-6EB96AEAD388}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F653B97F-956A-4533-A54D-6EB96AEAD388}.Release|Any CPU.Build.0 = Release|Any CPU
{9EDE2CAB-922C-40EB-8B8B-CD69502EEC66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9EDE2CAB-922C-40EB-8B8B-CD69502EEC66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EDE2CAB-922C-40EB-8B8B-CD69502EEC66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EDE2CAB-922C-40EB-8B8B-CD69502EEC66}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3F9D10B4-8F7E-4940-A162-1D71929F5E07}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,115 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.SearchModels;
using SYBDContracts.StoragesContracts;
using SYBDContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace SYBDBusinessLogic.BusinessLogics
{
public class AutoLogic : IAutoLogic
{
private readonly ILogger _logger;
private readonly IAutoStorage _autoStorage;
public AutoLogic(ILogger<AutoLogic> logger, IAutoStorage autoStorage)
{
_logger = logger;
_autoStorage = autoStorage;
}
public List<AutoViewModel>? ReadList(AutoSearchModel? model)
{
_logger.LogInformation("ReadList. StateNumber:{StateNumber}. Id:{Id}", model?.StateNumber, model?.Id);
var list = model == null ? _autoStorage.GetFullList() : _autoStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public AutoViewModel? ReadElement(AutoSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. StateNumber:{StateNumber}. Id:{Id}", model.StateNumber, model.Id);
var element = _autoStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(AutoBindingModel model)
{
CheckModel(model);
if (_autoStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(AutoBindingModel model)
{
CheckModel(model);
if (_autoStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(AutoBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_autoStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(AutoBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Model))
{
throw new ArgumentNullException("Нет модели", nameof(model.Model));
}
if (string.IsNullOrEmpty(model.StateNumber))
{
throw new ArgumentNullException("Нет номеров", nameof(model.StateNumber));
}
_logger.LogInformation("Auto. Model:{Model}. StateNumber:{StateNumber}. Id:{Id}", model.Model, model.StateNumber, model.Id);
var element = _autoStorage.GetElement(new AutoSearchModel
{
StateNumber = model.StateNumber
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Автомобиль с таким гос номером уже есть");
}
}
}
}

View File

@ -0,0 +1,111 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.SearchModels;
using SYBDContracts.StoragesContracts;
using SYBDContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace SYBDBusinessLogic.BusinessLogics
{
public class ClientLogic : IClientLogic
{
private readonly ILogger _logger;
private readonly IClientStorage _clientStorage;
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
{
_logger = logger;
_clientStorage = clientStorage;
}
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
{
_logger.LogInformation("ReadList. Fullname:{Fullname}. Id:{Id}", model?.Fullname, model?.Id);
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public ClientViewModel? ReadElement(ClientSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Fullname:{Fullname}. Id:{Id}", model.Fullname, model.Id);
var element = _clientStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(ClientBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_clientStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(ClientBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Fullname))
{
throw new ArgumentNullException("Нет ФИО клиента", nameof(model.Fullname));
}
if (string.IsNullOrEmpty(model.Phone))
{
throw new ArgumentNullException("Нет телефона клиента", nameof(model.Phone));
}
if (string.IsNullOrEmpty(model.Email))
{
throw new ArgumentNullException("Нет почты клиента", nameof(model.Email));
}
_logger.LogInformation("Client. Fullname:{Fullname}. Phone:{Phone}. Email: {Email} Id:{Id}", model.Fullname, model.Phone, model.Email, model.Id);
}
}
}

View File

@ -0,0 +1,119 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.SearchModels;
using SYBDContracts.StoragesContracts;
using SYBDContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace SYBDBusinessLogic.BusinessLogics
{
public class InsuranceLogic : IInsuranceLogic
{
private readonly ILogger _logger;
private readonly IInsuranceStorage _insuranceStorage;
public InsuranceLogic(ILogger<InsuranceLogic> logger, IInsuranceStorage insuranceStorage)
{
_logger = logger;
_insuranceStorage = insuranceStorage;
}
public List<InsuranceViewModel>? ReadList(InsuranceSearchModel? model)
{
_logger.LogInformation("ReadList. InsuranceName:{Name}. Id:{Id}", model?.Name, model?.Id);
var list = model == null ? _insuranceStorage.GetFullList() : _insuranceStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public InsuranceViewModel? ReadElement(InsuranceSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. InsuranceName:{Name}. Id:{Id}", model.Name, model.Id);
var element = _insuranceStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(InsuranceBindingModel model)
{
CheckModel(model);
if (_insuranceStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(InsuranceBindingModel model)
{
CheckModel(model);
if (_insuranceStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(InsuranceBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_insuranceStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(InsuranceBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Name))
{
throw new ArgumentNullException("Нет названия страховой", nameof(model.Name));
}
if (string.IsNullOrEmpty(model.Address))
{
throw new ArgumentNullException("Нет адреса страховой", nameof(model.Address));
}
if (string.IsNullOrEmpty(model.Phone))
{
throw new ArgumentNullException("Нет телефона страховой", nameof(model.Phone));
}
_logger.LogInformation("Insurance. Name:{Name}. Address:{Address}.Phone:{Phone}. Id:{Id}", model.Name, model.Address, model.Phone, model.Id);
var element = _insuranceStorage.GetElement(new InsuranceSearchModel
{
Name = model.Name
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Страховая с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,148 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.SearchModels;
using SYBDContracts.StoragesContracts;
using SYBDContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace SYBDBusinessLogic.BusinessLogics
{
public class OrderLogic : IOrderLogic
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
{
_logger = logger;
_orderStorage = orderStorage;
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{
_logger.LogInformation("ReadList. Id:{Id}", model?.Id);
var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public OrderViewModel? ReadElement(OrderSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Id:{Id}", model.Id);
var element = _orderStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(OrderBindingModel model)
{
CheckModel(model);
if (_orderStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(OrderBindingModel model)
{
CheckModel(model);
if (_orderStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(OrderBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_orderStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public bool DeliveryOrder(OrderBindingModel model)
{
return ChangeStatus(model, "Выдан");
}
public bool FinishOrder(OrderBindingModel model)
{
return ChangeStatus(model, "Готов");
}
public bool TakeOrderInWork(OrderBindingModel model)
{
return ChangeStatus(model, "Выполняется");
}
public bool ChangeStatus(OrderBindingModel model, string newStatus)
{
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
if (viewModel == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!((viewModel.Status == "В обработке") && (newStatus == "Выполняется") || (viewModel.Status == "Выполняется") && (newStatus == "Готов") || ((viewModel.Status == "Готов") && (newStatus == "Выдан"))))
{
return false;
}
model.Status = newStatus;
model.WorkerId = viewModel.WorkerId;
model.AutoId = viewModel.AutoId;
model.ClientId = viewModel.ClientId;
model.InsuranceId = viewModel.InsuranceId;
model.Price = viewModel.Price;
model.Description = viewModel.Description;
CheckModel(model, false);
if (_orderStorage.Update(model) == null)
{
_logger.LogWarning("Change status operation failed");
return false;
}
return true;
}
private void CheckModel(OrderBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Description))
{
throw new ArgumentNullException("Нет описания заказа", nameof(model.Description));
}
if (model.Price<=0)
{
throw new ArgumentNullException("Стоимость должна быть выше 0", nameof(model.Price));
}
_logger.LogInformation("Order. Description:{Description}. Price:{Price}.Id:{Id}", model.Description, model.Price, model.Id);
}
}
}

View File

@ -0,0 +1,117 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.SearchModels;
using SYBDContracts.StoragesContracts;
using SYBDContracts.ViewModels;
using Microsoft.Extensions.Logging;
namespace SYBDBusinessLogic.BusinessLogics
{
public class WorkerLogic : IWorkerLogic
{
private readonly ILogger _logger;
private readonly IWorkerStorage _workerStorage;
public WorkerLogic(ILogger<WorkerLogic> logger, IWorkerStorage workerStorage)
{
_logger = logger;
_workerStorage = workerStorage;
}
public bool Create(WorkerBindingModel model)
{
CheckModel(model);
CheckModel(model);
if (_workerStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(WorkerBindingModel model)
{
CheckModel(model);
if (_workerStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(WorkerBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_workerStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public WorkerViewModel? ReadElement(WorkerSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. Fullname:{Fullname}. Id:{Id}", model.Fullname, model.Id);
var element = _workerStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public List<WorkerViewModel>? ReadList(WorkerSearchModel? model)
{
_logger.LogInformation("ReadList. Fullname:{Fullname}. Id:{Id}", model?.Fullname, model?.Id);
var list = model == null ? _workerStorage.GetFullList() : _workerStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
private void CheckModel(WorkerBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.Fullname))
{
throw new ArgumentNullException("Нет ФИО работника", nameof(model.Fullname));
}
if (string.IsNullOrEmpty(model.Address))
{
throw new ArgumentNullException("Нет адреса работника", nameof(model.Address));
}
if (model.Salary <= 0)
{
throw new ArgumentNullException("Зарплата работника должна быть больше 0", nameof(model.Salary));
}
_logger.LogInformation("Component. Fullname:{Fullname}. Address:{Address}.Salary:{Salary}. Id:{Id}", model.Fullname, model.Address, model.Salary, model.Id);
var element = _workerStorage.GetElement(new WorkerSearchModel
{
Fullname = model.Fullname
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Работа с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SYBDContracts\SYBDContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,12 @@
using SYBDDataModels.Models;
namespace SYBDContracts.BindingModels
{
public class AutoBindingModel : IAutoModel
{
public int Id { get; set; }
public string StateNumber { get; set; } = string.Empty;
public string Model { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,13 @@
using SYBDDataModels.Models;
namespace SYBDContracts.BindingModels
{
public class ClientBindingModel : IClientModel
{
public int Id { get; set; }
public string Fullname { get; set; } = string.Empty;
public string Phone { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,14 @@
using SYBDDataModels.Models;
namespace SYBDContracts.BindingModels
{
public class InsuranceBindingModel : IInsuranceModel
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
public string Phone { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,17 @@
using SYBDDataModels.Models;
namespace SYBDContracts.BindingModels
{
public class OrderBindingModel : IOrderModel
{
public int Id { get; set; }
public int AutoId { get; set; }
public int ClientId { get; set; }
public int InsuranceId { get; set; }
public int WorkerId { get; set; }
public string Description { get; set; } = string.Empty;
public double Price { get; set; }
public string Status { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,13 @@
using SYBDDataModels.Models;
namespace SYBDContracts.BindingModels
{
public class WorkerBindingModel : IWorkerModel
{
public int Id { get; set; }
public string Fullname { get; set; } = string.Empty;
public string Address { get; set; } = string.Empty;
public int Salary { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.ViewModels;
namespace SYBDContracts.BusinessLogicsContracts
{
public interface IAutoLogic
{
List<AutoViewModel>? ReadList(AutoSearchModel? model);
AutoViewModel? ReadElement(AutoSearchModel model);
bool Create(AutoBindingModel model);
bool Update(AutoBindingModel model);
bool Delete(AutoBindingModel model);
}
}

View File

@ -0,0 +1,19 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.ViewModels;
namespace SYBDContracts.BusinessLogicsContracts
{
public interface IClientLogic
{
List<ClientViewModel>? ReadList(ClientSearchModel? model);
ClientViewModel? ReadElement(ClientSearchModel model);
bool Create(ClientBindingModel model);
bool Update(ClientBindingModel model);
bool Delete(ClientBindingModel model);
}
}

View File

@ -0,0 +1,19 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.ViewModels;
namespace SYBDContracts.BusinessLogicsContracts
{
public interface IInsuranceLogic
{
List<InsuranceViewModel>? ReadList(InsuranceSearchModel? model);
InsuranceViewModel? ReadElement(InsuranceSearchModel model);
bool Create(InsuranceBindingModel model);
bool Update(InsuranceBindingModel model);
bool Delete(InsuranceBindingModel model);
}
}

View File

@ -0,0 +1,25 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.ViewModels;
namespace SYBDContracts.BusinessLogicsContracts
{
public interface IOrderLogic
{
List<OrderViewModel>? ReadList(OrderSearchModel? model);
OrderViewModel? ReadElement(OrderSearchModel model);
bool Create(OrderBindingModel model);
bool Update(OrderBindingModel model);
bool Delete(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
bool DeliveryOrder(OrderBindingModel model);
}
}

View File

@ -0,0 +1,19 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.ViewModels;
namespace SYBDContracts.BusinessLogicsContracts
{
public interface IWorkerLogic
{
List<WorkerViewModel>? ReadList(WorkerSearchModel? model);
WorkerViewModel? ReadElement(WorkerSearchModel model);
bool Create(WorkerBindingModel model);
bool Update(WorkerBindingModel model);
bool Delete(WorkerBindingModel model);
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SYBDDataModels\SYBDDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,9 @@
namespace SYBDContracts.SearchModels
{
public class AutoSearchModel
{
public int? Id { get; set; }
public string? StateNumber { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace SYBDContracts.SearchModels
{
public class ClientSearchModel
{
public int? Id { get; set; }
public string? Fullname { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace SYBDContracts.SearchModels
{
public class InsuranceSearchModel
{
public int? Id { get; set; }
public string? Name { get; set; }
}
}

View File

@ -0,0 +1,7 @@
namespace SYBDContracts.SearchModels
{
public class OrderSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace SYBDContracts.SearchModels
{
public class WorkerSearchModel
{
public int? Id { get; set; }
public string? Fullname { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.ViewModels;
namespace SYBDContracts.StoragesContracts
{
public interface IAutoStorage
{
List<AutoViewModel> GetFullList();
List<AutoViewModel> GetFilteredList(AutoSearchModel model);
AutoViewModel? GetElement(AutoSearchModel model);
AutoViewModel? Insert(AutoBindingModel model);
AutoViewModel? Update(AutoBindingModel model);
AutoViewModel? Delete(AutoBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.ViewModels;
namespace SYBDContracts.StoragesContracts
{
public interface IClientStorage
{
List<ClientViewModel> GetFullList();
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
ClientViewModel? GetElement(ClientSearchModel model);
ClientViewModel? Insert(ClientBindingModel model);
ClientViewModel? Update(ClientBindingModel model);
ClientViewModel? Delete(ClientBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.ViewModels;
namespace SYBDContracts.StoragesContracts
{
public interface IInsuranceStorage
{
List<InsuranceViewModel> GetFullList();
List<InsuranceViewModel> GetFilteredList(InsuranceSearchModel model);
InsuranceViewModel? GetElement(InsuranceSearchModel model);
InsuranceViewModel? Insert(InsuranceBindingModel model);
InsuranceViewModel? Update(InsuranceBindingModel model);
InsuranceViewModel? Delete(InsuranceBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.ViewModels;
namespace SYBDContracts.StoragesContracts
{
public interface IOrderStorage
{
List<OrderViewModel> GetFullList();
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
OrderViewModel? GetElement(OrderSearchModel model);
OrderViewModel? Insert(OrderBindingModel model);
OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.ViewModels;
namespace SYBDContracts.StoragesContracts
{
public interface IWorkerStorage
{
List<WorkerViewModel> GetFullList();
List<WorkerViewModel> GetFilteredList(WorkerSearchModel model);
WorkerViewModel? GetElement(WorkerSearchModel model);
WorkerViewModel? Insert(WorkerBindingModel model);
WorkerViewModel? Update(WorkerBindingModel model);
WorkerViewModel? Delete(WorkerBindingModel model);
}
}

View File

@ -0,0 +1,16 @@
using SYBDDataModels.Models;
using System.ComponentModel;
namespace SYBDContracts.ViewModels
{
public class AutoViewModel : IAutoModel
{
public int Id { get; set; }
[DisplayName("Государственный номер")]
public string StateNumber { get; set; } = string.Empty;
[DisplayName("Модель")]
public string Model { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,17 @@
using SYBDDataModels.Models;
using System.ComponentModel;
namespace SYBDContracts.ViewModels
{
public class ClientViewModel : IClientModel
{
public int Id { get; set; }
[DisplayName("ФИО клиента")]
public string Fullname { get; set; } = string.Empty;
[DisplayName("Телефонный номер")]
public string Phone { get; set; } = string.Empty;
[DisplayName("Почта")]
public string Email { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,17 @@
using SYBDDataModels.Models;
using System.ComponentModel;
namespace SYBDContracts.ViewModels
{
public class InsuranceViewModel : IInsuranceModel
{
public int Id { get; set; }
[DisplayName("Название страховой")]
public string Name { get; set; } = string.Empty;
[DisplayName("Адрес")]
public string Address { get; set; } = string.Empty;
[DisplayName("Телефонный номер")]
public string Phone { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,43 @@
using SYBDDataModels.Models;
using System.ComponentModel;
namespace SYBDContracts.ViewModels
{
public class OrderViewModel : IOrderModel
{
[DisplayName("Номер")]
public int Id { get; set; }
[DisplayName("Номер автомобиля")]
public int AutoId { get; set; }
[DisplayName("Автомобиль")]
public string AutoModel { get; set; } = string.Empty;
[DisplayName("Номер клиента")]
public int ClientId { get; set; }
[DisplayName("Клиент")]
public string ClientFullname { get; set; } = string.Empty;
[DisplayName("Номер cтраховой")]
public int InsuranceId { get; set; }
[DisplayName("Страховая")]
public string InsuranceName { get; set; } = string.Empty;
[DisplayName("Номер работника")]
public int WorkerId { get; set; }
[DisplayName("Работник")]
public string WorkerFullname { get; set; } = string.Empty;
[DisplayName("Описание")]
public string Description { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
[DisplayName("Статус")]
public string Status { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,18 @@
using SYBDDataModels.Models;
using System.ComponentModel;
namespace SYBDContracts.ViewModels
{
public class WorkerViewModel : IWorkerModel
{
public int Id { get; set; }
[DisplayName("ФИО работника")]
public string Fullname { get; set; } = string.Empty;
[DisplayName("Адрес")]
public string Address { get; set; } = string.Empty;
[DisplayName("Зарплата")]
public int Salary { get; set; }
}
}

7
SYBDDataModels/IId.cs Normal file
View File

@ -0,0 +1,7 @@
namespace SYBDDataModels
{
public interface IId
{
int Id { get; }
}
}

View File

@ -0,0 +1,8 @@
namespace SYBDDataModels.Models
{
public interface IAutoModel : IId
{
string StateNumber { get; }
string Model { get; }
}
}

View File

@ -0,0 +1,12 @@
namespace SYBDDataModels.Models
{
public interface IClientModel : IId
{
string Fullname { get; }
string Phone { get; }
string Email { get; }
}
}

View File

@ -0,0 +1,12 @@
namespace SYBDDataModels.Models
{
public interface IInsuranceModel : IId
{
string Name { get; }
string Address { get; }
string Phone { get; }
}
}

View File

@ -0,0 +1,15 @@

namespace SYBDDataModels.Models
{
public interface IOrderModel : IId
{
int AutoId { get; }
int ClientId{ get; }
int InsuranceId{ get; }
int WorkerId{ get; }
string Description { get; }
string Status { get; }
double Price { get; }
}
}

View File

@ -0,0 +1,12 @@
namespace SYBDDataModels.Models
{
public interface IWorkerModel : IId
{
string Fullname { get; }
string Address { get; }
int Salary { get; }
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,84 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.StoragesContracts;
using SYBDContracts.ViewModels;
using SYBDDatabaseImplement.Models;
namespace SYBDDatabaseImplement.Implements
{
public class AutoStorage : IAutoStorage
{
public List<AutoViewModel> GetFullList()
{
using var context = new SYBDDatabase();
return context.auto
.Select(x => x.GetViewModel)
.ToList();
}
public List<AutoViewModel> GetFilteredList(AutoSearchModel model)
{
if (string.IsNullOrEmpty(model.StateNumber))
{
return new();
}
using var context = new SYBDDatabase();
return context.auto
.Where(x => x.StateNumber.Contains(model.StateNumber))
.Select(x => x.GetViewModel)
.ToList();
}
public AutoViewModel? GetElement(AutoSearchModel model)
{
if (string.IsNullOrEmpty(model.StateNumber) && !model.Id.HasValue)
{
return null;
}
using var context = new SYBDDatabase();
return context.auto
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.StateNumber) && x.StateNumber == model.StateNumber) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public AutoViewModel? Insert(AutoBindingModel model)
{
var newAuto = Auto.Create(model);
if (newAuto == null)
{
return null;
}
using var context = new SYBDDatabase();
context.auto.Add(newAuto);
context.SaveChanges();
return newAuto.GetViewModel;
}
public AutoViewModel? Update(AutoBindingModel model)
{
using var context = new SYBDDatabase();
var component = context.auto.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public AutoViewModel? Delete(AutoBindingModel model)
{
using var context = new SYBDDatabase();
var element = context.auto.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.auto.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,84 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.StoragesContracts;
using SYBDContracts.ViewModels;
using SYBDDatabaseImplement.Models;
namespace SYBDDatabaseImplement.Implements
{
public class ClientStorage : IClientStorage
{
public List<ClientViewModel> GetFullList()
{
using var context = new SYBDDatabase();
return context.client
.Select(x => x.GetViewModel)
.ToList();
}
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
{
if (string.IsNullOrEmpty(model.Fullname))
{
return new();
}
using var context = new SYBDDatabase();
return context.client
.Where(x => x.Fullname.Contains(model.Fullname))
.Select(x => x.GetViewModel)
.ToList();
}
public ClientViewModel? GetElement(ClientSearchModel model)
{
if (string.IsNullOrEmpty(model.Fullname) && !model.Id.HasValue)
{
return null;
}
using var context = new SYBDDatabase();
return context.client
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Fullname) && x.Fullname == model.Fullname) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public ClientViewModel? Insert(ClientBindingModel model)
{
var newClient = Client.Create(model);
if (newClient == null)
{
return null;
}
using var context = new SYBDDatabase();
context.client.Add(newClient);
context.SaveChanges();
return newClient.GetViewModel;
}
public ClientViewModel? Update(ClientBindingModel model)
{
using var context = new SYBDDatabase();
var component = context.client.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public ClientViewModel? Delete(ClientBindingModel model)
{
using var context = new SYBDDatabase();
var element = context.client.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.client.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,84 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.StoragesContracts;
using SYBDContracts.ViewModels;
using SYBDDatabaseImplement.Models;
namespace SYBDDatabaseImplement.Implements
{
public class InsuranceStorage : IInsuranceStorage
{
public List<InsuranceViewModel> GetFullList()
{
using var context = new SYBDDatabase();
return context.insurance
.Select(x => x.GetViewModel)
.ToList();
}
public List<InsuranceViewModel> GetFilteredList(InsuranceSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new SYBDDatabase();
return context.insurance
.Where(x => x.Name.Contains(model.Name))
.Select(x => x.GetViewModel)
.ToList();
}
public InsuranceViewModel? GetElement(InsuranceSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new SYBDDatabase();
return context.insurance
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public InsuranceViewModel? Insert(InsuranceBindingModel model)
{
var newInsurance = Insurance.Create(model);
if (newInsurance == null)
{
return null;
}
using var context = new SYBDDatabase();
context.insurance.Add(newInsurance);
context.SaveChanges();
return newInsurance.GetViewModel;
}
public InsuranceViewModel? Update(InsuranceBindingModel model)
{
using var context = new SYBDDatabase();
var component = context.insurance.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public InsuranceViewModel? Delete(InsuranceBindingModel model)
{
using var context = new SYBDDatabase();
var element = context.insurance.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.insurance.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,112 @@
using Microsoft.EntityFrameworkCore;
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.StoragesContracts;
using SYBDContracts.ViewModels;
using SYBDDatabaseImplement.Models;
namespace SYBDDatabaseImplement.Implements
{
public class OrderStorage : IOrderStorage
{
public OrderViewModel? Delete(OrderBindingModel model)
{
using var context = new SYBDDatabase();
var element = context.order
.Include(x => x.Auto)
.Include(x => x.Client)
.Include(x => x.Insurance)
.Include(x => x.Worker)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.order.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new SYBDDatabase();
return context.order
.Include(x => x.Auto)
.Include(x => x.Client)
.Include(x => x.Insurance)
.Include(x => x.Worker)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return new();
}
using var context = new SYBDDatabase();
return context.order
.Include(x => x.Auto)
.Include(x => x.Client)
.Include(x => x.Insurance)
.Include(x => x.Worker)
.Where(x => x.Id == model.Id)
.Select(x => x.GetViewModel)
.ToList();
}
public List<OrderViewModel> GetFullList()
{
using var context = new SYBDDatabase();
return context.order
.Include(x => x.Auto)
.Include(x => x.Client)
.Include(x => x.Insurance)
.Include(x => x.Worker)
.Select(x => x.GetViewModel)
.ToList();
}
public OrderViewModel? Insert(OrderBindingModel model)
{
var newOrder = Order.Create(model);
if (newOrder == null)
{
return null;
}
newOrder.Status = "В обработке";
using var context = new SYBDDatabase();
context.order.Add(newOrder);
context.SaveChanges();
return context.order
.Include(x => x.Auto)
.Include(x => x.Client)
.Include(x => x.Insurance)
.Include(x => x.Worker)
.FirstOrDefault()
?.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
{
using var context = new SYBDDatabase();
var order = context.order
.Include(x => x.Auto)
.Include(x => x.Client)
.Include(x => x.Insurance)
.Include(x => x.Worker).FirstOrDefault(x => x.Id == model.Id);
if (order == null)
{
return null;
}
order.Update(model);
context.SaveChanges();
return order.GetViewModel;
}
}
}

View File

@ -0,0 +1,84 @@
using SYBDContracts.BindingModels;
using SYBDContracts.SearchModels;
using SYBDContracts.StoragesContracts;
using SYBDContracts.ViewModels;
using SYBDDatabaseImplement.Models;
namespace SYBDDatabaseImplement.Implements
{
public class WorkerStorage : IWorkerStorage
{
public List<WorkerViewModel> GetFullList()
{
using var context = new SYBDDatabase();
return context.worker
.Select(x => x.GetViewModel)
.ToList();
}
public List<WorkerViewModel> GetFilteredList(WorkerSearchModel model)
{
if (string.IsNullOrEmpty(model.Fullname))
{
return new();
}
using var context = new SYBDDatabase();
return context.worker
.Where(x => x.Fullname.Contains(model.Fullname))
.Select(x => x.GetViewModel)
.ToList();
}
public WorkerViewModel? GetElement(WorkerSearchModel model)
{
if (string.IsNullOrEmpty(model.Fullname) && !model.Id.HasValue)
{
return null;
}
using var context = new SYBDDatabase();
return context.worker
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Fullname) && x.Fullname == model.Fullname) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public WorkerViewModel? Insert(WorkerBindingModel model)
{
var newWorker = Worker.Create(model);
if (newWorker == null)
{
return null;
}
using var context = new SYBDDatabase();
context.worker.Add(newWorker);
context.SaveChanges();
return newWorker.GetViewModel;
}
public WorkerViewModel? Update(WorkerBindingModel model)
{
using var context = new SYBDDatabase();
var component = context.worker.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public WorkerViewModel? Delete(WorkerBindingModel model)
{
using var context = new SYBDDatabase();
var element = context.worker.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.worker.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,221 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using SYBDDatabaseImplement;
#nullable disable
namespace SYBDDatabaseImplement.Migrations
{
[DbContext(typeof(SYBDDatabase))]
[Migration("20240416144856_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.29")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("SYBDDatabaseImplement.Models.Auto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Model")
.IsRequired()
.HasColumnType("text");
b.Property<string>("StateNumber")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Autos");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Fullname")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Phone")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Insurance", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Phone")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Insurances");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("AutoId")
.HasColumnType("integer");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("InsuranceId")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("AutoId");
b.HasIndex("ClientId");
b.HasIndex("InsuranceId");
b.HasIndex("WorkerId");
b.ToTable("Orders");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Worker", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Fullname")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Salary")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Workers");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Order", b =>
{
b.HasOne("SYBDDatabaseImplement.Models.Auto", "Auto")
.WithMany("Orders")
.HasForeignKey("AutoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SYBDDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SYBDDatabaseImplement.Models.Insurance", "Insurance")
.WithMany("Orders")
.HasForeignKey("InsuranceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SYBDDatabaseImplement.Models.Worker", "Worker")
.WithMany("Orders")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Auto");
b.Navigation("Client");
b.Navigation("Insurance");
b.Navigation("Worker");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Auto", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Insurance", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Worker", b =>
{
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,153 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace SYBDDatabaseImplement.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Autos",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Model = table.Column<string>(type: "text", nullable: false),
StateNumber = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Autos", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Fullname = table.Column<string>(type: "text", nullable: false),
Phone = table.Column<string>(type: "text", nullable: false),
Email = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Insurances",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "text", nullable: false),
Address = table.Column<string>(type: "text", nullable: false),
Phone = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Insurances", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Workers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Fullname = table.Column<string>(type: "text", nullable: false),
Address = table.Column<string>(type: "text", nullable: false),
Salary = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Workers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Orders",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
AutoId = table.Column<int>(type: "integer", nullable: false),
ClientId = table.Column<int>(type: "integer", nullable: false),
InsuranceId = table.Column<int>(type: "integer", nullable: false),
WorkerId = table.Column<int>(type: "integer", nullable: false),
Price = table.Column<double>(type: "double precision", nullable: false),
Description = table.Column<string>(type: "text", nullable: false),
Status = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Autos_AutoId",
column: x => x.AutoId,
principalTable: "Autos",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Orders_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Orders_Insurances_InsuranceId",
column: x => x.InsuranceId,
principalTable: "Insurances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Orders_Workers_WorkerId",
column: x => x.WorkerId,
principalTable: "Workers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Orders_AutoId",
table: "Orders",
column: "AutoId");
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Orders_InsuranceId",
table: "Orders",
column: "InsuranceId");
migrationBuilder.CreateIndex(
name: "IX_Orders_WorkerId",
table: "Orders",
column: "WorkerId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Orders");
migrationBuilder.DropTable(
name: "Autos");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable(
name: "Insurances");
migrationBuilder.DropTable(
name: "Workers");
}
}
}

View File

@ -0,0 +1,219 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using SYBDDatabaseImplement;
#nullable disable
namespace SYBDDatabaseImplement.Migrations
{
[DbContext(typeof(SYBDDatabase))]
partial class SYBDDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.29")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("SYBDDatabaseImplement.Models.Auto", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Model")
.IsRequired()
.HasColumnType("text");
b.Property<string>("StateNumber")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Autos");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Fullname")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Phone")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Insurance", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Phone")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("Insurances");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("AutoId")
.HasColumnType("integer");
b.Property<int>("ClientId")
.HasColumnType("integer");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("text");
b.Property<int>("InsuranceId")
.HasColumnType("integer");
b.Property<double>("Price")
.HasColumnType("double precision");
b.Property<int>("Status")
.HasColumnType("integer");
b.Property<int>("WorkerId")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("AutoId");
b.HasIndex("ClientId");
b.HasIndex("InsuranceId");
b.HasIndex("WorkerId");
b.ToTable("Orders");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Worker", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("text");
b.Property<string>("Fullname")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Salary")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Workers");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Order", b =>
{
b.HasOne("SYBDDatabaseImplement.Models.Auto", "Auto")
.WithMany("Orders")
.HasForeignKey("AutoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SYBDDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SYBDDatabaseImplement.Models.Insurance", "Insurance")
.WithMany("Orders")
.HasForeignKey("InsuranceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SYBDDatabaseImplement.Models.Worker", "Worker")
.WithMany("Orders")
.HasForeignKey("WorkerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Auto");
b.Navigation("Client");
b.Navigation("Insurance");
b.Navigation("Worker");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Auto", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Insurance", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SYBDDatabaseImplement.Models.Worker", b =>
{
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,61 @@
using SYBDContracts.BindingModels;
using SYBDContracts.ViewModels;
using SYBDDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace SYBDDatabaseImplement.Models
{
public class Auto : IAutoModel
{
public int Id { get; private set; }
[Required]
public string Model { get; private set; } = string.Empty;
[Required]
public string StateNumber { get; private set; } = string.Empty;
[ForeignKey("AutoId")]
public virtual List<Order> Orders { get; set; } = new();
public static Auto? Create(AutoBindingModel model)
{
if (model == null)
{
return null;
}
return new Auto()
{
Id = model.Id,
Model = model.Model,
StateNumber = model.StateNumber
};
}
public static Auto Create(AutoViewModel model)
{
return new Auto
{
Id = model.Id,
Model = model.Model,
StateNumber = model.StateNumber
};
}
public void Update(AutoBindingModel model)
{
if (model == null)
{
return;
}
Model = model.Model;
StateNumber = model.StateNumber;
}
public AutoViewModel GetViewModel => new()
{
Id = Id,
Model = Model,
StateNumber = StateNumber
};
}
}

View File

@ -0,0 +1,66 @@
using SYBDContracts.BindingModels;
using SYBDContracts.ViewModels;
using SYBDDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace SYBDDatabaseImplement.Models
{
public class Client : IClientModel
{
public int Id { get; private set; }
[Required]
public string Fullname { get; private set; } = string.Empty;
[Required]
public string Phone { get; private set; } = string.Empty;
[Required]
public string Email { get; private set; } = string.Empty;
[ForeignKey("ClientId")]
public virtual List<Order> Orders { get; set; } = new();
public static Client? Create(ClientBindingModel model)
{
if (model == null)
{
return null;
}
return new Client()
{
Id = model.Id,
Fullname = model.Fullname,
Phone = model.Phone,
Email= model.Email,
};
}
public static Client Create(ClientViewModel model)
{
return new Client
{
Id = model.Id,
Fullname = model.Fullname,
Phone = model.Phone,
Email = model.Email,
};
}
public void Update(ClientBindingModel model)
{
if (model == null)
{
return;
}
Fullname = model.Fullname;
Phone = model.Phone;
Email = model.Email;
}
public ClientViewModel GetViewModel => new()
{
Id = Id,
Fullname = Fullname,
Phone = Phone,
Email = Email,
};
}
}

View File

@ -0,0 +1,68 @@
using SYBDContracts.BindingModels;
using SYBDContracts.ViewModels;
using SYBDDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace SYBDDatabaseImplement.Models
{
public class Insurance : IInsuranceModel
{
public int Id { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
[Required]
public string Address { get; private set; } = string.Empty;
[Required]
public string Phone { get; private set; } = string.Empty;
[ForeignKey("InsuranceId")]
public virtual List<Order> Orders { get; set; } = new();
public static Insurance? Create(InsuranceBindingModel model)
{
if (model == null)
{
return null;
}
return new Insurance()
{
Id = model.Id,
Name = model.Name,
Address = model.Address,
Phone = model.Phone,
};
}
public static Insurance Create(InsuranceViewModel model)
{
return new Insurance
{
Id = model.Id,
Address = model.Address,
Name = model.Name,
Phone = model.Phone,
};
}
public void Update(InsuranceBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
Address = model.Address;
Phone = model.Phone;
}
public InsuranceViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Address = Address,
Phone = Phone,
};
}
}

View File

@ -0,0 +1,73 @@
using SYBDContracts.BindingModels;
using SYBDContracts.ViewModels;
using SYBDDataModels.Models;
using System.ComponentModel.DataAnnotations;
namespace SYBDDatabaseImplement.Models
{
public class Order : IOrderModel
{
[Required]
public int AutoId { get; set; }
[Required]
public int ClientId { get; set; }
[Required]
public int InsuranceId { get; set; }
[Required]
public int WorkerId { get; set; }
[Required]
public double Price { get; set; }
[Required]
public string Description { get; private set; } = string.Empty;
[Required]
public string Status { get; set; }
public int Id { get; set; }
public virtual Auto Auto { get; set; }
public virtual Client Client { get; set; }
public virtual Insurance Insurance { get; set; }
public virtual Worker Worker { get; set; }
public static Order? Create( OrderBindingModel? model)
{
if (model == null)
return null;
return new Order()
{
Id = model.Id,
AutoId = model.AutoId,
ClientId = model.ClientId,
InsuranceId = model.InsuranceId,
WorkerId = model.WorkerId,
Price = model.Price,
Description = model.Description,
Status = model.Status,
};
}
public void Update(OrderBindingModel? model)
{
if (model == null)
return;
Status = model.Status;
}
public OrderViewModel GetViewModel => new()
{
AutoId = AutoId,
AutoModel = Auto.Model,
ClientId = ClientId,
ClientFullname = Client.Fullname,
InsuranceId = InsuranceId,
InsuranceName = Insurance.Name,
WorkerId = WorkerId,
WorkerFullname = Worker.Fullname,
Price = Price,
Description = Description,
Status = Status,
Id = Id,
};
}
}

View File

@ -0,0 +1,58 @@
using SYBDContracts.BindingModels;
using SYBDContracts.ViewModels;
using SYBDDataModels.Models;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace SYBDDatabaseImplement.Models
{
public class Worker : IWorkerModel
{
public int Id { get; set; }
[Required]
public string Fullname { get; set; } = string.Empty;
[Required]
public string Address { get; set; } = string.Empty;
[Required]
public int Salary { get; set; }
[ForeignKey("WorkerId")]
public virtual List<Order> Orders { get; set; } = new();
public static Worker Create(WorkerViewModel model)
{
return new Worker
{
Id = model.Id,
Fullname = model.Fullname,
Address = model.Address,
Salary = model.Salary,
};
}
public static Worker? Create(WorkerBindingModel model)
{
return new Worker()
{
Id = model.Id,
Fullname = model.Fullname,
Address = model.Address,
Salary = model.Salary,
};
}
public void Update(WorkerBindingModel model)
{
Fullname = model.Fullname;
Address = model.Address;
Salary = model.Salary;
}
public WorkerViewModel GetViewModel => new()
{
Id = Id,
Fullname = Fullname,
Address = Address,
Salary = Salary
};
}
}

View File

@ -0,0 +1,26 @@
using SYBDDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace SYBDDatabaseImplement
{
public class SYBDDatabase : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseNpgsql(@"Host=192.168.225.184;Database=postgres;Username=sardq;");
}
base.OnConfiguring(optionsBuilder);
}
public virtual DbSet<Auto> auto { set; get; }
public virtual DbSet<Client> client { set; get; }
public virtual DbSet<Insurance> insurance{ set; get; }
public virtual DbSet<Order> order { set; get; }
public virtual DbSet<Worker> worker { set; get; }
}
}

View File

@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.29" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.29" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.29">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.22" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SYBDContracts\SYBDContracts.csproj" />
</ItemGroup>
</Project>

125
SYBDView/FormAuto.Designer.cs generated Normal file
View File

@ -0,0 +1,125 @@
namespace SYBDView
{
partial class FormAuto
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxStateNumber = new System.Windows.Forms.TextBox();
this.labelPrice = new System.Windows.Forms.Label();
this.textBoxModel = new System.Windows.Forms.TextBox();
this.labelName = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxStateNumber
//
this.textBoxStateNumber.Location = new System.Drawing.Point(157, 99);
this.textBoxStateNumber.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.textBoxStateNumber.Name = "textBoxStateNumber";
this.textBoxStateNumber.Size = new System.Drawing.Size(257, 31);
this.textBoxStateNumber.TabIndex = 23;
//
// labelPrice
//
this.labelPrice.AutoSize = true;
this.labelPrice.Location = new System.Drawing.Point(4, 80);
this.labelPrice.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.labelPrice.Name = "labelPrice";
this.labelPrice.Size = new System.Drawing.Size(160, 50);
this.labelPrice.TabIndex = 22;
this.labelPrice.Text = "Государственный \r\nномер:";
//
// textBoxModel
//
this.textBoxModel.Location = new System.Drawing.Point(157, 30);
this.textBoxModel.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.textBoxModel.Name = "textBoxModel";
this.textBoxModel.Size = new System.Drawing.Size(358, 31);
this.textBoxModel.TabIndex = 21;
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(4, 33);
this.labelName.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(80, 25);
this.labelName.TabIndex = 20;
this.labelName.Text = "Модель:";
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(414, 162);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(126, 45);
this.buttonCancel.TabIndex = 25;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(285, 162);
this.buttonSave.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(126, 45);
this.buttonSave.TabIndex = 24;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// FormAuto
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(555, 221);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxStateNumber);
this.Controls.Add(this.labelPrice);
this.Controls.Add(this.textBoxModel);
this.Controls.Add(this.labelName);
this.Name = "FormAuto";
this.Text = "Автомобиль";
this.Load += new System.EventHandler(this.FormAuto_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxStateNumber;
private Label labelPrice;
private TextBox textBoxModel;
private Label labelName;
private Button buttonCancel;
private Button buttonSave;
}
}

88
SYBDView/FormAuto.cs Normal file
View File

@ -0,0 +1,88 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.SearchModels;
using Microsoft.Extensions.Logging;
namespace SYBDView
{
public partial class FormAuto : Form
{
private readonly ILogger _logger;
private readonly IAutoLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormAuto(ILogger<FormAuto> logger, IAutoLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormAuto_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
_logger.LogInformation("Загрузка автомобилей");
try
{
var view = _logic.ReadElement(new AutoSearchModel { Id = _id.Value });
if (view != null)
{
textBoxModel.Text = view.Model;
textBoxStateNumber.Text = view.StateNumber;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки автомобиля");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxModel.Text))
{
MessageBox.Show("Заполните модель", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxStateNumber.Text))
{
MessageBox.Show("Заполните гос номер", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение автомобиля");
try
{
var model = new AutoBindingModel
{
Id = _id ?? 0,
Model = textBoxModel.Text,
StateNumber = textBoxStateNumber.Text,
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения автомобиля");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

60
SYBDView/FormAuto.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

127
SYBDView/FormAutos.Designer.cs generated Normal file
View File

@ -0,0 +1,127 @@
namespace SYBDView
{
partial class FormAutos
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonRef = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(779, 241);
this.buttonRef.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(125, 44);
this.buttonRef.TabIndex = 19;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(779, 162);
this.buttonDel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(125, 44);
this.buttonDel.TabIndex = 18;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(779, 95);
this.buttonUpd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(125, 44);
this.buttonUpd.TabIndex = 17;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(779, 22);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(125, 44);
this.buttonAdd.TabIndex = 16;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.dataGridView.MultiSelect = false;
this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersVisible = false;
this.dataGridView.RowHeadersWidth = 62;
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView.Size = new System.Drawing.Size(767, 450);
this.dataGridView.TabIndex = 15;
//
// FormAutos
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(918, 450);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.buttonUpd);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormAutos";
this.Text = "Автомобили";
this.Load += new System.EventHandler(this.FormAutos_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Button buttonRef;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

104
SYBDView/FormAutos.cs Normal file
View File

@ -0,0 +1,104 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace SYBDView
{
public partial class FormAutos : Form
{
public FormAutos(ILogger<FormAutos> logger, IAutoLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private readonly ILogger _logger;
private readonly IAutoLogic _logic;
private void FormAutos_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Model"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка Работ");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки работ");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormAuto));
if (service is FormAuto form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormAuto));
if (service is FormAuto form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление компонента");
try
{
if (!_logic.Delete(new AutoBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

60
SYBDView/FormAutos.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

149
SYBDView/FormClient.Designer.cs generated Normal file
View File

@ -0,0 +1,149 @@
namespace SYBDView
{
partial class FormClient
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxPhone = new System.Windows.Forms.TextBox();
this.labelSalary = new System.Windows.Forms.Label();
this.textBoxEmail = new System.Windows.Forms.TextBox();
this.labelAddress = new System.Windows.Forms.Label();
this.textBoxFullname = new System.Windows.Forms.TextBox();
this.labelName = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxPhone
//
this.textBoxPhone.Location = new System.Drawing.Point(180, 137);
this.textBoxPhone.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.textBoxPhone.Name = "textBoxPhone";
this.textBoxPhone.Size = new System.Drawing.Size(294, 31);
this.textBoxPhone.TabIndex = 29;
//
// labelSalary
//
this.labelSalary.AutoSize = true;
this.labelSalary.Location = new System.Drawing.Point(5, 140);
this.labelSalary.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.labelSalary.Name = "labelSalary";
this.labelSalary.Size = new System.Drawing.Size(177, 25);
this.labelSalary.TabIndex = 28;
this.labelSalary.Text = "Телефонный номер:";
//
// textBoxEmail
//
this.textBoxEmail.Location = new System.Drawing.Point(180, 85);
this.textBoxEmail.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.textBoxEmail.Name = "textBoxEmail";
this.textBoxEmail.Size = new System.Drawing.Size(358, 31);
this.textBoxEmail.TabIndex = 27;
//
// labelAddress
//
this.labelAddress.AutoSize = true;
this.labelAddress.Location = new System.Drawing.Point(5, 91);
this.labelAddress.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.labelAddress.Name = "labelAddress";
this.labelAddress.Size = new System.Drawing.Size(66, 25);
this.labelAddress.TabIndex = 26;
this.labelAddress.Text = "Почта:";
//
// textBoxFullname
//
this.textBoxFullname.Location = new System.Drawing.Point(180, 35);
this.textBoxFullname.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.textBoxFullname.Name = "textBoxFullname";
this.textBoxFullname.Size = new System.Drawing.Size(358, 31);
this.textBoxFullname.TabIndex = 25;
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(5, 41);
this.labelName.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(56, 25);
this.labelName.TabIndex = 24;
this.labelName.Text = "ФИО:";
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(449, 237);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(126, 45);
this.buttonCancel.TabIndex = 31;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(320, 237);
this.buttonSave.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(126, 45);
this.buttonSave.TabIndex = 30;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// FormClient
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(579, 285);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxPhone);
this.Controls.Add(this.labelSalary);
this.Controls.Add(this.textBoxEmail);
this.Controls.Add(this.labelAddress);
this.Controls.Add(this.textBoxFullname);
this.Controls.Add(this.labelName);
this.Name = "FormClient";
this.Text = "Клиент";
this.Load += new System.EventHandler(this.FormClient_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxPhone;
private Label labelSalary;
private TextBox textBoxEmail;
private Label labelAddress;
private TextBox textBoxFullname;
private Label labelName;
private Button buttonCancel;
private Button buttonSave;
}
}

95
SYBDView/FormClient.cs Normal file
View File

@ -0,0 +1,95 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.SearchModels;
using Microsoft.Extensions.Logging;
namespace SYBDView
{
public partial class FormClient : Form
{
private readonly ILogger _logger;
private readonly IClientLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormClient(ILogger<FormClient> logger, IClientLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormClient_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
_logger.LogInformation("Загрузка клиентов");
try
{
var view = _logic.ReadElement(new ClientSearchModel { Id = _id.Value });
if (view != null)
{
textBoxFullname.Text = view.Fullname;
textBoxEmail.Text = view.Email;
textBoxPhone.Text = view.Phone;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки клиента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxFullname.Text))
{
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxEmail.Text))
{
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxPhone.Text))
{
MessageBox.Show("Заполните телефон", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение изделия");
try
{
var model = new ClientBindingModel
{
Id = _id ?? 0,
Fullname = textBoxFullname.Text,
Email = textBoxEmail.Text,
Phone = textBoxPhone.Text,
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

60
SYBDView/FormClient.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

127
SYBDView/FormClients.Designer.cs generated Normal file
View File

@ -0,0 +1,127 @@
namespace SYBDView
{
partial class FormClients
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonRef = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.dataGridView.MultiSelect = false;
this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersVisible = false;
this.dataGridView.RowHeadersWidth = 62;
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView.Size = new System.Drawing.Size(583, 450);
this.dataGridView.TabIndex = 6;
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(645, 241);
this.buttonRef.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(125, 44);
this.buttonRef.TabIndex = 11;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(645, 174);
this.buttonDel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(125, 44);
this.buttonDel.TabIndex = 10;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(645, 107);
this.buttonUpd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(125, 44);
this.buttonUpd.TabIndex = 14;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(645, 34);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(125, 44);
this.buttonAdd.TabIndex = 13;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// FormClients
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.buttonUpd);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.dataGridView);
this.Name = "FormClients";
this.Text = "Клиенты";
this.Load += new System.EventHandler(this.FormClients_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonRef;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
}
}

106
SYBDView/FormClients.cs Normal file
View File

@ -0,0 +1,106 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.SearchModels;
using Microsoft.Extensions.Logging;
using System.Windows.Forms;
namespace SYBDView
{
public partial class FormClients : Form
{
private readonly ILogger _logger;
private readonly IClientLogic _logic;
public FormClients(ILogger<FormClients> logger, IClientLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormClients_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Fullname"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка клиентов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки работ");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
if (service is FormClient form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClient));
if (service is FormClient form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление компонента");
try
{
if (!_logic.Delete(new ClientBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

60
SYBDView/FormClients.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

229
SYBDView/FormCreateOrder.Designer.cs generated Normal file
View File

@ -0,0 +1,229 @@
namespace SYBDView
{
partial class FormCreateOrder
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.labelSum = new System.Windows.Forms.Label();
this.labelCount = new System.Windows.Forms.Label();
this.comboBoxClient = new System.Windows.Forms.ComboBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.textBoxDescription = new System.Windows.Forms.TextBox();
this.labelWork = new System.Windows.Forms.Label();
this.comboBoxAuto = new System.Windows.Forms.ComboBox();
this.labelClient = new System.Windows.Forms.Label();
this.comboBoxWorker = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.comboBoxInsurance = new System.Windows.Forms.ComboBox();
this.label2 = new System.Windows.Forms.Label();
this.textBoxPrice = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// labelSum
//
this.labelSum.AutoSize = true;
this.labelSum.Location = new System.Drawing.Point(9, 243);
this.labelSum.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.labelSum.Name = "labelSum";
this.labelSum.Size = new System.Drawing.Size(103, 25);
this.labelSum.TabIndex = 12;
this.labelSum.Text = "Стоимость:";
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(9, 194);
this.labelCount.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(96, 25);
this.labelCount.TabIndex = 10;
this.labelCount.Text = "Описание:";
//
// comboBoxClient
//
this.comboBoxClient.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxClient.FormattingEnabled = true;
this.comboBoxClient.Location = new System.Drawing.Point(134, 59);
this.comboBoxClient.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.comboBoxClient.Name = "comboBoxClient";
this.comboBoxClient.Size = new System.Drawing.Size(359, 33);
this.comboBoxClient.TabIndex = 9;
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(367, 291);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(125, 44);
this.buttonCancel.TabIndex = 15;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(232, 291);
this.buttonSave.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(125, 44);
this.buttonSave.TabIndex = 14;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// textBoxDescription
//
this.textBoxDescription.Location = new System.Drawing.Point(134, 194);
this.textBoxDescription.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.textBoxDescription.Name = "textBoxDescription";
this.textBoxDescription.Size = new System.Drawing.Size(359, 31);
this.textBoxDescription.TabIndex = 11;
//
// labelWork
//
this.labelWork.AutoSize = true;
this.labelWork.Location = new System.Drawing.Point(9, 64);
this.labelWork.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.labelWork.Name = "labelWork";
this.labelWork.Size = new System.Drawing.Size(71, 25);
this.labelWork.TabIndex = 8;
this.labelWork.Text = "Клиент:";
//
// comboBoxAuto
//
this.comboBoxAuto.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxAuto.FormattingEnabled = true;
this.comboBoxAuto.Location = new System.Drawing.Point(134, 14);
this.comboBoxAuto.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.comboBoxAuto.Name = "comboBoxAuto";
this.comboBoxAuto.Size = new System.Drawing.Size(359, 33);
this.comboBoxAuto.TabIndex = 17;
//
// labelClient
//
this.labelClient.AutoSize = true;
this.labelClient.Location = new System.Drawing.Point(9, 19);
this.labelClient.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.labelClient.Name = "labelClient";
this.labelClient.Size = new System.Drawing.Size(118, 25);
this.labelClient.TabIndex = 16;
this.labelClient.Text = "Автомобиль:";
//
// comboBoxWorker
//
this.comboBoxWorker.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxWorker.FormattingEnabled = true;
this.comboBoxWorker.Location = new System.Drawing.Point(134, 104);
this.comboBoxWorker.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.comboBoxWorker.Name = "comboBoxWorker";
this.comboBoxWorker.Size = new System.Drawing.Size(359, 33);
this.comboBoxWorker.TabIndex = 19;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(9, 109);
this.label1.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(92, 25);
this.label1.TabIndex = 18;
this.label1.Text = "Работник:";
//
// comboBoxInsurance
//
this.comboBoxInsurance.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxInsurance.FormattingEnabled = true;
this.comboBoxInsurance.Location = new System.Drawing.Point(134, 149);
this.comboBoxInsurance.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.comboBoxInsurance.Name = "comboBoxInsurance";
this.comboBoxInsurance.Size = new System.Drawing.Size(359, 33);
this.comboBoxInsurance.TabIndex = 21;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(9, 154);
this.label2.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(101, 25);
this.label2.TabIndex = 20;
this.label2.Text = "Страховая:";
//
// textBoxPrice
//
this.textBoxPrice.Location = new System.Drawing.Point(134, 240);
this.textBoxPrice.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.textBoxPrice.Name = "textBoxPrice";
this.textBoxPrice.Size = new System.Drawing.Size(359, 31);
this.textBoxPrice.TabIndex = 22;
//
// FormCreateOrder
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(534, 352);
this.Controls.Add(this.textBoxPrice);
this.Controls.Add(this.comboBoxInsurance);
this.Controls.Add(this.label2);
this.Controls.Add(this.comboBoxWorker);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBoxAuto);
this.Controls.Add(this.labelClient);
this.Controls.Add(this.labelSum);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.comboBoxClient);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxDescription);
this.Controls.Add(this.labelWork);
this.Name = "FormCreateOrder";
this.Text = "Заказ";
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Label labelSum;
private Label labelCount;
private ComboBox comboBoxClient;
private Button buttonCancel;
private Button buttonSave;
private TextBox textBoxDescription;
private Label labelWork;
private ComboBox comboBoxAuto;
private Label labelClient;
private ComboBox comboBoxWorker;
private Label label1;
private ComboBox comboBoxInsurance;
private Label label2;
private TextBox textBoxPrice;
}
}

172
SYBDView/FormCreateOrder.cs Normal file
View File

@ -0,0 +1,172 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.SearchModels;
using Microsoft.Extensions.Logging;
using System.Windows.Forms;
namespace SYBDView
{
public partial class FormCreateOrder : Form
{
private readonly ILogger _logger;
private readonly IWorkerLogic _logicWorker;
private readonly IAutoLogic _logicAuto;
private readonly IInsuranceLogic _logicInsurance;
private readonly IOrderLogic _logicO;
private readonly IClientLogic _logicClient;
private int? _id;
public int Id { set { _id = value; } }
public FormCreateOrder(ILogger<FormCreateOrder> logger, IWorkerLogic logicW, IOrderLogic logicO, IClientLogic logicClient, IInsuranceLogic logicI, IAutoLogic autoLogic)
{
InitializeComponent();
_logger = logger;
_logicWorker = logicW;
_logicO = logicO;
_logicClient = logicClient;
_logicAuto = autoLogic;
_logicInsurance = logicI;
}
private void FormCreateOrder_Load(object sender, EventArgs e)
{
try
{
var list = _logicWorker.ReadList(null);
if (list != null)
{
comboBoxWorker.DataSource = list;
comboBoxWorker.DisplayMember = "Fullname";
comboBoxWorker.ValueMember = "Id";
comboBoxWorker.SelectedItem = null;
}
_logger.LogInformation("Загрузка работ");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки работ");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
var list = _logicClient.ReadList(null);
if (list != null)
{
comboBoxClient.DataSource = list;
comboBoxClient.DisplayMember = "Fullname";
comboBoxClient.ValueMember = "Id";
comboBoxClient.SelectedItem = null;
}
_logger.LogInformation("Загрузка клиентов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки клиентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
var list = _logicAuto.ReadList(null);
if (list != null)
{
comboBoxAuto.DataSource = list;
comboBoxAuto.DisplayMember = "Model";
comboBoxAuto.ValueMember = "Id";
comboBoxAuto.SelectedItem = null;
}
_logger.LogInformation("Загрузка клиентов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки клиентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
var list = _logicInsurance.ReadList(null);
if (list != null)
{
comboBoxInsurance.DataSource = list;
comboBoxInsurance.DisplayMember = "Name";
comboBoxInsurance.ValueMember = "Id";
comboBoxInsurance.SelectedItem = null;
}
_logger.LogInformation("Загрузка клиентов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки клиентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxDescription.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxClient.SelectedValue == null)
{
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxInsurance.SelectedValue == null)
{
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxWorker.SelectedValue == null)
{
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxAuto.SelectedValue == null)
{
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание заказа");
try
{
var operationResult = _logicO.Create(new OrderBindingModel
{
WorkerId = Convert.ToInt32(comboBoxWorker.SelectedValue),
AutoId = Convert.ToInt32(comboBoxAuto.SelectedValue),
InsuranceId = Convert.ToInt32(comboBoxInsurance.SelectedValue),
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
Description = textBoxDescription.Text,
Price = Convert.ToDouble(textBoxPrice.Text)
});
if (!operationResult)
{
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

149
SYBDView/FormInsurance.Designer.cs generated Normal file
View File

@ -0,0 +1,149 @@
namespace SYBDView
{
partial class FormInsurance
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxPhone = new System.Windows.Forms.TextBox();
this.labelSalary = new System.Windows.Forms.Label();
this.textBoxAddress = new System.Windows.Forms.TextBox();
this.labelAddress = new System.Windows.Forms.Label();
this.textBoxName = new System.Windows.Forms.TextBox();
this.labelName = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxPhone
//
this.textBoxPhone.Location = new System.Drawing.Point(182, 123);
this.textBoxPhone.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.textBoxPhone.Name = "textBoxPhone";
this.textBoxPhone.Size = new System.Drawing.Size(294, 31);
this.textBoxPhone.TabIndex = 23;
//
// labelSalary
//
this.labelSalary.AutoSize = true;
this.labelSalary.Location = new System.Drawing.Point(7, 126);
this.labelSalary.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.labelSalary.Name = "labelSalary";
this.labelSalary.Size = new System.Drawing.Size(177, 25);
this.labelSalary.TabIndex = 22;
this.labelSalary.Text = "Телефонный номер:";
//
// textBoxAddress
//
this.textBoxAddress.Location = new System.Drawing.Point(182, 71);
this.textBoxAddress.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.textBoxAddress.Name = "textBoxAddress";
this.textBoxAddress.Size = new System.Drawing.Size(358, 31);
this.textBoxAddress.TabIndex = 19;
//
// labelAddress
//
this.labelAddress.AutoSize = true;
this.labelAddress.Location = new System.Drawing.Point(7, 77);
this.labelAddress.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.labelAddress.Name = "labelAddress";
this.labelAddress.Size = new System.Drawing.Size(66, 25);
this.labelAddress.TabIndex = 18;
this.labelAddress.Text = "Адрес:";
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(182, 21);
this.textBoxName.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(358, 31);
this.textBoxName.TabIndex = 17;
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(7, 27);
this.labelName.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(94, 25);
this.labelName.TabIndex = 16;
this.labelName.Text = "Название:";
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(451, 227);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(126, 45);
this.buttonCancel.TabIndex = 21;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(322, 227);
this.buttonSave.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(126, 45);
this.buttonSave.TabIndex = 20;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// FormInsurance
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(581, 281);
this.Controls.Add(this.textBoxPhone);
this.Controls.Add(this.labelSalary);
this.Controls.Add(this.textBoxAddress);
this.Controls.Add(this.labelAddress);
this.Controls.Add(this.textBoxName);
this.Controls.Add(this.labelName);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Name = "FormInsurance";
this.Text = "Страховая";
this.Load += new System.EventHandler(this.FormInsurances_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxPhone;
private Label labelSalary;
private TextBox textBoxAddress;
private Label labelAddress;
private TextBox textBoxName;
private Label labelName;
private Button buttonCancel;
private Button buttonSave;
}
}

93
SYBDView/FormInsurance.cs Normal file
View File

@ -0,0 +1,93 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.SearchModels;
using Microsoft.Extensions.Logging;
namespace SYBDView
{
public partial class FormInsurance : Form
{
public FormInsurance(ILogger<FormWorker> logger, IInsuranceLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private readonly ILogger _logger;
private readonly IInsuranceLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
private void FormInsurances_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
_logger.LogInformation("Загрузка страховой");
try
{
var view = _logic.ReadElement(new InsuranceSearchModel { Id = _id.Value });
if (view != null)
{
textBoxName.Text = view.Name;
textBoxAddress.Text = view.Address;
textBoxPhone.Text = view.Phone;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки страховой");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxAddress.Text))
{
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxPhone.Text))
{
MessageBox.Show("Заполните телефон", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение изделия");
try
{
var model = new InsuranceBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text,
Address = textBoxAddress.Text,
Phone = textBoxPhone.Text,
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

127
SYBDView/FormInsurances.Designer.cs generated Normal file
View File

@ -0,0 +1,127 @@
namespace SYBDView
{
partial class FormInsurances
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonRef = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(802, 243);
this.buttonRef.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(125, 44);
this.buttonRef.TabIndex = 19;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(802, 164);
this.buttonDel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(125, 44);
this.buttonDel.TabIndex = 18;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(802, 97);
this.buttonUpd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(125, 44);
this.buttonUpd.TabIndex = 17;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(802, 24);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(125, 44);
this.buttonAdd.TabIndex = 16;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.dataGridView.MultiSelect = false;
this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersVisible = false;
this.dataGridView.RowHeadersWidth = 62;
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView.Size = new System.Drawing.Size(767, 447);
this.dataGridView.TabIndex = 15;
//
// FormInsurances
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(963, 447);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.buttonUpd);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormInsurances";
this.Text = "Страховые";
this.Load += new System.EventHandler(this.FormWorks_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Button buttonRef;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

104
SYBDView/FormInsurances.cs Normal file
View File

@ -0,0 +1,104 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace SYBDView
{
public partial class FormInsurances : Form
{
public FormInsurances(ILogger<FormAutos> logger, IInsuranceLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private readonly ILogger _logger;
private readonly IInsuranceLogic _logic;
private void FormWorks_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка Работ");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки работ");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormInsurance));
if (service is FormInsurance form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormInsurance));
if (service is FormInsurance form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление компонента");
try
{
if (!_logic.Delete(new InsuranceBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

242
SYBDView/FormMain.Designer.cs generated Normal file
View File

@ -0,0 +1,242 @@
namespace SYBDView
{
partial class FormMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonCreateOrder = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.автомобилиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.клиентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.работникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.страховыеToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.buttonRef = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonIssuedOrder = new System.Windows.Forms.Button();
this.buttonOrderReady = new System.Windows.Forms.Button();
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.menuStrip1.SuspendLayout();
this.SuspendLayout();
//
// buttonCreateOrder
//
this.buttonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCreateOrder.Location = new System.Drawing.Point(1081, 75);
this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonCreateOrder.Name = "buttonCreateOrder";
this.buttonCreateOrder.Size = new System.Drawing.Size(249, 45);
this.buttonCreateOrder.TabIndex = 7;
this.buttonCreateOrder.Text = "Создать заказ";
this.buttonCreateOrder.UseVisualStyleBackColor = true;
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(2, 44);
this.dataGridView.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.dataGridView.MultiSelect = false;
this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersVisible = false;
this.dataGridView.RowHeadersWidth = 62;
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView.Size = new System.Drawing.Size(1055, 533);
this.dataGridView.TabIndex = 6;
//
// menuStrip1
//
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.справочникиToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(1377, 33);
this.menuStrip1.TabIndex = 12;
this.menuStrip1.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.автомобилиToolStripMenuItem,
this.клиентыToolStripMenuItem,
this.работникиToolStripMenuItem,
this.страховыеToolStripMenuItem});
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(139, 29);
this.справочникиToolStripMenuItem.Text = "Справочники";
//
// автомобилиToolStripMenuItem
//
this.автомобилиToolStripMenuItem.Name = "автомобилиToolStripMenuItem";
this.автомобилиToolStripMenuItem.Size = new System.Drawing.Size(217, 34);
this.автомобилиToolStripMenuItem.Text = "Автомобили";
this.автомобилиToolStripMenuItem.Click += new System.EventHandler(this.АвтомобилиToolStripMenuItem_Click);
//
// клиентыToolStripMenuItem
//
this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(217, 34);
this.клиентыToolStripMenuItem.Text = "Клиенты";
this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.клиентыToolStripMenuItem_Click);
//
// работникиToolStripMenuItem
//
this.работникиToolStripMenuItem.Name = "работникиToolStripMenuItem";
this.работникиToolStripMenuItem.Size = new System.Drawing.Size(217, 34);
this.работникиToolStripMenuItem.Text = "Работники";
this.работникиToolStripMenuItem.Click += new System.EventHandler(this.РаботникиToolStripMenuItem_Click);
//
// страховыеToolStripMenuItem
//
this.страховыеToolStripMenuItem.Name = "страховыеToolStripMenuItem";
this.страховыеToolStripMenuItem.Size = new System.Drawing.Size(217, 34);
this.страховыеToolStripMenuItem.Text = "Страховые";
this.страховыеToolStripMenuItem.Click += new System.EventHandler(this.СтраховыеToolStripMenuItem_Click);
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(1081, 516);
this.buttonRef.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(249, 44);
this.buttonRef.TabIndex = 17;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(1081, 437);
this.buttonDel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(249, 44);
this.buttonDel.TabIndex = 16;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(1081, 370);
this.buttonUpd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(249, 44);
this.buttonUpd.TabIndex = 15;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonIssuedOrder
//
this.buttonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonIssuedOrder.Location = new System.Drawing.Point(1081, 283);
this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
this.buttonIssuedOrder.Size = new System.Drawing.Size(249, 45);
this.buttonIssuedOrder.TabIndex = 20;
this.buttonIssuedOrder.Text = "Заказ выдан";
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
//
// buttonOrderReady
//
this.buttonOrderReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOrderReady.Location = new System.Drawing.Point(1081, 211);
this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonOrderReady.Name = "buttonOrderReady";
this.buttonOrderReady.Size = new System.Drawing.Size(249, 45);
this.buttonOrderReady.TabIndex = 19;
this.buttonOrderReady.Text = "Заказ готов";
this.buttonOrderReady.UseVisualStyleBackColor = true;
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
//
// buttonTakeOrderInWork
//
this.buttonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(1081, 144);
this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(249, 45);
this.buttonTakeOrderInWork.TabIndex = 18;
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1377, 602);
this.Controls.Add(this.buttonIssuedOrder);
this.Controls.Add(this.buttonOrderReady);
this.Controls.Add(this.buttonTakeOrderInWork);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.buttonUpd);
this.Controls.Add(this.buttonCreateOrder);
this.Controls.Add(this.dataGridView);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
this.Name = "FormMain";
this.Text = "Ремонт труб";
this.Load += new System.EventHandler(this.FormMain_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private Button buttonCreateOrder;
private DataGridView dataGridView;
private MenuStrip menuStrip1;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem автомобилиToolStripMenuItem;
private ToolStripMenuItem клиентыToolStripMenuItem;
private ToolStripMenuItem работникиToolStripMenuItem;
private ToolStripMenuItem страховыеToolStripMenuItem;
private Button buttonRef;
private Button buttonDel;
private Button buttonUpd;
private Button buttonIssuedOrder;
private Button buttonOrderReady;
private Button buttonTakeOrderInWork;
}
}

207
SYBDView/FormMain.cs Normal file
View File

@ -0,0 +1,207 @@
using Microsoft.Extensions.Logging;
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
namespace SYBDView
{
public partial class FormMain : Form
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _orderLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["WorkerId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["AutoId"].Visible = false;
dataGridView.Columns["InsuranceId"].Visible = false;
}
_logger.LogInformation("Загрузка заказов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try
{
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка передачи заказа в работу");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonOrderReady_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try
{
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try
{
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
_logger.LogInformation("Заказ №{id} выдан", id);
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void АвтомобилиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormAutos));
if (service is FormAutos form)
{
form.ShowDialog();
}
}
private void РаботникиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormWorkers));
if (service is FormWorkers form)
{
form.ShowDialog();
}
}
private void СтраховыеToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormInsurances));
if (service is FormInsurances form)
{
form.ShowDialog();
}
}
private void ButtonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form)
{
form.ShowDialog();
LoadData();
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление компонента");
try
{
if (!_orderLogic.Delete(new OrderBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
}
}
}
}

63
SYBDView/FormMain.resx Normal file
View File

@ -0,0 +1,63 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

149
SYBDView/FormWorker.Designer.cs generated Normal file
View File

@ -0,0 +1,149 @@
namespace SYBDView
{
partial class FormWorker
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxAddress = new System.Windows.Forms.TextBox();
this.labelAddress = new System.Windows.Forms.Label();
this.textBoxFullname = new System.Windows.Forms.TextBox();
this.labelName = new System.Windows.Forms.Label();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.labelSalary = new System.Windows.Forms.Label();
this.textBoxSalary = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBoxAddress
//
this.textBoxAddress.Location = new System.Drawing.Point(126, 64);
this.textBoxAddress.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.textBoxAddress.Name = "textBoxAddress";
this.textBoxAddress.Size = new System.Drawing.Size(358, 31);
this.textBoxAddress.TabIndex = 10;
//
// labelAddress
//
this.labelAddress.AutoSize = true;
this.labelAddress.Location = new System.Drawing.Point(15, 69);
this.labelAddress.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.labelAddress.Name = "labelAddress";
this.labelAddress.Size = new System.Drawing.Size(66, 25);
this.labelAddress.TabIndex = 9;
this.labelAddress.Text = "Адрес:";
//
// textBoxFullname
//
this.textBoxFullname.Location = new System.Drawing.Point(126, 14);
this.textBoxFullname.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.textBoxFullname.Name = "textBoxFullname";
this.textBoxFullname.Size = new System.Drawing.Size(358, 31);
this.textBoxFullname.TabIndex = 8;
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(15, 19);
this.labelName.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(56, 25);
this.labelName.TabIndex = 7;
this.labelName.Text = "ФИО:";
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(459, 219);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(126, 45);
this.buttonCancel.TabIndex = 13;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(330, 219);
this.buttonSave.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(126, 45);
this.buttonSave.TabIndex = 12;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// labelSalary
//
this.labelSalary.AutoSize = true;
this.labelSalary.Location = new System.Drawing.Point(15, 118);
this.labelSalary.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
this.labelSalary.Name = "labelSalary";
this.labelSalary.Size = new System.Drawing.Size(90, 25);
this.labelSalary.TabIndex = 14;
this.labelSalary.Text = "Зарплата:";
//
// textBoxSalary
//
this.textBoxSalary.Location = new System.Drawing.Point(126, 118);
this.textBoxSalary.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
this.textBoxSalary.Name = "textBoxSalary";
this.textBoxSalary.Size = new System.Drawing.Size(227, 31);
this.textBoxSalary.TabIndex = 15;
//
// FormWorker
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(591, 267);
this.Controls.Add(this.textBoxSalary);
this.Controls.Add(this.labelSalary);
this.Controls.Add(this.textBoxAddress);
this.Controls.Add(this.labelAddress);
this.Controls.Add(this.textBoxFullname);
this.Controls.Add(this.labelName);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Name = "FormWorker";
this.Text = "Работник";
this.Load += new System.EventHandler(this.FormWork_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TextBox textBoxAddress;
private Label labelAddress;
private TextBox textBoxFullname;
private Label labelName;
private Button buttonCancel;
private Button buttonSave;
private Label labelSalary;
private TextBox textBoxSalary;
}
}

95
SYBDView/FormWorker.cs Normal file
View File

@ -0,0 +1,95 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.SearchModels;
using Microsoft.Extensions.Logging;
namespace SYBDView
{
public partial class FormWorker : Form
{
private readonly ILogger _logger;
private readonly IWorkerLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormWorker(ILogger<FormWorker> logger, IWorkerLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormWork_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
_logger.LogInformation("Загрузка работников");
try
{
var view = _logic.ReadElement(new WorkerSearchModel { Id = _id.Value });
if (view != null)
{
textBoxFullname.Text = view.Fullname;
textBoxAddress.Text = view.Address;
textBoxSalary.Text = view.Salary.ToString();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки работника");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxFullname.Text))
{
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxAddress.Text))
{
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxSalary.Text))
{
MessageBox.Show("Заполните зарплату", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение изделия");
try
{
var model = new WorkerBindingModel
{
Id = _id ?? 0,
Fullname = textBoxFullname.Text,
Address = textBoxAddress.Text,
Salary = Convert.ToInt32(textBoxSalary.Text),
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

60
SYBDView/FormWorker.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

127
SYBDView/FormWorkers.Designer.cs generated Normal file
View File

@ -0,0 +1,127 @@
namespace SYBDView
{
partial class FormWorkers
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonRef = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonAdd = new System.Windows.Forms.Button();
this.dataGridView = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(804, 246);
this.buttonRef.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(125, 44);
this.buttonRef.TabIndex = 14;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(804, 167);
this.buttonDel.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(125, 44);
this.buttonDel.TabIndex = 13;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(804, 100);
this.buttonUpd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(125, 44);
this.buttonUpd.TabIndex = 12;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(804, 27);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(125, 44);
this.buttonAdd.TabIndex = 11;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Margin = new System.Windows.Forms.Padding(5, 6, 5, 6);
this.dataGridView.MultiSelect = false;
this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersVisible = false;
this.dataGridView.RowHeadersWidth = 62;
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView.Size = new System.Drawing.Size(767, 450);
this.dataGridView.TabIndex = 10;
//
// FormWorkers
//
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(943, 450);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.buttonUpd);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormWorkers";
this.Text = "Работники";
this.Load += new System.EventHandler(this.FormWorks_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Button buttonRef;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

104
SYBDView/FormWorkers.cs Normal file
View File

@ -0,0 +1,104 @@
using SYBDContracts.BindingModels;
using SYBDContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace SYBDView
{
public partial class FormWorkers : Form
{
private readonly ILogger _logger;
private readonly IWorkerLogic _logic;
public FormWorkers(ILogger<FormAutos> logger, IWorkerLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormWorks_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Fullname"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка Работ");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки работ");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormWorker));
if (service is FormWorker form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormWorker));
if (service is FormWorker form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление компонента");
try
{
if (!_logic.Delete(new WorkerBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

60
SYBDView/FormWorkers.resx Normal file
View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

62
SYBDView/Program.cs Normal file
View File

@ -0,0 +1,62 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using SYBDBusinessLogic.BusinessLogics;
using SYBDContracts.BusinessLogicsContracts;
using SYBDContracts.StoragesContracts;
using SYBDDatabaseImplement.Implements;
namespace SYBDView
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IAutoStorage, AutoStorage>();
services.AddTransient<IWorkerStorage, WorkerStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IInsuranceStorage, InsuranceStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IAutoLogic, AutoLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IWorkerLogic, WorkerLogic>();
services.AddTransient<IInsuranceLogic, InsuranceLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormAuto>();
services.AddTransient<FormAutos>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormWorker>();
services.AddTransient<FormWorkers>();
services.AddTransient<FormInsurance>();
services.AddTransient<FormInsurances>();
services.AddTransient<FormClients>();
services.AddTransient<FormClient>();
}
}
}

24
SYBDView/SYBDView.csproj Normal file
View File

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.29">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SYBDBusinessLogic\SYBDBusinessLogic.csproj" />
<ProjectReference Include="..\SYBDDatabaseImplement\SYBDDatabaseImplement.csproj" />
</ItemGroup>
</Project>

14
SYBDView/nlog.config Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
autoReload="true" internalLogLevel="Info">
<targets>
<target xsi:type="File" name="tofile" fileName="carlog-
${shortdate}.log" />
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="tofile" />
</rules>
</nlog>
</configuration>