финал

This commit is contained in:
GokaPek 2024-02-27 19:44:44 +04:00
parent 2af5c30a4f
commit be8194ceb5
72 changed files with 1678 additions and 1714 deletions

View File

@ -7,11 +7,11 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\LawFirmContracts\LawFirmContracts.csproj" /> <ProjectReference Include="..\AbstractLawFirmContracts\AbstractLawFirmContracts\AbstractLawFirmContracts.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,24 +1,27 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels.BindingModels;
using LawFirmContracts.BusinessLogicsContracts; using AbstractLawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts; using AbstractLawFirmContracts.StoragesContracts;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmBusinessLogic.BusinessLogics namespace AbstractLawFirmBusinessLogic.BusinessLogic
{ {
public class ComponentLogic : IComponentLogic public class ComponentLogic : IComponentLogic
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IComponentStorage _componentStorage; private readonly IComponentStorage _componentStorage;
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage
public ComponentLogic(ILogger<ComponentLogic> logger, IComponentStorage componentStorage) componentStorage)
{ {
_logger = logger; _logger = logger;
_componentStorage = componentStorage; _componentStorage = componentStorage;
} }
public List<ComponentViewModel>? ReadList(ComponentSearchModel? model) public List<ComponentViewModel>? ReadList(ComponentSearchModel? model)
{ {
_logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id); _logger.LogInformation("ReadList. ComponentName:{ComponentName}.Id:{ Id}", model?.ComponentName, model?.Id);
@ -31,7 +34,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
_logger.LogInformation("ReadList. Count:{Count}", list.Count); _logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list; return list;
} }
public ComponentViewModel? ReadElement(ComponentSearchModel model) public ComponentViewModel? ReadElement(ComponentSearchModel model)
{ {
if (model == null) if (model == null)
@ -48,7 +50,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id); _logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element; return element;
} }
public bool Create(ComponentBindingModel model) public bool Create(ComponentBindingModel model)
{ {
CheckModel(model); CheckModel(model);
@ -59,7 +60,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
} }
return true; return true;
} }
public bool Update(ComponentBindingModel model) public bool Update(ComponentBindingModel model)
{ {
CheckModel(model); CheckModel(model);
@ -70,7 +70,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
} }
return true; return true;
} }
public bool Delete(ComponentBindingModel model) public bool Delete(ComponentBindingModel model)
{ {
CheckModel(model, false); CheckModel(model, false);
@ -82,8 +81,8 @@ namespace LawFirmBusinessLogic.BusinessLogics
} }
return true; return true;
} }
private void CheckModel(ComponentBindingModel model, bool withParams =
private void CheckModel(ComponentBindingModel model, bool withParams = true) true)
{ {
if (model == null) if (model == null)
{ {
@ -95,7 +94,8 @@ namespace LawFirmBusinessLogic.BusinessLogics
} }
if (string.IsNullOrEmpty(model.ComponentName)) if (string.IsNullOrEmpty(model.ComponentName))
{ {
throw new ArgumentNullException("Нет названия компонента", nameof(model.ComponentName)); throw new ArgumentNullException("Нет названия компонента",
nameof(model.ComponentName));
} }
if (model.Cost <= 0) if (model.Cost <= 0)
{ {
@ -111,5 +111,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
throw new InvalidOperationException("Компонент с таким названием уже есть"); throw new InvalidOperationException("Компонент с таким названием уже есть");
} }
} }
} }
} }

View File

@ -1,19 +1,23 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicsContracts; using AbstractLawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts; using AbstractLawFirmContracts.StoragesContracts;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmBusinessLogic.BusinessLogics namespace AbstractLawFirmBusinessLogic.BusinessLogic
{ {
public class DocumentLogic : IDocumentLogic public class DocumentLogic : IDocumentLogic
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IDocumentStorage _documentStorage; private readonly IDocumentStorage _documentStorage;
public DocumentLogic(ILogger<DocumentLogic> logger, IDocumentStorage
public DocumentLogic(ILogger<DocumentLogic> logger, IDocumentStorage documentStorage) documentStorage)
{ {
_logger = logger; _logger = logger;
_documentStorage = documentStorage; _documentStorage = documentStorage;
@ -36,7 +40,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
{ {
throw new ArgumentNullException(nameof(model)); throw new ArgumentNullException(nameof(model));
} }
_logger.LogInformation("ReadElement. ComponentName:{DocumentName}. Id:{Id}", model.DocumentName, model.Id); _logger.LogInformation("ReadElement. DocumentName:{DocumentName}.Id:{ Id}", model.DocumentName, model.Id);
var element = _documentStorage.GetElement(model); var element = _documentStorage.GetElement(model);
if (element == null) if (element == null)
{ {
@ -56,7 +60,16 @@ namespace LawFirmBusinessLogic.BusinessLogics
} }
return true; return true;
} }
public bool Update(DocumentBindingModel model)
{
CheckModel(model);
if (_documentStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(DocumentBindingModel model) public bool Delete(DocumentBindingModel model)
{ {
CheckModel(model, false); CheckModel(model, false);
@ -68,17 +81,6 @@ namespace LawFirmBusinessLogic.BusinessLogics
} }
return true; return true;
} }
public bool Update(DocumentBindingModel model)
{
CheckModel(model);
if (_documentStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
private void CheckModel(DocumentBindingModel model, bool withParams = true) private void CheckModel(DocumentBindingModel model, bool withParams = true)
{ {
if (model == null) if (model == null)
@ -91,16 +93,21 @@ namespace LawFirmBusinessLogic.BusinessLogics
} }
if (string.IsNullOrEmpty(model.DocumentName)) if (string.IsNullOrEmpty(model.DocumentName))
{ {
throw new ArgumentNullException("Нет названия компонента", nameof(model.DocumentName)); throw new ArgumentNullException("Нет названия пакета документов",
nameof(model.DocumentName));
} }
_logger.LogInformation("Component. ComponentName:{ComponentName}. Id:{Id}", model.DocumentName, model.Id); if (model.Price <= 0)
{
throw new ArgumentNullException("Цена пакета документов должна быть больше 0", nameof(model.Price));
}
_logger.LogInformation("Document. DocumentName:{DocumentName}.Cost:{ Cost}. Id: { Id}", model.DocumentName, model.Price, model.Id);
var element = _documentStorage.GetElement(new DocumentSearchModel var element = _documentStorage.GetElement(new DocumentSearchModel
{ {
DocumentName = model.DocumentName DocumentName = model.DocumentName
}); });
if (element != null && element.Id != model.Id) if (element != null && element.Id != model.Id)
{ {
throw new InvalidOperationException("Компонент с таким названием уже есть"); throw new InvalidOperationException("Пакет документов с таким названием уже есть");
} }
} }
} }

View File

