закончил
This commit is contained in:
parent
660d0d6e41
commit
06037f119b
@ -1,14 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ProjectCompRepair.Entities;
|
||||
using ProjectCompRepair.Reports;
|
||||
using ProjectCompRepair.Reports;
|
||||
using ProjectCompRepair.Repositories;
|
||||
using Unity;
|
||||
|
||||
@ -23,11 +13,10 @@ namespace ProjectCompRepair.Forms
|
||||
public FormAccessoriesOrderReport(IUnityContainer container, IAccessoriesRepository accessoriesRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
comboBoxAccessories.DataSource = accessoriesRepository.ReadAccessories();
|
||||
comboBoxAccessories.ValueMember = "Id";
|
||||
comboBoxAccessories.DisplayMember = "AccessoriesType";
|
||||
comboBoxAccessories.ValueMember = "Id";
|
||||
|
||||
}
|
||||
|
||||
@ -54,8 +43,8 @@ namespace ProjectCompRepair.Forms
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
}
|
||||
|
||||
if
|
||||
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.Value, (int)comboBoxAccessories.SelectedValue!))
|
||||
if (_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.Value,
|
||||
(int)comboBoxAccessories.SelectedValue!, comboBoxAccessories.Text))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован",
|
||||
"Формирование документа",
|
||||
|
@ -21,7 +21,7 @@ public partial class FormAccessoriesReport : Form
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
comboBoxAccessories.DataSource = accessoriesRepository.ReadAccessories();
|
||||
comboBoxAccessories.DisplayMember = "Name";
|
||||
comboBoxAccessories.DisplayMember = "AccessoriesType";
|
||||
comboBoxAccessories.ValueMember = "Id";
|
||||
|
||||
}
|
||||
@ -59,7 +59,7 @@ public partial class FormAccessoriesReport : Form
|
||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||
}
|
||||
|
||||
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxAccessories.SelectedValue!, dateTimePickerDateBegin.Value, dateTimePickerDateEnd.Value))
|
||||
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxAccessories.SelectedValue!, dateTimePickerDateBegin.Value, dateTimePickerDateEnd.Value, comboBoxAccessories.Text))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectCompRepair.Entities;
|
||||
using ProjectCompRepair.Entities.Enums;
|
||||
using ProjectCompRepair.Repositories;
|
||||
using ProjectCompRepair.Repositories.Implemantations;
|
||||
using RegistrationOfPatients.Reports;
|
||||
@ -22,13 +23,13 @@ internal class ChartReport
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateChart(string filePath, DateTime dateTime, int accessoriesId)
|
||||
public bool CreateChart(string filePath, DateTime dateTime, int accessoriesId, string accessoriesType)
|
||||
{
|
||||
try
|
||||
{
|
||||
new PdfBuilder(filePath)
|
||||
.AddHeader("Комплектующие")
|
||||
.AddPieChart("потраченные комплектующие", GetData(dateTime, accessoriesId))
|
||||
.AddPieChart($"потраченные комплектующие типа {accessoriesType.ToString()} за {dateTime : dd.MM.yyyy}", GetData(dateTime, accessoriesId))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
@ -43,12 +44,12 @@ internal class ChartReport
|
||||
{
|
||||
return _orderRepository
|
||||
.ReadOrder(dateTo: dateTime.Date.AddDays(1), accessoriesId: accessoriesId)
|
||||
.GroupBy(x => x.Id, (key, group) => new
|
||||
.GroupBy(x => x.Name, (key, group) => new
|
||||
{
|
||||
Id = key,
|
||||
Name = key,
|
||||
Count = group.Sum(x => x.AccessoiresOrders.FirstOrDefault(y => y.AccessoriesId == accessoriesId)?.Count ?? 0)
|
||||
})
|
||||
.Select(x => (x.Id.ToString(), (double)x.Count))
|
||||
.Select(x => (x.Name.ToString(), (double)x.Count))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
@ -25,12 +25,12 @@ internal class TableReport
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateTable(string filePath, int accessoriesId, DateTime startDate, DateTime endDate)
|
||||
public bool CreateTable(string filePath, int accessoriesId, DateTime startDate, DateTime endDate, string accessoriesType)
|
||||
{
|
||||
try
|
||||
{
|
||||
new ExcelBuilder(filePath)
|
||||
.AddHeader("Поставка комплектующих", 0, 3)
|
||||
.AddHeader($"Поставка комплектующих {accessoriesType}", 0, 3)
|
||||
.AddParagraph($"за период {startDate: dd.MM.yyyy} по {endDate: dd.MM.yyyy}", 0)
|
||||
.AddTable([10, 15, 15], GetData(accessoriesId, startDate, endDate))
|
||||
.Build();
|
||||
|
Loading…
x
Reference in New Issue
Block a user