АААААААААААААААААААА
This commit is contained in:
parent
f4af6dafbc
commit
b44919089b
@ -1,4 +1,7 @@
|
|||||||
namespace Publication.Entites;
|
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace Publication.Entites;
|
||||||
|
|
||||||
public class PrintingHouses
|
public class PrintingHouses
|
||||||
{
|
{
|
||||||
@ -23,7 +26,22 @@ public class PrintingHouses
|
|||||||
Phone = phone,
|
Phone = phone,
|
||||||
Address = address,
|
Address = address,
|
||||||
MaterialsId=materialsId,
|
MaterialsId=materialsId,
|
||||||
|
Date = DateTime.Now,
|
||||||
printingHouseOrder = printingHouseOrders
|
printingHouseOrder = printingHouseOrders
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static PrintingHouses CreateEntity(TempPrintingHouseOrders tempPrintingHouseOrders, IEnumerable<PrintingHouseOrders> _printingHouseOrders)
|
||||||
|
{
|
||||||
|
return new PrintingHouses
|
||||||
|
{
|
||||||
|
Id = tempPrintingHouseOrders.Id,
|
||||||
|
Title = tempPrintingHouseOrders.Title,
|
||||||
|
Phone = tempPrintingHouseOrders.Phone,
|
||||||
|
Address = tempPrintingHouseOrders.Address,
|
||||||
|
MaterialsId = tempPrintingHouseOrders.MaterialsId,
|
||||||
|
Date = tempPrintingHouseOrders.Date,
|
||||||
|
printingHouseOrder = _printingHouseOrders
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
22
Publication/Entites/TempPrintingHouseOrders.cs
Normal file
22
Publication/Entites/TempPrintingHouseOrders.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Publication.Entites;
|
||||||
|
|
||||||
|
public class TempPrintingHouseOrders
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
public string Phone { get; set; }
|
||||||
|
public string Address { get; set; }
|
||||||
|
|
||||||
|
public int MaterialsId { get; set; }
|
||||||
|
|
||||||
|
public DateTime Date { get; set; }
|
||||||
|
|
||||||
|
public int OrderId { get; set; }
|
||||||
|
public int Count { get; set; }
|
||||||
|
}
|
43
Publication/Forms/FormCountReport.Designer.cs
generated
43
Publication/Forms/FormCountReport.Designer.cs
generated
@ -29,14 +29,12 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
label1 = new Label();
|
label1 = new Label();
|
||||||
label2 = new Label();
|
|
||||||
label3 = new Label();
|
label3 = new Label();
|
||||||
label4 = new Label();
|
label4 = new Label();
|
||||||
textBoxFilePath = new TextBox();
|
textBoxFilePath = new TextBox();
|
||||||
dateTimePickerStartDate = new DateTimePicker();
|
dateTimePickerStartDate = new DateTimePicker();
|
||||||
dateTimePickerEndDate = new DateTimePicker();
|
dateTimePickerEndDate = new DateTimePicker();
|
||||||
buttonSelectFilePath = new Button();
|
buttonSelectFilePath = new Button();
|
||||||
comboBoxProducts = new ComboBox();
|
|
||||||
buttonMakeReport = new Button();
|
buttonMakeReport = new Button();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -49,19 +47,10 @@
|
|||||||
label1.TabIndex = 0;
|
label1.TabIndex = 0;
|
||||||
label1.Text = "Путь до файла:";
|
label1.Text = "Путь до файла:";
|
||||||
//
|
//
|
||||||
// label2
|
|
||||||
//
|
|
||||||
label2.AutoSize = true;
|
|
||||||
label2.Location = new Point(22, 72);
|
|
||||||
label2.Name = "label2";
|
|
||||||
label2.Size = new Size(69, 20);
|
|
||||||
label2.TabIndex = 1;
|
|
||||||
label2.Text = "Продукт:";
|
|
||||||
//
|
|
||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
label3.AutoSize = true;
|
label3.AutoSize = true;
|
||||||
label3.Location = new Point(22, 127);
|
label3.Location = new Point(22, 79);
|
||||||
label3.Name = "label3";
|
label3.Name = "label3";
|
||||||
label3.Size = new Size(97, 20);
|
label3.Size = new Size(97, 20);
|
||||||
label3.TabIndex = 2;
|
label3.TabIndex = 2;
|
||||||
@ -70,7 +59,7 @@
|
|||||||
// label4
|
// label4
|
||||||
//
|
//
|
||||||
label4.AutoSize = true;
|
label4.AutoSize = true;
|
||||||
label4.Location = new Point(22, 178);
|
label4.Location = new Point(22, 130);
|
||||||
label4.Name = "label4";
|
label4.Name = "label4";
|
||||||
label4.Size = new Size(90, 20);
|
label4.Size = new Size(90, 20);
|
||||||
label4.TabIndex = 3;
|
label4.TabIndex = 3;
|
||||||
@ -86,14 +75,14 @@
|
|||||||
//
|
//
|
||||||
// dateTimePickerStartDate
|
// dateTimePickerStartDate
|
||||||
//
|
//
|
||||||
dateTimePickerStartDate.Location = new Point(188, 127);
|
dateTimePickerStartDate.Location = new Point(188, 79);
|
||||||
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
|
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
|
||||||
dateTimePickerStartDate.Size = new Size(181, 27);
|
dateTimePickerStartDate.Size = new Size(181, 27);
|
||||||
dateTimePickerStartDate.TabIndex = 5;
|
dateTimePickerStartDate.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// dateTimePickerEndDate
|
// dateTimePickerEndDate
|
||||||
//
|
//
|
||||||
dateTimePickerEndDate.Location = new Point(188, 173);
|
dateTimePickerEndDate.Location = new Point(188, 125);
|
||||||
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
|
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
|
||||||
dateTimePickerEndDate.Size = new Size(181, 27);
|
dateTimePickerEndDate.Size = new Size(181, 27);
|
||||||
dateTimePickerEndDate.TabIndex = 6;
|
dateTimePickerEndDate.TabIndex = 6;
|
||||||
@ -107,42 +96,34 @@
|
|||||||
buttonSelectFilePath.TabIndex = 7;
|
buttonSelectFilePath.TabIndex = 7;
|
||||||
buttonSelectFilePath.Text = "..";
|
buttonSelectFilePath.Text = "..";
|
||||||
buttonSelectFilePath.UseVisualStyleBackColor = false;
|
buttonSelectFilePath.UseVisualStyleBackColor = false;
|
||||||
//
|
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
||||||
// comboBoxProducts
|
|
||||||
//
|
|
||||||
comboBoxProducts.FormattingEnabled = true;
|
|
||||||
comboBoxProducts.Location = new Point(188, 72);
|
|
||||||
comboBoxProducts.Name = "comboBoxProducts";
|
|
||||||
comboBoxProducts.Size = new Size(181, 28);
|
|
||||||
comboBoxProducts.TabIndex = 8;
|
|
||||||
//
|
//
|
||||||
// buttonMakeReport
|
// buttonMakeReport
|
||||||
//
|
//
|
||||||
buttonMakeReport.BackColor = Color.FromArgb(192, 192, 255);
|
buttonMakeReport.BackColor = Color.FromArgb(192, 192, 255);
|
||||||
buttonMakeReport.Location = new Point(22, 234);
|
buttonMakeReport.Location = new Point(22, 186);
|
||||||
buttonMakeReport.Name = "buttonMakeReport";
|
buttonMakeReport.Name = "buttonMakeReport";
|
||||||
buttonMakeReport.Size = new Size(347, 29);
|
buttonMakeReport.Size = new Size(347, 29);
|
||||||
buttonMakeReport.TabIndex = 9;
|
buttonMakeReport.TabIndex = 9;
|
||||||
buttonMakeReport.Text = "Сформировать";
|
buttonMakeReport.Text = "Сформировать";
|
||||||
buttonMakeReport.UseVisualStyleBackColor = false;
|
buttonMakeReport.UseVisualStyleBackColor = false;
|
||||||
|
buttonMakeReport.Click += ButtonMakeReport_Click;
|
||||||
//
|
//
|
||||||
// FormProductReport
|
// FormCountReport
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(409, 302);
|
ClientSize = new Size(409, 249);
|
||||||
Controls.Add(buttonMakeReport);
|
Controls.Add(buttonMakeReport);
|
||||||
Controls.Add(comboBoxProducts);
|
|
||||||
Controls.Add(buttonSelectFilePath);
|
Controls.Add(buttonSelectFilePath);
|
||||||
Controls.Add(dateTimePickerEndDate);
|
Controls.Add(dateTimePickerEndDate);
|
||||||
Controls.Add(dateTimePickerStartDate);
|
Controls.Add(dateTimePickerStartDate);
|
||||||
Controls.Add(textBoxFilePath);
|
Controls.Add(textBoxFilePath);
|
||||||
Controls.Add(label4);
|
Controls.Add(label4);
|
||||||
Controls.Add(label3);
|
Controls.Add(label3);
|
||||||
Controls.Add(label2);
|
|
||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Name = "FormProductReport";
|
Name = "FormCountReport";
|
||||||
Text = "FormProductReport";
|
Text = "FormCountReport";
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -150,14 +131,12 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private Label label2;
|
|
||||||
private Label label3;
|
private Label label3;
|
||||||
private Label label4;
|
private Label label4;
|
||||||
private TextBox textBoxFilePath;
|
private TextBox textBoxFilePath;
|
||||||
private DateTimePicker dateTimePickerStartDate;
|
private DateTimePicker dateTimePickerStartDate;
|
||||||
private DateTimePicker dateTimePickerEndDate;
|
private DateTimePicker dateTimePickerEndDate;
|
||||||
private Button buttonSelectFilePath;
|
private Button buttonSelectFilePath;
|
||||||
private ComboBox comboBoxProducts;
|
|
||||||
private Button buttonMakeReport;
|
private Button buttonMakeReport;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using Publication.Reports;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -7,14 +8,59 @@ 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 Unity;
|
||||||
|
|
||||||
namespace Publication.Forms
|
namespace Publication.Forms
|
||||||
{
|
{
|
||||||
public partial class FormCountReport : Form
|
public partial class FormCountReport : Form
|
||||||
{
|
{
|
||||||
public FormCountReport()
|
IUnityContainer _container;
|
||||||
|
|
||||||
|
public FormCountReport(IUnityContainer container)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSelectFilePath_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Excel Files | *.xlsx"
|
||||||
|
};
|
||||||
|
if (sfd.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
textBoxFilePath.Text = sfd.FileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonMakeReport_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
||||||
|
{
|
||||||
|
throw new Exception("Отсутствует имя файла для отчета");
|
||||||
|
}
|
||||||
|
if (dateTimePickerEndDate.Value <= dateTimePickerStartDate.Value)
|
||||||
|
{
|
||||||
|
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||||
|
}
|
||||||
|
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, dateTimePickerStartDate.Value, dateTimePickerEndDate.Value))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при создании очета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,8 @@ MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return list;
|
return list.GroupBy(x => x.OrderId, x => x.Count, (id, counts) =>
|
||||||
|
PrintingHouseOrders.CreateEntity(0, id, counts.Sum())).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonBreak_Click(object sender, EventArgs e) => Close();
|
private void ButtonBreak_Click(object sender, EventArgs e) => Close();
|
||||||
|
17
Publication/Forms/Publication.Designer.cs
generated
17
Publication/Forms/Publication.Designer.cs
generated
@ -38,6 +38,8 @@
|
|||||||
CreateOrderToolStripMenuItem = new ToolStripMenuItem();
|
CreateOrderToolStripMenuItem = new ToolStripMenuItem();
|
||||||
PrintingToolStripMenuItem = new ToolStripMenuItem();
|
PrintingToolStripMenuItem = new ToolStripMenuItem();
|
||||||
ReportsToolStripMenuItem = new ToolStripMenuItem();
|
ReportsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
CountReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -92,9 +94,22 @@
|
|||||||
//
|
//
|
||||||
// ReportsToolStripMenuItem
|
// ReportsToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, CountReportToolStripMenuItem });
|
||||||
ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem";
|
ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem";
|
||||||
resources.ApplyResources(ReportsToolStripMenuItem, "ReportsToolStripMenuItem");
|
resources.ApplyResources(ReportsToolStripMenuItem, "ReportsToolStripMenuItem");
|
||||||
//
|
//
|
||||||
|
// DirectoryReportToolStripMenuItem
|
||||||
|
//
|
||||||
|
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
|
||||||
|
resources.ApplyResources(DirectoryReportToolStripMenuItem, "DirectoryReportToolStripMenuItem");
|
||||||
|
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// CountReportToolStripMenuItem
|
||||||
|
//
|
||||||
|
CountReportToolStripMenuItem.Name = "CountReportToolStripMenuItem";
|
||||||
|
resources.ApplyResources(CountReportToolStripMenuItem, "CountReportToolStripMenuItem");
|
||||||
|
CountReportToolStripMenuItem.Click += CountReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// Publication
|
// Publication
|
||||||
//
|
//
|
||||||
resources.ApplyResources(this, "$this");
|
resources.ApplyResources(this, "$this");
|
||||||
@ -119,5 +134,7 @@
|
|||||||
private ToolStripMenuItem CreateOrderToolStripMenuItem;
|
private ToolStripMenuItem CreateOrderToolStripMenuItem;
|
||||||
private ToolStripMenuItem PrintingToolStripMenuItem;
|
private ToolStripMenuItem PrintingToolStripMenuItem;
|
||||||
private ToolStripMenuItem ReportsToolStripMenuItem;
|
private ToolStripMenuItem ReportsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem CountReportToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,4 +81,28 @@ public partial class Publication : Form
|
|||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DirectoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
unityContainer.Resolve<FormDirectoryReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CountReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
unityContainer.Resolve<FormCountReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,24 +127,31 @@
|
|||||||
<data name="DictionsToolStripMenuItem.Text" xml:space="preserve">
|
<data name="DictionsToolStripMenuItem.Text" xml:space="preserve">
|
||||||
<value>Справочники</value>
|
<value>Справочники</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="CreateOrderToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
|
||||||
<value>224, 26</value>
|
|
||||||
</data>
|
|
||||||
<data name="CreateOrderToolStripMenuItem.Text" xml:space="preserve">
|
|
||||||
<value>Создать заказ</value>
|
|
||||||
</data>
|
|
||||||
<data name="PrintingToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
|
||||||
<value>224, 26</value>
|
|
||||||
</data>
|
|
||||||
<data name="PrintingToolStripMenuItem.Text" xml:space="preserve">
|
|
||||||
<value>Печать</value>
|
|
||||||
</data>
|
|
||||||
<data name="OperationsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="OperationsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>95, 24</value>
|
<value>95, 24</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="OperationsToolStripMenuItem.Text" xml:space="preserve">
|
<data name="OperationsToolStripMenuItem.Text" xml:space="preserve">
|
||||||
<value>Операции</value>
|
<value>Операции</value>
|
||||||
</data>
|
</data>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="DirectoryReportToolStripMenuItem.ShortcutKeys" type="System.Windows.Forms.Keys, System.Windows.Forms">
|
||||||
|
<value>Ctrl+W</value>
|
||||||
|
</data>
|
||||||
|
<data name="DirectoryReportToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>350, 26</value>
|
||||||
|
</data>
|
||||||
|
<data name="DirectoryReportToolStripMenuItem.Text" xml:space="preserve">
|
||||||
|
<value>Документ со справочниками</value>
|
||||||
|
</data>
|
||||||
|
<data name="CountReportToolStripMenuItem.ShortcutKeys" type="System.Windows.Forms.Keys, System.Windows.Forms">
|
||||||
|
<value>Ctrl+E</value>
|
||||||
|
</data>
|
||||||
|
<data name="CountReportToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>350, 26</value>
|
||||||
|
</data>
|
||||||
|
<data name="CountReportToolStripMenuItem.Text" xml:space="preserve">
|
||||||
|
<value>Движение заказов</value>
|
||||||
|
</data>
|
||||||
<data name="ReportsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="ReportsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>73, 24</value>
|
<value>73, 24</value>
|
||||||
</data>
|
</data>
|
||||||
@ -183,17 +190,29 @@
|
|||||||
<value>Заказчики</value>
|
<value>Заказчики</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="MaterialsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="MaterialsToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>224, 26</value>
|
<value>185, 26</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="MaterialsToolStripMenuItem.Text" xml:space="preserve">
|
<data name="MaterialsToolStripMenuItem.Text" xml:space="preserve">
|
||||||
<value>Материалы</value>
|
<value>Материалы</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="PublishingHousesToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
<data name="PublishingHousesToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
<value>224, 26</value>
|
<value>185, 26</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="PublishingHousesToolStripMenuItem.Text" xml:space="preserve">
|
<data name="PublishingHousesToolStripMenuItem.Text" xml:space="preserve">
|
||||||
<value>Издательства</value>
|
<value>Издательства</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="CreateOrderToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>188, 26</value>
|
||||||
|
</data>
|
||||||
|
<data name="CreateOrderToolStripMenuItem.Text" xml:space="preserve">
|
||||||
|
<value>Создать заказ</value>
|
||||||
|
</data>
|
||||||
|
<data name="PrintingToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
|
||||||
|
<value>188, 26</value>
|
||||||
|
</data>
|
||||||
|
<data name="PrintingToolStripMenuItem.Text" xml:space="preserve">
|
||||||
|
<value>Печать</value>
|
||||||
|
</data>
|
||||||
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="$this.Localizable" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
@ -2156,7 +2175,6 @@
|
|||||||
Gg8Vxln/2Q==
|
Gg8Vxln/2Q==
|
||||||
</value>
|
</value>
|
||||||
</data>
|
</data>
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
|
||||||
<data name="$this.BackgroundImageLayout" type="System.Windows.Forms.ImageLayout, System.Windows.Forms">
|
<data name="$this.BackgroundImageLayout" type="System.Windows.Forms.ImageLayout, System.Windows.Forms">
|
||||||
<value>Stretch</value>
|
<value>Stretch</value>
|
||||||
</data>
|
</data>
|
||||||
@ -2217,6 +2235,18 @@
|
|||||||
<data name=">>ReportsToolStripMenuItem.Type" xml:space="preserve">
|
<data name=">>ReportsToolStripMenuItem.Type" xml:space="preserve">
|
||||||
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name=">>DirectoryReportToolStripMenuItem.Name" xml:space="preserve">
|
||||||
|
<value>DirectoryReportToolStripMenuItem</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>DirectoryReportToolStripMenuItem.Type" xml:space="preserve">
|
||||||
|
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>CountReportToolStripMenuItem.Name" xml:space="preserve">
|
||||||
|
<value>CountReportToolStripMenuItem</value>
|
||||||
|
</data>
|
||||||
|
<data name=">>CountReportToolStripMenuItem.Type" xml:space="preserve">
|
||||||
|
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
<data name=">>$this.Name" xml:space="preserve">
|
<data name=">>$this.Name" xml:space="preserve">
|
||||||
<value>Publication</value>
|
<value>Publication</value>
|
||||||
</data>
|
</data>
|
||||||
|
86
Publication/Reports/PdfBuilder.cs
Normal file
86
Publication/Reports/PdfBuilder.cs
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Publication.Reports;
|
||||||
|
|
||||||
|
public class PdfBuilder
|
||||||
|
{
|
||||||
|
/*private readonly string _filePath;
|
||||||
|
private readonly Document _document;
|
||||||
|
public PdfBuilder(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(filePath));
|
||||||
|
}
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
_filePath = filePath;
|
||||||
|
_document = new Document();
|
||||||
|
DefineStyles();
|
||||||
|
}
|
||||||
|
public PdfBuilder AddHeader(string header)
|
||||||
|
{
|
||||||
|
_document.AddSection().AddParagraph(header, "NormalBold");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
|
||||||
|
{
|
||||||
|
if (data == null || data.Count == 0)
|
||||||
|
{
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
var chart = new Chart(ChartType.Pie2D);
|
||||||
|
var series = chart.SeriesCollection.AddSeries();
|
||||||
|
series.Add(data.Select(x => x.Value).ToArray());
|
||||||
|
|
||||||
|
var xseries = chart.XValues.AddXSeries();
|
||||||
|
xseries.Add(data.Select(x => x.Caption).ToArray());
|
||||||
|
|
||||||
|
chart.DataLabel.Type = DataLabelType.Percent;
|
||||||
|
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
||||||
|
|
||||||
|
chart.Width = Unit.FromCentimeter(16);
|
||||||
|
chart.Height = Unit.FromCentimeter(12);
|
||||||
|
|
||||||
|
chart.TopArea.AddParagraph(title);
|
||||||
|
|
||||||
|
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||||
|
|
||||||
|
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||||
|
chart.YAxis.HasMajorGridlines = true;
|
||||||
|
|
||||||
|
chart.PlotArea.LineFormat.Width = 1;
|
||||||
|
chart.PlotArea.LineFormat.Visible = true;
|
||||||
|
|
||||||
|
chart.TopArea.AddLegend();
|
||||||
|
|
||||||
|
_document.LastSection.Add(chart);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Build()
|
||||||
|
{
|
||||||
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||||
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
|
{
|
||||||
|
Document = _document
|
||||||
|
};
|
||||||
|
renderer.RenderDocument();
|
||||||
|
renderer.PdfDocument.Save(_filePath);
|
||||||
|
}
|
||||||
|
private void DefineStyles()
|
||||||
|
{
|
||||||
|
var headerStyle = _document.AddStyle("NormalBold", "Normal");
|
||||||
|
headerStyle.Font.Bold = true;
|
||||||
|
headerStyle.Font.Size = 14;
|
||||||
|
headerStyle.Font.Color = Colors.DeepPink;
|
||||||
|
}*/
|
||||||
|
}
|
@ -3,6 +3,7 @@ using Newtonsoft.Json;
|
|||||||
using Npgsql;
|
using Npgsql;
|
||||||
using Publication.Entites;
|
using Publication.Entites;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace Publication.Repositories.Implementations;
|
namespace Publication.Repositories.Implementations;
|
||||||
|
|
||||||
@ -75,10 +76,15 @@ public class PrintingHouseRepository : IPrintingHouseRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(connectionRepository.GetConnection);
|
using var connection = new NpgsqlConnection(connectionRepository.GetConnection);
|
||||||
var querySelect = "SELECT * FROM PrintingHouses";
|
var querySelect = @"SELECT ph.*, pho.OrderId, pho.Count
|
||||||
var printingHouses = connection.Query<PrintingHouses>(querySelect);
|
FROM PrintingHouses ph
|
||||||
|
INNER JOIN PrintingHouseOrders pho ON pho.PrintingHouseId = ph.Id";
|
||||||
|
var printingHouses = connection.Query<TempPrintingHouseOrders>(querySelect);
|
||||||
logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(printingHouses));
|
logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(printingHouses));
|
||||||
return printingHouses;
|
return printingHouses.GroupBy(x => x.Id, y => y,
|
||||||
|
(key, value) => PrintingHouses.CreateEntity(value.First(),
|
||||||
|
value.Select(z => PrintingHouseOrders.CreateEntity(0, z.OrderId, z.Count)))).ToList();
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user