@ -0,0 +1,111 @@
using AbstractLawFirmContracts.BindingModels;
using AbstractLawFirmContracts.BusinessLogicsContracts;
using AbstractLawFirmContracts.SearchModels;
using AbstractLawFirmContracts.StoragesContracts;
using AbstractLawFirmContracts.ViewModels;
using AbstractLawFirmDataModels.Enums;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractLawFirmBusinessLogic.BusinessLogic
{
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 bool CreateOrder(OrderBindingModel model)
{
CheckModel(model);
if (model.Status != OrderStatus.Неизвестен) return false;
model.Status = OrderStatus.Принят;
if (_orderStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool ChangeStatus(OrderBindingModel model, OrderStatus status)
{
CheckModel(model);
var element = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
if (element == null)
{
_logger.LogWarning("Read operation failed");
return false;
}
if (element.Status != status - 1)
{
_logger.LogWarning("Status change operation failed");
throw new InvalidOperationException("Текущий статус заказа не может быть переведен в выбранный");
}
model.Status = status;
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
_orderStorage.Update(model);
return true;
}
public bool TakeOrderInWork(OrderBindingModel model)
{
return ChangeStatus(model, OrderStatus.Выполняется);
}
public bool FinishOrder(OrderBindingModel model)
{
return ChangeStatus(model, OrderStatus.Готов);
}
public bool DeliveryOrder(OrderBindingModel model)
{
return ChangeStatus(model, OrderStatus.Выдан);
}
private void CheckModel(OrderBindingModel model, bool withParams =
true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (model.Sum <= 0)
{
throw new ArgumentNullException("Цена заказа должна быть больше 0", nameof(model.Sum));
}
if (model.Count <= 0)
{
throw new ArgumentNullException("Количество элементов в заказе должно быть больше 0", nameof(model.Count));
}
_logger.LogInformation("Order. Sum:{ Cost}. Id: { Id}", model.Sum, model.Id);
}
}
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
@ -7,8 +7,11 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\LawFirmContracts\LawFirmContracts.csproj" /> <PackageReference Include="Microsoft.Extensions.Logging.ions" Version="8.0.0" />
<ProjectReference Include="..\LawFirmDataModels\LawFirmDataModels.csproj" /> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LawFirmContracts\LawFirmContracts\LawFirmContracts.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractLawFirmContracts", "AbstractLawFirmContracts\AbstractLawFirmContracts.csproj", "{32D95EAA-926F-4BFA-A0A9-128BA0260A66}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{32D95EAA-926F-4BFA-A0A9-128BA0260A66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{32D95EAA-926F-4BFA-A0A9-128BA0260A66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{32D95EAA-926F-4BFA-A0A9-128BA0260A66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{32D95EAA-926F-4BFA-A0A9-128BA0260A66}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EA33641B-AC1E-42E6-BA74-A1A91DAF198E}
EndGlobalSection
EndGlobal

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="..\..\AbstractLawFirmDataModels\AbstractLawFirmDataModels\AbstractLawFirmDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,16 @@
using AbstractLawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractLawFirmContracts.BindingModels.BindingModels
{
public class ComponentBindingModel : IComponentModel
{
public int Id { get; set; }
public string ComponentName { get; set; } = string.Empty;
public double Cost { get; set; }
}
}

View File

@ -1,15 +1,17 @@
using LawFirmDataModels.Models; using AbstractLawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.BindingModels namespace AbstractLawFirmContracts.BindingModels
{ {
public class DocumentBindingModel : IDocumentModel public class DocumentBindingModel : IDocumentModel
{ {
public int Id { get; set; } public int Id { get; set; }
public string DocumentName { get; set; } = string.Empty; public string DocumentName { get; set; } = string.Empty;
public double Price { get; set; } public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> DocumentComponents { get; set; } = new(); public Dictionary<int, (IComponentModel, int)> DocumentComponents { get; set; } = new();
} }
} }

View File

@ -1,22 +1,21 @@
using LawFirmDataModels.Enums; using AbstractLawFirmDataModels.Enums;
using LawFirmDataModels.Models; using AbstractLawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.BindingModels namespace AbstractLawFirmContracts.BindingModels
{ {
public class OrderBindingModel : IOrderModel public class OrderBindingModel : IOrderModel
{ {
public int Id { get; set; } public int Id { get; set; }
public int DocumentId { get; set; } public int DocumentId { get; set; }
public int Count { get; set; } public int Count { get; set; }
public double Sum { get; set; } public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
} }
} }

View File

@ -1,19 +1,20 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels.BindingModels;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.BusinessLogicsContracts namespace AbstractLawFirmContracts.BusinessLogicsContracts
{ {
public interface IComponentLogic public interface IComponentLogic
{ {
List<ComponentViewModel>? ReadList(ComponentSearchModel? model); List<ComponentViewModel>? ReadList(ComponentSearchModel? model);
ComponentViewModel? ReadElement(ComponentSearchModel model); ComponentViewModel? ReadElement(ComponentSearchModel model);
bool Create(ComponentBindingModel model); bool Create(ComponentBindingModel model);
bool Update(ComponentBindingModel model); bool Update(ComponentBindingModel model);
bool Delete(ComponentBindingModel model); bool Delete(ComponentBindingModel model);
} }
} }

View File

@ -1,19 +1,20 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.BusinessLogicsContracts namespace AbstractLawFirmContracts.BusinessLogicsContracts
{ {
public interface IDocumentLogic public interface IDocumentLogic
{ {
List<DocumentViewModel>? ReadList(DocumentSearchModel? model); List<DocumentViewModel>? ReadList(DocumentSearchModel? model);
DocumentViewModel? ReadElement(DocumentSearchModel model); DocumentViewModel? ReadElement(DocumentSearchModel model);
bool Create(DocumentBindingModel model); bool Create(DocumentBindingModel model);
bool Update(DocumentBindingModel model); bool Update(DocumentBindingModel model);
bool Delete(DocumentBindingModel model); bool Delete(DocumentBindingModel model);
} }
} }

View File

@ -1,19 +1,20 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.BusinessLogicsContracts namespace AbstractLawFirmContracts.BusinessLogicsContracts
{ {
public interface IOrderLogic public interface IOrderLogic
{ {
List<OrderViewModel>? ReadList(OrderSearchModel? model); List<OrderViewModel>? ReadList(OrderSearchModel? model);
bool CreateOrder(OrderBindingModel model); bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model); bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model); bool FinishOrder(OrderBindingModel model);
bool DeliveryOrder(OrderBindingModel model); bool DeliveryOrder(OrderBindingModel model);
} }
} }

View File

@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\LawFirmDataModels\LawFirmDataModels.csproj" /> <ProjectReference Include="..\..\LawFirmDataModels\LawFirmDataModels\LawFirmDataModels.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractLawFirmContracts.SearchModels
{
public class ComponentSearchModel
{
public int? Id { get; set; }
public string? ComponentName { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractLawFirmContracts.SearchModels
{
public class DocumentSearchModel
{
public int? Id { get; set; }
public string? DocumentName { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractLawFirmContracts.SearchModels
{
public class OrderSearchModel
{
public int? Id { get; set; }
}
}

View File

@ -1,21 +1,21 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels.BindingModels;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.StoragesContracts namespace AbstractLawFirmContracts.StoragesContracts
{ {
public interface IComponentStorage public interface IComponentStorage
{ {
List<ComponentViewModel> GetFullList(); List<ComponentViewModel> GetFullList();
List<ComponentViewModel> GetFilteredList(ComponentSearchModel model); List<ComponentViewModel> GetFilteredList(ComponentSearchModel model);
ComponentViewModel? GetElement(ComponentSearchModel model); ComponentViewModel? GetElement(ComponentSearchModel model);
ComponentViewModel? Insert(ComponentBindingModel model); ComponentViewModel? Insert(ComponentBindingModel model);
ComponentViewModel? Update(ComponentBindingModel model); ComponentViewModel? Update(ComponentBindingModel model);
ComponentViewModel? Delete(ComponentBindingModel model); ComponentViewModel? Delete(ComponentBindingModel model);
} }
} }

View File

@ -1,21 +1,21 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.SearchModels;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.ViewModels;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.BindingModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.StoragesContracts namespace AbstractLawFirmContracts.StoragesContracts
{ {
public interface IDocumentStorage public interface IDocumentStorage
{ {
List<DocumentViewModel> GetFullList(); List<DocumentViewModel> GetFullList();
List<DocumentViewModel> GetFilteredList(DocumentSearchModel model); List<DocumentViewModel> GetFilteredList(DocumentSearchModel model);
DocumentViewModel? GetElement(DocumentSearchModel model); DocumentViewModel? GetElement(DocumentSearchModel model);
DocumentViewModel? Insert(DocumentBindingModel model); DocumentViewModel? Insert(DocumentBindingModel model);
DocumentViewModel? Update(DocumentBindingModel model); DocumentViewModel? Update(DocumentBindingModel model);
DocumentViewModel? Delete(DocumentBindingModel model); DocumentViewModel? Delete(DocumentBindingModel model);
} }
} }

View File

@ -1,21 +1,21 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.StoragesContracts namespace AbstractLawFirmContracts.StoragesContracts
{ {
public interface IOrderStorage public interface IOrderStorage
{ {
List<OrderViewModel> GetFullList(); List<OrderViewModel> GetFullList();
List<OrderViewModel> GetFilteredList(OrderSearchModel model); List<OrderViewModel> GetFilteredList(OrderSearchModel model);
OrderViewModel? GetElement(OrderSearchModel model); OrderViewModel? GetElement(OrderSearchModel model);
OrderViewModel? Insert(OrderBindingModel model); OrderViewModel? Insert(OrderBindingModel model);
OrderViewModel? Update(OrderBindingModel model); OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model); OrderViewModel? Delete(OrderBindingModel model);
} }
} }

View File

@ -1,15 +1,18 @@
using LawFirmDataModels.Models; using AbstractLawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.ViewModels namespace AbstractLawFirmContracts.ViewModels
{ {
public class ComponentViewModel : IComponentModel public class ComponentViewModel : IComponentModel
{ {
public int Id { get; set; } public int Id { get; set; }
[DisplayName("Название компонента")] [DisplayName("Название компонента")]
public string ComponentName { get; set; } = string.Empty; public string ComponentName { get; set; } = string.Empty;
[DisplayName("Цена")] [DisplayName("Цена")]
public double Cost { get; set; } public double Cost { get; set; }
} }

View File

@ -0,0 +1,25 @@
using AbstractLawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractLawFirmContracts.ViewModels
{
public class DocumentViewModel : IDocumentModel
{
public int Id { get; set; }
[DisplayName("Название пакета документов")]
public string DocumentName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> DocumentComponents
{
get;
set;
} = new();
}
}

View File

@ -1,31 +1,29 @@
using LawFirmDataModels.Enums; using AbstractLawFirmDataModels.Enums;
using LawFirmDataModels.Models; using AbstractLawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmContracts.ViewModels namespace AbstractLawFirmContracts.ViewModels
{ {
public class OrderViewModel : IOrderModel public class OrderViewModel : IOrderModel
{ {
[DisplayName("Номер")] [DisplayName("Номер")]
public int Id { get; set; } public int Id { get; set; }
public int DocumentId { get; set; } public int DocumentId { get; set; }
[DisplayName("Пакет документов")]
[DisplayName("Изделие")]
public string DocumentName { get; set; } = string.Empty; public string DocumentName { get; set; } = string.Empty;
[DisplayName("Количество")] [DisplayName("Количество")]
public int Count { get; set; } public int Count { get; set; }
[DisplayName("Сумма")] [DisplayName("Сумма")]
public double Sum { get; set; } public double Sum { get; set; }
[DisplayName("Статус")] [DisplayName("Статус")]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DisplayName("Дата создания")] [DisplayName("Дата создания")]
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Дата выполнения")] [DisplayName("Дата выполнения")]
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
} }

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractLawFirmDataModels", "AbstractLawFirmDataModels\AbstractLawFirmDataModels.csproj", "{9CA9492B-F2F5-40A3-821B-F7EC14AEFE5D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9CA9492B-F2F5-40A3-821B-F7EC14AEFE5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9CA9492B-F2F5-40A3-821B-F7EC14AEFE5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CA9492B-F2F5-40A3-821B-F7EC14AEFE5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CA9492B-F2F5-40A3-821B-F7EC14AEFE5D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3F1F2B80-1FE8-42C3-9167-E2E50274FE15}
EndGlobalSection
EndGlobal

View File

@ -1,15 +1,17 @@
namespace LawFirmDataModels.Enums using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractLawFirmDataModels.Enums
{ {
public enum OrderStatus public enum OrderStatus
{ {
Неизвестен = -1, Неизвестен = -1,
Принят = 0, Принят = 0,
Выполняется = 1, Выполняется = 1,
Готов = 2, Готов = 2,
Выдан = 3 Выдан = 3
} }
} }

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AbstractLawFirmDataModels
{
public interface IId
{
int Id { 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,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractLawFirmDataModels;
namespace AbstractLawFirmDataModels.Models
{
public interface IComponentModel : IId
{
string ComponentName { get; }
double Cost { get; }
}
}

View File

@ -1,11 +1,16 @@
namespace LawFirmDataModels.Models using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AbstractLawFirmDataModels;
namespace AbstractLawFirmDataModels.Models
{ {
public interface IDocumentModel : IId public interface IDocumentModel : IId
{ {
string DocumentName { get; } string DocumentName { get; }
double Price { get; } double Price { get; }
Dictionary<int, (IComponentModel, int)> DocumentComponents { get; } Dictionary<int, (IComponentModel, int)> DocumentComponents { get; }
} }
} }

View File

@ -1,19 +1,21 @@
using LawFirmDataModels.Enums; using AbstractLawFirmDataModels;
using AbstractLawFirmDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmDataModels.Models namespace AbstractLawFirmDataModels.Models
{ {
public interface IOrderModel : IId public interface IOrderModel : IId
{ {
int DocumentId { get; } int DocumentId { get; }
int Count { get; } int Count { get; }
double Sum { get; } double Sum { get; }
OrderStatus Status { get; } OrderStatus Status { get; }
DateTime DateCreate { get; } DateTime DateCreate { get; }
DateTime? DateImplement { get; } DateTime? DateImplement { get; }
} }
} }

View File

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

View File

@ -1,31 +1,30 @@
using LawFirmListImplement.Models; using AbstractLawFirmListImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmListImplement namespace AbstractLawFirmListImplement
{ {
internal class DataListSingleton public class DataListSingleton
{ {
private static DataListSingleton? _instance; private static DataListSingleton? _instance;
public List<Component> Components { get; set; } public List<Component> Components { get; set; }
public List<Order> Orders { get; set; } public List<Order> Orders { get; set; }
public List<Document> Documents { get; set; } public List<Document> Documents { get; set; }
private DataListSingleton() private DataListSingleton()
{ {
Components = new List<Component>(); Components = new List<Component>();
Orders = new List<Order>(); Orders = new List<Order>();
Documents = new List<Document>(); Documents = new List<Document>();
} }
public static DataListSingleton GetInstance() public static DataListSingleton GetInstance()
{ {
if (_instance == null) if (_instance == null)
{ {
_instance = new DataListSingleton(); _instance = new DataListSingleton();
} }
return _instance; return _instance;
} }
} }

View File

@ -1,20 +1,23 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels.BindingModels;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts; using AbstractLawFirmContracts.StoragesContracts;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using LawFirmListImplement.Models; using AbstractLawFirmListImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmListImplement.Implements namespace AbstractLawFirmListImplement.Implements
{ {
public class ComponentStorage : IComponentStorage public class ComponentStorage : IComponentStorage
{ {
private readonly DataListSingleton _source; private readonly DataListSingleton _source;
public ComponentStorage() public ComponentStorage()
{ {
_source = DataListSingleton.GetInstance(); _source = DataListSingleton.GetInstance();
} }
public List<ComponentViewModel> GetFullList() public List<ComponentViewModel> GetFullList()
{ {
var result = new List<ComponentViewModel>(); var result = new List<ComponentViewModel>();
@ -24,8 +27,8 @@ namespace LawFirmListImplement.Implements
} }
return result; return result;
} }
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model) model)
{ {
var result = new List<ComponentViewModel>(); var result = new List<ComponentViewModel>();
if (string.IsNullOrEmpty(model.ComponentName)) if (string.IsNullOrEmpty(model.ComponentName))
@ -41,7 +44,6 @@ namespace LawFirmListImplement.Implements
} }
return result; return result;
} }
public ComponentViewModel? GetElement(ComponentSearchModel model) public ComponentViewModel? GetElement(ComponentSearchModel model)
{ {
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
@ -50,7 +52,8 @@ namespace LawFirmListImplement.Implements
} }
foreach (var component in _source.Components) foreach (var component in _source.Components)
{ {
if ((!string.IsNullOrEmpty(model.ComponentName) && component.ComponentName == model.ComponentName) || if ((!string.IsNullOrEmpty(model.ComponentName) &&
component.ComponentName == model.ComponentName) ||
(model.Id.HasValue && component.Id == model.Id)) (model.Id.HasValue && component.Id == model.Id))
{ {
return component.GetViewModel; return component.GetViewModel;
@ -58,7 +61,6 @@ namespace LawFirmListImplement.Implements
} }
return null; return null;
} }
public ComponentViewModel? Insert(ComponentBindingModel model) public ComponentViewModel? Insert(ComponentBindingModel model)
{ {
model.Id = 1; model.Id = 1;
@ -77,7 +79,6 @@ namespace LawFirmListImplement.Implements
_source.Components.Add(newComponent); _source.Components.Add(newComponent);
return newComponent.GetViewModel; return newComponent.GetViewModel;
} }
public ComponentViewModel? Update(ComponentBindingModel model) public ComponentViewModel? Update(ComponentBindingModel model)
{ {
foreach (var component in _source.Components) foreach (var component in _source.Components)
@ -90,7 +91,6 @@ namespace LawFirmListImplement.Implements
} }
return null; return null;
} }
public ComponentViewModel? Delete(ComponentBindingModel model) public ComponentViewModel? Delete(ComponentBindingModel model)
{ {
for (int i = 0; i < _source.Components.Count; ++i) for (int i = 0; i < _source.Components.Count; ++i)

View File

@ -1,10 +1,16 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.BindingModels.BindingModels;
using LawFirmContracts.StoragesContracts; using AbstractLawFirmContracts.SearchModels;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.StoragesContracts;
using LawFirmListImplement.Models; using AbstractLawFirmContracts.ViewModels;
using AbstractLawFirmListImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmListImplement.Implements namespace AbstractLawFirmListImplement.Implements
{ {
public class DocumentStorage : IDocumentStorage public class DocumentStorage : IDocumentStorage
{ {
@ -16,24 +22,25 @@ namespace LawFirmListImplement.Implements
public List<DocumentViewModel> GetFullList() public List<DocumentViewModel> GetFullList()
{ {
var result = new List<DocumentViewModel>(); var result = new List<DocumentViewModel>();
foreach (var sushi in _source.Documents) foreach (var document in _source.Documents)
{ {
result.Add(sushi.GetViewModel); result.Add(document.GetViewModel);
} }
return result; return result;
} }
public List<DocumentViewModel> GetFilteredList(DocumentSearchModel model) public List<DocumentViewModel> GetFilteredList(DocumentSearchModel
model)
{ {
var result = new List<DocumentViewModel>(); var result = new List<DocumentViewModel>();
if (string.IsNullOrEmpty(model.DocumentName)) if (string.IsNullOrEmpty(model.DocumentName))
{ {
return result; return result;
} }
foreach (var sushi in _source.Documents) foreach (var document in _source.Documents)
{ {
if (sushi.DocumentName.Contains(model.DocumentName)) if (document.DocumentName.Contains(model.DocumentName))
{ {
result.Add(sushi.GetViewModel); result.Add(document.GetViewModel);
} }
} }
return result; return result;
@ -44,13 +51,13 @@ namespace LawFirmListImplement.Implements
{ {
return null; return null;
} }
foreach (var sushi in _source.Documents) foreach (var document in _source.Documents)
{ {
if ((!string.IsNullOrEmpty(model.DocumentName) && if ((!string.IsNullOrEmpty(model.DocumentName) &&
sushi.DocumentName == model.DocumentName) || document.DocumentName == model.DocumentName) ||
(model.Id.HasValue && sushi.Id == model.Id)) (model.Id.HasValue && document.Id == model.Id))
{ {
return sushi.GetViewModel; return document.GetViewModel;
} }
} }
return null; return null;
@ -58,11 +65,11 @@ namespace LawFirmListImplement.Implements
public DocumentViewModel? Insert(DocumentBindingModel model) public DocumentViewModel? Insert(DocumentBindingModel model)
{ {
model.Id = 1; model.Id = 1;
foreach (var sushi in _source.Documents) foreach (var document in _source.Documents)
{ {
if (model.Id <= sushi.Id) if (model.Id <= document.Id)
{ {
model.Id = sushi.Id + 1; model.Id = document.Id + 1;
} }
} }
var newDocument = Document.Create(model); var newDocument = Document.Create(model);
@ -75,12 +82,12 @@ namespace LawFirmListImplement.Implements
} }
public DocumentViewModel? Update(DocumentBindingModel model) public DocumentViewModel? Update(DocumentBindingModel model)
{ {
foreach (var sushi in _source.Documents) foreach (var document in _source.Documents)
{ {
if (sushi.Id == model.Id) if (document.Id == model.Id)
{ {
sushi.Update(model); document.Update(model);
return sushi.GetViewModel; return document.GetViewModel;
} }
} }
return null; return null;

View File

@ -1,10 +1,15 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts; using AbstractLawFirmContracts.ViewModels;
using LawFirmContracts.ViewModels; using AbstractLawFirmListImplement.Models;
using LawFirmListImplement.Models; using AbstractLawFirmContracts.StoragesContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmListImplement.Implements namespace AbstractLawFirmListImplement.Implements
{ {
public class OrderStorage : IOrderStorage public class OrderStorage : IOrderStorage
{ {
@ -18,13 +23,25 @@ namespace LawFirmListImplement.Implements
var result = new List<OrderViewModel>(); var result = new List<OrderViewModel>();
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
result.Add(order.GetViewModel); result.Add(AccessDocumentStorage(order.GetViewModel));
} }
return result; return result;
} }
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel
model)
{ {
var result = new List<OrderViewModel>(); var result = new List<OrderViewModel>();
if (!model.Id.HasValue)
{
return result;
}
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
{
result.Add(AccessDocumentStorage(order.GetViewModel));
}
}
return result; return result;
} }
public OrderViewModel? GetElement(OrderSearchModel model) public OrderViewModel? GetElement(OrderSearchModel model)
@ -85,5 +102,17 @@ namespace LawFirmListImplement.Implements
} }
return null; return null;
} }
public OrderViewModel AccessDocumentStorage(OrderViewModel model)
{
foreach (var document in _source.Documents)
{
if (document.Id == model.DocumentId)
{
model.DocumentName = document.DocumentName;
break;
}
}
return model;
}
} }
} }

View File

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\AbstractLawFirmContracts\AbstractLawFirmContracts\LawFirmContracts.csproj" />
<ProjectReference Include="..\AbstractLawFirmDataModels\AbstractLawFirmDataModels\LawFirmDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -1,17 +1,19 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels.BindingModels;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using LawFirmDataModels.Models; using AbstractLawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmListImplement.Models namespace AbstractLawFirmListImplement.Models
{ {
internal class Component : IComponentModel public class Component : IComponentModel
{ {
public int Id { get; private set; } public int Id { get; private set; }
public string ComponentName { get; private set; } = string.Empty; public string ComponentName { get; private set; } = string.Empty;
public double Cost { get; set; } public double Cost { get; set; }
public static Component? Create(ComponentBindingModel? model) public static Component? Create(ComponentBindingModel? model)
{ {
if (model == null) if (model == null)
@ -25,7 +27,6 @@ namespace LawFirmListImplement.Models
Cost = model.Cost Cost = model.Cost
}; };
} }
public void Update(ComponentBindingModel? model) public void Update(ComponentBindingModel? model)
{ {
if (model == null) if (model == null)
@ -35,12 +36,12 @@ namespace LawFirmListImplement.Models
ComponentName = model.ComponentName; ComponentName = model.ComponentName;
Cost = model.Cost; Cost = model.Cost;
} }
public ComponentViewModel GetViewModel => new() public ComponentViewModel GetViewModel => new()
{ {
Id = Id, Id = Id,
ComponentName = ComponentName, ComponentName = ComponentName,
Cost = Cost Cost = Cost
}; };
} }
} }

View File

@ -1,19 +1,24 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using LawFirmDataModels.Models; using AbstractLawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmListImplement.Models namespace AbstractLawFirmListImplement.Models
{ {
internal class Document : IDocumentModel public class Document : IDocumentModel
{ {
public int Id { get; private set; } public int Id { get; private set; }
public string DocumentName { get; private set; } = string.Empty; public string DocumentName { get; private set; } = string.Empty;
public double Price { get; private set; } public double Price { get; private set; }
public Dictionary<int, (IComponentModel, int)> DocumentComponents
public Dictionary<int, (IComponentModel, int)> DocumentComponents { get; private set; } = new Dictionary<int, (IComponentModel, int)>(); {
get;
private set;
} = new Dictionary<int, (IComponentModel, int)>();
public static Document? Create(DocumentBindingModel? model) public static Document? Create(DocumentBindingModel? model)
{ {
if (model == null) if (model == null)
@ -22,13 +27,13 @@ namespace LawFirmListImplement.Models
} }
return new Document() return new Document()
{ {
Id = model.Id, Id = model.Id,
DocumentName = model.DocumentName, DocumentName = model.DocumentName,
Price = model.Price, Price = model.Price,
DocumentComponents = model.DocumentComponents DocumentComponents = model.DocumentComponents
}; };
} }
public void Update(DocumentBindingModel? model) public void Update(DocumentBindingModel? model)
{ {
if (model == null) if (model == null)
@ -39,7 +44,6 @@ namespace LawFirmListImplement.Models
Price = model.Price; Price = model.Price;
DocumentComponents = model.DocumentComponents; DocumentComponents = model.DocumentComponents;
} }
public DocumentViewModel GetViewModel => new() public DocumentViewModel GetViewModel => new()
{ {
Id = Id, Id = Id,

View File

@ -1,9 +1,14 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using LawFirmDataModels.Enums; using AbstractLawFirmDataModels.Enums;
using LawFirmDataModels.Models; using AbstractLawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmListImplement.Models namespace AbstractLawFirmListImplement.Models
{ {
public class Order : IOrderModel public class Order : IOrderModel
{ {
@ -11,7 +16,7 @@ namespace LawFirmListImplement.Models
public int DocumentId { get; private set; } public int DocumentId { get; private set; }
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; private set; }
public DateTime DateCreate { get; private set; } public DateTime DateCreate { get; private set; }
public DateTime? DateImplement { get; private set; } public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model) public static Order? Create(OrderBindingModel? model)
@ -28,7 +33,7 @@ namespace LawFirmListImplement.Models
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
DateCreate = model.DateCreate, DateCreate = model.DateCreate,
DateImplement = model.DateImplement DateImplement = model.DateImplement,
}; };
} }
public void Update(OrderBindingModel? model) public void Update(OrderBindingModel? model)
@ -37,10 +42,12 @@ namespace LawFirmListImplement.Models
{ {
return; return;
} }
Id = model.Id;
DocumentId = model.DocumentId; DocumentId = model.DocumentId;
Count = model.Count; Count = model.Count;
Sum = model.Sum; Sum = model.Sum;
Status = model.Status; Status = model.Status;
DateCreate = model.DateCreate;
DateImplement = model.DateImplement; DateImplement = model.DateImplement;
} }
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel => new()
@ -51,7 +58,8 @@ namespace LawFirmListImplement.Models
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,
DateCreate = DateCreate, DateCreate = DateCreate,
DateImplement = DateImplement DateImplement = DateImplement,
}; };
} }
} }

View File

@ -1,17 +1,17 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.2.32616.157 VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmView", "LawFirmView\LawFirmView.csproj", "{30272FA6-ABB7-4436-AFC6-50478DF2B878}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmView", "LawFirmView\LawFirmView.csproj", "{32CEC3FF-22BE-4DCD-8955-E3B14953EA67}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmDataModels", "LawFirmDataModels\LawFirmDataModels.csproj", "{E47BFE5D-69E3-4A3F-85BE-251F10EAFA02}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractLawFirmDataModels", "AbstractLawFirmDataModels\AbstractLawFirmDataModels\AbstractLawFirmDataModels.csproj", "{99CE17B9-0CCE-42B6-B73F-61E8D49F1AAB}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmContracts", "LawFirmContracts\LawFirmContracts.csproj", "{9AD66AC2-51DF-4E16-83E9-35C1CA19E774}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbstractLawFirmContracts", "AbstractLawFirmContracts\AbstractLawFirmContracts\AbstractLawFirmContracts.csproj", "{C0155B2E-5974-4835-996B-6FDF0F5BC06B}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmListImplement", "LawFirmListImplement\LawFirmListImplement.csproj", "{74283CE4-7CE6-42AC-AA8D-EE4497E08D61}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractLawFirmBusinessLogic", "AbstractLawFirmBusinessLogic\AbstractLawFirmBusinessLogic.csproj", "{E48808B1-5381-4774-97B6-CDB107DCF98C}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmBusinessLogic", "LawFirmBusinessLogic\LawFirmBusinessLogic.csproj", "{9A10E59F-081B-4C4D-AB16-15A777B66502}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractLawFirmListImplement", "AbstractLawFirmListImplement\AbstractLawFirmListImplement.csproj", "{86D5FC6F-B262-44A0-9D30-970F9EA93E0A}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -19,31 +19,31 @@ Global
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{30272FA6-ABB7-4436-AFC6-50478DF2B878}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {32CEC3FF-22BE-4DCD-8955-E3B14953EA67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{30272FA6-ABB7-4436-AFC6-50478DF2B878}.Debug|Any CPU.Build.0 = Debug|Any CPU {32CEC3FF-22BE-4DCD-8955-E3B14953EA67}.Debug|Any CPU.Build.0 = Debug|Any CPU
{30272FA6-ABB7-4436-AFC6-50478DF2B878}.Release|Any CPU.ActiveCfg = Release|Any CPU {32CEC3FF-22BE-4DCD-8955-E3B14953EA67}.Release|Any CPU.ActiveCfg = Release|Any CPU
{30272FA6-ABB7-4436-AFC6-50478DF2B878}.Release|Any CPU.Build.0 = Release|Any CPU {32CEC3FF-22BE-4DCD-8955-E3B14953EA67}.Release|Any CPU.Build.0 = Release|Any CPU
{E47BFE5D-69E3-4A3F-85BE-251F10EAFA02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {99CE17B9-0CCE-42B6-B73F-61E8D49F1AAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E47BFE5D-69E3-4A3F-85BE-251F10EAFA02}.Debug|Any CPU.Build.0 = Debug|Any CPU {99CE17B9-0CCE-42B6-B73F-61E8D49F1AAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E47BFE5D-69E3-4A3F-85BE-251F10EAFA02}.Release|Any CPU.ActiveCfg = Release|Any CPU {99CE17B9-0CCE-42B6-B73F-61E8D49F1AAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E47BFE5D-69E3-4A3F-85BE-251F10EAFA02}.Release|Any CPU.Build.0 = Release|Any CPU {99CE17B9-0CCE-42B6-B73F-61E8D49F1AAB}.Release|Any CPU.Build.0 = Release|Any CPU
{9AD66AC2-51DF-4E16-83E9-35C1CA19E774}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {C0155B2E-5974-4835-996B-6FDF0F5BC06B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9AD66AC2-51DF-4E16-83E9-35C1CA19E774}.Debug|Any CPU.Build.0 = Debug|Any CPU {C0155B2E-5974-4835-996B-6FDF0F5BC06B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9AD66AC2-51DF-4E16-83E9-35C1CA19E774}.Release|Any CPU.ActiveCfg = Release|Any CPU {C0155B2E-5974-4835-996B-6FDF0F5BC06B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9AD66AC2-51DF-4E16-83E9-35C1CA19E774}.Release|Any CPU.Build.0 = Release|Any CPU {C0155B2E-5974-4835-996B-6FDF0F5BC06B}.Release|Any CPU.Build.0 = Release|Any CPU
{74283CE4-7CE6-42AC-AA8D-EE4497E08D61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {E48808B1-5381-4774-97B6-CDB107DCF98C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74283CE4-7CE6-42AC-AA8D-EE4497E08D61}.Debug|Any CPU.Build.0 = Debug|Any CPU {E48808B1-5381-4774-97B6-CDB107DCF98C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74283CE4-7CE6-42AC-AA8D-EE4497E08D61}.Release|Any CPU.ActiveCfg = Release|Any CPU {E48808B1-5381-4774-97B6-CDB107DCF98C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74283CE4-7CE6-42AC-AA8D-EE4497E08D61}.Release|Any CPU.Build.0 = Release|Any CPU {E48808B1-5381-4774-97B6-CDB107DCF98C}.Release|Any CPU.Build.0 = Release|Any CPU
{9A10E59F-081B-4C4D-AB16-15A777B66502}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {86D5FC6F-B262-44A0-9D30-970F9EA93E0A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A10E59F-081B-4C4D-AB16-15A777B66502}.Debug|Any CPU.Build.0 = Debug|Any CPU {86D5FC6F-B262-44A0-9D30-970F9EA93E0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A10E59F-081B-4C4D-AB16-15A777B66502}.Release|Any CPU.ActiveCfg = Release|Any CPU {86D5FC6F-B262-44A0-9D30-970F9EA93E0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A10E59F-081B-4C4D-AB16-15A777B66502}.Release|Any CPU.Build.0 = Release|Any CPU {86D5FC6F-B262-44A0-9D30-970F9EA93E0A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D1C13B06-DBB7-43DC-A4E9-5DAD170460D6} SolutionGuid = {F9226BA1-1E7A-4E32-A0D3-BB8E1CF929E3}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@ -1,60 +0,0 @@
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts;
using LawFirmContracts.ViewModels;
using LawFirmDataModels.Enums;
using Microsoft.Extensions.Logging;
namespace LawFirmBusinessLogic.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 bool CreateOrder(OrderBindingModel model)
{
if (_orderStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
model.Status = OrderStatus.Неизвестен;
return true;
}
public bool DeliveryOrder(OrderBindingModel model)
{
_logger.LogInformation("Delivery. Id:{Id}", model.Id);
model.Status = OrderStatus.Готов;
return _orderStorage.Update(model) != null;
}
public bool FinishOrder(OrderBindingModel model)
{
model.Status = OrderStatus.Выдан;
return _orderStorage.Update(model) != null;
}
public bool TakeOrderInWork(OrderBindingModel model)
{
model.Status = OrderStatus.Выполняется;
return _orderStorage.Update(model) != null;
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{
if (model == null)
{
return _orderStorage.GetFullList();
}
return _orderStorage.GetFilteredList(model);
}
}
}

View File

@ -1,13 +0,0 @@
using LawFirmDataModels.Models;
namespace LawFirmContracts.BindingModels
{
public class ComponentBindingModel : IComponentModel
{
public int Id { get; set; }
public string ComponentName { get; set; } = string.Empty;
public double Cost { get; set; }
}
}

View File

@ -1,9 +0,0 @@
namespace LawFirmContracts.SearchModels
{
public class ComponentSearchModel
{
public int? Id { get; set; }
public string? ComponentName { get; set; }
}
}

View File

@ -1,9 +0,0 @@
namespace LawFirmContracts.SearchModels
{
public class DocumentSearchModel
{
public int? Id { get; set; }
public string? DocumentName { get; set; }
}
}

View File

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

View File

@ -1,18 +0,0 @@
using LawFirmDataModels.Models;
using System.ComponentModel;
namespace LawFirmContracts.ViewModels
{
public class DocumentViewModel : IDocumentModel
{
public int Id { get; set; }
[DisplayName("Название изделия")]
public string DocumentName { get; set; } = string.Empty;
[DisplayName("Цена")]
public double Price { get; set; }
public Dictionary<int, (IComponentModel, int)> DocumentComponents { get; set; } = new();
}
}

View File

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

View File

@ -1,9 +0,0 @@
namespace LawFirmDataModels.Models
{
public interface IComponentModel : IId
{
string ComponentName { get; }
double Cost { get; }
}
}

View File

@ -1,20 +1,25 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels.BindingModels;
using LawFirmContracts.BusinessLogicsContracts; using AbstractLawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.SearchModels; using AbstractLawFirmContracts.SearchModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LawFirmView namespace LawFirmView
{ {
public partial class FormComponent : Form public partial class FormComponent : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IComponentLogic _logic; private readonly IComponentLogic _logic;
private int? _id; private int? _id;
public int Id { set { _id = value; } } public int Id { set { _id = value; } }
public FormComponent(ILogger<FormComponent> logger, IComponentLogic logic) public FormComponent(ILogger<FormComponent> logger, IComponentLogic logic)
{ {
InitializeComponent(); InitializeComponent();
@ -29,7 +34,11 @@ namespace LawFirmView
try try
{ {
_logger.LogInformation("Получение компонента"); _logger.LogInformation("Получение компонента");
var view = _logic.ReadElement(new ComponentSearchModel { Id = _id.Value }); var view = _logic.ReadElement(new ComponentSearchModel
{
Id =
_id.Value
});
if (view != null) if (view != null)
{ {
textBoxName.Text = view.ComponentName; textBoxName.Text = view.ComponentName;
@ -39,16 +48,18 @@ namespace LawFirmView
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка получения компонента"); _logger.LogError(ex, "Ошибка получения компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
} }
} }
} }
private void ButtonSave_Click(object sender, EventArgs e) private void buttonSave_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(textBoxName.Text)) if (string.IsNullOrEmpty(textBoxName.Text))
{ {
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните название", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
_logger.LogInformation("Сохранение компонента"); _logger.LogInformation("Сохранение компонента");
@ -60,23 +71,27 @@ namespace LawFirmView
ComponentName = textBoxName.Text, ComponentName = textBoxName.Text,
Cost = Convert.ToDouble(textBoxCost.Text) Cost = Convert.ToDouble(textBoxCost.Text)
}; };
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); var operationResult = _id.HasValue ? _logic.Update(model) :
_logic.Create(model);
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка сохранения компонента"); _logger.LogError(ex, "Ошибка сохранения компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
} MessageBoxIcon.Error);
} }
private void ButtonCancel_Click(object sender, EventArgs e) }
private void buttonCancel_Click(object sender, EventArgs e)
{ {
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();

View File

@ -28,86 +28,78 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.textBoxName = new System.Windows.Forms.TextBox(); this.textBoxName = new System.Windows.Forms.TextBox();
this.labelName = new System.Windows.Forms.Label();
this.textBoxCost = new System.Windows.Forms.TextBox(); this.textBoxCost = new System.Windows.Forms.TextBox();
this.labelCost = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(257, 71);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(88, 27);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(162, 71);
this.buttonSave.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(88, 27);
this.buttonSave.TabIndex = 4;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// textBoxName // textBoxName
// //
this.textBoxName.Location = new System.Drawing.Point(91, 7); this.textBoxName.Location = new System.Drawing.Point(72, 12);
this.textBoxName.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.textBoxName.Name = "textBoxName"; this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(252, 23); this.textBoxName.Size = new System.Drawing.Size(267, 23);
this.textBoxName.TabIndex = 1; this.textBoxName.TabIndex = 0;
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(14, 10);
this.labelName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(62, 15);
this.labelName.TabIndex = 0;
this.labelName.Text = "Название:";
// //
// textBoxCost // textBoxCost
// //
this.textBoxCost.Location = new System.Drawing.Point(91, 36); this.textBoxCost.Location = new System.Drawing.Point(72, 55);
this.textBoxCost.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.textBoxCost.Name = "textBoxCost"; this.textBoxCost.Name = "textBoxCost";
this.textBoxCost.Size = new System.Drawing.Size(129, 23); this.textBoxCost.Size = new System.Drawing.Size(143, 23);
this.textBoxCost.TabIndex = 3; this.textBoxCost.TabIndex = 1;
// //
// labelCost // label1
// //
this.labelCost.AutoSize = true; this.label1.AutoSize = true;
this.labelCost.Location = new System.Drawing.Point(14, 39); this.label1.Location = new System.Drawing.Point(2, 12);
this.labelCost.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1";
this.labelCost.Name = "labelCost"; this.label1.Size = new System.Drawing.Size(62, 15);
this.labelCost.Size = new System.Drawing.Size(38, 15); this.label1.TabIndex = 2;
this.labelCost.TabIndex = 2; this.label1.Text = "Название:";
this.labelCost.Text = "Цена:"; //
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 55);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(38, 15);
this.label2.TabIndex = 3;
this.label2.Text = "Цена:";
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(159, 101);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(75, 23);
this.buttonSave.TabIndex = 4;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(264, 101);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
// //
// FormComponent // FormComponent
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(360, 110); this.ClientSize = new System.Drawing.Size(456, 139);
this.Controls.Add(this.textBoxCost);
this.Controls.Add(this.labelCost);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonSave);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBoxCost);
this.Controls.Add(this.textBoxName); this.Controls.Add(this.textBoxName);
this.Controls.Add(this.labelName);
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.Name = "FormComponent"; this.Name = "FormComponent";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Компонент"; this.Text = "Компонент";
this.Load += new System.EventHandler(this.FormComponent_Load); this.Load += new System.EventHandler(this.FormComponent_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
@ -117,11 +109,11 @@
#endregion #endregion
private System.Windows.Forms.Button buttonCancel; private TextBox textBoxName;
private System.Windows.Forms.Button buttonSave;
private System.Windows.Forms.TextBox textBoxName;
private System.Windows.Forms.Label labelName;
private TextBox textBoxCost; private TextBox textBoxCost;
private Label labelCost; private Label label1;
private Label label2;
private Button buttonSave;
private Button buttonCancel;
} }
} }

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">

