This commit is contained in:
m1aksim1 2023-03-20 20:34:36 +04:00
parent 76c4c7c18d
commit 04aca8c706
15 changed files with 65 additions and 35 deletions

View File

@ -34,6 +34,13 @@ namespace SoftwareInstallationFileImplement.Implements
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) // если не ищем по айдишнику, значит ищем по диапазону дат
{
return _source.Orders
.Where(x => model.DateFrom <= x.DateCreate.Date && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
var result = GetElement(model);
return result != null ? new() { result } : new();
}

View File

@ -31,25 +31,16 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics
/// <returns></returns>
public List<ReportPackageComponentViewModel> GetPackageComponent()
{
var components = _componentStorage.GetFullList();
var packages = _packageStorage.GetFullList();
var list = new List<ReportPackageComponentViewModel>();
foreach (var component in components)
foreach (var package in packages)
{
var record = new ReportPackageComponentViewModel
{
ComponentName = component.ComponentName,
Packages = new List<Tuple<string, int>>(),
TotalCount = 0
PackageName = package.PackageName,
Components = package.PackageComponents.Values.Select(x => Tuple.Create(x.Item1.ComponentName, x.Item2)).ToList(),
TotalCount = package.PackageComponents.Values.Select(x => x.Item2).Sum(),
};
foreach (var package in packages)
{
if (package.PackageComponents.ContainsKey(component.Id))
{
record.Packages.Add(new Tuple<string, int>(package.PackageName, package.PackageComponents[component.Id].Item2));
record.TotalCount += package.PackageComponents[component.Id].Item2;
}
}
list.Add(record);
}
return list;
@ -65,12 +56,14 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics
{
DateFrom = model.DateFrom,
DateTo = model.DateTo
})
.Select(x => new ReportOrdersViewModel
{
Id = x.Id,
DateCreate = x.DateCreate,
PackageName = x.PackageName,
OrderStatus = x.Status.ToString(),
Sum = x.Sum
})
.ToList();
@ -85,7 +78,7 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics
{
FileName = model.FileName,
Title = "Список компонент",
Components = _componentStorage.GetFullList()
Packages = _packageStorage.GetFullList()
});
}
/// <summary>

View File

@ -31,11 +31,11 @@ namespace SoftwareInstallationBusinessLogic.OfficePackage
{
ColumnName = "A",
RowIndex = rowIndex,
Text = pc.ComponentName,
Text = pc.PackageName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var package in pc.Packages)
foreach (var package in pc.Components)
{
InsertCellInWorksheet(new ExcelCellParameters
{

View File

@ -21,10 +21,10 @@ namespace SoftwareInstallationBusinessLogic.OfficePackage
Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm" });
CreateTable(new List<string> { "2cm", "3cm", "6cm", "4cm", "3cm" });
CreateRow(new PdfRowParameters
{
Texts = new List<string> { "Номер", "Дата заказа", "Изделие","Сумма" },
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус заказа", "Сумма" },
Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center
});
@ -32,7 +32,7 @@ namespace SoftwareInstallationBusinessLogic.OfficePackage
{
CreateRow(new PdfRowParameters
{
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PackageName, order.Sum.ToString() },
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PackageName, Convert.ToString(order.OrderStatus), order.Sum.ToString() },
Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left
});

View File

@ -1,6 +1,5 @@
using SoftwareInstallationBusinessLogic.OfficePackage.HelperEnums;
using SoftwareInstallationBusinessLogic.OfficePackage.HelperModels;
using System.Collections.Generic;
namespace SoftwareInstallationBusinessLogic.OfficePackage
{
@ -11,20 +10,22 @@ namespace SoftwareInstallationBusinessLogic.OfficePackage
CreateWord(info);
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> { (info.Title, new
WordTextProperties { Bold = true, Size = "24", }) },
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
TextProperties = new WordTextProperties
{
Size = "24",
JustificationType = WordJustificationType.Center
}
});
foreach (var component in info.Components)
foreach (var package in info.Packages)
{
CreateParagraph(new WordParagraph
{
Texts = new List<(string, WordTextProperties)> {
(component.ComponentName, new WordTextProperties { Size = "24", }) },
Texts = new List<(string, WordTextProperties)>
{
(package.PackageName, new WordTextProperties { Size = "24", Bold = true}),
(" - цена: " + package.Price.ToString(), new WordTextProperties { Size = "24" })
},
TextProperties = new WordTextProperties
{
Size = "24",

View File

@ -6,6 +6,6 @@ namespace SoftwareInstallationBusinessLogic.OfficePackage.HelperModels
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ComponentViewModel> Components { get; set; } = new();
public List<PackageViewModel> Packages { get; set; } = new();
}
}

View File

@ -2,8 +2,8 @@
{
public class ReportPackageComponentViewModel
{
public string ComponentName { get; set; } = string.Empty;
public string PackageName { get; set; } = string.Empty;
public int TotalCount { get; set; }
public List<Tuple<string, int>> Packages { get; set; } = new();
public List<Tuple<string, int>> Components { get; set; } = new();
}
}

View File

@ -36,6 +36,15 @@ namespace SoftwareInstallationDatabaseImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) // если не ищем по айдишнику, значит ищем по диапазону дат
{
using var context = new SoftwareInstallationDatabase();
return context.Orders
.Include(x => x.Package)
.Where(x => model.DateFrom <= x.DateCreate.Date && x.DateCreate <= model.DateTo)
.Select(x => x.GetViewModel)
.ToList();
}
var result = GetElement(model);
return result != null ? new() { result } : new();
}

View File

@ -54,6 +54,10 @@ namespace SoftwareInstallationListImplement.Implements
{
return new() { order.GetViewModel };
}
if(model.DateFrom != null && model.DateTo != null && model.DateFrom <= order.DateCreate.Date && order.DateCreate <= model.DateTo)
{
result.Add(order.GetViewModel);
}
}
return result;
}

