сдал
This commit is contained in:
parent
56812e25df
commit
113be1af22
@ -38,6 +38,7 @@
|
|||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
документСоСправочникамиToolStripMenuItem = new ToolStripMenuItem();
|
документСоСправочникамиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
excelToolStripMenuItem = new ToolStripMenuItem();
|
excelToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
TypeOfAccessoriesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -96,7 +97,7 @@
|
|||||||
//
|
//
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { документСоСправочникамиToolStripMenuItem, excelToolStripMenuItem });
|
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { документСоСправочникамиToolStripMenuItem, excelToolStripMenuItem, TypeOfAccessoriesToolStripMenuItem });
|
||||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
@ -104,17 +105,24 @@
|
|||||||
// документСоСправочникамиToolStripMenuItem
|
// документСоСправочникамиToolStripMenuItem
|
||||||
//
|
//
|
||||||
документСоСправочникамиToolStripMenuItem.Name = "документСоСправочникамиToolStripMenuItem";
|
документСоСправочникамиToolStripMenuItem.Name = "документСоСправочникамиToolStripMenuItem";
|
||||||
документСоСправочникамиToolStripMenuItem.Size = new Size(294, 26);
|
документСоСправочникамиToolStripMenuItem.Size = new Size(348, 26);
|
||||||
документСоСправочникамиToolStripMenuItem.Text = "Документ со справочниками";
|
документСоСправочникамиToolStripMenuItem.Text = "Документ со справочниками";
|
||||||
документСоСправочникамиToolStripMenuItem.Click += DirecotryReportToolStripMenuItem_Click;
|
документСоСправочникамиToolStripMenuItem.Click += DirecotryReportToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// excelToolStripMenuItem
|
// excelToolStripMenuItem
|
||||||
//
|
//
|
||||||
excelToolStripMenuItem.Name = "excelToolStripMenuItem";
|
excelToolStripMenuItem.Name = "excelToolStripMenuItem";
|
||||||
excelToolStripMenuItem.Size = new Size(294, 26);
|
excelToolStripMenuItem.Size = new Size(348, 26);
|
||||||
excelToolStripMenuItem.Text = "Поток комплектующих";
|
excelToolStripMenuItem.Text = "Поток комплектующих";
|
||||||
excelToolStripMenuItem.Click += excelToolStripMenuItem_Click;
|
excelToolStripMenuItem.Click += excelToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// TypeOfAccessoriesToolStripMenuItem
|
||||||
|
//
|
||||||
|
TypeOfAccessoriesToolStripMenuItem.Name = "TypeOfAccessoriesToolStripMenuItem";
|
||||||
|
TypeOfAccessoriesToolStripMenuItem.Size = new Size(348, 26);
|
||||||
|
TypeOfAccessoriesToolStripMenuItem.Text = "Отчет о потраченых комплектующих";
|
||||||
|
TypeOfAccessoriesToolStripMenuItem.Click += TypeOfAccessoriesToolStripMenuItem_Click_1;
|
||||||
|
//
|
||||||
// FormCompRepair
|
// FormCompRepair
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
@ -146,5 +154,6 @@
|
|||||||
private ToolStripMenuItem ServiceToolStripMenuItem;
|
private ToolStripMenuItem ServiceToolStripMenuItem;
|
||||||
private ToolStripMenuItem документСоСправочникамиToolStripMenuItem;
|
private ToolStripMenuItem документСоСправочникамиToolStripMenuItem;
|
||||||
private ToolStripMenuItem excelToolStripMenuItem;
|
private ToolStripMenuItem excelToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem TypeOfAccessoriesToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,5 +85,18 @@ namespace ProjectCompRepair
|
|||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void TypeOfAccessoriesToolStripMenuItem_Click_1(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAccessoriesOrderReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
buttonSelectFileName.TabIndex = 0;
|
buttonSelectFileName.TabIndex = 0;
|
||||||
buttonSelectFileName.Text = "Выбрать";
|
buttonSelectFileName.Text = "Выбрать";
|
||||||
buttonSelectFileName.UseVisualStyleBackColor = true;
|
buttonSelectFileName.UseVisualStyleBackColor = true;
|
||||||
|
buttonSelectFileName.Click += ButtonSelectFileName_Click;
|
||||||
//
|
//
|
||||||
// labelFileName
|
// labelFileName
|
||||||
//
|
//
|
||||||
@ -73,12 +74,13 @@
|
|||||||
//
|
//
|
||||||
// buttonCreate
|
// buttonCreate
|
||||||
//
|
//
|
||||||
buttonCreate.Location = new Point(136, 178);
|
buttonCreate.Location = new Point(178, 178);
|
||||||
buttonCreate.Name = "buttonCreate";
|
buttonCreate.Name = "buttonCreate";
|
||||||
buttonCreate.Size = new Size(94, 29);
|
buttonCreate.Size = new Size(198, 29);
|
||||||
buttonCreate.TabIndex = 4;
|
buttonCreate.TabIndex = 4;
|
||||||
buttonCreate.Text = "Сформировать";
|
buttonCreate.Text = "Сформировать";
|
||||||
buttonCreate.UseVisualStyleBackColor = true;
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
//
|
//
|
||||||
// comboBoxAccessories
|
// comboBoxAccessories
|
||||||
//
|
//
|
||||||
|
@ -7,7 +7,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using ProjectCompRepair.Entities.Enums;
|
using ProjectCompRepair.Entities;
|
||||||
using ProjectCompRepair.Reports;
|
using ProjectCompRepair.Reports;
|
||||||
using ProjectCompRepair.Repositories;
|
using ProjectCompRepair.Repositories;
|
||||||
using Unity;
|
using Unity;
|
||||||
@ -25,7 +25,9 @@ namespace ProjectCompRepair.Forms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_container = container ??
|
_container = container ??
|
||||||
throw new ArgumentNullException(nameof(container));
|
throw new ArgumentNullException(nameof(container));
|
||||||
comboBoxAccessories.DataSource = Enum.GetValues(typeof(AccessoriesType));
|
comboBoxAccessories.DataSource = accessoriesRepository.ReadAccessories();
|
||||||
|
comboBoxAccessories.ValueMember = "Id";
|
||||||
|
comboBoxAccessories.DisplayMember = "AccessoriesType";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +55,7 @@ namespace ProjectCompRepair.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
if
|
if
|
||||||
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.Value, (int)comboBoxAccessories.SelectedIndex!))
|
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.Value, (int)comboBoxAccessories.SelectedValue!))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Документ сформирован",
|
MessageBox.Show("Документ сформирован",
|
||||||
"Формирование документа",
|
"Формирование документа",
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
textBoxFilePath = new TextBox();
|
textBoxFilePath = new TextBox();
|
||||||
buttonSelectFilePath = new Button();
|
buttonSelectFilePath = new Button();
|
||||||
comboBoxAccessories = new ComboBox();
|
comboBoxAccessories = new ComboBox();
|
||||||
label1 = new Label();
|
labelFile = new Label();
|
||||||
label2 = new Label();
|
labelNameAccessories = new Label();
|
||||||
label3 = new Label();
|
labelBeginTime = new Label();
|
||||||
label4 = new Label();
|
labelEndTime = new Label();
|
||||||
buttonMakeReport = new Button();
|
buttonMakeReport = new Button();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -71,7 +71,7 @@
|
|||||||
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
||||||
buttonSelectFilePath.Size = new Size(30, 31);
|
buttonSelectFilePath.Size = new Size(30, 31);
|
||||||
buttonSelectFilePath.TabIndex = 3;
|
buttonSelectFilePath.TabIndex = 3;
|
||||||
buttonSelectFilePath.Text = "button1";
|
buttonSelectFilePath.Text = "...";
|
||||||
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
||||||
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
||||||
//
|
//
|
||||||
@ -84,50 +84,50 @@
|
|||||||
comboBoxAccessories.Size = new Size(228, 28);
|
comboBoxAccessories.Size = new Size(228, 28);
|
||||||
comboBoxAccessories.TabIndex = 4;
|
comboBoxAccessories.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// label1
|
// labelFile
|
||||||
//
|
//
|
||||||
label1.AutoSize = true;
|
labelFile.AutoSize = true;
|
||||||
label1.Location = new Point(69, 112);
|
labelFile.Location = new Point(69, 112);
|
||||||
label1.Name = "label1";
|
labelFile.Name = "labelFile";
|
||||||
label1.Size = new Size(50, 20);
|
labelFile.Size = new Size(41, 20);
|
||||||
label1.TabIndex = 5;
|
labelFile.TabIndex = 5;
|
||||||
label1.Text = "label1";
|
labelFile.Text = "Путь";
|
||||||
//
|
//
|
||||||
// label2
|
// labelNameAccessories
|
||||||
//
|
//
|
||||||
label2.AutoSize = true;
|
labelNameAccessories.AutoSize = true;
|
||||||
label2.Location = new Point(69, 188);
|
labelNameAccessories.Location = new Point(47, 187);
|
||||||
label2.Name = "label2";
|
labelNameAccessories.Name = "labelNameAccessories";
|
||||||
label2.Size = new Size(50, 20);
|
labelNameAccessories.Size = new Size(145, 20);
|
||||||
label2.TabIndex = 6;
|
labelNameAccessories.TabIndex = 6;
|
||||||
label2.Text = "label2";
|
labelNameAccessories.Text = "id комплектующего";
|
||||||
//
|
//
|
||||||
// label3
|
// labelBeginTime
|
||||||
//
|
//
|
||||||
label3.AutoSize = true;
|
labelBeginTime.AutoSize = true;
|
||||||
label3.Location = new Point(69, 264);
|
labelBeginTime.Location = new Point(47, 261);
|
||||||
label3.Name = "label3";
|
labelBeginTime.Name = "labelBeginTime";
|
||||||
label3.Size = new Size(50, 20);
|
labelBeginTime.Size = new Size(134, 20);
|
||||||
label3.TabIndex = 7;
|
labelBeginTime.TabIndex = 7;
|
||||||
label3.Text = "label3";
|
labelBeginTime.Text = "Начальное время";
|
||||||
//
|
//
|
||||||
// label4
|
// labelEndTime
|
||||||
//
|
//
|
||||||
label4.AutoSize = true;
|
labelEndTime.AutoSize = true;
|
||||||
label4.Location = new Point(69, 317);
|
labelEndTime.Location = new Point(47, 314);
|
||||||
label4.Name = "label4";
|
labelEndTime.Name = "labelEndTime";
|
||||||
label4.Size = new Size(50, 20);
|
labelEndTime.Size = new Size(126, 20);
|
||||||
label4.TabIndex = 8;
|
labelEndTime.TabIndex = 8;
|
||||||
label4.Text = "label4";
|
labelEndTime.Text = "Конечное время";
|
||||||
//
|
//
|
||||||
// buttonMakeReport
|
// buttonMakeReport
|
||||||
//
|
//
|
||||||
buttonMakeReport.Location = new Point(175, 423);
|
buttonMakeReport.Location = new Point(175, 423);
|
||||||
buttonMakeReport.Margin = new Padding(3, 4, 3, 4);
|
buttonMakeReport.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonMakeReport.Name = "buttonMakeReport";
|
buttonMakeReport.Name = "buttonMakeReport";
|
||||||
buttonMakeReport.Size = new Size(86, 31);
|
buttonMakeReport.Size = new Size(134, 31);
|
||||||
buttonMakeReport.TabIndex = 9;
|
buttonMakeReport.TabIndex = 9;
|
||||||
buttonMakeReport.Text = "button2";
|
buttonMakeReport.Text = "Сформировать";
|
||||||
buttonMakeReport.UseVisualStyleBackColor = true;
|
buttonMakeReport.UseVisualStyleBackColor = true;
|
||||||
buttonMakeReport.Click += ButtonMakeReport_Click;
|
buttonMakeReport.Click += ButtonMakeReport_Click;
|
||||||
//
|
//
|
||||||
@ -137,10 +137,10 @@
|
|||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(535, 600);
|
ClientSize = new Size(535, 600);
|
||||||
Controls.Add(buttonMakeReport);
|
Controls.Add(buttonMakeReport);
|
||||||
Controls.Add(label4);
|
Controls.Add(labelEndTime);
|
||||||
Controls.Add(label3);
|
Controls.Add(labelBeginTime);
|
||||||
Controls.Add(label2);
|
Controls.Add(labelNameAccessories);
|
||||||
Controls.Add(label1);
|
Controls.Add(labelFile);
|
||||||
Controls.Add(comboBoxAccessories);
|
Controls.Add(comboBoxAccessories);
|
||||||
Controls.Add(buttonSelectFilePath);
|
Controls.Add(buttonSelectFilePath);
|
||||||
Controls.Add(textBoxFilePath);
|
Controls.Add(textBoxFilePath);
|
||||||
@ -160,10 +160,10 @@
|
|||||||
private TextBox textBoxFilePath;
|
private TextBox textBoxFilePath;
|
||||||
private Button buttonSelectFilePath;
|
private Button buttonSelectFilePath;
|
||||||
private ComboBox comboBoxAccessories;
|
private ComboBox comboBoxAccessories;
|
||||||
private Label label1;
|
private Label labelFile;
|
||||||
private Label label2;
|
private Label labelNameAccessories;
|
||||||
private Label label3;
|
private Label labelBeginTime;
|
||||||
private Label label4;
|
private Label labelEndTime;
|
||||||
private Button buttonMakeReport;
|
private Button buttonMakeReport;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ using Unity;
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Unity.Microsoft.Logging;
|
using Unity.Microsoft.Logging;
|
||||||
using Unity.Lifetime;
|
using Unity.Lifetime;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -24,6 +25,7 @@ namespace ProjectCompRepair
|
|||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(CreateContainer().Resolve<FormCompRepair>());
|
Application.Run(CreateContainer().Resolve<FormCompRepair>());
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IUnityContainer CreateContainer()
|
private static IUnityContainer CreateContainer()
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using ProjectCompRepair.Entities;
|
using ProjectCompRepair.Entities;
|
||||||
using ProjectCompRepair.Repositories;
|
using ProjectCompRepair.Repositories;
|
||||||
using ProjectCompRepair.Repositories.Implemantations;
|
using ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
using RegistrationOfPatients.Reports;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -42,7 +43,7 @@ internal class ChartReport
|
|||||||
{
|
{
|
||||||
return _orderRepository
|
return _orderRepository
|
||||||
.ReadOrder()
|
.ReadOrder()
|
||||||
.Where(x => x.Date.Date == dateTime.Date)
|
.Where(x => x.Date.Date == dateTime.Date && x.AccessoiresOrders.Any(y => y.AccessoriesId == accessoriesId))
|
||||||
.GroupBy(x => x.Id, (key, group) => new
|
.GroupBy(x => x.Id, (key, group) => new
|
||||||
{
|
{
|
||||||
Id = key,
|
Id = key,
|
||||||
|
@ -39,11 +39,11 @@ internal class DocReport
|
|||||||
}
|
}
|
||||||
if (includeService)
|
if (includeService)
|
||||||
{
|
{
|
||||||
builder.AddParagraph("Услуги").AddTable([2400], GetService());
|
builder.AddParagraph("Услуги").AddTable([2400,2400], GetService());
|
||||||
}
|
}
|
||||||
if (includeAccessories)
|
if (includeAccessories)
|
||||||
{
|
{
|
||||||
builder.AddParagraph("Комплектующие").AddTable([2400], AccessoriesGet());
|
builder.AddParagraph("Комплектующие").AddTable([2400,2400,2400], AccessoriesGet());
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.Build();
|
builder.Build();
|
||||||
|
@ -7,7 +7,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ProjectCompRepair.Reports;
|
namespace RegistrationOfPatients.Reports;
|
||||||
|
|
||||||
internal class ExcelBuilder
|
internal class ExcelBuilder
|
||||||
{
|
{
|
||||||
@ -32,17 +32,20 @@ internal class ExcelBuilder
|
|||||||
_columns = new Columns();
|
_columns = new Columns();
|
||||||
_rowIndex = 1;
|
_rowIndex = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
||||||
{
|
{
|
||||||
CreateCell(startIndex, _rowIndex, header, StyleIndex.SimpleTextWithoutBorder);
|
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
|
||||||
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||||
{
|
{
|
||||||
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
_mergeCells.Append(new MergeCell()
|
_mergeCells.Append(new MergeCell()
|
||||||
{
|
{
|
||||||
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
|
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
|
||||||
});
|
});
|
||||||
|
|
||||||
_rowIndex++;
|
_rowIndex++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -59,10 +62,12 @@ internal class ExcelBuilder
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(columnsWidths));
|
throw new ArgumentNullException(nameof(columnsWidths));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data == null || data.Count == 0)
|
if (data == null || data.Count == 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(data));
|
throw new ArgumentNullException(nameof(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.Any(x => x.Length != columnsWidths.Length))
|
if (data.Any(x => x.Length != columnsWidths.Length))
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("widths.Length != data.Length");
|
throw new InvalidOperationException("widths.Length != data.Length");
|
||||||
@ -77,28 +82,28 @@ internal class ExcelBuilder
|
|||||||
Width = x * coef,
|
Width = x * coef,
|
||||||
CustomWidth = true
|
CustomWidth = true
|
||||||
}));
|
}));
|
||||||
|
|
||||||
for (var j = 0; j < data.First().Length; ++j)
|
for (var j = 0; j < data.First().Length; ++j)
|
||||||
{
|
{
|
||||||
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.SimpleTextWithoutBorder);
|
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
|
||||||
}
|
}
|
||||||
_rowIndex++;
|
|
||||||
|
|
||||||
|
_rowIndex++;
|
||||||
for (var i = 1; i < data.Count - 1; ++i)
|
for (var i = 1; i < data.Count - 1; ++i)
|
||||||
{
|
{
|
||||||
for (var j = 0; j < data[i].Length; ++j)
|
for (var j = 0; j < data[i].Length; ++j)
|
||||||
{
|
{
|
||||||
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithoutBorder);
|
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
_rowIndex++;
|
_rowIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var j = 0; j < data.Last().Length; ++j)
|
for (var j = 0; j < data.Last().Length; ++j)
|
||||||
{
|
{
|
||||||
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.SimpleTextWithoutBorder);
|
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
|
||||||
}
|
}
|
||||||
_rowIndex++;
|
|
||||||
|
|
||||||
|
_rowIndex++;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,13 +115,12 @@ internal class ExcelBuilder
|
|||||||
workbookpart.Workbook = new Workbook();
|
workbookpart.Workbook = new Workbook();
|
||||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||||
worksheetPart.Worksheet = new Worksheet();
|
worksheetPart.Worksheet = new Worksheet();
|
||||||
|
|
||||||
if (_columns.HasChildren)
|
if (_columns.HasChildren)
|
||||||
{
|
{
|
||||||
worksheetPart.Worksheet.Append(_columns);
|
worksheetPart.Worksheet.Append(_columns);
|
||||||
}
|
}
|
||||||
worksheetPart.Worksheet.Append(_sheetData);
|
|
||||||
|
|
||||||
|
worksheetPart.Worksheet.Append(_sheetData);
|
||||||
var sheets = spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
var sheets = spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
||||||
var sheet = new Sheet()
|
var sheet = new Sheet()
|
||||||
{
|
{
|
||||||
@ -124,11 +128,12 @@ internal class ExcelBuilder
|
|||||||
SheetId = 1,
|
SheetId = 1,
|
||||||
Name = "Лист 1"
|
Name = "Лист 1"
|
||||||
};
|
};
|
||||||
sheets.Append(sheet);
|
|
||||||
|
|
||||||
|
sheets.Append(sheet);
|
||||||
if (_mergeCells.HasChildren)
|
if (_mergeCells.HasChildren)
|
||||||
{
|
{
|
||||||
worksheetPart.Worksheet.InsertAfter(_mergeCells, worksheetPart.Worksheet.Elements<SheetData>().First());
|
worksheetPart.Worksheet.InsertAfter(_mergeCells,
|
||||||
|
worksheetPart.Worksheet.Elements<SheetData>().First());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,18 +142,13 @@ internal class ExcelBuilder
|
|||||||
var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>();
|
var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>();
|
||||||
workbookStylesPart.Stylesheet = new Stylesheet();
|
workbookStylesPart.Stylesheet = new Stylesheet();
|
||||||
|
|
||||||
var fonts = new Fonts() { Count = 2, KnownFonts = BooleanValue.FromBoolean(true) };
|
var fonts = new Fonts()
|
||||||
|
{
|
||||||
|
Count = 2,
|
||||||
|
KnownFonts = BooleanValue.FromBoolean(true)
|
||||||
|
};
|
||||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||||
{
|
{
|
||||||
FontSize = new FontSize() { Val = 11 },
|
|
||||||
FontName = new FontName() { Val = "Calibri" },
|
|
||||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
|
||||||
FontScheme = new FontScheme() { Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor) }
|
|
||||||
});
|
|
||||||
// TODO добавить шрифт с жирным
|
|
||||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
|
||||||
{
|
|
||||||
Bold = new Bold() { Val = true },
|
|
||||||
FontSize = new FontSize() { Val = 11 },
|
FontSize = new FontSize() { Val = 11 },
|
||||||
FontName = new FontName() { Val = "Calibri" },
|
FontName = new FontName() { Val = "Calibri" },
|
||||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||||
@ -157,6 +157,18 @@ internal class ExcelBuilder
|
|||||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// TODO добавить шрифт с жирным
|
||||||
|
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||||
|
{
|
||||||
|
FontSize = new FontSize() { Val = 11 },
|
||||||
|
FontName = new FontName() { Val = "Calibri" },
|
||||||
|
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||||
|
FontScheme = new FontScheme()
|
||||||
|
{
|
||||||
|
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||||
|
},
|
||||||
|
Bold = new Bold() { Val = true }
|
||||||
|
});
|
||||||
|
|
||||||
workbookStylesPart.Stylesheet.Append(fonts);
|
workbookStylesPart.Stylesheet.Append(fonts);
|
||||||
|
|
||||||
@ -164,7 +176,10 @@ internal class ExcelBuilder
|
|||||||
var fills = new Fills() { Count = 1 };
|
var fills = new Fills() { Count = 1 };
|
||||||
fills.Append(new Fill
|
fills.Append(new Fill
|
||||||
{
|
{
|
||||||
PatternFill = new PatternFill() { PatternType = new EnumValue<PatternValues>(PatternValues.None) }
|
PatternFill = new PatternFill()
|
||||||
|
{
|
||||||
|
PatternType = new EnumValue<PatternValues>(PatternValues.None)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
workbookStylesPart.Stylesheet.Append(fills);
|
workbookStylesPart.Stylesheet.Append(fills);
|
||||||
|
|
||||||
@ -178,7 +193,7 @@ internal class ExcelBuilder
|
|||||||
BottomBorder = new BottomBorder(),
|
BottomBorder = new BottomBorder(),
|
||||||
DiagonalBorder = new DiagonalBorder()
|
DiagonalBorder = new DiagonalBorder()
|
||||||
});
|
});
|
||||||
|
// TODO добавить настройку с границами
|
||||||
borders.Append(new Border
|
borders.Append(new Border
|
||||||
{
|
{
|
||||||
LeftBorder = new LeftBorder { Style = BorderStyleValues.Thin },
|
LeftBorder = new LeftBorder { Style = BorderStyleValues.Thin },
|
||||||
@ -187,6 +202,7 @@ internal class ExcelBuilder
|
|||||||
BottomBorder = new BottomBorder { Style = BorderStyleValues.Thin },
|
BottomBorder = new BottomBorder { Style = BorderStyleValues.Thin },
|
||||||
DiagonalBorder = new DiagonalBorder()
|
DiagonalBorder = new DiagonalBorder()
|
||||||
});
|
});
|
||||||
|
|
||||||
workbookStylesPart.Stylesheet.Append(borders);
|
workbookStylesPart.Stylesheet.Append(borders);
|
||||||
|
|
||||||
// Default cell format and a date cell format
|
// Default cell format and a date cell format
|
||||||
@ -205,7 +221,7 @@ internal class ExcelBuilder
|
|||||||
WrapText = true
|
WrapText = true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
// TODO дополнить форматы
|
||||||
cellFormats.Append(new CellFormat
|
cellFormats.Append(new CellFormat
|
||||||
{
|
{
|
||||||
NumberFormatId = 0,
|
NumberFormatId = 0,
|
||||||
@ -248,12 +264,14 @@ internal class ExcelBuilder
|
|||||||
WrapText = true
|
WrapText = true
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
workbookStylesPart.Stylesheet.Append(cellFormats);
|
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum StyleIndex
|
private enum StyleIndex
|
||||||
{
|
{
|
||||||
SimpleTextWithoutBorder = 0,
|
SimpleTextWithoutBorder = 0,
|
||||||
|
// TODO дополнить стили
|
||||||
SimpleTextWithBorder = 1,
|
SimpleTextWithBorder = 1,
|
||||||
BoldTextWithoutBorder = 2,
|
BoldTextWithoutBorder = 2,
|
||||||
BoldTextWithBorder = 3,
|
BoldTextWithBorder = 3,
|
||||||
@ -264,7 +282,6 @@ internal class ExcelBuilder
|
|||||||
var columnName = GetExcelColumnName(columnIndex);
|
var columnName = GetExcelColumnName(columnIndex);
|
||||||
var cellReference = columnName + rowIndex;
|
var cellReference = columnName + rowIndex;
|
||||||
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex! == rowIndex);
|
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex! == rowIndex);
|
||||||
|
|
||||||
if (row == null)
|
if (row == null)
|
||||||
{
|
{
|
||||||
row = new Row() { RowIndex = rowIndex };
|
row = new Row() { RowIndex = rowIndex };
|
||||||
@ -273,7 +290,6 @@ internal class ExcelBuilder
|
|||||||
|
|
||||||
var newCell = row.Elements<Cell>()
|
var newCell = row.Elements<Cell>()
|
||||||
.FirstOrDefault(c => c.CellReference != null && c.CellReference.Value == columnName + rowIndex);
|
.FirstOrDefault(c => c.CellReference != null && c.CellReference.Value == columnName + rowIndex);
|
||||||
|
|
||||||
if (newCell == null)
|
if (newCell == null)
|
||||||
{
|
{
|
||||||
Cell? refCell = null;
|
Cell? refCell = null;
|
||||||
@ -313,5 +329,4 @@ internal class ExcelBuilder
|
|||||||
|
|
||||||
return columnName;
|
return columnName;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,25 +7,22 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ProjectCompRepair.Reports;
|
namespace RegistrationOfPatients.Reports;
|
||||||
|
|
||||||
internal class PdfBuilder
|
public class PdfBuilder
|
||||||
{
|
{
|
||||||
private readonly string _filePath;
|
private readonly string _filePath;
|
||||||
private readonly Document _document;
|
private readonly Document _document;
|
||||||
|
|
||||||
public PdfBuilder(string filePath)
|
public PdfBuilder(string filePath)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(filePath))
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(filePath));
|
throw new ArgumentNullException(nameof(filePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
File.Delete(filePath);
|
File.Delete(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
_filePath = filePath;
|
_filePath = filePath;
|
||||||
_document = new Document();
|
_document = new Document();
|
||||||
DefineStyles();
|
DefineStyles();
|
||||||
@ -36,7 +33,6 @@ internal class PdfBuilder
|
|||||||
_document.AddSection().AddParagraph(header, "NormalBold");
|
_document.AddSection().AddParagraph(header, "NormalBold");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
|
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
|
||||||
{
|
{
|
||||||
if (data == null || data.Count == 0)
|
if (data == null || data.Count == 0)
|
||||||
@ -53,22 +49,30 @@ internal class PdfBuilder
|
|||||||
|
|
||||||
chart.DataLabel.Type = DataLabelType.Percent;
|
chart.DataLabel.Type = DataLabelType.Percent;
|
||||||
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
||||||
|
|
||||||
chart.Width = Unit.FromCentimeter(16);
|
chart.Width = Unit.FromCentimeter(16);
|
||||||
chart.Height = Unit.FromCentimeter(12);
|
chart.Height = Unit.FromCentimeter(12);
|
||||||
|
|
||||||
chart.TopArea.AddParagraph(title);
|
chart.TopArea.AddParagraph(title);
|
||||||
|
|
||||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||||
|
|
||||||
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||||
chart.YAxis.HasMajorGridlines = true;
|
chart.YAxis.HasMajorGridlines = true;
|
||||||
|
|
||||||
chart.PlotArea.LineFormat.Width = 1;
|
chart.PlotArea.LineFormat.Width = 1;
|
||||||
chart.PlotArea.LineFormat.Visible = true;
|
chart.PlotArea.LineFormat.Visible = true;
|
||||||
|
|
||||||
chart.TopArea.AddLegend();
|
chart.TopArea.AddLegend();
|
||||||
|
|
||||||
_document.LastSection.Add(chart);
|
_document.LastSection.Add(chart);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Build()
|
public void Build()
|
||||||
{
|
{
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
var renderer = new PdfDocumentRenderer(true)
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
{
|
{
|
||||||
Document = _document
|
Document = _document
|
||||||
@ -77,11 +81,11 @@ internal class PdfBuilder
|
|||||||
renderer.RenderDocument();
|
renderer.RenderDocument();
|
||||||
renderer.PdfDocument.Save(_filePath);
|
renderer.PdfDocument.Save(_filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DefineStyles()
|
private void DefineStyles()
|
||||||
{
|
{
|
||||||
var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
|
var style = _document.Styles.AddStyle("NormalBold", "Normal");
|
||||||
headerStyle.Font.Bold = true;
|
style.Font.Bold = true;
|
||||||
headerStyle.Font.Size = 14;
|
style.Font.Size = 14;
|
||||||
|
style.ParagraphFormat.Alignment = ParagraphAlignment.Center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using ProjectCompRepair.Entities;
|
using ProjectCompRepair.Entities;
|
||||||
using ProjectCompRepair.Repositories;
|
using ProjectCompRepair.Repositories;
|
||||||
|
using RegistrationOfPatients.Reports;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -137,7 +137,7 @@ INNER JOIN AccessoriesOrder ao ON ao.OrderId = o.ID;";
|
|||||||
_logger.LogDebug("Полученные объекты : {json}", JsonConvert.SerializeObject(order));
|
_logger.LogDebug("Полученные объекты : {json}", JsonConvert.SerializeObject(order));
|
||||||
return order.GroupBy(x => x.Id, y => y,
|
return order.GroupBy(x => x.Id, y => y,
|
||||||
(key, value) => Order.CreateElement(value.First(),
|
(key, value) => Order.CreateElement(value.First(),
|
||||||
value.Select(z => AccessoiresOrder.CreateElement(0, z.AccessoriesId, z.Count)))).ToList();
|
value.Select(z => AccessoiresOrder.CreateElement(0, z.Count, z.AccessoriesId)))).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user