View File

@ -1,27 +1,34 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels.BindingModels;
using LawFirmContracts.BusinessLogicsContracts; using AbstractLawFirmContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LawFirmView namespace LawFirmView
{ {
public partial class FormComponents : Form public partial class FormComponents : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IComponentLogic _logic; private readonly IComponentLogic _logic;
public FormComponents(ILogger<FormComponents> logger, IComponentLogic logic) public FormComponents(ILogger<FormComponents> logger, IComponentLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
} }
private void FormComponents_Load(object sender, EventArgs e) private void FormComponents_Load(object sender, EventArgs e)
{ {
LoadData(); LoadData();
}
}
private void LoadData() private void LoadData()
{ {
try try
@ -31,18 +38,20 @@ namespace LawFirmView
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["ComponentName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
} }
_logger.LogInformation("Загрузка компонентов"); _logger.LogInformation("Загрузка компонентов");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки компонентов"); _logger.LogError(ex, "Ошибка загрузки компонентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
} }
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); var service = Program.ServiceProvider?.GetService(typeof(FormComponent));
if (service is FormComponent form) if (service is FormComponent form)
@ -54,33 +63,41 @@ namespace LawFirmView
} }
} }
private void ButtonUpd_Click(object sender, EventArgs e) private void buttonUpd_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); var service =
Program.ServiceProvider?.GetService(typeof(FormComponent));
if (service is FormComponent form) if (service is FormComponent form)
{ {
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); form.Id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
LoadData(); LoadData();
} }
} }
} }
} }
private void ButtonDel_Click(object sender, EventArgs e) private void buttonDel_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление компонента"); _logger.LogInformation("Удаление компонента");
try try
{ {
if (!_logic.Delete(new ComponentBindingModel { Id = id })) if (!_logic.Delete(new ComponentBindingModel
{
Id = id
}))
{ {
throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
} }
@ -89,15 +106,19 @@ namespace LawFirmView
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка удаления компонента"); _logger.LogError(ex, "Ошибка удаления компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка",
} MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
private void ButtonRef_Click(object sender, EventArgs e) }
private void buttonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
} }
} }

