Лабараторная номер 3
This commit is contained in:
parent
ba0ecef360
commit
495cc259ca
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using DocumentFormat.OpenXml.Bibliography;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -25,7 +26,22 @@ public class RoutSheet
|
|||||||
ConductorId = conductorid,
|
ConductorId = conductorid,
|
||||||
RoutId = routid,
|
RoutId = routid,
|
||||||
RoutSheetBus = RoutSheetBus,
|
RoutSheetBus = RoutSheetBus,
|
||||||
BusDate = busDate,
|
BusDate = busDate
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static RoutSheet CreatOpeartion(TempRoutSheetBus tempRoutSheetBus, IEnumerable<RoutSheetBus> RoutSheetBus)
|
||||||
|
{
|
||||||
|
return new RoutSheet
|
||||||
|
{
|
||||||
|
Id = tempRoutSheetBus.Id,
|
||||||
|
DriverId = tempRoutSheetBus.DriverId,
|
||||||
|
ConductorId = tempRoutSheetBus.ConductorId,
|
||||||
|
RoutId = tempRoutSheetBus.RoutId,
|
||||||
|
RoutSheetBus = RoutSheetBus,
|
||||||
|
BusDate = tempRoutSheetBus.BusDate
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||||
|
|
||||||
|
public class TempRoutSheetBus
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int DriverId { get; private set; }
|
||||||
|
public int ConductorId { get; private set; }
|
||||||
|
|
||||||
|
public int RoutId { get; private set; }
|
||||||
|
|
||||||
|
public DateTime BusDate { get; private set; }
|
||||||
|
|
||||||
|
public int BusId { get; private set; }
|
||||||
|
public decimal Cost { get; private set; }
|
||||||
|
}
|
@ -18,14 +18,14 @@ public class To
|
|||||||
public double Cost { get; private set; }
|
public double Cost { get; private set; }
|
||||||
public DateTime DateTo { get; private set; }
|
public DateTime DateTo { get; private set; }
|
||||||
|
|
||||||
public static To CreatOperation(int id, string discription, double cost, int busid, int staffid)
|
public static To CreatOperation(int id, string discription, double cost, DateTime dateTo, int busid, int staffid)
|
||||||
{
|
{
|
||||||
return new To()
|
return new To()
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Discription = discription ?? string.Empty,
|
Discription = discription ?? string.Empty,
|
||||||
Cost = cost,
|
Cost = cost,
|
||||||
DateTo = DateTime.Now,
|
DateTo = dateTo,
|
||||||
BusID = busid,
|
BusID = busid,
|
||||||
StaffID = staffid
|
StaffID = staffid
|
||||||
};
|
};
|
||||||
|
@ -37,6 +37,9 @@
|
|||||||
RoutSheetToolStripMenuItem = new ToolStripMenuItem();
|
RoutSheetToolStripMenuItem = new ToolStripMenuItem();
|
||||||
ToesToolStripMenuItem = new ToolStripMenuItem();
|
ToesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ToolStripMenuItemTo = new ToolStripMenuItem();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -100,10 +103,35 @@
|
|||||||
//
|
//
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, ToolStripMenuItem, ToolStripMenuItemTo });
|
||||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
//
|
//
|
||||||
|
// DirectoryReportToolStripMenuItem
|
||||||
|
//
|
||||||
|
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
|
||||||
|
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||||
|
DirectoryReportToolStripMenuItem.Size = new Size(362, 22);
|
||||||
|
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
|
||||||
|
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// ToolStripMenuItem
|
||||||
|
//
|
||||||
|
ToolStripMenuItem.Name = "ToolStripMenuItem";
|
||||||
|
ToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||||
|
ToolStripMenuItem.Size = new Size(362, 22);
|
||||||
|
ToolStripMenuItem.Text = "Сводка по Автобусам";
|
||||||
|
ToolStripMenuItem.Click += ToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// ToolStripMenuItemTo
|
||||||
|
//
|
||||||
|
ToolStripMenuItemTo.Name = "ToolStripMenuItemTo";
|
||||||
|
ToolStripMenuItemTo.ShortcutKeys = Keys.Control | Keys.P;
|
||||||
|
ToolStripMenuItemTo.Size = new Size(362, 22);
|
||||||
|
ToolStripMenuItemTo.Text = "Распределение Технического обслуживания";
|
||||||
|
ToolStripMenuItemTo.Click += ToolStripMenuItemTo_Click;
|
||||||
|
//
|
||||||
// FormBus
|
// FormBus
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -133,5 +161,8 @@
|
|||||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
private ToolStripMenuItem ToesToolStripMenuItem;
|
private ToolStripMenuItem ToesToolStripMenuItem;
|
||||||
private ToolStripMenuItem ToToolStripMenuItem;
|
private ToolStripMenuItem ToToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ToolStripMenuItemTo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public partial class FormBus : Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void RoutSheetToolStripMenuItem_Click(object sender, EventArgs e)
|
private void RoutSheetToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -77,4 +77,41 @@ public partial class FormBus : Form
|
|||||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DirectoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormDirectoryReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormBusReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ToolStripMenuItemTo_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormToDistributionReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
163
PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBusReport.Designer.cs
generated
Normal file
163
PIbd-24_EredavkinRA_BusBusiness/PIbd-24_EredavkinRA_BusBusiness/Forms/FormBusReport.Designer.cs
generated
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
|
||||||
|
{
|
||||||
|
partial class FormBusReport
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
dateTimePickerDateBegin = new DateTimePicker();
|
||||||
|
dateTimePickerDateEnd = new DateTimePicker();
|
||||||
|
comboBoxBus = new ComboBox();
|
||||||
|
textBoxFilePath = new TextBox();
|
||||||
|
buttonSelectFilePath = new Button();
|
||||||
|
label1 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
label4 = new Label();
|
||||||
|
buttonMakeReport = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dateTimePickerDateBegin
|
||||||
|
//
|
||||||
|
dateTimePickerDateBegin.Location = new Point(123, 115);
|
||||||
|
dateTimePickerDateBegin.Name = "dateTimePickerDateBegin";
|
||||||
|
dateTimePickerDateBegin.Size = new Size(278, 23);
|
||||||
|
dateTimePickerDateBegin.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// dateTimePickerDateEnd
|
||||||
|
//
|
||||||
|
dateTimePickerDateEnd.Location = new Point(123, 156);
|
||||||
|
dateTimePickerDateEnd.Name = "dateTimePickerDateEnd";
|
||||||
|
dateTimePickerDateEnd.Size = new Size(278, 23);
|
||||||
|
dateTimePickerDateEnd.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// comboBoxBus
|
||||||
|
//
|
||||||
|
comboBoxBus.FormattingEnabled = true;
|
||||||
|
comboBoxBus.Location = new Point(123, 56);
|
||||||
|
comboBoxBus.Name = "comboBoxBus";
|
||||||
|
comboBoxBus.Size = new Size(278, 23);
|
||||||
|
comboBoxBus.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// textBoxFilePath
|
||||||
|
//
|
||||||
|
textBoxFilePath.Location = new Point(123, 9);
|
||||||
|
textBoxFilePath.Name = "textBoxFilePath";
|
||||||
|
textBoxFilePath.ReadOnly = true;
|
||||||
|
textBoxFilePath.Size = new Size(208, 23);
|
||||||
|
textBoxFilePath.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonSelectFilePath
|
||||||
|
//
|
||||||
|
buttonSelectFilePath.Location = new Point(337, 12);
|
||||||
|
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
||||||
|
buttonSelectFilePath.Size = new Size(64, 24);
|
||||||
|
buttonSelectFilePath.TabIndex = 4;
|
||||||
|
buttonSelectFilePath.Text = "...";
|
||||||
|
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
||||||
|
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(12, 9);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(87, 15);
|
||||||
|
label1.TabIndex = 5;
|
||||||
|
label1.Text = "Путь до файла";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(37, 64);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(52, 15);
|
||||||
|
label2.TabIndex = 6;
|
||||||
|
label2.Text = "Автобус";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(31, 115);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(74, 15);
|
||||||
|
label3.TabIndex = 7;
|
||||||
|
label3.Text = "Дата начала";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(37, 162);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(68, 15);
|
||||||
|
label4.TabIndex = 8;
|
||||||
|
label4.Text = "Дата конца";
|
||||||
|
//
|
||||||
|
// buttonMakeReport
|
||||||
|
//
|
||||||
|
buttonMakeReport.Location = new Point(123, 204);
|
||||||
|
buttonMakeReport.Name = "buttonMakeReport";
|
||||||
|
buttonMakeReport.Size = new Size(204, 23);
|
||||||
|
buttonMakeReport.TabIndex = 9;
|
||||||
|
buttonMakeReport.Text = "Сформировать";
|
||||||
|
buttonMakeReport.UseVisualStyleBackColor = true;
|
||||||
|
buttonMakeReport.Click += ButtonMakeReport_Click;
|
||||||
|
//
|
||||||
|
// FormBusReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(425, 243);
|
||||||
|
Controls.Add(buttonMakeReport);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(buttonSelectFilePath);
|
||||||
|
Controls.Add(textBoxFilePath);
|
||||||
|
Controls.Add(comboBoxBus);
|
||||||
|
Controls.Add(dateTimePickerDateEnd);
|
||||||
|
Controls.Add(dateTimePickerDateBegin);
|
||||||
|
Name = "FormBusReport";
|
||||||
|
Text = "FormBusReport";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DateTimePicker dateTimePickerDateBegin;
|
||||||
|
private DateTimePicker dateTimePickerDateEnd;
|
||||||
|
private ComboBox comboBoxBus;
|
||||||
|
private TextBox textBoxFilePath;
|
||||||
|
private Button buttonSelectFilePath;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private Button buttonMakeReport;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
using PIbd_24_EredavkinRA_BusBusiness.Reports;
|
||||||
|
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
|
||||||
|
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 Unity;
|
||||||
|
|
||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Forms;
|
||||||
|
|
||||||
|
|
||||||
|
public partial class FormBusReport : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
public FormBusReport(IUnityContainer container, IBusRepository busRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentNullException(nameof(container));
|
||||||
|
comboBoxBus.DataSource = busRepository.ReadBus();
|
||||||
|
comboBoxBus.DisplayMember = "N_Z";
|
||||||
|
comboBoxBus.ValueMember = "Id";
|
||||||
|
}
|
||||||
|
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 (comboBoxBus.SelectedIndex < 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран автобус");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dateTimePickerDateEnd.Value <= dateTimePickerDateBegin.Value)
|
||||||
|
{
|
||||||
|
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text,
|
||||||
|
(int)comboBoxBus.SelectedValue!, dateTimePickerDateBegin.Value, dateTimePickerDateEnd.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -0,0 +1,99 @@
|
|||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
|
||||||
|
{
|
||||||
|
partial class FormDirectoryReport
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
checkBoxStaff = new CheckBox();
|
||||||
|
checkBoxRout = new CheckBox();
|
||||||
|
checkBoxBus = new CheckBox();
|
||||||
|
buttonBuild = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// checkBoxStaff
|
||||||
|
//
|
||||||
|
checkBoxStaff.AutoSize = true;
|
||||||
|
checkBoxStaff.Location = new Point(12, 12);
|
||||||
|
checkBoxStaff.Name = "checkBoxStaff";
|
||||||
|
checkBoxStaff.Size = new Size(92, 19);
|
||||||
|
checkBoxStaff.TabIndex = 0;
|
||||||
|
checkBoxStaff.Text = "Сотрудники";
|
||||||
|
checkBoxStaff.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxRout
|
||||||
|
//
|
||||||
|
checkBoxRout.AutoSize = true;
|
||||||
|
checkBoxRout.Location = new Point(12, 53);
|
||||||
|
checkBoxRout.Name = "checkBoxRout";
|
||||||
|
checkBoxRout.Size = new Size(88, 19);
|
||||||
|
checkBoxRout.TabIndex = 1;
|
||||||
|
checkBoxRout.Text = "Маршруты";
|
||||||
|
checkBoxRout.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxBus
|
||||||
|
//
|
||||||
|
checkBoxBus.AutoSize = true;
|
||||||
|
checkBoxBus.Location = new Point(12, 98);
|
||||||
|
checkBoxBus.Name = "checkBoxBus";
|
||||||
|
checkBoxBus.Size = new Size(83, 19);
|
||||||
|
checkBoxBus.TabIndex = 2;
|
||||||
|
checkBoxBus.Text = "Автобусы ";
|
||||||
|
checkBoxBus.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonBuild
|
||||||
|
//
|
||||||
|
buttonBuild.Location = new Point(193, 53);
|
||||||
|
buttonBuild.Name = "buttonBuild";
|
||||||
|
buttonBuild.Size = new Size(134, 23);
|
||||||
|
buttonBuild.TabIndex = 3;
|
||||||
|
buttonBuild.Text = "Сформировать";
|
||||||
|
buttonBuild.UseVisualStyleBackColor = true;
|
||||||
|
buttonBuild.Click += buttonBuild_Click;
|
||||||
|
//
|
||||||
|
// FormDirectoryReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(372, 142);
|
||||||
|
Controls.Add(buttonBuild);
|
||||||
|
Controls.Add(checkBoxBus);
|
||||||
|
Controls.Add(checkBoxRout);
|
||||||
|
Controls.Add(checkBoxStaff);
|
||||||
|
Name = "FormDirectoryReport";
|
||||||
|
Text = "FormDirectoryReport";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private CheckBox checkBoxStaff;
|
||||||
|
private CheckBox checkBoxRout;
|
||||||
|
private CheckBox checkBoxBus;
|
||||||
|
private Button buttonBuild;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
using PIbd_24_EredavkinRA_BusBusiness.Reports;
|
||||||
|
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 Unity;
|
||||||
|
|
||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
|
||||||
|
{
|
||||||
|
public partial class FormDirectoryReport : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
public FormDirectoryReport(IUnityContainer container)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonBuild_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!checkBoxBus.Checked && !checkBoxStaff.Checked && !checkBoxRout.Checked)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран ни один справочник для выгрузки");
|
||||||
|
}
|
||||||
|
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Docx Files | *.docx"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (sfd.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран файла для отчета");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxBus.Checked,
|
||||||
|
checkBoxRout.Checked, checkBoxStaff.Checked))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ сформирован", "Формирование документа",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||||
|
"Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -31,7 +31,7 @@ public partial class FormTO : Form
|
|||||||
{
|
{
|
||||||
throw new Exception("Имеются не заполненые поля");
|
throw new Exception("Имеются не заполненые поля");
|
||||||
}
|
}
|
||||||
_toRepository.CreateTo(To.CreatOperation(0, textBoxDescription.Text, Convert.ToDouble(numericUpDownCost.Value), (int)comboBoxBus.SelectedValue!,
|
_toRepository.CreateTo(To.CreatOperation(0, textBoxDescription.Text, Convert.ToDouble(numericUpDownCost.Value), dateTimePicker1.Value, (int)comboBoxBus.SelectedValue!,
|
||||||
(int)comboBoxStaff.SelectedValue!));
|
(int)comboBoxStaff.SelectedValue!));
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,107 @@
|
|||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Forms
|
||||||
|
{
|
||||||
|
partial class FormToDistributionReport
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
dateTimePicker = new DateTimePicker();
|
||||||
|
ButtonChoice = new Button();
|
||||||
|
labelFileName = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
buttontoform = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dateTimePicker
|
||||||
|
//
|
||||||
|
dateTimePicker.Location = new Point(100, 72);
|
||||||
|
dateTimePicker.Name = "dateTimePicker";
|
||||||
|
dateTimePicker.Size = new Size(168, 23);
|
||||||
|
dateTimePicker.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ButtonChoice
|
||||||
|
//
|
||||||
|
ButtonChoice.Location = new Point(23, 25);
|
||||||
|
ButtonChoice.Name = "ButtonChoice";
|
||||||
|
ButtonChoice.Size = new Size(75, 23);
|
||||||
|
ButtonChoice.TabIndex = 1;
|
||||||
|
ButtonChoice.Text = "Выбрать";
|
||||||
|
ButtonChoice.UseVisualStyleBackColor = true;
|
||||||
|
ButtonChoice.Click += ButtonChoice_Click;
|
||||||
|
//
|
||||||
|
// labelFileName
|
||||||
|
//
|
||||||
|
labelFileName.AutoSize = true;
|
||||||
|
labelFileName.Location = new Point(120, 29);
|
||||||
|
labelFileName.Name = "labelFileName";
|
||||||
|
labelFileName.Size = new Size(36, 15);
|
||||||
|
labelFileName.TabIndex = 2;
|
||||||
|
labelFileName.Text = "Файл";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(23, 78);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(32, 15);
|
||||||
|
label2.TabIndex = 3;
|
||||||
|
label2.Text = "Дата";
|
||||||
|
//
|
||||||
|
// buttontoform
|
||||||
|
//
|
||||||
|
buttontoform.Location = new Point(70, 139);
|
||||||
|
buttontoform.Name = "buttontoform";
|
||||||
|
buttontoform.Size = new Size(117, 23);
|
||||||
|
buttontoform.TabIndex = 4;
|
||||||
|
buttontoform.Text = "Сформировать";
|
||||||
|
buttontoform.UseVisualStyleBackColor = true;
|
||||||
|
buttontoform.Click += buttontoform_Click;
|
||||||
|
//
|
||||||
|
// FormToDistributionReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(280, 209);
|
||||||
|
Controls.Add(buttontoform);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(labelFileName);
|
||||||
|
Controls.Add(ButtonChoice);
|
||||||
|
Controls.Add(dateTimePicker);
|
||||||
|
Name = "FormToDistributionReport";
|
||||||
|
Text = "FormToDistributionReport";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DateTimePicker dateTimePicker;
|
||||||
|
private Button ButtonChoice;
|
||||||
|
private Label labelFileName;
|
||||||
|
private Label label2;
|
||||||
|
private Button buttontoform;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
using PIbd_24_EredavkinRA_BusBusiness.Reports;
|
||||||
|
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 Unity;
|
||||||
|
|
||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Forms;
|
||||||
|
|
||||||
|
public partial class FormToDistributionReport : Form
|
||||||
|
{
|
||||||
|
private string _fileName = string.Empty;
|
||||||
|
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
public FormToDistributionReport(IUnityContainer container)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
private void ButtonChoice_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Pdf Files | *.pdf"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (sfd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_fileName = sfd.FileName;
|
||||||
|
labelFileName.Text = Path.GetFileName(_fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void buttontoform_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(_fileName))
|
||||||
|
{
|
||||||
|
throw new Exception("Отсутствует имя файла для отчета");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -11,11 +11,13 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||||
|
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Npgsql" Version="9.0.1" />
|
<PackageReference Include="Npgsql" Version="9.0.1" />
|
||||||
|
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||||
|
@ -0,0 +1,52 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Reports;
|
||||||
|
|
||||||
|
internal class ChartReport
|
||||||
|
{
|
||||||
|
private readonly IToRepository _toRepository;
|
||||||
|
|
||||||
|
private readonly ILogger<ChartReport> _logger;
|
||||||
|
|
||||||
|
public ChartReport(IToRepository toRepository, ILogger<ChartReport> logger)
|
||||||
|
{
|
||||||
|
_toRepository = toRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(toRepository));
|
||||||
|
_logger = logger ??
|
||||||
|
throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateChart(string filePath, DateTime dateTime)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new PdfBuilder(filePath)
|
||||||
|
.AddHeader("Количество Обслуживаний Автобуса за день")
|
||||||
|
.AddPieChart("Автобусы", GetData(dateTime))
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||||
|
{
|
||||||
|
return _toRepository
|
||||||
|
.ReadTo()
|
||||||
|
.Where(x => x.DateTo.Date == dateTime.Date)
|
||||||
|
.GroupBy(x => x.BusID, (key, cost) => new { Id = key, Count = cost.Count() })
|
||||||
|
.Select(x => (x.Id.ToString(), (double)x.Count))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,103 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Reports;
|
||||||
|
|
||||||
|
internal class DocReport
|
||||||
|
{
|
||||||
|
private readonly IBusRepository _busRepository;
|
||||||
|
|
||||||
|
private readonly IRoutRepositories _routRepository;
|
||||||
|
|
||||||
|
private readonly IStaffRepositories _staffRepository;
|
||||||
|
|
||||||
|
private readonly ILogger<DocReport> _logger;
|
||||||
|
|
||||||
|
public DocReport(IBusRepository busRepository,
|
||||||
|
IRoutRepositories routRepository, IStaffRepositories staffRepository, ILogger<DocReport> logger)
|
||||||
|
{
|
||||||
|
_busRepository = busRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(busRepository));
|
||||||
|
_routRepository = routRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(routRepository));
|
||||||
|
_staffRepository = staffRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(staffRepository));
|
||||||
|
_logger = logger ??
|
||||||
|
throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
public bool CreateDoc(string filePath, bool includeBus, bool includeRout,
|
||||||
|
bool includeStaff)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var builder = new WordBuilder(filePath)
|
||||||
|
.AddHeader("Документ со справочниками");
|
||||||
|
|
||||||
|
if (includeBus)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Автобусы")
|
||||||
|
.AddTable([1200, 2400, 1200], GetBuses());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeRout)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Маршруты")
|
||||||
|
.AddTable([2400, 2400, 2400], GetRout());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeStaff)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Сотрудники")
|
||||||
|
.AddTable([2400, 2400, 2400], GetStaff());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
builder.Build();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetBuses()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Модель", "Номерной знак", "Количество мест"],
|
||||||
|
.. _busRepository
|
||||||
|
.ReadBus()
|
||||||
|
.Select(x => new string[] { x.ModelType.ToString(), x.N_Z, x.Capacity.ToString() }),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private List<string[]> GetStaff()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Фамилия", "Имя", "Должность"],
|
||||||
|
.. _staffRepository
|
||||||
|
.ReadStaff()
|
||||||
|
.Select(x => new string[] { x.LastName, x.FirstName, x.EmployeePost.ToString() }),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetRout()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Номер Маршрута", "Начальная остановка", "Конечная остановка"],
|
||||||
|
.. _routRepository
|
||||||
|
.ReadRout()
|
||||||
|
.Select(x => new string[] { x.NumberRout.ToString(), x.StartStop, x.EndStop }),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,328 @@
|
|||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Spreadsheet;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Reports;
|
||||||
|
|
||||||
|
internal class ExcelBuilder
|
||||||
|
{
|
||||||
|
private readonly string _filePath;
|
||||||
|
|
||||||
|
private readonly SheetData _sheetData;
|
||||||
|
|
||||||
|
private readonly MergeCells _mergeCells;
|
||||||
|
|
||||||
|
private readonly Columns _columns;
|
||||||
|
|
||||||
|
private uint _rowIndex = 0;
|
||||||
|
|
||||||
|
public ExcelBuilder(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(filePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filePath = filePath;
|
||||||
|
_sheetData = new SheetData();
|
||||||
|
_mergeCells = new MergeCells();
|
||||||
|
_columns = new Columns();
|
||||||
|
_rowIndex = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
||||||
|
{
|
||||||
|
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
|
||||||
|
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||||
|
{
|
||||||
|
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
||||||
|
}
|
||||||
|
|
||||||
|
_mergeCells.Append(new MergeCell()
|
||||||
|
{
|
||||||
|
Reference =
|
||||||
|
new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
|
||||||
|
});
|
||||||
|
|
||||||
|
_rowIndex++;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExcelBuilder AddParagraph(string text, int columnIndex)
|
||||||
|
{
|
||||||
|
CreateCell(columnIndex, _rowIndex++, text, StyleIndex.SimpleTextWithoutBorder);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
|
||||||
|
{
|
||||||
|
if (columnsWidths == null || columnsWidths.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(columnsWidths));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data == null || data.Count == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.Any(x => x.Length != columnsWidths.Length))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("columnsWidths.Length != data.Length");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint counter = 1;
|
||||||
|
int coef = 2;
|
||||||
|
_columns.Append(columnsWidths.Select(x => new Column
|
||||||
|
{
|
||||||
|
Min = counter,
|
||||||
|
Max = counter++,
|
||||||
|
Width = x * coef,
|
||||||
|
CustomWidth = true
|
||||||
|
}));
|
||||||
|
|
||||||
|
for (var j = 0; j < data.First().Length; ++j)
|
||||||
|
{
|
||||||
|
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
|
||||||
|
}
|
||||||
|
|
||||||
|
_rowIndex++;
|
||||||
|
for (var i = 1; i < data.Count - 1; ++i)
|
||||||
|
{
|
||||||
|
for (var j = 0; j < data[i].Length; ++j)
|
||||||
|
{
|
||||||
|
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder);
|
||||||
|
}
|
||||||
|
|
||||||
|
_rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var j = 0; j < data.Last().Length; ++j)
|
||||||
|
{
|
||||||
|
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
|
||||||
|
}
|
||||||
|
|
||||||
|
_rowIndex++;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Build()
|
||||||
|
{
|
||||||
|
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath, SpreadsheetDocumentType.Workbook);
|
||||||
|
var workbookpart = spreadsheetDocument.AddWorkbookPart();
|
||||||
|
GenerateStyle(workbookpart);
|
||||||
|
workbookpart.Workbook = new Workbook();
|
||||||
|
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||||
|
worksheetPart.Worksheet = new Worksheet();
|
||||||
|
if (_columns.HasChildren)
|
||||||
|
{
|
||||||
|
worksheetPart.Worksheet.Append(_columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
worksheetPart.Worksheet.Append(_sheetData);
|
||||||
|
var sheets = spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
||||||
|
var sheet = new Sheet()
|
||||||
|
{
|
||||||
|
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||||
|
SheetId = 1,
|
||||||
|
Name = "Лист 1"
|
||||||
|
};
|
||||||
|
|
||||||
|
sheets.Append(sheet);
|
||||||
|
if (_mergeCells.HasChildren)
|
||||||
|
{
|
||||||
|
worksheetPart.Worksheet.InsertAfter(_mergeCells, worksheetPart.Worksheet.Elements<SheetData>().First());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GenerateStyle(WorkbookPart workbookPart)
|
||||||
|
{
|
||||||
|
var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>();
|
||||||
|
workbookStylesPart.Stylesheet = new Stylesheet();
|
||||||
|
|
||||||
|
var fonts = new Fonts() { Count = 2, KnownFonts = BooleanValue.FromBoolean(true) };
|
||||||
|
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) }
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Default Fill
|
||||||
|
var fills = new Fills() { Count = 1 };
|
||||||
|
fills.Append(new Fill
|
||||||
|
{
|
||||||
|
PatternFill = new PatternFill() { PatternType = new EnumValue<PatternValues>(PatternValues.None) }
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(fills);
|
||||||
|
|
||||||
|
// Default Border
|
||||||
|
var borders = new Borders() { Count = 2 };
|
||||||
|
borders.Append(new Border
|
||||||
|
{
|
||||||
|
LeftBorder = new LeftBorder(),
|
||||||
|
RightBorder = new RightBorder(),
|
||||||
|
TopBorder = new TopBorder(),
|
||||||
|
BottomBorder = new BottomBorder(),
|
||||||
|
DiagonalBorder = new DiagonalBorder()
|
||||||
|
});
|
||||||
|
|
||||||
|
borders.Append(new Border
|
||||||
|
{
|
||||||
|
LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
RightBorder = new RightBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
TopBorder = new TopBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin },
|
||||||
|
DiagonalBorder = new DiagonalBorder()
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(borders);
|
||||||
|
|
||||||
|
// Default cell format and a date cell format
|
||||||
|
var cellFormats = new CellFormats() { Count = 4 };
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 0,
|
||||||
|
BorderId = 0,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Left,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 0,
|
||||||
|
BorderId = 1,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Right,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 1,
|
||||||
|
BorderId = 0,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Center,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
cellFormats.Append(new CellFormat
|
||||||
|
{
|
||||||
|
NumberFormatId = 0,
|
||||||
|
FormatId = 0,
|
||||||
|
FontId = 1,
|
||||||
|
BorderId = 1,
|
||||||
|
FillId = 0,
|
||||||
|
Alignment = new Alignment()
|
||||||
|
{
|
||||||
|
Horizontal = HorizontalAlignmentValues.Center,
|
||||||
|
Vertical = VerticalAlignmentValues.Center,
|
||||||
|
WrapText = true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum StyleIndex
|
||||||
|
{
|
||||||
|
SimpleTextWithoutBorder = 0,
|
||||||
|
SimpleTextWithBorder = 1,
|
||||||
|
BoldTextWithoutBorder = 2,
|
||||||
|
BoldTextWithBorder = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
|
||||||
|
{
|
||||||
|
var columnName = GetExcelColumnName(columnIndex);
|
||||||
|
var cellReference = columnName + rowIndex;
|
||||||
|
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex! == rowIndex);
|
||||||
|
if (row == null)
|
||||||
|
{
|
||||||
|
row = new Row() { RowIndex = rowIndex };
|
||||||
|
_sheetData.Append(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
var newCell = row.Elements<Cell>()
|
||||||
|
.FirstOrDefault(c => c.CellReference != null && c.CellReference.Value == columnName + rowIndex);
|
||||||
|
if (newCell == null)
|
||||||
|
{
|
||||||
|
Cell? refCell = null;
|
||||||
|
foreach (Cell cell in row.Elements<Cell>())
|
||||||
|
{
|
||||||
|
if (cell.CellReference?.Value != null && cell.CellReference.Value.Length == cellReference.Length)
|
||||||
|
{
|
||||||
|
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
|
||||||
|
{
|
||||||
|
refCell = cell;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newCell = new Cell() { CellReference = cellReference };
|
||||||
|
row.InsertBefore(newCell, refCell);
|
||||||
|
}
|
||||||
|
|
||||||
|
newCell.CellValue = new CellValue(text);
|
||||||
|
newCell.DataType = CellValues.String;
|
||||||
|
newCell.StyleIndex = (uint)styleIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetExcelColumnName(int columnNumber)
|
||||||
|
{
|
||||||
|
columnNumber += 1;
|
||||||
|
int dividend = columnNumber;
|
||||||
|
string columnName = string.Empty;
|
||||||
|
int modulo;
|
||||||
|
|
||||||
|
while (dividend > 0)
|
||||||
|
{
|
||||||
|
modulo = (dividend - 1) % 26;
|
||||||
|
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
|
||||||
|
dividend = (dividend - modulo) / 26;
|
||||||
|
}
|
||||||
|
|
||||||
|
return columnName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
using MigraDoc.DocumentObjectModel;
|
||||||
|
using MigraDoc.Rendering;
|
||||||
|
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Reports;
|
||||||
|
|
||||||
|
internal 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.Styles.AddStyle("NormalBold", "Normal");
|
||||||
|
headerStyle.Font.Bold = true;
|
||||||
|
headerStyle.Font.Size = 14;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using PIbd_24_EredavkinRA_BusBusiness.Entities;
|
||||||
|
using PIbd_24_EredavkinRA_BusBusiness.Repositories;
|
||||||
|
using PIbd_24_EredavkinRA_BusBusiness.Repositories.Implementations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Reports;
|
||||||
|
|
||||||
|
internal class TableReport
|
||||||
|
{
|
||||||
|
private readonly IRoutSheetRepository _routsheetRepository;
|
||||||
|
|
||||||
|
private readonly IToRepository _toRepository;
|
||||||
|
|
||||||
|
private readonly IBusRepository _busRepository;
|
||||||
|
|
||||||
|
private readonly ILogger<TableReport> _logger;
|
||||||
|
|
||||||
|
internal static readonly string[] item = ["Дата", "Номер Маршрута", "Стоимость ремонта"];
|
||||||
|
|
||||||
|
public TableReport(IRoutSheetRepository routsheetRepository, IToRepository toRepository, IBusRepository busRepository, ILogger<TableReport> logger)
|
||||||
|
{
|
||||||
|
_routsheetRepository = routsheetRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(routsheetRepository));
|
||||||
|
_toRepository = toRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(toRepository));
|
||||||
|
_busRepository = busRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(busRepository));
|
||||||
|
|
||||||
|
|
||||||
|
_logger = logger ??
|
||||||
|
throw new ArgumentNullException(nameof(logger));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateTable(string filePath, int busId, DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new ExcelBuilder(filePath)
|
||||||
|
.AddHeader("Общая сводка за Автобусами", 0, 3)
|
||||||
|
.AddParagraph("за период", 0)
|
||||||
|
.AddTable([15, 10, 10], GetData(busId, startDate, endDate))
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string[]> GetData(int busId, DateTime startDate, DateTime endDate)
|
||||||
|
{
|
||||||
|
var data = _routsheetRepository
|
||||||
|
.ReadRoutSheet()
|
||||||
|
.Where(x => x.BusDate >= startDate && x.BusDate <= endDate && x.RoutSheetBus.Any(y => y.BusID == busId))
|
||||||
|
.Select(x => new {
|
||||||
|
Date = x.BusDate,
|
||||||
|
Rout = (int?)x.RoutId,
|
||||||
|
Cost = (decimal?)null
|
||||||
|
})
|
||||||
|
.Union(
|
||||||
|
_toRepository
|
||||||
|
.ReadTo()
|
||||||
|
.Where(x => x.DateTo >= startDate && x.DateTo <= endDate && x.BusID == busId)
|
||||||
|
.Select(x => new {
|
||||||
|
Date = x.DateTo,
|
||||||
|
Rout = (int?)null,
|
||||||
|
Cost = (decimal?)x.Cost
|
||||||
|
}))
|
||||||
|
.OrderBy(x => x.Date);
|
||||||
|
|
||||||
|
return new List<string[]> { item }
|
||||||
|
.Union(
|
||||||
|
data.Select(x => new string[]
|
||||||
|
{
|
||||||
|
x.Date.ToString("dd.MM.yyyy"),
|
||||||
|
x.Rout?.ToString() ?? string.Empty,
|
||||||
|
x.Cost?.ToString() ?? string.Empty
|
||||||
|
}))
|
||||||
|
.Union(new[] { new string[] { "Всего", "", data.Sum(x => x.Cost ?? 0).ToString() } })
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,107 @@
|
|||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
|
||||||
|
|
||||||
|
namespace PIbd_24_EredavkinRA_BusBusiness.Reports;
|
||||||
|
|
||||||
|
internal class WordBuilder
|
||||||
|
{
|
||||||
|
private readonly string _filePath;
|
||||||
|
|
||||||
|
private readonly Document _document;
|
||||||
|
|
||||||
|
private readonly Body _body;
|
||||||
|
|
||||||
|
public WordBuilder(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(filePath));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
_filePath = filePath;
|
||||||
|
_document = new Document();
|
||||||
|
_body = _document.AppendChild(new Body());
|
||||||
|
}
|
||||||
|
|
||||||
|
public WordBuilder AddHeader(string header)
|
||||||
|
{
|
||||||
|
var paragraph = _body.AppendChild(new Paragraph());
|
||||||
|
var run = paragraph.AppendChild(new Run());
|
||||||
|
run.AppendChild(new RunProperties(new Bold()));
|
||||||
|
run.AppendChild(new Text(header));
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WordBuilder AddParagraph(string text)
|
||||||
|
{
|
||||||
|
var paragraph = _body.AppendChild(new Paragraph());
|
||||||
|
var run = paragraph.AppendChild(new Run());
|
||||||
|
run.AppendChild(new Text(text));
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WordBuilder AddTable(int[] widths, List<string[]> data)
|
||||||
|
{
|
||||||
|
if (widths == null || widths.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(widths));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data == null || data.Count == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.Any(x => x.Length != widths.Length))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("widths.Length != data.Length");
|
||||||
|
}
|
||||||
|
|
||||||
|
var table = new Table();
|
||||||
|
table.AppendChild(new TableProperties(
|
||||||
|
new TableBorders(
|
||||||
|
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 }
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
//Заголовок
|
||||||
|
var tr = new TableRow();
|
||||||
|
for (var j = 0; j < widths.Length; ++j)
|
||||||
|
{
|
||||||
|
tr.Append(new TableCell(
|
||||||
|
new TableCellProperties(new TableCellWidth() { Width = widths[j].ToString() }),
|
||||||
|
new Paragraph(new Run(new RunProperties(new Bold()), new Text(data.First()[j])))));
|
||||||
|
}
|
||||||
|
table.Append(tr);
|
||||||
|
|
||||||
|
// Данные
|
||||||
|
table.Append(data.Skip(1).Select(x =>
|
||||||
|
new TableRow(x.Select(y => new TableCell(new Paragraph(new Run(new Text(y))))))));
|
||||||
|
|
||||||
|
_body.Append(table);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Build()
|
||||||
|
{
|
||||||
|
using var wordDocument = WordprocessingDocument.Create(_filePath, WordprocessingDocumentType.Document);
|
||||||
|
var mainPart = wordDocument.AddMainDocumentPart();
|
||||||
|
mainPart.Document = _document;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using Dapper;
|
using Dapper;
|
||||||
|
using DocumentFormat.OpenXml.Bibliography;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Npgsql;
|
using Npgsql;
|
||||||
@ -58,10 +59,11 @@ public class RoutSheetRepository : IRoutSheetRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = "SELECT * FROM RoutSheet";
|
var querySelect = @"SELECT cs.*, dcs.BusId FROM RoutSheet cs
|
||||||
var routsheet = connection.Query<RoutSheet>(querySelect);
|
INNER JOIN RoutSheetBus dcs ON dcs.RoutSheetId = cs.Id";
|
||||||
|
var routsheet = connection.Query<TempRoutSheetBus>(querySelect);
|
||||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(routsheet));
|
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(routsheet));
|
||||||
return routsheet;
|
return routsheet.GroupBy(x => x.Id, y => y, (key, value) => RoutSheet.CreatOpeartion(value.First(), value.Select(z => RoutSheetBus.CreateElement(0, z.BusId)))).ToList();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user