Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fab7391ca7 | |||
| 1ff73bce3a | |||
| 22b2783547 | |||
| 10a344f0b1 | |||
| 8428b895a8 | |||
| 6d525876bc | |||
| a07aff9438 | |||
| 67bffd6798 | |||
| 1d24f91773 | |||
| 3d750ef0b2 | |||
| fe3e9171e8 | |||
| abf3aeca23 | |||
| 81b4335193 | |||
| f1c6437bc7 | |||
| d363e63eb8 | |||
| 1f791d68d7 | |||
| 3e61ea61df | |||
| b81bb26b41 | |||
| c10255f4cb | |||
| b1300d39ef | |||
| 036c45410e | |||
| ad9847c51c | |||
| 5d703cb615 | |||
| b4c8722cd4 | |||
| 2fa2dfe6bc | |||
| 1a650d93b1 | |||
| b4d4b6d0f4 | |||
| 57d43005e6 | |||
| 4330a80dd0 | |||
| 8447239146 | |||
| 8ad6e9478e | |||
| fe53deabde | |||
| 8114ecd7fb | |||
| 054222a8d4 | |||
| 4ac87a10ed | |||
| 332c58bda5 | |||
| e1fdeb7ba3 | |||
| 56faadb0ad | |||
| 27449f920f |
@@ -13,7 +13,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoWorkshopBusinessLogic",
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoWorkshopListImplement", "AutoWorkshopImplement\AutoWorkshopListImplement.csproj", "{B564F5E8-2F14-4816-8481-1F9649F1F414}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoWorkshopFileImplement", "AutoWorkshopFileImplement\AutoWorkshopFileImplement.csproj", "{862B0F3D-1B88-45B8-9526-AD21A6D6FA81}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AutoWorkshopFileImplement", "AutoWorkshopFileImplement\AutoWorkshopFileImplement.csproj", "{862B0F3D-1B88-45B8-9526-AD21A6D6FA81}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoWorkshopDatabaseImplement", "AutoWorkshopDatabaseImplement\AutoWorkshopDatabaseImplement.csproj", "{751668F7-01A3-43F0-BDD8-ABB3A8F5A955}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -45,6 +47,10 @@ Global
|
||||
{862B0F3D-1B88-45B8-9526-AD21A6D6FA81}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{862B0F3D-1B88-45B8-9526-AD21A6D6FA81}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{862B0F3D-1B88-45B8-9526-AD21A6D6FA81}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{751668F7-01A3-43F0-BDD8-ABB3A8F5A955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{751668F7-01A3-43F0-BDD8-ABB3A8F5A955}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{751668F7-01A3-43F0-BDD8-ABB3A8F5A955}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{751668F7-01A3-43F0-BDD8-ABB3A8F5A955}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -13,11 +13,14 @@ namespace AutoWorkshopBusinessLogic.BusinessLogics
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly IShopStorage _shopStorage;
|
||||
|
||||
public OrderLogic(ILogger<RepairLogic> Logger, IOrderStorage OrderStorage)
|
||||
public OrderLogic(ILogger<RepairLogic> Logger, IOrderStorage OrderStorage, IShopStorage ShopStorage)
|
||||
{
|
||||
_logger = Logger;
|
||||
|
||||
_orderStorage = OrderStorage;
|
||||
_shopStorage = ShopStorage;
|
||||
}
|
||||
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? Model)
|
||||
@@ -107,6 +110,23 @@ namespace AutoWorkshopBusinessLogic.BusinessLogics
|
||||
|
||||
public bool DeliveryOrder(OrderBindingModel Model)
|
||||
{
|
||||
var Order = _orderStorage.GetElement(new OrderSearchModel
|
||||
{
|
||||
Id = Model.Id
|
||||
});
|
||||
|
||||
if (Order is null)
|
||||
throw new ArgumentNullException(nameof(Order));
|
||||
|
||||
if (!_shopStorage.RestockingShops(new SupplyBindingModel
|
||||
{
|
||||
RepairId = Order.RepairId,
|
||||
Count = Order.Count
|
||||
}))
|
||||
{
|
||||
throw new ArgumentException("Недостаточно места");
|
||||
}
|
||||
|
||||
return ChangeOrderStatus(Model, OrderStatus.Delivered);
|
||||
}
|
||||
|
||||
|
||||
142
AutoWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs
Normal file
142
AutoWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
using AutoWorkshopBusinessLogic.OfficePackage;
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperModels;
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ReportLogic : IReportLogic
|
||||
{
|
||||
private readonly IComponentStorage _componentStorage;
|
||||
private readonly IRepairStorage _RepairStorage;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly IShopStorage _shopStorage;
|
||||
private readonly AbstractSaveToExcel _saveToExcel;
|
||||
private readonly AbstractSaveToWord _saveToWord;
|
||||
private readonly AbstractSaveToPdf _saveToPdf;
|
||||
|
||||
public ReportLogic(IRepairStorage RepairStorage, IComponentStorage ComponentStorage, IOrderStorage OrderStorage, IShopStorage ShopStorage,
|
||||
AbstractSaveToExcel SaveToExcel, AbstractSaveToWord SaveToWord, AbstractSaveToPdf SaveToPdf)
|
||||
{
|
||||
_RepairStorage = RepairStorage;
|
||||
_componentStorage = ComponentStorage;
|
||||
_orderStorage = OrderStorage;
|
||||
_shopStorage = ShopStorage;
|
||||
|
||||
_saveToExcel = SaveToExcel;
|
||||
_saveToWord = SaveToWord;
|
||||
_saveToPdf = SaveToPdf;
|
||||
}
|
||||
|
||||
public List<ReportRepairComponentViewModel> GetRepairComponents()
|
||||
{
|
||||
return _RepairStorage.GetFullList().
|
||||
Select(x => new ReportRepairComponentViewModel
|
||||
{
|
||||
RepairName = x.RepairName,
|
||||
Components = x.RepairComponents.Select(x => (x.Value.Item1.ComponentName, x.Value.Item2)).ToList(),
|
||||
TotalCount = x.RepairComponents.Select(x => x.Value.Item2).Sum()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ReportShopsViewModel> GetShops()
|
||||
{
|
||||
return _shopStorage.GetFullList().Select(x => new ReportShopsViewModel
|
||||
{
|
||||
ShopName = x.ShopName,
|
||||
Repairs = x.ShopRepairs.Select(x => (x.Value.Item1.RepairName, x.Value.Item2)).ToList(),
|
||||
TotalCount = x.ShopRepairs.Select(x => x.Value.Item2).Sum()
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public List<ReportGroupedOrdersViewModel> GetGroupedOrders()
|
||||
{
|
||||
return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportGroupedOrdersViewModel
|
||||
{
|
||||
Date = x.Key,
|
||||
OrdersCount = x.Count(),
|
||||
OrdersSum = x.Select(y => y.Sum).Sum()
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel Model)
|
||||
{
|
||||
return _orderStorage.GetFilteredList(new OrderSearchModel { DateFrom = Model.DateFrom, DateTo = Model.DateTo })
|
||||
.Select(x => new ReportOrdersViewModel
|
||||
{
|
||||
Id = x.Id,
|
||||
DateCreate = x.DateCreate,
|
||||
RepairName = x.RepairName,
|
||||
Sum = x.Sum,
|
||||
Status = x.Status.ToString()
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void SaveRepairsToWordFile(ReportBindingModel Model)
|
||||
{
|
||||
_saveToWord.CreateRepairsDoc(new WordRepairsInfo
|
||||
{
|
||||
FileName = Model.FileName,
|
||||
Title = "Список ремонтов",
|
||||
Repairs = _RepairStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveRepairComponentToExcelFile(ReportBindingModel Model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelRepairsInfo
|
||||
{
|
||||
FileName = Model.FileName,
|
||||
Title = "Список ремонтов",
|
||||
RepairComponents = GetRepairComponents()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveOrdersToPdfFile(ReportBindingModel Model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfOrdersInfo
|
||||
{
|
||||
FileName = Model.FileName,
|
||||
Title = "Список заказов",
|
||||
DateFrom = Model.DateFrom!.Value,
|
||||
DateTo = Model.DateTo!.Value,
|
||||
Orders = GetOrders(Model)
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveShopsToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateShopsDoc(new WordShopsInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список магазинов",
|
||||
Shops = _shopStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveShopsToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateShopRepairsReport(new ExcelShopsInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Загруженность магазинов",
|
||||
ShopRepairs = GetShops()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveGroupedOrdersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateGroupedOrdersDoc(new PdfGroupedOrdersInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список заказов, объединенных по датам",
|
||||
GroupedOrders = GetGroupedOrders()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
194
AutoWorkshopBusinessLogic/BusinessLogics/ShopLogic.cs
Normal file
194
AutoWorkshopBusinessLogic/BusinessLogics/ShopLogic.cs
Normal file
@@ -0,0 +1,194 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ShopLogic : IShopLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopStorage _shopStorage;
|
||||
private readonly IRepairStorage _repairStorage;
|
||||
|
||||
public ShopLogic(ILogger<ShopLogic> Logger, IShopStorage ShopStorage, IRepairStorage RepairStorage)
|
||||
{
|
||||
_logger = Logger;
|
||||
_shopStorage = ShopStorage;
|
||||
_repairStorage = RepairStorage;
|
||||
}
|
||||
|
||||
public List<ShopViewModel>? ReadList(ShopSearchModel? Model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id}", Model?.ShopName, Model?.Id);
|
||||
|
||||
var List = Model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(Model);
|
||||
|
||||
if (List == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", List.Count);
|
||||
return List;
|
||||
}
|
||||
|
||||
public ShopViewModel? ReadElement(ShopSearchModel Model)
|
||||
{
|
||||
if (Model == null)
|
||||
throw new ArgumentNullException(nameof(Model));
|
||||
|
||||
_logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", Model.ShopName, Model.Id);
|
||||
|
||||
var Element = _shopStorage.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(ShopBindingModel Model)
|
||||
{
|
||||
CheckModel(Model);
|
||||
|
||||
if (_shopStorage.Insert(Model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ShopBindingModel Model)
|
||||
{
|
||||
CheckModel(Model);
|
||||
|
||||
if (_shopStorage.Update(Model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ShopBindingModel Model)
|
||||
{
|
||||
CheckModel(Model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", Model.Id);
|
||||
|
||||
if (_shopStorage.Delete(Model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool MakeSupply(SupplyBindingModel Model)
|
||||
{
|
||||
if (Model == null)
|
||||
throw new ArgumentNullException(nameof(Model));
|
||||
|
||||
if (Model.Count <= 0)
|
||||
throw new ArgumentException("Количество ремонтов должно быть больше 0");
|
||||
|
||||
ShopViewModel? Shop = _shopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
Id = Model.ShopId
|
||||
});
|
||||
|
||||
if (Shop == null)
|
||||
throw new ArgumentException("Магазина не существует");
|
||||
|
||||
int CurrentRepairsNum = Shop.ShopRepairs.Select(x => x.Value.Item2).Sum();
|
||||
if (Model.Count > Shop.RepairsMaxCount - CurrentRepairsNum)
|
||||
{
|
||||
_logger.LogWarning("Попытка добавить в магазин число элементов, большее RepairsMaxCount");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Shop.ShopRepairs.ContainsKey(Model.RepairId))
|
||||
{
|
||||
var RepairsNum = Shop.ShopRepairs[Model.RepairId];
|
||||
RepairsNum.Item2 += Model.Count;
|
||||
Shop.ShopRepairs[Model.RepairId] = RepairsNum;
|
||||
}
|
||||
else
|
||||
{
|
||||
var Repair = _repairStorage.GetElement(new RepairSearchModel
|
||||
{
|
||||
Id = Model.RepairId
|
||||
});
|
||||
|
||||
if (Repair == null)
|
||||
throw new ArgumentException($"Поставка: Товар с id {Model.RepairId} не найден");
|
||||
|
||||
Shop.ShopRepairs.Add(Model.RepairId, (Repair, Model.Count));
|
||||
}
|
||||
|
||||
_shopStorage.Update(new ShopBindingModel()
|
||||
{
|
||||
Id = Shop.Id,
|
||||
ShopName = Shop.ShopName,
|
||||
Address = Shop.Address,
|
||||
OpeningDate = Shop.OpeningDate,
|
||||
ShopRepairs = Shop.ShopRepairs,
|
||||
RepairsMaxCount = Shop.RepairsMaxCount,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ShopBindingModel Model, bool WithParams=true)
|
||||
{
|
||||
if (Model == null)
|
||||
throw new ArgumentNullException(nameof(Model));
|
||||
|
||||
if (!WithParams)
|
||||
return;
|
||||
|
||||
if (string.IsNullOrEmpty(Model.Address))
|
||||
throw new ArgumentException("Адрес магазина длжен быть заполнен", nameof(Model.Address));
|
||||
|
||||
if (string.IsNullOrEmpty(Model.ShopName))
|
||||
throw new ArgumentException("Название магазина должно быть заполнено", nameof(Model.ShopName));
|
||||
|
||||
_logger.LogInformation("Shop. ShopName: {ShopName}. Address: {Address}. OpeningDate: {OpeningDate}. Id:{Id}",
|
||||
Model.ShopName, Model.Address, Model.OpeningDate, Model.Id);
|
||||
|
||||
var Element = _shopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
ShopName = Model.ShopName
|
||||
});
|
||||
if (Element != null && Element.Id != Model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
|
||||
public bool MakeSell(SupplySearchModel Model)
|
||||
{
|
||||
if (!Model.RepairId.HasValue || !Model.Count.HasValue)
|
||||
return false;
|
||||
|
||||
_logger.LogInformation("Поиск ремонтов во всех магазинах");
|
||||
if (_shopStorage.Sell(Model))
|
||||
{
|
||||
_logger.LogInformation("Продажа выполнена успешно");
|
||||
return true;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Продажа не выполнена");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
165
AutoWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
Normal file
165
AutoWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
Normal file
@@ -0,0 +1,165 @@
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToExcel
|
||||
{
|
||||
public void CreateReport(ExcelRepairsInfo Info)
|
||||
{
|
||||
CreateExcel(Info);
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = 1,
|
||||
Text = Info.Title,
|
||||
StyleInfo = ExcelStyleInfoType.Title
|
||||
});
|
||||
|
||||
MergeCells(new ExcelMergeParameters
|
||||
{
|
||||
CellFromName = "A1",
|
||||
CellToName = "C1"
|
||||
});
|
||||
|
||||
uint RowIndex = 2;
|
||||
|
||||
foreach (var RepComp in Info.RepairComponents)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = RowIndex,
|
||||
Text = RepComp.RepairName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
RowIndex++;
|
||||
|
||||
foreach (var (Component, Count) in RepComp.Components)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = RowIndex,
|
||||
Text = Component,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = RowIndex,
|
||||
Text = Count.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
RowIndex++;
|
||||
}
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = RowIndex,
|
||||
Text = "Итого",
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = RowIndex,
|
||||
Text = RepComp.TotalCount.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
RowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(Info);
|
||||
}
|
||||
|
||||
public void CreateShopRepairsReport(ExcelShopsInfo Info)
|
||||
{
|
||||
CreateExcel(Info);
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = 1,
|
||||
Text = Info.Title,
|
||||
StyleInfo = ExcelStyleInfoType.Title
|
||||
});
|
||||
|
||||
MergeCells(new ExcelMergeParameters
|
||||
{
|
||||
CellFromName = "A1",
|
||||
CellToName = "C1"
|
||||
});
|
||||
|
||||
uint RowIndex = 2;
|
||||
|
||||
foreach (var ShopRep in Info.ShopRepairs)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = RowIndex,
|
||||
Text = ShopRep.ShopName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
RowIndex++;
|
||||
|
||||
foreach (var (Repair, Count) in ShopRep.Repairs)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = RowIndex,
|
||||
Text = Repair,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = RowIndex,
|
||||
Text = Count.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
});
|
||||
|
||||
RowIndex++;
|
||||
}
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = RowIndex,
|
||||
Text = "Итого",
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = RowIndex,
|
||||
Text = ShopRep.TotalCount.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
RowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(Info);
|
||||
}
|
||||
|
||||
protected abstract void CreateExcel(IDocumentInfo Info);
|
||||
|
||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters ExcelParams);
|
||||
|
||||
protected abstract void MergeCells(ExcelMergeParameters ExcelParams);
|
||||
|
||||
protected abstract void SaveExcel(IDocumentInfo Info);
|
||||
}
|
||||
}
|
||||
74
AutoWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
Normal file
74
AutoWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToPdf
|
||||
{
|
||||
public void CreateDoc(PdfOrdersInfo Info)
|
||||
{
|
||||
CreatePdf(Info);
|
||||
CreateParagraph(new PdfParagraph { Text = Info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
CreateParagraph(new PdfParagraph { Text = $"с {Info.DateFrom.ToShortDateString()} по {Info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
||||
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Ремонт", "Статус", "Сумма" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
foreach (var order in Info.Orders)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.RepairName, order.Status.ToString(), order.Sum.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
CreateParagraph(new PdfParagraph { Text = $"Итого: {Info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Rigth });
|
||||
|
||||
SavePdf(Info);
|
||||
}
|
||||
|
||||
public void CreateGroupedOrdersDoc(PdfGroupedOrdersInfo Info)
|
||||
{
|
||||
CreatePdf(Info);
|
||||
CreateParagraph(new PdfParagraph { Text = Info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
|
||||
CreateTable(new List<string> { "4cm", "3cm", "2cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Дата заказа", "Кол-во", "Сумма" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
foreach (var groupedOrder in Info.GroupedOrders)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { groupedOrder.Date.ToShortDateString(), groupedOrder.OrdersCount.ToString(), groupedOrder.OrdersSum.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
|
||||
CreateParagraph(new PdfParagraph { Text = $"Итого: {Info.GroupedOrders.Sum(x => x.OrdersSum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
SavePdf(Info);
|
||||
}
|
||||
|
||||
protected abstract void CreatePdf(IDocumentInfo Info);
|
||||
|
||||
protected abstract void CreateParagraph(PdfParagraph Paragraph);
|
||||
|
||||
protected abstract void CreateTable(List<string> Columns);
|
||||
|
||||
protected abstract void CreateRow(PdfRowParameters RowParameters);
|
||||
|
||||
protected abstract void SavePdf(IDocumentInfo Info);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToWord
|
||||
{
|
||||
public void CreateRepairsDoc(WordRepairsInfo Info)
|
||||
{
|
||||
CreateWord(Info);
|
||||
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (Info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var Repair in Info.Repairs)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> {
|
||||
(Repair.RepairName, new WordTextProperties { Size = "24", Bold = true}),
|
||||
("\t"+Repair.Price.ToString(), new WordTextProperties{Size = "24"})
|
||||
},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SaveWord(Info);
|
||||
}
|
||||
|
||||
public void CreateShopsDoc(WordShopsInfo Info)
|
||||
{
|
||||
CreateWord(Info);
|
||||
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (Info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
|
||||
CreateTable(new List<string> { "3000", "3000", "3000" });
|
||||
CreateRow(new WordRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Название", "Адрес", "Дата открытия" },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
Bold = true,
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
|
||||
foreach (var Shop in Info.Shops)
|
||||
{
|
||||
CreateRow(new WordRowParameters
|
||||
{
|
||||
Texts = new List<string> { Shop.ShopName, Shop.Address, Shop.OpeningDate.ToString() },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "22",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
SaveWord(Info);
|
||||
}
|
||||
|
||||
protected abstract void CreateWord(IDocumentInfo Info);
|
||||
|
||||
protected abstract void CreateParagraph(WordParagraph Paragraph);
|
||||
|
||||
protected abstract void SaveWord(IDocumentInfo Info);
|
||||
|
||||
protected abstract void CreateTable(List<string> Colums);
|
||||
|
||||
protected abstract void CreateRow(WordRowParameters RowParameters);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum ExcelStyleInfoType
|
||||
{
|
||||
Title,
|
||||
Text,
|
||||
TextWithBroder
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum PdfParagraphAlignmentType
|
||||
{
|
||||
Center,
|
||||
Left,
|
||||
Rigth
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
public enum WordJustificationType
|
||||
{
|
||||
Center,
|
||||
Both
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelCellParameters
|
||||
{
|
||||
public string ColumnName { get; set; } = string.Empty;
|
||||
|
||||
public uint RowIndex { get; set; }
|
||||
|
||||
public string Text { get; set; } = string.Empty;
|
||||
|
||||
public string CellReference => $"{ColumnName}{RowIndex}";
|
||||
|
||||
public ExcelStyleInfoType StyleInfo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelMergeParameters
|
||||
{
|
||||
public string CellFromName { get; set; } = string.Empty;
|
||||
|
||||
public string CellToName { get; set; } = string.Empty;
|
||||
|
||||
public string Merge => $"{CellFromName}:{CellToName}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelRepairsInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<ReportRepairComponentViewModel> RepairComponents { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelShopsInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<ReportShopsViewModel> ShopRepairs { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public interface IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
|
||||
public string Title { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfGroupedOrdersInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateFrom { get; set; }
|
||||
|
||||
public DateTime DateTo { get; set; }
|
||||
|
||||
public List<ReportGroupedOrdersViewModel> GroupedOrders { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfOrdersInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateFrom { get; set; }
|
||||
|
||||
public DateTime DateTo { get; set; }
|
||||
|
||||
public List<ReportOrdersViewModel> Orders { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfParagraph
|
||||
{
|
||||
public string Text { get; set; } = string.Empty;
|
||||
|
||||
public string Style { get; set; } = string.Empty;
|
||||
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class PdfRowParameters
|
||||
{
|
||||
public List<string> Texts { get; set; } = new();
|
||||
|
||||
public string Style { get; set; } = string.Empty;
|
||||
|
||||
public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordParagraph
|
||||
{
|
||||
public List<(string, WordTextProperties)> Texts { get; set; } = new();
|
||||
|
||||
public WordTextProperties? TextProperties { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordRepairsInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<RepairViewModel> Repairs { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordRowParameters
|
||||
{
|
||||
public List<string> Texts { get; set; } = new();
|
||||
|
||||
public WordTextProperties TextProperties { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordShopsInfo : IDocumentInfo
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
public List<ShopViewModel> Shops { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperEnums;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class WordTextProperties
|
||||
{
|
||||
public string Size { get; set; } = string.Empty;
|
||||
|
||||
public bool Bold { get; set; }
|
||||
|
||||
public WordJustificationType JustificationType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,281 @@
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToExcel : AbstractSaveToExcel
|
||||
{
|
||||
private SpreadsheetDocument? _spreadsheetDocument;
|
||||
private SharedStringTablePart? _shareStringPart;
|
||||
private Worksheet? _worksheet;
|
||||
|
||||
private static void CreateStyles(WorkbookPart WorkbookPart)
|
||||
{
|
||||
var sp = WorkbookPart.AddNewPart<WorkbookStylesPart>();
|
||||
sp.Stylesheet = new Stylesheet();
|
||||
|
||||
var Fonts = new Fonts() { Count = 2U, KnownFonts = true };
|
||||
|
||||
var FontUsual = new Font();
|
||||
FontUsual.Append(new FontSize() { Val = 12D });
|
||||
FontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||
FontUsual.Append(new FontName() { Val = "Times New Roman" });
|
||||
FontUsual.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
FontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
var FontTitle = new Font();
|
||||
FontTitle.Append(new Bold());
|
||||
FontTitle.Append(new FontSize() { Val = 14D });
|
||||
FontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U });
|
||||
FontTitle.Append(new FontName() { Val = "Times New Roman" });
|
||||
FontTitle.Append(new FontFamilyNumbering() { Val = 2 });
|
||||
FontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
|
||||
|
||||
Fonts.Append(FontUsual);
|
||||
Fonts.Append(FontTitle);
|
||||
|
||||
var Fills = new Fills() { Count = 2U };
|
||||
|
||||
var Fill1 = new Fill();
|
||||
Fill1.Append(new PatternFill() { PatternType = PatternValues.None });
|
||||
|
||||
var Fill2 = new Fill();
|
||||
Fill2.Append(new PatternFill() { PatternType = PatternValues.Gray125 });
|
||||
|
||||
Fills.Append(Fill1);
|
||||
Fills.Append(Fill2);
|
||||
|
||||
var Borders = new Borders() { Count = 2U };
|
||||
|
||||
var BorderNoBorder = new Border();
|
||||
BorderNoBorder.Append(new LeftBorder());
|
||||
BorderNoBorder.Append(new RightBorder());
|
||||
BorderNoBorder.Append(new TopBorder());
|
||||
BorderNoBorder.Append(new BottomBorder());
|
||||
BorderNoBorder.Append(new DiagonalBorder());
|
||||
|
||||
var BorderThin = new Border();
|
||||
|
||||
var LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin };
|
||||
LeftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var RightBorder = new RightBorder() { Style = BorderStyleValues.Thin };
|
||||
RightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var TopBorder = new TopBorder() { Style = BorderStyleValues.Thin };
|
||||
TopBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
var BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin };
|
||||
BottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U });
|
||||
|
||||
BorderThin.Append(LeftBorder);
|
||||
BorderThin.Append(RightBorder);
|
||||
BorderThin.Append(TopBorder);
|
||||
BorderThin.Append(BottomBorder);
|
||||
BorderThin.Append(new DiagonalBorder());
|
||||
|
||||
Borders.Append(BorderNoBorder);
|
||||
Borders.Append(BorderThin);
|
||||
|
||||
var CellStyleFormats = new CellStyleFormats() { Count = 1U };
|
||||
var CellFormatStyle = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U };
|
||||
|
||||
CellStyleFormats.Append(CellFormatStyle);
|
||||
|
||||
var CellFormats = new CellFormats() { Count = 3U };
|
||||
var CellFormatFont = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 0U, FormatId = 0U, ApplyFont = true };
|
||||
var CellFormatFontAndBorder = new CellFormat() { NumberFormatId = 0U, FontId = 0U, FillId = 0U, BorderId = 1U, FormatId = 0U, ApplyFont = true, ApplyBorder = true };
|
||||
var CellFormatTitle = new CellFormat() { NumberFormatId = 0U, FontId = 1U, FillId = 0U, BorderId = 0U, FormatId = 0U, Alignment = new Alignment() { Vertical = VerticalAlignmentValues.Center, WrapText = true, Horizontal = HorizontalAlignmentValues.Center }, ApplyFont = true };
|
||||
|
||||
CellFormats.Append(CellFormatFont);
|
||||
CellFormats.Append(CellFormatFontAndBorder);
|
||||
CellFormats.Append(CellFormatTitle);
|
||||
|
||||
var CellStyles = new CellStyles() { Count = 1U };
|
||||
|
||||
CellStyles.Append(new CellStyle() { Name = "Normal", FormatId = 0U, BuiltinId = 0U });
|
||||
|
||||
var DifferentialFormats = new DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats() { Count = 0U };
|
||||
|
||||
var TableStyles = new TableStyles() { Count = 0U, DefaultTableStyle = "TableStyleMedium2", DefaultPivotStyle = "PivotStyleLight16" };
|
||||
|
||||
var StylesheetExtensionList = new StylesheetExtensionList();
|
||||
|
||||
var StylesheetExtension1 = new StylesheetExtension() { Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}" };
|
||||
StylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
StylesheetExtension1.Append(new SlicerStyles() { DefaultSlicerStyle = "SlicerStyleLight1" });
|
||||
|
||||
var StylesheetExtension2 = new StylesheetExtension() { Uri = "{9260A510-F301-46a8-8635-F512D64BE5F5}" };
|
||||
StylesheetExtension2.AddNamespaceDeclaration("x15", "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
|
||||
StylesheetExtension2.Append(new TimelineStyles() { DefaultTimelineStyle = "TimeSlicerStyleLight1" });
|
||||
|
||||
StylesheetExtensionList.Append(StylesheetExtension1);
|
||||
StylesheetExtensionList.Append(StylesheetExtension2);
|
||||
|
||||
sp.Stylesheet.Append(Fonts);
|
||||
sp.Stylesheet.Append(Fills);
|
||||
sp.Stylesheet.Append(Borders);
|
||||
sp.Stylesheet.Append(CellStyleFormats);
|
||||
sp.Stylesheet.Append(CellFormats);
|
||||
sp.Stylesheet.Append(CellStyles);
|
||||
sp.Stylesheet.Append(DifferentialFormats);
|
||||
sp.Stylesheet.Append(TableStyles);
|
||||
sp.Stylesheet.Append(StylesheetExtensionList);
|
||||
}
|
||||
|
||||
private static uint GetStyleValue(ExcelStyleInfoType StyleInfo)
|
||||
{
|
||||
return StyleInfo switch
|
||||
{
|
||||
ExcelStyleInfoType.Title => 2U,
|
||||
ExcelStyleInfoType.TextWithBroder => 1U,
|
||||
ExcelStyleInfoType.Text => 0U,
|
||||
_ => 0U,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void CreateExcel(IDocumentInfo Info)
|
||||
{
|
||||
_spreadsheetDocument = SpreadsheetDocument.Create(Info.FileName, SpreadsheetDocumentType.Workbook);
|
||||
|
||||
var WorkbookPart = _spreadsheetDocument.AddWorkbookPart();
|
||||
WorkbookPart.Workbook = new Workbook();
|
||||
|
||||
CreateStyles(WorkbookPart);
|
||||
|
||||
_shareStringPart = _spreadsheetDocument.WorkbookPart!.GetPartsOfType<SharedStringTablePart>().Any()
|
||||
? _spreadsheetDocument.WorkbookPart.GetPartsOfType<SharedStringTablePart>().First()
|
||||
: _spreadsheetDocument.WorkbookPart.AddNewPart<SharedStringTablePart>();
|
||||
|
||||
// Создаем SharedStringTable, если его нет
|
||||
if (_shareStringPart.SharedStringTable == null)
|
||||
{
|
||||
_shareStringPart.SharedStringTable = new SharedStringTable();
|
||||
}
|
||||
|
||||
// Создаем лист в книгу
|
||||
var WorksheetPart = WorkbookPart.AddNewPart<WorksheetPart>();
|
||||
WorksheetPart.Worksheet = new Worksheet(new SheetData());
|
||||
|
||||
// Добавляем лист в книгу
|
||||
var Sheets = _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
|
||||
var Sheet = new Sheet()
|
||||
{
|
||||
Id = _spreadsheetDocument.WorkbookPart.GetIdOfPart(WorksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист"
|
||||
};
|
||||
|
||||
Sheets.Append(Sheet);
|
||||
|
||||
_worksheet = WorksheetPart.Worksheet;
|
||||
}
|
||||
|
||||
protected override void InsertCellInWorksheet(ExcelCellParameters ExcelParams)
|
||||
{
|
||||
if (_worksheet == null || _shareStringPart == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var SheetData = _worksheet.GetFirstChild<SheetData>();
|
||||
if (SheetData == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Ищем строку, либо добавляем ее
|
||||
Row row;
|
||||
if (SheetData.Elements<Row>().Where(r => r.RowIndex! == ExcelParams.RowIndex).Any())
|
||||
{
|
||||
row = SheetData.Elements<Row>().Where(r => r.RowIndex! == ExcelParams.RowIndex).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
row = new Row() { RowIndex = ExcelParams.RowIndex };
|
||||
SheetData.Append(row);
|
||||
}
|
||||
|
||||
// Ищем нужную ячейку
|
||||
Cell cell;
|
||||
if (row.Elements<Cell>().Where(c => c.CellReference!.Value == ExcelParams.CellReference).Any())
|
||||
{
|
||||
cell = row.Elements<Cell>().Where(c => c.CellReference!.Value == ExcelParams.CellReference).First();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Все ячейки должны быть последовательно друг за другом расположены
|
||||
// нужно определить, после какой вставлять
|
||||
Cell? refCell = null;
|
||||
foreach (Cell rowCell in row.Elements<Cell>())
|
||||
{
|
||||
if (string.Compare(rowCell.CellReference!.Value, ExcelParams.CellReference, true) > 0)
|
||||
{
|
||||
refCell = rowCell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var NewCell = new Cell() { CellReference = ExcelParams.CellReference };
|
||||
row.InsertBefore(NewCell, refCell);
|
||||
|
||||
cell = NewCell;
|
||||
}
|
||||
|
||||
// вставляем новый текст
|
||||
_shareStringPart.SharedStringTable.AppendChild(new SharedStringItem(new Text(ExcelParams.Text)));
|
||||
_shareStringPart.SharedStringTable.Save();
|
||||
|
||||
cell.CellValue = new CellValue((_shareStringPart.SharedStringTable.Elements<SharedStringItem>().Count() - 1).ToString());
|
||||
cell.DataType = new EnumValue<CellValues>(CellValues.SharedString);
|
||||
cell.StyleIndex = GetStyleValue(ExcelParams.StyleInfo);
|
||||
}
|
||||
|
||||
protected override void MergeCells(ExcelMergeParameters ExcelParams)
|
||||
{
|
||||
if (_worksheet == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MergeCells MergeCells;
|
||||
|
||||
if (_worksheet.Elements<MergeCells>().Any())
|
||||
{
|
||||
MergeCells = _worksheet.Elements<MergeCells>().First();
|
||||
}
|
||||
else
|
||||
{
|
||||
MergeCells = new MergeCells();
|
||||
|
||||
if (_worksheet.Elements<CustomSheetView>().Any())
|
||||
{
|
||||
_worksheet.InsertAfter(MergeCells, _worksheet.Elements<CustomSheetView>().First());
|
||||
}
|
||||
else
|
||||
{
|
||||
_worksheet.InsertAfter(MergeCells, _worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
|
||||
var MergeCell = new MergeCell()
|
||||
{
|
||||
Reference = new StringValue(ExcelParams.Merge)
|
||||
};
|
||||
|
||||
MergeCells.Append(MergeCell);
|
||||
}
|
||||
|
||||
protected override void SaveExcel(IDocumentInfo Info)
|
||||
{
|
||||
if (_spreadsheetDocument == null)
|
||||
return;
|
||||
|
||||
_spreadsheetDocument.WorkbookPart!.Workbook.Save();
|
||||
_spreadsheetDocument.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
108
AutoWorkshopBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
Normal file
108
AutoWorkshopBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
Normal file
@@ -0,0 +1,108 @@
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToPdf : AbstractSaveToPdf
|
||||
{
|
||||
private Document? _document;
|
||||
private Section? _section;
|
||||
private Table? _table;
|
||||
|
||||
private static ParagraphAlignment GetParagraphAlignment(PdfParagraphAlignmentType Type)
|
||||
{
|
||||
return Type switch
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
|
||||
private static void DefineStyles(Document Document)
|
||||
{
|
||||
var Style = Document.Styles["Normal"];
|
||||
Style.Font.Name = "Times New Roman";
|
||||
Style.Font.Size = 14;
|
||||
|
||||
Style = Document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
Style.Font.Bold = true;
|
||||
}
|
||||
|
||||
protected override void CreatePdf(IDocumentInfo Info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
|
||||
protected override void CreateParagraph(PdfParagraph PdfParagraph)
|
||||
{
|
||||
if (_section == null)
|
||||
return;
|
||||
|
||||
var Paragraph = _section.AddParagraph(PdfParagraph.Text);
|
||||
|
||||
Paragraph.Format.SpaceAfter = "1cm";
|
||||
Paragraph.Format.Alignment = GetParagraphAlignment(PdfParagraph.ParagraphAlignment);
|
||||
Paragraph.Style = PdfParagraph.Style;
|
||||
}
|
||||
|
||||
protected override void CreateTable(List<string> Columns)
|
||||
{
|
||||
if (_document == null)
|
||||
return;
|
||||
|
||||
_table = _document.LastSection.AddTable();
|
||||
|
||||
foreach (var Elem in Columns)
|
||||
{
|
||||
_table.AddColumn(Elem);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateRow(PdfRowParameters RowParameters)
|
||||
{
|
||||
if (_table == null)
|
||||
return;
|
||||
|
||||
var Row = _table.AddRow();
|
||||
|
||||
for (int i = 0; i < RowParameters.Texts.Count; ++i)
|
||||
{
|
||||
Row.Cells[i].AddParagraph(RowParameters.Texts[i]);
|
||||
|
||||
if (!string.IsNullOrEmpty(RowParameters.Style))
|
||||
{
|
||||
Row.Cells[i].Style = RowParameters.Style;
|
||||
}
|
||||
|
||||
Unit borderWidth = 0.5;
|
||||
|
||||
Row.Cells[i].Borders.Left.Width = borderWidth;
|
||||
Row.Cells[i].Borders.Right.Width = borderWidth;
|
||||
Row.Cells[i].Borders.Top.Width = borderWidth;
|
||||
Row.Cells[i].Borders.Bottom.Width = borderWidth;
|
||||
|
||||
Row.Cells[i].Format.Alignment = GetParagraphAlignment(RowParameters.ParagraphAlignment);
|
||||
Row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SavePdf(IDocumentInfo Info)
|
||||
{
|
||||
var Renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
|
||||
Renderer.RenderDocument();
|
||||
Renderer.PdfDocument.Save(Info.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
192
AutoWorkshopBusinessLogic/OfficePackage/Implements/SaveToWord.cs
Normal file
192
AutoWorkshopBusinessLogic/OfficePackage/Implements/SaveToWord.cs
Normal file
@@ -0,0 +1,192 @@
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace AutoWorkshopBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
public class SaveToWord : AbstractSaveToWord
|
||||
{
|
||||
private WordprocessingDocument? _wordDocument;
|
||||
private Body? _docBody;
|
||||
|
||||
private static JustificationValues GetJustificationValues(WordJustificationType Type)
|
||||
{
|
||||
return Type switch
|
||||
{
|
||||
WordJustificationType.Both => JustificationValues.Both,
|
||||
WordJustificationType.Center => JustificationValues.Center,
|
||||
_ => JustificationValues.Left,
|
||||
};
|
||||
}
|
||||
|
||||
private static SectionProperties CreateSectionProperties()
|
||||
{
|
||||
var Properties = new SectionProperties();
|
||||
|
||||
var PageSize = new PageSize
|
||||
{
|
||||
Orient = PageOrientationValues.Portrait
|
||||
};
|
||||
|
||||
Properties.AppendChild(PageSize);
|
||||
return Properties;
|
||||
}
|
||||
|
||||
private static ParagraphProperties? CreateParagraphProperties(WordTextProperties? ParagraphProperties)
|
||||
{
|
||||
if (ParagraphProperties == null)
|
||||
return null;
|
||||
|
||||
|
||||
var Properties = new ParagraphProperties();
|
||||
|
||||
Properties.AppendChild(new Justification()
|
||||
{
|
||||
Val = GetJustificationValues(ParagraphProperties.JustificationType)
|
||||
});
|
||||
|
||||
Properties.AppendChild(new SpacingBetweenLines
|
||||
{
|
||||
LineRule = LineSpacingRuleValues.Auto
|
||||
});
|
||||
|
||||
Properties.AppendChild(new Indentation());
|
||||
|
||||
var ParagraphMarkRunProperties = new ParagraphMarkRunProperties();
|
||||
if (!string.IsNullOrEmpty(ParagraphProperties.Size))
|
||||
{
|
||||
ParagraphMarkRunProperties.AppendChild(new FontSize { Val = ParagraphProperties.Size });
|
||||
}
|
||||
|
||||
Properties.AppendChild(ParagraphMarkRunProperties);
|
||||
return Properties;
|
||||
}
|
||||
|
||||
protected override void CreateWord(IDocumentInfo Info)
|
||||
{
|
||||
_wordDocument = WordprocessingDocument.Create(Info.FileName, WordprocessingDocumentType.Document);
|
||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||
|
||||
mainPart.Document = new Document();
|
||||
_docBody = mainPart.Document.AppendChild(new Body());
|
||||
}
|
||||
|
||||
protected override void CreateParagraph(WordParagraph Paragraph)
|
||||
{
|
||||
if (_docBody == null || Paragraph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var DocParagraph = new Paragraph();
|
||||
DocParagraph.AppendChild(CreateParagraphProperties(Paragraph.TextProperties));
|
||||
|
||||
foreach (var Run in Paragraph.Texts)
|
||||
{
|
||||
var DocRun = new Run();
|
||||
|
||||
var Properties = new RunProperties();
|
||||
Properties.AppendChild(new FontSize { Val = Run.Item2.Size });
|
||||
|
||||
if (Run.Item2.Bold)
|
||||
{
|
||||
Properties.AppendChild(new Bold());
|
||||
}
|
||||
|
||||
DocRun.AppendChild(Properties);
|
||||
DocRun.AppendChild(new Text { Text = Run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||
DocParagraph.AppendChild(DocRun);
|
||||
}
|
||||
|
||||
_docBody.AppendChild(DocParagraph);
|
||||
}
|
||||
|
||||
protected override void SaveWord(IDocumentInfo Info)
|
||||
{
|
||||
if (_docBody == null || _wordDocument == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_docBody.AppendChild(CreateSectionProperties());
|
||||
_wordDocument.MainDocumentPart!.Document.Save();
|
||||
_wordDocument.Close();
|
||||
}
|
||||
|
||||
private Table? _lastTable;
|
||||
|
||||
protected override void CreateTable(List<string> Columns)
|
||||
{
|
||||
if (_docBody == null)
|
||||
return;
|
||||
|
||||
_lastTable = new Table();
|
||||
|
||||
var TableProp = new TableProperties();
|
||||
TableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
|
||||
TableProp.AppendChild(new TableBorders(
|
||||
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 }
|
||||
));
|
||||
TableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
|
||||
_lastTable.AppendChild(TableProp);
|
||||
|
||||
TableGrid TableGrid = new TableGrid();
|
||||
|
||||
foreach (var Column in Columns)
|
||||
{
|
||||
TableGrid.AppendChild(new GridColumn() { Width = Column });
|
||||
}
|
||||
|
||||
_lastTable.AppendChild(TableGrid);
|
||||
_docBody.AppendChild(_lastTable);
|
||||
}
|
||||
|
||||
protected override void CreateRow(WordRowParameters RowParameters)
|
||||
{
|
||||
if (_docBody == null || _lastTable == null)
|
||||
return;
|
||||
|
||||
TableRow DocRow = new TableRow();
|
||||
foreach (var Column in RowParameters.Texts)
|
||||
{
|
||||
var DocParagraph = new Paragraph();
|
||||
WordParagraph Paragraph = new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (Column, RowParameters.TextProperties) },
|
||||
TextProperties = RowParameters.TextProperties
|
||||
};
|
||||
|
||||
DocParagraph.AppendChild(CreateParagraphProperties(Paragraph.TextProperties));
|
||||
|
||||
foreach (var Run in Paragraph.Texts)
|
||||
{
|
||||
var DocRun = new Run();
|
||||
var Properties = new RunProperties();
|
||||
|
||||
Properties.AppendChild(new FontSize { Val = Run.Item2.Size });
|
||||
if (Run.Item2.Bold)
|
||||
{
|
||||
Properties.AppendChild(new Bold());
|
||||
}
|
||||
DocRun.AppendChild(Properties);
|
||||
DocRun.AppendChild(new Text { Text = Run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||
DocParagraph.AppendChild(DocRun);
|
||||
}
|
||||
|
||||
TableCell docCell = new TableCell();
|
||||
|
||||
docCell.AppendChild(DocParagraph);
|
||||
DocRow.AppendChild(docCell);
|
||||
}
|
||||
|
||||
_lastTable.AppendChild(DocRow);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
AutoWorkshopContracts/BindingModels/ReportBindingModel.cs
Normal file
11
AutoWorkshopContracts/BindingModels/ReportBindingModel.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace AutoWorkshopContracts.BindingModels
|
||||
{
|
||||
public class ReportBindingModel
|
||||
{
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
|
||||
public DateTime? DateFrom { get; set; }
|
||||
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
19
AutoWorkshopContracts/BindingModels/ShopBindingModel.cs
Normal file
19
AutoWorkshopContracts/BindingModels/ShopBindingModel.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using AutoWorkshopDataModels.Models;
|
||||
|
||||
namespace AutoWorkshopContracts.BindingModels
|
||||
{
|
||||
public class ShopBindingModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||
|
||||
public Dictionary<int, (IRepairModel, int)> ShopRepairs { get; set; } = new();
|
||||
|
||||
public int RepairsMaxCount { get; set; }
|
||||
}
|
||||
}
|
||||
13
AutoWorkshopContracts/BindingModels/SupplyBindingModel.cs
Normal file
13
AutoWorkshopContracts/BindingModels/SupplyBindingModel.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using AutoWorkshopDataModels.Models;
|
||||
|
||||
namespace AutoWorkshopContracts.BindingModels
|
||||
{
|
||||
public class SupplyBindingModel : ISupplyModel
|
||||
{
|
||||
public int ShopId { get; set; }
|
||||
|
||||
public int RepairId { get; set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
28
AutoWorkshopContracts/BusinessLogicContracts/IReportLogic.cs
Normal file
28
AutoWorkshopContracts/BusinessLogicContracts/IReportLogic.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IReportLogic
|
||||
{
|
||||
List<ReportRepairComponentViewModel> GetRepairComponents();
|
||||
|
||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel Model);
|
||||
|
||||
List<ReportShopsViewModel> GetShops();
|
||||
|
||||
List<ReportGroupedOrdersViewModel> GetGroupedOrders();
|
||||
|
||||
void SaveRepairsToWordFile(ReportBindingModel Model);
|
||||
|
||||
void SaveRepairComponentToExcelFile(ReportBindingModel Model);
|
||||
|
||||
void SaveOrdersToPdfFile(ReportBindingModel Model);
|
||||
|
||||
void SaveShopsToWordFile(ReportBindingModel Model);
|
||||
|
||||
void SaveShopsToExcelFile(ReportBindingModel Model);
|
||||
|
||||
void SaveGroupedOrdersToPdfFile(ReportBindingModel Model);
|
||||
}
|
||||
}
|
||||
23
AutoWorkshopContracts/BusinessLogicContracts/IShopLogic.cs
Normal file
23
AutoWorkshopContracts/BusinessLogicContracts/IShopLogic.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IShopLogic
|
||||
{
|
||||
List<ShopViewModel>? ReadList(ShopSearchModel? Model);
|
||||
|
||||
ShopViewModel? ReadElement(ShopSearchModel Model);
|
||||
|
||||
bool Create(ShopBindingModel Model);
|
||||
|
||||
bool Update(ShopBindingModel Model);
|
||||
|
||||
bool Delete(ShopBindingModel Model);
|
||||
|
||||
bool MakeSupply(SupplyBindingModel Model);
|
||||
|
||||
bool MakeSell(SupplySearchModel Model);
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,9 @@
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public DateTime? DateFrom { get; set; }
|
||||
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
9
AutoWorkshopContracts/SearchModels/ShopSearchModel.cs
Normal file
9
AutoWorkshopContracts/SearchModels/ShopSearchModel.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace AutoWorkshopContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
|
||||
public string? ShopName { get; set; }
|
||||
}
|
||||
}
|
||||
9
AutoWorkshopContracts/SearchModels/SupplySearchModel.cs
Normal file
9
AutoWorkshopContracts/SearchModels/SupplySearchModel.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace AutoWorkshopContracts.SearchModels
|
||||
{
|
||||
public class SupplySearchModel
|
||||
{
|
||||
public int? RepairId { get; set; }
|
||||
|
||||
public int? Count { get; set; }
|
||||
}
|
||||
}
|
||||
25
AutoWorkshopContracts/StoragesContracts/IShopStorage.cs
Normal file
25
AutoWorkshopContracts/StoragesContracts/IShopStorage.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
|
||||
namespace AutoWorkshopContracts.StoragesContracts
|
||||
{
|
||||
public interface IShopStorage
|
||||
{
|
||||
List<ShopViewModel> GetFullList();
|
||||
|
||||
List<ShopViewModel> GetFilteredList(ShopSearchModel Model);
|
||||
|
||||
ShopViewModel? GetElement(ShopSearchModel Model);
|
||||
|
||||
ShopViewModel? Insert(ShopBindingModel Model);
|
||||
|
||||
ShopViewModel? Update(ShopBindingModel Model);
|
||||
|
||||
ShopViewModel? Delete(ShopBindingModel Model);
|
||||
|
||||
bool Sell(SupplySearchModel Model);
|
||||
|
||||
bool RestockingShops(SupplyBindingModel Model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace AutoWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ReportGroupedOrdersViewModel
|
||||
{
|
||||
public DateTime Date { get; set; } = DateTime.Now;
|
||||
|
||||
public int OrdersCount { get; set; }
|
||||
|
||||
public double OrdersSum { get; set; }
|
||||
}
|
||||
}
|
||||
15
AutoWorkshopContracts/ViewModels/ReportOrdersViewModel.cs
Normal file
15
AutoWorkshopContracts/ViewModels/ReportOrdersViewModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace AutoWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ReportOrdersViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public DateTime DateCreate { get; set; }
|
||||
|
||||
public string RepairName { get; set; } = string.Empty;
|
||||
|
||||
public double Sum { get; set; }
|
||||
|
||||
public string Status { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace AutoWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ReportRepairComponentViewModel
|
||||
{
|
||||
public string RepairName { get; set; } = string.Empty;
|
||||
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
public List<(string Component, int Count)> Components { get; set; } = new();
|
||||
}
|
||||
}
|
||||
11
AutoWorkshopContracts/ViewModels/ReportShopsViewModel.cs
Normal file
11
AutoWorkshopContracts/ViewModels/ReportShopsViewModel.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace AutoWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ReportShopsViewModel
|
||||
{
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
public List<(string Repair, int Count)> Repairs { get; set; } = new();
|
||||
}
|
||||
}
|
||||
24
AutoWorkshopContracts/ViewModels/ShopViewModel.cs
Normal file
24
AutoWorkshopContracts/ViewModels/ShopViewModel.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace AutoWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название")]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Адрес")]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime OpeningDate { get; set; }
|
||||
|
||||
public Dictionary<int, (IRepairModel, int)> ShopRepairs { get; set; } = new();
|
||||
|
||||
[DisplayName("Вместимость")]
|
||||
public int RepairsMaxCount { get; set; }
|
||||
}
|
||||
}
|
||||
15
AutoWorkshopDataModels/Models/IShopModel.cs
Normal file
15
AutoWorkshopDataModels/Models/IShopModel.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace AutoWorkshopDataModels.Models
|
||||
{
|
||||
public interface IShopModel : IId
|
||||
{
|
||||
string ShopName { get; }
|
||||
|
||||
string Address { get; }
|
||||
|
||||
DateTime OpeningDate { get; }
|
||||
|
||||
Dictionary<int, (IRepairModel, int)> ShopRepairs { get; }
|
||||
|
||||
int RepairsMaxCount { get; }
|
||||
}
|
||||
}
|
||||
11
AutoWorkshopDataModels/Models/ISupplyModel.cs
Normal file
11
AutoWorkshopDataModels/Models/ISupplyModel.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace AutoWorkshopDataModels.Models
|
||||
{
|
||||
public interface ISupplyModel
|
||||
{
|
||||
int ShopId { get; }
|
||||
|
||||
int RepairId { get; }
|
||||
|
||||
int Count { get; }
|
||||
}
|
||||
}
|
||||
33
AutoWorkshopDatabaseImplement/AutoWorkshopDatabase.cs
Normal file
33
AutoWorkshopDatabaseImplement/AutoWorkshopDatabase.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using AutoWorkshopDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement
|
||||
{
|
||||
public class AutoWorkshopDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder OptionsBuilder)
|
||||
{
|
||||
if (OptionsBuilder.IsConfigured == false)
|
||||
{
|
||||
OptionsBuilder.UseNpgsql(@"Host=localhost;Port=5000;Database=AutoWorkshop_Hard;Username=postgres;Password=admin");
|
||||
}
|
||||
|
||||
base.OnConfiguring(OptionsBuilder);
|
||||
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
}
|
||||
|
||||
public virtual DbSet<Component> Components { set; get; }
|
||||
|
||||
public virtual DbSet<Repair> Repairs { set; get; }
|
||||
|
||||
public virtual DbSet<RepairComponent> RepairComponents { set; get; }
|
||||
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
|
||||
public virtual DbSet<Shop> Shops { get; set; }
|
||||
|
||||
public virtual DbSet<ShopRepair> ShopRepairs { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.17" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.17">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="netcore-psql-util" Version="1.2.1" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AutoWorkshopContracts\AutoWorkshopContracts.csproj" />
|
||||
<ProjectReference Include="..\AutoWorkshopDataModels\AutoWorkshopDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
82
AutoWorkshopDatabaseImplement/Implements/ComponentStorage.cs
Normal file
82
AutoWorkshopDatabaseImplement/Implements/ComponentStorage.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDatabaseImplement.Models;
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Implements
|
||||
{
|
||||
public class ComponentStorage : IComponentStorage
|
||||
{
|
||||
public List<ComponentViewModel> GetFullList()
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
return Context.Components.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ComponentViewModel> GetFilteredList(ComponentSearchModel Model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Model.ComponentName))
|
||||
return new();
|
||||
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
return Context.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;
|
||||
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
return Context.Components
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(Model.ComponentName) && x.ComponentName == Model.ComponentName) ||
|
||||
(Model.Id.HasValue && x.Id == Model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public ComponentViewModel? Insert(ComponentBindingModel Model)
|
||||
{
|
||||
var NewComponent = Component.Create(Model);
|
||||
|
||||
if (NewComponent == null)
|
||||
return null;
|
||||
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
Context.Components.Add(NewComponent);
|
||||
Context.SaveChanges();
|
||||
|
||||
return NewComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public ComponentViewModel? Update(ComponentBindingModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
var Component = Context.Components.FirstOrDefault(x => x.Id == Model.Id);
|
||||
|
||||
if (Component == null)
|
||||
return null;
|
||||
|
||||
Component.Update(Model);
|
||||
Context.SaveChanges();
|
||||
|
||||
return Component.GetViewModel;
|
||||
}
|
||||
|
||||
public ComponentViewModel? Delete(ComponentBindingModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
var Component = Context.Components.FirstOrDefault(rec => rec.Id == Model.Id);
|
||||
|
||||
if (Component == null)
|
||||
return null;
|
||||
|
||||
Context.Components.Remove(Component);
|
||||
Context.SaveChanges();
|
||||
return Component.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
104
AutoWorkshopDatabaseImplement/Implements/OrderStorage.cs
Normal file
104
AutoWorkshopDatabaseImplement/Implements/OrderStorage.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
return Context.Orders
|
||||
.Include(x => x.Repair)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel Model)
|
||||
{
|
||||
if (!Model.Id.HasValue && (!Model.DateFrom.HasValue || !Model.DateTo.HasValue))
|
||||
return new();
|
||||
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
if (Model.DateFrom.HasValue)
|
||||
{
|
||||
return Context.Orders
|
||||
.Include(x => x.Repair)
|
||||
.Where(x => x.DateCreate >= Model.DateFrom && x.DateCreate <= Model.DateTo)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return Context.Orders
|
||||
.Include(x => x.Repair)
|
||||
.Where(x => x.Id == Model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel Model)
|
||||
{
|
||||
if (!Model.Id.HasValue)
|
||||
return null;
|
||||
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
return Context.Orders
|
||||
.Include(x => x.Repair)
|
||||
.FirstOrDefault(x => Model.Id.HasValue && x.Id == Model.Id)?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel Model)
|
||||
{
|
||||
if (Model == null)
|
||||
return null;
|
||||
|
||||
var NewOrder = Order.Create(Model);
|
||||
if (NewOrder == null)
|
||||
return null;
|
||||
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
Context.Orders.Add(NewOrder);
|
||||
Context.SaveChanges();
|
||||
|
||||
return Context.Orders.Include(x => x.Repair).FirstOrDefault(x => x.Id == NewOrder.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
var Order = Context.Orders.FirstOrDefault(x => x.Id == Model.Id);
|
||||
if (Order == null)
|
||||
return null;
|
||||
|
||||
Order.Update(Model);
|
||||
Context.SaveChanges();
|
||||
|
||||
return Context.Orders.Include(x => x.Repair).FirstOrDefault(x => x.Id == Model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
var Order = Context.Orders.FirstOrDefault(rec => rec.Id == Model.Id);
|
||||
|
||||
if (Order == null)
|
||||
return null;
|
||||
|
||||
Context.Orders.Remove(Order);
|
||||
Context.SaveChanges();
|
||||
|
||||
return Order.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
109
AutoWorkshopDatabaseImplement/Implements/RepairStorage.cs
Normal file
109
AutoWorkshopDatabaseImplement/Implements/RepairStorage.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Implements
|
||||
{
|
||||
public class RepairStorage : IRepairStorage
|
||||
{
|
||||
public List<RepairViewModel> GetFullList()
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
return Context.Repairs
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<RepairViewModel> GetFilteredList(RepairSearchModel Model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Model.RepairName))
|
||||
return new();
|
||||
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
return Context.Repairs
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.Where(x => x.RepairName.Contains(Model.RepairName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public RepairViewModel? GetElement(RepairSearchModel Model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Model.RepairName) && !Model.Id.HasValue)
|
||||
return null;
|
||||
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
return Context.Repairs
|
||||
.Include(x => x.Components)
|
||||
.ThenInclude(x => x.Component)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(Model.RepairName) && x.RepairName == Model.RepairName) ||
|
||||
(Model.Id.HasValue && x.Id == Model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public RepairViewModel? Insert(RepairBindingModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
var NewRepair = Repair.Create(Context, Model);
|
||||
if (NewRepair == null)
|
||||
return null;
|
||||
|
||||
Context.Repairs.Add(NewRepair);
|
||||
Context.SaveChanges();
|
||||
|
||||
return NewRepair.GetViewModel;
|
||||
}
|
||||
|
||||
public RepairViewModel? Update(RepairBindingModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
using var Transaction = Context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var Repair = Context.Repairs.FirstOrDefault(rec => rec.Id == Model.Id);
|
||||
|
||||
if (Repair == null)
|
||||
return null;
|
||||
|
||||
Repair.Update(Model);
|
||||
Context.SaveChanges();
|
||||
Repair.UpdateComponents(Context, Model);
|
||||
|
||||
Transaction.Commit();
|
||||
return Repair.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public RepairViewModel? Delete(RepairBindingModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
var Repair = Context.Repairs
|
||||
.Include(x => x.Components)
|
||||
.FirstOrDefault(rec => rec.Id == Model.Id);
|
||||
|
||||
if (Repair == null)
|
||||
return null;
|
||||
|
||||
Context.Repairs.Remove(Repair);
|
||||
Context.SaveChanges();
|
||||
return Repair.GetViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
221
AutoWorkshopDatabaseImplement/Implements/ShopStorage.cs
Normal file
221
AutoWorkshopDatabaseImplement/Implements/ShopStorage.cs
Normal file
@@ -0,0 +1,221 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
return Context.Shops
|
||||
.Include(x => x.Repairs)
|
||||
.ThenInclude(x => x.Repair)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel Model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Model.ShopName))
|
||||
return new();
|
||||
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
return Context.Shops
|
||||
.Include(x => x.Repairs)
|
||||
.ThenInclude(x => x.Repair)
|
||||
.Where(x => x.ShopName.Contains(Model.ShopName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ShopViewModel? GetElement(ShopSearchModel Model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Model.ShopName) && !Model.Id.HasValue)
|
||||
return new();
|
||||
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
return Context.Shops
|
||||
.Include(x => x.Repairs)
|
||||
.ThenInclude(x => x.Repair)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(Model.ShopName) && x.ShopName == Model.ShopName) ||
|
||||
(Model.Id.HasValue && x.Id == Model.Id))?
|
||||
.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Insert(ShopBindingModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
var NewShop = Shop.Create(Context, Model);
|
||||
if (NewShop == null)
|
||||
return null;
|
||||
|
||||
Context.Shops.Add(NewShop);
|
||||
Context.SaveChanges();
|
||||
|
||||
return NewShop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
using var Transaction = Context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var Shop = Context.Shops.FirstOrDefault(x => x.Id == Model.Id);
|
||||
|
||||
if (Shop == null)
|
||||
return null;
|
||||
|
||||
Shop.Update(Model);
|
||||
Context.SaveChanges();
|
||||
Shop.UpdateRepairs(Context, Model);
|
||||
|
||||
Transaction.Commit();
|
||||
return Shop.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public ShopViewModel? Delete(ShopBindingModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
|
||||
var Shop = Context.Shops
|
||||
.Include(x => x.Repairs)
|
||||
.FirstOrDefault(x => x.Id == Model.Id);
|
||||
|
||||
if (Shop == null)
|
||||
return null;
|
||||
|
||||
Context.Shops.Remove(Shop);
|
||||
Context.SaveChanges();
|
||||
|
||||
return Shop.GetViewModel;
|
||||
}
|
||||
|
||||
public bool Sell(SupplySearchModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
var Transaction = Context.Database.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
var ShopsWithDesiredRepair = Context.Shops
|
||||
.Include(x => x.Repairs)
|
||||
.ThenInclude(x => x.Repair)
|
||||
.ToList()
|
||||
.Where(x => x.ShopRepairs.ContainsKey(Model.RepairId.Value))
|
||||
.OrderByDescending(x => x.ShopRepairs[Model.RepairId.Value].Item2)
|
||||
.ToList();
|
||||
|
||||
foreach (var Shop in ShopsWithDesiredRepair)
|
||||
{
|
||||
int Slack = Model.Count.Value - Shop.ShopRepairs[Model.RepairId.Value].Item2;
|
||||
|
||||
if (Slack > 0)
|
||||
{
|
||||
Shop.ShopRepairs.Remove(Model.RepairId.Value);
|
||||
Shop.RepairsDictionatyUpdate(Context);
|
||||
Context.SaveChanges();
|
||||
|
||||
Model.Count = Slack;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Slack == 0)
|
||||
{
|
||||
Shop.ShopRepairs.Remove(Model.RepairId.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
var RepairAndCount = Shop.ShopRepairs[Model.RepairId.Value];
|
||||
RepairAndCount.Item2 = -Slack;
|
||||
Shop.ShopRepairs[Model.RepairId.Value] = RepairAndCount;
|
||||
}
|
||||
|
||||
Shop.RepairsDictionatyUpdate(Context);
|
||||
Transaction.Commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public bool RestockingShops(SupplyBindingModel Model)
|
||||
{
|
||||
using var Context = new AutoWorkshopDatabase();
|
||||
var Transaction = Context.Database.BeginTransaction();
|
||||
|
||||
var Shops = Context.Shops
|
||||
.Include(x => x.Repairs)
|
||||
.ThenInclude(x => x.Repair)
|
||||
.ToList()
|
||||
.Where(x => x.RepairsMaxCount > x.ShopRepairs
|
||||
.Select(x => x.Value.Item2).Sum())
|
||||
.ToList();
|
||||
|
||||
try
|
||||
{
|
||||
foreach (Shop Shop in Shops)
|
||||
{
|
||||
int FreeSpaceNum = Shop.RepairsMaxCount - Shop.ShopRepairs.Select(x => x.Value.Item2).Sum();
|
||||
|
||||
int Refill = Math.Min(FreeSpaceNum, Model.Count);
|
||||
Model.Count -= Refill;
|
||||
|
||||
if (Shop.ShopRepairs.ContainsKey(Model.RepairId))
|
||||
{
|
||||
var RepairAndCount = Shop.ShopRepairs[Model.RepairId];
|
||||
RepairAndCount.Item2 += Refill;
|
||||
Shop.ShopRepairs[Model.RepairId] = RepairAndCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
var Repair = Context.Repairs.First(x => x.Id == Model.RepairId);
|
||||
Shop.ShopRepairs.Add(Model.RepairId, (Repair, Refill));
|
||||
}
|
||||
|
||||
Shop.RepairsDictionatyUpdate(Context);
|
||||
|
||||
if (Model.Count == 0)
|
||||
{
|
||||
Transaction.Commit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Transaction.Rollback();
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
248
AutoWorkshopDatabaseImplement/Migrations/20240417061857_Shops.Designer.cs
generated
Normal file
248
AutoWorkshopDatabaseImplement/Migrations/20240417061857_Shops.Designer.cs
generated
Normal file
@@ -0,0 +1,248 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AutoWorkshopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AutoWorkshopDatabase))]
|
||||
[Migration("20240417061857_Shops")]
|
||||
partial class Shops
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.17")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("RepairId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RepairId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Repair", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("RepairName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Repairs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.RepairComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RepairId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("RepairId");
|
||||
|
||||
b.ToTable("RepairComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("OpeningDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("RepairsMaxCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.ShopRepair", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RepairId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RepairId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopRepairs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Repair", "Repair")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("RepairId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Repair");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.RepairComponent", b =>
|
||||
{
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("RepairComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Repair", "Repair")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("RepairId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Repair");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.ShopRepair", b =>
|
||||
{
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Repair", "Repair")
|
||||
.WithMany()
|
||||
.HasForeignKey("RepairId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Repairs")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Repair");
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("RepairComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Repair", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Repairs");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
185
AutoWorkshopDatabaseImplement/Migrations/20240417061857_Shops.cs
Normal file
185
AutoWorkshopDatabaseImplement/Migrations/20240417061857_Shops.cs
Normal file
@@ -0,0 +1,185 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Shops : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ComponentName = table.Column<string>(type: "text", nullable: false),
|
||||
Cost = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Repairs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
RepairName = table.Column<string>(type: "text", nullable: false),
|
||||
Price = table.Column<double>(type: "double precision", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Repairs", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Shops",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ShopName = table.Column<string>(type: "text", nullable: false),
|
||||
Address = table.Column<string>(type: "text", nullable: false),
|
||||
OpeningDate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
RepairsMaxCount = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
RepairId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false),
|
||||
Sum = table.Column<double>(type: "double precision", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "timestamp without time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Orders_Repairs_RepairId",
|
||||
column: x => x.RepairId,
|
||||
principalTable: "Repairs",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "RepairComponents",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
RepairId = table.Column<int>(type: "integer", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_RepairComponents", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_RepairComponents_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_RepairComponents_Repairs_RepairId",
|
||||
column: x => x.RepairId,
|
||||
principalTable: "Repairs",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ShopRepairs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
RepairId = table.Column<int>(type: "integer", nullable: false),
|
||||
ShopId = table.Column<int>(type: "integer", nullable: false),
|
||||
Count = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ShopRepairs", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopRepairs_Repairs_RepairId",
|
||||
column: x => x.RepairId,
|
||||
principalTable: "Repairs",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopRepairs_Shops_ShopId",
|
||||
column: x => x.ShopId,
|
||||
principalTable: "Shops",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_RepairId",
|
||||
table: "Orders",
|
||||
column: "RepairId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RepairComponents_ComponentId",
|
||||
table: "RepairComponents",
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_RepairComponents_RepairId",
|
||||
table: "RepairComponents",
|
||||
column: "RepairId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopRepairs_RepairId",
|
||||
table: "ShopRepairs",
|
||||
column: "RepairId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopRepairs_ShopId",
|
||||
table: "ShopRepairs",
|
||||
column: "ShopId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "RepairComponents");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ShopRepairs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Repairs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Shops");
|
||||
}
|
||||
}
|
||||
}
|
||||
250
AutoWorkshopDatabaseImplement/Migrations/20240505173724_Fix Shop-Repair relationship.Designer.cs
generated
Normal file
250
AutoWorkshopDatabaseImplement/Migrations/20240505173724_Fix Shop-Repair relationship.Designer.cs
generated
Normal file
@@ -0,0 +1,250 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AutoWorkshopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AutoWorkshopDatabase))]
|
||||
[Migration("20240505173724_Fix Shop-Repair relationship")]
|
||||
partial class FixShopRepairrelationship
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.17")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("RepairId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RepairId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Repair", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("RepairName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Repairs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.RepairComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RepairId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("RepairId");
|
||||
|
||||
b.ToTable("RepairComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("OpeningDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("RepairsMaxCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.ShopRepair", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RepairId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RepairId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopRepairs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Repair", "Repair")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("RepairId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Repair");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.RepairComponent", b =>
|
||||
{
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("RepairComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Repair", "Repair")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("RepairId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Repair");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.ShopRepair", b =>
|
||||
{
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Repair", "Repair")
|
||||
.WithMany("Shops")
|
||||
.HasForeignKey("RepairId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Repairs")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Repair");
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("RepairComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Repair", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Repairs");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class FixShopRepairrelationship : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using AutoWorkshopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(AutoWorkshopDatabase))]
|
||||
partial class AutoWorkshopDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.17")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("RepairId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RepairId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Repair", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("double precision");
|
||||
|
||||
b.Property<string>("RepairName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Repairs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.RepairComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RepairId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("RepairId");
|
||||
|
||||
b.ToTable("RepairComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.Property<DateTime>("OpeningDate")
|
||||
.HasColumnType("timestamp without time zone");
|
||||
|
||||
b.Property<int>("RepairsMaxCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("text");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.ShopRepair", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("RepairId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ShopId")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("RepairId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopRepairs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Repair", "Repair")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("RepairId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Repair");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.RepairComponent", b =>
|
||||
{
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("RepairComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Repair", "Repair")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("RepairId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Repair");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.ShopRepair", b =>
|
||||
{
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Repair", "Repair")
|
||||
.WithMany("Shops")
|
||||
.HasForeignKey("RepairId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("AutoWorkshopDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Repairs")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Repair");
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("RepairComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Repair", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("AutoWorkshopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Repairs");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
61
AutoWorkshopDatabaseImplement/Models/Component.cs
Normal file
61
AutoWorkshopDatabaseImplement/Models/Component.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Models
|
||||
{
|
||||
public class Component : IComponentModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<RepairComponent> RepairComponents { get; set; } = new();
|
||||
|
||||
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(ComponentViewModel Model)
|
||||
{
|
||||
return new Component
|
||||
{
|
||||
Id = Model.Id,
|
||||
ComponentName = Model.ComponentName,
|
||||
Cost = Model.Cost
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
70
AutoWorkshopDatabaseImplement/Models/Order.cs
Normal file
70
AutoWorkshopDatabaseImplement/Models/Order.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDataModels.Enums;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int RepairId { get; private set; }
|
||||
|
||||
public virtual Repair Repair { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
|
||||
[Required]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Undefined;
|
||||
|
||||
[Required]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel Model)
|
||||
{
|
||||
if (Model is null)
|
||||
return null;
|
||||
|
||||
return new Order()
|
||||
{
|
||||
Id = Model.Id,
|
||||
RepairId = Model.RepairId,
|
||||
Count = Model.Count,
|
||||
Sum = Model.Sum,
|
||||
Status = Model.Status,
|
||||
DateCreate = Model.DateCreate,
|
||||
DateImplement = Model.DateImplement,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(OrderBindingModel Model)
|
||||
{
|
||||
if (Model is null)
|
||||
return;
|
||||
|
||||
Status = Model.Status;
|
||||
DateImplement = Model.DateImplement;
|
||||
}
|
||||
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
RepairId = RepairId,
|
||||
RepairName = Repair.RepairName,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
Status = Status,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
};
|
||||
}
|
||||
}
|
||||
109
AutoWorkshopDatabaseImplement/Models/Repair.cs
Normal file
109
AutoWorkshopDatabaseImplement/Models/Repair.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Models
|
||||
{
|
||||
public class Repair : IRepairModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string RepairName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public double Price { get; set; }
|
||||
|
||||
private Dictionary<int, (IComponentModel, int)>? _repairComponents = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IComponentModel, int)> RepairComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_repairComponents == null)
|
||||
{
|
||||
_repairComponents = Components.ToDictionary(RepComp => RepComp.ComponentId, RepComp =>
|
||||
(RepComp.Component as IComponentModel, RepComp.Count));
|
||||
}
|
||||
|
||||
return _repairComponents;
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("RepairId")]
|
||||
public virtual List<RepairComponent> Components { get; set; } = new();
|
||||
|
||||
[ForeignKey("RepairId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
|
||||
[ForeignKey("RepairId")]
|
||||
public virtual List<ShopRepair> Shops { get; set; } = new();
|
||||
|
||||
public static Repair Create(AutoWorkshopDatabase Context, RepairBindingModel Model)
|
||||
{
|
||||
return new Repair()
|
||||
{
|
||||
Id = Model.Id,
|
||||
RepairName = Model.RepairName,
|
||||
Price = Model.Price,
|
||||
Components = Model.RepairComponents.Select(x => new RepairComponent
|
||||
{
|
||||
Component = Context.Components.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(RepairBindingModel Model)
|
||||
{
|
||||
RepairName = Model.RepairName;
|
||||
Price = Model.Price;
|
||||
}
|
||||
|
||||
public RepairViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
RepairName = RepairName,
|
||||
Price = Price,
|
||||
RepairComponents = RepairComponents
|
||||
};
|
||||
|
||||
public void UpdateComponents(AutoWorkshopDatabase Context, RepairBindingModel Model)
|
||||
{
|
||||
var RepairComponents = Context.RepairComponents.Where(rec => rec.RepairId == Model.Id).ToList();
|
||||
|
||||
if (RepairComponents != null && RepairComponents.Count > 0)
|
||||
{
|
||||
Context.RepairComponents.RemoveRange(RepairComponents.Where(rec => !Model.RepairComponents.ContainsKey(rec.ComponentId)));
|
||||
Context.SaveChanges();
|
||||
|
||||
foreach (var ComponentToUpdate in RepairComponents)
|
||||
{
|
||||
ComponentToUpdate.Count = Model.RepairComponents[ComponentToUpdate.ComponentId].Item2;
|
||||
Model.RepairComponents.Remove(ComponentToUpdate.ComponentId);
|
||||
}
|
||||
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
var Repair = Context.Repairs.First(x => x.Id == Id);
|
||||
|
||||
foreach (var RepairComponent in Model.RepairComponents)
|
||||
{
|
||||
Context.RepairComponents.Add(new RepairComponent
|
||||
{
|
||||
Repair = Repair,
|
||||
Component = Context.Components.First(x => x.Id == RepairComponent.Key),
|
||||
Count = RepairComponent.Value.Item2
|
||||
});
|
||||
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
_repairComponents = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
AutoWorkshopDatabaseImplement/Models/RepairComponent.cs
Normal file
22
AutoWorkshopDatabaseImplement/Models/RepairComponent.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Models
|
||||
{
|
||||
public class RepairComponent
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int RepairId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ComponentId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Component Component { get; set; } = new();
|
||||
|
||||
public virtual Repair Repair { get; set; } = new();
|
||||
}
|
||||
}
|
||||
131
AutoWorkshopDatabaseImplement/Models/Shop.cs
Normal file
131
AutoWorkshopDatabaseImplement/Models/Shop.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public DateTime OpeningDate { get; set; }
|
||||
|
||||
[Required]
|
||||
public int RepairsMaxCount { get; set; }
|
||||
|
||||
[ForeignKey("ShopId")]
|
||||
public List<ShopRepair> Repairs { get; set; } = new();
|
||||
|
||||
private Dictionary<int, (IRepairModel, int)>? _shopRepairs = null;
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IRepairModel, int)> ShopRepairs
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_shopRepairs == null)
|
||||
{
|
||||
if (_shopRepairs == null)
|
||||
{
|
||||
_shopRepairs = Repairs.ToDictionary(ShopRep => ShopRep.RepairId, ShopRep => (ShopRep.Repair as IRepairModel, ShopRep.Count));
|
||||
}
|
||||
return _shopRepairs;
|
||||
}
|
||||
|
||||
return _shopRepairs;
|
||||
}
|
||||
}
|
||||
|
||||
public static Shop Create(AutoWorkshopDatabase Context, ShopBindingModel Model)
|
||||
{
|
||||
return new Shop()
|
||||
{
|
||||
Id = Model.Id,
|
||||
ShopName = Model.ShopName,
|
||||
Address = Model.Address,
|
||||
OpeningDate = Model.OpeningDate,
|
||||
Repairs = Model.ShopRepairs.Select(x => new ShopRepair
|
||||
{
|
||||
Repair = Context.Repairs.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList(),
|
||||
RepairsMaxCount = Model.RepairsMaxCount
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel Model)
|
||||
{
|
||||
ShopName = Model.ShopName;
|
||||
Address = Model.Address;
|
||||
OpeningDate = Model.OpeningDate;
|
||||
RepairsMaxCount = Model.RepairsMaxCount;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
OpeningDate = OpeningDate,
|
||||
ShopRepairs = ShopRepairs,
|
||||
RepairsMaxCount = RepairsMaxCount
|
||||
};
|
||||
|
||||
public void UpdateRepairs(AutoWorkshopDatabase Context, ShopBindingModel Model)
|
||||
{
|
||||
var ShopRepairs = Context.ShopRepairs
|
||||
.Where(rec => rec.ShopId == Model.Id)
|
||||
.ToList();
|
||||
|
||||
if (ShopRepairs != null && ShopRepairs.Count > 0)
|
||||
{
|
||||
Context.ShopRepairs.RemoveRange(ShopRepairs.Where(rec => !Model.ShopRepairs.ContainsKey(rec.RepairId)));
|
||||
Context.SaveChanges();
|
||||
|
||||
ShopRepairs = Context.ShopRepairs.Where(rec => rec.ShopId == Model.Id).ToList();
|
||||
|
||||
foreach (var RepairToUpdate in ShopRepairs)
|
||||
{
|
||||
RepairToUpdate.Count = Model.ShopRepairs[RepairToUpdate.RepairId].Item2;
|
||||
Model.ShopRepairs.Remove(RepairToUpdate.RepairId);
|
||||
}
|
||||
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
var Shop = Context.Shops.First(x => x.Id == Id);
|
||||
|
||||
foreach (var ShopRepair in Model.ShopRepairs)
|
||||
{
|
||||
Context.ShopRepairs.Add(new ShopRepair
|
||||
{
|
||||
Shop = Shop,
|
||||
Repair = Context.Repairs.First(x => x.Id == ShopRepair.Key),
|
||||
Count = ShopRepair.Value.Item2
|
||||
});
|
||||
|
||||
Context.SaveChanges();
|
||||
}
|
||||
|
||||
_shopRepairs = null;
|
||||
}
|
||||
|
||||
public void RepairsDictionatyUpdate(AutoWorkshopDatabase Context)
|
||||
{
|
||||
UpdateRepairs(Context, new ShopBindingModel
|
||||
{
|
||||
Id = Id,
|
||||
ShopRepairs = ShopRepairs
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
22
AutoWorkshopDatabaseImplement/Models/ShopRepair.cs
Normal file
22
AutoWorkshopDatabaseImplement/Models/ShopRepair.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace AutoWorkshopDatabaseImplement.Models
|
||||
{
|
||||
public class ShopRepair
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int RepairId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ShopId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Shop Shop { get; set; } = new();
|
||||
|
||||
public virtual Repair Repair { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@@ -10,18 +10,19 @@ namespace AutoWorkshopFileImplement
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string RepairFileName = "Repair.xml";
|
||||
|
||||
public List<Component> Components { get; private set; }
|
||||
|
||||
public List<Order> Orders { get; private set; }
|
||||
|
||||
private readonly string ShopFileName = "Shop.xml";
|
||||
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Repair> Repairs { get; private set; }
|
||||
|
||||
public List<Shop> Shops { get; private set; }
|
||||
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Repairs = LoadData(RepairFileName, "Repair", x => Repair.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||
}
|
||||
|
||||
public static DataFileSingleton GetInstance()
|
||||
@@ -37,6 +38,7 @@ namespace AutoWorkshopFileImplement
|
||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||
public void SaveRepairs() => SaveData(Repairs, RepairFileName, "Repairs", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||
|
||||
private static List<T>? LoadData<T>(string FileName, string XmlNodeName, Func<XElement, T> SelectFunction)
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopFileImplement.Models;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AutoWorkshopFileImplement.Implements
|
||||
{
|
||||
@@ -23,10 +22,13 @@ namespace AutoWorkshopFileImplement.Implements
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel Model)
|
||||
{
|
||||
if (!Model.Id.HasValue)
|
||||
if (!Model.Id.HasValue && (!Model.DateFrom.HasValue || !Model.DateTo.HasValue))
|
||||
return new();
|
||||
|
||||
return _source.Orders.Where(x => x.Id == Model.Id).Select(x => AddRepairName(x.GetViewModel)).ToList();
|
||||
return _source.Orders
|
||||
.Where(x => x.DateCreate >= Model.DateFrom && x.DateCreate <= Model.DateTo)
|
||||
.Select(x => AddRepairName(x.GetViewModel))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel Model)
|
||||
|
||||
168
AutoWorkshopFileImplement/Implements/ShopStorage.cs
Normal file
168
AutoWorkshopFileImplement/Implements/ShopStorage.cs
Normal file
@@ -0,0 +1,168 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopFileImplement.Models;
|
||||
|
||||
namespace AutoWorkshopFileImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataFileSingleton _source;
|
||||
|
||||
public ShopStorage()
|
||||
{
|
||||
_source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
return _source.Shops.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
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 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)
|
||||
return null;
|
||||
|
||||
_source.Shops.Remove(Shop);
|
||||
_source.SaveShops();
|
||||
|
||||
return Shop.GetViewModel;
|
||||
}
|
||||
|
||||
public bool Sell(SupplySearchModel Model)
|
||||
{
|
||||
if (Model == null || !Model.RepairId.HasValue || !Model.Count.HasValue)
|
||||
return false;
|
||||
|
||||
int TotalRepairsNum = _source.Shops
|
||||
.Select(x => x.Repairs.ContainsKey(Model.RepairId.Value) ? x.Repairs[Model.RepairId.Value] : 0)
|
||||
.Sum();
|
||||
if (TotalRepairsNum < Model.Count)
|
||||
return false;
|
||||
|
||||
var ShopsWithDesiredRepair = _source.Shops
|
||||
.Where(x => x.Repairs.ContainsKey(Model.RepairId.Value))
|
||||
.OrderByDescending(x => x.Repairs[Model.RepairId.Value])
|
||||
.ToList();
|
||||
|
||||
foreach (var Shop in ShopsWithDesiredRepair)
|
||||
{
|
||||
int Slack = Model.Count.Value - Shop.Repairs[Model.RepairId.Value];
|
||||
|
||||
if (Slack > 0)
|
||||
{
|
||||
Shop.Repairs.Remove(Model.RepairId.Value);
|
||||
Shop.RepairsUpdate();
|
||||
|
||||
Model.Count = Slack;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Slack == 0)
|
||||
Shop.Repairs.Remove(Model.RepairId.Value);
|
||||
else
|
||||
Shop.Repairs[Model.RepairId.Value] = -Slack;
|
||||
|
||||
Shop.RepairsUpdate();
|
||||
_source.SaveShops();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
_source.SaveShops();
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool RestockingShops(SupplyBindingModel Model)
|
||||
{
|
||||
int TotalFreeSpaceNum = _source.Shops
|
||||
.Select(x => x.RepairsMaxCount - x.ShopRepairs
|
||||
.Select(y => y.Value.Item2)
|
||||
.Sum())
|
||||
.Sum();
|
||||
|
||||
if (TotalFreeSpaceNum < Model.Count)
|
||||
return false;
|
||||
|
||||
foreach (Shop Shop in _source.Shops)
|
||||
{
|
||||
int FreeSpaceNum = Shop.RepairsMaxCount - Shop.ShopRepairs.Select(x => x.Value.Item2).Sum();
|
||||
|
||||
if (FreeSpaceNum <= 0)
|
||||
continue;
|
||||
|
||||
FreeSpaceNum = Math.Min(FreeSpaceNum, Model.Count);
|
||||
Model.Count -= FreeSpaceNum;
|
||||
|
||||
if (Shop.Repairs.ContainsKey(Model.RepairId))
|
||||
Shop.Repairs[Model.RepairId] += FreeSpaceNum;
|
||||
else
|
||||
Shop.Repairs.Add(Model.RepairId, FreeSpaceNum);
|
||||
|
||||
Shop.RepairsUpdate();
|
||||
|
||||
if (Model.Count == 0)
|
||||
{
|
||||
_source.SaveShops();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
110
AutoWorkshopFileImplement/Models/Shop.cs
Normal file
110
AutoWorkshopFileImplement/Models/Shop.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace AutoWorkshopFileImplement.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 OpeningDate { get; private set; }
|
||||
|
||||
public Dictionary<int, int> Repairs { get; private set; } = new();
|
||||
|
||||
private Dictionary<int, (IRepairModel, int)>? _shopRepairs = null;
|
||||
|
||||
public Dictionary<int, (IRepairModel, int)> ShopRepairs
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_shopRepairs == null)
|
||||
{
|
||||
var Source = DataFileSingleton.GetInstance();
|
||||
_shopRepairs = Repairs.ToDictionary(x => x.Key, y => ((Source.Repairs.FirstOrDefault(z => z.Id == y.Key) as IRepairModel)!, y.Value));
|
||||
}
|
||||
|
||||
return _shopRepairs;
|
||||
}
|
||||
}
|
||||
|
||||
public int RepairsMaxCount { get; private set; }
|
||||
|
||||
public static Shop? Create(ShopBindingModel? Model)
|
||||
{
|
||||
if (Model == null)
|
||||
return null;
|
||||
|
||||
return new Shop()
|
||||
{
|
||||
Id = Model.Id,
|
||||
ShopName = Model.ShopName,
|
||||
Address = Model.Address,
|
||||
OpeningDate = Model.OpeningDate,
|
||||
Repairs = Model.ShopRepairs.ToDictionary(x => x.Key, x => x.Value.Item2),
|
||||
RepairsMaxCount = Model.RepairsMaxCount
|
||||
};
|
||||
}
|
||||
|
||||
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,
|
||||
OpeningDate = Convert.ToDateTime(Element.Element("OpeningDate")!.Value),
|
||||
Repairs = Element.Element("ShopRepairs")!.Elements("ShopRepair")!.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||
x => Convert.ToInt32(x.Element("Value")?.Value)),
|
||||
RepairsMaxCount = Convert.ToInt32(Element.Element("RepairsMaxCount")!.Value)
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel? Model)
|
||||
{
|
||||
if (Model == null)
|
||||
return;
|
||||
|
||||
ShopName = Model.ShopName;
|
||||
Address = Model.Address;
|
||||
OpeningDate = Model.OpeningDate;
|
||||
RepairsMaxCount = Model.RepairsMaxCount;
|
||||
Repairs = Model.ShopRepairs.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
_shopRepairs = null;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
OpeningDate = OpeningDate,
|
||||
ShopRepairs = ShopRepairs,
|
||||
RepairsMaxCount = RepairsMaxCount
|
||||
};
|
||||
|
||||
public XElement GetXElement => new(
|
||||
"Shop",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ShopName", ShopName),
|
||||
new XElement("Address", Address),
|
||||
new XElement("OpeningDate", OpeningDate.ToString()),
|
||||
new XElement("ShopRepairs", Repairs.Select(
|
||||
x => new XElement("ShopRepair", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray()),
|
||||
new XElement("RepairsMaxCount", RepairsMaxCount.ToString())
|
||||
);
|
||||
|
||||
public void RepairsUpdate()
|
||||
{
|
||||
_shopRepairs = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,12 +11,15 @@ namespace AutoWorkshopListImplement
|
||||
public List<Order> Orders { get; set; }
|
||||
|
||||
public List<Repair> Repairs { get; set; }
|
||||
|
||||
public List<Shop> Shops { get; set; }
|
||||
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Repairs = new List<Repair>();
|
||||
Shops = new List<Shop>();
|
||||
}
|
||||
|
||||
public static DataListSingleton GetInstance()
|
||||
|
||||
@@ -3,6 +3,7 @@ using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopListImplement.Models;
|
||||
using System.Reflection;
|
||||
|
||||
namespace AutoWorkshopListImplement.Implements
|
||||
{
|
||||
@@ -31,12 +32,12 @@ namespace AutoWorkshopListImplement.Implements
|
||||
{
|
||||
var Result = new List<OrderViewModel>();
|
||||
|
||||
if (!Model.Id.HasValue)
|
||||
if (!Model.Id.HasValue && (!Model.DateFrom.HasValue || !Model.DateTo.HasValue))
|
||||
return Result;
|
||||
|
||||
foreach (var Order in _source.Orders)
|
||||
{
|
||||
if (Order.Id == Model.Id)
|
||||
if (Order.DateCreate >= Model.DateFrom && Order.DateCreate <= Model.DateTo)
|
||||
{
|
||||
Result.Add(JoinRepairName(Order.GetViewModel));
|
||||
break;
|
||||
|
||||
122
AutoWorkshopImplement/Implements/ShopStorage.cs
Normal file
122
AutoWorkshopImplement/Implements/ShopStorage.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopListImplement.Models;
|
||||
|
||||
namespace AutoWorkshopListImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
|
||||
public ShopStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
var Result = new List<ShopViewModel>();
|
||||
|
||||
foreach (var Shop in _source.Shops)
|
||||
{
|
||||
Result.Add(Shop.GetViewModel);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel Model)
|
||||
{
|
||||
var Result = new List<ShopViewModel>();
|
||||
|
||||
if (string.IsNullOrEmpty(Model.ShopName))
|
||||
return Result;
|
||||
|
||||
foreach (var Shop in _source.Shops)
|
||||
{
|
||||
if (Shop.ShopName.Contains(Model.ShopName))
|
||||
Result.Add(Shop.GetViewModel);
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
public ShopViewModel? GetElement(ShopSearchModel Model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Model.ShopName) && !Model.Id.HasValue)
|
||||
return null;
|
||||
|
||||
foreach (var Shop in _source.Shops)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(Model.ShopName) && Shop.ShopName == Model.ShopName) ||
|
||||
(Model.Id.HasValue && Shop.Id == Model.Id))
|
||||
{
|
||||
return Shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ShopViewModel? Insert(ShopBindingModel Model)
|
||||
{
|
||||
Model.Id = 1;
|
||||
|
||||
foreach (var Shop in _source.Shops)
|
||||
{
|
||||
if (Model.Id <= Shop.Id)
|
||||
Model.Id = Shop.Id + 1;
|
||||
}
|
||||
|
||||
var NewShop = Shop.Create(Model);
|
||||
|
||||
if (NewShop is null)
|
||||
return null;
|
||||
|
||||
_source.Shops.Add(NewShop);
|
||||
return NewShop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel Model)
|
||||
{
|
||||
foreach (var Shop in _source.Shops)
|
||||
{
|
||||
if (Shop.Id == Model.Id)
|
||||
{
|
||||
Shop.Update(Model);
|
||||
return Shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ShopViewModel? Delete(ShopBindingModel Model)
|
||||
{
|
||||
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||
{
|
||||
if (_source.Shops[i].Id == Model.Id)
|
||||
{
|
||||
var Shop = _source.Shops[i];
|
||||
_source.Shops.RemoveAt(i);
|
||||
|
||||
return Shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Sell(SupplySearchModel Model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool RestockingShops(SupplyBindingModel Model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
57
AutoWorkshopImplement/Models/Shop.cs
Normal file
57
AutoWorkshopImplement/Models/Shop.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
|
||||
namespace AutoWorkshopListImplement.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 OpeningDate { get; private set; }
|
||||
|
||||
public Dictionary<int, (IRepairModel, int)> ShopRepairs { get; private set; } = new();
|
||||
|
||||
public int RepairsMaxCount { get; private set; }
|
||||
|
||||
public static Shop? Create(ShopBindingModel? Model)
|
||||
{
|
||||
if (Model is null)
|
||||
return null;
|
||||
|
||||
return new Shop()
|
||||
{
|
||||
Id = Model.Id,
|
||||
ShopName = Model.ShopName,
|
||||
Address = Model.Address,
|
||||
OpeningDate = Model.OpeningDate,
|
||||
RepairsMaxCount = Model.RepairsMaxCount,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel? Model)
|
||||
{
|
||||
if (Model is null)
|
||||
return;
|
||||
|
||||
ShopName = Model.ShopName;
|
||||
Address = Model.Address;
|
||||
OpeningDate = Model.OpeningDate;
|
||||
RepairsMaxCount = Model.RepairsMaxCount;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
OpeningDate = OpeningDate,
|
||||
ShopRepairs = ShopRepairs,
|
||||
RepairsMaxCount = RepairsMaxCount,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,25 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AutoWorkshopBusinessLogic\AutoWorkshopBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\AutoWorkshopFileImplement\AutoWorkshopFileImplement.csproj" />
|
||||
<ProjectReference Include="..\AutoWorkshopImplement\AutoWorkshopListImplement.csproj" />
|
||||
<ProjectReference Include="..\AutoWorkshopDatabaseImplement\AutoWorkshopDatabaseImplement.csproj" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.17">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="NLog" Version="5.2.8" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.19" />
|
||||
<PackageReference Include="System.Text.Encoding" Version="4.3.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="ReportOrder.rdlc">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="ReportGroupedOrders.rdlc">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
120
AutoWorkshopView/Forms/FormRepairs.resx
Normal file
120
AutoWorkshopView/Forms/FormRepairs.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd: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>
|
||||
89
AutoWorkshopView/Forms/FormReportGroupedOrders.Designer.cs
generated
Normal file
89
AutoWorkshopView/Forms/FormReportGroupedOrders.Designer.cs
generated
Normal file
@@ -0,0 +1,89 @@
|
||||
namespace AutoWorkshopView.Forms
|
||||
{
|
||||
partial class FormReportGroupedOrders
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
Panel = new Panel();
|
||||
ToPdfButton = new Button();
|
||||
CreateButton = new Button();
|
||||
Panel.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// Panel
|
||||
//
|
||||
Panel.Controls.Add(ToPdfButton);
|
||||
Panel.Controls.Add(CreateButton);
|
||||
Panel.Dock = DockStyle.Top;
|
||||
Panel.Location = new Point(0, 0);
|
||||
Panel.Margin = new Padding(3, 2, 3, 2);
|
||||
Panel.Name = "Panel";
|
||||
Panel.Size = new Size(849, 39);
|
||||
Panel.TabIndex = 1;
|
||||
//
|
||||
// ToPdfButton
|
||||
//
|
||||
ToPdfButton.Location = new Point(425, 9);
|
||||
ToPdfButton.Margin = new Padding(3, 2, 3, 2);
|
||||
ToPdfButton.Name = "ToPdfButton";
|
||||
ToPdfButton.Size = new Size(360, 22);
|
||||
ToPdfButton.TabIndex = 5;
|
||||
ToPdfButton.Text = "В PDF";
|
||||
ToPdfButton.UseVisualStyleBackColor = true;
|
||||
ToPdfButton.Click += ButtonToPdf_Click;
|
||||
//
|
||||
// CreateButton
|
||||
//
|
||||
CreateButton.Location = new Point(43, 9);
|
||||
CreateButton.Margin = new Padding(3, 2, 3, 2);
|
||||
CreateButton.Name = "CreateButton";
|
||||
CreateButton.Size = new Size(330, 22);
|
||||
CreateButton.TabIndex = 4;
|
||||
CreateButton.Text = "Сформировать";
|
||||
CreateButton.UseVisualStyleBackColor = true;
|
||||
CreateButton.Click += ButtonMake_Click;
|
||||
//
|
||||
// FormReportGroupedOrders
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(849, 338);
|
||||
Controls.Add(Panel);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormReportGroupedOrders";
|
||||
Text = "Объединенные по датам заказы";
|
||||
Panel.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel Panel;
|
||||
private Button ToPdfButton;
|
||||
private Button CreateButton;
|
||||
}
|
||||
}
|
||||
75
AutoWorkshopView/Forms/FormReportGroupedOrders.cs
Normal file
75
AutoWorkshopView/Forms/FormReportGroupedOrders.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Reporting.WinForms;
|
||||
|
||||
namespace AutoWorkshopView.Forms
|
||||
{
|
||||
public partial class FormReportGroupedOrders : Form
|
||||
{
|
||||
private readonly ReportViewer _reportViewer;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportLogic _logic;
|
||||
|
||||
public FormReportGroupedOrders(ILogger<FormReportGroupedOrders> Logger, IReportLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = Logger;
|
||||
_logic = Logic;
|
||||
|
||||
_reportViewer = new ReportViewer
|
||||
{
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
_reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupedOrders.rdlc", FileMode.Open));
|
||||
|
||||
Controls.Clear();
|
||||
Controls.Add(_reportViewer);
|
||||
Controls.Add(Panel);
|
||||
}
|
||||
|
||||
private void ButtonMake_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var DataSource = _logic.GetGroupedOrders();
|
||||
var Source = new ReportDataSource("DataSetGroupedOrders", DataSource);
|
||||
_reportViewer.LocalReport.DataSources.Clear();
|
||||
_reportViewer.LocalReport.DataSources.Add(Source);
|
||||
|
||||
_reportViewer.RefreshReport();
|
||||
_logger.LogInformation("Загрузка списка заказов, объединенных по датам");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка заказов, объединенных по датам");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonToPdf_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var Dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
|
||||
|
||||
if (Dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
_logic.SaveGroupedOrdersToPdfFile(new ReportBindingModel
|
||||
{
|
||||
FileName = Dialog.FileName,
|
||||
});
|
||||
|
||||
_logger.LogInformation("Сохранение списка заказов, объединенных по датам");
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка заказов, объединенных по датам");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
AutoWorkshopView/Forms/FormReportGroupedOrders.resx
Normal file
120
AutoWorkshopView/Forms/FormReportGroupedOrders.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd: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>
|
||||
136
AutoWorkshopView/Forms/FormReportOrders.Designer.cs
generated
Normal file
136
AutoWorkshopView/Forms/FormReportOrders.Designer.cs
generated
Normal file
@@ -0,0 +1,136 @@
|
||||
namespace AutoWorkshopView.Forms
|
||||
{
|
||||
partial class FormReportOrders
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
Panel = new Panel();
|
||||
ToPdfButton = new Button();
|
||||
CreateButton = new Button();
|
||||
ToDateTimePicker = new DateTimePicker();
|
||||
ToLabel = new Label();
|
||||
FromDateTimePicker = new DateTimePicker();
|
||||
FromLabel = new Label();
|
||||
Panel.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel
|
||||
//
|
||||
Panel.Controls.Add(ToPdfButton);
|
||||
Panel.Controls.Add(CreateButton);
|
||||
Panel.Controls.Add(ToDateTimePicker);
|
||||
Panel.Controls.Add(ToLabel);
|
||||
Panel.Controls.Add(FromDateTimePicker);
|
||||
Panel.Controls.Add(FromLabel);
|
||||
Panel.Dock = DockStyle.Top;
|
||||
Panel.Location = new Point(0, 0);
|
||||
Panel.Margin = new Padding(3, 2, 3, 2);
|
||||
Panel.Name = "Panel";
|
||||
Panel.Size = new Size(838, 39);
|
||||
Panel.TabIndex = 0;
|
||||
//
|
||||
// ToPdfButton
|
||||
//
|
||||
ToPdfButton.Location = new Point(683, 7);
|
||||
ToPdfButton.Margin = new Padding(3, 2, 3, 2);
|
||||
ToPdfButton.Name = "ToPdfButton";
|
||||
ToPdfButton.Size = new Size(144, 22);
|
||||
ToPdfButton.TabIndex = 5;
|
||||
ToPdfButton.Text = "В PDF";
|
||||
ToPdfButton.UseVisualStyleBackColor = true;
|
||||
ToPdfButton.Click += ButtonToPdf_Click;
|
||||
//
|
||||
// CreateButton
|
||||
//
|
||||
CreateButton.Location = new Point(474, 8);
|
||||
CreateButton.Margin = new Padding(3, 2, 3, 2);
|
||||
CreateButton.Name = "CreateButton";
|
||||
CreateButton.Size = new Size(144, 22);
|
||||
CreateButton.TabIndex = 4;
|
||||
CreateButton.Text = "Сформировать";
|
||||
CreateButton.UseVisualStyleBackColor = true;
|
||||
CreateButton.Click += ButtonMake_Click;
|
||||
//
|
||||
// ToDateTimePicker
|
||||
//
|
||||
ToDateTimePicker.Location = new Point(262, 7);
|
||||
ToDateTimePicker.Margin = new Padding(3, 2, 3, 2);
|
||||
ToDateTimePicker.Name = "ToDateTimePicker";
|
||||
ToDateTimePicker.Size = new Size(175, 23);
|
||||
ToDateTimePicker.TabIndex = 3;
|
||||
//
|
||||
// ToLabel
|
||||
//
|
||||
ToLabel.AutoSize = true;
|
||||
ToLabel.Location = new Point(222, 10);
|
||||
ToLabel.Name = "ToLabel";
|
||||
ToLabel.Size = new Size(21, 15);
|
||||
ToLabel.TabIndex = 2;
|
||||
ToLabel.Text = "по";
|
||||
//
|
||||
// FromDateTimePicker
|
||||
//
|
||||
FromDateTimePicker.Location = new Point(32, 7);
|
||||
FromDateTimePicker.Margin = new Padding(3, 2, 3, 2);
|
||||
FromDateTimePicker.Name = "FromDateTimePicker";
|
||||
FromDateTimePicker.Size = new Size(175, 23);
|
||||
FromDateTimePicker.TabIndex = 1;
|
||||
//
|
||||
// FromLabel
|
||||
//
|
||||
FromLabel.AutoSize = true;
|
||||
FromLabel.Location = new Point(10, 10);
|
||||
FromLabel.Name = "FromLabel";
|
||||
FromLabel.Size = new Size(15, 15);
|
||||
FromLabel.TabIndex = 0;
|
||||
FromLabel.Text = "C";
|
||||
//
|
||||
// FormReportOrders
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(838, 338);
|
||||
Controls.Add(Panel);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormReportOrders";
|
||||
Text = "Заказы";
|
||||
Panel.ResumeLayout(false);
|
||||
Panel.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel Panel;
|
||||
private Button ToPdfButton;
|
||||
private Button CreateButton;
|
||||
private DateTimePicker ToDateTimePicker;
|
||||
private Label ToLabel;
|
||||
private DateTimePicker FromDateTimePicker;
|
||||
private Label FromLabel;
|
||||
}
|
||||
}
|
||||
100
AutoWorkshopView/Forms/FormReportOrders.cs
Normal file
100
AutoWorkshopView/Forms/FormReportOrders.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Reporting.WinForms;
|
||||
|
||||
namespace AutoWorkshopView.Forms
|
||||
{
|
||||
public partial class FormReportOrders : Form
|
||||
{
|
||||
private readonly ReportViewer _reportViewer;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportLogic _logic;
|
||||
|
||||
public FormReportOrders(ILogger<FormReportOrders> Logger, IReportLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = Logger;
|
||||
_logic = Logic;
|
||||
|
||||
_reportViewer = new ReportViewer
|
||||
{
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
_reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrder.rdlc", FileMode.Open));
|
||||
|
||||
Controls.Clear();
|
||||
Controls.Add(_reportViewer);
|
||||
Controls.Add(Panel);
|
||||
}
|
||||
|
||||
private void ButtonMake_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (FromDateTimePicker.Value.Date >= ToDateTimePicker.Value.Date)
|
||||
{
|
||||
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var DataSource = _logic.GetOrders(new ReportBindingModel
|
||||
{
|
||||
DateFrom = FromDateTimePicker.Value,
|
||||
DateTo = ToDateTimePicker.Value
|
||||
});
|
||||
|
||||
var Source = new ReportDataSource("DataSetOrders", DataSource);
|
||||
|
||||
_reportViewer.LocalReport.DataSources.Clear();
|
||||
_reportViewer.LocalReport.DataSources.Add(Source);
|
||||
|
||||
var Parameters = new[] {
|
||||
new ReportParameter("ReportParameterPeriod", $"c {FromDateTimePicker.Value.ToShortDateString()} по {ToDateTimePicker.Value.ToShortDateString()}")
|
||||
};
|
||||
_reportViewer.LocalReport.SetParameters(Parameters);
|
||||
|
||||
_reportViewer.RefreshReport();
|
||||
_logger.LogInformation("Загрузка списка заказов на период {From}-{To}", FromDateTimePicker.Value.ToShortDateString(), ToDateTimePicker.Value.ToShortDateString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка заказов на период");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonToPdf_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (FromDateTimePicker.Value.Date >= ToDateTimePicker.Value.Date)
|
||||
{
|
||||
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
using var Dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
|
||||
|
||||
if (Dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
_logic.SaveOrdersToPdfFile(new ReportBindingModel
|
||||
{
|
||||
FileName = Dialog.FileName,
|
||||
DateFrom = FromDateTimePicker.Value,
|
||||
DateTo = ToDateTimePicker.Value
|
||||
});
|
||||
|
||||
_logger.LogInformation("Сохранение списка заказов на период {From}-{To}", FromDateTimePicker.Value.ToShortDateString(), ToDateTimePicker.Value.ToShortDateString());
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка заказов на период");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
AutoWorkshopView/Forms/FormReportOrders.resx
Normal file
120
AutoWorkshopView/Forms/FormReportOrders.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd: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>
|
||||
115
AutoWorkshopView/Forms/FormReportRepairComponents.Designer.cs
generated
Normal file
115
AutoWorkshopView/Forms/FormReportRepairComponents.Designer.cs
generated
Normal file
@@ -0,0 +1,115 @@
|
||||
namespace AutoWorkshopView.Forms
|
||||
{
|
||||
partial class FormReportRepairComponents
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
DataGridView = new DataGridView();
|
||||
ColumnRepair = new DataGridViewTextBoxColumn();
|
||||
ColumnComponent = new DataGridViewTextBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
SaveToExcelButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.AllowUserToAddRows = false;
|
||||
DataGridView.AllowUserToDeleteRows = false;
|
||||
DataGridView.AllowUserToOrderColumns = true;
|
||||
DataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnRepair, ColumnComponent, ColumnCount });
|
||||
DataGridView.Dock = DockStyle.Bottom;
|
||||
DataGridView.Location = new Point(0, 61);
|
||||
DataGridView.Margin = new Padding(3, 2, 3, 2);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.ReadOnly = true;
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.RowTemplate.Height = 29;
|
||||
DataGridView.Size = new Size(494, 277);
|
||||
DataGridView.TabIndex = 0;
|
||||
//
|
||||
// ColumnRepair
|
||||
//
|
||||
ColumnRepair.FillWeight = 130F;
|
||||
ColumnRepair.HeaderText = "Ремонт";
|
||||
ColumnRepair.MinimumWidth = 6;
|
||||
ColumnRepair.Name = "ColumnRepair";
|
||||
ColumnRepair.ReadOnly = true;
|
||||
//
|
||||
// ColumnComponent
|
||||
//
|
||||
ColumnComponent.FillWeight = 140F;
|
||||
ColumnComponent.HeaderText = "Компонент";
|
||||
ColumnComponent.MinimumWidth = 6;
|
||||
ColumnComponent.Name = "ColumnComponent";
|
||||
ColumnComponent.ReadOnly = true;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.FillWeight = 90F;
|
||||
ColumnCount.HeaderText = "Количество";
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
ColumnCount.ReadOnly = true;
|
||||
//
|
||||
// SaveToExcelButton
|
||||
//
|
||||
SaveToExcelButton.Location = new Point(12, 11);
|
||||
SaveToExcelButton.Margin = new Padding(3, 2, 3, 2);
|
||||
SaveToExcelButton.Name = "SaveToExcelButton";
|
||||
SaveToExcelButton.Size = new Size(153, 36);
|
||||
SaveToExcelButton.TabIndex = 1;
|
||||
SaveToExcelButton.Text = "Сохранить в Excel";
|
||||
SaveToExcelButton.UseVisualStyleBackColor = true;
|
||||
SaveToExcelButton.Click += ButtonSaveToExcel_Click;
|
||||
//
|
||||
// FormReportRepairComponents
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(494, 338);
|
||||
Controls.Add(SaveToExcelButton);
|
||||
Controls.Add(DataGridView);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormReportRepairComponents";
|
||||
Text = "Ремонт с компонентами";
|
||||
Load += FormReportRepairComponents_Load;
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button SaveToExcelButton;
|
||||
private DataGridViewTextBoxColumn ColumnRepair;
|
||||
private DataGridViewTextBoxColumn ColumnComponent;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
}
|
||||
}
|
||||
75
AutoWorkshopView/Forms/FormReportRepairComponents.cs
Normal file
75
AutoWorkshopView/Forms/FormReportRepairComponents.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView.Forms
|
||||
{
|
||||
public partial class FormReportRepairComponents : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportLogic _logic;
|
||||
|
||||
public FormReportRepairComponents(ILogger<FormReportRepairComponents> Logger, IReportLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = Logger;
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormReportRepairComponents_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var Dict = _logic.GetRepairComponents();
|
||||
|
||||
if (Dict != null)
|
||||
{
|
||||
DataGridView.Rows.Clear();
|
||||
|
||||
foreach (var Elem in Dict)
|
||||
{
|
||||
DataGridView.Rows.Add(new object[] { Elem.RepairName, "", "" });
|
||||
|
||||
foreach (var ListElem in Elem.Components)
|
||||
DataGridView.Rows.Add(new object[] { "", ListElem.Item1, ListElem.Item2 });
|
||||
|
||||
DataGridView.Rows.Add(new object[] { "Итого", "", Elem.TotalCount });
|
||||
DataGridView.Rows.Add(Array.Empty<object>());
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка списка ремонтов по компонентам");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка ремонтов по компонентам");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var Dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
|
||||
|
||||
if (Dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveRepairComponentToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FileName = Dialog.FileName
|
||||
});
|
||||
|
||||
_logger.LogInformation("Сохранение списка ремонтов по компонентам");
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка ремонтов по компонентам");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
AutoWorkshopView/Forms/FormReportRepairComponents.resx
Normal file
120
AutoWorkshopView/Forms/FormReportRepairComponents.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd: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>
|
||||
115
AutoWorkshopView/Forms/FormReportShop.Designer.cs
generated
Normal file
115
AutoWorkshopView/Forms/FormReportShop.Designer.cs
generated
Normal file
@@ -0,0 +1,115 @@
|
||||
namespace AutoWorkshopView.Forms
|
||||
{
|
||||
partial class FormReportShop
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
SaveToExcelButton = new Button();
|
||||
DataGridView = new DataGridView();
|
||||
ColumnShop = new DataGridViewTextBoxColumn();
|
||||
ColumnRepair = new DataGridViewTextBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// SaveToExcelButton
|
||||
//
|
||||
SaveToExcelButton.Location = new Point(12, 10);
|
||||
SaveToExcelButton.Margin = new Padding(3, 2, 3, 2);
|
||||
SaveToExcelButton.Name = "SaveToExcelButton";
|
||||
SaveToExcelButton.Size = new Size(195, 27);
|
||||
SaveToExcelButton.TabIndex = 3;
|
||||
SaveToExcelButton.Text = "Сохранить в Excel";
|
||||
SaveToExcelButton.UseVisualStyleBackColor = true;
|
||||
SaveToExcelButton.Click += ButtonSaveToExcel_Click;
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.AllowUserToAddRows = false;
|
||||
DataGridView.AllowUserToDeleteRows = false;
|
||||
DataGridView.AllowUserToOrderColumns = true;
|
||||
DataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnShop, ColumnRepair, ColumnCount });
|
||||
DataGridView.Dock = DockStyle.Bottom;
|
||||
DataGridView.Location = new Point(0, 50);
|
||||
DataGridView.Margin = new Padding(3, 2, 3, 2);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.ReadOnly = true;
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.RowTemplate.Height = 29;
|
||||
DataGridView.Size = new Size(523, 288);
|
||||
DataGridView.TabIndex = 2;
|
||||
//
|
||||
// ColumnShop
|
||||
//
|
||||
ColumnShop.FillWeight = 130F;
|
||||
ColumnShop.HeaderText = "Магазин";
|
||||
ColumnShop.MinimumWidth = 6;
|
||||
ColumnShop.Name = "ColumnShop";
|
||||
ColumnShop.ReadOnly = true;
|
||||
//
|
||||
// ColumnRepair
|
||||
//
|
||||
ColumnRepair.FillWeight = 140F;
|
||||
ColumnRepair.HeaderText = "Ремонт";
|
||||
ColumnRepair.MinimumWidth = 6;
|
||||
ColumnRepair.Name = "ColumnRepair";
|
||||
ColumnRepair.ReadOnly = true;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.FillWeight = 90F;
|
||||
ColumnCount.HeaderText = "Количество";
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
ColumnCount.ReadOnly = true;
|
||||
//
|
||||
// FormReportShop
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(523, 338);
|
||||
Controls.Add(SaveToExcelButton);
|
||||
Controls.Add(DataGridView);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormReportShop";
|
||||
Text = "Загруженность магазинов";
|
||||
Load += FormReportShop_Load;
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button SaveToExcelButton;
|
||||
private DataGridView DataGridView;
|
||||
private DataGridViewTextBoxColumn ColumnShop;
|
||||
private DataGridViewTextBoxColumn ColumnRepair;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
}
|
||||
}
|
||||
75
AutoWorkshopView/Forms/FormReportShop.cs
Normal file
75
AutoWorkshopView/Forms/FormReportShop.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView.Forms
|
||||
{
|
||||
public partial class FormReportShop : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportLogic _logic;
|
||||
|
||||
public FormReportShop(ILogger<FormReportShop> Logger, IReportLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = Logger;
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormReportShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var Shops = _logic.GetShops();
|
||||
if (Shops != null)
|
||||
{
|
||||
DataGridView.Rows.Clear();
|
||||
|
||||
foreach (var Shop in Shops)
|
||||
{
|
||||
DataGridView.Rows.Add(new object[] { Shop.ShopName, "", "" });
|
||||
|
||||
foreach (var Repair in Shop.Repairs)
|
||||
{
|
||||
DataGridView.Rows.Add(new object[] { "", Repair.Item1, Repair.Item2 });
|
||||
}
|
||||
|
||||
DataGridView.Rows.Add(new object[] { "Итого", "", Shop.TotalCount });
|
||||
DataGridView.Rows.Add(Array.Empty<object>());
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка списка ремонтов по магазинам");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка ремонтов по магазинам");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var Dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
|
||||
if (Dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveShopsToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FileName = Dialog.FileName
|
||||
});
|
||||
|
||||
_logger.LogInformation("Сохранение списка ремонтов по магазинам");
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка ремонтов по магазинам");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
AutoWorkshopView/Forms/FormReportShop.resx
Normal file
120
AutoWorkshopView/Forms/FormReportShop.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd: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>
|
||||
146
AutoWorkshopView/Forms/Shop/FormCreateSupply.Designer.cs
generated
Normal file
146
AutoWorkshopView/Forms/Shop/FormCreateSupply.Designer.cs
generated
Normal file
@@ -0,0 +1,146 @@
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
partial class FormCreateSupply
|
||||
{
|
||||
/// <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
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
ShopComboBox = new ComboBox();
|
||||
ShopLabel = new Label();
|
||||
RepairLabel = new Label();
|
||||
RepairComboBox = new ComboBox();
|
||||
CountLabel = new Label();
|
||||
CountTextbox = new TextBox();
|
||||
CancelButton = new Button();
|
||||
SaveButton = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ShopComboBox
|
||||
//
|
||||
ShopComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
ShopComboBox.FormattingEnabled = true;
|
||||
ShopComboBox.Location = new Point(101, 9);
|
||||
ShopComboBox.Margin = new Padding(3, 2, 3, 2);
|
||||
ShopComboBox.Name = "ShopComboBox";
|
||||
ShopComboBox.Size = new Size(302, 23);
|
||||
ShopComboBox.TabIndex = 0;
|
||||
//
|
||||
// ShopLabel
|
||||
//
|
||||
ShopLabel.AutoSize = true;
|
||||
ShopLabel.Location = new Point(10, 12);
|
||||
ShopLabel.Name = "ShopLabel";
|
||||
ShopLabel.Size = new Size(60, 15);
|
||||
ShopLabel.TabIndex = 1;
|
||||
ShopLabel.Text = "Магазин: ";
|
||||
//
|
||||
// RepairLabel
|
||||
//
|
||||
RepairLabel.AutoSize = true;
|
||||
RepairLabel.Location = new Point(11, 39);
|
||||
RepairLabel.Name = "RepairLabel";
|
||||
RepairLabel.Size = new Size(51, 15);
|
||||
RepairLabel.TabIndex = 2;
|
||||
RepairLabel.Text = "Ремонт:";
|
||||
//
|
||||
// RepairComboBox
|
||||
//
|
||||
RepairComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
RepairComboBox.FormattingEnabled = true;
|
||||
RepairComboBox.Location = new Point(101, 36);
|
||||
RepairComboBox.Margin = new Padding(3, 2, 3, 2);
|
||||
RepairComboBox.Name = "RepairComboBox";
|
||||
RepairComboBox.Size = new Size(302, 23);
|
||||
RepairComboBox.TabIndex = 3;
|
||||
//
|
||||
// CountLabel
|
||||
//
|
||||
CountLabel.AutoSize = true;
|
||||
CountLabel.Location = new Point(11, 66);
|
||||
CountLabel.Name = "CountLabel";
|
||||
CountLabel.Size = new Size(78, 15);
|
||||
CountLabel.TabIndex = 4;
|
||||
CountLabel.Text = "Количество: ";
|
||||
//
|
||||
// CountTextbox
|
||||
//
|
||||
CountTextbox.Location = new Point(101, 63);
|
||||
CountTextbox.Margin = new Padding(3, 2, 3, 2);
|
||||
CountTextbox.Name = "CountTextbox";
|
||||
CountTextbox.Size = new Size(302, 23);
|
||||
CountTextbox.TabIndex = 5;
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(301, 100);
|
||||
CancelButton.Margin = new Padding(3, 2, 3, 2);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(102, 29);
|
||||
CancelButton.TabIndex = 6;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
CancelButton.Click += CancelButton_Click;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(183, 100);
|
||||
SaveButton.Margin = new Padding(3, 2, 3, 2);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(102, 29);
|
||||
SaveButton.TabIndex = 7;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
//
|
||||
// FormCreateSupply
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(417, 143);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(CountTextbox);
|
||||
Controls.Add(CountLabel);
|
||||
Controls.Add(RepairComboBox);
|
||||
Controls.Add(RepairLabel);
|
||||
Controls.Add(ShopLabel);
|
||||
Controls.Add(ShopComboBox);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormCreateSupply";
|
||||
Text = "Создание поставки";
|
||||
Load += FormCreateSupply_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox ShopComboBox;
|
||||
private Label ShopLabel;
|
||||
private Label RepairLabel;
|
||||
private ComboBox RepairComboBox;
|
||||
private Label CountLabel;
|
||||
private TextBox CountTextbox;
|
||||
private Button CancelButton;
|
||||
private Button SaveButton;
|
||||
}
|
||||
}
|
||||
99
AutoWorkshopView/Forms/Shop/FormCreateSupply.cs
Normal file
99
AutoWorkshopView/Forms/Shop/FormCreateSupply.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
public partial class FormCreateSupply : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IRepairLogic _repairLogic;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
|
||||
private List<ShopViewModel> _shopList = new List<ShopViewModel>();
|
||||
private List<RepairViewModel> _RepairList = new List<RepairViewModel>();
|
||||
|
||||
public FormCreateSupply(ILogger<FormCreateSupply> Logger, IRepairLogic RepairLogic, IShopLogic ShopLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = Logger;
|
||||
_repairLogic = RepairLogic;
|
||||
_shopLogic = ShopLogic;
|
||||
}
|
||||
|
||||
private void FormCreateSupply_Load(object sender, EventArgs e)
|
||||
{
|
||||
_shopList = _shopLogic.ReadList(null);
|
||||
_RepairList = _repairLogic.ReadList(null);
|
||||
|
||||
if (_shopList != null)
|
||||
{
|
||||
ShopComboBox.DisplayMember = "ShopName";
|
||||
ShopComboBox.ValueMember = "Id";
|
||||
ShopComboBox.DataSource = _shopList;
|
||||
ShopComboBox.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка магазинов для поставок");
|
||||
}
|
||||
|
||||
if (_RepairList != null)
|
||||
{
|
||||
RepairComboBox.DisplayMember = "RepairName";
|
||||
RepairComboBox.ValueMember = "Id";
|
||||
RepairComboBox.DataSource = _RepairList;
|
||||
RepairComboBox.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка ремонтов для поставок");
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ShopComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (RepairComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Создание поставки");
|
||||
|
||||
try
|
||||
{
|
||||
var OperationResult = _shopLogic.MakeSupply(new SupplyBindingModel
|
||||
{
|
||||
ShopId = Convert.ToInt32(ShopComboBox.SelectedValue),
|
||||
RepairId = Convert.ToInt32(RepairComboBox.SelectedValue),
|
||||
Count = Convert.ToInt32(CountTextbox.Text)
|
||||
});
|
||||
|
||||
if (!OperationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания поставки");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
AutoWorkshopView/Forms/Shop/FormCreateSupply.resx
Normal file
120
AutoWorkshopView/Forms/Shop/FormCreateSupply.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd: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>
|
||||
125
AutoWorkshopView/Forms/Shop/FormSellRepair.Designer.cs
generated
Normal file
125
AutoWorkshopView/Forms/Shop/FormSellRepair.Designer.cs
generated
Normal file
@@ -0,0 +1,125 @@
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
partial class FormSellRepair
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
RepairLabel = new Label();
|
||||
RepairComboBox = new ComboBox();
|
||||
CountLabel = new Label();
|
||||
CountTextBox = new TextBox();
|
||||
SellButton = new Button();
|
||||
CancelButton = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// RepairLabel
|
||||
//
|
||||
RepairLabel.AutoSize = true;
|
||||
RepairLabel.Location = new Point(10, 11);
|
||||
RepairLabel.Name = "RepairLabel";
|
||||
RepairLabel.Size = new Size(54, 15);
|
||||
RepairLabel.TabIndex = 0;
|
||||
RepairLabel.Text = "Ремонт: ";
|
||||
//
|
||||
// RepairComboBox
|
||||
//
|
||||
RepairComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
RepairComboBox.FormattingEnabled = true;
|
||||
RepairComboBox.Location = new Point(94, 8);
|
||||
RepairComboBox.Margin = new Padding(3, 2, 3, 2);
|
||||
RepairComboBox.Name = "RepairComboBox";
|
||||
RepairComboBox.Size = new Size(217, 23);
|
||||
RepairComboBox.TabIndex = 1;
|
||||
//
|
||||
// CountLabel
|
||||
//
|
||||
CountLabel.AutoSize = true;
|
||||
CountLabel.Location = new Point(10, 41);
|
||||
CountLabel.Name = "CountLabel";
|
||||
CountLabel.Size = new Size(78, 15);
|
||||
CountLabel.TabIndex = 2;
|
||||
CountLabel.Text = "Количество: ";
|
||||
//
|
||||
// CountTextBox
|
||||
//
|
||||
CountTextBox.Location = new Point(94, 39);
|
||||
CountTextBox.Margin = new Padding(3, 2, 3, 2);
|
||||
CountTextBox.Name = "CountTextBox";
|
||||
CountTextBox.Size = new Size(217, 23);
|
||||
CountTextBox.TabIndex = 3;
|
||||
//
|
||||
// SellButton
|
||||
//
|
||||
SellButton.Location = new Point(117, 77);
|
||||
SellButton.Margin = new Padding(3, 2, 3, 2);
|
||||
SellButton.Name = "SellButton";
|
||||
SellButton.Size = new Size(92, 30);
|
||||
SellButton.TabIndex = 4;
|
||||
SellButton.Text = "Продать";
|
||||
SellButton.UseVisualStyleBackColor = true;
|
||||
SellButton.Click += SellButton_Click;
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(215, 77);
|
||||
CancelButton.Margin = new Padding(3, 2, 3, 2);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(96, 30);
|
||||
CancelButton.TabIndex = 5;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
CancelButton.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormSellRepair
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(325, 122);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(SellButton);
|
||||
Controls.Add(CountTextBox);
|
||||
Controls.Add(CountLabel);
|
||||
Controls.Add(RepairComboBox);
|
||||
Controls.Add(RepairLabel);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormSellRepair";
|
||||
Text = "Продажа ремонтов";
|
||||
Load += FormSellRepair_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label RepairLabel;
|
||||
private ComboBox RepairComboBox;
|
||||
private Label CountLabel;
|
||||
private TextBox CountTextBox;
|
||||
private Button SellButton;
|
||||
private Button CancelButton;
|
||||
}
|
||||
}
|
||||
87
AutoWorkshopView/Forms/Shop/FormSellRepair.cs
Normal file
87
AutoWorkshopView/Forms/Shop/FormSellRepair.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
public partial class FormSellRepair : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IRepairLogic _repairLogic;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
|
||||
private List<RepairViewModel> _repairList = new List<RepairViewModel>();
|
||||
|
||||
public FormSellRepair(ILogger<FormSellRepair> Logger, IRepairLogic RepairLogic, IShopLogic ShopLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = Logger;
|
||||
_repairLogic = RepairLogic;
|
||||
_shopLogic = ShopLogic;
|
||||
}
|
||||
|
||||
private void FormSellRepair_Load(object sender, EventArgs e)
|
||||
{
|
||||
_repairList = _repairLogic.ReadList(null);
|
||||
|
||||
if (_repairList != null)
|
||||
{
|
||||
RepairComboBox.DisplayMember = "RepairName";
|
||||
RepairComboBox.ValueMember = "Id";
|
||||
RepairComboBox.DataSource = _repairList;
|
||||
RepairComboBox.SelectedItem = null;
|
||||
|
||||
_logger.LogInformation("Загрузка ремонтов для продажи");
|
||||
}
|
||||
}
|
||||
|
||||
private void SellButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (RepairComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите ремонт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Создание покупки");
|
||||
|
||||
try
|
||||
{
|
||||
bool Result = _shopLogic.MakeSell(new SupplySearchModel
|
||||
{
|
||||
RepairId = Convert.ToInt32(RepairComboBox.SelectedValue),
|
||||
Count = Convert.ToInt32(CountTextBox.Text)
|
||||
});
|
||||
|
||||
if (Result)
|
||||
{
|
||||
_logger.LogInformation("Проверка пройдена, продажа проведена");
|
||||
MessageBox.Show("Продажа проведена", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogInformation("Проверка не пройдена");
|
||||
MessageBox.Show("Продажа не может быть создана.", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
AutoWorkshopView/Forms/Shop/FormSellRepair.resx
Normal file
120
AutoWorkshopView/Forms/Shop/FormSellRepair.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd: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>
|
||||
222
AutoWorkshopView/Forms/Shop/FormShop.Designer.cs
generated
Normal file
222
AutoWorkshopView/Forms/Shop/FormShop.Designer.cs
generated
Normal file
@@ -0,0 +1,222 @@
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
partial class FormShop
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
NameLabel = new Label();
|
||||
NameTextBox = new TextBox();
|
||||
AddressTextBox = new TextBox();
|
||||
AddressLabel = new Label();
|
||||
CancelButton = new Button();
|
||||
SaveButton = new Button();
|
||||
ViewDataGrid = new DataGridView();
|
||||
IdColumn = new DataGridViewTextBoxColumn();
|
||||
RepairNameColumn = new DataGridViewTextBoxColumn();
|
||||
CountColumn = new DataGridViewTextBoxColumn();
|
||||
OpeningDateLabel = new Label();
|
||||
OpenDateTimePicker = new DateTimePicker();
|
||||
RepairsMaxCountLabel = new Label();
|
||||
RepairsMaxCountNumericUp = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)ViewDataGrid).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)RepairsMaxCountNumericUp).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// NameLabel
|
||||
//
|
||||
NameLabel.AutoSize = true;
|
||||
NameLabel.Location = new Point(9, 9);
|
||||
NameLabel.Name = "NameLabel";
|
||||
NameLabel.Size = new Size(65, 15);
|
||||
NameLabel.TabIndex = 0;
|
||||
NameLabel.Text = "Название: ";
|
||||
//
|
||||
// NameTextBox
|
||||
//
|
||||
NameTextBox.Location = new Point(105, 6);
|
||||
NameTextBox.Margin = new Padding(3, 2, 3, 2);
|
||||
NameTextBox.Name = "NameTextBox";
|
||||
NameTextBox.Size = new Size(210, 23);
|
||||
NameTextBox.TabIndex = 1;
|
||||
//
|
||||
// AddressTextBox
|
||||
//
|
||||
AddressTextBox.Location = new Point(105, 33);
|
||||
AddressTextBox.Margin = new Padding(3, 2, 3, 2);
|
||||
AddressTextBox.Name = "AddressTextBox";
|
||||
AddressTextBox.Size = new Size(210, 23);
|
||||
AddressTextBox.TabIndex = 3;
|
||||
//
|
||||
// AddressLabel
|
||||
//
|
||||
AddressLabel.AutoSize = true;
|
||||
AddressLabel.Location = new Point(10, 36);
|
||||
AddressLabel.Name = "AddressLabel";
|
||||
AddressLabel.Size = new Size(46, 15);
|
||||
AddressLabel.TabIndex = 2;
|
||||
AddressLabel.Text = "Адрес: ";
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(345, 302);
|
||||
CancelButton.Margin = new Padding(3, 2, 3, 2);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(100, 25);
|
||||
CancelButton.TabIndex = 5;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
CancelButton.Click += CancelButton_Click;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(239, 302);
|
||||
SaveButton.Margin = new Padding(3, 2, 3, 2);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(100, 25);
|
||||
SaveButton.TabIndex = 6;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
//
|
||||
// ViewDataGrid
|
||||
//
|
||||
ViewDataGrid.AllowUserToAddRows = false;
|
||||
ViewDataGrid.AllowUserToDeleteRows = false;
|
||||
ViewDataGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
ViewDataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
ViewDataGrid.Columns.AddRange(new DataGridViewColumn[] { IdColumn, RepairNameColumn, CountColumn });
|
||||
ViewDataGrid.Location = new Point(9, 126);
|
||||
ViewDataGrid.Margin = new Padding(3, 2, 3, 2);
|
||||
ViewDataGrid.Name = "ViewDataGrid";
|
||||
ViewDataGrid.ReadOnly = true;
|
||||
ViewDataGrid.RowHeadersBorderStyle = DataGridViewHeaderBorderStyle.None;
|
||||
ViewDataGrid.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders;
|
||||
ViewDataGrid.RowTemplate.Height = 29;
|
||||
ViewDataGrid.Size = new Size(436, 172);
|
||||
ViewDataGrid.TabIndex = 7;
|
||||
//
|
||||
// IdColumn
|
||||
//
|
||||
IdColumn.HeaderText = "Id";
|
||||
IdColumn.MinimumWidth = 6;
|
||||
IdColumn.Name = "IdColumn";
|
||||
IdColumn.ReadOnly = true;
|
||||
IdColumn.Visible = false;
|
||||
//
|
||||
// RepairNameColumn
|
||||
//
|
||||
RepairNameColumn.HeaderText = "Ремонт";
|
||||
RepairNameColumn.MinimumWidth = 6;
|
||||
RepairNameColumn.Name = "RepairNameColumn";
|
||||
RepairNameColumn.ReadOnly = true;
|
||||
//
|
||||
// CountColumn
|
||||
//
|
||||
CountColumn.HeaderText = "Количество";
|
||||
CountColumn.MinimumWidth = 6;
|
||||
CountColumn.Name = "CountColumn";
|
||||
CountColumn.ReadOnly = true;
|
||||
//
|
||||
// OpeningDateLabel
|
||||
//
|
||||
OpeningDateLabel.AutoSize = true;
|
||||
OpeningDateLabel.Location = new Point(9, 63);
|
||||
OpeningDateLabel.Name = "OpeningDateLabel";
|
||||
OpeningDateLabel.Size = new Size(90, 15);
|
||||
OpeningDateLabel.TabIndex = 8;
|
||||
OpeningDateLabel.Text = "Дата открытия:";
|
||||
//
|
||||
// OpenDateTimePicker
|
||||
//
|
||||
OpenDateTimePicker.Location = new Point(105, 60);
|
||||
OpenDateTimePicker.Margin = new Padding(3, 2, 3, 2);
|
||||
OpenDateTimePicker.Name = "OpenDateTimePicker";
|
||||
OpenDateTimePicker.Size = new Size(210, 23);
|
||||
OpenDateTimePicker.TabIndex = 9;
|
||||
//
|
||||
// RepairsMaxCountLabel
|
||||
//
|
||||
RepairsMaxCountLabel.AutoSize = true;
|
||||
RepairsMaxCountLabel.Location = new Point(9, 90);
|
||||
RepairsMaxCountLabel.Name = "RepairsMaxCountLabel";
|
||||
RepairsMaxCountLabel.Size = new Size(83, 15);
|
||||
RepairsMaxCountLabel.TabIndex = 10;
|
||||
RepairsMaxCountLabel.Text = "Вместимость:";
|
||||
//
|
||||
// RepairsMaxCountNumericUp
|
||||
//
|
||||
RepairsMaxCountNumericUp.Location = new Point(105, 87);
|
||||
RepairsMaxCountNumericUp.Margin = new Padding(3, 2, 3, 2);
|
||||
RepairsMaxCountNumericUp.Maximum = new decimal(new int[] { 10000, 0, 0, 0 });
|
||||
RepairsMaxCountNumericUp.Name = "RepairsMaxCountNumericUp";
|
||||
RepairsMaxCountNumericUp.Size = new Size(210, 23);
|
||||
RepairsMaxCountNumericUp.TabIndex = 11;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(460, 340);
|
||||
Controls.Add(RepairsMaxCountNumericUp);
|
||||
Controls.Add(RepairsMaxCountLabel);
|
||||
Controls.Add(OpenDateTimePicker);
|
||||
Controls.Add(OpeningDateLabel);
|
||||
Controls.Add(ViewDataGrid);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(AddressTextBox);
|
||||
Controls.Add(AddressLabel);
|
||||
Controls.Add(NameTextBox);
|
||||
Controls.Add(NameLabel);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormShop";
|
||||
Text = "Магазин";
|
||||
Load += FormShop_Load;
|
||||
((System.ComponentModel.ISupportInitialize)ViewDataGrid).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)RepairsMaxCountNumericUp).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label NameLabel;
|
||||
private TextBox NameTextBox;
|
||||
private TextBox AddressTextBox;
|
||||
private Label AddressLabel;
|
||||
private Button CancelButton;
|
||||
private Button SaveButton;
|
||||
private DataGridView ViewDataGrid;
|
||||
private DataGridViewTextBoxColumn IdColumn;
|
||||
private DataGridViewTextBoxColumn RepairNameColumn;
|
||||
private DataGridViewTextBoxColumn CountColumn;
|
||||
private Label OpeningDateLabel;
|
||||
private DateTimePicker OpenDateTimePicker;
|
||||
private Label RepairsMaxCountLabel;
|
||||
private NumericUpDown RepairsMaxCountNumericUp;
|
||||
}
|
||||
}
|
||||
136
AutoWorkshopView/Forms/Shop/FormShop.cs
Normal file
136
AutoWorkshopView/Forms/Shop/FormShop.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using AutoWorkshopContracts.SearchModels;
|
||||
using AutoWorkshopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
public partial class FormShop : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
private Dictionary<int, (IRepairModel, int)> _shopRepairs;
|
||||
private DateTime? _openingDate = null;
|
||||
|
||||
public FormShop(ILogger<FormShop> Logger, IShopLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = Logger;
|
||||
_logic = Logic;
|
||||
_shopRepairs = new Dictionary<int, (IRepairModel, int)>();
|
||||
}
|
||||
|
||||
private void FormShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазина");
|
||||
|
||||
try
|
||||
{
|
||||
var View = _logic.ReadElement(new ShopSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
|
||||
if (View != null)
|
||||
{
|
||||
NameTextBox.Text = View.ShopName;
|
||||
AddressTextBox.Text = View.Address;
|
||||
OpenDateTimePicker.Value = View.OpeningDate;
|
||||
RepairsMaxCountNumericUp.Value = View.RepairsMaxCount;
|
||||
_shopRepairs = View.ShopRepairs ?? new Dictionary<int, (IRepairModel, int)>();
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка ремонтов в магазине");
|
||||
|
||||
try
|
||||
{
|
||||
if (_shopRepairs != null)
|
||||
{
|
||||
ViewDataGrid.Rows.Clear();
|
||||
foreach (var ShopRepair in _shopRepairs)
|
||||
{
|
||||
ViewDataGrid.Rows.Add(new object[] { ShopRepair.Key, ShopRepair.Value.Item1.RepairName, ShopRepair.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(NameTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(AddressTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
|
||||
try
|
||||
{
|
||||
var Model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = NameTextBox.Text,
|
||||
Address = AddressTextBox.Text,
|
||||
OpeningDate = OpenDateTimePicker.Value,
|
||||
RepairsMaxCount = (int)RepairsMaxCountNumericUp.Value,
|
||||
};
|
||||
|
||||
var OperationResult = _id.HasValue ? _logic.Update(Model) : _logic.Create(Model);
|
||||
if (!OperationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
AutoWorkshopView/Forms/Shop/FormShop.resx
Normal file
120
AutoWorkshopView/Forms/Shop/FormShop.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd: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>
|
||||
136
AutoWorkshopView/Forms/Shop/FormShops.Designer.cs
generated
Normal file
136
AutoWorkshopView/Forms/Shop/FormShops.Designer.cs
generated
Normal file
@@ -0,0 +1,136 @@
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
partial class FormShops
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
ToolsPanel = new Panel();
|
||||
RefreshButton = new Button();
|
||||
DeleteButton = new Button();
|
||||
UpdateButton = new Button();
|
||||
AddButton = new Button();
|
||||
ViewDataGrid = new DataGridView();
|
||||
ToolsPanel.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)ViewDataGrid).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ToolsPanel
|
||||
//
|
||||
ToolsPanel.Controls.Add(RefreshButton);
|
||||
ToolsPanel.Controls.Add(DeleteButton);
|
||||
ToolsPanel.Controls.Add(UpdateButton);
|
||||
ToolsPanel.Controls.Add(AddButton);
|
||||
ToolsPanel.Location = new Point(532, 9);
|
||||
ToolsPanel.Margin = new Padding(3, 2, 3, 2);
|
||||
ToolsPanel.Name = "ToolsPanel";
|
||||
ToolsPanel.Size = new Size(117, 320);
|
||||
ToolsPanel.TabIndex = 3;
|
||||
//
|
||||
// RefreshButton
|
||||
//
|
||||
RefreshButton.Location = new Point(3, 105);
|
||||
RefreshButton.Margin = new Padding(3, 2, 3, 2);
|
||||
RefreshButton.Name = "RefreshButton";
|
||||
RefreshButton.Size = new Size(110, 27);
|
||||
RefreshButton.TabIndex = 3;
|
||||
RefreshButton.Text = "Обновить";
|
||||
RefreshButton.UseVisualStyleBackColor = true;
|
||||
RefreshButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(3, 74);
|
||||
DeleteButton.Margin = new Padding(3, 2, 3, 2);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(110, 27);
|
||||
DeleteButton.TabIndex = 2;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
DeleteButton.Click += DeleteButton_Click;
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
UpdateButton.Location = new Point(3, 43);
|
||||
UpdateButton.Margin = new Padding(3, 2, 3, 2);
|
||||
UpdateButton.Name = "UpdateButton";
|
||||
UpdateButton.Size = new Size(110, 27);
|
||||
UpdateButton.TabIndex = 1;
|
||||
UpdateButton.Text = "Изменить";
|
||||
UpdateButton.UseVisualStyleBackColor = true;
|
||||
UpdateButton.Click += UpdateButton_Click;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(3, 12);
|
||||
AddButton.Margin = new Padding(3, 2, 3, 2);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(110, 27);
|
||||
AddButton.TabIndex = 0;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// ViewDataGrid
|
||||
//
|
||||
ViewDataGrid.AllowUserToAddRows = false;
|
||||
ViewDataGrid.AllowUserToDeleteRows = false;
|
||||
ViewDataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
ViewDataGrid.Location = new Point(10, 9);
|
||||
ViewDataGrid.Margin = new Padding(3, 2, 3, 2);
|
||||
ViewDataGrid.Name = "ViewDataGrid";
|
||||
ViewDataGrid.ReadOnly = true;
|
||||
ViewDataGrid.RowHeadersWidth = 51;
|
||||
ViewDataGrid.RowTemplate.Height = 29;
|
||||
ViewDataGrid.Size = new Size(516, 320);
|
||||
ViewDataGrid.TabIndex = 2;
|
||||
//
|
||||
// FormShops
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(660, 338);
|
||||
Controls.Add(ToolsPanel);
|
||||
Controls.Add(ViewDataGrid);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormShops";
|
||||
Text = "Магазины";
|
||||
Load += FormShops_Load;
|
||||
ToolsPanel.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)ViewDataGrid).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel ToolsPanel;
|
||||
private Button RefreshButton;
|
||||
private Button DeleteButton;
|
||||
private Button UpdateButton;
|
||||
private Button AddButton;
|
||||
private DataGridView ViewDataGrid;
|
||||
}
|
||||
}
|
||||
113
AutoWorkshopView/Forms/Shop/FormShops.cs
Normal file
113
AutoWorkshopView/Forms/Shop/FormShops.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView.Forms.Shop
|
||||
{
|
||||
public partial class FormShops : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
public FormShops(ILogger<FormShops> Logger, IShopLogic Logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = Logger;
|
||||
_logic = Logic;
|
||||
}
|
||||
|
||||
private void FormShops_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var List = _logic.ReadList(null);
|
||||
|
||||
if (List != null)
|
||||
{
|
||||
ViewDataGrid.DataSource = List;
|
||||
ViewDataGrid.Columns["Id"].Visible = false;
|
||||
ViewDataGrid.Columns["ShopRepairs"].Visible = false;
|
||||
ViewDataGrid.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
|
||||
if (Service is FormShop Form)
|
||||
{
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ViewDataGrid.SelectedRows.Count == 1)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
if (Service is FormShop Form)
|
||||
{
|
||||
Form.Id = Convert.ToInt32(ViewDataGrid.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
if (Form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ViewDataGrid.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int Id = Convert.ToInt32(ViewDataGrid.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление магазина");
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ShopBindingModel
|
||||
{
|
||||
Id = Id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
AutoWorkshopView/Forms/Shop/FormShops.resx
Normal file
120
AutoWorkshopView/Forms/Shop/FormShops.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd: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>
|
||||
109
AutoWorkshopView/MainForm.Designer.cs
generated
109
AutoWorkshopView/MainForm.Designer.cs
generated
@@ -32,6 +32,17 @@
|
||||
ToolStripMenu = new ToolStripMenuItem();
|
||||
ComponentsStripMenuItem = new ToolStripMenuItem();
|
||||
RepairStripMenuItem = new ToolStripMenuItem();
|
||||
ShopsToolStripMenuItem = new ToolStripMenuItem();
|
||||
OperationToolStripMenuItem = new ToolStripMenuItem();
|
||||
TransactionToolStripMenuItem = new ToolStripMenuItem();
|
||||
SaleToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportRepairsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportRepCompToolStripMenuItem = new ToolStripMenuItem();
|
||||
OrdersToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportShopsToolStripMenuItem = new ToolStripMenuItem();
|
||||
RepostBusyShopsToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportGroupOrdersToolStripMenuItem = new ToolStripMenuItem();
|
||||
DataGridView = new DataGridView();
|
||||
CreateOrderButton = new Button();
|
||||
TakeInWorkButton = new Button();
|
||||
@@ -45,7 +56,7 @@
|
||||
// MenuStrip
|
||||
//
|
||||
MenuStrip.ImageScalingSize = new Size(20, 20);
|
||||
MenuStrip.Items.AddRange(new ToolStripItem[] { ToolStripMenu });
|
||||
MenuStrip.Items.AddRange(new ToolStripItem[] { ToolStripMenu, OperationToolStripMenuItem, ReportsToolStripMenuItem });
|
||||
MenuStrip.Location = new Point(0, 0);
|
||||
MenuStrip.Name = "MenuStrip";
|
||||
MenuStrip.Padding = new Padding(5, 2, 0, 2);
|
||||
@@ -55,7 +66,7 @@
|
||||
//
|
||||
// ToolStripMenu
|
||||
//
|
||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { ComponentsStripMenuItem, RepairStripMenuItem });
|
||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { ComponentsStripMenuItem, RepairStripMenuItem, ShopsToolStripMenuItem });
|
||||
ToolStripMenu.Name = "ToolStripMenu";
|
||||
ToolStripMenu.Size = new Size(94, 20);
|
||||
ToolStripMenu.Text = "Справочники";
|
||||
@@ -63,19 +74,98 @@
|
||||
// ComponentsStripMenuItem
|
||||
//
|
||||
ComponentsStripMenuItem.Name = "ComponentsStripMenuItem";
|
||||
ComponentsStripMenuItem.Size = new Size(145, 22);
|
||||
ComponentsStripMenuItem.Size = new Size(180, 22);
|
||||
ComponentsStripMenuItem.Text = "Компоненты";
|
||||
ComponentsStripMenuItem.Click += ComponentsStripMenuItem_Click;
|
||||
//
|
||||
// RepairStripMenuItem
|
||||
//
|
||||
RepairStripMenuItem.Name = "RepairStripMenuItem";
|
||||
RepairStripMenuItem.Size = new Size(145, 22);
|
||||
RepairStripMenuItem.Size = new Size(180, 22);
|
||||
RepairStripMenuItem.Text = "Ремонты";
|
||||
RepairStripMenuItem.Click += RepairsStripMenuItem_Click;
|
||||
//
|
||||
// ShopsToolStripMenuItem
|
||||
//
|
||||
ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem";
|
||||
ShopsToolStripMenuItem.Size = new Size(180, 22);
|
||||
ShopsToolStripMenuItem.Text = "Магазины";
|
||||
ShopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click;
|
||||
//
|
||||
// OperationToolStripMenuItem
|
||||
//
|
||||
OperationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { TransactionToolStripMenuItem, SaleToolStripMenuItem });
|
||||
OperationToolStripMenuItem.Name = "OperationToolStripMenuItem";
|
||||
OperationToolStripMenuItem.Size = new Size(75, 20);
|
||||
OperationToolStripMenuItem.Text = "Операции";
|
||||
//
|
||||
// TransactionToolStripMenuItem
|
||||
//
|
||||
TransactionToolStripMenuItem.Name = "TransactionToolStripMenuItem";
|
||||
TransactionToolStripMenuItem.Size = new Size(180, 22);
|
||||
TransactionToolStripMenuItem.Text = "Поставка";
|
||||
TransactionToolStripMenuItem.Click += TransactionToolStripMenuItem_Click;
|
||||
//
|
||||
// SaleToolStripMenuItem
|
||||
//
|
||||
SaleToolStripMenuItem.Name = "SaleToolStripMenuItem";
|
||||
SaleToolStripMenuItem.Size = new Size(180, 22);
|
||||
SaleToolStripMenuItem.Text = "Продажа";
|
||||
SaleToolStripMenuItem.Click += SellToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportsToolStripMenuItem
|
||||
//
|
||||
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ReportRepairsToolStripMenuItem, ReportRepCompToolStripMenuItem, OrdersToolStripMenuItem, ReportShopsToolStripMenuItem, RepostBusyShopsToolStripMenuItem, ReportGroupOrdersToolStripMenuItem });
|
||||
ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem";
|
||||
ReportsToolStripMenuItem.Size = new Size(60, 20);
|
||||
ReportsToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// ReportRepairsToolStripMenuItem
|
||||
//
|
||||
ReportRepairsToolStripMenuItem.Name = "ReportRepairsToolStripMenuItem";
|
||||
ReportRepairsToolStripMenuItem.Size = new Size(219, 22);
|
||||
ReportRepairsToolStripMenuItem.Text = "Ремонты";
|
||||
ReportRepairsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportRepCompToolStripMenuItem
|
||||
//
|
||||
ReportRepCompToolStripMenuItem.Name = "ReportRepCompToolStripMenuItem";
|
||||
ReportRepCompToolStripMenuItem.Size = new Size(219, 22);
|
||||
ReportRepCompToolStripMenuItem.Text = "Ремонт с компонентами";
|
||||
ReportRepCompToolStripMenuItem.Click += ComponentRepairToolStripMenuItem_Click;
|
||||
//
|
||||
// OrdersToolStripMenuItem
|
||||
//
|
||||
OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem";
|
||||
OrdersToolStripMenuItem.Size = new Size(219, 22);
|
||||
OrdersToolStripMenuItem.Text = "Заказы";
|
||||
OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportShopsToolStripMenuItem
|
||||
//
|
||||
ReportShopsToolStripMenuItem.Name = "ReportShopsToolStripMenuItem";
|
||||
ReportShopsToolStripMenuItem.Size = new Size(219, 22);
|
||||
ReportShopsToolStripMenuItem.Text = "Список магазинов";
|
||||
ReportShopsToolStripMenuItem.Click += ReportShopsToolStripMenuItem_Click;
|
||||
//
|
||||
// RepostBusyShopsToolStripMenuItem
|
||||
//
|
||||
RepostBusyShopsToolStripMenuItem.Name = "RepostBusyShopsToolStripMenuItem";
|
||||
RepostBusyShopsToolStripMenuItem.Size = new Size(219, 22);
|
||||
RepostBusyShopsToolStripMenuItem.Text = "Загруженность магазинов";
|
||||
RepostBusyShopsToolStripMenuItem.Click += ReportBusyShopsToolStripMenuItem_Click;
|
||||
//
|
||||
// ReportGroupOrdersToolStripMenuItem
|
||||
//
|
||||
ReportGroupOrdersToolStripMenuItem.Name = "ReportGroupOrdersToolStripMenuItem";
|
||||
ReportGroupOrdersToolStripMenuItem.Size = new Size(219, 22);
|
||||
ReportGroupOrdersToolStripMenuItem.Text = "Объединенные заказы";
|
||||
ReportGroupOrdersToolStripMenuItem.Click += ReportGroupOrdersToolStripMenuItem_Click;
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.AllowUserToAddRows = false;
|
||||
DataGridView.AllowUserToDeleteRows = false;
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(10, 23);
|
||||
DataGridView.Margin = new Padding(3, 2, 3, 2);
|
||||
@@ -175,5 +265,16 @@
|
||||
private Button ReadyButton;
|
||||
private Button IssuedButton;
|
||||
private Button RefreshButton;
|
||||
private ToolStripMenuItem ShopsToolStripMenuItem;
|
||||
private ToolStripMenuItem OperationToolStripMenuItem;
|
||||
private ToolStripMenuItem TransactionToolStripMenuItem;
|
||||
private ToolStripMenuItem SaleToolStripMenuItem;
|
||||
private ToolStripMenuItem ReportsToolStripMenuItem;
|
||||
private ToolStripMenuItem ReportRepairsToolStripMenuItem;
|
||||
private ToolStripMenuItem ReportRepCompToolStripMenuItem;
|
||||
private ToolStripMenuItem OrdersToolStripMenuItem;
|
||||
private ToolStripMenuItem ReportShopsToolStripMenuItem;
|
||||
private ToolStripMenuItem RepostBusyShopsToolStripMenuItem;
|
||||
private ToolStripMenuItem ReportGroupOrdersToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using AutoWorkshopContracts.BindingModels;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopView.Forms;
|
||||
using AutoWorkshopView.Forms.Shop;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace AutoWorkshopView
|
||||
@@ -9,12 +10,15 @@ namespace AutoWorkshopView
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
public MainForm(ILogger<MainForm> Logger, IOrderLogic OrderLogic)
|
||||
private readonly IReportLogic _reportLogic;
|
||||
|
||||
public MainForm(ILogger<MainForm> Logger, IOrderLogic OrderLogic, IReportLogic ReportLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = Logger;
|
||||
_orderLogic = OrderLogic;
|
||||
_reportLogic = ReportLogic;
|
||||
}
|
||||
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
@@ -164,5 +168,97 @@ namespace AutoWorkshopView
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||
|
||||
if (Service is FormShops Form)
|
||||
{
|
||||
Form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void TransactionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply));
|
||||
|
||||
if (Service is FormCreateSupply Form)
|
||||
{
|
||||
Form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void SellToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormSellRepair));
|
||||
|
||||
if (Service is FormSellRepair Form)
|
||||
{
|
||||
Form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var Dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
|
||||
if (Dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveRepairsToWordFile(new ReportBindingModel { FileName = Dialog.FileName });
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void ComponentRepairToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormReportRepairComponents));
|
||||
|
||||
if (Service is FormReportRepairComponents Form)
|
||||
{
|
||||
Form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
|
||||
if (Service is FormReportOrders Form)
|
||||
{
|
||||
Form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportShopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var Dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
|
||||
if (Dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveShopsToWordFile(new ReportBindingModel { FileName = Dialog.FileName });
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportBusyShopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormReportShop));
|
||||
|
||||
if (Service is FormReportShop Form)
|
||||
{
|
||||
Form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportGroupOrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var Service = Program.ServiceProvider?.GetService(typeof(FormReportGroupedOrders));
|
||||
|
||||
if (Service is FormReportGroupedOrders Form)
|
||||
{
|
||||
Form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
using AutoWorkshopBusinessLogic.BusinessLogics;
|
||||
using AutoWorkshopBusinessLogic.OfficePackage.Implements;
|
||||
using AutoWorkshopBusinessLogic.OfficePackage;
|
||||
using AutoWorkshopContracts.BusinessLogicContracts;
|
||||
using AutoWorkshopContracts.BusinessLogicsContracts;
|
||||
using AutoWorkshopContracts.StoragesContracts;
|
||||
using AutoWorkshopFileImplement.Implements;
|
||||
using AutoWorkshopDatabaseImplement.Implements;
|
||||
using AutoWorkshopView.Forms;
|
||||
using AutoWorkshopView.Forms.Shop;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
@@ -37,9 +41,17 @@ namespace AutoWorkshopView
|
||||
Services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
Services.AddTransient<IRepairStorage, RepairStorage>();
|
||||
Services.AddTransient<IShopStorage, ShopStorage>();
|
||||
|
||||
Services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
Services.AddTransient<IRepairLogic, RepairLogic>();
|
||||
Services.AddTransient<IReportLogic, ReportLogic>();
|
||||
Services.AddTransient<IShopLogic, ShopLogic>();
|
||||
|
||||
Services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
||||
Services.AddTransient<MainForm>();
|
||||
Services.AddTransient<FormComponent>();
|
||||
@@ -48,6 +60,14 @@ namespace AutoWorkshopView
|
||||
Services.AddTransient<FormRepair>();
|
||||
Services.AddTransient<FormRepairComponent>();
|
||||
Services.AddTransient<FormRepairs>();
|
||||
Services.AddTransient<FormShop>();
|
||||
Services.AddTransient<FormShops>();
|
||||
Services.AddTransient<FormCreateSupply>();
|
||||
Services.AddTransient<FormSellRepair>();
|
||||
Services.AddTransient<FormReportRepairComponents>();
|
||||
Services.AddTransient<FormReportOrders>();
|
||||
Services.AddTransient<FormReportShop>();
|
||||
Services.AddTransient<FormReportGroupedOrders>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
441
AutoWorkshopView/ReportGroupedOrders.rdlc
Normal file
441
AutoWorkshopView/ReportGroupedOrders.rdlc
Normal file
@@ -0,0 +1,441 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
|
||||
<AutoRefresh>0</AutoRefresh>
|
||||
<DataSources>
|
||||
<DataSource Name="AutoWorkshopContractsViewModels">
|
||||
<ConnectionProperties>
|
||||
<DataProvider>System.Data.DataSet</DataProvider>
|
||||
<ConnectString>/* Local Connection */</ConnectString>
|
||||
</ConnectionProperties>
|
||||
<rd:DataSourceID>20791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
|
||||
</DataSource>
|
||||
</DataSources>
|
||||
<DataSets>
|
||||
<DataSet Name="DataSetGroupedOrders">
|
||||
<Query>
|
||||
<DataSourceName>AutoWorkshopContractsViewModels</DataSourceName>
|
||||
<CommandText>/* Local Query */</CommandText>
|
||||
</Query>
|
||||
<Fields>
|
||||
<Field Name="Date">
|
||||
<DataField>Date</DataField>
|
||||
<rd:TypeName>System.DateTime</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="OrdersCount">
|
||||
<DataField>OrdersCount</DataField>
|
||||
<rd:TypeName>System.Int32</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="OrdersSum">
|
||||
<DataField>OrdersSum</DataField>
|
||||
<rd:TypeName>System.Decimal</rd:TypeName>
|
||||
</Field>
|
||||
</Fields>
|
||||
<rd:DataSetInfo>
|
||||
<rd:DataSetName>AutoWorkshopContracts.ViewModels</rd:DataSetName>
|
||||
<rd:TableName>AutoWorksReportGroupedOrdersViewModelhop</rd:TableName>
|
||||
<rd:ObjectDataSourceType>AutoWorkshopContracts.ViewModels.AutoWorksReportGroupedOrdersViewModelhop, AutoWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
||||
</rd:DataSetInfo>
|
||||
</DataSet>
|
||||
</DataSets>
|
||||
<ReportSections>
|
||||
<ReportSection>
|
||||
<Body>
|
||||
<ReportItems>
|
||||
<Textbox Name="TextboxTitle">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Отчёт по заказам</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Center</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>16.51cm</Width>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<VerticalAlign>Middle</VerticalAlign>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Textbox Name="ReportParameterPeriod">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Parameters!ReportParameterPeriod.Value</Value>
|
||||
<Style>
|
||||
<Format>d</Format>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Center</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
|
||||
<Top>0.6cm</Top>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>16.51cm</Width>
|
||||
<ZIndex>1</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Tablix Name="Tablix1">
|
||||
<TablixBody>
|
||||
<TablixColumns>
|
||||
<TablixColumn>
|
||||
<Width>3.90406cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>3.97461cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>3.65711cm</Width>
|
||||
</TablixColumn>
|
||||
</TablixColumns>
|
||||
<TablixRows>
|
||||
<TablixRow>
|
||||
<Height>0.6cm</Height>
|
||||
<TablixCells>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="TextboxDate">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Дата создания</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="TextboxCount">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Количество заказов</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="TextboxSum">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Общая сумма заказов</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
</TablixCells>
|
||||
</TablixRow>
|
||||
<TablixRow>
|
||||
<Height>0.6cm</Height>
|
||||
<TablixCells>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Date">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!Date.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Date</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="OrdersCount">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!OrdersCount.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>OrdersCount</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="OrdersSum">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!OrdersSum.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>OrdersSum</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
</TablixCells>
|
||||
</TablixRow>
|
||||
</TablixRows>
|
||||
</TablixBody>
|
||||
<TablixColumnHierarchy>
|
||||
<TablixMembers>
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
</TablixMembers>
|
||||
</TablixColumnHierarchy>
|
||||
<TablixRowHierarchy>
|
||||
<TablixMembers>
|
||||
<TablixMember>
|
||||
<KeepWithGroup>After</KeepWithGroup>
|
||||
</TablixMember>
|
||||
<TablixMember>
|
||||
<Group Name="Подробности" />
|
||||
</TablixMember>
|
||||
</TablixMembers>
|
||||
</TablixRowHierarchy>
|
||||
<DataSetName>DataSetGroupedOrders</DataSetName>
|
||||
<Top>1.88242cm</Top>
|
||||
<Left>2.68676cm</Left>
|
||||
<Height>1.2cm</Height>
|
||||
<Width>11.53578cm</Width>
|
||||
<ZIndex>2</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
</Style>
|
||||
</Tablix>
|
||||
<Textbox Name="TextboxResout">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Итого:</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Right</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Top>3.29409cm</Top>
|
||||
<Left>8.06542cm</Left>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>2.5cm</Width>
|
||||
<ZIndex>3</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Textbox Name="TextboxFullSum">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Sum(Fields!OrdersSum.Value, "DataSetGroupedOrders")</Value>
|
||||
<Style>
|
||||
<Format>0.00;(0.00)</Format>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Right</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Top>3.29409cm</Top>
|
||||
<Left>10.70653cm</Left>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>3.48072cm</Width>
|
||||
<ZIndex>4</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</ReportItems>
|
||||
<Height>2in</Height>
|
||||
<Style />
|
||||
</Body>
|
||||
<Width>6.5in</Width>
|
||||
<Page>
|
||||
<PageHeight>29.7cm</PageHeight>
|
||||
<PageWidth>21cm</PageWidth>
|
||||
<LeftMargin>2cm</LeftMargin>
|
||||
<RightMargin>2cm</RightMargin>
|
||||
<TopMargin>2cm</TopMargin>
|
||||
<BottomMargin>2cm</BottomMargin>
|
||||
<ColumnSpacing>0.13cm</ColumnSpacing>
|
||||
<Style />
|
||||
</Page>
|
||||
</ReportSection>
|
||||
</ReportSections>
|
||||
<ReportParameters>
|
||||
<ReportParameter Name="ReportParameterPeriod">
|
||||
<DataType>String</DataType>
|
||||
<Nullable>true</Nullable>
|
||||
<Prompt>ReportParameter1</Prompt>
|
||||
</ReportParameter>
|
||||
</ReportParameters>
|
||||
<ReportParametersLayout>
|
||||
<GridLayoutDefinition>
|
||||
<NumberOfColumns>4</NumberOfColumns>
|
||||
<NumberOfRows>2</NumberOfRows>
|
||||
<CellDefinitions>
|
||||
<CellDefinition>
|
||||
<ColumnIndex>0</ColumnIndex>
|
||||
<RowIndex>0</RowIndex>
|
||||
<ParameterName>ReportParameterPeriod</ParameterName>
|
||||
</CellDefinition>
|
||||
</CellDefinitions>
|
||||
</GridLayoutDefinition>
|
||||
</ReportParametersLayout>
|
||||
<rd:ReportUnitType>Cm</rd:ReportUnitType>
|
||||
<rd:ReportID>b5a8ad5e-1151-4687-8576-a5270295c079</rd:ReportID>
|
||||
</Report>
|
||||
572
AutoWorkshopView/ReportOrder.rdlc
Normal file
572
AutoWorkshopView/ReportOrder.rdlc
Normal file
@@ -0,0 +1,572 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
|
||||
<AutoRefresh>0</AutoRefresh>
|
||||
<DataSources>
|
||||
<DataSource Name="AutoWorkshopContractsViewModels">
|
||||
<ConnectionProperties>
|
||||
<DataProvider>System.Data.DataSet</DataProvider>
|
||||
<ConnectString>/* Local Connection */</ConnectString>
|
||||
</ConnectionProperties>
|
||||
<rd:DataSourceID>10791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
|
||||
</DataSource>
|
||||
</DataSources>
|
||||
<DataSets>
|
||||
<DataSet Name="DataSetOrders">
|
||||
<Query>
|
||||
<DataSourceName>AutoWorkshopContractsViewModels</DataSourceName>
|
||||
<CommandText>/* Local Query */</CommandText>
|
||||
</Query>
|
||||
<Fields>
|
||||
<Field Name="Id">
|
||||
<DataField>Id</DataField>
|
||||
<rd:TypeName>System.Int32</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="DateCreate">
|
||||
<DataField>DateCreate</DataField>
|
||||
<rd:TypeName>System.DateTime</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="RepairName">
|
||||
<DataField>RepairName</DataField>
|
||||
<rd:TypeName>System.String</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="Sum">
|
||||
<DataField>Sum</DataField>
|
||||
<rd:TypeName>System.Decimal</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="Status">
|
||||
<DataField>Status</DataField>
|
||||
<rd:TypeName>System.String</rd:TypeName>
|
||||
</Field>
|
||||
</Fields>
|
||||
<rd:DataSetInfo>
|
||||
<rd:DataSetName>AutoWorkshopContracts.ViewModels</rd:DataSetName>
|
||||
<rd:TableName>ReportOrdersViewModel</rd:TableName>
|
||||
<rd:ObjectDataSourceType>AutoWorkshopContracts.ViewModels.ReportOrdersViewModel, AutoWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
||||
</rd:DataSetInfo>
|
||||
</DataSet>
|
||||
</DataSets>
|
||||
<ReportSections>
|
||||
<ReportSection>
|
||||
<Body>
|
||||
<ReportItems>
|
||||
<Textbox Name="TextboxTitle">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Заказы</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Center</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>16.51cm</Width>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<VerticalAlign>Middle</VerticalAlign>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Textbox Name="ReportParameterPeriod">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Parameters!ReportParameterPeriod.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Center</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
|
||||
<Top>0.6cm</Top>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>16.51cm</Width>
|
||||
<ZIndex>1</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<VerticalAlign>Middle</VerticalAlign>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Tablix Name="Tablix">
|
||||
<TablixBody>
|
||||
<TablixColumns>
|
||||
<TablixColumn>
|
||||
<Width>2.60583cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>3.262cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>4.8495cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>2.5cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>2.5cm</Width>
|
||||
</TablixColumn>
|
||||
</TablixColumns>
|
||||
<TablixRows>
|
||||
<TablixRow>
|
||||
<Height>0.6cm</Height>
|
||||
<TablixCells>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="TextboxId">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Номер</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="TextboxDateCreate">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Дата создания</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="TextboxRepairName">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Ремонт</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Textbox2">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Статус</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox2</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="TextboxSum">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Сумма</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
</TablixCells>
|
||||
</TablixRow>
|
||||
<TablixRow>
|
||||
<Height>0.6cm</Height>
|
||||
<TablixCells>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Id">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!Id.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Id</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="DateCreate">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!DateCreate.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>DateCreate</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="RepairName">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!RepairName.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>RepairName</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Status1">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!Status.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Status1</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Sum">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!Sum.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Sum</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
<Style>Solid</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</CellContents>
|
||||
</TablixCell>
|
||||
</TablixCells>
|
||||
</TablixRow>
|
||||
</TablixRows>
|
||||
</TablixBody>
|
||||
<TablixColumnHierarchy>
|
||||
<TablixMembers>
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
<TablixMember />
|
||||
</TablixMembers>
|
||||
</TablixColumnHierarchy>
|
||||
<TablixRowHierarchy>
|
||||
<TablixMembers>
|
||||
<TablixMember>
|
||||
<KeepWithGroup>After</KeepWithGroup>
|
||||
</TablixMember>
|
||||
<TablixMember>
|
||||
<Group Name="Подробности" />
|
||||
</TablixMember>
|
||||
</TablixMembers>
|
||||
</TablixRowHierarchy>
|
||||
<DataSetName>DataSetOrders</DataSetName>
|
||||
<Top>1.9177cm</Top>
|
||||
<Left>0.79267cm</Left>
|
||||
<Height>1.2cm</Height>
|
||||
<Width>15.71733cm</Width>
|
||||
<ZIndex>2</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
</Style>
|
||||
</Tablix>
|
||||
<Textbox Name="TextboxResout">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Итого:</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Right</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Top>3.46287cm</Top>
|
||||
<Left>11.51cm</Left>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>2.5cm</Width>
|
||||
<ZIndex>3</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Textbox Name="Textbox10">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Sum(Fields!Sum.Value, "DataSetOrders")</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox10</rd:DefaultName>
|
||||
<Top>3.46287cm</Top>
|
||||
<Left>14.01cm</Left>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>2.5cm</Width>
|
||||
<ZIndex>4</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
</ReportItems>
|
||||
<Height>2in</Height>
|
||||
<Style />
|
||||
</Body>
|
||||
<Width>7.48425in</Width>
|
||||
<Page>
|
||||
<PageHeight>29.7cm</PageHeight>
|
||||
<PageWidth>21cm</PageWidth>
|
||||
<LeftMargin>2cm</LeftMargin>
|
||||
<RightMargin>2cm</RightMargin>
|
||||
<TopMargin>2cm</TopMargin>
|
||||
<BottomMargin>2cm</BottomMargin>
|
||||
<ColumnSpacing>0.13cm</ColumnSpacing>
|
||||
<Style />
|
||||
</Page>
|
||||
</ReportSection>
|
||||
</ReportSections>
|
||||
<ReportParameters>
|
||||
<ReportParameter Name="ReportParameterPeriod">
|
||||
<DataType>String</DataType>
|
||||
<Nullable>true</Nullable>
|
||||
<Prompt>ReportParameter1</Prompt>
|
||||
</ReportParameter>
|
||||
</ReportParameters>
|
||||
<ReportParametersLayout>
|
||||
<GridLayoutDefinition>
|
||||
<NumberOfColumns>4</NumberOfColumns>
|
||||
<NumberOfRows>2</NumberOfRows>
|
||||
<CellDefinitions>
|
||||
<CellDefinition>
|
||||
<ColumnIndex>0</ColumnIndex>
|
||||
<RowIndex>0</RowIndex>
|
||||
<ParameterName>ReportParameterPeriod</ParameterName>
|
||||
</CellDefinition>
|
||||
</CellDefinitions>
|
||||
</GridLayoutDefinition>
|
||||
</ReportParametersLayout>
|
||||
<rd:ReportUnitType>Cm</rd:ReportUnitType>
|
||||
<rd:ReportID>0c9e94bc-df40-42bd-a526-01713dd3057f</rd:ReportID>
|
||||
</Report>
|
||||
Reference in New Issue
Block a user