View File

@ -28,83 +28,75 @@
/// </summary> /// </summary>
private void InitializeComponent() 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(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonAdd = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// buttonRef // dataGridView
// //
this.buttonRef.Location = new System.Drawing.Point(370, 132); this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.buttonRef.Name = "buttonRef"; this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.buttonRef.Size = new System.Drawing.Size(75, 23); this.dataGridView.Name = "dataGridView";
this.buttonRef.TabIndex = 4; this.dataGridView.RowTemplate.Height = 25;
this.buttonRef.Text = "Обновить"; this.dataGridView.Size = new System.Drawing.Size(439, 442);
this.buttonRef.UseVisualStyleBackColor = true; this.dataGridView.TabIndex = 0;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(370, 91);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(75, 23);
this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(370, 50);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(75, 23);
this.buttonUpd.TabIndex = 2;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
// //
// buttonAdd // buttonAdd
// //
this.buttonAdd.Location = new System.Drawing.Point(370, 12); this.buttonAdd.Location = new System.Drawing.Point(486, 12);
this.buttonAdd.Name = "buttonAdd"; this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(75, 23); this.buttonAdd.Size = new System.Drawing.Size(102, 40);
this.buttonAdd.TabIndex = 1; this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить"; this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true; this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
// //
// dataGridView // buttonUpd
// //
this.dataGridView.AllowUserToAddRows = false; this.buttonUpd.Location = new System.Drawing.Point(486, 58);
this.dataGridView.AllowUserToDeleteRows = false; this.buttonUpd.Name = "buttonUpd";
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; this.buttonUpd.Size = new System.Drawing.Size(102, 41);
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.buttonUpd.TabIndex = 2;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; this.buttonUpd.Text = "Изменить";
this.dataGridView.Location = new System.Drawing.Point(0, 0); this.buttonUpd.UseVisualStyleBackColor = true;
this.dataGridView.MultiSelect = false; this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click);
this.dataGridView.Name = "dataGridView"; //
this.dataGridView.ReadOnly = true; // buttonDel
this.dataGridView.RowHeadersVisible = false; //
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.buttonDel.Location = new System.Drawing.Point(486, 105);
this.dataGridView.Size = new System.Drawing.Size(350, 312); this.buttonDel.Name = "buttonDel";
this.dataGridView.TabIndex = 0; this.buttonDel.Size = new System.Drawing.Size(102, 42);
this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(486, 153);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(102, 39);
this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
// //
// FormComponents // FormComponents
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(464, 312); this.ClientSize = new System.Drawing.Size(632, 443);
this.Controls.Add(this.buttonRef); this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel); this.Controls.Add(this.buttonDel);
this.Controls.Add(this.buttonUpd); this.Controls.Add(this.buttonUpd);
this.Controls.Add(this.buttonAdd); this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView); this.Controls.Add(this.dataGridView);
this.Name = "FormComponents"; this.Name = "FormComponents";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "FormComponents";
this.Text = "Компоненты";
this.Load += new System.EventHandler(this.FormComponents_Load); this.Load += new System.EventHandler(this.FormComponents_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
@ -113,10 +105,10 @@
#endregion #endregion
private System.Windows.Forms.Button buttonRef; private DataGridView dataGridView;
private System.Windows.Forms.Button buttonDel; private Button buttonAdd;
private System.Windows.Forms.Button buttonUpd; private Button buttonUpd;
private System.Windows.Forms.Button buttonAdd; private Button buttonDel;
private System.Windows.Forms.DataGridView dataGridView; private Button buttonRef;
} }
} }

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">

