ISEbd-21. Fadeeva A.A. LabWork02 base #2

Open
Nastya wants to merge 3 commits from LabWork02 into LabWork01
35 changed files with 1851 additions and 642 deletions

View File

@ -3,15 +3,17 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215 VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmView", "LawFirmView\LawFirmView.csproj", "{15EE7231-6283-4A53-AD30-F1E446471C6B}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmView", "LawFirmView\LawFirmView.csproj", "{15EE7231-6283-4A53-AD30-F1E446471C6B}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmDataModels", "LawFirmDataModels\LawFirmDataModels.csproj", "{7C356B57-C3B5-45C1-987A-9D7755161EB6}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmDataModels", "LawFirmDataModels\LawFirmDataModels.csproj", "{7C356B57-C3B5-45C1-987A-9D7755161EB6}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmContracts", "LawFirmContracts\LawFirmContracts.csproj", "{DA3562B0-F5B0-4513-B53F-3161AB3B8F78}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmContracts", "LawFirmContracts\LawFirmContracts.csproj", "{DA3562B0-F5B0-4513-B53F-3161AB3B8F78}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmListImplement", "LawFirmListImplement\LawFirmListImplement.csproj", "{F2ECDD91-4CA4-4BDF-8EFF-F2CC80DFDFE7}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmListImplement", "LawFirmListImplement\LawFirmListImplement.csproj", "{F2ECDD91-4CA4-4BDF-8EFF-F2CC80DFDFE7}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmBusinessLogic", "LawFirmBusinessLogic\LawFirmBusinessLogic.csproj", "{E09C46AA-9871-4B96-BC73-CCD93918AEE1}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LawFirmBusinessLogic", "LawFirmBusinessLogic\LawFirmBusinessLogic.csproj", "{E09C46AA-9871-4B96-BC73-CCD93918AEE1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LawFirmFileImplement", "LawFirmFileImplement\LawFirmFileImplement.csproj", "{E5961797-2975-425F-B5DD-FC92947C54E7}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -39,6 +41,10 @@ Global
{E09C46AA-9871-4B96-BC73-CCD93918AEE1}.Debug|Any CPU.Build.0 = Debug|Any CPU {E09C46AA-9871-4B96-BC73-CCD93918AEE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E09C46AA-9871-4B96-BC73-CCD93918AEE1}.Release|Any CPU.ActiveCfg = Release|Any CPU {E09C46AA-9871-4B96-BC73-CCD93918AEE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E09C46AA-9871-4B96-BC73-CCD93918AEE1}.Release|Any CPU.Build.0 = Release|Any CPU {E09C46AA-9871-4B96-BC73-CCD93918AEE1}.Release|Any CPU.Build.0 = Release|Any CPU
{E5961797-2975-425F-B5DD-FC92947C54E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E5961797-2975-425F-B5DD-FC92947C54E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E5961797-2975-425F-B5DD-FC92947C54E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E5961797-2975-425F-B5DD-FC92947C54E7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -1,7 +1,9 @@
using LawFirmContracts.BindingModels; using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicsContracts; using LawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.SearchModels; using LawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts;
using LawFirmContracts.ViewModels; using LawFirmContracts.ViewModels;
using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -12,24 +14,107 @@ namespace LawFirmBusinessLogic.BusinessLogic
{ {
public class DocumentLogic : IDocumentLogic public class DocumentLogic : IDocumentLogic
{ {
public bool Create(DocumentBindingModel model) private readonly ILogger _logger;
private readonly IDocumentStorage _documentStorage;
public DocumentLogic(ILogger<DocumentLogic> logger, IDocumentStorage documentStorage)
{ {
throw new NotImplementedException(); _logger = logger;
_documentStorage = documentStorage;
} }
public DocumentViewModel? ReadElement(DocumentSearchModel model)
{
throw new NotImplementedException();
}
public List<DocumentViewModel>? ReadList(DocumentSearchModel? model) public List<DocumentViewModel>? ReadList(DocumentSearchModel? model)
{ {
throw new NotImplementedException(); _logger.LogInformation("ReadList. DocumentName:{DocumentName}.Id:{ Id}", model?.DocumentName, model?.Id);
var list = model == null ? _documentStorage.GetFullList() : _documentStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
} }
public DocumentViewModel? ReadElement(DocumentSearchModel? model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. DocumentName:{DocumentName}.Id:{ Id}", model.DocumentName, model.Id);
var element = _documentStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(DocumentBindingModel model)
{
CheckModel(model);
if (_documentStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(DocumentBindingModel model) public bool Update(DocumentBindingModel model)
{ {
throw new NotImplementedException(); CheckModel(model);
if (_documentStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(DocumentBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_documentStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(DocumentBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.DocumentName))
{
throw new ArgumentNullException("Нет названия документа", nameof(model.DocumentName));
}
if (model.Price <= 0)
{
throw new ArgumentNullException("Цена документа должна быть больше 0", nameof(model.Price));
}
_logger.LogInformation("Document. DocumentName:{DocumentName}.Price:{ Price}. Id: { Id} ", model.DocumentName, model.Price, model.Id);
var element = _documentStorage.GetElement(new DocumentSearchModel
{
DocumentName = model.DocumentName
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Документ с таким названием уже есть");
}
} }
} }
} }

View File

@ -1,7 +1,10 @@
using LawFirmContracts.BindingModels; using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicsContracts; using LawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.SearchModels; using LawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts;
using LawFirmContracts.ViewModels; using LawFirmContracts.ViewModels;
using LawFirmDataModels.Enums;
using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -12,29 +15,105 @@ namespace LawFirmBusinessLogic.BusinessLogic
{ {
public class OrderLogic : IOrderLogic 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) public bool CreateOrder(OrderBindingModel model)
{ {
throw new NotImplementedException(); CheckModel(model);
if (model.Status != OrderStatus.Неизвестен)
{
_logger.LogWarning("Insert operation failed. Order status incorrect.");
return false;
}
model.Status = OrderStatus.Принят;
if (_orderStorage.Insert(model) == null)
{
model.Status = OrderStatus.Неизвестен;
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool StatusUpdate(OrderBindingModel model, OrderStatus newStatus)
{
var viewModel = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
if (viewModel == null)
{
throw new ArgumentNullException(nameof(model));
}
if (viewModel.Status + 1 != newStatus)
{
_logger.LogWarning("Update operation failed. Order status incorrect.");
return false;
}
model.Status = newStatus;
if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.Now;
else
{
model.DateImplement = viewModel.DateImplement;
}
CheckModel(model, false);
if (_orderStorage.Update(model) == null)
{
model.Status--;
_logger.LogWarning("Update operation failed");
return false;
}
return true;
} }
public bool DeliveryOrder(OrderBindingModel model) public bool DeliveryOrder(OrderBindingModel model)
{ {
throw new NotImplementedException(); return StatusUpdate(model, OrderStatus.Выдан);
} }
public bool FinishOrder(OrderBindingModel model) public bool FinishOrder(OrderBindingModel model)
{ {
throw new NotImplementedException(); return StatusUpdate(model, OrderStatus.Готов);
} }
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{
throw new NotImplementedException();
}
public bool TakeOrderInWork(OrderBindingModel model) public bool TakeOrderInWork(OrderBindingModel model)
{ {
throw new NotImplementedException(); return StatusUpdate(model, OrderStatus.Выполняется);
}
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
{
_logger.LogInformation("ReadList. OrderId:{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;
}
private void CheckModel(OrderBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (model.DocumentId < 0)
{
throw new ArgumentNullException("Некорректный идентификатор документа", nameof(model.DocumentId));
}
if (model.Count <= 0)
{
throw new ArgumentNullException("Количество документов в заказе должно быть больше 0", nameof(model.Count));
}
if (model.Sum <= 0)
{
throw new ArgumentNullException("Сумма заказа должна быть больше 0", nameof(model.Sum));
}
_logger.LogInformation("Order. Count: {Count}. Sum: {Sum}. Id: {Id}", model.Count, model.Sum, model.Id);
} }
} }
} }

View File

@ -18,5 +18,7 @@ namespace LawFirmContracts.BusinessLogicsContracts
bool Create(DocumentBindingModel model); bool Create(DocumentBindingModel model);
bool Update(DocumentBindingModel model); bool Update(DocumentBindingModel model);
bool Delete(DocumentBindingModel model);
} }
} }

View File

@ -11,6 +11,11 @@ namespace LawFirmContracts.StoragesContracts
{ {
public interface IOrderStorage public interface IOrderStorage
{ {
List<OrderViewModel> GetFullList(); List<OrderViewModel> GetFullList();
List<OrderViewModel> GetFilteredList(OrderSearchModel model); List<OrderViewModel> GetFilteredList(OrderSearchModel model);

View File

@ -0,0 +1,66 @@
using LawFirmFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace LawFirmFileImplement
{
internal class DataFileSingleton
{
private static DataFileSingleton? instance;
private readonly string ComponentFileName = "Component.xml";
private readonly string DocumentFileName = "Document.xml";
private readonly string OrderFileName = "Order.xml";
public List<Component> Components { get; private set; }
public List<Order> Orders { get; private set; }
public List<Document> Documents { get; private set; }
public static DataFileSingleton GetInstance()
{
if (instance == null)
{
instance = new DataFileSingleton();
}
return instance;
}
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
public void SaveDocuments() => SaveData(Documents, DocumentFileName, "Documents", x => x.GetXElement);
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
private DataFileSingleton()
{
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
Documents = LoadData(DocumentFileName, "Document", x => Document.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
}
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
{
if (File.Exists(filename))
{
return
XDocument.Load(filename)?.Root?.Elements(xmlNodeName)?.Select(selectFunction)?.ToList();
}
return new List<T>();
}
private static void SaveData<T>(List<T> data, string filename, string xmlNodeName, Func<T, XElement> selectFunction)
{
if (data != null)
{
new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())).Save(filename);
}
}
}
}

View File

@ -0,0 +1,89 @@
using LawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts;
using LawFirmContracts.ViewModels;
using LawFirmFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmFileImplement.Implements
{
public class ComponentStorage : IComponentStorage
{
private readonly DataFileSingleton source;
public ComponentStorage()
{
source = DataFileSingleton.GetInstance();
}
public List<ComponentViewModel> GetFullList()
{
return source.Components
.Select(x => x.GetViewModel)
.ToList();
}
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel model)
{
if (string.IsNullOrEmpty(model.ComponentName))
{
return new();
}
return source.Components
.Where(x => x.ComponentName.Contains(model.ComponentName))
.Select(x => x.GetViewModel)
.ToList();
}
public ComponentViewModel? GetElement(ComponentSearchModel model)
{
if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue)
{
return null;
}
return source.Components
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && x.ComponentName == model.ComponentName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public ComponentViewModel? Insert(ComponentBindingModel model)
{
model.Id = source.Components.Count > 0 ? source.Components.Max(x => x.Id) + 1 : 1;
var newComponent = Component.Create(model);
if (newComponent == null)
{
return null;
}
source.Components.Add(newComponent);
source.SaveComponents();
return newComponent.GetViewModel;
}
public ComponentViewModel? Update(ComponentBindingModel model)
{
var component = source.Components.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
source.SaveComponents();
return component.GetViewModel;
}
public ComponentViewModel? Delete(ComponentBindingModel model)
{
var element = source.Components.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
source.Components.Remove(element);
source.SaveComponents();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,80 @@
using LawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts;
using LawFirmContracts.ViewModels;
using LawFirmFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmFileImplement.Implements
{
public class DocumentStorage : IDocumentStorage
{
private readonly DataFileSingleton source;
public DocumentStorage()
{
source = DataFileSingleton.GetInstance();
}
public List<DocumentViewModel> GetFullList()
{
return source.Documents
.Select(x => x.GetViewModel)
.ToList();
}
public List<DocumentViewModel> GetFilteredList(DocumentSearchModel model)
{
if (string.IsNullOrEmpty(model.DocumentName))
{
return new();
}
return source.Documents
.Select(x => x.GetViewModel)
.ToList();
}
public DocumentViewModel? GetElement(DocumentSearchModel model)
{
if (string.IsNullOrEmpty(model.DocumentName) && !model.Id.HasValue)
{
return null;
}
return source.Documents.FirstOrDefault(x => (!string.IsNullOrEmpty(model.DocumentName) && x.DocumentName == model.DocumentName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public DocumentViewModel? Insert(DocumentBindingModel model)
{
model.Id = source.Documents.Count > 0 ? source.Documents.Max(x => x.Id) + 1 : 1;
var newDocument = Document.Create(model);
if (newDocument == null)
{
return null;
}
source.Documents.Add(newDocument);
source.SaveDocuments();
return newDocument.GetViewModel;
}
public DocumentViewModel? Update(DocumentBindingModel model)
{
var document = source.Documents.FirstOrDefault(x => x.Id == model.Id);
if (document == null)
{
return null;
}
document.Update(model);
source.SaveDocuments();
return document.GetViewModel;
}
public DocumentViewModel? Delete(DocumentBindingModel model)
{
var element = source.Documents.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
source.Documents.Remove(element);
source.SaveDocuments();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,91 @@
using LawFirmContracts.BindingModels;
using LawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts;
using LawFirmContracts.ViewModels;
using LawFirmFileImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LawFirmFileImplement.Implements
{
public class OrderStorage : IOrderStorage
{
private readonly DataFileSingleton source;
public OrderStorage()
{
source = DataFileSingleton.GetInstance();
}
private OrderViewModel AddDocumentName(OrderViewModel model)
{
model.DocumentName = source.Documents.SingleOrDefault(x => x.Id == model.DocumentId)?.DocumentName ?? string.Empty;
return model;
}
public List<OrderViewModel> GetFullList()
{
return source.Orders
.Select(x => AddDocumentName(x.GetViewModel))
.ToList();
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (model.Id == null)
{
return new();
}
return source.Orders
.Where(x => x.Id == model.Id)
.Select(x => AddDocumentName(x.GetViewModel))
.ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
var order = source.Orders.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
if (order == null)
{
return null;
}
return AddDocumentName(order);
}
public OrderViewModel? Insert(OrderBindingModel model)
{
model.Id = source.Orders.Count > 0 ? source.Orders.Max(x => x.Id) + 1 : 1;
var newOrder = Order.Create(model);
if (newOrder == null)
{
return null;
}
source.Orders.Add(newOrder);
source.SaveOrders();
return newOrder.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
{
var order = source.Orders.FirstOrDefault(x => x.Id == model.Id);
if (order == null)
{
return null;
}
order.Update(model);
source.SaveOrders();
return order.GetViewModel;
}
public OrderViewModel? Delete(OrderBindingModel model)
{
var element = source.Orders.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
source.Orders.Remove(element);
source.SaveOrders();
return element.GetViewModel;
}
return null;
}
}
}

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="..\LawFirmContracts\LawFirmContracts.csproj" />
<ProjectReference Include="..\LawFirmDataModels\LawFirmDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,64 @@
using LawFirmContracts.BindingModels;
using LawFirmContracts.ViewModels;
using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace LawFirmFileImplement.Models
{
internal class Component : IComponentModel
{
public int Id { get; private set; }
public string ComponentName { get; private set; } = string.Empty;
public double Cost { get; set; }
public static Component? Create(ComponentBindingModel model)
{
if (model == null)
{
return null;
}
return new Component()
{
Id = model.Id,
ComponentName = model.ComponentName,
Cost = model.Cost
};
}
public static Component? Create(XElement element)
{
if (element == null)
{
return null;
}
return new Component()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ComponentName = element.Element("ComponentName")!.Value,
Cost = Convert.ToDouble(element.Element("Cost")!.Value)
};
}
public void Update(ComponentBindingModel model)
{
if (model == null)
{
return;
}
ComponentName = model.ComponentName;
Cost = model.Cost;
}
public ComponentViewModel GetViewModel => new()
{
Id = Id,
ComponentName = ComponentName,
Cost = Cost
};
public XElement GetXElement => new("Component",
new XAttribute("Id", Id),
new XElement("ComponentName", ComponentName),
new XElement("Cost", Cost.ToString()));
}
}

View File

@ -0,0 +1,99 @@
using LawFirmContracts.BindingModels;
using LawFirmContracts.ViewModels;
using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace LawFirmFileImplement.Models
{
internal class Document : IDocumentModel
{
public int Id { get; private set; }
public string DocumentName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary<int, int> Components { get; private set; } = new();
private Dictionary<int, (IComponentModel, int)>? _documentComponents = null;
public Dictionary<int, (IComponentModel, int)> DocumentComponents
{
get
{
if (_documentComponents == null)
{
var source = DataFileSingleton.GetInstance();
_documentComponents = Components.ToDictionary(x => x.Key, y => ((source.Components.FirstOrDefault(z => z.Id == y.Key) as IComponentModel)!, y.Value));
}
return _documentComponents;
}
}
public static Document? Create(DocumentBindingModel? model)
{
if (model == null)
{
return null;
}
return new Document()
{
Id = model.Id,
DocumentName = model.DocumentName,
Price = model.Price,
Components = model.DocumentComponents.ToDictionary(x => x.Key, x => x.Value.Item2)
};
}
public static Document? Create(XElement element)
{
if (element == null)
{
return null;
}
return new Document()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
DocumentName = element.Element("DocumentName")!.Value,
Price = Convert.ToDouble(element.Element("Price")!.Value),
Components = element.Element("DocumentComponents")!.Elements("DocumentComponent")
.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
};
}
public void Update(DocumentBindingModel? model)
{
if (model == null)
{
return;
}
DocumentName = model.DocumentName;
Price = model.Price;
Components = model.DocumentComponents.ToDictionary(x => x.Key, x => x.Value.Item2);
_documentComponents = null;
}
public DocumentViewModel GetViewModel => new()
{
Id = Id,
DocumentName = DocumentName,
Price = Price,
DocumentComponents = DocumentComponents
};
public XElement GetXElement => new("Document",
new XAttribute("Id", Id),
new XElement("DocumentName", DocumentName),
new XElement("Price", Price.ToString()),
new XElement("DocumentComponents", Components.Select(x => new XElement("DocumentComponent",
new XElement("Key", x.Key),
new XElement("Value", x.Value)))
.ToArray()));
}
}

View File

@ -0,0 +1,104 @@
using LawFirmContracts.BindingModels;
using LawFirmContracts.ViewModels;
using LawFirmDataModels.Enums;
using LawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
namespace LawFirmFileImplement.Models
{
internal class Order : IOrderModel
{
public int Id { get; private set; }
public int DocumentId { get; private set; }
public int Count { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; private set; } = DateTime.Now;
public DateTime? DateImplement { get; private set; }
public static Order? Create(OrderBindingModel? model)
{
if (model == null)
{
return null;
}
return new Order()
{
Id = model.Id,
DocumentId = model.DocumentId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement
};
}
public static Order? Create(XElement element)
{
if (element == null)
{
return null;
}
var order = new Order()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
DocumentId = Convert.ToInt32(element.Element("DocumentId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
DateCreate = DateTime.ParseExact(element.Element("DateCreate")!.Value, "G", null)
};
DateTime.TryParse(element.Element("DateImplement")!.Value, out DateTime dateImpl);
order.DateImplement = dateImpl;
return order;
}
public void Update(OrderBindingModel? model)
{
if (model == null)
{
return;
}
Status = model.Status;
if (model.DateImplement.HasValue)
{
DateImplement = model.DateImplement;
}
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
DocumentId = DocumentId,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
};
public XElement GetXElement => new("Order",
new XAttribute("Id", Id),
new XElement("DocumentId", DocumentId),
new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()),
new XElement("DateCreate", DateCreate.ToString()),
new XElement("DateImplement", DateImplement.ToString()));
}
}

View File

@ -2,7 +2,9 @@
using LawFirmContracts.SearchModels; using LawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts; using LawFirmContracts.StoragesContracts;
using LawFirmContracts.ViewModels; using LawFirmContracts.ViewModels;
using LawFirmListImplement.Models;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -12,34 +14,94 @@ namespace LawFirmListImplement.Implements
{ {
public class DocumentStorage : IDocumentStorage public class DocumentStorage : IDocumentStorage
{ {
public DocumentViewModel? Delete(DocumentBindingModel model) private readonly DataListSingleton _source;
public DocumentStorage()
{ {
throw new NotImplementedException(); _source = DataListSingleton.GetInstance();
} }
public DocumentViewModel? GetElement(DocumentSearchModel model)
{
throw new NotImplementedException();
}
public List<DocumentViewModel> GetFilteredList(DocumentSearchModel model)
{
throw new NotImplementedException();
}
public List<DocumentViewModel> GetFullList() public List<DocumentViewModel> GetFullList()
{ {
throw new NotImplementedException(); var result = new List<DocumentViewModel>();
foreach (var document in _source.Documents)
{
result.Add(document.GetViewModel);
}
return result;
}
public List<DocumentViewModel> GetFilteredList(DocumentSearchModel model)
{
var result = new List<DocumentViewModel>();
if (string.IsNullOrEmpty(model.DocumentName))
{
return result;
}
foreach (var document in _source.Documents)
{
if (document.DocumentName.Contains(model.DocumentName))
{
result.Add(document.GetViewModel);
}
}
return result;
}
public DocumentViewModel? GetElement(DocumentSearchModel model)
{
if (string.IsNullOrEmpty(model.DocumentName) && !model.Id.HasValue)
{
return null;
}
foreach (var document in _source.Documents)
{
if ((!string.IsNullOrEmpty(model.DocumentName) && document.DocumentName == model.DocumentName) || (model.Id.HasValue && document.Id == model.Id))
{
return document.GetViewModel;
}
}
return null;
} }
public DocumentViewModel? Insert(DocumentBindingModel model) public DocumentViewModel? Insert(DocumentBindingModel model)
{ {
throw new NotImplementedException(); model.Id = 1;
foreach (var document in _source.Documents)
{
if (model.Id <= document.Id)
{
model.Id = document.Id + 1;
}
}
var newDocument = Document.Create(model);
if (newDocument == null)
{
return null;
}
_source.Documents.Add(newDocument);
return newDocument.GetViewModel;
} }
public DocumentViewModel? Update(DocumentBindingModel model) public DocumentViewModel? Update(DocumentBindingModel model)
{ {
throw new NotImplementedException(); foreach (var document in _source.Documents)
{
if (document.Id == model.Id)
{
document.Update(model);
return document.GetViewModel;
}
}
return null;
} }
public DocumentViewModel? Delete(DocumentBindingModel model)
{
for (int i = 0; i < _source.Documents.Count; ++i)
{
if (_source.Documents[i].Id == model.Id)
{
var element = _source.Documents[i];
_source.Documents.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
}
} }
} }

View File

@ -2,7 +2,9 @@
using LawFirmContracts.SearchModels; using LawFirmContracts.SearchModels;
using LawFirmContracts.StoragesContracts; using LawFirmContracts.StoragesContracts;
using LawFirmContracts.ViewModels; using LawFirmContracts.ViewModels;
using LawFirmListImplement.Models;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -12,34 +14,112 @@ namespace LawFirmListImplement.Implements
{ {
public class OrderStorage : IOrderStorage public class OrderStorage : IOrderStorage
{ {
public OrderViewModel? Delete(OrderBindingModel model) private readonly DataListSingleton _source;
public OrderStorage()
{ {
throw new NotImplementedException(); _source = DataListSingleton.GetInstance();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
throw new NotImplementedException();
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
throw new NotImplementedException();
} }
public List<OrderViewModel> GetFullList() public List<OrderViewModel> GetFullList()
{ {
throw new NotImplementedException(); var result = new List<OrderViewModel>();
foreach (var order in _source.Orders)
{
OrderViewModel thisorder = order.GetViewModel;
Document? computer = _source.Documents.Find(x => x.Id == order.DocumentId);
string computerName = computer?.DocumentName ?? string.Empty;
thisorder.DocumentName = computerName;
result.Add(thisorder);
}
return result;
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
var result = new List<OrderViewModel>();
if (model.Id.HasValue)
{
return result;
}
foreach (var order in _source.Orders)
{
if (model.Id.HasValue && order.Id == model.Id)
{
OrderViewModel thisorder = order.GetViewModel;
Document? computer = _source.Documents.Find(x => x.Id == order.DocumentId);
string computerName = computer?.DocumentName ?? string.Empty;
thisorder.DocumentName = computerName;
result.Add(thisorder);
}
}
return result;
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
foreach (var order in _source.Orders)
{
if ((model.Id.HasValue && order.Id == model.Id))
{
OrderViewModel thisorder = order.GetViewModel;
Document? computer = _source.Documents.Find(x => x.Id == order.DocumentId);
string computerName = computer?.DocumentName ?? string.Empty;
thisorder.DocumentName = computerName;
return thisorder;
}
}
return null;
} }
public OrderViewModel? Insert(OrderBindingModel model) public OrderViewModel? Insert(OrderBindingModel model)
{ {
throw new NotImplementedException(); model.Id = 1;
foreach (var order in _source.Orders)
{
if (model.Id <= order.Id)
{
model.Id = order.Id + 1;
}
}
var newOrder = Order.Create(model);
if (newOrder == null)
{
return null;
}
_source.Orders.Add(newOrder);
return newOrder.GetViewModel;
} }
public OrderViewModel? Update(OrderBindingModel model) public OrderViewModel? Update(OrderBindingModel model)
{ {
throw new NotImplementedException(); foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
{
order.Update(model);
return order.GetViewModel;
}
}
return null;
}
public OrderViewModel? Delete(OrderBindingModel model)
{
for (int i = 0; i < _source.Orders.Count; ++i)
{
if (_source.Orders[i].Id == model.Id)
{
var element = _source.Orders[i];
_source.Documents.RemoveAt(i);
return element.GetViewModel;
}
}
return null;
} }
} }
} }

View File

@ -1,4 +1,6 @@
using LawFirmDataModels.Enums; using LawFirmContracts.BindingModels;
using LawFirmContracts.ViewModels;
using LawFirmDataModels.Enums;
using LawFirmDataModels.Models; using LawFirmDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -10,18 +12,59 @@ namespace LawFirmListImplement.Models
{ {
internal class Order : IOrderModel internal class Order : IOrderModel
{ {
public int DocumentId => throw new NotImplementedException(); public int Id { get; private set; }
public int Count => throw new NotImplementedException(); public int DocumentId { get; private set; }
public double Sum => throw new NotImplementedException(); public int Count { get; private set; }
public OrderStatus Status => throw new NotImplementedException(); public double Sum { get; private set; }
public DateTime DateCreate => throw new NotImplementedException(); public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public DateTime? DateImplement => throw new NotImplementedException(); public DateTime DateCreate { get; set; } = DateTime.Now;
public int Id => throw new NotImplementedException(); public DateTime? DateImplement { get; set; }
public static Order? Create(OrderBindingModel? model)
{
if (model == null)
{
return null;
}
return new Order()
{
Id = model.Id,
DocumentId = model.DocumentId,
Count = model.Count,
Sum = model.Sum,
Status = model.Status,
DateCreate = model.DateCreate,
DateImplement = model.DateImplement
};
}
public void Update(OrderBindingModel? model)
{
if (model == null)
{
return;
}
Status = model.Status;
if (model.DateImplement != null)
{
DateImplement = model.DateImplement;
}
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
DocumentId = DocumentId,
Count = Count,
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
DateImplement = DateImplement
};
} }
} }

View File

@ -28,82 +28,86 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); label1 = new Label();
this.label2 = new System.Windows.Forms.Label(); label2 = new Label();
this.buttonSave = new System.Windows.Forms.Button(); buttonSave = new Button();
this.buttonCancel = new System.Windows.Forms.Button(); buttonCancel = new Button();
this.textBoxName = new System.Windows.Forms.TextBox(); textBoxName = new TextBox();
this.textBoxCost = new System.Windows.Forms.TextBox(); textBoxCost = new TextBox();
this.SuspendLayout(); SuspendLayout();
// //
// label1 // label1
// //
this.label1.AutoSize = true; label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 18); label1.Location = new Point(14, 24);
this.label1.Name = "label1"; label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(62, 15); label1.Size = new Size(80, 20);
this.label1.TabIndex = 0; label1.TabIndex = 0;
this.label1.Text = "Название:"; label1.Text = "Название:";
// //
// label2 // label2
// //
this.label2.AutoSize = true; label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 46); label2.Location = new Point(14, 61);
this.label2.Name = "label2"; label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(38, 15); label2.Size = new Size(48, 20);
this.label2.TabIndex = 1; label2.TabIndex = 1;
this.label2.Text = "Цена:"; label2.Text = "Цена:";
// //
// buttonSave // buttonSave
// //
this.buttonSave.Location = new System.Drawing.Point(181, 80); buttonSave.Location = new Point(183, 107);
this.buttonSave.Name = "buttonSave"; buttonSave.Margin = new Padding(3, 4, 3, 4);
this.buttonSave.Size = new System.Drawing.Size(75, 23); buttonSave.Name = "buttonSave";
this.buttonSave.TabIndex = 2; buttonSave.Size = new Size(99, 31);
this.buttonSave.Text = "Сохранить"; buttonSave.TabIndex = 2;
this.buttonSave.UseVisualStyleBackColor = true; buttonSave.Text = "Сохранить";
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
// //
// buttonCancel // buttonCancel
// //
this.buttonCancel.Location = new System.Drawing.Point(262, 80); buttonCancel.Location = new Point(288, 107);
this.buttonCancel.Name = "buttonCancel"; buttonCancel.Margin = new Padding(3, 4, 3, 4);
this.buttonCancel.Size = new System.Drawing.Size(75, 23); buttonCancel.Name = "buttonCancel";
this.buttonCancel.TabIndex = 3; buttonCancel.Size = new Size(97, 31);
this.buttonCancel.Text = "Отмена"; buttonCancel.TabIndex = 3;
this.buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Text = "Отмена";
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
// //
// textBoxName // textBoxName
// //
this.textBoxName.Location = new System.Drawing.Point(80, 15); textBoxName.Location = new Point(91, 20);
this.textBoxName.Name = "textBoxName"; textBoxName.Margin = new Padding(3, 4, 3, 4);
this.textBoxName.Size = new System.Drawing.Size(257, 23); textBoxName.Name = "textBoxName";
this.textBoxName.TabIndex = 4; textBoxName.Size = new Size(293, 27);
textBoxName.TabIndex = 4;
// //
// textBoxCost // textBoxCost
// //
this.textBoxCost.Location = new System.Drawing.Point(80, 43); textBoxCost.Location = new Point(91, 57);
this.textBoxCost.Name = "textBoxCost"; textBoxCost.Margin = new Padding(3, 4, 3, 4);
this.textBoxCost.Size = new System.Drawing.Size(127, 23); textBoxCost.Name = "textBoxCost";
this.textBoxCost.TabIndex = 5; textBoxCost.Size = new Size(145, 27);
textBoxCost.TabIndex = 5;
// //
// FormComponent // FormComponent
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleDimensions = new SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(356, 119); ClientSize = new Size(407, 159);
this.Controls.Add(this.textBoxCost); Controls.Add(textBoxCost);
this.Controls.Add(this.textBoxName); Controls.Add(textBoxName);
this.Controls.Add(this.buttonCancel); Controls.Add(buttonCancel);
this.Controls.Add(this.buttonSave); Controls.Add(buttonSave);
this.Controls.Add(this.label2); Controls.Add(label2);
this.Controls.Add(this.label1); Controls.Add(label1);
this.Name = "FormComponent"; Margin = new Padding(3, 4, 3, 4);
this.Text = "Компонент"; Name = "FormComponent";
this.ResumeLayout(false); Text = "Компонент";
this.PerformLayout(); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion

View File

@ -17,11 +17,11 @@ 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)

View File

@ -34,10 +34,9 @@
this.buttonDel = new System.Windows.Forms.Button(); this.buttonDel = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button(); this.buttonRef = new System.Windows.Forms.Button();
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
this.Load += new System.EventHandler(this.FormComponents_Load);
// //
// dataGridView // dataGridView
// //
@ -46,9 +45,7 @@
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; 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.ColumnId});
this.Column1,
this.Column2});
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGridView.Location = new System.Drawing.Point(0, 0); this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
@ -108,19 +105,6 @@
this.ColumnId.ReadOnly = true; this.ColumnId.ReadOnly = true;
this.ColumnId.Visible = false; this.ColumnId.Visible = false;
// //
// Column1
//
this.Column1.HeaderText = "Название компонента";
this.Column1.Name = "Column1";
this.Column1.ReadOnly = true;
this.Column1.Width = 383;
//
// Column2
//
this.Column2.HeaderText = "Цена";
this.Column2.Name = "Column2";
this.Column2.ReadOnly = true;
//
// FormComponents // FormComponents
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
@ -146,7 +130,5 @@
private Button buttonDel; private Button buttonDel;
private Button buttonRef; private Button buttonRef;
private DataGridViewTextBoxColumn ColumnId; private DataGridViewTextBoxColumn ColumnId;
private DataGridViewTextBoxColumn Column1;
private DataGridViewTextBoxColumn Column2;
} }
} }

View File

@ -60,10 +60,4 @@
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </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>
</root> </root>

View File

@ -28,107 +28,113 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); label1 = new Label();
this.label2 = new System.Windows.Forms.Label(); label2 = new Label();
this.label3 = new System.Windows.Forms.Label(); label3 = new Label();
this.comboBoxProduct = new System.Windows.Forms.ComboBox(); comboBoxDocument = new ComboBox();
this.textBoxCount = new System.Windows.Forms.TextBox(); textBoxCount = new TextBox();
this.textBoxSum = new System.Windows.Forms.TextBox(); textBoxSum = new TextBox();
this.buttonSave = new System.Windows.Forms.Button(); buttonSave = new Button();
this.buttonCancel = new System.Windows.Forms.Button(); buttonCancel = new Button();
this.SuspendLayout(); SuspendLayout();
// //
// label1 // label1
// //
this.label1.AutoSize = true; label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9); label1.Location = new Point(14, 12);
this.label1.Name = "label1"; label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 15); label1.Size = new Size(71, 20);
this.label1.TabIndex = 0; label1.TabIndex = 0;
this.label1.Text = "Изделие:"; label1.Text = "Изделие:";
// //
// label2 // label2
// //
this.label2.AutoSize = true; label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 37); label2.Location = new Point(14, 56);
this.label2.Name = "label2"; label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(75, 15); label2.Size = new Size(93, 20);
this.label2.TabIndex = 1; label2.TabIndex = 1;
this.label2.Text = "Количество:"; label2.Text = "Количество:";
// //
// label3 // label3
// //
this.label3.AutoSize = true; label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(12, 64); label3.Location = new Point(14, 99);
this.label3.Name = "label3"; label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(48, 15); label3.Size = new Size(58, 20);
this.label3.TabIndex = 2; label3.TabIndex = 2;
this.label3.Text = "Сумма:"; label3.Text = "Сумма:";
// //
// comboBoxProduct // comboBoxDocument
// //
this.comboBoxProduct.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; comboBoxDocument.DropDownStyle = ComboBoxStyle.DropDownList;
this.comboBoxProduct.FormattingEnabled = true; comboBoxDocument.FormattingEnabled = true;
this.comboBoxProduct.Location = new System.Drawing.Point(93, 6); comboBoxDocument.Location = new Point(106, 8);
this.comboBoxProduct.Name = "comboBoxProduct"; comboBoxDocument.Margin = new Padding(3, 4, 3, 4);
this.comboBoxProduct.Size = new System.Drawing.Size(270, 23); comboBoxDocument.Name = "comboBoxDocument";
this.comboBoxProduct.TabIndex = 3; comboBoxDocument.Size = new Size(308, 28);
this.comboBoxProduct.SelectedIndexChanged += new System.EventHandler(this.ComboBoxProduct_SelectedIndexChanged); comboBoxDocument.TabIndex = 5;
comboBoxDocument.SelectedIndexChanged += ComboBoxDocument_SelectedIndexChanged;
// //
// textBoxCount // textBoxCount
// //
this.textBoxCount.Location = new System.Drawing.Point(93, 34); textBoxCount.Location = new Point(106, 52);
this.textBoxCount.Name = "textBoxCount"; textBoxCount.Margin = new Padding(3, 4, 3, 4);
this.textBoxCount.Size = new System.Drawing.Size(270, 23); textBoxCount.Name = "textBoxCount";
this.textBoxCount.TabIndex = 4; textBoxCount.Size = new Size(308, 27);
this.textBoxCount.TextChanged += new System.EventHandler(this.TextBoxCount_TextChanged); textBoxCount.TabIndex = 4;
textBoxCount.TextChanged += TextBoxCount_TextChanged;
// //
// textBoxSum // textBoxSum
// //
this.textBoxSum.Location = new System.Drawing.Point(93, 61); textBoxSum.Location = new Point(106, 95);
this.textBoxSum.Name = "textBoxSum"; textBoxSum.Margin = new Padding(3, 4, 3, 4);
this.textBoxSum.ReadOnly = true; textBoxSum.Name = "textBoxSum";
this.textBoxSum.Size = new System.Drawing.Size(270, 23); textBoxSum.ReadOnly = true;
this.textBoxSum.TabIndex = 5; textBoxSum.Size = new Size(308, 27);
textBoxSum.TabIndex = 5;
// //
// buttonSave // buttonSave
// //
this.buttonSave.Location = new System.Drawing.Point(207, 106); buttonSave.Location = new Point(222, 141);
this.buttonSave.Name = "buttonSave"; buttonSave.Margin = new Padding(3, 4, 3, 4);
this.buttonSave.Size = new System.Drawing.Size(75, 23); buttonSave.Name = "buttonSave";
this.buttonSave.TabIndex = 6; buttonSave.Size = new Size(93, 31);
this.buttonSave.Text = "Сохранить"; buttonSave.TabIndex = 6;
this.buttonSave.UseVisualStyleBackColor = true; buttonSave.Text = "Сохранить";
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
// //
// buttonCancel // buttonCancel
// //
this.buttonCancel.Location = new System.Drawing.Point(288, 106); buttonCancel.Location = new Point(321, 141);
this.buttonCancel.Name = "buttonCancel"; buttonCancel.Margin = new Padding(3, 4, 3, 4);
this.buttonCancel.Size = new System.Drawing.Size(75, 23); buttonCancel.Name = "buttonCancel";
this.buttonCancel.TabIndex = 7; buttonCancel.Size = new Size(94, 31);
this.buttonCancel.Text = "Отмена"; buttonCancel.TabIndex = 7;
this.buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Text = "Отмена";
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
// //
// FormCreateOrder // FormCreateOrder
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleDimensions = new SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(381, 141); ClientSize = new Size(435, 188);
this.Controls.Add(this.buttonCancel); Controls.Add(buttonCancel);
this.Controls.Add(this.buttonSave); Controls.Add(buttonSave);
this.Controls.Add(this.textBoxSum); Controls.Add(textBoxSum);
this.Controls.Add(this.textBoxCount); Controls.Add(textBoxCount);
this.Controls.Add(this.comboBoxProduct); Controls.Add(comboBoxDocument);
this.Controls.Add(this.label3); Controls.Add(label3);
this.Controls.Add(this.label2); Controls.Add(label2);
this.Controls.Add(this.label1); Controls.Add(label1);
this.Name = "FormCreateOrder"; Margin = new Padding(3, 4, 3, 4);
this.Text = "FormCreateOrder"; Name = "FormCreateOrder";
this.ResumeLayout(false); Text = "Заказ";
this.PerformLayout(); Load += FormCreateOrder_Load;
ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
@ -136,7 +142,7 @@
private Label label1; private Label label1;
private Label label2; private Label label2;
private Label label3; private Label label3;
private ComboBox comboBoxProduct; private ComboBox comboBoxDocument;
private TextBox textBoxCount; private TextBox textBoxCount;
private TextBox textBoxSum; private TextBox textBoxSum;
private Button buttonSave; private Button buttonSave;

