lab2hard vrode work
This commit is contained in:
parent
02a6e66eb7
commit
2185902019
@ -12,10 +12,17 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
private readonly IShopLogic _shopLogic;
|
||||
private readonly IDocumentStorage _documentStorage;
|
||||
public OrderLogic(ILogger<OrderLogic> logger,
|
||||
IOrderStorage orderStorage,
|
||||
IShopLogic shopLogic,
|
||||
IDocumentStorage documentStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_shopLogic = shopLogic;
|
||||
_documentStorage = documentStorage;
|
||||
}
|
||||
public bool CreateOrder(OrderBindingModel model)
|
||||
{
|
||||
@ -47,16 +54,29 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
return false;
|
||||
}
|
||||
model.Status = newStatus;
|
||||
if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.Now;
|
||||
if (model.Status == OrderStatus.Готов)
|
||||
{
|
||||
|
||||
model.DateImplement = DateTime.Now;
|
||||
var document = _documentStorage.GetElement(new() { Id = viewModel.DocumentId });
|
||||
if (document == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(document));
|
||||
}
|
||||
if (!_shopLogic.AddDocuments(document, viewModel.Count))
|
||||
{
|
||||
throw new Exception($"AddDocuments operation failed - нет места");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
model.DateImplement = viewModel.DateImplement;
|
||||
}
|
||||
CheckModel(model);
|
||||
CheckModel(model, false);
|
||||
if (_orderStorage.Update(model) == null)
|
||||
{
|
||||
model.Status--;
|
||||
_logger.LogWarning("Update operation failed");
|
||||
_logger.LogWarning("Change status operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -107,7 +107,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddDocument(ShopSearchModel model, IDocumentModel ship, int count)
|
||||
public bool AddDocument(ShopSearchModel model, IDocumentModel document, int count)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
@ -115,6 +115,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
return false;
|
||||
throw new ArgumentException("Количество поездок должно быть больше 0", nameof(count));
|
||||
}
|
||||
_logger.LogInformation("AddDocument. ShopName:{ShopName}. Id:{Id}", model.ShopName, model.Id);
|
||||
@ -124,19 +125,22 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
_logger.LogWarning("AddDocument element not found");
|
||||
return false;
|
||||
}
|
||||
_logger.LogInformation("AddDocument find. Id:{Id}", element.Id);
|
||||
if (element.Capacity - element.ShopDocuments.Select(x => x.Value.Item2).Sum() < count)
|
||||
{
|
||||
throw new ArgumentNullException("В магазине не хватает места", nameof(count));
|
||||
}
|
||||
|
||||
if (element.ShopDocuments.TryGetValue(ship.Id, out var pair))
|
||||
if (element.ShopDocuments.TryGetValue(document.Id, out var pair))
|
||||
{
|
||||
element.ShopDocuments[ship.Id] = (ship, count + pair.Item2);
|
||||
_logger.LogInformation("AddDocument. Added {count} {ship} to '{ShopName}' shop",
|
||||
count, ship.DocumentName, element.ShopName);
|
||||
element.ShopDocuments[document.Id] = (document, count + pair.Item2);
|
||||
_logger.LogInformation("AddDocument. Added {count} {document} to '{ShopName}' shop",
|
||||
count, document.DocumentName, element.ShopName);
|
||||
}
|
||||
else
|
||||
{
|
||||
element.ShopDocuments[ship.Id] = (ship, count);
|
||||
_logger.LogInformation("AddDocument. Added {count} new ship {ship} to '{ShopName}' shop",
|
||||
count, ship.DocumentName, element.ShopName);
|
||||
element.ShopDocuments[document.Id] = (document, count);
|
||||
_logger.LogInformation("AddDocument. Added {count} new document {document} to '{ShopName}' shop",
|
||||
count, document.DocumentName, element.ShopName);
|
||||
}
|
||||
_shopStorage.Update(new()
|
||||
{
|
||||
@ -144,9 +148,64 @@ namespace LawFirmBusinessLogic.BusinessLogics
|
||||
Address = element.Address,
|
||||
ShopName = element.ShopName,
|
||||
DateOpen = element.DateOpen,
|
||||
Capacity = element.Capacity,
|
||||
ShopDocuments = element.ShopDocuments
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public bool AddDocuments(IDocumentModel model, int count)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Количество документов должно быть больше 0", nameof(count));
|
||||
}
|
||||
_logger.LogInformation("AddDocuments. ShopName:{ShopName}. Id:{Id}", model.DocumentName, model.Id);
|
||||
var allFreeQuantity = _shopStorage.GetFullList().Select(x => x.Capacity - x.ShopDocuments.Select(x => x.Value.Item2).Sum()).Sum();
|
||||
if (allFreeQuantity < count)
|
||||
{
|
||||
_logger.LogWarning("AddTravels operation failed.");
|
||||
return false;
|
||||
}
|
||||
foreach (var shop in _shopStorage.GetFullList())
|
||||
{
|
||||
int freeQuantity = shop.Capacity - shop.ShopDocuments.Select(x => x.Value.Item2).Sum();
|
||||
if (freeQuantity <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (freeQuantity < count)
|
||||
{
|
||||
if (!AddDocument(new() { Id = shop.Id }, model, freeQuantity))
|
||||
{
|
||||
_logger.LogWarning("AddDocuments operation failed.");
|
||||
return false;
|
||||
}
|
||||
count -= freeQuantity;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!AddDocument(new() { Id = shop.Id }, model, count))
|
||||
{
|
||||
_logger.LogWarning("AddDocuments operation failed.");
|
||||
return false;
|
||||
}
|
||||
count = 0;
|
||||
}
|
||||
if (count == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_logger.LogWarning("AddDocuments operation failed.");
|
||||
return false;
|
||||
}
|
||||
public bool SellDocuments(IDocumentModel model, int count)
|
||||
{
|
||||
return _shopStorage.SellDocuments(model, count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,8 @@ namespace LawFirmContracts.BindingModels
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
public string Address { get; set; } = string.Empty;
|
||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, (IDocumentModel, int)> ShopDocuments { get; set; } = new();
|
||||
public int Capacity { get; set; }
|
||||
public Dictionary<int, (IDocumentModel, int)> ShopDocuments { get; set; } = new();
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ namespace LawFirmContracts.BusinessLogicsContracts
|
||||
bool Create(ShopBindingModel model);
|
||||
bool Update(ShopBindingModel model);
|
||||
bool Delete(ShopBindingModel model);
|
||||
bool AddDocument(ShopSearchModel model, IDocumentModel document, int count);
|
||||
bool AddDocuments(IDocumentModel model, int count);
|
||||
bool SellDocuments(IDocumentModel model, int count);
|
||||
bool AddDocument(ShopSearchModel model, IDocumentModel document, int count);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
using LawFirmContracts.BindingModels;
|
||||
using LawFirmContracts.SearchModels;
|
||||
using LawFirmContracts.ViewModels;
|
||||
using LawFirmDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@ -17,5 +18,6 @@ namespace LawFirmContracts.StoragesContracts
|
||||
ShopViewModel? Insert(ShopBindingModel model);
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
bool SellDocuments(IDocumentModel model, int count);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,9 @@ namespace LawFirmContracts.ViewModels
|
||||
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, (IDocumentModel, int)> ShopDocuments { get; set; } = new();
|
||||
[DisplayName("Вместимость магазина")]
|
||||
public int Capacity { get; set; }
|
||||
public Dictionary<int, (IDocumentModel, int)> ShopDocuments { get; set; } = new();
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ namespace LawFirmDataModels.Models
|
||||
string ShopName { get; }
|
||||
string Address { get; }
|
||||
DateTime DateOpen { get; }
|
||||
Dictionary<int, (IDocumentModel, int)> ShopDocuments { get; }
|
||||
public int Capacity { get; }
|
||||
Dictionary<int, (IDocumentModel, int)> ShopDocuments { get; }
|
||||
}
|
||||
}
|
||||
|
@ -9,10 +9,14 @@ namespace LawFirmFileImplement
|
||||
private readonly string BlankFileName = "Blank.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string DocumentFileName = "Document.xml";
|
||||
public List<Blank> Blanks { get; private set; }
|
||||
private readonly string ShopFileName = "Shop.xml";
|
||||
|
||||
public List<Blank> Blanks { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Document> Documents { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
public List<Shop> Shops { get; private set; }
|
||||
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
@ -23,13 +27,16 @@ namespace LawFirmFileImplement
|
||||
public void SaveBlanks() => SaveData(Blanks, BlankFileName, "Blanks", 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()
|
||||
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Blanks = LoadData(BlankFileName, "Blank", x => Blank.Create(x)!)!;
|
||||
Documents = LoadData(DocumentFileName, "Document", x => Document.Create(x)!)!;
|
||||
Orders = new List<Order>();
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
||||
Func<XElement, T> selectFunction)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
|
@ -50,14 +50,14 @@ namespace LawFirmFileImplement.Implements
|
||||
}
|
||||
public DocumentViewModel? Update(DocumentBindingModel model)
|
||||
{
|
||||
var ship = source.Documents.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (ship == null)
|
||||
var document = source.Documents.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (document == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ship.Update(model);
|
||||
document.Update(model);
|
||||
source.SaveDocuments();
|
||||
return ship.GetViewModel;
|
||||
return document.GetViewModel;
|
||||
}
|
||||
public DocumentViewModel? Delete(DocumentBindingModel model)
|
||||
{
|
||||
|
@ -38,10 +38,10 @@ namespace LawFirmFileImplement.Implements
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
var ship = source.Documents.FirstOrDefault(x => x.Id == order.DocumentId);
|
||||
if (ship != null)
|
||||
var document = source.Documents.FirstOrDefault(x => x.Id == order.DocumentId);
|
||||
if (document != null)
|
||||
{
|
||||
viewModel.DocumentName = ship.DocumentName;
|
||||
viewModel.DocumentName = document.DocumentName;
|
||||
}
|
||||
return viewModel;
|
||||
}
|
||||
|
129
LawFirm/LawFirmFileImplement/Implements/ShopStorage.cs
Normal file
129
LawFirm/LawFirmFileImplement/Implements/ShopStorage.cs
Normal file
@ -0,0 +1,129 @@
|
||||
|
||||
using LawFirmContracts.BindingModels;
|
||||
using LawFirmContracts.SearchModels;
|
||||
using LawFirmContracts.StoragesContracts;
|
||||
using LawFirmContracts.ViewModels;
|
||||
using LawFirmDataModels.Models;
|
||||
using LawFirmFileImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LawFirmFileImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
|
||||
public ShopStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return source.Shops
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
/*return source.Shops
|
||||
.Where(x => x.ShopName.Contains(model.ShopName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();*/
|
||||
return source.Shops
|
||||
.Where(x => x.ShopName.Contains(model.ShopName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
return source.Shops.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
model.Id = source.Shops.Count > 0 ? source.Shops.Max(x => x.Id) + 1 : 1;
|
||||
var newShop = Shop.Create(model);
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Shops.Add(newShop);
|
||||
source.SaveShops();
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (shop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
shop.Update(model);
|
||||
source.SaveShops();
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (shop != null)
|
||||
{
|
||||
source.Shops.Remove(shop);
|
||||
source.SaveShops();
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public bool SellDocuments(IDocumentModel model, int count)
|
||||
{
|
||||
int availableQuantity = source.Shops.Select(x => x.ShopDocuments.FirstOrDefault(y => y.Key == model.Id).Value.Item2).Sum();
|
||||
if (availableQuantity < count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var shops = source.Shops.Where(x => x.ShopDocuments.ContainsKey(model.Id));
|
||||
foreach (var shop in shops)
|
||||
{
|
||||
int countInCurrentShop = shop.ShopDocuments[model.Id].Item2;
|
||||
if (countInCurrentShop <= count)
|
||||
{
|
||||
shop.ShopDocuments[model.Id] = (shop.ShopDocuments[model.Id].Item1, 0);
|
||||
count -= countInCurrentShop;
|
||||
}
|
||||
else
|
||||
{
|
||||
shop.ShopDocuments[model.Id] = (shop.ShopDocuments[model.Id].Item1, countInCurrentShop - count);
|
||||
count = 0;
|
||||
}
|
||||
Update(new ShopBindingModel
|
||||
{
|
||||
Id = shop.Id,
|
||||
ShopName = shop.ShopName,
|
||||
Address = shop.Address,
|
||||
DateOpen = shop.DateOpen,
|
||||
ShopDocuments = shop.ShopDocuments,
|
||||
Capacity = shop.Capacity
|
||||
});
|
||||
if (count == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
108
LawFirm/LawFirmFileImplement/Models/Shop.cs
Normal file
108
LawFirm/LawFirmFileImplement/Models/Shop.cs
Normal file
@ -0,0 +1,108 @@
|
||||
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
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
public DateTime DateOpen { get; private set; }
|
||||
public int Capacity { get; private set; }
|
||||
public Dictionary<int, int> DocumentsCount = new();
|
||||
public Dictionary<int, (IDocumentModel, int)>? _documents = null;
|
||||
public Dictionary<int, (IDocumentModel, int)> ShopDocuments
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_documents == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_documents = DocumentsCount.ToDictionary(
|
||||
x => x.Key,
|
||||
y => ((source.Documents.FirstOrDefault(z => z.Id == y.Key) as IDocumentModel)!,
|
||||
y.Value)
|
||||
);
|
||||
}
|
||||
return _documents;
|
||||
}
|
||||
}
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpen = model.DateOpen,
|
||||
Capacity = model.Capacity,
|
||||
DocumentsCount = model.ShopDocuments.ToDictionary(x => x.Key, x => x.Value.Item2)
|
||||
};
|
||||
}
|
||||
public static Shop? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ShopName = element.Element("ShopName")!.Value,
|
||||
Address = element.Element("Address")!.Value,
|
||||
DateOpen = Convert.ToDateTime(element.Element("DateOpening")!.Value),
|
||||
Capacity = Convert.ToInt32(element.Element("Capacity")!.Value),
|
||||
DocumentsCount = element.Element("Documents")!.Elements("Document")
|
||||
.ToDictionary(
|
||||
x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||
x => Convert.ToInt32(x.Element("Value")?.Value))
|
||||
};
|
||||
}
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpen = model.DateOpen;
|
||||
Capacity = model.Capacity;
|
||||
DocumentsCount = model.ShopDocuments.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
_documents = null;
|
||||
|
||||
}
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpen = DateOpen,
|
||||
Capacity = Capacity,
|
||||
ShopDocuments = ShopDocuments
|
||||
};
|
||||
public XElement GetXElement => new("Shop",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ShopName", ShopName),
|
||||
new XElement("Address", Address),
|
||||
new XElement("DateOpening", DateOpen.ToString()),
|
||||
new XElement("Capacity", Capacity.ToString()),
|
||||
new XElement("Documents", DocumentsCount.Select(x =>
|
||||
new XElement("Document",
|
||||
new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value)))
|
||||
.ToArray()));
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using LawFirmContracts.SearchModels;
|
||||
using LawFirmContracts.StoragesContracts;
|
||||
using LawFirmContracts.ViewModels;
|
||||
using LawFirmDataModels.Models;
|
||||
using LawFirmListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -108,5 +109,10 @@ namespace LawFirmListImplement.Implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool SellDocuments(IDocumentModel model, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ namespace LawFirmListImplement.Models
|
||||
|
||||
public string Address { get; set; } = string.Empty;
|
||||
public DateTime DateOpen { get; set; }
|
||||
public int Id { get; set; }
|
||||
public int Capacity { get; private set; }
|
||||
public int Id { get; set; }
|
||||
public Dictionary<int, (IDocumentModel, int)> ShopDocuments { get; private set; } = new Dictionary<int, (IDocumentModel, int)>();
|
||||
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
|
@ -19,7 +19,7 @@ namespace LawFirmView
|
||||
|
||||
private void FormAddDocument_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка списка кораблей для пополнения");
|
||||
_logger.LogInformation("Загрузка списка документов для пополнения");
|
||||
try
|
||||
{
|
||||
var list = _logicDocument.ReadList(null);
|
||||
@ -33,7 +33,7 @@ namespace LawFirmView
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка кораблей");
|
||||
_logger.LogError(ex, "Ошибка загрузки списка документов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
|
310
LawFirm/LawFirmView/FormMain.Designer.cs
generated
310
LawFirm/LawFirmView/FormMain.Designer.cs
generated
@ -28,157 +28,170 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.бланкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.документыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
||||
this.buttonOrderReady = new System.Windows.Forms.Button();
|
||||
this.buttonIssuedOrder = new System.Windows.Forms.Button();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonAddDocument = new System.Windows.Forms.Button();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
|
||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.бланкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.документыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
||||
this.buttonOrderReady = new System.Windows.Forms.Button();
|
||||
this.buttonIssuedOrder = new System.Windows.Forms.Button();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonAddDocument = new System.Windows.Forms.Button();
|
||||
this.buttonSellDocument = new System.Windows.Forms.Button();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.справочникиToolStripMenuItem});
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(800, 24);
|
||||
this.menuStrip1.TabIndex = 0;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip1.Name = "menuStrip1";
|
||||
this.menuStrip1.Size = new System.Drawing.Size(800, 24);
|
||||
this.menuStrip1.TabIndex = 0;
|
||||
this.menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.бланкиToolStripMenuItem,
|
||||
this.документыToolStripMenuItem,
|
||||
this.магазиныToolStripMenuItem});
|
||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// бланкиToolStripMenuItem
|
||||
//
|
||||
this.бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem";
|
||||
this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.бланкиToolStripMenuItem.Text = "Бланки";
|
||||
this.бланкиToolStripMenuItem.Click += new System.EventHandler(this.BlanksToolStripMenuItem_Click);
|
||||
//
|
||||
// документыToolStripMenuItem
|
||||
//
|
||||
this.документыToolStripMenuItem.Name = "документыToolStripMenuItem";
|
||||
this.документыToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.документыToolStripMenuItem.Text = "Документы";
|
||||
this.документыToolStripMenuItem.Click += new System.EventHandler(this.DocumentsToolStripMenuItem_Click);
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.магазиныToolStripMenuItem.Text = "Магазины";
|
||||
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopToolStripMenuItem_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 27);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(566, 411);
|
||||
this.dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
this.buttonCreateOrder.Location = new System.Drawing.Point(605, 27);
|
||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
this.buttonCreateOrder.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonCreateOrder.TabIndex = 2;
|
||||
this.buttonCreateOrder.Text = "Создать заказ";
|
||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(605, 56);
|
||||
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonTakeOrderInWork.TabIndex = 3;
|
||||
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
this.buttonOrderReady.Location = new System.Drawing.Point(605, 85);
|
||||
this.buttonOrderReady.Name = "buttonOrderReady";
|
||||
this.buttonOrderReady.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonOrderReady.TabIndex = 4;
|
||||
this.buttonOrderReady.Text = "Заказ готов";
|
||||
this.buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(605, 114);
|
||||
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
this.buttonIssuedOrder.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonIssuedOrder.TabIndex = 5;
|
||||
this.buttonIssuedOrder.Text = "Заказ выдан";
|
||||
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(605, 143);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonUpdate.TabIndex = 6;
|
||||
this.buttonUpdate.Text = "Обновить список";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// buttonAddDocument
|
||||
//
|
||||
this.buttonAddDocument.Location = new System.Drawing.Point(605, 172);
|
||||
this.buttonAddDocument.Name = "buttonAddDocument";
|
||||
this.buttonAddDocument.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonAddDocument.TabIndex = 7;
|
||||
this.buttonAddDocument.Text = "Добавить документ";
|
||||
this.buttonAddDocument.UseVisualStyleBackColor = true;
|
||||
this.buttonAddDocument.Click += new System.EventHandler(this.ButtonAddDocument_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonAddDocument);
|
||||
this.Controls.Add(this.buttonUpdate);
|
||||
this.Controls.Add(this.buttonIssuedOrder);
|
||||
this.Controls.Add(this.buttonOrderReady);
|
||||
this.Controls.Add(this.buttonTakeOrderInWork);
|
||||
this.Controls.Add(this.buttonCreateOrder);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "FormMain";
|
||||
this.Text = "Юридическая фирма";
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// бланкиToolStripMenuItem
|
||||
//
|
||||
this.бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem";
|
||||
this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
|
||||
this.бланкиToolStripMenuItem.Text = "Бланки";
|
||||
this.бланкиToolStripMenuItem.Click += new System.EventHandler(this.BlanksToolStripMenuItem_Click);
|
||||
//
|
||||
// документыToolStripMenuItem
|
||||
//
|
||||
this.документыToolStripMenuItem.Name = "документыToolStripMenuItem";
|
||||
this.документыToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
|
||||
this.документыToolStripMenuItem.Text = "Документы";
|
||||
this.документыToolStripMenuItem.Click += new System.EventHandler(this.DocumentsToolStripMenuItem_Click);
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
|
||||
this.магазиныToolStripMenuItem.Text = "Магазины";
|
||||
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopToolStripMenuItem_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 27);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(566, 411);
|
||||
this.dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
this.buttonCreateOrder.Location = new System.Drawing.Point(605, 27);
|
||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
this.buttonCreateOrder.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonCreateOrder.TabIndex = 2;
|
||||
this.buttonCreateOrder.Text = "Создать заказ";
|
||||
this.buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(605, 56);
|
||||
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonTakeOrderInWork.TabIndex = 3;
|
||||
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
|
||||
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
this.buttonOrderReady.Location = new System.Drawing.Point(605, 85);
|
||||
this.buttonOrderReady.Name = "buttonOrderReady";
|
||||
this.buttonOrderReady.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonOrderReady.TabIndex = 4;
|
||||
this.buttonOrderReady.Text = "Заказ готов";
|
||||
this.buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(605, 114);
|
||||
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
this.buttonIssuedOrder.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonIssuedOrder.TabIndex = 5;
|
||||
this.buttonIssuedOrder.Text = "Заказ выдан";
|
||||
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(605, 143);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonUpdate.TabIndex = 6;
|
||||
this.buttonUpdate.Text = "Обновить список";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// buttonAddDocument
|
||||
//
|
||||
this.buttonAddDocument.Location = new System.Drawing.Point(605, 172);
|
||||
this.buttonAddDocument.Name = "buttonAddDocument";
|
||||
this.buttonAddDocument.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonAddDocument.TabIndex = 7;
|
||||
this.buttonAddDocument.Text = "Добавить документ";
|
||||
this.buttonAddDocument.UseVisualStyleBackColor = true;
|
||||
this.buttonAddDocument.Click += new System.EventHandler(this.ButtonAddDocument_Click);
|
||||
//
|
||||
// buttonSellDocument
|
||||
//
|
||||
this.buttonSellDocument.Location = new System.Drawing.Point(605, 201);
|
||||
this.buttonSellDocument.Name = "buttonSellDocument";
|
||||
this.buttonSellDocument.Size = new System.Drawing.Size(168, 23);
|
||||
this.buttonSellDocument.TabIndex = 8;
|
||||
this.buttonSellDocument.Text = "Продать документ";
|
||||
this.buttonSellDocument.UseVisualStyleBackColor = true;
|
||||
this.buttonSellDocument.Click += new System.EventHandler(this.ButtonSellDocument_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonSellDocument);
|
||||
this.Controls.Add(this.buttonAddDocument);
|
||||
this.Controls.Add(this.buttonUpdate);
|
||||
this.Controls.Add(this.buttonIssuedOrder);
|
||||
this.Controls.Add(this.buttonOrderReady);
|
||||
this.Controls.Add(this.buttonTakeOrderInWork);
|
||||
this.Controls.Add(this.buttonCreateOrder);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "FormMain";
|
||||
this.Text = "Юридическая фирма";
|
||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
this.menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@ -196,5 +209,6 @@
|
||||
private ToolStripMenuItem документыToolStripMenuItem;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private Button buttonAddDocument;
|
||||
}
|
||||
private Button buttonSellDocument;
|
||||
}
|
||||
}
|
@ -181,5 +181,15 @@ namespace LawFirmView
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSellDocument_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSellDocuments));
|
||||
if (service is FormSellDocuments form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
LawFirm/LawFirmView/FormSellDocuments.Designer.cs
generated
Normal file
120
LawFirm/LawFirmView/FormSellDocuments.Designer.cs
generated
Normal file
@ -0,0 +1,120 @@
|
||||
namespace LawFirmView
|
||||
{
|
||||
partial class FormSellDocuments
|
||||
{
|
||||
/// <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.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.comboBoxDocuments = new System.Windows.Forms.ComboBox();
|
||||
this.numericUpDownCount = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelDocument = new System.Windows.Forms.Label();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.ButtonSave = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(266, 153);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(94, 29);
|
||||
this.ButtonCancel.TabIndex = 1;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// comboBoxDocuments
|
||||
//
|
||||
this.comboBoxDocuments.FormattingEnabled = true;
|
||||
this.comboBoxDocuments.Location = new System.Drawing.Point(144, 38);
|
||||
this.comboBoxDocuments.Name = "comboBoxDocuments";
|
||||
this.comboBoxDocuments.Size = new System.Drawing.Size(216, 28);
|
||||
this.comboBoxDocuments.TabIndex = 2;
|
||||
//
|
||||
// numericUpDownCount
|
||||
//
|
||||
this.numericUpDownCount.Location = new System.Drawing.Point(144, 102);
|
||||
this.numericUpDownCount.Name = "numericUpDownCount";
|
||||
this.numericUpDownCount.Size = new System.Drawing.Size(216, 27);
|
||||
this.numericUpDownCount.TabIndex = 3;
|
||||
//
|
||||
// labelDocument
|
||||
//
|
||||
this.labelDocument.AutoSize = true;
|
||||
this.labelDocument.Location = new System.Drawing.Point(34, 38);
|
||||
this.labelDocument.Name = "labelDocument";
|
||||
this.labelDocument.Size = new System.Drawing.Size(69, 20);
|
||||
this.labelDocument.TabIndex = 4;
|
||||
this.labelDocument.Text = "Корабль";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(34, 109);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(90, 20);
|
||||
this.labelCount.TabIndex = 5;
|
||||
this.labelCount.Text = "Количество";
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
this.ButtonSave.Location = new System.Drawing.Point(144, 153);
|
||||
this.ButtonSave.Name = "ButtonSave";
|
||||
this.ButtonSave.Size = new System.Drawing.Size(94, 29);
|
||||
this.ButtonSave.TabIndex = 6;
|
||||
this.ButtonSave.Text = "Сохранить";
|
||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// FormSellDocuments
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(373, 194);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelDocument);
|
||||
this.Controls.Add(this.numericUpDownCount);
|
||||
this.Controls.Add(this.comboBoxDocuments);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Name = "FormSellDocuments";
|
||||
this.Text = "Продажа документов";
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private Button ButtonCancel;
|
||||
private ComboBox comboBoxDocuments;
|
||||
private NumericUpDown numericUpDownCount;
|
||||
private Label labelDocument;
|
||||
private Label labelCount;
|
||||
private Button ButtonSave;
|
||||
}
|
||||
}
|
86
LawFirm/LawFirmView/FormSellDocuments.cs
Normal file
86
LawFirm/LawFirmView/FormSellDocuments.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using LawFirmContracts.BusinessLogicsContracts;
|
||||
using LawFirmContracts.ViewModels;
|
||||
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 FormSellDocuments : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
private readonly IDocumentLogic _documentLogic;
|
||||
private readonly List<DocumentViewModel>? _listDocument;
|
||||
public FormSellDocuments(ILogger<FormSellDocuments> logger, IShopLogic shopLogic, IDocumentLogic documentLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_shopLogic = shopLogic;
|
||||
_documentLogic = documentLogic;
|
||||
_listDocument = documentLogic.ReadList(null);
|
||||
if (_listDocument != null)
|
||||
{
|
||||
comboBoxDocuments.DisplayMember = "DocumentName";
|
||||
comboBoxDocuments.ValueMember = "Id";
|
||||
comboBoxDocuments.DataSource=_listDocument;
|
||||
comboBoxDocuments.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxDocuments.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите корабль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(numericUpDownCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Продажа поездок");
|
||||
try
|
||||
{
|
||||
var document = _documentLogic.ReadElement(new()
|
||||
{
|
||||
Id = (int)comboBoxDocuments.SelectedValue
|
||||
});
|
||||
if (document == null)
|
||||
{
|
||||
throw new Exception("Корабль не найден. Дополнительная информация в логах.");
|
||||
}
|
||||
var operationResult = _shopLogic.SellDocuments(
|
||||
model: document,
|
||||
count: (int)numericUpDownCount.Value
|
||||
);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при продаже корабля. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения корабля");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
LawFirm/LawFirmView/FormSellDocuments.resx
Normal file
60
LawFirm/LawFirmView/FormSellDocuments.resx
Normal 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>
|
305
LawFirm/LawFirmView/FormShop.Designer.cs
generated
305
LawFirm/LawFirmView/FormShop.Designer.cs
generated
@ -28,145 +28,174 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.labelShop = new System.Windows.Forms.Label();
|
||||
this.labelAddress = new System.Windows.Forms.Label();
|
||||
this.labelDate = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
||||
this.dateTimePickerDateOpen = new System.Windows.Forms.DateTimePicker();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ButtonSave = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.DocumentName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
this.labelShop.AutoSize = true;
|
||||
this.labelShop.Location = new System.Drawing.Point(12, 21);
|
||||
this.labelShop.Name = "labelShop";
|
||||
this.labelShop.Size = new System.Drawing.Size(69, 20);
|
||||
this.labelShop.TabIndex = 0;
|
||||
this.labelShop.Text = "Магазин";
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
this.labelAddress.AutoSize = true;
|
||||
this.labelAddress.Location = new System.Drawing.Point(195, 21);
|
||||
this.labelAddress.Name = "labelAddress";
|
||||
this.labelAddress.Size = new System.Drawing.Size(51, 20);
|
||||
this.labelAddress.TabIndex = 1;
|
||||
this.labelAddress.Text = "Адрес";
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
this.labelDate.AutoSize = true;
|
||||
this.labelDate.Location = new System.Drawing.Point(474, 21);
|
||||
this.labelDate.Name = "labelDate";
|
||||
this.labelDate.Size = new System.Drawing.Size(110, 20);
|
||||
this.labelDate.TabIndex = 2;
|
||||
this.labelDate.Text = "Дата открытия";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(12, 44);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(160, 27);
|
||||
this.textBoxName.TabIndex = 3;
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
this.textBoxAddress.Location = new System.Drawing.Point(195, 44);
|
||||
this.textBoxAddress.Name = "textBoxAddress";
|
||||
this.textBoxAddress.Size = new System.Drawing.Size(246, 27);
|
||||
this.textBoxAddress.TabIndex = 4;
|
||||
//
|
||||
// dateTimePickerDateOpen
|
||||
//
|
||||
this.dateTimePickerDateOpen.Location = new System.Drawing.Point(474, 44);
|
||||
this.dateTimePickerDateOpen.Name = "dateTimePickerDateOpen";
|
||||
this.dateTimePickerDateOpen.Size = new System.Drawing.Size(250, 27);
|
||||
this.dateTimePickerDateOpen.TabIndex = 5;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.labelShop = new System.Windows.Forms.Label();
|
||||
this.labelAddress = new System.Windows.Forms.Label();
|
||||
this.labelDate = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
||||
this.dateTimePickerDateOpen = new System.Windows.Forms.DateTimePicker();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.DocumentName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ButtonSave = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.numericUpDownCapacity = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelCapacity = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCapacity)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
this.labelShop.AutoSize = true;
|
||||
this.labelShop.Location = new System.Drawing.Point(10, 16);
|
||||
this.labelShop.Name = "labelShop";
|
||||
this.labelShop.Size = new System.Drawing.Size(54, 15);
|
||||
this.labelShop.TabIndex = 0;
|
||||
this.labelShop.Text = "Магазин";
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
this.labelAddress.AutoSize = true;
|
||||
this.labelAddress.Location = new System.Drawing.Point(156, 16);
|
||||
this.labelAddress.Name = "labelAddress";
|
||||
this.labelAddress.Size = new System.Drawing.Size(40, 15);
|
||||
this.labelAddress.TabIndex = 1;
|
||||
this.labelAddress.Text = "Адрес";
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
this.labelDate.AutoSize = true;
|
||||
this.labelDate.Location = new System.Drawing.Point(375, 16);
|
||||
this.labelDate.Name = "labelDate";
|
||||
this.labelDate.Size = new System.Drawing.Size(87, 15);
|
||||
this.labelDate.TabIndex = 2;
|
||||
this.labelDate.Text = "Дата открытия";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(10, 33);
|
||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(140, 23);
|
||||
this.textBoxName.TabIndex = 3;
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
this.textBoxAddress.Location = new System.Drawing.Point(156, 33);
|
||||
this.textBoxAddress.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxAddress.Name = "textBoxAddress";
|
||||
this.textBoxAddress.Size = new System.Drawing.Size(216, 23);
|
||||
this.textBoxAddress.TabIndex = 4;
|
||||
//
|
||||
// dateTimePickerDateOpen
|
||||
//
|
||||
this.dateTimePickerDateOpen.Location = new System.Drawing.Point(375, 33);
|
||||
this.dateTimePickerDateOpen.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dateTimePickerDateOpen.Name = "dateTimePickerDateOpen";
|
||||
this.dateTimePickerDateOpen.Size = new System.Drawing.Size(123, 23);
|
||||
this.dateTimePickerDateOpen.TabIndex = 5;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ID,
|
||||
this.DocumentName,
|
||||
this.Count});
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 77);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(712, 330);
|
||||
this.dataGridView.TabIndex = 6;
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
this.ButtonSave.Location = new System.Drawing.Point(490, 413);
|
||||
this.ButtonSave.Name = "ButtonSave";
|
||||
this.ButtonSave.Size = new System.Drawing.Size(111, 29);
|
||||
this.ButtonSave.TabIndex = 7;
|
||||
this.ButtonSave.Text = "Сохранить";
|
||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(630, 413);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(94, 29);
|
||||
this.ButtonCancel.TabIndex = 8;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// ID
|
||||
//
|
||||
this.ID.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.ID.HeaderText = "ID";
|
||||
this.ID.MinimumWidth = 6;
|
||||
this.ID.Name = "ID";
|
||||
this.ID.Visible = false;
|
||||
//
|
||||
// DocumentName
|
||||
//
|
||||
this.DocumentName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.DocumentName.HeaderText = "DocumentName";
|
||||
this.DocumentName.MinimumWidth = 6;
|
||||
this.DocumentName.Name = "DocumentName";
|
||||
//
|
||||
// Count
|
||||
//
|
||||
this.Count.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.Count.HeaderText = "Count";
|
||||
this.Count.MinimumWidth = 6;
|
||||
this.Count.Name = "Count";
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(740, 450);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.dateTimePickerDateOpen);
|
||||
this.Controls.Add(this.textBoxAddress);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.labelDate);
|
||||
this.Controls.Add(this.labelAddress);
|
||||
this.Controls.Add(this.labelShop);
|
||||
this.Name = "FormShop";
|
||||
this.Text = "Магазин";
|
||||
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
this.dataGridView.Location = new System.Drawing.Point(10, 58);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(623, 248);
|
||||
this.dataGridView.TabIndex = 6;
|
||||
//
|
||||
// ID
|
||||
//
|
||||
this.ID.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.ID.HeaderText = "ID";
|
||||
this.ID.MinimumWidth = 6;
|
||||
this.ID.Name = "ID";
|
||||
this.ID.Visible = false;
|
||||
//
|
||||
// DocumentName
|
||||
//
|
||||
this.DocumentName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.DocumentName.HeaderText = "DocumentName";
|
||||
this.DocumentName.MinimumWidth = 6;
|
||||
this.DocumentName.Name = "DocumentName";
|
||||
//
|
||||
// Count
|
||||
//
|
||||
this.Count.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.Count.HeaderText = "Count";
|
||||
this.Count.MinimumWidth = 6;
|
||||
this.Count.Name = "Count";
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
this.ButtonSave.Location = new System.Drawing.Point(429, 310);
|
||||
this.ButtonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.ButtonSave.Name = "ButtonSave";
|
||||
this.ButtonSave.Size = new System.Drawing.Size(97, 22);
|
||||
this.ButtonSave.TabIndex = 7;
|
||||
this.ButtonSave.Text = "Сохранить";
|
||||
this.ButtonSave.UseVisualStyleBackColor = true;
|
||||
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(551, 310);
|
||||
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(82, 22);
|
||||
this.ButtonCancel.TabIndex = 8;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// numericUpDownCapacity
|
||||
//
|
||||
this.numericUpDownCapacity.Location = new System.Drawing.Point(504, 33);
|
||||
this.numericUpDownCapacity.Name = "numericUpDownCapacity";
|
||||
this.numericUpDownCapacity.Size = new System.Drawing.Size(120, 23);
|
||||
this.numericUpDownCapacity.TabIndex = 9;
|
||||
//
|
||||
// labelCapacity
|
||||
//
|
||||
this.labelCapacity.AutoSize = true;
|
||||
this.labelCapacity.Location = new System.Drawing.Point(504, 16);
|
||||
this.labelCapacity.Name = "labelCapacity";
|
||||
this.labelCapacity.Size = new System.Drawing.Size(134, 15);
|
||||
this.labelCapacity.TabIndex = 10;
|
||||
this.labelCapacity.Text = "Вместимость магазина";
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(648, 338);
|
||||
this.Controls.Add(this.labelCapacity);
|
||||
this.Controls.Add(this.numericUpDownCapacity);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.ButtonSave);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.dateTimePickerDateOpen);
|
||||
this.Controls.Add(this.textBoxAddress);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.labelDate);
|
||||
this.Controls.Add(this.labelAddress);
|
||||
this.Controls.Add(this.labelShop);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormShop";
|
||||
this.Text = "Магазин";
|
||||
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCapacity)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@ -184,5 +213,7 @@
|
||||
private DataGridViewTextBoxColumn ID;
|
||||
private DataGridViewTextBoxColumn DocumentName;
|
||||
private DataGridViewTextBoxColumn Count;
|
||||
}
|
||||
private NumericUpDown numericUpDownCapacity;
|
||||
private Label labelCapacity;
|
||||
}
|
||||
}
|
@ -37,7 +37,8 @@ namespace LawFirmView
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAddress.Text = view.Address.ToString();
|
||||
dateTimePickerDateOpen.Text = view.DateOpen.ToString();
|
||||
_shopDocuments = view.ShopDocuments ?? new Dictionary<int, (IDocumentModel, int)>();
|
||||
numericUpDownCapacity.Value = view.Capacity;
|
||||
_shopDocuments = view.ShopDocuments ?? new Dictionary<int, (IDocumentModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
@ -50,7 +51,7 @@ namespace LawFirmView
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка кораблей магазина");
|
||||
_logger.LogInformation("Загрузка документов магазина");
|
||||
try
|
||||
{
|
||||
if (_shopDocuments != null)
|
||||
@ -64,7 +65,7 @@ namespace LawFirmView
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки кораблей магазина");
|
||||
_logger.LogError(ex, "Ошибка загрузки документов магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
@ -91,12 +92,13 @@ namespace LawFirmView
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpen = DateTime.Parse(dateTimePickerDateOpen.Text),
|
||||
ShopDocuments = _shopDocuments
|
||||
};
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpen = DateTime.Parse(dateTimePickerDateOpen.Text),
|
||||
Capacity = (int)numericUpDownCapacity.Value,
|
||||
ShopDocuments = _shopDocuments
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
@ -118,5 +120,5 @@ namespace LawFirmView
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ namespace LawFirmView
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления кораблей");
|
||||
_logger.LogError(ex, "Ошибка удаления документов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,7 @@ namespace LawFirmView
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormAddDocument>();
|
||||
}
|
||||
services.AddTransient<FormSellDocuments>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user