View File

@ -1,72 +1,108 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.SearchModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using AbstractLawFirmContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AbstractLawFirmContracts.BindingModels;
namespace LawFirmView namespace LawFirmView
{ {
public partial class FormCreateOrder : Form public partial class FormCreateOrder : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IDocumentLogic _logicD;
private readonly IDocumentLogic _logicP;
private readonly IOrderLogic _logicO; private readonly IOrderLogic _logicO;
public FormCreateOrder(ILogger<FormCreateOrder> logger, IDocumentLogic logicD, IOrderLogic logicO)
public FormCreateOrder(ILogger<FormCreateOrder> logger, IDocumentLogic logicP, IOrderLogic logicO)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logicP = logicP; _logicD = logicD;
_logicO = logicO; _logicO = logicO;
} }
private void FormCreateOrder_Load(object sender, EventArgs e) private void FormCreateOrder_Load(object sender, EventArgs e)
{ {
_logger.LogInformation("Загрузка изделий для заказа"); _logger.LogInformation("Загрузка пакетов документов для заказа");
// прописать логику try
{
var list = _logicD.ReadList(null);
if (list != null)
{
comboBoxDocument.DisplayMember = "DocumentName";
comboBoxDocument.ValueMember = "Id";
comboBoxDocument.DataSource = list;
comboBoxDocument.SelectedItem = null;
}
_logger.LogInformation("Пакеты документов загружены");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки пакетов документов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
} }
private void CalcSum() private void CalcSum()
{ {
if (comboBoxProduct.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text)) if (comboBoxDocument.SelectedValue != null &&
!string.IsNullOrEmpty(textBoxCount.Text))
{ {
try try
{ {
int id = Convert.ToInt32(comboBoxProduct.SelectedValue); int id = Convert.ToInt32(comboBoxDocument.SelectedValue);
var product = _logicP.ReadElement(new DocumentSearchModel { Id = id }); var product = _logicD.ReadElement(new DocumentSearchModel
{
Id
= id
});
int count = Convert.ToInt32(textBoxCount.Text); int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0), 2).ToString(); textBoxSum.Text = Math.Round(count * (product?.Price ?? 0),
2).ToString();
_logger.LogInformation("Расчет суммы заказа"); _logger.LogInformation("Расчет суммы заказа");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка расчета суммы заказа"); _logger.LogError(ex, "Ошибка расчета суммы заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
} }
} }
} }
private void TextBoxCount_TextChanged(object sender, EventArgs e) private void textBoxCount_TextChanged(object sender, EventArgs e)
{ {
CalcSum(); CalcSum();
} }
private void ComboBoxProduct_SelectedIndexChanged(object sender, EventArgs e) private void comboBoxDocument_SelectedIndexChanged(object sender, EventArgs e)
{ {
CalcSum(); CalcSum();
} }
private void ButtonSave_Click(object sender, EventArgs e) private void textBoxSum_TextChanged(object sender, EventArgs e)
{
CalcSum();
}
private void buttonSave_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(textBoxCount.Text)) if (string.IsNullOrEmpty(textBoxCount.Text))
{ {
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните поле Количество", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (comboBoxProduct.SelectedValue == null) if (comboBoxDocument.SelectedValue == null)
{ {
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Выберите пакет документов", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
_logger.LogInformation("Создание заказа"); _logger.LogInformation("Создание заказа");
@ -74,7 +110,7 @@ namespace LawFirmView
{ {
var operationResult = _logicO.CreateOrder(new OrderBindingModel var operationResult = _logicO.CreateOrder(new OrderBindingModel
{ {
DocumentId = Convert.ToInt32(comboBoxProduct.SelectedValue), DocumentId = Convert.ToInt32(comboBoxDocument.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text), Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text) Sum = Convert.ToDouble(textBoxSum.Text)
}); });
@ -82,7 +118,8 @@ namespace LawFirmView
{ {
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
} }
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
@ -91,9 +128,10 @@ namespace LawFirmView
_logger.LogError(ex, "Ошибка создания заказа"); _logger.LogError(ex, "Ошибка создания заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonCancel_Click(object sender, EventArgs e) private void buttonCancel_Click(object sender, EventArgs e)
{ {
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();

View File

@ -28,104 +28,102 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.labelCount = new System.Windows.Forms.Label(); this.comboBoxDocument = new System.Windows.Forms.ComboBox();
this.comboBoxProduct = new System.Windows.Forms.ComboBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.textBoxCount = new System.Windows.Forms.TextBox(); this.textBoxCount = new System.Windows.Forms.TextBox();
this.labelProduct = new System.Windows.Forms.Label();
this.labelSum = new System.Windows.Forms.Label();
this.textBoxSum = new System.Windows.Forms.TextBox(); this.textBoxSum = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// labelCount // comboBoxDocument
// //
this.labelCount.AutoSize = true; this.comboBoxDocument.FormattingEnabled = true;
this.labelCount.Location = new System.Drawing.Point(12, 36); this.comboBoxDocument.Location = new System.Drawing.Point(116, 12);
this.labelCount.Name = "labelCount"; this.comboBoxDocument.Name = "comboBoxDocument";
this.labelCount.Size = new System.Drawing.Size(69, 13); this.comboBoxDocument.Size = new System.Drawing.Size(198, 23);
this.labelCount.TabIndex = 2; this.comboBoxDocument.TabIndex = 0;
this.labelCount.Text = "Количество:"; this.comboBoxDocument.SelectedIndexChanged += new System.EventHandler(this.comboBoxDocument_SelectedIndexChanged);
// //
// comboBoxProduct // textBoxCount
// //
this.comboBoxProduct.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.textBoxCount.Location = new System.Drawing.Point(116, 41);
this.comboBoxProduct.FormattingEnabled = true; this.textBoxCount.Name = "textBoxCount";
this.comboBoxProduct.Location = new System.Drawing.Point(87, 6); this.textBoxCount.Size = new System.Drawing.Size(198, 23);
this.comboBoxProduct.Name = "comboBoxProduct"; this.textBoxCount.TabIndex = 1;
this.comboBoxProduct.Size = new System.Drawing.Size(217, 21); this.textBoxCount.TextChanged += new System.EventHandler(this.textBoxCount_TextChanged);
this.comboBoxProduct.TabIndex = 1;
this.comboBoxProduct.SelectedIndexChanged += new System.EventHandler(this.ComboBoxProduct_SelectedIndexChanged);
// //
// buttonCancel // textBoxSum
// //
this.buttonCancel.Location = new System.Drawing.Point(219, 85); this.textBoxSum.Location = new System.Drawing.Point(116, 70);
this.buttonCancel.Name = "buttonCancel"; this.textBoxSum.Name = "textBoxSum";
this.buttonCancel.Size = new System.Drawing.Size(75, 23); this.textBoxSum.Size = new System.Drawing.Size(198, 23);
this.buttonCancel.TabIndex = 7; this.textBoxSum.TabIndex = 2;
this.buttonCancel.Text = "Отмена"; this.textBoxSum.TextChanged += new System.EventHandler(this.textBoxSum_TextChanged);
this.buttonCancel.UseVisualStyleBackColor = true; //
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(3, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(110, 15);
this.label1.TabIndex = 3;
this.label1.Text = "Пакет документов:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(3, 44);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(75, 15);
this.label2.TabIndex = 4;
this.label2.Text = "Количество:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(3, 70);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(48, 15);
this.label3.TabIndex = 5;
this.label3.Text = "Сумма:";
// //
// buttonSave // buttonSave
// //
this.buttonSave.Location = new System.Drawing.Point(138, 85); this.buttonSave.Location = new System.Drawing.Point(180, 122);
this.buttonSave.Name = "buttonSave"; this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(75, 23); this.buttonSave.Size = new System.Drawing.Size(75, 23);
this.buttonSave.TabIndex = 6; this.buttonSave.TabIndex = 6;
this.buttonSave.Text = "Сохранить"; this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
// //
// textBoxCount // buttonCancel
// //
this.textBoxCount.Location = new System.Drawing.Point(87, 33); this.buttonCancel.Location = new System.Drawing.Point(282, 122);
this.textBoxCount.Name = "textBoxCount"; this.buttonCancel.Name = "buttonCancel";
this.textBoxCount.Size = new System.Drawing.Size(217, 20); this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.textBoxCount.TabIndex = 3; this.buttonCancel.TabIndex = 7;
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged); this.buttonCancel.Text = "Отмена";
// this.buttonCancel.UseVisualStyleBackColor = true;
// labelProduct this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
this.labelProduct.AutoSize = true;
this.labelProduct.Location = new System.Drawing.Point(12, 9);
this.labelProduct.Name = "labelProduct";
this.labelProduct.Size = new System.Drawing.Size(54, 13);
this.labelProduct.TabIndex = 0;
this.labelProduct.Text = "Изделие:";
//
// labelSum
//
this.labelSum.AutoSize = true;
this.labelSum.Location = new System.Drawing.Point(12, 62);
this.labelSum.Name = "labelSum";
this.labelSum.Size = new System.Drawing.Size(44, 13);
this.labelSum.TabIndex = 4;
this.labelSum.Text = "Сумма:";
//
// textBoxSum
//
this.textBoxSum.Location = new System.Drawing.Point(87, 59);
this.textBoxSum.Name = "textBoxSum";
this.textBoxSum.ReadOnly = true;
this.textBoxSum.Size = new System.Drawing.Size(217, 20);
this.textBoxSum.TabIndex = 5;
// //
// FormCreateOrder // FormCreateOrder
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(318, 118); this.ClientSize = new System.Drawing.Size(445, 158);
this.Controls.Add(this.labelSum);
this.Controls.Add(this.textBoxSum);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.comboBoxProduct);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonSave);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBoxSum);
this.Controls.Add(this.textBoxCount); this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.labelProduct); this.Controls.Add(this.comboBoxDocument);
this.Name = "FormCreateOrder"; this.Name = "FormCreateOrder";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Заказ"; this.Text = "Заказ";
this.Load += new System.EventHandler(this.FormCreateOrder_Load); this.Load += new System.EventHandler(this.FormCreateOrder_Load);
this.ResumeLayout(false); this.ResumeLayout(false);
@ -134,13 +132,14 @@
} }
#endregion #endregion
private System.Windows.Forms.Label labelCount;
private System.Windows.Forms.ComboBox comboBoxProduct; private ComboBox comboBoxDocument;
private System.Windows.Forms.Button buttonCancel; private TextBox textBoxCount;
private System.Windows.Forms.Button buttonSave; private TextBox textBoxSum;
private System.Windows.Forms.TextBox textBoxCount; private Label label1;
private System.Windows.Forms.Label labelProduct; private Label label2;
private System.Windows.Forms.Label labelSum; private Label label3;
private System.Windows.Forms.TextBox textBoxSum; private Button buttonSave;
private Button buttonCancel;
} }
} }

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">

View File

