s
This commit is contained in:
parent
a0db0595f1
commit
51d95da83b
@ -28,12 +28,135 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
dateTimePickerDateEnd = new DateTimePicker();
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
dateTimePickerDateBegin = new DateTimePicker();
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
textBoxFilePath = new TextBox();
|
||||||
this.Text = "FormAccessoriesReport";
|
buttonSelectFilePath = new Button();
|
||||||
|
comboBoxAccessories = new ComboBox();
|
||||||
|
label1 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
label4 = new Label();
|
||||||
|
buttonMakeReport = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dateTimePickerDateEnd
|
||||||
|
//
|
||||||
|
dateTimePickerDateEnd.Location = new Point(173, 232);
|
||||||
|
dateTimePickerDateEnd.Name = "dateTimePickerDateEnd";
|
||||||
|
dateTimePickerDateEnd.Size = new Size(200, 23);
|
||||||
|
dateTimePickerDateEnd.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// dateTimePickerDateBegin
|
||||||
|
//
|
||||||
|
dateTimePickerDateBegin.Location = new Point(173, 192);
|
||||||
|
dateTimePickerDateBegin.Name = "dateTimePickerDateBegin";
|
||||||
|
dateTimePickerDateBegin.Size = new Size(200, 23);
|
||||||
|
dateTimePickerDateBegin.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// textBoxFilePath
|
||||||
|
//
|
||||||
|
textBoxFilePath.Location = new Point(173, 81);
|
||||||
|
textBoxFilePath.Name = "textBoxFilePath";
|
||||||
|
textBoxFilePath.Size = new Size(168, 23);
|
||||||
|
textBoxFilePath.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// buttonSelectFilePath
|
||||||
|
//
|
||||||
|
buttonSelectFilePath.Location = new Point(347, 81);
|
||||||
|
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
||||||
|
buttonSelectFilePath.Size = new Size(26, 23);
|
||||||
|
buttonSelectFilePath.TabIndex = 3;
|
||||||
|
buttonSelectFilePath.Text = "button1";
|
||||||
|
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
||||||
|
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
||||||
|
//
|
||||||
|
// comboBoxAccessories
|
||||||
|
//
|
||||||
|
comboBoxAccessories.FormattingEnabled = true;
|
||||||
|
comboBoxAccessories.Location = new Point(173, 138);
|
||||||
|
comboBoxAccessories.Name = "comboBoxAccessories";
|
||||||
|
comboBoxAccessories.Size = new Size(200, 23);
|
||||||
|
comboBoxAccessories.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(60, 84);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(38, 15);
|
||||||
|
label1.TabIndex = 5;
|
||||||
|
label1.Text = "label1";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(60, 141);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(38, 15);
|
||||||
|
label2.TabIndex = 6;
|
||||||
|
label2.Text = "label2";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(60, 198);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(38, 15);
|
||||||
|
label3.TabIndex = 7;
|
||||||
|
label3.Text = "label3";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(60, 238);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(38, 15);
|
||||||
|
label4.TabIndex = 8;
|
||||||
|
label4.Text = "label4";
|
||||||
|
//
|
||||||
|
// buttonMakeReport
|
||||||
|
//
|
||||||
|
buttonMakeReport.Location = new Point(153, 317);
|
||||||
|
buttonMakeReport.Name = "buttonMakeReport";
|
||||||
|
buttonMakeReport.Size = new Size(75, 23);
|
||||||
|
buttonMakeReport.TabIndex = 9;
|
||||||
|
buttonMakeReport.Text = "button2";
|
||||||
|
buttonMakeReport.UseVisualStyleBackColor = true;
|
||||||
|
buttonMakeReport.Click += ButtonMakeReport_Click;
|
||||||
|
//
|
||||||
|
// FormAccessoriesReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(buttonMakeReport);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(comboBoxAccessories);
|
||||||
|
Controls.Add(buttonSelectFilePath);
|
||||||
|
Controls.Add(textBoxFilePath);
|
||||||
|
Controls.Add(dateTimePickerDateBegin);
|
||||||
|
Controls.Add(dateTimePickerDateEnd);
|
||||||
|
Name = "FormAccessoriesReport";
|
||||||
|
Text = "FormAccessoriesReport";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private DateTimePicker dateTimePickerDateEnd;
|
||||||
|
private DateTimePicker dateTimePickerDateBegin;
|
||||||
|
private TextBox textBoxFilePath;
|
||||||
|
private Button buttonSelectFilePath;
|
||||||
|
private ComboBox comboBoxAccessories;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private Button buttonMakeReport;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using ProjectCompRepair.Reports;
|
using ProjectCompRepair.Reports;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@ -15,13 +16,13 @@ namespace ProjectCompRepair.Forms;
|
|||||||
public partial class FormAccessoriesReport : Form
|
public partial class FormAccessoriesReport : Form
|
||||||
{
|
{
|
||||||
private readonly IUnityContainer _container;
|
private readonly IUnityContainer _container;
|
||||||
public FormAccessoriesReport()
|
public FormAccessoriesReport(IUnityContainer container, IAccessoriesRepository accessoriesRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
comboBoxFeed.DataSource = feedRepository.ReadFeeds();
|
comboBoxAccessories.DataSource = accessoriesRepository.ReadAccessories();
|
||||||
comboBoxFeed.DisplayMember = "Name";
|
comboBoxAccessories.DisplayMember = "Name";
|
||||||
comboBoxFeed.ValueMember = "Id";
|
comboBoxAccessories.ValueMember = "Id";
|
||||||
|
|
||||||
}
|
}
|
||||||
private void ButtonSelectFilePath_Click(object sender, EventArgs e)
|
private void ButtonSelectFilePath_Click(object sender, EventArgs e)
|
||||||
@ -48,7 +49,7 @@ public partial class FormAccessoriesReport : Form
|
|||||||
throw new Exception("Отсутствует имя файла для отчета");
|
throw new Exception("Отсутствует имя файла для отчета");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comboBoxFeed.SelectedIndex < 0)
|
if (comboBoxAccessories.SelectedIndex < 0)
|
||||||
{
|
{
|
||||||
throw new Exception("Не выбран корм");
|
throw new Exception("Не выбран корм");
|
||||||
}
|
}
|
||||||
@ -58,7 +59,7 @@ public partial class FormAccessoriesReport : Form
|
|||||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxFeed.SelectedValue!, dateTimePickerDateBegin.Value, dateTimePickerDateEnd.Value))
|
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxAccessories.SelectedValue!, dateTimePickerDateBegin.Value, dateTimePickerDateEnd.Value))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root>
|
<root>
|
||||||
<!--
|
<!--
|
||||||
Microsoft ResX Schema
|
Microsoft ResX Schema
|
||||||
|
|
||||||
Version 2.0
|
Version 2.0
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
The primary goals of this format is to allow a simple XML format
|
||||||
that is mostly human readable. The generation and parsing of the
|
that is mostly human readable. The generation and parsing of the
|
||||||
various data types are done through the TypeConverter classes
|
various data types are done through the TypeConverter classes
|
||||||
associated with the data types.
|
associated with the data types.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
... ado.net/XML headers & schema ...
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
<resheader name="version">2.0</resheader>
|
<resheader name="version">2.0</resheader>
|
||||||
@ -26,36 +26,36 @@
|
|||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
<comment>This is a comment</comment>
|
<comment>This is a comment</comment>
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
There are any number of "resheader" rows that contain simple
|
||||||
name/value pairs.
|
name/value pairs.
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
Each data row contains a name, and value. The row also contains a
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
text/value conversion through the TypeConverter architecture.
|
text/value conversion through the TypeConverter architecture.
|
||||||
Classes that don't support this are serialized and stored with the
|
Classes that don't support this are serialized and stored with the
|
||||||
mimetype set.
|
mimetype set.
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
The mimetype is used for serialized objects, and tells the
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
read any of the formats listed below.
|
read any of the formats listed below.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
value : The object must be serialized into a byte array
|
value : The object must be serialized into a byte array
|
||||||
: using a System.ComponentModel.TypeConverter
|
: using a System.ComponentModel.TypeConverter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
-->
|
-->
|
||||||
|
@ -1,47 +1,47 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
//using Microsoft.Extensions.Logging;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using System.Text;
|
//using System.Text;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ProjectCompRepair.Reports;
|
//namespace ProjectCompRepair.Reports;
|
||||||
|
|
||||||
internal class ChartReport
|
//internal class ChartReport
|
||||||
{
|
//{
|
||||||
private readonly IFeedingAnimalRepository _feedingAnimalRepository;
|
// private readonly IFeedingAnimalRepository _feedingAnimalRepository;
|
||||||
private readonly ILogger<ChartReport> _logger;
|
// private readonly ILogger<ChartReport> _logger;
|
||||||
|
|
||||||
public ChartReport(IFeedingAnimalRepository feedingAnimalRepository, ILogger<ChartReport> logger)
|
// public ChartReport(IFeedingAnimalRepository feedingAnimalRepository, ILogger<ChartReport> logger)
|
||||||
{
|
// {
|
||||||
_feedingAnimalRepository = feedingAnimalRepository ?? throw new ArgumentNullException(nameof(feedingAnimalRepository));
|
// _feedingAnimalRepository = feedingAnimalRepository ?? throw new ArgumentNullException(nameof(feedingAnimalRepository));
|
||||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
// _logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
}
|
// }
|
||||||
|
|
||||||
public bool CreateChart(string filePath, DateTime dateTime)
|
// public bool CreateChart(string filePath, DateTime dateTime)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
new PdfBuilder(filePath)
|
// new PdfBuilder(filePath)
|
||||||
.AddHeader("Питание животных")
|
// .AddHeader("Питание животных")
|
||||||
.AddPieChart("Выданные корма", GetData(dateTime))
|
// .AddPieChart("Выданные корма", GetData(dateTime))
|
||||||
.Build();
|
// .Build();
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
// _logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
// private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||||
{
|
// {
|
||||||
return _feedingAnimalRepository
|
// return _feedingAnimalRepository
|
||||||
.ReadFeedingAnimals()
|
// .ReadFeedingAnimals()
|
||||||
.Where(x => x.FeedingDate.Date == dateTime.Date)
|
// .Where(x => x.FeedingDate.Date == dateTime.Date)
|
||||||
.GroupBy(x => x.AnimalId, (key, group) => new { Id = key, Count = group.Sum(x => x.Ration) })
|
// .GroupBy(x => x.AnimalId, (key, group) => new { Id = key, Count = group.Sum(x => x.Ration) })
|
||||||
.Select(x => (x.Id.ToString(), (double)x.Count))
|
// .Select(x => (x.Id.ToString(), (double)x.Count))
|
||||||
.ToList();
|
// .ToList();
|
||||||
}
|
// }
|
||||||
}
|
//}
|
Loading…
Reference in New Issue
Block a user