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