@ -1,66 +1,77 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmDataModels.Models;
using LawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.SearchModels;
using LawFirmDataModels.Models;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using AbstractLawFirmContracts.BusinessLogicsContracts;
using AbstractLawFirmContracts.SearchModels;
using AbstractLawFirmContracts.BindingModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LawFirmView namespace LawFirmView
{ {
public partial class FormDocument : Form public partial class FormDocument : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IDocumentLogic _logic; private readonly IDocumentLogic _logic;
private int? _id; private int? _id;
private Dictionary<int, (IComponentModel, int)> _documentComponents;
private Dictionary<int, (IComponentModel, int)> _productComponents;
public int Id { set { _id = value; } } public int Id { set { _id = value; } }
public FormDocument(ILogger<FormDocument> logger, IDocumentLogic logic) public FormDocument(ILogger<FormDocument> logger, IDocumentLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
_productComponents = new Dictionary<int, (IComponentModel, int)>(); _documentComponents = new Dictionary<int, (IComponentModel, int)>();
} }
private void FormProduct_Load(object sender, EventArgs e) private void FormDocument_Load(object sender, EventArgs e)
{ {
if (_id.HasValue) if (_id.HasValue)
{ {
_logger.LogInformation("Загрузка изделия"); _logger.LogInformation("Загрузка изделия");
try try
{ {
var view = _logic.ReadElement(new DocumentSearchModel { Id = _id.Value }); var view = _logic.ReadElement(new DocumentSearchModel
{
Id =
_id.Value
});
if (view != null) if (view != null)
{ {
textBoxName.Text = view.DocumentName; textBoxName.Text = view.DocumentName;
textBoxPrice.Text = view.Price.ToString(); textBoxPrice.Text = view.Price.ToString();
_productComponents = view.DocumentComponents ?? new Dictionary<int, (IComponentModel, int)>(); _documentComponents = view.DocumentComponents ?? new
Dictionary<int, (IComponentModel, int)>();
LoadData(); LoadData();
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки изделия"); _logger.LogError(ex, "Ошибка загрузки изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
} MessageBoxIcon.Error);
} }
} }
}
private void LoadData() private void LoadData()
{ {
_logger.LogInformation("Загрузка компонент изделия"); _logger.LogInformation("Загрузка компонент изделия");
try try
{ {
if (_productComponents != null) if (_documentComponents != null)
{ {
dataGridView.Rows.Clear(); dataGridView.Rows.Clear();
foreach (var pc in _productComponents) foreach (var pc in _documentComponents)
{ {
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 }); dataGridView.Rows.Add(new object[] { pc.Key,
pc.Value.Item1.ComponentName, pc.Value.Item2 });
} }
textBoxPrice.Text = CalcPrice().ToString(); textBoxPrice.Text = CalcPrice().ToString();
} }
@ -68,13 +79,15 @@ namespace LawFirmView
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки компонент изделия"); _logger.LogError(ex, "Ошибка загрузки компонент изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
} }
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormDocumentComponent)); var service =
Program.ServiceProvider?.GetService(typeof(FormDocumentComponent));
if (service is FormDocumentComponent form) if (service is FormDocumentComponent form)
{ {
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
@ -84,83 +97,96 @@ namespace LawFirmView
return; return;
} }
_logger.LogInformation("Добавление нового компонента:{ ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count); _logger.LogInformation("Добавление нового компонента:{ ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count);
if (_productComponents.ContainsKey(form.Id)) if (_documentComponents.ContainsKey(form.Id))
{ {
_productComponents[form.Id] = (form.ComponentModel, form.Count); _documentComponents[form.Id] = (form.ComponentModel,
form.Count);
} }
else else
{ {
_productComponents.Add(form.Id, (form.ComponentModel, form.Count)); _documentComponents.Add(form.Id, (form.ComponentModel,
form.Count));
} }
LoadData(); LoadData();
} }
} }
} }
private void ButtonUpd_Click(object sender, EventArgs e) private void buttonUpd_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormDocumentComponent)); var service =
Program.ServiceProvider?.GetService(typeof(FormDocumentComponent));
if (service is FormDocumentComponent form) if (service is FormDocumentComponent form)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id; form.Id = id;
form.Count = _productComponents[id].Item2; form.Count = _documentComponents[id].Item2;
if (form.ShowDialog() == DialogResult.OK) if (form.ShowDialog() == DialogResult.OK)
{ {
if (form.ComponentModel == null) if (form.ComponentModel == null)
{ {
return; return;
} }
_logger.LogInformation("Изменение компонента: {ComponentName} - {Count}", form.ComponentModel.ComponentName, form.Count); _logger.LogInformation("Изменение компонента:{ ComponentName - { Count}", form.ComponentModel.ComponentName, form.Count);
_productComponents[form.Id] = (form.ComponentModel, form.Count); _documentComponents[form.Id] = (form.ComponentModel,form.Count);
LoadData(); LoadData();
} }
} }
} }
} }
private void ButtonDel_Click(object sender, EventArgs e) private void buttonDel_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (MessageBox.Show("Удалить запись?", "Вопрос",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
try try
{ {
_logger.LogInformation("Удаление компонента: { ComponentName} - { Count} ", dataGridView.SelectedRows[0].Cells[1].Value); _logger.LogInformation("Удаление компонента: { ComponentName} - { Count} ", dataGridView.SelectedRows[0].Cells[1].Value);
_productComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
_documentComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
} }
catch (Exception ex) catch (Exception ex)
{ {
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
LoadData(); LoadData();
} }
} }
} }
private void ButtonRef_Click(object sender, EventArgs e) private void buttonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void ButtonSave_Click(object sender, EventArgs e) private void buttonSave_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(textBoxName.Text)) if (string.IsNullOrEmpty(textBoxName.Text))
{ {
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните название", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (string.IsNullOrEmpty(textBoxPrice.Text)) if (string.IsNullOrEmpty(textBoxPrice.Text))
{ {
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
return; return;
} }
if (_productComponents == null || _productComponents.Count == 0) if (_documentComponents == null || _documentComponents.Count == 0)
{ {
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните компоненты", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
_logger.LogInformation("Сохранение изделия"); _logger.LogInformation("Сохранение изделия");
@ -171,14 +197,16 @@ namespace LawFirmView
Id = _id ?? 0, Id = _id ?? 0,
DocumentName = textBoxName.Text, DocumentName = textBoxName.Text,
Price = Convert.ToDouble(textBoxPrice.Text), Price = Convert.ToDouble(textBoxPrice.Text),
DocumentComponents = _productComponents DocumentComponents = _documentComponents
}; };
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); var operationResult = _id.HasValue ? _logic.Update(model) :
_logic.Create(model);
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
@ -187,18 +215,18 @@ namespace LawFirmView
_logger.LogError(ex, "Ошибка сохранения изделия"); _logger.LogError(ex, "Ошибка сохранения изделия");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ButtonCancel_Click(object sender, EventArgs e) private void buttonCancel_Click(object sender, EventArgs e)
{ {
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
private double CalcPrice() private double CalcPrice()
{ {
double price = 0; double price = 0;
foreach (var elem in _productComponents) foreach (var elem in _documentComponents)
{ {
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
} }

View File

@ -28,203 +28,177 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.buttonCancel = new System.Windows.Forms.Button(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.buttonSave = new System.Windows.Forms.Button();
this.textBoxName = new System.Windows.Forms.TextBox();
this.labelName = new System.Windows.Forms.Label();
this.textBoxPrice = new System.Windows.Forms.TextBox();
this.labelPrice = new System.Windows.Forms.Label();
this.groupBoxComponents = new System.Windows.Forms.GroupBox();
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(); this.dataGridView = new System.Windows.Forms.DataGridView();
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.groupBoxComponents.SuspendLayout(); this.buttonAdd = new System.Windows.Forms.Button();
this.buttonUpd = new System.Windows.Forms.Button();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.textBoxName = new System.Windows.Forms.TextBox();
this.textBoxPrice = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// buttonCancel // groupBox1
// //
this.buttonCancel.Location = new System.Drawing.Point(455, 362); this.groupBox1.Controls.Add(this.buttonRef);
this.buttonCancel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.groupBox1.Controls.Add(this.buttonDel);
this.buttonCancel.Name = "buttonCancel"; this.groupBox1.Controls.Add(this.buttonUpd);
this.buttonCancel.Size = new System.Drawing.Size(88, 27); this.groupBox1.Controls.Add(this.buttonAdd);
this.buttonCancel.TabIndex = 6; this.groupBox1.Controls.Add(this.dataGridView);
this.buttonCancel.Text = "Отмена"; this.groupBox1.Location = new System.Drawing.Point(58, 98);
this.buttonCancel.UseVisualStyleBackColor = true; this.groupBox1.Name = "groupBox1";
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); this.groupBox1.Size = new System.Drawing.Size(605, 288);
// this.groupBox1.TabIndex = 0;
// buttonSave this.groupBox1.TabStop = false;
// this.groupBox1.Text = "Компоненты";
this.buttonSave.Location = new System.Drawing.Point(360, 362);
this.buttonSave.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(88, 27);
this.buttonSave.TabIndex = 5;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(92, 7);
this.textBoxName.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(252, 23);
this.textBoxName.TabIndex = 1;
//
// labelName
//
this.labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(14, 10);
this.labelName.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(62, 15);
this.labelName.TabIndex = 0;
this.labelName.Text = "Название:";
//
// textBoxPrice
//
this.textBoxPrice.Enabled = false;
this.textBoxPrice.Location = new System.Drawing.Point(92, 37);
this.textBoxPrice.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.textBoxPrice.Name = "textBoxPrice";
this.textBoxPrice.Size = new System.Drawing.Size(147, 23);
this.textBoxPrice.TabIndex = 3;
//
// labelPrice
//
this.labelPrice.AutoSize = true;
this.labelPrice.Location = new System.Drawing.Point(14, 40);
this.labelPrice.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.labelPrice.Name = "labelPrice";
this.labelPrice.Size = new System.Drawing.Size(70, 15);
this.labelPrice.TabIndex = 2;
this.labelPrice.Text = "Стоимость:";
//
// groupBoxComponents
//
this.groupBoxComponents.Controls.Add(this.buttonRef);
this.groupBoxComponents.Controls.Add(this.buttonDel);
this.groupBoxComponents.Controls.Add(this.buttonUpd);
this.groupBoxComponents.Controls.Add(this.buttonAdd);
this.groupBoxComponents.Controls.Add(this.dataGridView);
this.groupBoxComponents.Location = new System.Drawing.Point(14, 67);
this.groupBoxComponents.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.groupBoxComponents.Name = "groupBoxComponents";
this.groupBoxComponents.Padding = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.groupBoxComponents.Size = new System.Drawing.Size(558, 288);
this.groupBoxComponents.TabIndex = 4;
this.groupBoxComponents.TabStop = false;
this.groupBoxComponents.Text = "Компоненты";
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(441, 171);
this.buttonRef.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(88, 27);
this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(441, 123);
this.buttonDel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(88, 27);
this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(441, 76);
this.buttonUpd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(88, 27);
this.buttonUpd.TabIndex = 2;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(441, 32);
this.buttonAdd.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(88, 27);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
// //
// dataGridView // dataGridView
// //
this.dataGridView.AllowUserToAddRows = false; this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ColumnId, this.Column1,
this.ColumnName, this.Column2,
this.ColumnCount}); this.Column3});
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; this.dataGridView.Location = new System.Drawing.Point(3, 19);
this.dataGridView.Location = new System.Drawing.Point(4, 19);
this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.dataGridView.MultiSelect = false;
this.dataGridView.Name = "dataGridView"; this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true; this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.RowHeadersVisible = false; this.dataGridView.Size = new System.Drawing.Size(413, 254);
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView.Size = new System.Drawing.Size(408, 266);
this.dataGridView.TabIndex = 0; this.dataGridView.TabIndex = 0;
// //
// ColumnId // Column1
// //
this.ColumnId.HeaderText = "Id"; this.Column1.HeaderText = "id";
this.ColumnId.Name = "ColumnId"; this.Column1.Name = "Column1";
this.ColumnId.ReadOnly = true; this.Column1.Visible = false;
this.ColumnId.Visible = false;
// //
// ColumnName // Column2
// //
this.ColumnName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; this.Column2.HeaderText = "Компонент";
this.ColumnName.HeaderText = "Компонент"; this.Column2.Name = "Column2";
this.ColumnName.Name = "ColumnName";
this.ColumnName.ReadOnly = true;
// //
// ColumnCount // Column3
// //
this.ColumnCount.HeaderText = "Количество"; this.Column3.HeaderText = "Количество";
this.ColumnCount.Name = "ColumnCount"; this.Column3.Name = "Column3";
this.ColumnCount.ReadOnly = true;
// //
// FormProduct // buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(476, 19);
this.buttonAdd.Name = "buttonAdd";
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
this.buttonAdd.TabIndex = 1;
this.buttonAdd.Text = "Добавить";
this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(476, 61);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(75, 23);
this.buttonUpd.TabIndex = 2;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(476, 108);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(75, 23);
this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(476, 156);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(75, 23);
this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(427, 403);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(75, 23);
this.buttonSave.TabIndex = 1;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(534, 403);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 2;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// textBoxName
//
this.textBoxName.Location = new System.Drawing.Point(102, 12);
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new System.Drawing.Size(205, 23);
this.textBoxName.TabIndex = 3;
//
// textBoxPrice
//
this.textBoxPrice.Location = new System.Drawing.Point(102, 41);
this.textBoxPrice.Name = "textBoxPrice";
this.textBoxPrice.Size = new System.Drawing.Size(151, 23);
this.textBoxPrice.TabIndex = 4;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(62, 15);
this.label1.TabIndex = 5;
this.label1.Text = "Название:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 41);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(70, 15);
this.label2.TabIndex = 6;
this.label2.Text = "Стоимость:";
//
// FormDocument
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(586, 402); this.ClientSize = new System.Drawing.Size(691, 450);
this.Controls.Add(this.groupBoxComponents); this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBoxPrice); this.Controls.Add(this.textBoxPrice);
this.Controls.Add(this.labelPrice); this.Controls.Add(this.textBoxName);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonSave);
this.Controls.Add(this.textBoxName); this.Controls.Add(this.groupBox1);
this.Controls.Add(this.labelName); this.Name = "FormDocument";
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.Text = "Пакет документов";
this.Name = "FormProduct"; this.Load += new System.EventHandler(this.FormDocument_Load);
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.groupBox1.ResumeLayout(false);
this.Text = "Изделие";
this.Load += new System.EventHandler(this.FormProduct_Load);
this.groupBoxComponents.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -233,20 +207,20 @@
#endregion #endregion
private System.Windows.Forms.Button buttonCancel; private GroupBox groupBox1;
private System.Windows.Forms.Button buttonSave; private Button buttonRef;
private System.Windows.Forms.TextBox textBoxName; private Button buttonDel;
private System.Windows.Forms.Label labelName; private Button buttonUpd;
private System.Windows.Forms.TextBox textBoxPrice; private Button buttonAdd;
private System.Windows.Forms.Label labelPrice; private DataGridView dataGridView;
private System.Windows.Forms.GroupBox groupBoxComponents; private DataGridViewTextBoxColumn Column1;
private System.Windows.Forms.Button buttonRef; private DataGridViewTextBoxColumn Column2;
private System.Windows.Forms.Button buttonDel; private DataGridViewTextBoxColumn Column3;
private System.Windows.Forms.Button buttonUpd; private Button buttonSave;
private System.Windows.Forms.Button buttonAdd; private Button buttonCancel;
private System.Windows.Forms.DataGridView dataGridView; private TextBox textBoxName;
private System.Windows.Forms.DataGridViewTextBoxColumn ColumnId; private TextBox textBoxPrice;
private System.Windows.Forms.DataGridViewTextBoxColumn ColumnName; private Label label1;
private System.Windows.Forms.DataGridViewTextBoxColumn ColumnCount; private Label label2;
} }
} }

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
@ -117,4 +57,22 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

View File

