Merge branch 'dev-guarantor'
This commit is contained in:
commit
05d5ba207e
@ -1,6 +1,7 @@
|
||||
using ComputerShopContracts.BindingModels;
|
||||
using ComputerShopBusinessLogic.OfficePackage;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
using ComputerShopContracts.BindingModels;
|
||||
using ComputerShopContracts.BusinessLogicContracts;
|
||||
using ComputerShopContracts.SearchModels;
|
||||
using ComputerShopContracts.StorageContracts;
|
||||
using ComputerShopContracts.ViewModels;
|
||||
|
||||
@ -10,35 +11,70 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly IComponentStorage _componentStorage;
|
||||
|
||||
public ReportGuarantorLogic(IComponentStorage ComponentStorage)
|
||||
private readonly AbstractSaveToExcelGuarantor _saveToExcel;
|
||||
private readonly AbstractSaveToWordGuarantor _saveToWord;
|
||||
private readonly AbstractSaveToPdfGuarantor _saveToPdf;
|
||||
|
||||
public ReportGuarantorLogic(IComponentStorage ComponentStorage,
|
||||
AbstractSaveToExcelGuarantor SaveToExcel, AbstractSaveToWordGuarantor SaveToWord, AbstractSaveToPdfGuarantor SaveToPdf)
|
||||
{
|
||||
_componentStorage = ComponentStorage;
|
||||
_saveToExcel = SaveToExcel;
|
||||
_saveToWord = SaveToWord;
|
||||
_saveToPdf = SaveToPdf;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение отчёта для Word или Excel
|
||||
/// </summary>
|
||||
public List<ReportComponentWithShipmentViewModel> GetReportComponentsWithShipments(List<ComponentSearchModel> SelectedComponents)
|
||||
public List<ReportComponentWithShipmentViewModel> GetReportComponentsWithShipments(List<int> SelectedComponentIds)
|
||||
{
|
||||
return _componentStorage.GetComponentsWithShipments(SelectedComponents);
|
||||
return _componentStorage.GetComponentsWithShipments(SelectedComponentIds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Получение отчёта для отправки на почту
|
||||
/// </summary>
|
||||
public List<ReportComponentByDateViewModel> GetReportComponentsByRequestDate(UserSearchModel CurrentUser, ReportBindingModel Report)
|
||||
public List<ReportComponentByDateViewModel> GetReportComponentsByRequestDate(ReportBindingModel Model)
|
||||
{
|
||||
return _componentStorage.GetComponentsByShipmentDate(Report, CurrentUser);
|
||||
return _componentStorage.GetComponentsByShipmentDate(Model);
|
||||
}
|
||||
|
||||
public void SaveReportToWordFile(ReportBindingModel Model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_saveToWord.CreateDoc(new WordInfoGuarantor
|
||||
{
|
||||
Filename = Model.FileName,
|
||||
Title = "Список сборок по выбранным заказам",
|
||||
ShipmentComponents = GetReportComponentsWithShipments(Model.Ids!)
|
||||
}); ;
|
||||
}
|
||||
|
||||
|
||||
public void SaveReportToExcelFile(ReportBindingModel Model)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
_saveToExcel.CreateReport(new ExcelInfoGuarantor
|
||||
{
|
||||
Filename = Model.FileName,
|
||||
ShipmentComponents = GetReportComponentsWithShipments(Model.Ids!)
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveReportComponentsByRequestDateToPdfFile(ReportBindingModel Model)
|
||||
{
|
||||
if (Model.DateFrom == null)
|
||||
throw new ArgumentException("Дата начала не задана");
|
||||
|
||||
if (Model.DateTo == null)
|
||||
throw new ArgumentException("Дата окончания не задана");
|
||||
|
||||
_saveToPdf.CreateDoc(new PdfInfoGuarantor
|
||||
{
|
||||
Filename = Model.FileName,
|
||||
Title = "Отчёт по комплектующим за период",
|
||||
DateFrom = Model.DateFrom!.Value,
|
||||
DateTo = Model.DateTo!.Value,
|
||||
ComponentsByDate = GetReportComponentsByRequestDate(Model)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace ComputerShopBusinessLogic.OfficePackage
|
||||
{
|
||||
@ -98,20 +97,34 @@ namespace ComputerShopBusinessLogic.OfficePackage
|
||||
Text = ComponentWithShipments.ComponentCost.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "D",
|
||||
RowIndex = RowIndex,
|
||||
Text = Shipment.ProviderName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "E",
|
||||
RowIndex = RowIndex,
|
||||
Text = Shipment.ShipmentDate.ToShortDateString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "D",
|
||||
RowIndex = RowIndex,
|
||||
Text = Shipment.ProviderName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "E",
|
||||
RowIndex = RowIndex,
|
||||
Text = Shipment.ShipmentDate.ToShortDateString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "F",
|
||||
RowIndex = RowIndex,
|
||||
Text = Shipment.ProductName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "G",
|
||||
RowIndex = RowIndex,
|
||||
Text = Shipment.ProductPrice.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
}
|
||||
ShipmentIndex++;
|
||||
if (ShipmentIndex < ShipmentsNum && !string.IsNullOrEmpty(Shipment.ProviderName))
|
||||
|
@ -1,6 +1,5 @@
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace ComputerShopBusinessLogic.OfficePackage
|
||||
{
|
||||
@ -11,7 +10,7 @@ namespace ComputerShopBusinessLogic.OfficePackage
|
||||
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", "2.5cm", "2cm", "2cm", "2cm", "4cm", "2.5cm", "3.5cm", "3.5cm", "2.5cm" });
|
||||
CreateTable(new List<string> { "3cm", "2cm", "2cm", "2cm", "2cm", "2cm", "2.5cm", "2.5cm", "3cm", "4cm" });
|
||||
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
@ -37,8 +36,6 @@ namespace ComputerShopBusinessLogic.OfficePackage
|
||||
ComponentByDate.DateRequest.ToShortDateString(),
|
||||
ComponentByDate.ClientFIO,
|
||||
},
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace ComputerShopBusinessLogic.OfficePackage
|
||||
{
|
||||
@ -26,9 +25,9 @@ namespace ComputerShopBusinessLogic.OfficePackage
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)>
|
||||
{
|
||||
("Комплектующая №" + ComponentWithShipments.ComponentId.ToString() + " - " +
|
||||
ComponentWithShipments.ComponentName.ToString() + " - " +
|
||||
ComponentWithShipments.ComponentCost.ToString() + " - ", new WordTextProperties {Size = "24", Bold=true})
|
||||
("Комплектующая №" + ComponentWithShipments.ComponentId.ToString() + " - " +
|
||||
ComponentWithShipments.ComponentName.ToString() + " - " +
|
||||
ComponentWithShipments.ComponentCost.ToString() + ":", new WordTextProperties {Size = "24", Bold=true})
|
||||
},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
@ -45,7 +44,9 @@ namespace ComputerShopBusinessLogic.OfficePackage
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> {
|
||||
(Shipment.ProviderName + " - ", new WordTextProperties { Size = "24" }),
|
||||
(Shipment.ShipmentDate.ToShortDateString() + " - ", new WordTextProperties { Size = "24" })
|
||||
(Shipment.ShipmentDate.ToShortDateString() + " - ", new WordTextProperties { Size = "24" }),
|
||||
(Shipment.ProductName + " - ", new WordTextProperties { Size = "24" }),
|
||||
(Shipment.ProductPrice.ToString(), new WordTextProperties { Size = "24" }),
|
||||
},
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
@ -54,7 +55,6 @@ namespace ComputerShopBusinessLogic.OfficePackage
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,19 +4,19 @@ namespace ComputerShopBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public class ExcelInfoGuarantor : DocumentInfo
|
||||
{
|
||||
public string Title1 { get; set; } = "ID заказа";
|
||||
public string Title1 { get; set; } = "ID комплектующей";
|
||||
|
||||
public string Title2 { get; set; } = "Дата заказа";
|
||||
public string Title2 { get; set; } = "Наименование";
|
||||
|
||||
public string Title3 { get; set; } = "Стоимость заказа";
|
||||
public string Title3 { get; set; } = "Стоимость комплектующей";
|
||||
|
||||
public string Title4 { get; set; } = "Статус заказа";
|
||||
public string Title4 { get; set; } = "Поставщик партии";
|
||||
|
||||
public string Title5 { get; set; } = "Название сборки";
|
||||
public string Title5 { get; set; } = "Дата поставки";
|
||||
|
||||
public string Title6 { get; set; } = "Категория сборки";
|
||||
public string Title6 { get; set; } = "Товар";
|
||||
|
||||
public string Title7 { get; set; } = "Цена сборки";
|
||||
public string Title7 { get; set; } = "Цена товара";
|
||||
|
||||
public List<ReportComponentWithShipmentViewModel> ShipmentComponents { get; set; } = new();
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using DocumentFormat.OpenXml.Office2013.Excel;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace ComputerShopBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
@ -171,12 +170,12 @@ namespace ComputerShopBusinessLogic.OfficePackage.Implements
|
||||
lstColumns = new Columns();
|
||||
}
|
||||
|
||||
lstColumns.Append(new Column() { Min = 1, Max = 1, Width = 10, CustomWidth = true });
|
||||
lstColumns.Append(new Column() { Min = 2, Max = 2, Width = 10, CustomWidth = true });
|
||||
lstColumns.Append(new Column() { Min = 1, Max = 1, Width = 20, CustomWidth = true });
|
||||
lstColumns.Append(new Column() { Min = 2, Max = 2, Width = 20, CustomWidth = true });
|
||||
lstColumns.Append(new Column() { Min = 3, Max = 3, Width = 20, CustomWidth = true });
|
||||
lstColumns.Append(new Column() { Min = 4, Max = 4, Width = 10, CustomWidth = true });
|
||||
lstColumns.Append(new Column() { Min = 4, Max = 4, Width = 20, CustomWidth = true });
|
||||
lstColumns.Append(new Column() { Min = 5, Max = 5, Width = 20, CustomWidth = true });
|
||||
lstColumns.Append(new Column() { Min = 6, Max = 6, Width = 20, CustomWidth = true });
|
||||
lstColumns.Append(new Column() { Min = 6, Max = 6, Width = 25, CustomWidth = true });
|
||||
lstColumns.Append(new Column() { Min = 7, Max = 7, Width = 20, CustomWidth = true });
|
||||
worksheetPart.Worksheet.InsertAt(lstColumns, 0);
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Tables;
|
||||
using MigraDoc.Rendering;
|
||||
@ -28,7 +27,7 @@ namespace ComputerShopBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
var style = document.Styles["Normal"];
|
||||
style.Font.Name = "Times New Roman";
|
||||
style.Font.Size = 14;
|
||||
style.Font.Size = 10;
|
||||
|
||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||
style.Font.Bold = true;
|
||||
@ -37,7 +36,8 @@ namespace ComputerShopBusinessLogic.OfficePackage.Implements
|
||||
protected override void CreatePdf(HelperModels.DocumentInfo Info)
|
||||
{
|
||||
_document = new Document();
|
||||
DefineStyles(_document);
|
||||
_document.DefaultPageSetup.Orientation = Orientation.Landscape;
|
||||
DefineStyles(_document);
|
||||
|
||||
_section = _document.AddSection();
|
||||
}
|
||||
@ -49,7 +49,7 @@ namespace ComputerShopBusinessLogic.OfficePackage.Implements
|
||||
return;
|
||||
}
|
||||
var paragraph = _section.AddParagraph(pdfParagraph.Text);
|
||||
paragraph.Format.SpaceAfter = "1cm";
|
||||
paragraph.Format.SpaceAfter = "0.5cm";
|
||||
paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
|
||||
paragraph.Style = pdfParagraph.Style;
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperEnums;
|
||||
using GarmentFactoryBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace ComputerShopBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using ComputerShopContracts.BindingModels;
|
||||
using ComputerShopContracts.SearchModels;
|
||||
using ComputerShopContracts.ViewModels;
|
||||
|
||||
namespace ComputerShopContracts.BusinessLogicContracts
|
||||
@ -9,15 +8,17 @@ namespace ComputerShopContracts.BusinessLogicContracts
|
||||
/// <summary>
|
||||
/// Получение отчёта для Word или Excel
|
||||
/// </summary>
|
||||
List<ReportComponentWithShipmentViewModel> GetReportComponentsWithShipments(List<ComponentSearchModel> SelectedComponents);
|
||||
List<ReportComponentWithShipmentViewModel> GetReportComponentsWithShipments(List<int> SelectedComponentIds);
|
||||
|
||||
/// <summary>
|
||||
/// Получение отчёта для отправки на почту
|
||||
/// </summary>
|
||||
List<ReportComponentByDateViewModel> GetReportComponentsByRequestDate(UserSearchModel CurrentUser, ReportBindingModel Report);
|
||||
List<ReportComponentByDateViewModel> GetReportComponentsByRequestDate(ReportBindingModel Model);
|
||||
|
||||
void SaveReportToWordFile(ReportBindingModel Model);
|
||||
|
||||
void SaveReportToExcelFile(ReportBindingModel Model);
|
||||
|
||||
void SaveReportComponentsByRequestDateToPdfFile(ReportBindingModel Model);
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,8 @@ namespace ComputerShopContracts.StorageContracts
|
||||
|
||||
ComponentViewModel? Delete(ComponentBindingModel Model);
|
||||
|
||||
List<ReportComponentWithShipmentViewModel> GetComponentsWithShipments(List<ComponentSearchModel> Models);
|
||||
List<ReportComponentWithShipmentViewModel> GetComponentsWithShipments(List<int> ComponentIds);
|
||||
|
||||
List<ReportComponentByDateViewModel> GetComponentsByShipmentDate(ReportBindingModel ReportModel, UserSearchModel UserModel);
|
||||
List<ReportComponentByDateViewModel> GetComponentsByShipmentDate(ReportBindingModel ReportModel);
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
return ExistingComponent.ViewModel;
|
||||
}
|
||||
|
||||
public List<ReportComponentWithShipmentViewModel> GetComponentsWithShipments(List<ComponentSearchModel> Models)
|
||||
public List<ReportComponentWithShipmentViewModel> GetComponentsWithShipments(List<int> ComponentIds)
|
||||
{
|
||||
using var Context = new ComputerShopDatabase();
|
||||
|
||||
@ -96,8 +96,8 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
.Include(x => x.ProductComponents)
|
||||
.ThenInclude(x => x.Product)
|
||||
.ThenInclude(x => x.Shipment)
|
||||
.Where(x =>
|
||||
Models.Select(x => x.Id).Contains(x.Id) // Компонент, указанный пользователем,
|
||||
.Where(x =>
|
||||
ComponentIds.Contains(x.Id) // Компонент, указанный пользователем,
|
||||
&& x.ProductComponents.Any(y => y.Product.Shipment != null)) // который содержится в товаре, имеющем партию товаров
|
||||
.ToList()
|
||||
.Select(x => new ReportComponentWithShipmentViewModel
|
||||
@ -106,18 +106,18 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
ComponentName = x.ComponentName,
|
||||
ComponentCost = x.Cost,
|
||||
Shipments = x.ProductComponents
|
||||
.Select(y => (0, y.Product.ProductName, y.Product.Price, y.Product.Shipment!.ProviderName, y.Product.Shipment.DateShipment))
|
||||
.Select(y => (y.Product.ProductName, y.Product.Price, y.Product.Shipment!.ProviderName, y.Product.Shipment.DateShipment))
|
||||
.ToList(),
|
||||
})
|
||||
.ToList();
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ReportComponentByDateViewModel> GetComponentsByShipmentDate(ReportBindingModel ReportModel, UserSearchModel UserModel)
|
||||
public List<ReportComponentByDateViewModel> GetComponentsByShipmentDate(ReportBindingModel ReportModel)
|
||||
{
|
||||
using var Context = new ComputerShopDatabase();
|
||||
|
||||
return Context.Components
|
||||
.Where(c => c.UserId == UserModel.Id)
|
||||
.Where(c => c.UserId == ReportModel.UserId)
|
||||
.Include(c => c.AssemblyComponents)
|
||||
.ThenInclude(ac => ac.Assembly)
|
||||
.ThenInclude(a => a.Requests.Where(r => r.DateRequest >= ReportModel.DateFrom && r.DateRequest <= ReportModel.DateTo))
|
||||
|
@ -11,7 +11,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputerShopBusinessLogic\ComputerShopBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\ComputerShopContracts\ComputerShopContracts.csproj" />
|
||||
<ProjectReference Include="..\ComputerShopDatabaseImplement\ComputerShopDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using ComputerShopContracts.BindingModels;
|
||||
using ComputerShopContracts.BusinessLogicContracts;
|
||||
using ComputerShopContracts.ViewModels;
|
||||
using ComputerShopGuarantorApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -9,10 +10,12 @@ namespace ComputerShopGuarantorApp.Controllers
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
private readonly IReportGuarantorLogic _reportLogic;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
public HomeController(ILogger<HomeController> logger, IReportGuarantorLogic ReportLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_reportLogic = ReportLogic;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
@ -89,7 +92,8 @@ namespace ComputerShopGuarantorApp.Controllers
|
||||
Response.Redirect("../Components");
|
||||
}
|
||||
|
||||
public void DeleteComponent(int Id)
|
||||
[HttpPost]
|
||||
public void DeleteComponent(int Id)
|
||||
{
|
||||
ApiUser.PostRequest($"api/component/deletecomponent", new ComponentBindingModel { Id = Id });
|
||||
Response.Redirect("../Components");
|
||||
@ -172,6 +176,7 @@ namespace ComputerShopGuarantorApp.Controllers
|
||||
Response.Redirect("../Assemblies");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteAssembly(int Id)
|
||||
{
|
||||
ApiUser.PostRequest($"api/assembly/deleteassembly", new AssemblyBindingModel { Id = Id });
|
||||
@ -259,6 +264,7 @@ namespace ComputerShopGuarantorApp.Controllers
|
||||
Response.Redirect("../Products");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteProduct(int Id)
|
||||
{
|
||||
ApiUser.PostRequest($"api/product/deleteproduct", new ProductBindingModel { Id = Id });
|
||||
@ -269,17 +275,180 @@ namespace ComputerShopGuarantorApp.Controllers
|
||||
* Отчеты
|
||||
*-----------------------------------------------------*/
|
||||
|
||||
public IActionResult ReportComponentsWithShipments()
|
||||
{
|
||||
if (ApiUser.User == null)
|
||||
return Redirect("~/Home/Enter");
|
||||
|
||||
ViewBag.Components = ApiUser.GetRequest<List<ComponentViewModel>>($"api/component/getcomponents?userId={ApiUser.User.Id}");
|
||||
return View();
|
||||
}
|
||||
|
||||
// ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ ОСТАЛЬНОЕ
|
||||
public IActionResult GetWordFile()
|
||||
{
|
||||
return PhysicalFile("C:\\!КУРСОВАЯ\\Партии товаров по выбранным компонентам.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Партии товаров по выбранным компонентам.docx");
|
||||
}
|
||||
|
||||
public IActionResult GetExcelFile()
|
||||
{
|
||||
return PhysicalFile("C:\\!КУРСОВАЯ\\Партии товаров по выбранным компонентам.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Партии товаров по выбранным компонентам.xlsx");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult ReportComponentsWithShipments(int[] ComponentIds, string Type)
|
||||
{
|
||||
if (ApiUser.User == null)
|
||||
Redirect("Index");
|
||||
|
||||
if (ComponentIds.Length > 0 && !string.IsNullOrEmpty(Type))
|
||||
{
|
||||
if (Type == "docx")
|
||||
{
|
||||
ApiUser.PostRequest("api/component/createreporttowordfile", new ReportBindingModel
|
||||
{
|
||||
Ids = ComponentIds.ToList(),
|
||||
FileName = "C:\\!КУРСОВАЯ\\Партии товаров по выбранным компонентам.docx"
|
||||
});
|
||||
return GetWordFile();
|
||||
}
|
||||
|
||||
if (Type == "xlsx")
|
||||
{
|
||||
ApiUser.PostRequest("api/component/createreporttoexcelfile", new ReportBindingModel
|
||||
{
|
||||
Ids = ComponentIds.ToList(),
|
||||
FileName = "C:\\!КУРСОВАЯ\\Партии товаров по выбранным компонентам.xlsx"
|
||||
});
|
||||
return GetExcelFile();
|
||||
}
|
||||
}
|
||||
|
||||
return Redirect("Index");
|
||||
}
|
||||
|
||||
public IActionResult ReportComponentsByRequestDate()
|
||||
{
|
||||
if (ApiUser.User == null)
|
||||
return Redirect("~/Home/Enter");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public string GetComponentsByRequestDate(DateTime DateFrom, DateTime DateTo)
|
||||
{
|
||||
if (ApiUser.User == null)
|
||||
throw new Exception("Вход только авторизованным");
|
||||
|
||||
if (DateFrom != DateTime.MinValue && DateTo != DateTime.MinValue)
|
||||
{
|
||||
List<ReportComponentByDateViewModel> Result;
|
||||
Result = _reportLogic.GetReportComponentsByRequestDate(new ReportBindingModel
|
||||
{
|
||||
UserId = ApiUser.User.Id,
|
||||
DateFrom = DateFrom,
|
||||
DateTo = DateTo
|
||||
});
|
||||
string Table = string.Empty;
|
||||
|
||||
Table += $"<table class=\"u-table-entity\">";
|
||||
Table += "<colgroup>";
|
||||
|
||||
// ID комплектующей
|
||||
Table += "<col width=\"7%\" />";
|
||||
// Название
|
||||
Table += "<col width=\"8%\" />";
|
||||
// Стоимость
|
||||
Table += "<col width=\"8%\" />";
|
||||
// ID сборки
|
||||
Table += "<col width=\"7%\" />";
|
||||
// Название сборки
|
||||
Table += "<col width=\"13%\" />";
|
||||
// Цена сборки
|
||||
Table += "<col width=\"10%\" />";
|
||||
// Категория
|
||||
Table += "<col width=\"8%\" />";
|
||||
// ID заявки
|
||||
Table += "<col width=\"8%\" />";
|
||||
// Дата заявки
|
||||
Table += "<col width=\"10%\" />";
|
||||
// ФИО клиента
|
||||
Table += "<col width=\"12%\" />";
|
||||
|
||||
Table += "</colgroup>";
|
||||
Table += "<thead class=\"u-custom-color-1 u-table-header u-table-header-1\">";
|
||||
Table += "<tr style=\"height: 31px\">";
|
||||
|
||||
Table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">ID комплектующей</th>";
|
||||
Table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Название</th>";
|
||||
Table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Стоимость</th>";
|
||||
Table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">ID сборки</th>";
|
||||
Table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Название сборки</th>";
|
||||
Table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Цена сборки</th>";
|
||||
Table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Категория</th>";
|
||||
Table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">ID заявки</th>";
|
||||
Table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Дата заявки</th>";
|
||||
Table += $"<th class=\"u-border-1 u-border-grey-50 u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">Клиент</th>";
|
||||
|
||||
Table += "</tr>";
|
||||
Table += "</thead>";
|
||||
Table += "<tbody class=\"u-table-body\">";
|
||||
|
||||
foreach (var ComponentByDate in Result)
|
||||
{
|
||||
Table += "<tr style=\"height: 75px\">";
|
||||
Table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{ComponentByDate.ComponentId}</td>";
|
||||
Table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{ComponentByDate.ComponentName}</td>";
|
||||
Table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{ComponentByDate.ComponentCost}</td>";
|
||||
Table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{ComponentByDate.AssemblyId}</td>";
|
||||
Table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{ComponentByDate.AssemblyName}</td>";
|
||||
Table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{ComponentByDate.AssemblyPrice}</td>";
|
||||
Table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{ComponentByDate.AssemblyCategory}</td>";
|
||||
Table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{ComponentByDate.RequestId}</td>";
|
||||
Table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{ComponentByDate.DateRequest.ToShortDateString()}</td>";
|
||||
Table += $"<td class=\"u-border-1 u-border-grey-40 u-border-no-left u-border-no-right u-table-cell\" style=\"text-align:center; border: 1px solid black; border-collapse:collapse\">{ComponentByDate.ClientFIO}</td>";
|
||||
|
||||
Table += "</tr>";
|
||||
}
|
||||
Table += "</table>";
|
||||
return Table;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void ReportComponentsByRequestDate(DateTime DateFrom, DateTime DateTo)
|
||||
{
|
||||
if (ApiUser.User == null)
|
||||
{
|
||||
throw new Exception("Вход только авторизованным");
|
||||
}
|
||||
|
||||
if (DateFrom != DateTime.MinValue && DateTo != DateTime.MinValue)
|
||||
{
|
||||
ApiUser.PostRequest("api/component/createreporttopdffile", new ReportBindingModel
|
||||
{
|
||||
FileName = "C:\\!КУРСОВАЯ\\Отчёт за период.pdf",
|
||||
DateFrom = DateFrom,
|
||||
DateTo = DateTo,
|
||||
UserId = ApiUser.User.Id
|
||||
});
|
||||
ApiUser.PostRequest("api/component/sendpdftomail", new MailSendInfoBindingModel
|
||||
{
|
||||
MailAddress = ApiUser.User.Email,
|
||||
Subject = "Отчет за период",
|
||||
Text = "Отчет по компонентам с " + DateFrom.ToShortDateString() + " по " + DateTo.ToShortDateString()
|
||||
});
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
if (ApiUser.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
|
||||
return View(ApiUser.User);
|
||||
}
|
||||
|
||||
@ -287,13 +456,11 @@ namespace ComputerShopGuarantorApp.Controllers
|
||||
public void Privacy(string Login, string Password, string Email)
|
||||
{
|
||||
if (ApiUser.User == null)
|
||||
{
|
||||
throw new Exception("Вход только авторизованным");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(Login) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(Email))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и почту");
|
||||
}
|
||||
|
||||
ApiUser.PostRequest("api/user/updatedata", new UserBindingModel
|
||||
{
|
||||
Id = ApiUser.User.Id,
|
||||
@ -305,6 +472,7 @@ namespace ComputerShopGuarantorApp.Controllers
|
||||
ApiUser.User.Login = Login;
|
||||
ApiUser.User.Password = Password;
|
||||
ApiUser.User.Email = Email;
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
@ -323,14 +491,12 @@ namespace ComputerShopGuarantorApp.Controllers
|
||||
public void Enter(string Login, string Password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Login) || string.IsNullOrEmpty(Password))
|
||||
{
|
||||
throw new Exception("Введите логин и пароль");
|
||||
}
|
||||
|
||||
ApiUser.User = ApiUser.GetRequest<UserViewModel>($"api/user/loginguarantor?login={Login}&password={Password}");
|
||||
if (ApiUser.User == null)
|
||||
{
|
||||
throw new Exception("Неверный логин или пароль");
|
||||
}
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
@ -343,9 +509,8 @@ namespace ComputerShopGuarantorApp.Controllers
|
||||
public void Register(string Login, string Password, string Email)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Login) || string.IsNullOrEmpty(Password) || string.IsNullOrEmpty(Email))
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и почту");
|
||||
}
|
||||
|
||||
ApiUser.PostRequest("api/user/registerguarantor", new UserBindingModel
|
||||
{
|
||||
Login = Login,
|
||||
@ -353,12 +518,18 @@ namespace ComputerShopGuarantorApp.Controllers
|
||||
Email = Email
|
||||
});
|
||||
ApiUser.User = ApiUser.GetRequest<UserViewModel>($"api/user/loginguarantor?login={Login}&password={Password}");
|
||||
if (ApiUser.User == null)
|
||||
{
|
||||
Response.Redirect("Enter");
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
|
||||
if (ApiUser.User == null)
|
||||
Response.Redirect("Enter");
|
||||
|
||||
Response.Redirect("Index");
|
||||
return;
|
||||
}
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
ApiUser.User = null;
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,21 @@
|
||||
using ComputerShopBusinessLogic.BusinessLogics;
|
||||
using ComputerShopBusinessLogic.OfficePackage;
|
||||
using ComputerShopBusinessLogic.OfficePackage.Implements;
|
||||
using ComputerShopContracts.BusinessLogicContracts;
|
||||
using ComputerShopContracts.StorageContracts;
|
||||
using ComputerShopDatabaseImplement.Implements;
|
||||
using ComputerShopGuarantorApp;
|
||||
|
||||
var Builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
//Builder.Services.AddTransient<IUserStorage, UserStorage>();
|
||||
Builder.Services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
|
||||
Builder.Services.AddTransient<IReportGuarantorLogic, ReportGuarantorLogic>();
|
||||
Builder.Services.AddTransient<AbstractSaveToWordGuarantor, SaveToWordGuarantor>();
|
||||
Builder.Services.AddTransient<AbstractSaveToExcelGuarantor, SaveToExcelGuarantor>();
|
||||
Builder.Services.AddTransient<AbstractSaveToPdfGuarantor, SaveToPdfGuarantor>();
|
||||
|
||||
// Add services to the container.
|
||||
Builder.Services.AddControllersWithViews();
|
||||
|
||||
|
@ -20,23 +20,23 @@
|
||||
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Название:</label>
|
||||
<label class="mb-1">Название:</label>
|
||||
<input type="text" name="assemblyName" class="mb-3 form-control" value="@(Model?.AssemblyName ?? "")">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Цена:</label>
|
||||
<label class="mb-1">Цена:</label>
|
||||
<input type="number" name="price" class="mb-3 form-control" value="@(Model?.Price ?? 0.00)" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Категория:</label>
|
||||
<label class="mb-1">Категория:</label>
|
||||
<input type="text" name="category" class="mb-3 form-control" value="@(Model?.Category ?? "")">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Комплектующие:</label>
|
||||
<select name="componentIds" class="form-control border border-dark rounded" multiple size="6">
|
||||
<label class="mb-1">Комплектующие:</label>
|
||||
<select name="componentIds" class="form-control border border-dark rounded mb-3" multiple size="6">
|
||||
@foreach (var Component in ViewBag.Components)
|
||||
{
|
||||
@if (Model != null && Model.AssemblyComponents.Values.Any(x => Component.Id == x.Id))
|
||||
@ -51,11 +51,6 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Сохранить" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" value="Сохранить" class="btn btn-primary my-2" />
|
||||
</form>
|
||||
</div>
|
||||
|
@ -20,20 +20,15 @@
|
||||
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Наименование:</label>
|
||||
<label class="mb-1">Наименование:</label>
|
||||
<input type="text" name="componentName" class="mb-3 form-control" value="@(Model == null ? "" : Model.ComponentName)">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Стоимость:</label>
|
||||
<label class="mb-1">Стоимость:</label>
|
||||
<input type="number" name="cost" class="mb-3 form-control" step="1" value="@(Model == null ? 0 : Model.Cost)">
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Сохранить" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" value="Сохранить" class="btn btn-primary my-2" />
|
||||
</form>
|
||||
</div>
|
||||
|
@ -1,6 +1,34 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
@using ComputerShopContracts.ViewModels
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
||||
@model UserViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Профиль";
|
||||
}
|
||||
|
||||
<div class="container-md py-4 mb-4">
|
||||
<div class="text-center">
|
||||
<h2>Профиль поручителя</h2>
|
||||
<p class="lead text-muted">На этой странице можно изменить данные или выйти из аккаунта</p>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label class="mb-1">Логин:</label>
|
||||
<input type="text" name="login" class="mb-3 form-control" value="@Model.Login" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="mb-1">Почта:</label>
|
||||
<input type="email" name="email" class="mb-3 form-control" value="@Model.Email" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="mb-1">Пароль:</label>
|
||||
<input type="password" name="password" class="mb-3 form-control" value="@Model.Password" />
|
||||
</div>
|
||||
|
||||
<div class="flex-column mt-2">
|
||||
<input type="submit" value="Сохранить" class="btn btn-primary" />
|
||||
<a class="btn btn-danger ms-2" asp-area="" asp-controller="Home" asp-action="Logout">Выйти</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -20,23 +20,23 @@
|
||||
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Название:</label>
|
||||
<label class="mb-1">Название:</label>
|
||||
<input type="text" name="productName" class="mb-3 form-control" value="@(Model?.ProductName ?? "")">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Цена:</label>
|
||||
<label class="mb-1">Цена:</label>
|
||||
<input type="number" name="price" class="mb-3 form-control" value="@(Model?.Price ?? 0.00)" readonly>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Гарантия:</label>
|
||||
<label class="mb-1">Гарантия:</label>
|
||||
<input type="number" name="warranty" class="mb-3 form-control" value="@(Model?.Warranty ?? 0)">
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Комплектующие:</label>
|
||||
<select name="componentIds" class="form-control border border-dark rounded" multiple size="6">
|
||||
<label class="mb-1">Комплектующие:</label>
|
||||
<select name="componentIds" class="form-control border border-dark rounded mb-3" multiple size="6">
|
||||
@foreach (var Component in ViewBag.Components)
|
||||
{
|
||||
@if (Model != null && Model.ProductComponents.Values.Any(x => Component.Id == x.Id))
|
||||
@ -52,8 +52,8 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="mb-3">Поставщик:</label>
|
||||
<select name="shipmentId" class="form-control border border-dark rounded" size="4">
|
||||
<label class="mb-1">Поставщик:</label>
|
||||
<select name="shipmentId" class="form-control border border-dark rounded mb-3" size="4">
|
||||
@foreach (var Shipment in ViewBag.Shipments)
|
||||
{
|
||||
@if (Model != null && Model.ShipmentId == Shipment.Id)
|
||||
@ -68,11 +68,6 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Сохранить" class="btn btn-primary" />
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" value="Сохранить" class="btn btn-primary my-2" />
|
||||
</form>
|
||||
</div>
|
||||
|
@ -0,0 +1,54 @@
|
||||
@using ComputerShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Комплектующие по дате поставки";
|
||||
}
|
||||
|
||||
<div class="container-md py-4 mb-4">
|
||||
<div class="text-center">
|
||||
<h2>Получение сведений за период по комплектующим</h2>
|
||||
<p class="lead text-muted">Информация о комплектующих, которые указывались в сборках и заявках</p>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label class="mb-3" for="dateFrom">Начальная дата:</label>
|
||||
<input type="datetime-local" placeholder="Выберите дату начала периода" id="dateFrom" name="dateFrom" />
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="mb-3" for="dateTo">Конечная дата:</label>
|
||||
<input type="datetime-local" placeholder="Выберите дату окончания периода" id="dateTo" name="dateTo" />
|
||||
</div>
|
||||
<div class="flex-column mt-2">
|
||||
<input type="submit" value="Отправить на почту" class="btn btn-primary" />
|
||||
<button class="btn btn-dark ms-2" type="button" id="show">Вывести</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="mt-3" id="report">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
function check() {
|
||||
console.log('Check was called!');
|
||||
var dateFrom = $('#dateFrom').val();
|
||||
var dateTo = $('#dateTo').val();
|
||||
if (dateFrom && dateTo) {
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetComponentsByRequestDate",
|
||||
data: { dateFrom: dateFrom, dateTo: dateTo },
|
||||
success: function (result) {
|
||||
if (result != null) {
|
||||
$('#report').html(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
$('#show').on('click', (e) => check());
|
||||
</script>
|
@ -0,0 +1,43 @@
|
||||
@using ComputerShopContracts.ViewModels
|
||||
@{
|
||||
ViewData["Title"] = "Комплектующие";
|
||||
}
|
||||
|
||||
<div class="container-md py-4 mb-4">
|
||||
<div class="text-center">
|
||||
<h2>Получение списка партий товаров по выбранным комплектующим</h2>
|
||||
<p class="lead text-muted">Укажите комплектующие, для который вы хотите получить список партий товаров, и выберите тип файла для отчета</p>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
<label class="pt-3 mb-3">Выберите комплектующие:</label>
|
||||
<select multiple name="componentIds" class="form-control mb-3">
|
||||
@foreach (var Component in ViewBag.Components)
|
||||
{
|
||||
<option value="@Component.Id">[@Component.Id] @Component.ComponentName</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<div class="pb-3">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1">
|
||||
Выберите формат файла:
|
||||
</label>
|
||||
<div class="form-check form-check-inline ms-3">
|
||||
<input class="form-check-input" type="radio" name="type" value="docx" checked>
|
||||
<label class="u-label u-text-custom-color-1 u-label-1" for="docx">
|
||||
Word-файл
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="radio" name="type" value="xlsx" id="xlsx">
|
||||
<label class="u-label u-text-custom-color-1 u-label-1" for="xlsx">
|
||||
Excel-файл
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
<input type="submit" value="Получить отчёт" class="btn btn-primary" />
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
@ -8,6 +8,8 @@
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css">
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/ComputerShopGuarantorApp.styles.css" asp-append-version="true" />
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
@ -33,10 +35,10 @@
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Products">Товары</a>
|
||||
</li>
|
||||
<li class="nav-item me-3">
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Index">Отчет</a>
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="ReportComponentsWithShipments">Получение списка</a>
|
||||
</li>
|
||||
<li class="nav-item me-3">
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Index">Выгрузка списка</a>
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="ReportComponentsByRequestDate">Сведения за период</a>
|
||||
</li>
|
||||
|
||||
@if (ApiUser.User == null)
|
||||
@ -70,7 +72,7 @@
|
||||
|
||||
<footer class="bg-dark text-light mt-auto footer">
|
||||
<div class="container">
|
||||
© 2024 - "Ты ж программист" @* - <a asp-area="" asp-controller="Home" asp-action="Privacy" class="text-decoration-underline text-secondary">Privacy</a> *@
|
||||
© 2024 - "Ты ж программист"
|
||||
</div>
|
||||
</footer>
|
||||
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||
|
@ -1,4 +1,5 @@
|
||||
using ComputerShopContracts.BindingModels;
|
||||
using ComputerShopBusinessLogic.MailWorker;
|
||||
using ComputerShopContracts.BindingModels;
|
||||
using ComputerShopContracts.BusinessLogicContracts;
|
||||
using ComputerShopContracts.SearchModels;
|
||||
using ComputerShopContracts.ViewModels;
|
||||
@ -12,11 +13,15 @@ namespace ComputerShopRestApi.Controllers
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IComponentLogic _componentLogic;
|
||||
private readonly IReportGuarantorLogic _reportLogic;
|
||||
private readonly AbstractMailWorker _mailWorker;
|
||||
|
||||
public ComponentController(IComponentLogic Logic, ILogger<ComponentController> Logger)
|
||||
public ComponentController(IComponentLogic Logic, ILogger<ComponentController> Logger, IReportGuarantorLogic ReportLogic, AbstractMailWorker MailWorker)
|
||||
{
|
||||
_logger = Logger;
|
||||
_componentLogic = Logic;
|
||||
_reportLogic = ReportLogic;
|
||||
_mailWorker = MailWorker;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -94,5 +99,62 @@ namespace ComputerShopRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateReportToWordFile(ReportBindingModel Model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SaveReportToWordFile(Model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateReportToExcelFile(ReportBindingModel Model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_reportLogic.SaveReportToExcelFile(Model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateReportToPdfFile(ReportBindingModel Model)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
||||
_reportLogic.SaveReportComponentsByRequestDateToPdfFile(Model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания отчета");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void SendPdfToMail(MailSendInfoBindingModel Model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_mailWorker.MailSendAsync(Model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отправки письма");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,10 @@ Builder.Services.AddTransient<AbstractSaveToExcelImplementer, SaveToExcelImpleme
|
||||
Builder.Services.AddTransient<AbstractSaveToWordImplementer, SaveToWordImplementer>();
|
||||
Builder.Services.AddTransient<AbstractSaveToPdfImplementer, SaveToPdfImplementer>();
|
||||
|
||||
Builder.Services.AddTransient<AbstractSaveToExcelGuarantor, SaveToExcelGuarantor>();
|
||||
Builder.Services.AddTransient<AbstractSaveToWordGuarantor, SaveToWordGuarantor>();
|
||||
Builder.Services.AddTransient<AbstractSaveToPdfGuarantor, SaveToPdfGuarantor>();
|
||||
|
||||
Builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
|
||||
Builder.Services.AddControllers();
|
||||
|
Loading…
Reference in New Issue
Block a user