View File

@ -18,34 +18,42 @@ namespace LawFirmView
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IDocumentLogic _logicP; private readonly IDocumentLogic _logicD;
private readonly IOrderLogic _logicO; private readonly IOrderLogic _logicO;
public FormCreateOrder(ILogger<FormCreateOrder> logger, IDocumentLogic logicP, IOrderLogic logicO) public FormCreateOrder(ILogger<FormCreateOrder> logger, IDocumentLogic logicD, 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("Загрузка изделий для заказа");
// прописать логику
var list = _logicD.ReadList(null);
if (list != null)
{
comboBoxDocument.DisplayMember = "DocumentName";
comboBoxDocument.ValueMember = "Id";
comboBoxDocument.DataSource = list;
comboBoxDocument.SelectedItem = null;
}
} }
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 document = _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 * (document?.Price ?? 0), 2).ToString();
_logger.LogInformation("Расчет суммы заказа"); _logger.LogInformation("Расчет суммы заказа");
} }
catch (Exception ex) catch (Exception ex)
@ -61,7 +69,7 @@ namespace LawFirmView
CalcSum(); CalcSum();
} }
private void ComboBoxProduct_SelectedIndexChanged(object sender, EventArgs e) private void ComboBoxDocument_SelectedIndexChanged(object sender, EventArgs e)
{ {
CalcSum(); CalcSum();
} }
@ -73,7 +81,7 @@ namespace LawFirmView
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;
@ -81,9 +89,12 @@ namespace LawFirmView
_logger.LogInformation("Создание заказа"); _logger.LogInformation("Создание заказа");
try try
{ {
int id = Convert.ToInt32(comboBoxDocument.SelectedValue);
int counr = Convert.ToInt32(textBoxCount.Text);
double sum = Convert.ToDouble(textBoxSum.Text);
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)
}); });
@ -107,7 +118,7 @@ namespace LawFirmView
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
} }
} }