@ -1,15 +1,33 @@
using LawFirmContracts.BusinessLogicsContracts; using AbstractLawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.ViewModels; using AbstractLawFirmContracts.ViewModels;
using LawFirmDataModels.Models; using AbstractLawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LawFirmView namespace LawFirmView
{ {
public partial class FormDocumentComponent : Form public partial class FormDocumentComponent : Form
{ {
private readonly List<ComponentViewModel>? _list; private readonly List<ComponentViewModel>? _list;
public int Id
public int Id { get { return Convert.ToInt32(comboBoxComponent.SelectedValue); } set { comboBoxComponent.SelectedValue = value; } } {
get
{
return
Convert.ToInt32(comboBoxComponent.SelectedValue);
}
set
{
comboBoxComponent.SelectedValue = value;
}
}
public IComponentModel? ComponentModel public IComponentModel? ComponentModel
{ {
get get
@ -28,13 +46,16 @@ namespace LawFirmView
return null; return null;
} }
} }
public int Count
public int Count { get { return Convert.ToInt32(textBoxCount.Text); } set { textBoxCount.Text = value.ToString(); } } {
get { return Convert.ToInt32(textBoxCount.Text); }
set
{ textBoxCount.Text = value.ToString(); }
}
public FormDocumentComponent(IComponentLogic logic) public FormDocumentComponent(IComponentLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_list = logic.ReadList(null); _list = logic.ReadList(null);
if (_list != null) if (_list != null)
{ {
@ -43,29 +64,32 @@ namespace LawFirmView
comboBoxComponent.DataSource = _list; comboBoxComponent.DataSource = _list;
comboBoxComponent.SelectedItem = null; comboBoxComponent.SelectedItem = null;
} }
} }
private void ButtonSave_Click(object sender, EventArgs e) private void buttonSave_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(textBoxCount.Text)) if (string.IsNullOrEmpty(textBoxCount.Text))
{ {
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Заполните поле Количество", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (comboBoxComponent.SelectedValue == null) if (comboBoxComponent.SelectedValue == null)
{ {
MessageBox.Show("Выберите компонент", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Выберите компонент", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Close(); Close();
} }
private void ButtonCancel_Click(object sender, EventArgs e) private void buttonCancel_Click(object sender, EventArgs e)
{ {
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
} }
} }

View File

@ -28,82 +28,80 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.labelComponent = new System.Windows.Forms.Label();
this.textBoxCount = new System.Windows.Forms.TextBox();
this.comboBoxComponent = new System.Windows.Forms.ComboBox(); this.comboBoxComponent = new System.Windows.Forms.ComboBox();
this.labelCount = new System.Windows.Forms.Label(); this.textBoxCount = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.buttonSave = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// buttonCancel // comboBoxComponent
// //
this.buttonCancel.Location = new System.Drawing.Point(218, 59); this.comboBoxComponent.FormattingEnabled = true;
this.buttonCancel.Name = "buttonCancel"; this.comboBoxComponent.Location = new System.Drawing.Point(93, 12);
this.buttonCancel.Size = new System.Drawing.Size(75, 23); this.comboBoxComponent.Name = "comboBoxComponent";
this.buttonCancel.TabIndex = 5; this.comboBoxComponent.Size = new System.Drawing.Size(215, 23);
this.buttonCancel.Text = "Отмена"; this.comboBoxComponent.TabIndex = 0;
this.buttonCancel.UseVisualStyleBackColor = true; //
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); // textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(93, 50);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(146, 23);
this.textBoxCount.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 12);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 15);
this.label1.TabIndex = 2;
this.label1.Text = "Компонент:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 50);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(75, 15);
this.label2.TabIndex = 3;
this.label2.Text = "Количество:";
// //
// buttonSave // buttonSave
// //
this.buttonSave.Location = new System.Drawing.Point(137, 59); this.buttonSave.Location = new System.Drawing.Point(164, 91);
this.buttonSave.Name = "buttonSave"; this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(75, 23); this.buttonSave.Size = new System.Drawing.Size(75, 23);
this.buttonSave.TabIndex = 4; this.buttonSave.TabIndex = 4;
this.buttonSave.Text = "Сохранить"; this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true; this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
// //
// labelComponent // buttonCancel
// //
this.labelComponent.AutoSize = true; this.buttonCancel.Location = new System.Drawing.Point(259, 91);
this.labelComponent.Location = new System.Drawing.Point(12, 9); this.buttonCancel.Name = "buttonCancel";
this.labelComponent.Name = "labelComponent"; this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.labelComponent.Size = new System.Drawing.Size(66, 13); this.buttonCancel.TabIndex = 5;
this.labelComponent.TabIndex = 0; this.buttonCancel.Text = "Отмена";
this.labelComponent.Text = "Компонент:"; this.buttonCancel.UseVisualStyleBackColor = true;
// this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(87, 33);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(217, 20);
this.textBoxCount.TabIndex = 3;
//
// comboBoxComponent
//
this.comboBoxComponent.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxComponent.FormattingEnabled = true;
this.comboBoxComponent.Location = new System.Drawing.Point(87, 6);
this.comboBoxComponent.Name = "comboBoxComponent";
this.comboBoxComponent.Size = new System.Drawing.Size(217, 21);
this.comboBoxComponent.TabIndex = 1;
//
// labelCount
//
this.labelCount.AutoSize = true;
this.labelCount.Location = new System.Drawing.Point(12, 36);
this.labelCount.Name = "labelCount";
this.labelCount.Size = new System.Drawing.Size(69, 13);
this.labelCount.TabIndex = 2;
this.labelCount.Text = "Количество:";
// //
// FormProductComponent // FormProductComponent
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(320, 96); this.ClientSize = new System.Drawing.Size(384, 136);
this.Controls.Add(this.labelCount);
this.Controls.Add(this.comboBoxComponent);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave); this.Controls.Add(this.buttonSave);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.textBoxCount); this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.labelComponent); this.Controls.Add(this.comboBoxComponent);
this.Name = "FormProductComponent"; this.Name = "FormProductComponent";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Компонент пакета документов";
this.Text = "Компонент изделия";
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -111,11 +109,11 @@
#endregion #endregion
private System.Windows.Forms.Button buttonCancel; private ComboBox comboBoxComponent;
private System.Windows.Forms.Button buttonSave; private TextBox textBoxCount;
private System.Windows.Forms.Label labelComponent; private Label label1;
private System.Windows.Forms.TextBox textBoxCount; private Label label2;
private System.Windows.Forms.ComboBox comboBoxComponent; private Button buttonSave;
private System.Windows.Forms.Label labelCount; private Button buttonCancel;
} }
} }

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">

View File

@ -28,98 +28,87 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
buttonRef = new Button(); this.dataGridView = new System.Windows.Forms.DataGridView();
buttonDel = new Button(); this.buttonAdd = new System.Windows.Forms.Button();
buttonUpd = new Button(); this.buttonUpd = new System.Windows.Forms.Button();
buttonAdd = new Button(); this.buttonDel = new System.Windows.Forms.Button();
dataGridView = new DataGridView(); this.buttonRef = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
SuspendLayout(); this.SuspendLayout();
//
// buttonRef
//
buttonRef.Location = new Point(597, 203);
buttonRef.Margin = new Padding(4, 5, 4, 5);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(100, 35);
buttonRef.TabIndex = 9;
buttonRef.Text = "Обновить";
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
//
// buttonDel
//
buttonDel.Location = new Point(597, 140);
buttonDel.Margin = new Padding(4, 5, 4, 5);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(100, 35);
buttonDel.TabIndex = 8;
buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonUpd
//
buttonUpd.Location = new Point(597, 77);
buttonUpd.Margin = new Padding(4, 5, 4, 5);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(100, 35);
buttonUpd.TabIndex = 7;
buttonUpd.Text = "Изменить";
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(597, 18);
buttonAdd.Margin = new Padding(4, 5, 4, 5);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(100, 35);
buttonAdd.TabIndex = 6;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
// //
// dataGridView // dataGridView
// //
dataGridView.AllowUserToAddRows = false; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.AllowUserToDeleteRows = false; this.dataGridView.Location = new System.Drawing.Point(0, 0);
dataGridView.BackgroundColor = SystemColors.ControlLightLight; this.dataGridView.Name = "dataGridView";
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.RowTemplate.Height = 25;
dataGridView.Dock = DockStyle.Left; this.dataGridView.Size = new System.Drawing.Size(445, 420);
dataGridView.Location = new Point(0, 0); this.dataGridView.TabIndex = 0;
dataGridView.Margin = new Padding(4, 5, 4, 5); //
dataGridView.MultiSelect = false; // buttonAdd
dataGridView.Name = "dataGridView"; //
dataGridView.ReadOnly = true; this.buttonAdd.Location = new System.Drawing.Point(514, 22);
dataGridView.RowHeadersVisible = false; this.buttonAdd.Name = "buttonAdd";
dataGridView.RowHeadersWidth = 51; this.buttonAdd.Size = new System.Drawing.Size(95, 37);
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; this.buttonAdd.TabIndex = 1;
dataGridView.Size = new Size(467, 450); this.buttonAdd.Text = "Добавить";
dataGridView.TabIndex = 5; this.buttonAdd.UseVisualStyleBackColor = true;
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(514, 80);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(95, 39);
this.buttonUpd.TabIndex = 2;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(514, 142);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(95, 40);
this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(514, 205);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(95, 39);
this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
// //
// FormDocuments // FormDocuments
// //
AutoScaleDimensions = new SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new Size(724, 450); this.ClientSize = new System.Drawing.Size(669, 432);
Controls.Add(buttonRef); this.Controls.Add(this.buttonRef);
Controls.Add(buttonDel); this.Controls.Add(this.buttonDel);
Controls.Add(buttonUpd); this.Controls.Add(this.buttonUpd);
Controls.Add(buttonAdd); this.Controls.Add(this.buttonAdd);
Controls.Add(dataGridView); this.Controls.Add(this.dataGridView);
Name = "FormDocuments"; this.Name = "FormDocuments";
Text = "Документы"; this.Text = "Пакеты документов";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); this.Load += new System.EventHandler(this.FormDocuments_Load);
ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
} }
#endregion #endregion
private Button buttonRef;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private Button buttonRef;
} }
} }

View File

@ -1,27 +1,34 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.SearchModels;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using AbstractLawFirmContracts.BindingModels;
using Microsoft.VisualBasic.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LawFirmView namespace LawFirmView
{ {
public partial class FormDocuments : Form public partial class FormDocuments : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IDocumentLogic _logic; private readonly IDocumentLogic _logic;
public FormDocuments(ILogger<FormDocument> logger, IDocumentLogic logic) public FormDocuments(ILogger<FormDocuments> logger, IDocumentLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
} }
private void FormComponents_Load(object sender, EventArgs e) private void FormDocuments_Load(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void LoadData() private void LoadData()
{ {
try try
@ -31,18 +38,21 @@ namespace LawFirmView
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false; dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["DocumentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["DocumentName"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["DocumentComponents"].Visible = false;
} }
_logger.LogInformation("Загрузка компонентов"); _logger.LogInformation("Загрузка пакетов документов");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки компонентов"); _logger.LogError(ex, "Ошибка загрузки пакетов документов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
} }
} }
private void ButtonAdd_Click(object sender, EventArgs e) private void buttonAdd_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormDocument)); var service = Program.ServiceProvider?.GetService(typeof(FormDocument));
if (service is FormDocument form) if (service is FormDocument form)
@ -54,7 +64,7 @@ namespace LawFirmView
} }
} }
private void ButtonUpd_Click(object sender, EventArgs e) private void buttonUpd_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
@ -70,17 +80,20 @@ namespace LawFirmView
} }
} }
private void ButtonDel_Click(object sender, EventArgs e) private void buttonDel_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление компонента"); _logger.LogInformation("Удаление пакета документов");
try try
{ {
if (!_logic.Delete(new DocumentBindingModel { Id = id })) if (!_logic.Delete(new DocumentBindingModel
{
Id = id
}))
{ {
throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
} }
@ -88,14 +101,14 @@ namespace LawFirmView
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка удаления компонента"); _logger.LogError(ex, "Ошибка удаления пакета документов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
} }
private void ButtonRef_Click(object sender, EventArgs e) private void buttonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">

View File

@ -1,15 +1,23 @@
using LawFirmContracts.BindingModels; using AbstractLawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicsContracts; using AbstractLawFirmContracts.BusinessLogicsContracts;
using AbstractLawFirmDataModels.Enums;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LawFirmView namespace LawFirmView
{ {
public partial class FormMain : Form public partial class FormMain : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic; private readonly IOrderLogic _orderLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic) public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
{ {
InitializeComponent(); InitializeComponent();
@ -21,23 +29,38 @@ namespace LawFirmView
{ {
LoadData(); LoadData();
} }
private void LoadData() private void LoadData()
{ {
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
// прописать логику try
{
var list = _orderLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["DocumentId"].Visible = false;
dataGridView.Columns["DocumentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка заказов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} }
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e) private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form) if (service is FormComponents form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e) private void пакетыДокументовToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormDocuments)); var service = Program.ServiceProvider?.GetService(typeof(FormDocuments));
if (service is FormDocuments form) if (service is FormDocuments form)
@ -46,7 +69,7 @@ namespace LawFirmView
} }
} }
private void ButtonCreateOrder_Click(object sender, EventArgs e) private void buttonCreateOrder_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form) if (service is FormCreateOrder form)
@ -54,17 +77,19 @@ namespace LawFirmView
form.ShowDialog(); form.ShowDialog();
LoadData(); LoadData();
} }
} }
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) private void buttonTakeOrderInWork_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try try
{ {
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); var operationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id));
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
@ -74,20 +99,24 @@ namespace LawFirmView
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка передачи заказа в работу"); _logger.LogError(ex, "Ошибка передачи заказа в работу");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
} MessageBoxIcon.Error);
} }
} }
private void ButtonOrderReady_Click(object sender, EventArgs e) }
private void buttonOrderReady_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); int id =
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'",
id);
try try
{ {
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); var operationResult = _orderLogic.FinishOrder(CreateBindingModel(id));
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
@ -100,17 +129,20 @@ namespace LawFirmView
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
private void ButtonIssuedOrder_Click(object sender, EventArgs e) private void buttonIssuedOrder_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); int id =
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'",
id);
try try
{ {
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id }); var operationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id));
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
@ -121,14 +153,28 @@ namespace LawFirmView
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка отметки о выдачи заказа"); _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
} MessageBoxIcon.Error);
} }
} }
private void ButtonRef_Click(object sender, EventArgs e) }
private void buttonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private OrderBindingModel CreateBindingModel(int id, bool isDone = false)
{
return new OrderBindingModel
{
Id = id,
DocumentId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DocumentId"].Value),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
};
}
} }
} }

