PIbd-22_Elli_T.A._LabWork3 #3
@ -8,11 +8,13 @@ public class AthleteAccommodation
|
||||
|
||||
public int AthleteId { get; private set; }
|
||||
|
||||
public decimal Price { get; private set; }
|
||||
|
||||
public DateTime DateStart { get; private set; }
|
||||
|
||||
public DateTime DateEnd { get; private set; }
|
||||
|
||||
public static AthleteAccommodation CreateOpeartion(int id, int roomId, int athleteId)
|
||||
public static AthleteAccommodation CreateOpeartion(int id, int roomId, int athleteId, decimal price)
|
||||
{
|
||||
var dateStart = DateTime.Now;
|
||||
return new AthleteAccommodation
|
||||
@ -20,6 +22,7 @@ public class AthleteAccommodation
|
||||
Id = id,
|
||||
RoomId = roomId,
|
||||
AthleteId = athleteId,
|
||||
Price = price,
|
||||
DateStart = dateStart,
|
||||
DateEnd = dateStart.AddMonths(1)
|
||||
};
|
||||
|
@ -24,4 +24,17 @@ public class ServiceProvision
|
||||
ServiceProvisionConnection = serviceProvisionConnection
|
||||
};
|
||||
}
|
||||
|
||||
public static ServiceProvision CreateOpeartion(TempServiceProvisionConnection tempServiceProvisionConnection,
|
||||
IEnumerable<ServiceProvisionConnection> serviceProvisionConnection)
|
||||
{
|
||||
return new ServiceProvision
|
||||
{
|
||||
Id = tempServiceProvisionConnection.Id,
|
||||
HotelId = tempServiceProvisionConnection.HotelId,
|
||||
Name = tempServiceProvisionConnection.Name,
|
||||
Date = tempServiceProvisionConnection.Date,
|
||||
ServiceProvisionConnection = serviceProvisionConnection
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
namespace ProjectAthletesAccommodation.Entities;
|
||||
|
||||
public class TempServiceProvisionConnection
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
public int HotelId { get; private set; }
|
||||
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
public DateTime Date { get; private set; }
|
||||
|
||||
public int AthleteId { get; private set; }
|
||||
|
||||
public decimal Price { get; private set; }
|
||||
}
|
@ -37,6 +37,9 @@
|
||||
AthletesAccommodationToolStripMenuItem = new ToolStripMenuItem();
|
||||
ServicesProvisionToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportsToolStripMenuItem = new ToolStripMenuItem();
|
||||
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
AthleteReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
AccommodationOfAthletesToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -59,21 +62,21 @@
|
||||
// AthletesToolStripMenuItem
|
||||
//
|
||||
AthletesToolStripMenuItem.Name = "AthletesToolStripMenuItem";
|
||||
AthletesToolStripMenuItem.Size = new Size(180, 22);
|
||||
AthletesToolStripMenuItem.Size = new Size(145, 22);
|
||||
AthletesToolStripMenuItem.Text = "Спортсмены";
|
||||
AthletesToolStripMenuItem.Click += AthletesToolStripMenuItem_Click;
|
||||
//
|
||||
// HotelsToolStripMenuItem
|
||||
//
|
||||
HotelsToolStripMenuItem.Name = "HotelsToolStripMenuItem";
|
||||
HotelsToolStripMenuItem.Size = new Size(180, 22);
|
||||
HotelsToolStripMenuItem.Size = new Size(145, 22);
|
||||
HotelsToolStripMenuItem.Text = "Гостиницы";
|
||||
HotelsToolStripMenuItem.Click += HotelsToolStripMenuItem_Click;
|
||||
//
|
||||
// RoomsToolStripMenuItem
|
||||
//
|
||||
RoomsToolStripMenuItem.Name = "RoomsToolStripMenuItem";
|
||||
RoomsToolStripMenuItem.Size = new Size(180, 22);
|
||||
RoomsToolStripMenuItem.Size = new Size(145, 22);
|
||||
RoomsToolStripMenuItem.Text = "Номера";
|
||||
RoomsToolStripMenuItem.Click += RoomsToolStripMenuItem_Click;
|
||||
//
|
||||
@ -100,10 +103,35 @@
|
||||
//
|
||||
// ReportsToolStripMenuItem
|
||||
//
|
||||
ReportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, AthleteReportToolStripMenuItem, AccommodationOfAthletesToolStripMenuItem });
|
||||
ReportsToolStripMenuItem.Name = "ReportsToolStripMenuItem";
|
||||
ReportsToolStripMenuItem.Size = new Size(60, 20);
|
||||
ReportsToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// DirectoryReportToolStripMenuItem
|
||||
//
|
||||
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
|
||||
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||
DirectoryReportToolStripMenuItem.Size = new Size(280, 22);
|
||||
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
|
||||
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
||||
//
|
||||
// AthleteReportToolStripMenuItem
|
||||
//
|
||||
AthleteReportToolStripMenuItem.Name = "AthleteReportToolStripMenuItem";
|
||||
AthleteReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||
AthleteReportToolStripMenuItem.Size = new Size(280, 22);
|
||||
AthleteReportToolStripMenuItem.Text = "Сведения о спортсменах";
|
||||
AthleteReportToolStripMenuItem.Click += AthleteReportToolStripMenuItem_Click;
|
||||
//
|
||||
// AccommodationOfAthletesToolStripMenuItem
|
||||
//
|
||||
AccommodationOfAthletesToolStripMenuItem.Name = "AccommodationOfAthletesToolStripMenuItem";
|
||||
AccommodationOfAthletesToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
||||
AccommodationOfAthletesToolStripMenuItem.Size = new Size(280, 22);
|
||||
AccommodationOfAthletesToolStripMenuItem.Text = "Заселение спортсменов";
|
||||
AccommodationOfAthletesToolStripMenuItem.Click += AccommodationOfAthletesToolStripMenuItem_Click;
|
||||
//
|
||||
// FormAthleteAccommodation
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
@ -134,5 +162,8 @@
|
||||
private ToolStripMenuItem AthletesAccommodationToolStripMenuItem;
|
||||
private ToolStripMenuItem ServicesProvisionToolStripMenuItem;
|
||||
private ToolStripMenuItem ReportsToolStripMenuItem;
|
||||
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||
private ToolStripMenuItem AthleteReportToolStripMenuItem;
|
||||
private ToolStripMenuItem AccommodationOfAthletesToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
@ -77,5 +77,44 @@ namespace ProjectAthletesAccommodation
|
||||
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 AthleteReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormAthleteReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AccommodationOfAthletesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormAthleteAccommodationReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -38,12 +38,15 @@
|
||||
dateTimePickerDateEnd = new DateTimePicker();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
labelPrice = new Label();
|
||||
numericUpDownPrice = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelRoom
|
||||
//
|
||||
labelRoom.AutoSize = true;
|
||||
labelRoom.Location = new Point(60, 27);
|
||||
labelRoom.Location = new Point(106, 27);
|
||||
labelRoom.Name = "labelRoom";
|
||||
labelRoom.Size = new Size(45, 15);
|
||||
labelRoom.TabIndex = 0;
|
||||
@ -52,7 +55,7 @@
|
||||
// labelAthlete
|
||||
//
|
||||
labelAthlete.AutoSize = true;
|
||||
labelAthlete.Location = new Point(36, 60);
|
||||
labelAthlete.Location = new Point(82, 60);
|
||||
labelAthlete.Name = "labelAthlete";
|
||||
labelAthlete.Size = new Size(69, 15);
|
||||
labelAthlete.TabIndex = 1;
|
||||
@ -61,7 +64,7 @@
|
||||
// labelDateStart
|
||||
//
|
||||
labelDateStart.AutoSize = true;
|
||||
labelDateStart.Location = new Point(36, 102);
|
||||
labelDateStart.Location = new Point(82, 128);
|
||||
labelDateStart.Name = "labelDateStart";
|
||||
labelDateStart.Size = new Size(69, 15);
|
||||
labelDateStart.TabIndex = 2;
|
||||
@ -70,7 +73,7 @@
|
||||
// labelDateEnd
|
||||
//
|
||||
labelDateEnd.AutoSize = true;
|
||||
labelDateEnd.Location = new Point(32, 135);
|
||||
labelDateEnd.Location = new Point(78, 163);
|
||||
labelDateEnd.Name = "labelDateEnd";
|
||||
labelDateEnd.Size = new Size(73, 15);
|
||||
labelDateEnd.TabIndex = 3;
|
||||
@ -80,7 +83,7 @@
|
||||
//
|
||||
comboBoxRoom.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxRoom.FormattingEnabled = true;
|
||||
comboBoxRoom.Location = new Point(111, 24);
|
||||
comboBoxRoom.Location = new Point(157, 24);
|
||||
comboBoxRoom.Name = "comboBoxRoom";
|
||||
comboBoxRoom.Size = new Size(200, 23);
|
||||
comboBoxRoom.TabIndex = 4;
|
||||
@ -89,7 +92,7 @@
|
||||
//
|
||||
comboBoxAthlete.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxAthlete.FormattingEnabled = true;
|
||||
comboBoxAthlete.Location = new Point(111, 57);
|
||||
comboBoxAthlete.Location = new Point(157, 57);
|
||||
comboBoxAthlete.Name = "comboBoxAthlete";
|
||||
comboBoxAthlete.Size = new Size(200, 23);
|
||||
comboBoxAthlete.TabIndex = 5;
|
||||
@ -97,7 +100,7 @@
|
||||
// dateTimePickerDateStart
|
||||
//
|
||||
dateTimePickerDateStart.Enabled = false;
|
||||
dateTimePickerDateStart.Location = new Point(111, 96);
|
||||
dateTimePickerDateStart.Location = new Point(157, 122);
|
||||
dateTimePickerDateStart.Name = "dateTimePickerDateStart";
|
||||
dateTimePickerDateStart.Size = new Size(200, 23);
|
||||
dateTimePickerDateStart.TabIndex = 6;
|
||||
@ -105,16 +108,16 @@
|
||||
// dateTimePickerDateEnd
|
||||
//
|
||||
dateTimePickerDateEnd.Enabled = false;
|
||||
dateTimePickerDateEnd.Location = new Point(111, 129);
|
||||
dateTimePickerDateEnd.Location = new Point(157, 157);
|
||||
dateTimePickerDateEnd.Name = "dateTimePickerDateEnd";
|
||||
dateTimePickerDateEnd.Size = new Size(200, 23);
|
||||
dateTimePickerDateEnd.TabIndex = 7;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(32, 168);
|
||||
buttonSave.Location = new Point(18, 202);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(133, 45);
|
||||
buttonSave.Size = new Size(159, 45);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
@ -122,19 +125,41 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(178, 168);
|
||||
buttonCancel.Location = new Point(197, 202);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(133, 45);
|
||||
buttonCancel.Size = new Size(160, 45);
|
||||
buttonCancel.TabIndex = 9;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// labelPrice
|
||||
//
|
||||
labelPrice.AutoSize = true;
|
||||
labelPrice.Location = new Point(12, 92);
|
||||
labelPrice.Name = "labelPrice";
|
||||
labelPrice.Size = new Size(139, 15);
|
||||
labelPrice.TabIndex = 10;
|
||||
labelPrice.Text = "Стоимость проживания";
|
||||
//
|
||||
// numericUpDownPrice
|
||||
//
|
||||
numericUpDownPrice.DecimalPlaces = 2;
|
||||
numericUpDownPrice.Location = new Point(157, 90);
|
||||
numericUpDownPrice.Maximum = new decimal(new int[] { 999999999, 0, 0, 0 });
|
||||
numericUpDownPrice.Minimum = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||
numericUpDownPrice.Size = new Size(200, 23);
|
||||
numericUpDownPrice.TabIndex = 11;
|
||||
numericUpDownPrice.Value = new decimal(new int[] { 1, 0, 0, 131072 });
|
||||
//
|
||||
// FormAthleteAccommodation
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(342, 225);
|
||||
ClientSize = new Size(380, 267);
|
||||
Controls.Add(numericUpDownPrice);
|
||||
Controls.Add(labelPrice);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(dateTimePickerDateEnd);
|
||||
@ -148,6 +173,7 @@
|
||||
Name = "FormAthleteAccommodation";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Размещение спортсмена";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -164,5 +190,7 @@
|
||||
private DateTimePicker dateTimePickerDateEnd;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label labelPrice;
|
||||
private NumericUpDown numericUpDownPrice;
|
||||
}
|
||||
}
|
@ -34,7 +34,7 @@ namespace ProjectAthletesAccommodation.Forms
|
||||
|
||||
_athleteAccommodationRepository.CreateAthleteAccommodation
|
||||
(AthleteAccommodation.CreateOpeartion(0, (int)comboBoxRoom.SelectedValue!,
|
||||
(int)comboBoxAthlete.SelectedValue!));
|
||||
(int)comboBoxAthlete.SelectedValue!, Convert.ToDecimal(numericUpDownPrice.Value)));
|
||||
|
||||
Close();
|
||||
}
|
||||
|
@ -0,0 +1,108 @@
|
||||
namespace ProjectAthletesAccommodation.Forms
|
||||
{
|
||||
partial class FormAthleteAccommodationReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonSelectFileName = new Button();
|
||||
labelFileName = new Label();
|
||||
labelDate = new Label();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
buttonBuild = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSelectFileName
|
||||
//
|
||||
buttonSelectFileName.Location = new Point(28, 23);
|
||||
buttonSelectFileName.Name = "buttonSelectFileName";
|
||||
buttonSelectFileName.Size = new Size(75, 23);
|
||||
buttonSelectFileName.TabIndex = 0;
|
||||
buttonSelectFileName.Text = "Выбрать";
|
||||
buttonSelectFileName.UseVisualStyleBackColor = true;
|
||||
buttonSelectFileName.Click += ButtonSelectFileName_Click;
|
||||
//
|
||||
// labelFileName
|
||||
//
|
||||
labelFileName.AutoSize = true;
|
||||
labelFileName.Location = new Point(109, 27);
|
||||
labelFileName.Name = "labelFileName";
|
||||
labelFileName.Size = new Size(36, 15);
|
||||
labelFileName.TabIndex = 1;
|
||||
labelFileName.Text = "Файл";
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
labelDate.AutoSize = true;
|
||||
labelDate.Location = new Point(28, 60);
|
||||
labelDate.Name = "labelDate";
|
||||
labelDate.Size = new Size(32, 15);
|
||||
labelDate.TabIndex = 2;
|
||||
labelDate.Text = "Дата";
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(66, 54);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(209, 23);
|
||||
dateTimePicker.TabIndex = 3;
|
||||
//
|
||||
// buttonBuild
|
||||
//
|
||||
buttonBuild.Location = new Point(28, 92);
|
||||
buttonBuild.Name = "buttonBuild";
|
||||
buttonBuild.Size = new Size(247, 48);
|
||||
buttonBuild.TabIndex = 4;
|
||||
buttonBuild.Text = "Сформировать";
|
||||
buttonBuild.UseVisualStyleBackColor = true;
|
||||
buttonBuild.Click += ButtonBuild_Click;
|
||||
//
|
||||
// FormAthleteAccommodationReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(304, 156);
|
||||
Controls.Add(buttonBuild);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(labelDate);
|
||||
Controls.Add(labelFileName);
|
||||
Controls.Add(buttonSelectFileName);
|
||||
Name = "FormAthleteAccommodationReport";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Заселение спортсменов";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSelectFileName;
|
||||
private Label labelFileName;
|
||||
private Label labelDate;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Button buttonBuild;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
using ProjectAthletesAccommodation.Reports;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectAthletesAccommodation.Forms
|
||||
{
|
||||
public partial class FormAthleteAccommodationReport : Form
|
||||
{
|
||||
private string _fileName = string.Empty;
|
||||
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
public FormAthleteAccommodationReport(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
private void ButtonBuild_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);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSelectFileName_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
165
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthleteReport.Designer.cs
generated
Normal file
165
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormAthleteReport.Designer.cs
generated
Normal file
@ -0,0 +1,165 @@
|
||||
namespace ProjectAthletesAccommodation.Forms
|
||||
{
|
||||
partial class FormAthleteReport
|
||||
{
|
||||
/// <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();
|
||||
labelFilePath = new Label();
|
||||
labelAthlete = new Label();
|
||||
labelDateStart = new Label();
|
||||
labelDateEnd = new Label();
|
||||
buttonSelectFilePath = new Button();
|
||||
textBoxFilePath = new TextBox();
|
||||
comboBoxAthlete = new ComboBox();
|
||||
buttonBuild = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dateTimePickerDateBegin
|
||||
//
|
||||
dateTimePickerDateBegin.Location = new Point(114, 102);
|
||||
dateTimePickerDateBegin.Name = "dateTimePickerDateBegin";
|
||||
dateTimePickerDateBegin.Size = new Size(228, 23);
|
||||
dateTimePickerDateBegin.TabIndex = 0;
|
||||
//
|
||||
// dateTimePickerDateEnd
|
||||
//
|
||||
dateTimePickerDateEnd.Location = new Point(114, 141);
|
||||
dateTimePickerDateEnd.Name = "dateTimePickerDateEnd";
|
||||
dateTimePickerDateEnd.Size = new Size(228, 23);
|
||||
dateTimePickerDateEnd.TabIndex = 1;
|
||||
//
|
||||
// labelFilePath
|
||||
//
|
||||
labelFilePath.AutoSize = true;
|
||||
labelFilePath.Location = new Point(21, 32);
|
||||
labelFilePath.Name = "labelFilePath";
|
||||
labelFilePath.Size = new Size(87, 15);
|
||||
labelFilePath.TabIndex = 2;
|
||||
labelFilePath.Text = "Путь до файла";
|
||||
//
|
||||
// labelAthlete
|
||||
//
|
||||
labelAthlete.AutoSize = true;
|
||||
labelAthlete.Location = new Point(39, 70);
|
||||
labelAthlete.Name = "labelAthlete";
|
||||
labelAthlete.Size = new Size(69, 15);
|
||||
labelAthlete.TabIndex = 3;
|
||||
labelAthlete.Text = "Спортсмен";
|
||||
//
|
||||
// labelDateStart
|
||||
//
|
||||
labelDateStart.AutoSize = true;
|
||||
labelDateStart.Location = new Point(34, 108);
|
||||
labelDateStart.Name = "labelDateStart";
|
||||
labelDateStart.Size = new Size(74, 15);
|
||||
labelDateStart.TabIndex = 4;
|
||||
labelDateStart.Text = "Дата начала";
|
||||
//
|
||||
// labelDateEnd
|
||||
//
|
||||
labelDateEnd.AutoSize = true;
|
||||
labelDateEnd.Location = new Point(40, 147);
|
||||
labelDateEnd.Name = "labelDateEnd";
|
||||
labelDateEnd.Size = new Size(68, 15);
|
||||
labelDateEnd.TabIndex = 5;
|
||||
labelDateEnd.Text = "Дата конца";
|
||||
//
|
||||
// buttonSelectFilePath
|
||||
//
|
||||
buttonSelectFilePath.Location = new Point(320, 29);
|
||||
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
||||
buttonSelectFilePath.Size = new Size(22, 22);
|
||||
buttonSelectFilePath.TabIndex = 6;
|
||||
buttonSelectFilePath.Text = "..";
|
||||
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
||||
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
||||
//
|
||||
// textBoxFilePath
|
||||
//
|
||||
textBoxFilePath.Location = new Point(114, 29);
|
||||
textBoxFilePath.Name = "textBoxFilePath";
|
||||
textBoxFilePath.ReadOnly = true;
|
||||
textBoxFilePath.Size = new Size(200, 23);
|
||||
textBoxFilePath.TabIndex = 7;
|
||||
//
|
||||
// comboBoxAthlete
|
||||
//
|
||||
comboBoxAthlete.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxAthlete.FormattingEnabled = true;
|
||||
comboBoxAthlete.Location = new Point(114, 67);
|
||||
comboBoxAthlete.Name = "comboBoxAthlete";
|
||||
comboBoxAthlete.Size = new Size(228, 23);
|
||||
comboBoxAthlete.TabIndex = 8;
|
||||
//
|
||||
// buttonBuild
|
||||
//
|
||||
buttonBuild.Location = new Point(95, 184);
|
||||
buttonBuild.Name = "buttonBuild";
|
||||
buttonBuild.Size = new Size(177, 45);
|
||||
buttonBuild.TabIndex = 9;
|
||||
buttonBuild.Text = "Сформировать";
|
||||
buttonBuild.UseVisualStyleBackColor = true;
|
||||
buttonBuild.Click += ButtonBuild_Click;
|
||||
//
|
||||
// FormAthleteReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(371, 247);
|
||||
Controls.Add(buttonBuild);
|
||||
Controls.Add(comboBoxAthlete);
|
||||
Controls.Add(textBoxFilePath);
|
||||
Controls.Add(buttonSelectFilePath);
|
||||
Controls.Add(labelDateEnd);
|
||||
Controls.Add(labelDateStart);
|
||||
Controls.Add(labelAthlete);
|
||||
Controls.Add(labelFilePath);
|
||||
Controls.Add(dateTimePickerDateEnd);
|
||||
Controls.Add(dateTimePickerDateBegin);
|
||||
Name = "FormAthleteReport";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Отчёт по спортсмену";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DateTimePicker dateTimePickerDateBegin;
|
||||
private DateTimePicker dateTimePickerDateEnd;
|
||||
private Label labelFilePath;
|
||||
private Label labelAthlete;
|
||||
private Label labelDateStart;
|
||||
private Label labelDateEnd;
|
||||
private Button buttonSelectFilePath;
|
||||
private TextBox textBoxFilePath;
|
||||
private ComboBox comboBoxAthlete;
|
||||
private Button buttonBuild;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
using ProjectAthletesAccommodation.Reports;
|
||||
using ProjectAthletesAccommodation.Repositories;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectAthletesAccommodation.Forms;
|
||||
|
||||
public partial class FormAthleteReport : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
public FormAthleteReport(IUnityContainer container, IAthleteRepository athleteRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
|
||||
comboBoxAthlete.DataSource = athleteRepository.ReadAthletes();
|
||||
comboBoxAthlete.DisplayMember = "Name";
|
||||
comboBoxAthlete.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 ButtonBuild_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
||||
{
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
}
|
||||
|
||||
if (comboBoxAthlete.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Не выбран спортсмен");
|
||||
}
|
||||
|
||||
if (dateTimePickerDateEnd.Value <= dateTimePickerDateBegin.Value)
|
||||
{
|
||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||
}
|
||||
|
||||
if(_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxAthlete.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>
|
100
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
100
ProjectAthletesAccommodation/ProjectAthletesAccommodation/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
@ -0,0 +1,100 @@
|
||||
namespace ProjectAthletesAccommodation.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()
|
||||
{
|
||||
checkBoxAthletes = new CheckBox();
|
||||
checkBoxRooms = new CheckBox();
|
||||
checkBoxHotels = new CheckBox();
|
||||
buttonBuild = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkBoxAthletes
|
||||
//
|
||||
checkBoxAthletes.AutoSize = true;
|
||||
checkBoxAthletes.Location = new Point(33, 29);
|
||||
checkBoxAthletes.Name = "checkBoxAthletes";
|
||||
checkBoxAthletes.Size = new Size(97, 19);
|
||||
checkBoxAthletes.TabIndex = 0;
|
||||
checkBoxAthletes.Text = "Спортсмены";
|
||||
checkBoxAthletes.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxRooms
|
||||
//
|
||||
checkBoxRooms.AutoSize = true;
|
||||
checkBoxRooms.Location = new Point(33, 97);
|
||||
checkBoxRooms.Name = "checkBoxRooms";
|
||||
checkBoxRooms.Size = new Size(124, 19);
|
||||
checkBoxRooms.TabIndex = 1;
|
||||
checkBoxRooms.Text = "Номера гостиниц";
|
||||
checkBoxRooms.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxHotels
|
||||
//
|
||||
checkBoxHotels.AutoSize = true;
|
||||
checkBoxHotels.Location = new Point(33, 63);
|
||||
checkBoxHotels.Name = "checkBoxHotels";
|
||||
checkBoxHotels.Size = new Size(87, 19);
|
||||
checkBoxHotels.TabIndex = 2;
|
||||
checkBoxHotels.Text = "Гостиницы";
|
||||
checkBoxHotels.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonBuild
|
||||
//
|
||||
buttonBuild.Location = new Point(182, 33);
|
||||
buttonBuild.Name = "buttonBuild";
|
||||
buttonBuild.Size = new Size(112, 76);
|
||||
buttonBuild.TabIndex = 3;
|
||||
buttonBuild.Text = "Сформировать";
|
||||
buttonBuild.UseVisualStyleBackColor = true;
|
||||
buttonBuild.Click += ButtonBuild_Click;
|
||||
//
|
||||
// FormDirectoryReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(324, 140);
|
||||
Controls.Add(buttonBuild);
|
||||
Controls.Add(checkBoxHotels);
|
||||
Controls.Add(checkBoxRooms);
|
||||
Controls.Add(checkBoxAthletes);
|
||||
Name = "FormDirectoryReport";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Выгрузка справочников";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckBox checkBoxAthletes;
|
||||
private CheckBox checkBoxRooms;
|
||||
private CheckBox checkBoxHotels;
|
||||
private Button buttonBuild;
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
using ProjectAthletesAccommodation.Reports;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectAthletesAccommodation.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 (!checkBoxAthletes.Checked && !checkBoxHotels.Checked && !checkBoxRooms.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, checkBoxAthletes.Checked,
|
||||
checkBoxHotels.Checked, checkBoxRooms.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>
|
@ -65,7 +65,8 @@ namespace ProjectAthletesAccommodation.Forms
|
||||
Convert.ToDecimal(row.Cells["ColumnPrice"].Value)));
|
||||
}
|
||||
|
||||
return list;
|
||||
return list.GroupBy(x => x.AthleteId, x => x.Price, (id, prices) =>
|
||||
ServiceProvisionConnection.CreateElement(0, id, prices.Sum())).ToList();
|
||||
}
|
||||
}
|
||||
}
|
@ -14,11 +14,13 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.1" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
<PackageReference Include="Serilog" Version="4.0.2" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
|
@ -0,0 +1,50 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectAthletesAccommodation.Repositories;
|
||||
|
||||
namespace ProjectAthletesAccommodation.Reports;
|
||||
|
||||
public class ChartReport
|
||||
{
|
||||
private readonly IAthleteAccommodationRepository _athleteAccommodationRepository;
|
||||
|
||||
private readonly ILogger<ChartReport> _logger;
|
||||
public ChartReport(IAthleteAccommodationRepository athleteAccommodationRepository,
|
||||
ILogger<ChartReport> logger)
|
||||
{
|
||||
_athleteAccommodationRepository = athleteAccommodationRepository ??
|
||||
throw new ArgumentNullException(nameof(athleteAccommodationRepository));
|
||||
_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 _athleteAccommodationRepository
|
||||
.ReadAthleteAccommodation()
|
||||
.Where(x => x.DateStart.Date == dateTime.Date)
|
||||
.GroupBy(x => x.AthleteId, (key, group) => new
|
||||
{
|
||||
Id = key,
|
||||
Count = group.Sum(x => x.Price)
|
||||
})
|
||||
.Select(x => (x.Id.ToString(), (double)x.Count))
|
||||
.ToList();
|
||||
}
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectAthletesAccommodation.Repositories;
|
||||
|
||||
namespace ProjectAthletesAccommodation.Reports;
|
||||
|
||||
public class DocReport
|
||||
{
|
||||
private readonly IAthleteRepository _athleteRepository;
|
||||
|
||||
private readonly IRoomRepository _roomRepository;
|
||||
|
||||
private readonly IHotelRepository _hotelRepository;
|
||||
|
||||
private readonly ILogger<DocReport> _logger;
|
||||
|
||||
public DocReport(IAthleteRepository athleteRepository, IRoomRepository roomRepository,
|
||||
IHotelRepository hotelRepository, ILogger<DocReport> logger)
|
||||
{
|
||||
_athleteRepository = athleteRepository ??
|
||||
throw new ArgumentNullException(nameof(athleteRepository));
|
||||
_roomRepository = roomRepository ??
|
||||
throw new ArgumentNullException(nameof(roomRepository));
|
||||
_hotelRepository = hotelRepository ??
|
||||
throw new ArgumentNullException(nameof(hotelRepository));
|
||||
_logger = logger ??
|
||||
throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateDoc(string filePath, bool includeAthletes, bool includeRooms, bool includeHotels)
|
||||
{
|
||||
try
|
||||
{
|
||||
var builder = new WordBuilder(filePath).AddHeader("Документ со справочниками");
|
||||
|
||||
if(includeAthletes)
|
||||
{
|
||||
builder.AddParagraph("Спортсмены").AddTable([2400, 2400, 2000, 2000], GetAthletes());
|
||||
}
|
||||
|
||||
if(includeRooms)
|
||||
{
|
||||
builder.AddParagraph("Номера").AddTable([2400, 2400, 2400], GetRooms());
|
||||
}
|
||||
|
||||
if(includeHotels)
|
||||
{
|
||||
builder.AddParagraph("Гостиницы").AddTable([2400], GetHotels());
|
||||
}
|
||||
|
||||
builder.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetAthletes()
|
||||
{
|
||||
return [
|
||||
["Имя", "Фамилия", "Вид спорта", "Классификация"],
|
||||
.. _athleteRepository
|
||||
.ReadAthletes()
|
||||
.Select(x => new string[]
|
||||
{x.Name, x.Surname, x.KindOfSport.ToString(), x.AthleteClassification.ToString()}),
|
||||
];
|
||||
}
|
||||
|
||||
private List<string[]> GetHotels()
|
||||
{
|
||||
return [
|
||||
["Название"],
|
||||
.. _hotelRepository
|
||||
.ReadHotels()
|
||||
.Select(x => new string[]
|
||||
{x.Name}),
|
||||
];
|
||||
}
|
||||
|
||||
private List<string[]> GetRooms()
|
||||
{
|
||||
return [
|
||||
["Гостиница (Id)", "Номер", "Тип номера"],
|
||||
.. _roomRepository
|
||||
.ReadRooms()
|
||||
.Select(x => new string[]
|
||||
{x.HotelId.ToString(), x.Name, x.TypeOfRoom.ToString()}),
|
||||
];
|
||||
}
|
||||
}
|
@ -0,0 +1,325 @@
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
|
||||
namespace ProjectAthletesAccommodation.Reports;
|
||||
|
||||
public 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.BoldTextWithoutBorder);
|
||||
}
|
||||
|
||||
_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("widths.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 },
|
||||
Bold = new Bold(),
|
||||
FontScheme = new FontScheme()
|
||||
{
|
||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fonts);
|
||||
|
||||
var fills = new Fills() { Count = 1 };
|
||||
fills.Append(new Fill
|
||||
{
|
||||
PatternFill = new PatternFill()
|
||||
{
|
||||
PatternType = new EnumValue<PatternValues>(PatternValues.None)
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fills);
|
||||
|
||||
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);
|
||||
|
||||
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 = 1,
|
||||
BorderId = 1,
|
||||
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.Left,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Left,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||
}
|
||||
|
||||
private enum StyleIndex
|
||||
{
|
||||
SimpleTextWithoutBorder = 0,
|
||||
BoldTextWithBorder = 1,
|
||||
SimpleTextWithBorder = 2,
|
||||
BoldTextWithoutBorder = 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,91 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||
using MigraDoc.Rendering;
|
||||
using System.Text;
|
||||
|
||||
namespace ProjectAthletesAccommodation.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()
|
||||
{
|
||||
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 = 16;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectAthletesAccommodation.Repositories;
|
||||
|
||||
namespace ProjectAthletesAccommodation.Reports;
|
||||
|
||||
public class TableReport
|
||||
{
|
||||
private readonly IAthleteAccommodationRepository _athleteAccommodationRepository;
|
||||
|
||||
private readonly IServiceProvisionRepository _serviceProvisionRepository;
|
||||
|
||||
private readonly ILogger<TableReport> _logger;
|
||||
|
||||
internal static readonly string[] item = ["Дата", "Траты на услуги", "Оплата проживания в номере"];
|
||||
|
||||
public TableReport(IAthleteAccommodationRepository athleteAccommodationRepository,
|
||||
IServiceProvisionRepository serviceProvisionRepository, ILogger<TableReport> logger)
|
||||
{
|
||||
_athleteAccommodationRepository = athleteAccommodationRepository ??
|
||||
throw new ArgumentNullException(nameof(athleteAccommodationRepository));
|
||||
_serviceProvisionRepository = serviceProvisionRepository ??
|
||||
throw new ArgumentNullException(nameof(serviceProvisionRepository));
|
||||
_logger = logger ??
|
||||
throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateTable(string filePath, int athleteId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
new ExcelBuilder(filePath)
|
||||
.AddHeader("Сводка по спортсмену", 0, 3)
|
||||
.AddParagraph("За период", 0)
|
||||
.AddTable([15, 15, 15], GetData(athleteId, startDate, endDate))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetData(int athleteId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var data = _serviceProvisionRepository
|
||||
.ReadServiceProvision()
|
||||
.Where(x => x.Date >= startDate && x.Date <= endDate && x.ServiceProvisionConnection.Any(y => y.AthleteId == athleteId))
|
||||
.Select(x => new { Date = x.Date, PriceService = x.ServiceProvisionConnection.FirstOrDefault(y => y.AthleteId == athleteId)?.Price, PriceRoom = (decimal?)null })
|
||||
.Union(
|
||||
_athleteAccommodationRepository
|
||||
.ReadAthleteAccommodation()
|
||||
.Where(x => x.DateStart >= startDate && x.DateStart <= endDate && x.AthleteId == athleteId)
|
||||
.Select(x => new {Date = x.DateStart, PriceService = (decimal?)null, PriceRoom = (decimal?)x.Price }))
|
||||
.OrderBy(x => x.Date);
|
||||
|
||||
return
|
||||
new List<string[]>() { item }
|
||||
.Union(
|
||||
data
|
||||
.Select(x => new string[] {x.Date.ToString(), x.PriceService?.ToString() ?? string.Empty, x.PriceRoom?.ToString() ?? string.Empty }))
|
||||
.Union(
|
||||
[["Всего", data.Sum(x => x.PriceService ?? 0).ToString(), data.Sum(x => x.PriceRoom ?? 0).ToString()]])
|
||||
.ToList();
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using DocumentFormat.OpenXml;
|
||||
|
||||
namespace ProjectAthletesAccommodation.Reports;
|
||||
|
||||
public 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());
|
||||
|
||||
var runProperties = run.AppendChild(new RunProperties());
|
||||
runProperties.AppendChild(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;
|
||||
}
|
||||
}
|
@ -26,8 +26,8 @@ public class AthleteAccommodationRepository : IAthleteAccommodationRepository
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert =
|
||||
@"INSERT INTO AthleteAccommodation (RoomId, AthleteId, DateStart, DateEnd)
|
||||
VALUES (@RoomId, @AthleteId, @DateStart, @DateEnd)";
|
||||
@"INSERT INTO AthleteAccommodation (RoomId, AthleteId, Price, DateStart, DateEnd)
|
||||
VALUES (@RoomId, @AthleteId, @Price, @DateStart, @DateEnd)";
|
||||
connection.Execute(queryInsert, athleteAccommodation);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -72,10 +72,14 @@ public class ServiceProvisionRepository : IServiceProvisionRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM ServiceProvision";
|
||||
var serviceProvision = connection.Query<ServiceProvision>(querySelect);
|
||||
var querySelect =
|
||||
@"SELECT sp.*, spc.AthleteId, spc.Price FROM ServiceProvision sp
|
||||
INNER JOIN ServiceProvisionConnection spc ON spc.ServiceProvisionId = sp.Id";
|
||||
var serviceProvision = connection.Query<TempServiceProvisionConnection>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(serviceProvision));
|
||||
return serviceProvision;
|
||||
return serviceProvision.GroupBy(x => x.Id, y => y,
|
||||
(key, value) => ServiceProvision.CreateOpeartion(value.First(),
|
||||
value.Select(z => ServiceProvisionConnection.CreateElement(0, z.AthleteId, z.Price)))).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user