View File

@ -28,192 +28,206 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); label1 = new Label();
this.label2 = new System.Windows.Forms.Label(); label2 = new Label();
this.textBoxName = new System.Windows.Forms.TextBox(); textBoxName = new TextBox();
this.textBoxPrice = new System.Windows.Forms.TextBox(); textBoxPrice = new TextBox();
this.groupBoxComponents = new System.Windows.Forms.GroupBox(); groupBoxComponents = new GroupBox();
this.buttonRef = new System.Windows.Forms.Button(); buttonRef = new Button();
this.buttonDel = new System.Windows.Forms.Button(); buttonDel = new Button();
this.buttonUpd = new System.Windows.Forms.Button(); buttonUpd = new Button();
this.buttonAdd = new System.Windows.Forms.Button(); buttonAdd = new Button();
this.dataGridView = new System.Windows.Forms.DataGridView(); dataGridView = new DataGridView();
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn(); ColumnId = new DataGridViewTextBoxColumn();
this.ColumnName = new System.Windows.Forms.DataGridViewTextBoxColumn(); ColumnName = new DataGridViewTextBoxColumn();
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); ColumnCount = new DataGridViewTextBoxColumn();
this.buttonSave = new System.Windows.Forms.Button(); buttonSave = new Button();
this.buttonCancel = new System.Windows.Forms.Button(); buttonCancel = new Button();
this.groupBoxComponents.SuspendLayout(); groupBoxComponents.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
this.SuspendLayout(); SuspendLayout();
// //
// label1 // label1
// //
this.label1.AutoSize = true; label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 9); label1.Location = new Point(14, 12);
this.label1.Name = "label1"; label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(62, 15); label1.Size = new Size(80, 20);
this.label1.TabIndex = 0; label1.TabIndex = 0;
this.label1.Text = "Название:"; label1.Text = "Название:";
// //
// label2 // label2
// //
this.label2.AutoSize = true; label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 40); label2.Location = new Point(14, 53);
this.label2.Name = "label2"; label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(70, 15); label2.Size = new Size(86, 20);
this.label2.TabIndex = 1; label2.TabIndex = 1;
this.label2.Text = "Стоимость:"; label2.Text = "Стоимость:";
// //
// textBoxName // textBoxName
// //
this.textBoxName.Location = new System.Drawing.Point(80, 6); textBoxName.Location = new Point(91, 8);
this.textBoxName.Name = "textBoxName"; textBoxName.Margin = new Padding(3, 4, 3, 4);
this.textBoxName.Size = new System.Drawing.Size(256, 23); textBoxName.Name = "textBoxName";
this.textBoxName.TabIndex = 2; textBoxName.Size = new Size(292, 27);
textBoxName.TabIndex = 2;
// //
// textBoxPrice // textBoxPrice
// //
this.textBoxPrice.Enabled = false; textBoxPrice.Enabled = false;
this.textBoxPrice.Location = new System.Drawing.Point(80, 37); textBoxPrice.Location = new Point(91, 49);
this.textBoxPrice.Name = "textBoxPrice"; textBoxPrice.Margin = new Padding(3, 4, 3, 4);
this.textBoxPrice.Size = new System.Drawing.Size(132, 23); textBoxPrice.Name = "textBoxPrice";
this.textBoxPrice.TabIndex = 3; textBoxPrice.Size = new Size(150, 27);
textBoxPrice.TabIndex = 3;
// //
// groupBoxComponents // groupBoxComponents
// //
this.groupBoxComponents.Controls.Add(this.buttonRef); groupBoxComponents.Controls.Add(buttonRef);
this.groupBoxComponents.Controls.Add(this.buttonDel); groupBoxComponents.Controls.Add(buttonDel);
this.groupBoxComponents.Controls.Add(this.buttonUpd); groupBoxComponents.Controls.Add(buttonUpd);
this.groupBoxComponents.Controls.Add(this.buttonAdd); groupBoxComponents.Controls.Add(buttonAdd);
this.groupBoxComponents.Controls.Add(this.dataGridView); groupBoxComponents.Controls.Add(dataGridView);
this.groupBoxComponents.Location = new System.Drawing.Point(12, 73); groupBoxComponents.Location = new Point(14, 97);
this.groupBoxComponents.Name = "groupBoxComponents"; groupBoxComponents.Margin = new Padding(3, 4, 3, 4);
this.groupBoxComponents.Size = new System.Drawing.Size(561, 311); groupBoxComponents.Name = "groupBoxComponents";
this.groupBoxComponents.TabIndex = 4; groupBoxComponents.Padding = new Padding(3, 4, 3, 4);
this.groupBoxComponents.TabStop = false; groupBoxComponents.Size = new Size(641, 415);
this.groupBoxComponents.Text = "Компоненты"; groupBoxComponents.TabIndex = 4;
groupBoxComponents.TabStop = false;
groupBoxComponents.Text = "Компоненты";
// //
// buttonRef // buttonRef
// //
this.buttonRef.Location = new System.Drawing.Point(428, 136); buttonRef.Location = new Point(489, 181);
this.buttonRef.Name = "buttonRef"; buttonRef.Margin = new Padding(3, 4, 3, 4);
this.buttonRef.Size = new System.Drawing.Size(75, 23); buttonRef.Name = "buttonRef";
this.buttonRef.TabIndex = 4; buttonRef.Size = new Size(86, 31);
this.buttonRef.Text = "Обновить"; buttonRef.TabIndex = 4;
this.buttonRef.UseVisualStyleBackColor = true; buttonRef.Text = "Обновить";
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
// //
// buttonDel // buttonDel
// //
this.buttonDel.Location = new System.Drawing.Point(428, 98); buttonDel.Location = new Point(489, 131);
this.buttonDel.Name = "buttonDel"; buttonDel.Margin = new Padding(3, 4, 3, 4);
this.buttonDel.Size = new System.Drawing.Size(75, 23); buttonDel.Name = "buttonDel";
this.buttonDel.TabIndex = 3; buttonDel.Size = new Size(86, 31);
this.buttonDel.Text = "Удалить"; buttonDel.TabIndex = 3;
this.buttonDel.UseVisualStyleBackColor = true; buttonDel.Text = "Удалить";
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click); buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
// //
// buttonUpd // buttonUpd
// //
this.buttonUpd.Location = new System.Drawing.Point(428, 60); buttonUpd.Location = new Point(489, 80);
this.buttonUpd.Name = "buttonUpd"; buttonUpd.Margin = new Padding(3, 4, 3, 4);
this.buttonUpd.Size = new System.Drawing.Size(75, 23); buttonUpd.Name = "buttonUpd";
this.buttonUpd.TabIndex = 2; buttonUpd.Size = new Size(86, 31);
this.buttonUpd.Text = "Изменить"; buttonUpd.TabIndex = 2;
this.buttonUpd.UseVisualStyleBackColor = true; buttonUpd.Text = "Изменить";
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
// //
// buttonAdd // buttonAdd
// //
this.buttonAdd.Location = new System.Drawing.Point(428, 22); buttonAdd.Location = new Point(489, 29);
this.buttonAdd.Name = "buttonAdd"; buttonAdd.Margin = new Padding(3, 4, 3, 4);
this.buttonAdd.Size = new System.Drawing.Size(75, 23); buttonAdd.Name = "buttonAdd";
this.buttonAdd.TabIndex = 1; buttonAdd.Size = new Size(86, 31);
this.buttonAdd.Text = "Добавить"; buttonAdd.TabIndex = 1;
this.buttonAdd.UseVisualStyleBackColor = true; buttonAdd.Text = "Добавить";
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
// //
// dataGridView // dataGridView
// //
this.dataGridView.AllowUserToAddRows = false; dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false; dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; dataGridView.BackgroundColor = SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnName, ColumnCount });
this.ColumnId, dataGridView.Dock = DockStyle.Left;
this.ColumnName, dataGridView.Location = new Point(3, 24);
this.ColumnCount}); dataGridView.Margin = new Padding(5, 4, 5, 4);
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; dataGridView.MultiSelect = false;
this.dataGridView.Location = new System.Drawing.Point(3, 19); dataGridView.Name = "dataGridView";
this.dataGridView.MultiSelect = false; dataGridView.ReadOnly = true;
this.dataGridView.Name = "dataGridView"; dataGridView.RowHeadersVisible = false;
this.dataGridView.ReadOnly = true; dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowHeadersVisible = false; dataGridView.RowTemplate.Height = 25;
this.dataGridView.RowTemplate.Height = 25; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; dataGridView.Size = new Size(433, 387);
this.dataGridView.Size = new System.Drawing.Size(408, 289); dataGridView.TabIndex = 0;
this.dataGridView.TabIndex = 0;
// //
// ColumnId // ColumnId
// //
this.ColumnId.HeaderText = "Id"; ColumnId.HeaderText = "Id";
this.ColumnId.Name = "ColumnId"; ColumnId.MinimumWidth = 6;
this.ColumnId.ReadOnly = true; ColumnId.Name = "ColumnId";
this.ColumnId.Visible = false; ColumnId.ReadOnly = true;
ColumnId.Visible = false;
ColumnId.Width = 125;
// //
// ColumnName // ColumnName
// //
this.ColumnName.HeaderText = "Компонент"; ColumnName.HeaderText = "Компонент";
this.ColumnName.Name = "ColumnName"; ColumnName.MinimumWidth = 6;
this.ColumnName.ReadOnly = true; ColumnName.Name = "ColumnName";
this.ColumnName.Width = 305; ColumnName.ReadOnly = true;
ColumnName.Width = 305;
// //
// ColumnCount // ColumnCount
// //
this.ColumnCount.HeaderText = "Количество"; ColumnCount.HeaderText = "Количество";
this.ColumnCount.Name = "ColumnCount"; ColumnCount.MinimumWidth = 6;
this.ColumnCount.ReadOnly = true; ColumnCount.Name = "ColumnCount";
ColumnCount.ReadOnly = true;
ColumnCount.Width = 125;
// //
// buttonSave // buttonSave
// //
this.buttonSave.Location = new System.Drawing.Point(377, 397); buttonSave.Location = new Point(422, 529);
this.buttonSave.Name = "buttonSave"; buttonSave.Margin = new Padding(3, 4, 3, 4);
this.buttonSave.Size = new System.Drawing.Size(75, 23); buttonSave.Name = "buttonSave";
this.buttonSave.TabIndex = 5; buttonSave.Size = new Size(95, 31);
this.buttonSave.Text = "Сохранить"; buttonSave.TabIndex = 5;
this.buttonSave.UseVisualStyleBackColor = true; buttonSave.Text = "Сохранить";
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
// //
// buttonCancel // buttonCancel
// //
this.buttonCancel.Location = new System.Drawing.Point(458, 397); buttonCancel.Location = new Point(523, 529);
this.buttonCancel.Name = "buttonCancel"; buttonCancel.Margin = new Padding(3, 4, 3, 4);
this.buttonCancel.Size = new System.Drawing.Size(75, 23); buttonCancel.Name = "buttonCancel";
this.buttonCancel.TabIndex = 6; buttonCancel.Size = new Size(98, 31);
this.buttonCancel.Text = "Отмена"; buttonCancel.TabIndex = 6;
this.buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Text = "Отмена";
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
// //
// FormDocument // FormDocument
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleDimensions = new SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(586, 432); ClientSize = new Size(670, 576);
this.Controls.Add(this.buttonCancel); Controls.Add(buttonCancel);
this.Controls.Add(this.buttonSave); Controls.Add(buttonSave);
this.Controls.Add(this.groupBoxComponents); Controls.Add(groupBoxComponents);
this.Controls.Add(this.textBoxPrice); Controls.Add(textBoxPrice);
this.Controls.Add(this.textBoxName); Controls.Add(textBoxName);
this.Controls.Add(this.label2); Controls.Add(label2);
this.Controls.Add(this.label1); Controls.Add(label1);
this.Name = "FormDocument"; Margin = new Padding(3, 4, 3, 4);
this.Text = "Изделие"; Name = "FormDocument";
this.groupBoxComponents.ResumeLayout(false); Text = "Изделие";
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); groupBoxComponents.ResumeLayout(false);
this.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
this.PerformLayout(); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion

View File

@ -43,7 +43,7 @@ namespace LawFirmView
{ {
textBoxName.Text = view.DocumentName; textBoxName.Text = view.DocumentName;
textBoxPrice.Text = view.Price.ToString(); textBoxPrice.Text = view.Price.ToString();
_documentComponents = view.DocumentComponents ?? new Dictionary<int, (IComponentModel, int)>(); _documentComponents = view.DocumentComponents ?? new Dictionary<int, (IComponentModel, int)>();
LoadData(); LoadData();
} }
} }
@ -191,7 +191,7 @@ 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);
} }

View File

@ -66,13 +66,4 @@
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

View File

@ -28,84 +28,89 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.label1 = new System.Windows.Forms.Label(); label1 = new Label();
this.label2 = new System.Windows.Forms.Label(); label2 = new Label();
this.comboBoxComponent = new System.Windows.Forms.ComboBox(); comboBoxComponent = new ComboBox();
this.textBoxCount = new System.Windows.Forms.TextBox(); textBoxCount = new TextBox();
this.buttonSave = new System.Windows.Forms.Button(); buttonSave = new Button();
this.buttonCancel = new System.Windows.Forms.Button(); buttonCancel = new Button();
this.SuspendLayout(); SuspendLayout();
// //
// label1 // label1
// //
this.label1.AutoSize = true; label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(21, 18); label1.Location = new Point(24, 24);
this.label1.Name = "label1"; label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(72, 15); label1.Size = new Size(91, 20);
this.label1.TabIndex = 0; label1.TabIndex = 0;
this.label1.Text = "Компонент:"; label1.Text = "Компонент:";
// //
// label2 // label2
// //
this.label2.AutoSize = true; label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(18, 46); label2.Location = new Point(21, 61);
this.label2.Name = "label2"; label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(75, 15); label2.Size = new Size(93, 20);
this.label2.TabIndex = 1; label2.TabIndex = 1;
this.label2.Text = "Количество:"; label2.Text = "Количество:";
// //
// comboBoxComponent // comboBoxComponent
// //
this.comboBoxComponent.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; comboBoxComponent.DropDownStyle = ComboBoxStyle.DropDownList;
this.comboBoxComponent.FormattingEnabled = true; comboBoxComponent.FormattingEnabled = true;
this.comboBoxComponent.Location = new System.Drawing.Point(99, 15); comboBoxComponent.Location = new Point(113, 20);
this.comboBoxComponent.Name = "comboBoxComponent"; comboBoxComponent.Margin = new Padding(3, 4, 3, 4);
this.comboBoxComponent.Size = new System.Drawing.Size(249, 23); comboBoxComponent.Name = "comboBoxComponent";
this.comboBoxComponent.TabIndex = 2; comboBoxComponent.Size = new Size(284, 28);
comboBoxComponent.TabIndex = 4;
comboBoxComponent.SelectedIndexChanged += comboBoxComponent_SelectedIndexChanged;
// //
// textBoxCount // textBoxCount
// //
this.textBoxCount.Location = new System.Drawing.Point(99, 43); textBoxCount.Location = new Point(113, 57);
this.textBoxCount.Name = "textBoxCount"; textBoxCount.Margin = new Padding(3, 4, 3, 4);
this.textBoxCount.Size = new System.Drawing.Size(249, 23); textBoxCount.Name = "textBoxCount";
this.textBoxCount.TabIndex = 3; textBoxCount.Size = new Size(284, 27);
textBoxCount.TabIndex = 3;
// //
// buttonSave // buttonSave
// //
this.buttonSave.Location = new System.Drawing.Point(132, 81); buttonSave.Location = new Point(140, 108);
this.buttonSave.Name = "buttonSave"; buttonSave.Margin = new Padding(3, 4, 3, 4);
this.buttonSave.Size = new System.Drawing.Size(75, 23); buttonSave.Name = "buttonSave";
this.buttonSave.TabIndex = 4; buttonSave.Size = new Size(97, 31);
this.buttonSave.Text = "Сохранить"; buttonSave.TabIndex = 4;
this.buttonSave.UseVisualStyleBackColor = true; buttonSave.Text = "Сохранить";
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click); buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
// //
// buttonCancel // buttonCancel
// //
this.buttonCancel.Location = new System.Drawing.Point(213, 81); buttonCancel.Location = new Point(243, 108);
this.buttonCancel.Name = "buttonCancel"; buttonCancel.Margin = new Padding(3, 4, 3, 4);
this.buttonCancel.Size = new System.Drawing.Size(75, 23); buttonCancel.Name = "buttonCancel";
this.buttonCancel.TabIndex = 5; buttonCancel.Size = new Size(96, 31);
this.buttonCancel.Text = "Отмена"; buttonCancel.TabIndex = 5;
this.buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Text = "Отмена";
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
// //
// FormDocumentComponent // FormDocumentComponent
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleDimensions = new SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(369, 124); ClientSize = new Size(422, 165);
this.Controls.Add(this.buttonCancel); Controls.Add(buttonCancel);
this.Controls.Add(this.buttonSave); Controls.Add(buttonSave);
this.Controls.Add(this.textBoxCount); Controls.Add(textBoxCount);
this.Controls.Add(this.comboBoxComponent); Controls.Add(comboBoxComponent);
this.Controls.Add(this.label2); Controls.Add(label2);
this.Controls.Add(this.label1); Controls.Add(label1);
this.Name = "FormDocumentComponent"; Margin = new Padding(3, 4, 3, 4);
this.Text = "FormDocumentComponent"; Name = "FormDocumentComponent";
this.ResumeLayout(false); Text = "Компонент изделия";
this.PerformLayout(); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion

View File

@ -17,13 +17,13 @@ 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); } get { return Convert.ToInt32(comboBoxComponent.SelectedValue); }
set { comboBoxComponent.SelectedValue = value; } set { comboBoxComponent.SelectedValue = value; }
} }
public IComponentModel? ComponentModel public IComponentModel? ComponentModel
{ {
get get
@ -84,5 +84,10 @@ namespace LawFirmView
DialogResult = DialogResult.Cancel; DialogResult = DialogResult.Cancel;
Close(); Close();
} }
private void comboBoxComponent_SelectedIndexChanged(object sender, EventArgs e)
{
}
} }
} }

View File

@ -0,0 +1,115 @@
namespace LawFirmView
{
partial class FormDocuments
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.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();
this.SuspendLayout();
this.Load += new System.EventHandler(this.FormDocuments_Load);
//
// dataGridView
//
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(1, 1);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(457, 450);
this.dataGridView.TabIndex = 0;
//
// buttonAdd
//
this.buttonAdd.Location = new System.Drawing.Point(483, 12);
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(483, 51);
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(483, 90);
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(483, 129);
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);
//
// FormDocuments
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(589, 450);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.buttonUpd);
this.Controls.Add(this.buttonAdd);
this.Controls.Add(this.dataGridView);
this.Name = "FormDocuments";
this.Text = "Изделия";
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private Button buttonRef;
}
}