View File

@ -10,11 +10,12 @@ namespace SoftwareInstallationView
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
_reportLogic = reportLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{

View File

@ -45,8 +45,7 @@ namespace SoftwareInstallationView
var source = new ReportDataSource("DataSetOrders", dataSource);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(source);
var parameters = new[] { new ReportParameter("ReportParameterPeriod",
$"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") };
var parameters = new[] { new ReportParameter("ReportParameterPeriod",$"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") };
reportViewer.LocalReport.SetParameters(parameters);
reportViewer.RefreshReport();

View File

@ -23,8 +23,8 @@ namespace SoftwareInstallationView
dataGridView.Rows.Clear();
foreach (var elem in dict)
{
dataGridView.Rows.Add(new object[] { elem.ComponentName,"", "" });
foreach (var listElem in elem.Packages)
dataGridView.Rows.Add(new object[] { elem.PackageName,"", "" });
foreach (var listElem in elem.Components)
{
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
}

View File

@ -5,6 +5,9 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using SoftwareInstallationBusinessLogic.BusinessLogic;
using SoftwareInstallationBusinessLogic.BusinessLogics;
using SoftwareInstallationBusinessLogic.OfficePackage.Implements;
using SoftwareInstallationBusinessLogic.OfficePackage;
namespace SoftwareInstallationView
{
@ -40,6 +43,11 @@ namespace SoftwareInstallationView
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IPackageLogic, PackageLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
@ -48,6 +56,9 @@ namespace SoftwareInstallationView
services.AddTransient<FormPackage>();
services.AddTransient<FormPackageComponent>();
services.AddTransient<FormPackages>();
services.AddTransient<FormReportOrders>();
services.AddTransient<FormReportPackageComponents>();
}
}
}

View File

@ -424,7 +424,6 @@
<PaddingBottom>2pt</PaddingBottom>
</Style>
</Textbox>
<rd:Selected>true</rd:Selected>
</CellContents>
</TablixCell>
<TablixCell>
@ -484,7 +483,7 @@
<Top>2.48391cm</Top>
<Left>0.55245cm</Left>
<Height>1.2cm</Height>
<Width>19.84713cm</Width>
<Width>19.84714cm</Width>
<ZIndex>2</ZIndex>
<Style>
<Border>

View File

@ -27,4 +27,10 @@
<ProjectReference Include="..\SoftwareInstallationListImplement\SoftwareInstallationListImplement.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="ReportOrders.rdlc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>