Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b7add5c30a | |||
| 52f4079c6f | |||
| dc57411081 | |||
| e2f3046137 | |||
| 1aab16e288 |
@@ -1,4 +1,6 @@
|
||||
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System.ComponentModel;
|
||||
using Travel_Agency.Entities.Enums;
|
||||
|
||||
namespace Travel_Agency.Entities;
|
||||
@@ -6,10 +8,18 @@ namespace Travel_Agency.Entities;
|
||||
public class Client
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DisplayName("Ф.И.О. клиента")]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Паспортные данные")]
|
||||
public string PassportDetails { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Позиция в обществе")]
|
||||
public PositionInSociety PositionInSociety { get; private set; }
|
||||
|
||||
public string Name_PositionInSociety => $"{Name} {PositionInSociety}";
|
||||
|
||||
public static Client CreateEntity(int id , string name, string passportDetails, PositionInSociety positionInSociety)
|
||||
{
|
||||
return new Client
|
||||
|
||||
@@ -1,14 +1,37 @@
|
||||
|
||||
using System.ComponentModel;
|
||||
using Unity;
|
||||
|
||||
namespace Travel_Agency.Entities;
|
||||
public class Contract
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DisplayName("Номер договора")]
|
||||
public int ContractNumber { get; private set; }
|
||||
|
||||
[DisplayName("Скидка в %")]
|
||||
public int Discount { get; private set; } = 0;
|
||||
|
||||
[DisplayName("Число туристов")]
|
||||
public int TouristNumber { get; private set; }
|
||||
|
||||
[DisplayName("Финальная цена")]
|
||||
public int FinalPrice { get; private set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public int ClientId { get; private set; }
|
||||
|
||||
[DisplayName("Ф.И.О. клиента")]
|
||||
public string ClientName { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата заключения договора")]
|
||||
public DateTime Date { get; private set; }
|
||||
|
||||
[DisplayName("Туры")]
|
||||
public string Tour => Tours != null ? string.Join(", ", Tours.Select(x => $"{x.TourName} {x.CountOfStop}")) : string.Empty;
|
||||
|
||||
[Browsable(false)]
|
||||
public IEnumerable<Contract_Tour> Tours { get; private set; } = [];
|
||||
|
||||
public static Contract CreateOperation(int id, int contractNumber, int discount, int touristNumber, int finalprice, int clientId, IEnumerable<Contract_Tour> tours)
|
||||
@@ -25,4 +48,12 @@ public class Contract
|
||||
Tours = tours
|
||||
};
|
||||
}
|
||||
|
||||
public void SetContract_Tours(IEnumerable<Contract_Tour> tours)
|
||||
{
|
||||
if (tours != null && tours.Any())
|
||||
{
|
||||
Tours = tours;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,17 @@
|
||||
namespace Travel_Agency.Entities;
|
||||
public class Contract_Tour
|
||||
{
|
||||
public int ContractId { get; private set; }
|
||||
public int Id { get; private set; }
|
||||
public int TourId { get; private set; }
|
||||
public string StartDate { get; private set; } = string.Empty;
|
||||
public string EndDate { get; private set; } = string.Empty;
|
||||
public static Contract_Tour CreateElement(int Contractid, int tourId, string startDate, string endDate)
|
||||
public int CountOfStop { get; private set; }
|
||||
public string TourName { get; private set; } = string.Empty;
|
||||
public static Contract_Tour CreateElement(int Contractid, int tourId, int countOfStop)
|
||||
{
|
||||
return new Contract_Tour
|
||||
{
|
||||
ContractId = Contractid,
|
||||
Id = Contractid,
|
||||
TourId = tourId,
|
||||
StartDate = startDate,
|
||||
EndDate = endDate
|
||||
CountOfStop = countOfStop
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Travel_Agency.Entities;
|
||||
public class Payment
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DisplayName("Сумма оплаты")]
|
||||
public int Sum { get; private set; } = 0;
|
||||
|
||||
[Browsable(false)]
|
||||
public int ClientId { get; private set; }
|
||||
|
||||
[DisplayName("Ф.И.О. клиента")]
|
||||
public string ClientName { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата оплаты")]
|
||||
public DateTime Date { get; private set; }
|
||||
|
||||
public static Payment CreateOperation(int id, int sum, int clientId)
|
||||
{
|
||||
return new Payment {
|
||||
|
||||
@@ -1,13 +1,29 @@
|
||||
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Travel_Agency.Entities;
|
||||
public class Route
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DisplayName("Название маршрута")]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Рейтинг маршрута")]
|
||||
public int Rating { get; private set; } = 0;
|
||||
|
||||
[DisplayName("Места посещения")]
|
||||
public string Places { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Стоимость маршрута")]
|
||||
public int Price { get; private set; } = 0;
|
||||
|
||||
[Browsable(false)]
|
||||
public int TourId { get; private set; }
|
||||
|
||||
[DisplayName("Тур")]
|
||||
public string TourName { get; private set; } = string.Empty;
|
||||
|
||||
public static Route CreateEntity(int id, string name, int rating, string places, int price, int tourId)
|
||||
{
|
||||
return new Route
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
using System.ComponentModel;
|
||||
using Travel_Agency.Entities.Enums;
|
||||
|
||||
namespace Travel_Agency.Entities;
|
||||
@@ -6,9 +7,18 @@ namespace Travel_Agency.Entities;
|
||||
public class Tour
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[DisplayName("Название тура")]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
|
||||
[DisplayName("Тип тура")]
|
||||
public TypeOfTour TypeOfTour { get; private set; }
|
||||
|
||||
[DisplayName("Стоимость тура")]
|
||||
public int Price { get; private set; } = 0;
|
||||
|
||||
public string Name_TypeOfTour => $"{Name} {TypeOfTour}";
|
||||
|
||||
public static Tour CreateEntity(int id, string name, TypeOfTour typeOfTour, int price)
|
||||
{
|
||||
return new Tour
|
||||
|
||||
@@ -37,6 +37,9 @@
|
||||
ContractToolStripMenuItem = new ToolStripMenuItem();
|
||||
PaymentToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
TourAndPaymentReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
VolumeOfPaymentsToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@@ -101,10 +104,35 @@
|
||||
//
|
||||
// отчётыToolStripMenuItem
|
||||
//
|
||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, TourAndPaymentReportToolStripMenuItem, VolumeOfPaymentsToolStripMenuItem });
|
||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||
отчётыToolStripMenuItem.Size = new Size(73, 24);
|
||||
отчётыToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// DirectoryReportToolStripMenuItem
|
||||
//
|
||||
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
|
||||
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||
DirectoryReportToolStripMenuItem.Size = new Size(467, 26);
|
||||
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
|
||||
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
||||
//
|
||||
// TourAndPaymentReportToolStripMenuItem
|
||||
//
|
||||
TourAndPaymentReportToolStripMenuItem.Name = "TourAndPaymentReportToolStripMenuItem";
|
||||
TourAndPaymentReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||
TourAndPaymentReportToolStripMenuItem.Size = new Size(467, 26);
|
||||
TourAndPaymentReportToolStripMenuItem.Text = "Сводка по числу остановок и оплате договора";
|
||||
TourAndPaymentReportToolStripMenuItem.Click += TourAndPaymentReportToolStripMenuItem_Click;
|
||||
//
|
||||
// VolumeOfPaymentsToolStripMenuItem
|
||||
//
|
||||
VolumeOfPaymentsToolStripMenuItem.Name = "VolumeOfPaymentsToolStripMenuItem";
|
||||
VolumeOfPaymentsToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
||||
VolumeOfPaymentsToolStripMenuItem.Size = new Size(467, 26);
|
||||
VolumeOfPaymentsToolStripMenuItem.Text = "Объём оплат клиентов";
|
||||
VolumeOfPaymentsToolStripMenuItem.Click += VolumeOfPaymentsToolStripMenuItem_Click;
|
||||
//
|
||||
// FormTravel_Agency
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
@@ -134,5 +162,8 @@
|
||||
private ToolStripMenuItem ContractToolStripMenuItem;
|
||||
private ToolStripMenuItem PaymentToolStripMenuItem;
|
||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||
private ToolStripMenuItem TourAndPaymentReportToolStripMenuItem;
|
||||
private ToolStripMenuItem VolumeOfPaymentsToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
@@ -78,5 +78,44 @@ namespace Travel_Agency
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void DirectoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormDirectoryReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void TourAndPaymentReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormTourAndPaymentReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void VolumeOfPaymentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormPaymentReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -122,6 +122,7 @@
|
||||
Controls.Add(labelName);
|
||||
Controls.Add(comboBoxPosition);
|
||||
Name = "FormClient";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Клиент";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Travel_Agency.Forms
|
||||
}
|
||||
|
||||
private void ButtonCencel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
|
||||
private Client CreateClient(int id) => Client.CreateEntity(id, textBoxName.Text, textBoxPassport.Text,
|
||||
(PositionInSociety)comboBoxPosition.SelectedItem!);
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormClients";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Клиенты";
|
||||
Load += FormClients_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
|
||||
@@ -87,7 +87,14 @@ namespace Travel_Agency.Forms
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridView.DataSource = _clientRepository.ReadClients();
|
||||
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridView.DataSource = _clientRepository.ReadClients();
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["Name_PositionInSociety"].Visible = false;
|
||||
}
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
<data name="ButtonDel.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAANMAAADPCAIAAADgcXNuAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vgAADr4B6kKxwAAADuxJREFUeF7tnUGOJDsRhp8EQiC9xZNACNAsWHAFFpyCFYdg2Wdg3zfgAn0BbtAH
|
||||
vQAADr0BR/uQrQAADuxJREFUeF7tnUGOJDsRhp8EQiC9xZNACNAsWHAFFpyCFYdg2Wdg3zfgAn0BbtAH
|
||||
4Aq15Q5DaPxPql6U7YqwIxzOrPj0L0Yz1ZFO+ytn2lld88PXJIkgzUtiSPOSGNK8JIY0L4khzUtiSPOS
|
||||
GNK8JIY0L4khzUtiSPOSGNK8JIY0L4khzUtiSPOSGNK8JIY0L4khzUtiSPOSGNK8JIY0L4khzUtiSPOa
|
||||
3G63z8/P9/f3t7e3v33ny3d+uKP8TXnBP75BP/LxDSqCcsnPSfNA8axIxsSahwoeOuJ4L89Lm+en2lNS
|
||||
@@ -191,7 +191,7 @@
|
||||
<data name="ButtonUpd.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAPMAAAD0CAIAAADBkYfQAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vgAADr4B6kKxwAAADAxJREFUeF7t3V9o1fUfx/FqzRaFMCWHYxkkIhokmEZb1E1s0EWOLqaCKAOFmF5N
|
||||
vQAADr0BR/uQrQAADAxJREFUeF7t3V9o1fUfx/FqzRaFMCWHYxkkIhokmEZb1E1s0EWOLqaCKAOFmF5N
|
||||
vGkUgcyLyEYXRRALvHHQIi+T2qBFY3lhhBeyIQjqwfVHf6hoWa6136fO2+U83/M93+85n/P5+3xwCM52
|
||||
vue7i2dfXvuyuQcWgBBRNsJE2QgTZSNMlI0wUTbCRNkIE2UjTJSNso4cOTIwMCBPfEPZSHbs2LEH/tXb
|
||||
2ysf8gplI8H4+Hgx66LOzs4rV67I5zxB2bjfzMxMS0uLRH3XM888c+bMGXmFDygbS9y8eXPz5s2S81LN
|
||||
@@ -248,7 +248,7 @@
|
||||
<data name="ButtonAdd.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAKkAAAClCAIAAACodUoDAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vgAADr4B6kKxwAAAF+dJREFUeF7tXWuPHcWZpvvcT/eZGc+Mx4MvYGOMr4Nn7PGYGc94xvY4EayWzRek
|
||||
vQAADr0BR/uQrQAAF+dJREFUeF7tXWuPHcWZpvvcT/eZGc+Mx4MvYGOMr4Nn7PGYGc94xvY4EayWzRek
|
||||
fEFKpEjRhmg3lmATKSChZaWED+twMyEkEG4mrLlfYsDY2GGDWUIE5DfwQ9jnPf36eFynqk51d/XlzDmP
|
||||
Ho16+nR3VdfT9Va9b1dVX/dtH72Kvva9i772vYu+9r2Lvva9i772vYu+9r2Lvva9i772vYu+9r2Lvva9
|
||||
i772vYu+9r2Lvva9i772vYtVrv0333xz+fLlkydPnmhitomNTVx3LYKdwQF33XUXDj5z5gzO5QutRqw2
|
||||
|
||||
@@ -43,8 +43,7 @@
|
||||
groupBoxTour = new GroupBox();
|
||||
dataGridViewTours = new DataGridView();
|
||||
ColumnTour = new DataGridViewComboBoxColumn();
|
||||
ColumnStartDate = new DataGridViewTextBoxColumn();
|
||||
ColumEndDate = new DataGridViewTextBoxColumn();
|
||||
ColumnCountOfStop = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownContractNumber).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownDiscount).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownTouristNumber).BeginInit();
|
||||
@@ -164,7 +163,7 @@
|
||||
groupBoxTour.Controls.Add(dataGridViewTours);
|
||||
groupBoxTour.Location = new Point(403, 33);
|
||||
groupBoxTour.Name = "groupBoxTour";
|
||||
groupBoxTour.Size = new Size(463, 428);
|
||||
groupBoxTour.Size = new Size(434, 428);
|
||||
groupBoxTour.TabIndex = 16;
|
||||
groupBoxTour.TabStop = false;
|
||||
groupBoxTour.Text = "Туры";
|
||||
@@ -174,7 +173,7 @@
|
||||
dataGridViewTours.AllowUserToResizeColumns = false;
|
||||
dataGridViewTours.AllowUserToResizeRows = false;
|
||||
dataGridViewTours.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewTours.Columns.AddRange(new DataGridViewColumn[] { ColumnTour, ColumnStartDate, ColumEndDate });
|
||||
dataGridViewTours.Columns.AddRange(new DataGridViewColumn[] { ColumnTour, ColumnCountOfStop });
|
||||
dataGridViewTours.Dock = DockStyle.Fill;
|
||||
dataGridViewTours.Location = new Point(3, 23);
|
||||
dataGridViewTours.MultiSelect = false;
|
||||
@@ -182,7 +181,7 @@
|
||||
dataGridViewTours.RowHeadersVisible = false;
|
||||
dataGridViewTours.RowHeadersWidth = 51;
|
||||
dataGridViewTours.RowTemplate.Height = 29;
|
||||
dataGridViewTours.Size = new Size(457, 402);
|
||||
dataGridViewTours.Size = new Size(428, 402);
|
||||
dataGridViewTours.StandardTab = true;
|
||||
dataGridViewTours.TabIndex = 0;
|
||||
//
|
||||
@@ -191,28 +190,21 @@
|
||||
ColumnTour.HeaderText = "Тур";
|
||||
ColumnTour.MinimumWidth = 6;
|
||||
ColumnTour.Name = "ColumnTour";
|
||||
ColumnTour.Width = 200;
|
||||
ColumnTour.Width = 300;
|
||||
//
|
||||
// ColumnStartDate
|
||||
// ColumnCountOfStop
|
||||
//
|
||||
ColumnStartDate.HeaderText = "Дата начала путишествия";
|
||||
ColumnStartDate.MinimumWidth = 6;
|
||||
ColumnStartDate.Name = "ColumnStartDate";
|
||||
ColumnStartDate.Resizable = DataGridViewTriState.True;
|
||||
ColumnStartDate.Width = 125;
|
||||
//
|
||||
// ColumEndDate
|
||||
//
|
||||
ColumEndDate.HeaderText = "Дата конца путешествия";
|
||||
ColumEndDate.MinimumWidth = 6;
|
||||
ColumEndDate.Name = "ColumEndDate";
|
||||
ColumEndDate.Width = 125;
|
||||
ColumnCountOfStop.HeaderText = "Число остановок";
|
||||
ColumnCountOfStop.MinimumWidth = 6;
|
||||
ColumnCountOfStop.Name = "ColumnCountOfStop";
|
||||
ColumnCountOfStop.Resizable = DataGridViewTriState.True;
|
||||
ColumnCountOfStop.Width = 125;
|
||||
//
|
||||
// FormContract
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(897, 496);
|
||||
ClientSize = new Size(868, 496);
|
||||
Controls.Add(groupBoxTour);
|
||||
Controls.Add(numericUpDownFinalPrice);
|
||||
Controls.Add(numericUpDownTouristNumber);
|
||||
@@ -256,7 +248,6 @@
|
||||
private GroupBox groupBoxTour;
|
||||
private DataGridView dataGridViewTours;
|
||||
private DataGridViewComboBoxColumn ColumnTour;
|
||||
private DataGridViewTextBoxColumn ColumnStartDate;
|
||||
private DataGridViewTextBoxColumn ColumEndDate;
|
||||
private DataGridViewTextBoxColumn ColumnCountOfStop;
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,10 @@ namespace Travel_Agency.Forms
|
||||
_contractRepository = contractRepository ??
|
||||
throw new ArgumentNullException(nameof(contractRepository));
|
||||
comboBoxClient.DataSource = clientRepository.ReadClients();
|
||||
comboBoxClient.DisplayMember = "Name";
|
||||
comboBoxClient.DisplayMember = "Name_PositionInSociety";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
ColumnTour.DataSource = tourRepository.ReadTours();
|
||||
ColumnTour.DisplayMember = "Name";
|
||||
ColumnTour.DisplayMember = "Name_TypeOfTour";
|
||||
ColumnTour.ValueMember = "Id";
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ namespace Travel_Agency.Forms
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private List<Contract_Tour> CreateListContract_TourFromDataGrid()
|
||||
{
|
||||
var list = new List<Contract_Tour>();
|
||||
@@ -58,11 +59,11 @@ namespace Travel_Agency.Forms
|
||||
}
|
||||
list.Add(Contract_Tour.CreateElement(0,
|
||||
Convert.ToInt32(row.Cells["ColumnTour"].Value),
|
||||
row.Cells["ColumnStartDate"].Value.ToString(),
|
||||
row.Cells["ColumEndDate"].Value.ToString()
|
||||
));
|
||||
Convert.ToInt32(row.Cells["ColumnCountOfStop"].Value
|
||||
)));
|
||||
}
|
||||
return list;
|
||||
return list.GroupBy(x => x.TourId, x => x.CountOfStop, (id, counts) =>
|
||||
Contract_Tour.CreateElement(0, id, counts.Sum())).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,10 +120,7 @@
|
||||
<metadata name="ColumnTour.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnStartDate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumEndDate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<metadata name="ColumnCountOfStop.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -42,7 +42,7 @@
|
||||
panel1.Controls.Add(ButtonDel);
|
||||
panel1.Controls.Add(ButtonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(651, 0);
|
||||
panel1.Location = new Point(1080, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(149, 450);
|
||||
panel1.TabIndex = 3;
|
||||
@@ -86,14 +86,14 @@
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(651, 450);
|
||||
dataGridView.Size = new Size(1080, 450);
|
||||
dataGridView.TabIndex = 4;
|
||||
//
|
||||
// FormContracts
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
ClientSize = new Size(1229, 450);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormContracts";
|
||||
|
||||
@@ -32,7 +32,12 @@ namespace Travel_Agency.Forms
|
||||
|
||||
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _contractRepository.ReadContracts();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridView.DataSource = _contractRepository.ReadContracts();
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["Date"].DefaultCellStyle.Format = "dd.MM.yyyy";
|
||||
}
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
|
||||
100
Travel_Agency/Travel_Agency/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
100
Travel_Agency/Travel_Agency/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
@@ -0,0 +1,100 @@
|
||||
namespace Travel_Agency.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()
|
||||
{
|
||||
checkBoxClients = new CheckBox();
|
||||
checkBoxTours = new CheckBox();
|
||||
checkBoxRoutes = new CheckBox();
|
||||
ButtonCreate = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkBoxClients
|
||||
//
|
||||
checkBoxClients.AutoSize = true;
|
||||
checkBoxClients.Location = new Point(34, 41);
|
||||
checkBoxClients.Name = "checkBoxClients";
|
||||
checkBoxClients.Size = new Size(91, 24);
|
||||
checkBoxClients.TabIndex = 0;
|
||||
checkBoxClients.Text = "Клиенты";
|
||||
checkBoxClients.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxTours
|
||||
//
|
||||
checkBoxTours.AutoSize = true;
|
||||
checkBoxTours.Location = new Point(34, 93);
|
||||
checkBoxTours.Name = "checkBoxTours";
|
||||
checkBoxTours.Size = new Size(66, 24);
|
||||
checkBoxTours.TabIndex = 1;
|
||||
checkBoxTours.Text = "Туры";
|
||||
checkBoxTours.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxRoutes
|
||||
//
|
||||
checkBoxRoutes.AutoSize = true;
|
||||
checkBoxRoutes.Location = new Point(34, 152);
|
||||
checkBoxRoutes.Name = "checkBoxRoutes";
|
||||
checkBoxRoutes.Size = new Size(106, 24);
|
||||
checkBoxRoutes.TabIndex = 2;
|
||||
checkBoxRoutes.Text = "Маршруты";
|
||||
checkBoxRoutes.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// ButtonCreate
|
||||
//
|
||||
ButtonCreate.Location = new Point(210, 83);
|
||||
ButtonCreate.Name = "ButtonCreate";
|
||||
ButtonCreate.Size = new Size(127, 43);
|
||||
ButtonCreate.TabIndex = 3;
|
||||
ButtonCreate.Text = "Сформировать";
|
||||
ButtonCreate.UseVisualStyleBackColor = true;
|
||||
ButtonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// FormDirectoryReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(409, 228);
|
||||
Controls.Add(ButtonCreate);
|
||||
Controls.Add(checkBoxRoutes);
|
||||
Controls.Add(checkBoxTours);
|
||||
Controls.Add(checkBoxClients);
|
||||
Name = "FormDirectoryReport";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Отчёт по справочникам";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckBox checkBoxClients;
|
||||
private CheckBox checkBoxTours;
|
||||
private CheckBox checkBoxRoutes;
|
||||
private Button ButtonCreate;
|
||||
}
|
||||
}
|
||||
50
Travel_Agency/Travel_Agency/Forms/FormDirectoryReport.cs
Normal file
50
Travel_Agency/Travel_Agency/Forms/FormDirectoryReport.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Travel_Agency.Reports;
|
||||
using Unity;
|
||||
|
||||
namespace Travel_Agency.Forms
|
||||
{
|
||||
public partial class FormDirectoryReport : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
public FormDirectoryReport(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!checkBoxClients.Checked && !checkBoxTours.Checked && !checkBoxRoutes.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, checkBoxClients.Checked,
|
||||
checkBoxTours.Checked, checkBoxRoutes.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Travel_Agency/Travel_Agency/Forms/FormDirectoryReport.resx
Normal file
120
Travel_Agency/Travel_Agency/Forms/FormDirectoryReport.resx
Normal file
@@ -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>
|
||||
@@ -27,8 +27,9 @@ namespace Travel_Agency.Forms
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
_paymentRepository.CreatePayment(Payment.CreateOperation(0,
|
||||
(int)comboBoxClient.SelectedValue!,
|
||||
Convert.ToInt32(numericUpDownSum.Value)));
|
||||
Convert.ToInt32(numericUpDownSum.Value),
|
||||
(int)comboBoxClient.SelectedValue!));
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
108
Travel_Agency/Travel_Agency/Forms/FormPaymentReport.Designer.cs
generated
Normal file
108
Travel_Agency/Travel_Agency/Forms/FormPaymentReport.Designer.cs
generated
Normal file
@@ -0,0 +1,108 @@
|
||||
namespace Travel_Agency.Forms
|
||||
{
|
||||
partial class FormPaymentReport
|
||||
{
|
||||
/// <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();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
labelDate = new Label();
|
||||
labelFile = new Label();
|
||||
ButtonCreate = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ButtonSelectFileName
|
||||
//
|
||||
ButtonSelectFileName.Location = new Point(43, 33);
|
||||
ButtonSelectFileName.Name = "ButtonSelectFileName";
|
||||
ButtonSelectFileName.Size = new Size(94, 29);
|
||||
ButtonSelectFileName.TabIndex = 0;
|
||||
ButtonSelectFileName.Text = "Выбрать";
|
||||
ButtonSelectFileName.UseVisualStyleBackColor = true;
|
||||
ButtonSelectFileName.Click += ButtonSelectFileName_Click;
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(153, 126);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(250, 27);
|
||||
dateTimePicker.TabIndex = 1;
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
labelDate.AutoSize = true;
|
||||
labelDate.Location = new Point(44, 131);
|
||||
labelDate.Name = "labelDate";
|
||||
labelDate.Size = new Size(44, 20);
|
||||
labelDate.TabIndex = 2;
|
||||
labelDate.Text = "Дата:";
|
||||
//
|
||||
// labelFile
|
||||
//
|
||||
labelFile.AutoSize = true;
|
||||
labelFile.Location = new Point(184, 37);
|
||||
labelFile.Name = "labelFile";
|
||||
labelFile.Size = new Size(45, 20);
|
||||
labelFile.TabIndex = 3;
|
||||
labelFile.Text = "Файл";
|
||||
//
|
||||
// ButtonCreate
|
||||
//
|
||||
ButtonCreate.Location = new Point(153, 198);
|
||||
ButtonCreate.Name = "ButtonCreate";
|
||||
ButtonCreate.Size = new Size(128, 29);
|
||||
ButtonCreate.TabIndex = 4;
|
||||
ButtonCreate.Text = "Сформировать";
|
||||
ButtonCreate.UseVisualStyleBackColor = true;
|
||||
ButtonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// FormPaymentReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(447, 273);
|
||||
Controls.Add(ButtonCreate);
|
||||
Controls.Add(labelFile);
|
||||
Controls.Add(labelDate);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(ButtonSelectFileName);
|
||||
Name = "FormPaymentReport";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Отчёт по выплатам";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button ButtonSelectFileName;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Label labelDate;
|
||||
private Label labelFile;
|
||||
private Button ButtonCreate;
|
||||
}
|
||||
}
|
||||
62
Travel_Agency/Travel_Agency/Forms/FormPaymentReport.cs
Normal file
62
Travel_Agency/Travel_Agency/Forms/FormPaymentReport.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
using Travel_Agency.Reports;
|
||||
using Unity;
|
||||
|
||||
namespace Travel_Agency.Forms
|
||||
{
|
||||
public partial class FormPaymentReport : Form
|
||||
{
|
||||
private string _fileName = string.Empty;
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
public FormPaymentReport(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
private void ButtonSelectFileName_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Pdf Files | *.pdf"
|
||||
};
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_fileName = sfd.FileName;
|
||||
labelFile.Text = Path.GetFileName(_fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Travel_Agency/Travel_Agency/Forms/FormPaymentReport.resx
Normal file
120
Travel_Agency/Travel_Agency/Forms/FormPaymentReport.resx
Normal file
@@ -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>
|
||||
@@ -84,7 +84,8 @@
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormPayments";
|
||||
Text = "FormPayments";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Выплаты";
|
||||
Load += FormPayments_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
|
||||
@@ -45,6 +45,11 @@ namespace Travel_Agency.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _paymentRepository.ReadPayments();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridView.DataSource = _paymentRepository.ReadPayments();
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["Date"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(48, 52);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(118, 20);
|
||||
labelName.Size = new Size(158, 20);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "Название маршрута :";
|
||||
//
|
||||
@@ -83,7 +83,7 @@
|
||||
// labelTourId
|
||||
//
|
||||
labelTourId.AutoSize = true;
|
||||
labelTourId.Location = new Point(48, 311);
|
||||
labelTourId.Location = new Point(48, 306);
|
||||
labelTourId.Name = "labelTourId";
|
||||
labelTourId.Size = new Size(40, 20);
|
||||
labelTourId.TabIndex = 4;
|
||||
@@ -142,9 +142,9 @@
|
||||
// comboBoxTour
|
||||
//
|
||||
comboBoxTour.FormattingEnabled = true;
|
||||
comboBoxTour.Location = new Point(278, 303);
|
||||
comboBoxTour.Location = new Point(210, 303);
|
||||
comboBoxTour.Name = "comboBoxTour";
|
||||
comboBoxTour.Size = new Size(151, 28);
|
||||
comboBoxTour.Size = new Size(361, 28);
|
||||
comboBoxTour.TabIndex = 12;
|
||||
//
|
||||
// FormRoute
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Travel_Agency.Forms
|
||||
_routeRepository = routeRepository ??
|
||||
throw new ArgumentNullException(nameof(routeRepository));
|
||||
comboBoxTour.DataSource = tourRepository.ReadTours();
|
||||
comboBoxTour.DisplayMember = "Name";
|
||||
comboBoxTour.DisplayMember = "Name_TypeOfTour";
|
||||
comboBoxTour.ValueMember = "Id";
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,12 @@ namespace Travel_Agency.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _routeRepository.ReadRoutes();
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridView.DataSource = _routeRepository.ReadRoutes();
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
}
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
|
||||
187
Travel_Agency/Travel_Agency/Forms/FormTourAndPaymentReport.Designer.cs
generated
Normal file
187
Travel_Agency/Travel_Agency/Forms/FormTourAndPaymentReport.Designer.cs
generated
Normal file
@@ -0,0 +1,187 @@
|
||||
namespace Travel_Agency.Forms
|
||||
{
|
||||
partial class FormTourAndPaymentReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelPath = new Label();
|
||||
textBoxFilePath = new TextBox();
|
||||
ButtonSelectFilePath = new Button();
|
||||
ButtonCreate = new Button();
|
||||
labelClient = new Label();
|
||||
labelStartDate = new Label();
|
||||
labelEndDate = new Label();
|
||||
dateTimePickerStartDate = new DateTimePicker();
|
||||
dateTimePickerEndDate = new DateTimePicker();
|
||||
labelTour = new Label();
|
||||
comboBoxClient = new ComboBox();
|
||||
comboBoxTour = new ComboBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelPath
|
||||
//
|
||||
labelPath.AutoSize = true;
|
||||
labelPath.Location = new Point(32, 27);
|
||||
labelPath.Name = "labelPath";
|
||||
labelPath.Size = new Size(112, 20);
|
||||
labelPath.TabIndex = 0;
|
||||
labelPath.Text = "Путь до файла:";
|
||||
//
|
||||
// textBoxFilePath
|
||||
//
|
||||
textBoxFilePath.Location = new Point(158, 24);
|
||||
textBoxFilePath.Name = "textBoxFilePath";
|
||||
textBoxFilePath.ReadOnly = true;
|
||||
textBoxFilePath.Size = new Size(214, 27);
|
||||
textBoxFilePath.TabIndex = 1;
|
||||
//
|
||||
// ButtonSelectFilePath
|
||||
//
|
||||
ButtonSelectFilePath.Location = new Point(378, 22);
|
||||
ButtonSelectFilePath.Name = "ButtonSelectFilePath";
|
||||
ButtonSelectFilePath.Size = new Size(30, 29);
|
||||
ButtonSelectFilePath.TabIndex = 2;
|
||||
ButtonSelectFilePath.Text = "..";
|
||||
ButtonSelectFilePath.UseVisualStyleBackColor = true;
|
||||
ButtonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
||||
//
|
||||
// ButtonCreate
|
||||
//
|
||||
ButtonCreate.Location = new Point(158, 305);
|
||||
ButtonCreate.Name = "ButtonCreate";
|
||||
ButtonCreate.Size = new Size(124, 29);
|
||||
ButtonCreate.TabIndex = 3;
|
||||
ButtonCreate.Text = "Сформировать";
|
||||
ButtonCreate.UseVisualStyleBackColor = true;
|
||||
ButtonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// labelClient
|
||||
//
|
||||
labelClient.AutoSize = true;
|
||||
labelClient.Location = new Point(32, 77);
|
||||
labelClient.Name = "labelClient";
|
||||
labelClient.Size = new Size(61, 20);
|
||||
labelClient.TabIndex = 4;
|
||||
labelClient.Text = "Клиент:";
|
||||
//
|
||||
// labelStartDate
|
||||
//
|
||||
labelStartDate.AutoSize = true;
|
||||
labelStartDate.Location = new Point(32, 196);
|
||||
labelStartDate.Name = "labelStartDate";
|
||||
labelStartDate.Size = new Size(97, 20);
|
||||
labelStartDate.TabIndex = 5;
|
||||
labelStartDate.Text = "Дата начала:";
|
||||
//
|
||||
// labelEndDate
|
||||
//
|
||||
labelEndDate.AutoSize = true;
|
||||
labelEndDate.Location = new Point(32, 240);
|
||||
labelEndDate.Name = "labelEndDate";
|
||||
labelEndDate.Size = new Size(90, 20);
|
||||
labelEndDate.TabIndex = 6;
|
||||
labelEndDate.Text = "Дата конца:";
|
||||
//
|
||||
// dateTimePickerStartDate
|
||||
//
|
||||
dateTimePickerStartDate.Location = new Point(158, 191);
|
||||
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
|
||||
dateTimePickerStartDate.Size = new Size(250, 27);
|
||||
dateTimePickerStartDate.TabIndex = 7;
|
||||
//
|
||||
// dateTimePickerEndDate
|
||||
//
|
||||
dateTimePickerEndDate.Location = new Point(158, 235);
|
||||
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
|
||||
dateTimePickerEndDate.Size = new Size(250, 27);
|
||||
dateTimePickerEndDate.TabIndex = 8;
|
||||
//
|
||||
// labelTour
|
||||
//
|
||||
labelTour.AutoSize = true;
|
||||
labelTour.Location = new Point(32, 138);
|
||||
labelTour.Name = "labelTour";
|
||||
labelTour.Size = new Size(36, 20);
|
||||
labelTour.TabIndex = 9;
|
||||
labelTour.Text = "Тур:";
|
||||
//
|
||||
// comboBoxClient
|
||||
//
|
||||
comboBoxClient.FormattingEnabled = true;
|
||||
comboBoxClient.Location = new Point(158, 74);
|
||||
comboBoxClient.Name = "comboBoxClient";
|
||||
comboBoxClient.Size = new Size(250, 28);
|
||||
comboBoxClient.TabIndex = 10;
|
||||
//
|
||||
// comboBoxTour
|
||||
//
|
||||
comboBoxTour.FormattingEnabled = true;
|
||||
comboBoxTour.Location = new Point(158, 135);
|
||||
comboBoxTour.Name = "comboBoxTour";
|
||||
comboBoxTour.Size = new Size(250, 28);
|
||||
comboBoxTour.TabIndex = 11;
|
||||
//
|
||||
// FormTourAndPaymentReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(462, 352);
|
||||
Controls.Add(comboBoxTour);
|
||||
Controls.Add(comboBoxClient);
|
||||
Controls.Add(labelTour);
|
||||
Controls.Add(dateTimePickerEndDate);
|
||||
Controls.Add(dateTimePickerStartDate);
|
||||
Controls.Add(labelEndDate);
|
||||
Controls.Add(labelStartDate);
|
||||
Controls.Add(labelClient);
|
||||
Controls.Add(ButtonCreate);
|
||||
Controls.Add(ButtonSelectFilePath);
|
||||
Controls.Add(textBoxFilePath);
|
||||
Controls.Add(labelPath);
|
||||
Name = "FormTourAndPaymentReport";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Отчёт по остановкам и оплатам";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelPath;
|
||||
private TextBox textBoxFilePath;
|
||||
private Button ButtonSelectFilePath;
|
||||
private Button ButtonCreate;
|
||||
private Label labelClient;
|
||||
private Label labelStartDate;
|
||||
private Label labelEndDate;
|
||||
private DateTimePicker dateTimePickerStartDate;
|
||||
private DateTimePicker dateTimePickerEndDate;
|
||||
private Label labelTour;
|
||||
private ComboBox comboBoxClient;
|
||||
private ComboBox comboBoxTour;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
|
||||
using Travel_Agency.Reports;
|
||||
using Travel_Agency.Repositories;
|
||||
using Unity;
|
||||
|
||||
namespace Travel_Agency.Forms
|
||||
{
|
||||
public partial class FormTourAndPaymentReport : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
|
||||
public FormTourAndPaymentReport(IUnityContainer container, ITourRepository tourRepository, IClientRepository clientRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
comboBoxClient.DataSource = clientRepository.ReadClients();
|
||||
comboBoxClient.DisplayMember = "Name";
|
||||
comboBoxClient.ValueMember = "Id";
|
||||
comboBoxTour.DataSource = tourRepository.ReadTours();
|
||||
comboBoxTour.DisplayMember = "Name";
|
||||
comboBoxTour.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 ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
||||
{
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
}
|
||||
if (comboBoxClient.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Не выбран клиент");
|
||||
}
|
||||
if (comboBoxTour.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Не выбран тур");
|
||||
}
|
||||
if (dateTimePickerEndDate.Value <=
|
||||
dateTimePickerStartDate.Value)
|
||||
{
|
||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||
}
|
||||
if
|
||||
(_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text,
|
||||
(int)comboBoxClient.SelectedValue!, (int)comboBoxTour.SelectedValue!,
|
||||
dateTimePickerStartDate.Value, dateTimePickerEndDate.Value))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован",
|
||||
"Формирование документа",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||
"Формирование документа",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
Travel_Agency/Travel_Agency/Forms/FormTourAndPaymentReport.resx
Normal file
120
Travel_Agency/Travel_Agency/Forms/FormTourAndPaymentReport.resx
Normal file
@@ -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>
|
||||
@@ -87,7 +87,14 @@ namespace Travel_Agency.Forms
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridView.DataSource = _tourRepository.ReadTours();
|
||||
|
||||
private void LoadList()
|
||||
{
|
||||
dataGridView.DataSource = _tourRepository.ReadTours();
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["Name_TypeOfTour"].Visible = false;
|
||||
}
|
||||
|
||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||
{
|
||||
id = 0;
|
||||
|
||||
42
Travel_Agency/Travel_Agency/Reports/ChartReport.cs
Normal file
42
Travel_Agency/Travel_Agency/Reports/ChartReport.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Travel_Agency.Repositories;
|
||||
|
||||
namespace Travel_Agency.Reports;
|
||||
|
||||
public class ChartReport
|
||||
{
|
||||
private readonly IPaymentRepository _paymentRepository;
|
||||
private readonly ILogger<ChartReport> _logger;
|
||||
|
||||
public ChartReport(IPaymentRepository paymentRepository, ILogger<ChartReport> logger)
|
||||
{
|
||||
_paymentRepository = paymentRepository ?? throw new ArgumentNullException(nameof(paymentRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
public bool CreateChart(string filePath, DateTime dateTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
new PdfBuilder(filePath)
|
||||
.AddHeader("Сумма выплат клиентов")
|
||||
.AddPieChart($"Клиенты на {dateTime: dd MMMM yyyy}", GetData(dateTime))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||
{
|
||||
return _paymentRepository
|
||||
.ReadPayments(dateForm: dateTime.Date, dateTo: dateTime.Date.AddDays(1))
|
||||
.Where(x => x.Date.Date == dateTime.Date)
|
||||
.GroupBy(x => x.ClientName, (key, group) => new { ID = key, AllSum = group.Sum(y => y.Sum) })
|
||||
.Select(x => (x.ID.ToString(), (double)x.AllSum))
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
82
Travel_Agency/Travel_Agency/Reports/DocReport.cs
Normal file
82
Travel_Agency/Travel_Agency/Reports/DocReport.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Travel_Agency.Repositories;
|
||||
|
||||
namespace Travel_Agency.Reports;
|
||||
|
||||
public class DocReport
|
||||
{
|
||||
private readonly IClientRepository _clientRepository;
|
||||
private readonly IRouteRepository _routeRepository;
|
||||
private readonly ITourRepository _tourRepository;
|
||||
|
||||
private readonly ILogger<DocReport> _logger;
|
||||
|
||||
public DocReport(IClientRepository clientRepository, IRouteRepository routeRepository,
|
||||
ITourRepository tourRepository, ILogger<DocReport> logger)
|
||||
{
|
||||
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
|
||||
_tourRepository = tourRepository ?? throw new ArgumentNullException(nameof(tourRepository));
|
||||
_routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateDoc(string filePath, bool includeClients, bool includeTours, bool includeRoutes)
|
||||
{
|
||||
try
|
||||
{
|
||||
var builder = new WordBuilder(filePath).AddHeader("Документ со справочниками");
|
||||
if (includeClients)
|
||||
{
|
||||
builder.AddParagraph("Клиенты").AddTable([2400, 2400, 2400], GetClients());
|
||||
}
|
||||
if (includeTours)
|
||||
{
|
||||
builder.AddParagraph("Туры").AddTable([2400, 2400, 2400], GetTours());
|
||||
}
|
||||
if (includeRoutes)
|
||||
{
|
||||
builder.AddParagraph("Маршруты").AddTable([1200, 1200, 2400, 1200, 1200], GetRoutes());
|
||||
}
|
||||
builder.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetClients()
|
||||
{
|
||||
return [
|
||||
["ФИО клиента", "Паспортные данные", "позиция в обществе"],
|
||||
.. _clientRepository
|
||||
.ReadClients()
|
||||
.Select(x => new string[] { x.Name, x.PassportDetails, x.PositionInSociety.ToString() }),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private List<string[]> GetTours()
|
||||
{
|
||||
return [
|
||||
["Название", "Тип тура", "Цена"],
|
||||
.. _tourRepository
|
||||
.ReadTours()
|
||||
.Select(x => new string[] { x.Name, x.TypeOfTour.ToString(), x.Price.ToString() }),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
private List<string[]> GetRoutes()
|
||||
{
|
||||
return [
|
||||
["Название", "Рейтинг в %", "Места посещения", "Цена", "Тур"],
|
||||
.. _routeRepository
|
||||
.ReadRoutes()
|
||||
.Select(x => new string[] { x.Name, x.Rating.ToString(), x.Places, x.Price.ToString(), x.TourId.ToString() }),
|
||||
];
|
||||
}
|
||||
}
|
||||
313
Travel_Agency/Travel_Agency/Reports/ExcelBuilder.cs
Normal file
313
Travel_Agency/Travel_Agency/Reports/ExcelBuilder.cs
Normal file
@@ -0,0 +1,313 @@
|
||||
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml;
|
||||
|
||||
namespace Travel_Agency.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.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("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)
|
||||
}
|
||||
});
|
||||
// TODO добавить шрифт с жирным
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme()
|
||||
{
|
||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||
},
|
||||
Bold = new Bold() { Val = true }
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fonts);
|
||||
|
||||
// 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()
|
||||
});
|
||||
// TODO добавить настройку с границами
|
||||
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
|
||||
}
|
||||
});
|
||||
// TODO дополнить форматы
|
||||
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,
|
||||
// TODO дополнить стили
|
||||
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;
|
||||
}
|
||||
}
|
||||
88
Travel_Agency/Travel_Agency/Reports/PdfBuilder.cs
Normal file
88
Travel_Agency/Travel_Agency/Reports/PdfBuilder.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||
using MigraDoc.Rendering;
|
||||
using System.Text;
|
||||
|
||||
namespace Travel_Agency.Reports;
|
||||
|
||||
public class PdfBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
private readonly Document _document;
|
||||
public PdfBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
_filePath = filePath;
|
||||
_document = new Document();
|
||||
DefineStyles();
|
||||
}
|
||||
|
||||
public PdfBuilder AddHeader(string header)
|
||||
{
|
||||
_document.AddSection().AddParagraph(header, "NormalBold");
|
||||
return this;
|
||||
}
|
||||
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
|
||||
{
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
var chart = new Chart(ChartType.Pie2D);
|
||||
var series = chart.SeriesCollection.AddSeries();
|
||||
series.Add(data.Select(x => x.Value).ToArray());
|
||||
|
||||
var xseries = chart.XValues.AddXSeries();
|
||||
xseries.Add(data.Select(x => x.Caption).ToArray());
|
||||
|
||||
chart.DataLabel.Type = DataLabelType.Percent;
|
||||
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
||||
|
||||
chart.Width = Unit.FromCentimeter(16);
|
||||
chart.Height = Unit.FromCentimeter(12);
|
||||
|
||||
chart.TopArea.AddParagraph(title);
|
||||
|
||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||
|
||||
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.HasMajorGridlines = true;
|
||||
|
||||
chart.PlotArea.LineFormat.Width = 1;
|
||||
chart.PlotArea.LineFormat.Visible = true;
|
||||
|
||||
chart.TopArea.AddLegend();
|
||||
|
||||
_document.LastSection.Add(chart);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(_filePath);
|
||||
}
|
||||
|
||||
private void DefineStyles()
|
||||
{
|
||||
//TODO задать стиль для заголовка(жирный)
|
||||
var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
|
||||
headerStyle.Font.Bold = true;
|
||||
headerStyle.Font.Size = 14;
|
||||
}
|
||||
}
|
||||
60
Travel_Agency/Travel_Agency/Reports/TableReport.cs
Normal file
60
Travel_Agency/Travel_Agency/Reports/TableReport.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Linq;
|
||||
using Travel_Agency.Entities;
|
||||
using Travel_Agency.Repositories;
|
||||
|
||||
namespace Travel_Agency.Reports;
|
||||
|
||||
public class TableReport
|
||||
{
|
||||
private readonly IContractRepository _contractRepository;
|
||||
private readonly IPaymentRepository _paymentRepository;
|
||||
private readonly ILogger<TableReport> _logger;
|
||||
internal static readonly string[] item = ["Клиент", "Дата", "Число остановок", "Оплата договора"];
|
||||
|
||||
public TableReport(IContractRepository contractRepository, IPaymentRepository paymentRepository,
|
||||
ILogger<TableReport> logger)
|
||||
{
|
||||
_contractRepository = contractRepository ?? throw new ArgumentNullException(nameof(contractRepository));
|
||||
_paymentRepository = paymentRepository ?? throw new ArgumentNullException(nameof(paymentRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateTable(string filePath, int clientId, int tourId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
new ExcelBuilder(filePath)
|
||||
.AddHeader("Сводка по числу остановок и оплате договора", 0, 4)
|
||||
.AddParagraph($"за период c { startDate: dd.MM.yyyy} по { endDate: dd.MM.yyyy}", 0)
|
||||
.AddTable([10, 10, 10, 10], GetData(clientId, tourId, startDate, endDate))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetData(int clientId, int tourId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var data = _contractRepository
|
||||
.ReadContracts(startDate, endDate, clientId)
|
||||
.Select(x => new { x.ClientName, Date = x.Date, CountOfStop = x.Tours.FirstOrDefault(y => y.TourId == tourId)?.CountOfStop, Payment = (int?)null })
|
||||
.Union(
|
||||
_paymentRepository
|
||||
.ReadPayments(startDate, endDate, clientId)
|
||||
.Select(x => new {x.ClientName, x.Date, CountOfStop = (int?)null, Payment = (int?)x.Sum }))
|
||||
.OrderBy(x => x.Date);
|
||||
return
|
||||
new List<string[]>() { item }
|
||||
.Union(
|
||||
data
|
||||
.Select(x => new string[] { x.ClientName, x.Date.ToString("dd.MM.yyyy"), x.CountOfStop?.ToString() ?? string.Empty, x.Payment?.ToString() ?? string.Empty }))
|
||||
.Union(
|
||||
[["Всего ", "", data.Sum(x => x.CountOfStop ?? 0).ToString(), data.Sum(x => x.Payment ?? 0).ToString()]])
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
94
Travel_Agency/Travel_Agency/Reports/WordBuilder.cs
Normal file
94
Travel_Agency/Travel_Agency/Reports/WordBuilder.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
|
||||
namespace Travel_Agency.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());
|
||||
// TODO прописать настройки под жирный текст
|
||||
run.PrependChild(new RunProperties());
|
||||
run.RunProperties.AddChild(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;
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace Travel_Agency.Repositories;
|
||||
|
||||
public interface IContractRepository
|
||||
{
|
||||
IEnumerable<Contract> ReadContracts(DateTime? dateFrom = null, DateTime? dateTo = null, int? clientId = null);
|
||||
IEnumerable<Contract> ReadContracts(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null);
|
||||
void DeleteContract(int id);
|
||||
void CreateContract(Contract contract);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ namespace Travel_Agency.Repositories;
|
||||
|
||||
public interface IPaymentRepository
|
||||
{
|
||||
IEnumerable<Payment> ReadPayments(DateTime? dateFrom = null, DateTime? dateTo = null, int? clientId = null);
|
||||
IEnumerable<Payment> ReadPayments(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null);
|
||||
void CreatePayment(Payment payment);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using Travel_Agency.Entities;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Travel_Agency.Repositories.Implementations;
|
||||
|
||||
@@ -30,17 +33,16 @@ public class ContractRepository : IContractRepository
|
||||
VALUES (@ContractNumber, @Discount,
|
||||
@TouristNumber, @FinalPrice, @ClientId, @Date);
|
||||
SELECT MAX(Id) FROM CONTRACT";
|
||||
var contractId = connection.QueryFirst<int>(queryInsert, contract, transaction);
|
||||
var querySubInsert = @"INSERT INTO CONTRACT_TOUR (ContractId, TourId, StartDate, EndDate)
|
||||
VALUES (@ContractId, @TourId, @StartDate, @EndDate)";
|
||||
var Id = connection.QueryFirst<int>(queryInsert, contract, transaction);
|
||||
var querySubInsert = @"INSERT INTO CONTRACT_TOUR (Id, TourId, CountOfStop)
|
||||
VALUES (@Id, @TourId, @CountOfStop)";
|
||||
foreach (var elem in contract.Tours)
|
||||
{
|
||||
connection.Execute(querySubInsert, new
|
||||
{
|
||||
contractId,
|
||||
Id,
|
||||
elem.TourId,
|
||||
elem.StartDate,
|
||||
elem.EndDate
|
||||
elem.CountOfStop
|
||||
}, transaction);
|
||||
}
|
||||
transaction.Commit();
|
||||
@@ -72,17 +74,56 @@ public class ContractRepository : IContractRepository
|
||||
|
||||
}
|
||||
|
||||
public IEnumerable<Contract> ReadContracts(DateTime? dateFrom = null, DateTime? dateTo = null, int? clientId = null)
|
||||
public IEnumerable<Contract> ReadContracts(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
var builder = new QueryBuilder();
|
||||
if (dateForm.HasValue)
|
||||
{
|
||||
builder.AddCondition("con.Date >= @dateForm");
|
||||
}
|
||||
if (dateTo.HasValue)
|
||||
{
|
||||
builder.AddCondition("con.Date <= @dateTo");
|
||||
}
|
||||
if (clientId.HasValue)
|
||||
{
|
||||
builder.AddCondition("con.ClientId = @clientId");
|
||||
}
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM CONTRACT";
|
||||
var contracts = connection.Query<Contract>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(contracts));
|
||||
return contracts;
|
||||
|
||||
var querySelect = @$"SELECT con.*, cl.Name as ClientName,
|
||||
ct.TourId, ct.CountOfStop, t.Name as TourName
|
||||
FROM CONTRACT con
|
||||
INNER JOIN CONTRACT_TOUR ct ON ct.Id = con.Id
|
||||
INNER JOIN CLIENT cl ON con.ClientId = cl.Id
|
||||
INNER JOIN TOUR t ON t.Id = ct.TourId
|
||||
{builder.Build()}";
|
||||
|
||||
var contractDict = new Dictionary<int, List<Contract_Tour>>();
|
||||
|
||||
var contracts = connection.Query<Contract, Contract_Tour, Contract>(querySelect,
|
||||
(contract, contract_Tour) =>
|
||||
{
|
||||
if (!contractDict.TryGetValue(contract.Id, out var tr))
|
||||
{
|
||||
tr = [];
|
||||
contractDict.Add(contract.Id, tr);
|
||||
}
|
||||
|
||||
tr.Add(contract_Tour);
|
||||
return contract;
|
||||
}, splitOn: "TourId", param: new { dateForm, dateTo, clientId});
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(contracts));
|
||||
|
||||
return contractDict.Select(x =>
|
||||
{
|
||||
var tr = contracts.First(y => y.Id == x.Key);
|
||||
tr.SetContract_Tours(x.Value);
|
||||
return tr;
|
||||
}).ToArray();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -34,14 +34,31 @@ public class PaymentRepository : IPaymentRepository
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Payment> ReadPayments(DateTime? dateFrom = null, DateTime? dateTo = null, int? clientId = null)
|
||||
public IEnumerable<Payment> ReadPayments(DateTime? dateForm = null, DateTime? dateTo = null, int? clientId = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
var builder = new QueryBuilder();
|
||||
if (dateForm.HasValue)
|
||||
{
|
||||
builder.AddCondition("pm.Date >= @dateForm");
|
||||
}
|
||||
if (dateTo.HasValue)
|
||||
{
|
||||
builder.AddCondition("pm.Date <= @dateTo");
|
||||
}
|
||||
if (clientId.HasValue)
|
||||
{
|
||||
builder.AddCondition("pm.ClientId = @clientId");
|
||||
}
|
||||
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM PAYMENT";
|
||||
var payments = connection.Query<Payment>(querySelect);
|
||||
var querySelect = @$"SELECT pm.*, cl.Name as ClientName
|
||||
FROM PAYMENT pm
|
||||
INNER JOIN CLIENT cl ON pm.ClientId = cl.id
|
||||
{builder.Build()}";
|
||||
var payments = connection.Query<Payment>(querySelect, new { dateForm, dateTo, clientId });
|
||||
_logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(payments));
|
||||
return payments;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace Travel_Agency.Repositories.Implementations;
|
||||
|
||||
public class QueryBuilder
|
||||
{
|
||||
private readonly StringBuilder _builder;
|
||||
public QueryBuilder()
|
||||
{
|
||||
_builder = new();
|
||||
}
|
||||
public QueryBuilder AddCondition(string condition)
|
||||
{
|
||||
if (_builder.Length > 0)
|
||||
{
|
||||
_builder.Append(" AND ");
|
||||
}
|
||||
_builder.Append(condition);
|
||||
return this;
|
||||
}
|
||||
public string Build()
|
||||
{
|
||||
if (_builder.Length == 0)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
return $"WHERE {_builder}";
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,9 @@ public class RouteRepository : IRouteRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM ROUTE";
|
||||
var querySelect = @"SELECT rt.*, tr.Name as TourName
|
||||
FROM ROUTE rt
|
||||
INNER JOIN TOUR tr ON rt.TourId = tr.id";
|
||||
var routes = connection.Query<Route>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(routes));
|
||||
|
||||
@@ -11,11 +11,12 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" 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="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
|
||||
<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.1.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
|
||||
Reference in New Issue
Block a user