View File

@ -3,14 +3,14 @@
partial class FormMain partial class FormMain
{ {
/// <summary> /// <summary>
/// Обязательная переменная конструктора. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// Освободить все используемые ресурсы. /// Clean up any resources being used.
/// </summary> /// </summary>
/// <param name="disposing">истинно, если управляемый ресурс должен быть удален; иначе ложно.</param> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
@ -20,175 +20,155 @@
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Код, автоматически созданный конструктором форм Windows #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Требуемый метод для поддержки конструктора — не изменяйте /// Required method for Designer support - do not modify
/// содержимое этого метода с помощью редактора кода. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
menuStrip1 = new MenuStrip(); this.menuStrip1 = new System.Windows.Forms.MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem(); this.toolStripMenuItemCatalogs = new System.Windows.Forms.ToolStripMenuItem();
компонентыToolStripMenuItem = new ToolStripMenuItem(); this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
изделияToolStripMenuItem = new ToolStripMenuItem(); this.пакетыДокументовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
buttonIssuedOrder = new Button(); this.dataGridView = new System.Windows.Forms.DataGridView();
buttonOrderReady = new Button(); this.buttonCreateOrder = new System.Windows.Forms.Button();
buttonTakeOrderInWork = new Button(); this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
buttonCreateOrder = new Button(); this.buttonOrderReady = new System.Windows.Forms.Button();
dataGridView = new DataGridView(); this.buttonIssuedOrder = new System.Windows.Forms.Button();
buttonRef = new Button(); this.buttonRef = new System.Windows.Forms.Button();
menuStrip1.SuspendLayout(); this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
SuspendLayout(); this.SuspendLayout();
// //
// menuStrip1 // menuStrip1
// //
menuStrip1.ImageScalingSize = new Size(20, 20); this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem }); this.toolStripMenuItemCatalogs});
menuStrip1.Location = new Point(0, 0); this.menuStrip1.Location = new System.Drawing.Point(0, 0);
menuStrip1.Name = "menuStrip1"; this.menuStrip1.Name = "menuStrip1";
menuStrip1.Padding = new Padding(8, 3, 0, 3); this.menuStrip1.Size = new System.Drawing.Size(910, 24);
menuStrip1.Size = new Size(1178, 30); this.menuStrip1.TabIndex = 0;
menuStrip1.TabIndex = 0; this.menuStrip1.Text = "Справочники";
menuStrip1.Text = "menuStrip1";
// //
// справочникиToolStripMenuItem // toolStripMenuItemCatalogs
// //
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem }); this.toolStripMenuItemCatalogs.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; this.компонентыToolStripMenuItem,
справочникиToolStripMenuItem.Size = new Size(117, 24); this.пакетыДокументовToolStripMenuItem});
справочникиToolStripMenuItem.Text = "Справочники"; this.toolStripMenuItemCatalogs.Name = "toolStripMenuItemCatalogs";
this.toolStripMenuItemCatalogs.Size = new System.Drawing.Size(94, 20);
this.toolStripMenuItemCatalogs.Text = "Справочники";
// //
// компонентыToolStripMenuItem // компонентыToolStripMenuItem
// //
компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem"; this.компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem";
компонентыToolStripMenuItem.Size = new Size(182, 26); this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
компонентыToolStripMenuItem.Text = "Компоненты"; this.компонентыToolStripMenuItem.Text = "Компоненты";
компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click; this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
// //
// изделияToolStripMenuItem // пакетыДокументовToolStripMenuItem
// //
изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; this.пакетыДокументовToolStripMenuItem.Name = "пакетыДокументовToolStripMenuItem";
изделияToolStripMenuItem.Size = new Size(182, 26); this.пакетыДокументовToolStripMenuItem.Size = new System.Drawing.Size(183, 22);
изделияToolStripMenuItem.Text = "Изделия"; this.пакетыДокументовToolStripMenuItem.Text = "Пакеты документов";
изделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click; this.пакетыДокументовToolStripMenuItem.Click += new System.EventHandler(this.пакетыДокументовToolStripMenuItem_Click);
//
// buttonIssuedOrder
//
buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonIssuedOrder.Location = new Point(965, 308);
buttonIssuedOrder.Margin = new Padding(5, 4, 5, 4);
buttonIssuedOrder.Name = "buttonIssuedOrder";
buttonIssuedOrder.Size = new Size(199, 36);
buttonIssuedOrder.TabIndex = 4;
buttonIssuedOrder.Text = "Заказ выдан";
buttonIssuedOrder.UseVisualStyleBackColor = true;
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
//
// buttonOrderReady
//
buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonOrderReady.Location = new Point(965, 228);
buttonOrderReady.Margin = new Padding(5, 4, 5, 4);
buttonOrderReady.Name = "buttonOrderReady";
buttonOrderReady.Size = new Size(199, 36);
buttonOrderReady.TabIndex = 3;
buttonOrderReady.Text = "Заказ готов";
buttonOrderReady.UseVisualStyleBackColor = true;
buttonOrderReady.Click += ButtonOrderReady_Click;
//
// buttonTakeOrderInWork
//
buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonTakeOrderInWork.Location = new Point(965, 156);
buttonTakeOrderInWork.Margin = new Padding(5, 4, 5, 4);
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
buttonTakeOrderInWork.Size = new Size(199, 36);
buttonTakeOrderInWork.TabIndex = 2;
buttonTakeOrderInWork.Text = "Отдать на выполнение";
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
//
// buttonCreateOrder
//
buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonCreateOrder.Location = new Point(965, 77);
buttonCreateOrder.Margin = new Padding(5, 4, 5, 4);
buttonCreateOrder.Name = "buttonCreateOrder";
buttonCreateOrder.Size = new Size(199, 36);
buttonCreateOrder.TabIndex = 1;
buttonCreateOrder.Text = "Создать заказ";
buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.Click += ButtonCreateOrder_Click;
// //
// dataGridView // dataGridView
// //
dataGridView.AllowUserToAddRows = false; this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.AllowUserToDeleteRows = false; this.dataGridView.Location = new System.Drawing.Point(0, 27);
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; this.dataGridView.Name = "dataGridView";
dataGridView.BackgroundColor = SystemColors.ControlLightLight; this.dataGridView.RowTemplate.Height = 25;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dataGridView.Size = new System.Drawing.Size(736, 411);
dataGridView.Location = new Point(0, 37); this.dataGridView.TabIndex = 1;
dataGridView.Margin = new Padding(5, 4, 5, 4); //
dataGridView.MultiSelect = false; // buttonCreateOrder
dataGridView.Name = "dataGridView"; //
dataGridView.ReadOnly = true; this.buttonCreateOrder.Location = new System.Drawing.Point(742, 39);
dataGridView.RowHeadersVisible = false; this.buttonCreateOrder.Name = "buttonCreateOrder";
dataGridView.RowHeadersWidth = 51; this.buttonCreateOrder.Size = new System.Drawing.Size(156, 26);
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; this.buttonCreateOrder.TabIndex = 2;
dataGridView.Size = new Size(944, 424); this.buttonCreateOrder.Text = "Создать заказ";
dataGridView.TabIndex = 0; this.buttonCreateOrder.UseVisualStyleBackColor = true;
this.buttonCreateOrder.Click += new System.EventHandler(this.buttonCreateOrder_Click);
//
// buttonTakeOrderInWork
//
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(742, 71);
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(156, 23);
this.buttonTakeOrderInWork.TabIndex = 3;
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.buttonTakeOrderInWork_Click);
//
// buttonOrderReady
//
this.buttonOrderReady.Location = new System.Drawing.Point(742, 100);
this.buttonOrderReady.Name = "buttonOrderReady";
this.buttonOrderReady.Size = new System.Drawing.Size(156, 23);
this.buttonOrderReady.TabIndex = 4;
this.buttonOrderReady.Text = "Заказ готов";
this.buttonOrderReady.UseVisualStyleBackColor = true;
this.buttonOrderReady.Click += new System.EventHandler(this.buttonOrderReady_Click);
//
// buttonIssuedOrder
//
this.buttonIssuedOrder.Location = new System.Drawing.Point(742, 129);
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
this.buttonIssuedOrder.Size = new System.Drawing.Size(156, 23);
this.buttonIssuedOrder.TabIndex = 5;
this.buttonIssuedOrder.Text = "Заказ выдан";
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
this.buttonIssuedOrder.Click += new System.EventHandler(this.buttonIssuedOrder_Click);
// //
// buttonRef // buttonRef
// //
buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; this.buttonRef.Location = new System.Drawing.Point(742, 158);
buttonRef.Location = new Point(965, 387); this.buttonRef.Name = "buttonRef";
buttonRef.Margin = new Padding(5, 4, 5, 4); this.buttonRef.Size = new System.Drawing.Size(156, 23);
buttonRef.Name = "buttonRef"; this.buttonRef.TabIndex = 6;
buttonRef.Size = new Size(199, 36); this.buttonRef.Text = "Обновить список";
buttonRef.TabIndex = 5; this.buttonRef.UseVisualStyleBackColor = true;
buttonRef.Text = "Обновить список"; this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
// //
// FormMain // FormMain
// //
AutoScaleDimensions = new SizeF(8F, 20F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new Size(1178, 463); this.ClientSize = new System.Drawing.Size(910, 477);
Controls.Add(buttonRef); this.Controls.Add(this.buttonRef);
Controls.Add(buttonIssuedOrder); this.Controls.Add(this.buttonIssuedOrder);
Controls.Add(buttonOrderReady); this.Controls.Add(this.buttonOrderReady);
Controls.Add(buttonTakeOrderInWork); this.Controls.Add(this.buttonTakeOrderInWork);
Controls.Add(buttonCreateOrder); this.Controls.Add(this.buttonCreateOrder);
Controls.Add(dataGridView); this.Controls.Add(this.dataGridView);
Controls.Add(menuStrip1); this.Controls.Add(this.menuStrip1);
MainMenuStrip = menuStrip1; this.MainMenuStrip = this.menuStrip1;
Margin = new Padding(5, 4, 5, 4); this.Name = "FormMain";
Name = "FormMain"; this.Text = "FormMain";
StartPosition = FormStartPosition.CenterScreen; this.Load += new System.EventHandler(this.FormMain_Load);
Text = "Юридическая фирма Все сидят"; this.menuStrip1.ResumeLayout(false);
Load += FormMain_Load; this.menuStrip1.PerformLayout();
menuStrip1.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
menuStrip1.PerformLayout(); this.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); this.PerformLayout();
ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
private MenuStrip menuStrip1; private MenuStrip menuStrip1;
private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem toolStripMenuItemCatalogs;
private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem;
private ToolStripMenuItem изделияToolStripMenuItem; private ToolStripMenuItem пакетыДокументовToolStripMenuItem;
private Button buttonIssuedOrder;
private Button buttonOrderReady;
private Button buttonTakeOrderInWork;
private Button buttonCreateOrder;
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonCreateOrder;
private Button buttonTakeOrderInWork;
private Button buttonOrderReady;
private Button buttonIssuedOrder;
private Button buttonRef; private Button buttonRef;
} }
} }

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
@ -120,4 +60,7 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>25</value>
</metadata>
</root> </root>

View File

@ -9,26 +9,13 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<None Remove="nlog.config" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="nlog.config"> <ProjectReference Include="..\AbstractLawFirmBusinessLogic\AbstractLawFirmBusinessLogic.csproj" />
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <ProjectReference Include="..\AbstractLawFirmListImplement\AbstractLawFirmListImplement.csproj" />
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LawFirmBusinessLogic\LawFirmBusinessLogic.csproj" />
<ProjectReference Include="..\LawFirmContracts\LawFirmContracts.csproj" />
<ProjectReference Include="..\LawFirmListImplement\LawFirmListImplement.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,11 +1,11 @@
using LawFirmBusinessLogic.BusinessLogics; using AbstractLawFirmBusinessLogic.BusinessLogic;
using LawFirmContracts.BusinessLogicsContracts; using AbstractLawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.StoragesContracts; using AbstractLawFirmContracts.StoragesContracts;
using LawFirmListImplement.Implements; using AbstractLawFirmListImplement.Implements;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
using System.Drawing; using System;
namespace LawFirmView namespace LawFirmView
{ {
@ -19,6 +19,8 @@ namespace LawFirmView
[STAThread] [STAThread]
static void Main() static void Main()
{ {
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
var services = new ServiceCollection(); var services = new ServiceCollection();
ConfigureServices(services); ConfigureServices(services);
@ -46,5 +48,6 @@ namespace LawFirmView
services.AddTransient<FormDocumentComponent>(); services.AddTransient<FormDocumentComponent>();
services.AddTransient<FormDocuments>(); services.AddTransient<FormDocuments>();
} }
} }
} }