View File

@ -0,0 +1,112 @@
using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicsContracts;
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
{
public partial class FormDocuments : Form
{
private readonly ILogger _logger;
private readonly IDocumentLogic _logic;
public FormDocuments(ILogger<FormComponents> logger, IDocumentLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormDocuments_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["DocumentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["DocumentComponents"].Visible = false;
}
_logger.LogInformation("Загрузка документов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки документов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDocument));
if (service is FormDocument form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDocument));
if (service is FormDocument form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Удаление документов");
try
{
if (!_logic.Delete(new DocumentBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления документов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void buttonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

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

View File

@ -28,211 +28,152 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.menuStrip1 = new System.Windows.Forms.MenuStrip(); menuStrip1 = new MenuStrip();
this.справочникиToolStripMenuItem = 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(); изделияToolStripMenuItem = new ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView(); buttonCreateOrder = new Button();
this.buttonCreateOrder = new System.Windows.Forms.Button(); buttonTakeOrderInWork = new Button();
this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); buttonOrderReady = new Button();
this.buttonOrderReady = new System.Windows.Forms.Button(); buttonIssuedOrder = new Button();
this.buttonIssuedOrder = new System.Windows.Forms.Button(); buttonRef = new Button();
this.buttonRef = new System.Windows.Forms.Button(); dataGridView = new DataGridView();
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn(); menuStrip1.SuspendLayout();
this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn(); SuspendLayout();
this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
// //
// menuStrip1 // menuStrip1
// //
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { menuStrip1.ImageScalingSize = new Size(20, 20);
this.справочникиToolStripMenuItem}); menuStrip1.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
this.menuStrip1.Location = new System.Drawing.Point(0, 0); menuStrip1.Location = new Point(0, 0);
this.menuStrip1.Name = "menuStrip1"; menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(870, 24); menuStrip1.Padding = new Padding(7, 3, 0, 3);
this.menuStrip1.TabIndex = 0; menuStrip1.Size = new Size(1150, 30);
this.menuStrip1.Text = "menuStrip1"; menuStrip1.TabIndex = 0;
menuStrip1.Text = "menuStrip1";
// //
// справочникиToolStripMenuItem // справочникиToolStripMenuItem
// //
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделияToolStripMenuItem });
this.компонентыToolStripMenuItem, справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
this.изделияToolStripMenuItem}); справочникиToolStripMenuItem.Size = new Size(117, 24);
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Text = "Справочники";
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
this.справочникиToolStripMenuItem.Text = "Справочники";
// //
// компонентыToolStripMenuItem // компонентыToolStripMenuItem
// //
this.компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem"; компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem";
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(180, 22); компонентыToolStripMenuItem.Size = new Size(182, 26);
this.компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Text = "Компоненты";
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click_1); компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click_1;
// //
// изделияToolStripMenuItem // изделияToolStripMenuItem
// //
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(180, 22); изделияToolStripMenuItem.Size = new Size(182, 26);
this.изделияToolStripMenuItem.Text = "Изделия"; изделияToolStripMenuItem.Text = "Изделия";
this.изделияToolStripMenuItem.Click += new System.EventHandler(this.изделияToolStripMenuItem_Click_1); изделияToolStripMenuItem.Click += изделияToolStripMenuItem_Click_1;
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.ColumnId,
this.Column1,
this.Column2,
this.Column3,
this.Column4,
this.Column5,
this.Column6,
this.Column7});
this.dataGridView.Location = new System.Drawing.Point(0, 27);
this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersVisible = false;
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(702, 353);
this.dataGridView.TabIndex = 1;
// //
// buttonCreateOrder // buttonCreateOrder
// //
this.buttonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
this.buttonCreateOrder.Location = new System.Drawing.Point(709, 56); buttonCreateOrder.Location = new Point(966, 75);
this.buttonCreateOrder.Name = "buttonCreateOrder"; buttonCreateOrder.Margin = new Padding(3, 4, 3, 4);
this.buttonCreateOrder.Size = new System.Drawing.Size(149, 23); buttonCreateOrder.Name = "buttonCreateOrder";
this.buttonCreateOrder.TabIndex = 2; buttonCreateOrder.Size = new Size(170, 31);
this.buttonCreateOrder.Text = "Создать заказ"; buttonCreateOrder.TabIndex = 2;
this.buttonCreateOrder.UseVisualStyleBackColor = true; buttonCreateOrder.Text = "Создать заказ";
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.Click += ButtonCreateOrder_Click;
// //
// buttonTakeOrderInWork // buttonTakeOrderInWork
// //
this.buttonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right;
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(709, 95); buttonTakeOrderInWork.Location = new Point(966, 127);
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; buttonTakeOrderInWork.Margin = new Padding(3, 4, 3, 4);
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(149, 23); buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
this.buttonTakeOrderInWork.TabIndex = 3; buttonTakeOrderInWork.Size = new Size(170, 54);
this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; buttonTakeOrderInWork.TabIndex = 3;
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; buttonTakeOrderInWork.Text = "Отдать на выполнение";
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); buttonTakeOrderInWork.UseVisualStyleBackColor = true;
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
// //
// buttonOrderReady // buttonOrderReady
// //
this.buttonOrderReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right;
this.buttonOrderReady.Location = new System.Drawing.Point(709, 133); buttonOrderReady.Location = new Point(966, 189);
this.buttonOrderReady.Name = "buttonOrderReady"; buttonOrderReady.Margin = new Padding(3, 4, 3, 4);
this.buttonOrderReady.Size = new System.Drawing.Size(149, 23); buttonOrderReady.Name = "buttonOrderReady";
this.buttonOrderReady.TabIndex = 4; buttonOrderReady.Size = new Size(170, 31);
this.buttonOrderReady.Text = "Заказ готов"; buttonOrderReady.TabIndex = 4;
this.buttonOrderReady.UseVisualStyleBackColor = true; buttonOrderReady.Text = "Заказ готов";
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); buttonOrderReady.UseVisualStyleBackColor = true;
buttonOrderReady.Click += ButtonOrderReady_Click;
// //
// buttonIssuedOrder // buttonIssuedOrder
// //
this.buttonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
this.buttonIssuedOrder.Location = new System.Drawing.Point(709, 171); buttonIssuedOrder.Location = new Point(966, 228);
this.buttonIssuedOrder.Name = "buttonIssuedOrder"; buttonIssuedOrder.Margin = new Padding(3, 4, 3, 4);
this.buttonIssuedOrder.Size = new System.Drawing.Size(149, 23); buttonIssuedOrder.Name = "buttonIssuedOrder";
this.buttonIssuedOrder.TabIndex = 5; buttonIssuedOrder.Size = new Size(170, 31);
this.buttonIssuedOrder.Text = "Заказ выдан"; buttonIssuedOrder.TabIndex = 5;
this.buttonIssuedOrder.UseVisualStyleBackColor = true; buttonIssuedOrder.Text = "Заказ выдан";
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); buttonIssuedOrder.UseVisualStyleBackColor = true;
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
// //
// buttonRef // buttonRef
// //
this.buttonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right;
this.buttonRef.Location = new System.Drawing.Point(709, 210); buttonRef.Location = new Point(966, 280);
this.buttonRef.Name = "buttonRef"; buttonRef.Margin = new Padding(3, 4, 3, 4);
this.buttonRef.Size = new System.Drawing.Size(149, 23); buttonRef.Name = "buttonRef";
this.buttonRef.TabIndex = 6; buttonRef.Size = new Size(170, 31);
this.buttonRef.Text = "Обновить список"; buttonRef.TabIndex = 6;
this.buttonRef.UseVisualStyleBackColor = true; buttonRef.Text = "Обновить список";
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
// //
// ColumnId // dataGridView
// //
this.ColumnId.HeaderText = "ID"; dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
this.ColumnId.Name = "ColumnId"; dataGridView.BackgroundColor = SystemColors.ControlLightLight;
this.ColumnId.Visible = false; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
// dataGridView.Location = new Point(0, 36);
// Column1 dataGridView.Margin = new Padding(3, 4, 3, 4);
// dataGridView.Name = "dataGridView";
this.Column1.HeaderText = "Номер"; dataGridView.RowHeadersWidth = 51;
this.Column1.Name = "Column1"; dataGridView.RowTemplate.Height = 25;
// dataGridView.Size = new Size(959, 512);
// Column2 dataGridView.TabIndex = 7;
//
this.Column2.HeaderText = "Изделие";
this.Column2.Name = "Column2";
//
// Column3
//
this.Column3.HeaderText = "Количество";
this.Column3.Name = "Column3";
//
// Column4
//
this.Column4.HeaderText = "Сумма";
this.Column4.Name = "Column4";
//
// Column5
//
this.Column5.HeaderText = "Статус";
this.Column5.Name = "Column5";
//
// Column6
//
this.Column6.HeaderText = "Дата создания";
this.Column6.Name = "Column6";
//
// Column7
//
this.Column7.HeaderText = "Дата выполнения";
this.Column7.Name = "Column7";
// //
// FormMain // FormMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleDimensions = new SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(870, 379); ClientSize = new Size(1150, 545);
this.Controls.Add(this.buttonRef); Controls.Add(dataGridView);
this.Controls.Add(this.buttonIssuedOrder); Controls.Add(buttonRef);
this.Controls.Add(this.buttonOrderReady); Controls.Add(buttonIssuedOrder);
this.Controls.Add(this.buttonTakeOrderInWork); Controls.Add(buttonOrderReady);
this.Controls.Add(this.buttonCreateOrder); Controls.Add(buttonTakeOrderInWork);
this.Controls.Add(this.dataGridView); Controls.Add(buttonCreateOrder);
this.Controls.Add(this.menuStrip1); Controls.Add(menuStrip1);
this.MainMenuStrip = this.menuStrip1; MainMenuStrip = menuStrip1;
this.Name = "FormMain"; Margin = new Padding(3, 4, 3, 4);
this.Text = "FormMain"; Name = "FormMain";
this.menuStrip1.ResumeLayout(false); Text = "Юридическая фирма";
this.menuStrip1.PerformLayout(); Load += FormMain_Load;
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); menuStrip1.ResumeLayout(false);
this.ResumeLayout(false); menuStrip1.PerformLayout();
this.PerformLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
private MenuStrip menuStrip1; private MenuStrip menuStrip1;
private DataGridView dataGridView;
private Button buttonCreateOrder; private Button buttonCreateOrder;
private Button buttonTakeOrderInWork; private Button buttonTakeOrderInWork;
private Button buttonOrderReady; private Button buttonOrderReady;
@ -249,5 +190,6 @@
private DataGridViewTextBoxColumn Column5; private DataGridViewTextBoxColumn Column5;
private DataGridViewTextBoxColumn Column6; private DataGridViewTextBoxColumn Column6;
private DataGridViewTextBoxColumn Column7; private DataGridViewTextBoxColumn Column7;
private DataGridView dataGridView;
} }
} }

View File

@ -35,6 +35,21 @@ namespace LawFirmView
{ {
_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;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки документов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} }
private void компонентыToolStripMenuItem_Click_1(object sender, EventArgs e) private void компонентыToolStripMenuItem_Click_1(object sender, EventArgs e)
{ {
@ -48,6 +63,11 @@ namespace LawFirmView
private void изделияToolStripMenuItem_Click_1(object sender, EventArgs e) private void изделияToolStripMenuItem_Click_1(object sender, EventArgs e)
{ {
// прописать логику // прописать логику
var service = Program.ServiceProvider?.GetService(typeof(FormDocuments));
if (service is FormDocuments form)
{
form.ShowDialog();
}
} }
private void ButtonCreateOrder_Click(object sender, EventArgs e) private void ButtonCreateOrder_Click(object sender, EventArgs e)

View File

@ -60,30 +60,6 @@
<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="ColumnId.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>
<metadata name="Column4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column5.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column6.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Column7.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>75</value> <value>75</value>
</metadata> </metadata>

View File

@ -28,6 +28,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\LawFirmBusinessLogic\LawFirmBusinessLogic.csproj" /> <ProjectReference Include="..\LawFirmBusinessLogic\LawFirmBusinessLogic.csproj" />
<ProjectReference Include="..\LawFirmContracts\LawFirmContracts.csproj" /> <ProjectReference Include="..\LawFirmContracts\LawFirmContracts.csproj" />
<ProjectReference Include="..\LawFirmFileImplement\LawFirmFileImplement.csproj" />
<ProjectReference Include="..\LawFirmListImplement\LawFirmListImplement.csproj" /> <ProjectReference Include="..\LawFirmListImplement\LawFirmListImplement.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -1,7 +1,7 @@
using LawFirmBusinessLogic.BusinessLogic; using LawFirmBusinessLogic.BusinessLogic;
using LawFirmContracts.BusinessLogicsContracts; using LawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.StoragesContracts; using LawFirmContracts.StoragesContracts;
using LawFirmListImplement.Implements; using LawFirmFileImplement.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;
@ -51,7 +51,9 @@ namespace LawFirmView
services.AddTransient<FormCreateOrder>(); services.AddTransient<FormCreateOrder>();
services.AddTransient<FormDocument>(); services.AddTransient<FormDocument>();
services.AddTransient<FormDocumentComponent>(); services.AddTransient<FormDocumentComponent>();
services.AddTransient<FormDocuments>();
} }
} }
} }