готово
This commit is contained in:
parent
d025f0b025
commit
cd35229525
@ -19,7 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TravelCompanyDatabaseImplem
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TravelCompanyClientApp", "TravelCompanyClientApp\TravelCompanyClientApp.csproj", "{F1E802C4-EE5D-4508-B42F-3ACB70621013}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TravelCompanyClientApp", "TravelCompanyClientApp\TravelCompanyClientApp.csproj", "{F1E802C4-EE5D-4508-B42F-3ACB70621013}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TravelCompanyRestApi", "TravelCompanyRestApi\TravelCompanyRestApi.csproj", "{E24D011F-7289-4DBA-9C90-D49713C4E495}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TravelCompanyRestApi", "TravelCompanyRestApi\TravelCompanyRestApi.csproj", "{E24D011F-7289-4DBA-9C90-D49713C4E495}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TravelCompanyShopApp", "TravelCompanyShopApp\TravelCompanyShopApp.csproj", "{1F906886-7F67-47F4-9BBB-EC070796B3B1}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -63,6 +65,10 @@ Global
|
|||||||
{E24D011F-7289-4DBA-9C90-D49713C4E495}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E24D011F-7289-4DBA-9C90-D49713C4E495}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E24D011F-7289-4DBA-9C90-D49713C4E495}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E24D011F-7289-4DBA-9C90-D49713C4E495}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E24D011F-7289-4DBA-9C90-D49713C4E495}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E24D011F-7289-4DBA-9C90-D49713C4E495}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{1F906886-7F67-47F4-9BBB-EC070796B3B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{1F906886-7F67-47F4-9BBB-EC070796B3B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{1F906886-7F67-47F4-9BBB-EC070796B3B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{1F906886-7F67-47F4-9BBB-EC070796B3B1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
143
TravelCompany/TravelCompany/FormCreateSupply.Designer.cs
generated
Normal file
143
TravelCompany/TravelCompany/FormCreateSupply.Designer.cs
generated
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
partial class FormCreateSupply
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelShop = new System.Windows.Forms.Label();
|
||||||
|
this.labelTravel = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxTravel = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBoxShop
|
||||||
|
//
|
||||||
|
this.comboBoxShop.FormattingEnabled = true;
|
||||||
|
this.comboBoxShop.Location = new System.Drawing.Point(115, 12);
|
||||||
|
this.comboBoxShop.Name = "comboBoxShop";
|
||||||
|
this.comboBoxShop.Size = new System.Drawing.Size(344, 28);
|
||||||
|
this.comboBoxShop.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// labelShop
|
||||||
|
//
|
||||||
|
this.labelShop.AutoSize = true;
|
||||||
|
this.labelShop.Location = new System.Drawing.Point(12, 15);
|
||||||
|
this.labelShop.Name = "labelShop";
|
||||||
|
this.labelShop.Size = new System.Drawing.Size(76, 20);
|
||||||
|
this.labelShop.TabIndex = 1;
|
||||||
|
this.labelShop.Text = "Магазин: ";
|
||||||
|
//
|
||||||
|
// labelTravel
|
||||||
|
//
|
||||||
|
this.labelTravel.AutoSize = true;
|
||||||
|
this.labelTravel.Location = new System.Drawing.Point(12, 49);
|
||||||
|
this.labelTravel.Name = "labelTravel";
|
||||||
|
this.labelTravel.Size = new System.Drawing.Size(75, 20);
|
||||||
|
this.labelTravel.TabIndex = 2;
|
||||||
|
this.labelTravel.Text = "Изделие: ";
|
||||||
|
//
|
||||||
|
// comboBoxTravel
|
||||||
|
//
|
||||||
|
this.comboBoxTravel.FormattingEnabled = true;
|
||||||
|
this.comboBoxTravel.Location = new System.Drawing.Point(115, 46);
|
||||||
|
this.comboBoxTravel.Name = "comboBoxTravel";
|
||||||
|
this.comboBoxTravel.Size = new System.Drawing.Size(344, 28);
|
||||||
|
this.comboBoxTravel.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
this.labelCount.AutoSize = true;
|
||||||
|
this.labelCount.Location = new System.Drawing.Point(12, 83);
|
||||||
|
this.labelCount.Name = "labelCount";
|
||||||
|
this.labelCount.Size = new System.Drawing.Size(97, 20);
|
||||||
|
this.labelCount.TabIndex = 4;
|
||||||
|
this.labelCount.Text = "Количество: ";
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(115, 80);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(344, 27);
|
||||||
|
this.textBoxCount.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(300, 113);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(116, 39);
|
||||||
|
this.buttonCancel.TabIndex = 6;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(168, 113);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(116, 39);
|
||||||
|
this.buttonSave.TabIndex = 7;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// FormCreateSupply
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(471, 164);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.labelCount);
|
||||||
|
this.Controls.Add(this.comboBoxTravel);
|
||||||
|
this.Controls.Add(this.labelTravel);
|
||||||
|
this.Controls.Add(this.labelShop);
|
||||||
|
this.Controls.Add(this.comboBoxShop);
|
||||||
|
this.Name = "FormCreateSupply";
|
||||||
|
this.Text = "Создание поставки";
|
||||||
|
this.Load += new System.EventHandler(this.FormCreateSupply_Load);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox comboBoxShop;
|
||||||
|
private Label labelShop;
|
||||||
|
private Label labelTravel;
|
||||||
|
private ComboBox comboBoxTravel;
|
||||||
|
private Label labelCount;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
}
|
||||||
|
}
|
99
TravelCompany/TravelCompany/FormCreateSupply.cs
Normal file
99
TravelCompany/TravelCompany/FormCreateSupply.cs
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.BusinessLogicsContracts;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
public partial class FormCreateSupply : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ITravelLogic _logicP;
|
||||||
|
private readonly IShopLogic _logicS;
|
||||||
|
private List<ShopViewModel> _shopList = new List<ShopViewModel>();
|
||||||
|
private List<TravelViewModel> _TravelList = new List<TravelViewModel>();
|
||||||
|
|
||||||
|
public FormCreateSupply(ILogger<FormCreateSupply> logger, ITravelLogic logicP, IShopLogic logicS)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logicP = logicP;
|
||||||
|
_logicS = logicS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCreateSupply_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_shopList = _logicS.ReadList(null);
|
||||||
|
_TravelList = _logicP.ReadList(null);
|
||||||
|
if (_shopList != null)
|
||||||
|
{
|
||||||
|
comboBoxShop.DisplayMember = "ShopName";
|
||||||
|
comboBoxShop.ValueMember = "Id";
|
||||||
|
comboBoxShop.DataSource = _shopList;
|
||||||
|
comboBoxShop.SelectedItem = null;
|
||||||
|
_logger.LogInformation("Загрузка магазинов для поставок");
|
||||||
|
}
|
||||||
|
if (_TravelList != null)
|
||||||
|
{
|
||||||
|
comboBoxTravel.DisplayMember = "TravelName";
|
||||||
|
comboBoxTravel.ValueMember = "Id";
|
||||||
|
comboBoxTravel.DataSource = _TravelList;
|
||||||
|
comboBoxTravel.SelectedItem = null;
|
||||||
|
_logger.LogInformation("Загрузка путёвок для поставок");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxShop.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxTravel.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Создание поставки");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var operationResult = _logicS.MakeSupply(new SupplyBindingModel
|
||||||
|
{
|
||||||
|
ShopId = Convert.ToInt32(comboBoxShop.SelectedValue),
|
||||||
|
TravelId = Convert.ToInt32(comboBoxTravel.SelectedValue),
|
||||||
|
Count = Convert.ToInt32(textBoxCount.Text)
|
||||||
|
});
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания поставки");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
TravelCompany/TravelCompany/FormCreateSupply.resx
Normal file
120
TravelCompany/TravelCompany/FormCreateSupply.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>
|
174
TravelCompany/TravelCompany/FormMain.Designer.cs
generated
174
TravelCompany/TravelCompany/FormMain.Designer.cs
generated
@ -33,17 +33,27 @@
|
|||||||
toolStripDropDownButton1 = new ToolStripDropDownButton();
|
toolStripDropDownButton1 = new ToolStripDropDownButton();
|
||||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
ПутёвкиToolStripMenuItem = new ToolStripMenuItem();
|
ПутёвкиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
списокКомпонентовToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
компонентыПоПутёвкамToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
buttonTakeOrderInWork = new Button();
|
buttonTakeOrderInWork = new Button();
|
||||||
buttonOrderReady = new Button();
|
buttonOrderReady = new Button();
|
||||||
buttonIssuedOrder = new Button();
|
buttonIssuedOrder = new Button();
|
||||||
buttonRef = new Button();
|
buttonRef = new Button();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
изделияToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
списокИзделийToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
пиццаСИнгридиентамиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
магазинToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
информацияToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
загруженностьToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
заказыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
заказыToolStripMenuItem1 = new ToolStripMenuItem();
|
||||||
|
заказыПоГруппамToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
operationToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
transactionToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
продажаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
toolStrip1.SuspendLayout();
|
toolStrip1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -51,7 +61,7 @@
|
|||||||
// toolStrip1
|
// toolStrip1
|
||||||
//
|
//
|
||||||
toolStrip1.ImageScalingSize = new Size(20, 20);
|
toolStrip1.ImageScalingSize = new Size(20, 20);
|
||||||
toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, отчетыToolStripMenuItem });
|
toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, operationToolStripMenuItem, отчётыToolStripMenuItem });
|
||||||
toolStrip1.Location = new Point(0, 0);
|
toolStrip1.Location = new Point(0, 0);
|
||||||
toolStrip1.Name = "toolStrip1";
|
toolStrip1.Name = "toolStrip1";
|
||||||
toolStrip1.Size = new Size(969, 25);
|
toolStrip1.Size = new Size(969, 25);
|
||||||
@ -61,7 +71,7 @@
|
|||||||
// toolStripDropDownButton1
|
// toolStripDropDownButton1
|
||||||
//
|
//
|
||||||
toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text;
|
toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text;
|
||||||
toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, ПутёвкиToolStripMenuItem, клиентыToolStripMenuItem });
|
toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, ПутёвкиToolStripMenuItem, клиентыToolStripMenuItem, магазиныToolStripMenuItem });
|
||||||
toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image");
|
toolStripDropDownButton1.Image = (Image)resources.GetObject("toolStripDropDownButton1.Image");
|
||||||
toolStripDropDownButton1.ImageTransparentColor = Color.Magenta;
|
toolStripDropDownButton1.ImageTransparentColor = Color.Magenta;
|
||||||
toolStripDropDownButton1.Name = "toolStripDropDownButton1";
|
toolStripDropDownButton1.Name = "toolStripDropDownButton1";
|
||||||
@ -82,33 +92,12 @@
|
|||||||
ПутёвкиToolStripMenuItem.Text = "Туристич. путёвки";
|
ПутёвкиToolStripMenuItem.Text = "Туристич. путёвки";
|
||||||
ПутёвкиToolStripMenuItem.Click += консервыToolStripMenuItem_Click;
|
ПутёвкиToolStripMenuItem.Click += консервыToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// отчетыToolStripMenuItem
|
// клиентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоПутёвкамToolStripMenuItem, списокЗаказовToolStripMenuItem });
|
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
клиентыToolStripMenuItem.Size = new Size(180, 22);
|
||||||
отчетыToolStripMenuItem.Size = new Size(60, 25);
|
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
||||||
//
|
|
||||||
// списокКомпонентовToolStripMenuItem
|
|
||||||
//
|
|
||||||
списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem";
|
|
||||||
списокКомпонентовToolStripMenuItem.Size = new Size(216, 22);
|
|
||||||
списокКомпонентовToolStripMenuItem.Text = "Список компонентов";
|
|
||||||
списокКомпонентовToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// компонентыПоПутёвкамToolStripMenuItem
|
|
||||||
//
|
|
||||||
компонентыПоПутёвкамToolStripMenuItem.Name = "компонентыПоПутёвкамToolStripMenuItem";
|
|
||||||
компонентыПоПутёвкамToolStripMenuItem.Size = new Size(216, 22);
|
|
||||||
компонентыПоПутёвкамToolStripMenuItem.Text = "Компоненты по путёвкам";
|
|
||||||
компонентыПоПутёвкамToolStripMenuItem.Click += компонентыПоПутёвкамToolStripMenuItem_Click;
|
|
||||||
//
|
|
||||||
// списокЗаказовToolStripMenuItem
|
|
||||||
//
|
|
||||||
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
|
||||||
списокЗаказовToolStripMenuItem.Size = new Size(216, 22);
|
|
||||||
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
|
||||||
списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click;
|
|
||||||
//
|
//
|
||||||
// buttonCreateOrder
|
// buttonCreateOrder
|
||||||
//
|
//
|
||||||
@ -172,12 +161,103 @@
|
|||||||
dataGridView.Size = new Size(763, 435);
|
dataGridView.Size = new Size(763, 435);
|
||||||
dataGridView.TabIndex = 6;
|
dataGridView.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// клиентыToolStripMenuItem
|
// магазиныToolStripMenuItem
|
||||||
//
|
//
|
||||||
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||||
клиентыToolStripMenuItem.Size = new Size(180, 22);
|
магазиныToolStripMenuItem.Size = new Size(180, 22);
|
||||||
клиентыToolStripMenuItem.Text = "Клиенты";
|
магазиныToolStripMenuItem.Text = "Магазины";
|
||||||
клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click;
|
магазиныToolStripMenuItem.Click += shopsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// отчётыToolStripMenuItem
|
||||||
|
//
|
||||||
|
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { изделияToolStripMenuItem, магазинToolStripMenuItem, заказыToolStripMenuItem });
|
||||||
|
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||||
|
отчётыToolStripMenuItem.Size = new Size(60, 25);
|
||||||
|
отчётыToolStripMenuItem.Text = "Отчёты";
|
||||||
|
//
|
||||||
|
// изделияToolStripMenuItem
|
||||||
|
//
|
||||||
|
изделияToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокИзделийToolStripMenuItem, пиццаСИнгридиентамиToolStripMenuItem });
|
||||||
|
изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
|
||||||
|
изделияToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
изделияToolStripMenuItem.Text = "Путевки";
|
||||||
|
//
|
||||||
|
// списокИзделийToolStripMenuItem
|
||||||
|
//
|
||||||
|
списокИзделийToolStripMenuItem.Name = "списокИзделийToolStripMenuItem";
|
||||||
|
списокИзделийToolStripMenuItem.Size = new Size(213, 22);
|
||||||
|
списокИзделийToolStripMenuItem.Text = "Список путевок";
|
||||||
|
списокИзделийToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// пиццаСИнгридиентамиToolStripMenuItem
|
||||||
|
//
|
||||||
|
пиццаСИнгридиентамиToolStripMenuItem.Name = "пиццаСИнгридиентамиToolStripMenuItem";
|
||||||
|
пиццаСИнгридиентамиToolStripMenuItem.Size = new Size(213, 22);
|
||||||
|
пиццаСИнгридиентамиToolStripMenuItem.Text = "Путевка с компонентами";
|
||||||
|
пиццаСИнгридиентамиToolStripMenuItem.Click += ComponentTravelToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// магазинToolStripMenuItem
|
||||||
|
//
|
||||||
|
магазинToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { информацияToolStripMenuItem, загруженностьToolStripMenuItem });
|
||||||
|
магазинToolStripMenuItem.Name = "магазинToolStripMenuItem";
|
||||||
|
магазинToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
магазинToolStripMenuItem.Text = "Магазин";
|
||||||
|
//
|
||||||
|
// информацияToolStripMenuItem
|
||||||
|
//
|
||||||
|
информацияToolStripMenuItem.Name = "информацияToolStripMenuItem";
|
||||||
|
информацияToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
информацияToolStripMenuItem.Text = "Информация";
|
||||||
|
информацияToolStripMenuItem.Click += InfoToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// загруженностьToolStripMenuItem
|
||||||
|
//
|
||||||
|
загруженностьToolStripMenuItem.Name = "загруженностьToolStripMenuItem";
|
||||||
|
загруженностьToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
загруженностьToolStripMenuItem.Text = "Загруженность";
|
||||||
|
загруженностьToolStripMenuItem.Click += BusyShopsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// заказыToolStripMenuItem
|
||||||
|
//
|
||||||
|
заказыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказыToolStripMenuItem1, заказыПоГруппамToolStripMenuItem });
|
||||||
|
заказыToolStripMenuItem.Name = "заказыToolStripMenuItem";
|
||||||
|
заказыToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
заказыToolStripMenuItem.Text = "Заказы";
|
||||||
|
//
|
||||||
|
// заказыToolStripMenuItem1
|
||||||
|
//
|
||||||
|
заказыToolStripMenuItem1.Name = "заказыToolStripMenuItem1";
|
||||||
|
заказыToolStripMenuItem1.Size = new Size(180, 22);
|
||||||
|
заказыToolStripMenuItem1.Text = "Заказы";
|
||||||
|
заказыToolStripMenuItem1.Click += OrdersToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// заказыПоГруппамToolStripMenuItem
|
||||||
|
//
|
||||||
|
заказыПоГруппамToolStripMenuItem.Name = "заказыПоГруппамToolStripMenuItem";
|
||||||
|
заказыПоГруппамToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
заказыПоГруппамToolStripMenuItem.Text = "Заказы по группам";
|
||||||
|
заказыПоГруппамToolStripMenuItem.Click += GroupOrdersToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// operationToolStripMenuItem
|
||||||
|
//
|
||||||
|
operationToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { transactionToolStripMenuItem, продажаToolStripMenuItem });
|
||||||
|
operationToolStripMenuItem.Name = "operationToolStripMenuItem";
|
||||||
|
operationToolStripMenuItem.Size = new Size(75, 25);
|
||||||
|
operationToolStripMenuItem.Text = "Операции";
|
||||||
|
//
|
||||||
|
// transactionToolStripMenuItem
|
||||||
|
//
|
||||||
|
transactionToolStripMenuItem.Name = "transactionToolStripMenuItem";
|
||||||
|
transactionToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
transactionToolStripMenuItem.Text = "Поставка";
|
||||||
|
transactionToolStripMenuItem.Click += transactionToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// продажаToolStripMenuItem
|
||||||
|
//
|
||||||
|
продажаToolStripMenuItem.Name = "продажаToolStripMenuItem";
|
||||||
|
продажаToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
продажаToolStripMenuItem.Text = "Продажа";
|
||||||
|
продажаToolStripMenuItem.Click += SellToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
@ -213,10 +293,20 @@
|
|||||||
private ToolStripDropDownButton toolStripDropDownButton1;
|
private ToolStripDropDownButton toolStripDropDownButton1;
|
||||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||||
private ToolStripMenuItem ПутёвкиToolStripMenuItem;
|
private ToolStripMenuItem ПутёвкиToolStripMenuItem;
|
||||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem списокКомпонентовToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem компонентыПоПутёвкамToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem клиентыToolStripMenuItem;
|
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem operationToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem transactionToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem продажаToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem изделияToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem списокИзделийToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem пиццаСИнгридиентамиToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem магазинToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem информацияToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem загруженностьToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem заказыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem заказыToolStripMenuItem1;
|
||||||
|
private ToolStripMenuItem заказыПоГруппамToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -198,5 +198,89 @@ Program.ServiceProvider?.GetService(typeof(FormClients));
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void shopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||||
|
if (service is FormShops form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void transactionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateSupply));
|
||||||
|
if (service is FormCreateSupply form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SellToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSellTravels));
|
||||||
|
if (service is FormSellTravels form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_reportLogic.SaveTravelsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ComponentTravelToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportTravelComponents));
|
||||||
|
if (service is FormReportTravelComponents form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InfoToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
_reportLogic.SaveShopsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void BusyShopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportShop));
|
||||||
|
if (service is FormReportShop form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||||
|
if (service is FormReportOrders form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GroupOrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupedOrders));
|
||||||
|
if (service is FormReportGroupedOrders form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
86
TravelCompany/TravelCompany/FormReportGroupedOrders.Designer.cs
generated
Normal file
86
TravelCompany/TravelCompany/FormReportGroupedOrders.Designer.cs
generated
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
partial class FormReportGroupedOrders
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
this.panel = new System.Windows.Forms.Panel();
|
||||||
|
this.buttonToPDF = new System.Windows.Forms.Button();
|
||||||
|
this.buttonMake = new System.Windows.Forms.Button();
|
||||||
|
this.panel.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel
|
||||||
|
//
|
||||||
|
this.panel.Controls.Add(this.buttonToPDF);
|
||||||
|
this.panel.Controls.Add(this.buttonMake);
|
||||||
|
this.panel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.panel.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.panel.Name = "panel";
|
||||||
|
this.panel.Size = new System.Drawing.Size(970, 52);
|
||||||
|
this.panel.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonToPDF
|
||||||
|
//
|
||||||
|
this.buttonToPDF.Location = new System.Drawing.Point(486, 12);
|
||||||
|
this.buttonToPDF.Name = "buttonToPDF";
|
||||||
|
this.buttonToPDF.Size = new System.Drawing.Size(411, 29);
|
||||||
|
this.buttonToPDF.TabIndex = 5;
|
||||||
|
this.buttonToPDF.Text = "В PDF";
|
||||||
|
this.buttonToPDF.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonToPDF.Click += new System.EventHandler(this.buttonToPDF_Click);
|
||||||
|
//
|
||||||
|
// buttonMake
|
||||||
|
//
|
||||||
|
this.buttonMake.Location = new System.Drawing.Point(49, 12);
|
||||||
|
this.buttonMake.Name = "buttonMake";
|
||||||
|
this.buttonMake.Size = new System.Drawing.Size(377, 29);
|
||||||
|
this.buttonMake.TabIndex = 4;
|
||||||
|
this.buttonMake.Text = "Сформировать";
|
||||||
|
this.buttonMake.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click);
|
||||||
|
//
|
||||||
|
// FormReportGroupedOrders
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(970, 450);
|
||||||
|
this.Controls.Add(this.panel);
|
||||||
|
this.Name = "FormReportGroupedOrders";
|
||||||
|
this.Text = "Отчёт по группированным заказам ";
|
||||||
|
this.panel.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel;
|
||||||
|
private Button buttonToPDF;
|
||||||
|
private Button buttonMake;
|
||||||
|
}
|
||||||
|
}
|
80
TravelCompany/TravelCompany/FormReportGroupedOrders.cs
Normal file
80
TravelCompany/TravelCompany/FormReportGroupedOrders.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Reporting.WinForms;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.BusinessLogicsContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
public partial class FormReportGroupedOrders : Form
|
||||||
|
{
|
||||||
|
private readonly ReportViewer reportViewer;
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IReportLogic _logic;
|
||||||
|
|
||||||
|
public FormReportGroupedOrders(ILogger<FormReportGroupedOrders> logger, IReportLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
reportViewer = new ReportViewer
|
||||||
|
{
|
||||||
|
Dock = DockStyle.Fill
|
||||||
|
};
|
||||||
|
reportViewer.LocalReport.LoadReportDefinition(new FileStream("C:\\Users\\goldfest\\Desktop\\RPP\\TravelCompany\\TravelCompany\\ReportGroupedOrders.rdlc", FileMode.Open));
|
||||||
|
Controls.Clear();
|
||||||
|
Controls.Add(reportViewer);
|
||||||
|
Controls.Add(panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonMake_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dataSource = _logic.GetGroupedOrders();
|
||||||
|
var source = new ReportDataSource("DataSetGroupedOrders", dataSource);
|
||||||
|
reportViewer.LocalReport.DataSources.Clear();
|
||||||
|
reportViewer.LocalReport.DataSources.Add(source);
|
||||||
|
|
||||||
|
reportViewer.RefreshReport();
|
||||||
|
_logger.LogInformation("Загрузка списка группированных заказов");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка группированных заказов на период");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void buttonToPDF_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.SaveGroupedOrdersToPdfFile(new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = dialog.FileName,
|
||||||
|
});
|
||||||
|
_logger.LogInformation("Сохранение списка группированных заказов");
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения списка группированных заказов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
TravelCompany/TravelCompany/FormReportGroupedOrders.resx
Normal file
120
TravelCompany/TravelCompany/FormReportGroupedOrders.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>
|
115
TravelCompany/TravelCompany/FormReportShop.Designer.cs
generated
Normal file
115
TravelCompany/TravelCompany/FormReportShop.Designer.cs
generated
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
partial class FormReportShop
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
buttonSaveToExcel = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
ColumnShop = new DataGridViewTextBoxColumn();
|
||||||
|
ColumnTravel = new DataGridViewTextBoxColumn();
|
||||||
|
ColumnCount = new DataGridViewTextBoxColumn();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonSaveToExcel
|
||||||
|
//
|
||||||
|
buttonSaveToExcel.Location = new Point(0, 4);
|
||||||
|
buttonSaveToExcel.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
buttonSaveToExcel.Name = "buttonSaveToExcel";
|
||||||
|
buttonSaveToExcel.Size = new Size(195, 22);
|
||||||
|
buttonSaveToExcel.TabIndex = 3;
|
||||||
|
buttonSaveToExcel.Text = "Сохранить в Excel";
|
||||||
|
buttonSaveToExcel.UseVisualStyleBackColor = true;
|
||||||
|
buttonSaveToExcel.Click += ButtonSaveToExcel_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.AllowUserToOrderColumns = true;
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnShop, ColumnTravel, ColumnCount });
|
||||||
|
dataGridView.Dock = DockStyle.Bottom;
|
||||||
|
dataGridView.Location = new Point(0, 36);
|
||||||
|
dataGridView.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.RowTemplate.Height = 29;
|
||||||
|
dataGridView.Size = new Size(523, 302);
|
||||||
|
dataGridView.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// ColumnShop
|
||||||
|
//
|
||||||
|
ColumnShop.FillWeight = 130F;
|
||||||
|
ColumnShop.HeaderText = "Магазин";
|
||||||
|
ColumnShop.MinimumWidth = 6;
|
||||||
|
ColumnShop.Name = "ColumnShop";
|
||||||
|
ColumnShop.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnTravel
|
||||||
|
//
|
||||||
|
ColumnTravel.FillWeight = 140F;
|
||||||
|
ColumnTravel.HeaderText = "Путевка";
|
||||||
|
ColumnTravel.MinimumWidth = 6;
|
||||||
|
ColumnTravel.Name = "ColumnTravel";
|
||||||
|
ColumnTravel.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnCount
|
||||||
|
//
|
||||||
|
ColumnCount.FillWeight = 90F;
|
||||||
|
ColumnCount.HeaderText = "Количество";
|
||||||
|
ColumnCount.MinimumWidth = 6;
|
||||||
|
ColumnCount.Name = "ColumnCount";
|
||||||
|
ColumnCount.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// FormReportShop
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(523, 338);
|
||||||
|
Controls.Add(buttonSaveToExcel);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
|
Name = "FormReportShop";
|
||||||
|
Text = "Наполненость магазинов";
|
||||||
|
Load += FormReportShop_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonSaveToExcel;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private DataGridViewTextBoxColumn ColumnShop;
|
||||||
|
private DataGridViewTextBoxColumn ColumnTravel;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
|
}
|
||||||
|
}
|
78
TravelCompany/TravelCompany/FormReportShop.cs
Normal file
78
TravelCompany/TravelCompany/FormReportShop.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.BusinessLogicsContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
public partial class FormReportShop : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IReportLogic _logic;
|
||||||
|
|
||||||
|
public FormReportShop(ILogger<FormReportShop> logger, IReportLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormReportShop_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var dict = _logic.GetShops();
|
||||||
|
if (dict != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var elem in dict)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" });
|
||||||
|
foreach (var listElem in elem.Travels)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||||
|
}
|
||||||
|
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
|
||||||
|
dataGridView.Rows.Add(Array.Empty<object>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка списка путевок по магазинам");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки списка путевок по магазинам");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logic.SaveShopsToExcelFile(new ReportBindingModel
|
||||||
|
{
|
||||||
|
FileName = dialog.FileName
|
||||||
|
});
|
||||||
|
_logger.LogInformation("Сохранение списка путевок по магазинам");
|
||||||
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения списка путевок по магазинам");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
TravelCompany/TravelCompany/FormReportShop.resx
Normal file
120
TravelCompany/TravelCompany/FormReportShop.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>
|
124
TravelCompany/TravelCompany/FormSellTravels.Designer.cs
generated
Normal file
124
TravelCompany/TravelCompany/FormSellTravels.Designer.cs
generated
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
partial class FormSellTravels
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
labelTravel = new Label();
|
||||||
|
comboBoxTravel = new ComboBox();
|
||||||
|
labelCount = new Label();
|
||||||
|
textBoxCount = new TextBox();
|
||||||
|
buttonSell = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelTravel
|
||||||
|
//
|
||||||
|
labelTravel.AutoSize = true;
|
||||||
|
labelTravel.Location = new Point(10, 10);
|
||||||
|
labelTravel.Name = "labelTravel";
|
||||||
|
labelTravel.Size = new Size(57, 15);
|
||||||
|
labelTravel.TabIndex = 0;
|
||||||
|
labelTravel.Text = "Путёвка: ";
|
||||||
|
//
|
||||||
|
// comboBoxTravel
|
||||||
|
//
|
||||||
|
comboBoxTravel.FormattingEnabled = true;
|
||||||
|
comboBoxTravel.Location = new Point(101, 8);
|
||||||
|
comboBoxTravel.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
comboBoxTravel.Name = "comboBoxTravel";
|
||||||
|
comboBoxTravel.Size = new Size(210, 23);
|
||||||
|
comboBoxTravel.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
labelCount.AutoSize = true;
|
||||||
|
labelCount.Location = new Point(10, 41);
|
||||||
|
labelCount.Name = "labelCount";
|
||||||
|
labelCount.Size = new Size(78, 15);
|
||||||
|
labelCount.TabIndex = 2;
|
||||||
|
labelCount.Text = "Количество: ";
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
textBoxCount.Location = new Point(101, 39);
|
||||||
|
textBoxCount.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
textBoxCount.Name = "textBoxCount";
|
||||||
|
textBoxCount.Size = new Size(210, 23);
|
||||||
|
textBoxCount.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonSell
|
||||||
|
//
|
||||||
|
buttonSell.Location = new Point(112, 74);
|
||||||
|
buttonSell.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
buttonSell.Name = "buttonSell";
|
||||||
|
buttonSell.Size = new Size(82, 22);
|
||||||
|
buttonSell.TabIndex = 4;
|
||||||
|
buttonSell.Text = "Продать";
|
||||||
|
buttonSell.UseVisualStyleBackColor = true;
|
||||||
|
buttonSell.Click += ButtonSell_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(212, 74);
|
||||||
|
buttonCancel.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(82, 22);
|
||||||
|
buttonCancel.TabIndex = 5;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// FormSellTravels
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(320, 105);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSell);
|
||||||
|
Controls.Add(textBoxCount);
|
||||||
|
Controls.Add(labelCount);
|
||||||
|
Controls.Add(comboBoxTravel);
|
||||||
|
Controls.Add(labelTravel);
|
||||||
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
|
Name = "FormSellTravels";
|
||||||
|
Text = "Продажа путёвок";
|
||||||
|
Load += FormSellingTravel_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelTravel;
|
||||||
|
private ComboBox comboBoxTravel;
|
||||||
|
private Label labelCount;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private Button buttonSell;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
88
TravelCompany/TravelCompany/FormSellTravels.cs
Normal file
88
TravelCompany/TravelCompany/FormSellTravels.cs
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using TravelCompanyContracts.BusinessLogicsContracts;
|
||||||
|
using TravelCompanyContracts.SearchModels;
|
||||||
|
using TravelCompanyContracts.StoragesContracts;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
public partial class FormSellTravels : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly ITravelLogic _logicP;
|
||||||
|
private readonly IShopLogic _logicS;
|
||||||
|
private List<TravelViewModel> _TravelList = new List<TravelViewModel>();
|
||||||
|
|
||||||
|
public FormSellTravels(ILogger<FormSellTravels> logger, ITravelLogic logicP, IShopLogic logicS)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logicP = logicP;
|
||||||
|
_logicS = logicS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormSellingTravel_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_TravelList = _logicP.ReadList(null);
|
||||||
|
if (_TravelList != null)
|
||||||
|
{
|
||||||
|
comboBoxTravel.DisplayMember = "TravelName";
|
||||||
|
comboBoxTravel.ValueMember = "Id";
|
||||||
|
comboBoxTravel.DataSource = _TravelList;
|
||||||
|
comboBoxTravel.SelectedItem = null;
|
||||||
|
_logger.LogInformation("Загрузка путёвок для продажи");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSell_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (comboBoxTravel.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите пиццу", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Создание покупки");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool resout = _logicS.Sale(new SupplySearchModel
|
||||||
|
{
|
||||||
|
TravelId = Convert.ToInt32(comboBoxTravel.SelectedValue),
|
||||||
|
Count = Convert.ToInt32(textBoxCount.Text)
|
||||||
|
});
|
||||||
|
if (resout)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Проверка пройдена, продажа проведена");
|
||||||
|
MessageBox.Show("Продажа проведена", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Проверка не пройдена");
|
||||||
|
MessageBox.Show("Продажа не может быть создана.", "Результат", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания покупки");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
TravelCompany/TravelCompany/FormSellTravels.resx
Normal file
120
TravelCompany/TravelCompany/FormSellTravels.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>
|
222
TravelCompany/TravelCompany/FormShop.Designer.cs
generated
Normal file
222
TravelCompany/TravelCompany/FormShop.Designer.cs
generated
Normal file
@ -0,0 +1,222 @@
|
|||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
partial class FormShop
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
this.labelName = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxAdress = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelAdress = new System.Windows.Forms.Label();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.TravelName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
|
this.dateTimeOpen = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.numericUpTravelMaxCount = new System.Windows.Forms.NumericUpDown();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpTravelMaxCount)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
this.labelName.AutoSize = true;
|
||||||
|
this.labelName.Location = new System.Drawing.Point(11, 15);
|
||||||
|
this.labelName.Name = "labelName";
|
||||||
|
this.labelName.Size = new System.Drawing.Size(84, 20);
|
||||||
|
this.labelName.TabIndex = 0;
|
||||||
|
this.labelName.Text = "Название: ";
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
this.textBoxName.Location = new System.Drawing.Point(102, 12);
|
||||||
|
this.textBoxName.Name = "textBoxName";
|
||||||
|
this.textBoxName.Size = new System.Drawing.Size(276, 27);
|
||||||
|
this.textBoxName.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// textBoxAdress
|
||||||
|
//
|
||||||
|
this.textBoxAdress.Location = new System.Drawing.Point(102, 59);
|
||||||
|
this.textBoxAdress.Name = "textBoxAdress";
|
||||||
|
this.textBoxAdress.Size = new System.Drawing.Size(427, 27);
|
||||||
|
this.textBoxAdress.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// labelAdress
|
||||||
|
//
|
||||||
|
this.labelAdress.AutoSize = true;
|
||||||
|
this.labelAdress.Location = new System.Drawing.Point(11, 61);
|
||||||
|
this.labelAdress.Name = "labelAdress";
|
||||||
|
this.labelAdress.Size = new System.Drawing.Size(58, 20);
|
||||||
|
this.labelAdress.TabIndex = 2;
|
||||||
|
this.labelAdress.Text = "Адрес: ";
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(451, 457);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(130, 44);
|
||||||
|
this.buttonCancel.TabIndex = 5;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(315, 457);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(130, 44);
|
||||||
|
this.buttonSave.TabIndex = 6;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.id,
|
||||||
|
this.TravelName,
|
||||||
|
this.Count});
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 185);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.ReadOnly = true;
|
||||||
|
this.dataGridView.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
|
||||||
|
this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(569, 266);
|
||||||
|
this.dataGridView.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// id
|
||||||
|
//
|
||||||
|
this.id.HeaderText = "id";
|
||||||
|
this.id.MinimumWidth = 6;
|
||||||
|
this.id.Name = "id";
|
||||||
|
this.id.ReadOnly = true;
|
||||||
|
this.id.Visible = false;
|
||||||
|
//
|
||||||
|
// TravelName
|
||||||
|
//
|
||||||
|
this.TravelName.HeaderText = "Пицца";
|
||||||
|
this.TravelName.MinimumWidth = 6;
|
||||||
|
this.TravelName.Name = "TravelName";
|
||||||
|
this.TravelName.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// Count
|
||||||
|
//
|
||||||
|
this.Count.HeaderText = "Количество";
|
||||||
|
this.Count.MinimumWidth = 6;
|
||||||
|
this.Count.Name = "Count";
|
||||||
|
this.Count.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
this.label1.AutoSize = true;
|
||||||
|
this.label1.Location = new System.Drawing.Point(12, 103);
|
||||||
|
this.label1.Name = "label1";
|
||||||
|
this.label1.Size = new System.Drawing.Size(110, 20);
|
||||||
|
this.label1.TabIndex = 8;
|
||||||
|
this.label1.Text = "Дата открытия";
|
||||||
|
//
|
||||||
|
// dateTimeOpen
|
||||||
|
//
|
||||||
|
this.dateTimeOpen.Location = new System.Drawing.Point(128, 103);
|
||||||
|
this.dateTimeOpen.Name = "dateTimeOpen";
|
||||||
|
this.dateTimeOpen.Size = new System.Drawing.Size(401, 27);
|
||||||
|
this.dateTimeOpen.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(12, 148);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(100, 20);
|
||||||
|
this.label2.TabIndex = 10;
|
||||||
|
this.label2.Text = "Вместимость";
|
||||||
|
//
|
||||||
|
// numericUpTravelMaxCount
|
||||||
|
//
|
||||||
|
this.numericUpTravelMaxCount.Location = new System.Drawing.Point(128, 146);
|
||||||
|
this.numericUpTravelMaxCount.Maximum = new decimal(new int[] {
|
||||||
|
10000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.numericUpTravelMaxCount.Name = "numericUpTravelMaxCount";
|
||||||
|
this.numericUpTravelMaxCount.Size = new System.Drawing.Size(401, 27);
|
||||||
|
this.numericUpTravelMaxCount.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// FormShop
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(593, 513);
|
||||||
|
this.Controls.Add(this.numericUpTravelMaxCount);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
|
this.Controls.Add(this.dateTimeOpen);
|
||||||
|
this.Controls.Add(this.label1);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.textBoxAdress);
|
||||||
|
this.Controls.Add(this.labelAdress);
|
||||||
|
this.Controls.Add(this.textBoxName);
|
||||||
|
this.Controls.Add(this.labelName);
|
||||||
|
this.Name = "FormShop";
|
||||||
|
this.Text = "Магазин";
|
||||||
|
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.numericUpTravelMaxCount)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelName;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private TextBox textBoxAdress;
|
||||||
|
private Label labelAdress;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private DataGridViewTextBoxColumn id;
|
||||||
|
private DataGridViewTextBoxColumn TravelName;
|
||||||
|
private DataGridViewTextBoxColumn Count;
|
||||||
|
private Label label1;
|
||||||
|
private DateTimePicker dateTimeOpen;
|
||||||
|
private Label label2;
|
||||||
|
private NumericUpDown numericUpTravelMaxCount;
|
||||||
|
}
|
||||||
|
}
|
127
TravelCompany/TravelCompany/FormShop.cs
Normal file
127
TravelCompany/TravelCompany/FormShop.cs
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
using TravelCompanyDataModels.Models;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.BusinessLogicsContracts;
|
||||||
|
using TravelCompanyContracts.SearchModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
public partial class FormShop : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IShopLogic _logic;
|
||||||
|
private int? _id;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
private Dictionary<int, (ITravelModel, int)> _ShopTravels;
|
||||||
|
private DateTime? _openingDate = null;
|
||||||
|
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
_ShopTravels = new Dictionary<int, (ITravelModel, int)>();
|
||||||
|
}
|
||||||
|
private void FormShop_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка магазина");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logic.ReadElement(new ShopSearchModel
|
||||||
|
{
|
||||||
|
Id = _id.Value
|
||||||
|
});
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxName.Text = view.ShopName;
|
||||||
|
textBoxAdress.Text = view.Adress;
|
||||||
|
dateTimeOpen.Value = view.OpeningDate;
|
||||||
|
numericUpTravelMaxCount.Value = view.TravelMaxCount;
|
||||||
|
_ShopTravels = view.ShopTravels ?? new Dictionary<int, (ITravelModel, int)>();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Загрузка изделий в магазине");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_ShopTravels != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var sr in _ShopTravels)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { sr.Key, sr.Value.Item1.TravelName, sr.Value.Item2 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки изделий магазина");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(textBoxAdress.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение магазина");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
ShopName = textBoxName.Text,
|
||||||
|
Adress = textBoxAdress.Text,
|
||||||
|
OpeningDate = dateTimeOpen.Value,
|
||||||
|
TravelMaxCount = (int)numericUpTravelMaxCount.Value
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка сохранения магазина");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
TravelCompany/TravelCompany/FormShop.resx
Normal file
120
TravelCompany/TravelCompany/FormShop.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>
|
130
TravelCompany/TravelCompany/FormShops.Designer.cs
generated
Normal file
130
TravelCompany/TravelCompany/FormShops.Designer.cs
generated
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
partial class FormShops
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
this.ToolsPanel = new System.Windows.Forms.Panel();
|
||||||
|
this.buttonRef = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.ToolsPanel.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// ToolsPanel
|
||||||
|
//
|
||||||
|
this.ToolsPanel.Controls.Add(this.buttonRef);
|
||||||
|
this.ToolsPanel.Controls.Add(this.buttonDel);
|
||||||
|
this.ToolsPanel.Controls.Add(this.buttonUpd);
|
||||||
|
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
||||||
|
this.ToolsPanel.Location = new System.Drawing.Point(608, 12);
|
||||||
|
this.ToolsPanel.Name = "ToolsPanel";
|
||||||
|
this.ToolsPanel.Size = new System.Drawing.Size(180, 426);
|
||||||
|
this.ToolsPanel.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonRef
|
||||||
|
//
|
||||||
|
this.buttonRef.Location = new System.Drawing.Point(31, 206);
|
||||||
|
this.buttonRef.Name = "buttonRef";
|
||||||
|
this.buttonRef.Size = new System.Drawing.Size(126, 36);
|
||||||
|
this.buttonRef.TabIndex = 3;
|
||||||
|
this.buttonRef.Text = "Обновить";
|
||||||
|
this.buttonRef.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(31, 142);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(126, 36);
|
||||||
|
this.buttonDel.TabIndex = 2;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(31, 76);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(126, 36);
|
||||||
|
this.buttonUpd.TabIndex = 1;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(31, 16);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(126, 36);
|
||||||
|
this.buttonAdd.TabIndex = 0;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.AllowUserToAddRows = false;
|
||||||
|
this.dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 12);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.ReadOnly = true;
|
||||||
|
this.dataGridView.RowHeadersWidth = 51;
|
||||||
|
this.dataGridView.RowTemplate.Height = 29;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(590, 426);
|
||||||
|
this.dataGridView.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// FormShops
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||||
|
this.Controls.Add(this.ToolsPanel);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormShops";
|
||||||
|
this.Text = "Магазины";
|
||||||
|
this.Load += new System.EventHandler(this.FormShops_Load);
|
||||||
|
this.ToolsPanel.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel ToolsPanel;
|
||||||
|
private Button buttonRef;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
117
TravelCompany/TravelCompany/FormShops.cs
Normal file
117
TravelCompany/TravelCompany/FormShops.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using TravelCompany;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.BusinessLogicsContracts;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace TravelCompany.Forms
|
||||||
|
{
|
||||||
|
public partial class FormShops : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IShopLogic _logic;
|
||||||
|
|
||||||
|
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormShops_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["ShopTravels"].Visible = false;
|
||||||
|
dataGridView.Columns["ShopName"].AutoSizeMode =
|
||||||
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Загрузка магазинов");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||||
|
if (service is FormShop form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||||
|
if (service is FormShop form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
_logger.LogInformation("Удаление магазина");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
TravelCompany/TravelCompany/FormShops.resx
Normal file
120
TravelCompany/TravelCompany/FormShops.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>
|
@ -7,6 +7,7 @@ using Microsoft.Extensions.Logging;
|
|||||||
using NLog.Extensions.Logging;
|
using NLog.Extensions.Logging;
|
||||||
using TravelCompanyBusinessLogic.OfficePackage.Implements;
|
using TravelCompanyBusinessLogic.OfficePackage.Implements;
|
||||||
using TravelCompanyBusinessLogic.OfficePackage;
|
using TravelCompanyBusinessLogic.OfficePackage;
|
||||||
|
using TravelCompanyBusinessLogic.BusinessLogics;
|
||||||
|
|
||||||
|
|
||||||
namespace TravelCompany.Forms
|
namespace TravelCompany.Forms
|
||||||
@ -48,6 +49,15 @@ namespace TravelCompany.Forms
|
|||||||
services.AddTransient<IClientLogic, ClientLogic>();
|
services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
services.AddTransient<IClientStorage, ClientStorage>();
|
services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
|
|
||||||
|
services.AddTransient<IShopStorage, ShopStorage>();
|
||||||
|
services.AddTransient<IShopLogic, ShopLogic>();
|
||||||
|
services.AddTransient<FormShop>();
|
||||||
|
services.AddTransient<FormShops>();
|
||||||
|
services.AddTransient<FormCreateSupply>();
|
||||||
|
services.AddTransient<FormSellTravels>();
|
||||||
|
services.AddTransient<FormReportShop>();
|
||||||
|
services.AddTransient<FormReportGroupedOrders>();
|
||||||
|
|
||||||
services.AddTransient<FormMain>();
|
services.AddTransient<FormMain>();
|
||||||
services.AddTransient<FormComponent>();
|
services.AddTransient<FormComponent>();
|
||||||
services.AddTransient<FormComponents>();
|
services.AddTransient<FormComponents>();
|
||||||
|
441
TravelCompany/TravelCompany/ReportGroupedOrders.rdlc
Normal file
441
TravelCompany/TravelCompany/ReportGroupedOrders.rdlc
Normal file
@ -0,0 +1,441 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2016/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
|
||||||
|
<AutoRefresh>0</AutoRefresh>
|
||||||
|
<DataSources>
|
||||||
|
<DataSource Name="TravelCompanyContractsViewModels">
|
||||||
|
<ConnectionProperties>
|
||||||
|
<DataProvider>System.Data.DataSet</DataProvider>
|
||||||
|
<ConnectString>/* Local Connection */</ConnectString>
|
||||||
|
</ConnectionProperties>
|
||||||
|
<rd:DataSourceID>20791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
|
||||||
|
</DataSource>
|
||||||
|
</DataSources>
|
||||||
|
<DataSets>
|
||||||
|
<DataSet Name="DataSetGroupedOrders">
|
||||||
|
<Query>
|
||||||
|
<DataSourceName>TravelCompanyContractsViewModels</DataSourceName>
|
||||||
|
<CommandText>/* Local Query */</CommandText>
|
||||||
|
</Query>
|
||||||
|
<Fields>
|
||||||
|
<Field Name="Date">
|
||||||
|
<DataField>Date</DataField>
|
||||||
|
<rd:TypeName>System.DateTime</rd:TypeName>
|
||||||
|
</Field>
|
||||||
|
<Field Name="OrdersCount">
|
||||||
|
<DataField>OrdersCount</DataField>
|
||||||
|
<rd:TypeName>System.Int32</rd:TypeName>
|
||||||
|
</Field>
|
||||||
|
<Field Name="OrdersSum">
|
||||||
|
<DataField>OrdersSum</DataField>
|
||||||
|
<rd:TypeName>System.Decimal</rd:TypeName>
|
||||||
|
</Field>
|
||||||
|
</Fields>
|
||||||
|
<rd:DataSetInfo>
|
||||||
|
<rd:DataSetName>TravelCompanyContracts.ViewModels</rd:DataSetName>
|
||||||
|
<rd:TableName>ReportGroupOrdersViewModel</rd:TableName>
|
||||||
|
<rd:ObjectDataSourceType>TravelCompanyContracts.ViewModels.ReportGroupOrdersViewModel, TravelCompanyContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
||||||
|
</rd:DataSetInfo>
|
||||||
|
</DataSet>
|
||||||
|
</DataSets>
|
||||||
|
<ReportSections>
|
||||||
|
<ReportSection>
|
||||||
|
<Body>
|
||||||
|
<ReportItems>
|
||||||
|
<Textbox Name="TextboxTitle">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Отчёт по заказам</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Center</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<Width>16.51cm</Width>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
<VerticalAlign>Middle</VerticalAlign>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
<Textbox Name="ReportParameterPeriod">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Parameters!ReportParameterPeriod.Value</Value>
|
||||||
|
<Style>
|
||||||
|
<Format>d</Format>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Center</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
|
||||||
|
<Top>0.6cm</Top>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<Width>16.51cm</Width>
|
||||||
|
<ZIndex>1</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
<Tablix Name="Tablix1">
|
||||||
|
<TablixBody>
|
||||||
|
<TablixColumns>
|
||||||
|
<TablixColumn>
|
||||||
|
<Width>3.90406cm</Width>
|
||||||
|
</TablixColumn>
|
||||||
|
<TablixColumn>
|
||||||
|
<Width>3.97461cm</Width>
|
||||||
|
</TablixColumn>
|
||||||
|
<TablixColumn>
|
||||||
|
<Width>3.65711cm</Width>
|
||||||
|
</TablixColumn>
|
||||||
|
</TablixColumns>
|
||||||
|
<TablixRows>
|
||||||
|
<TablixRow>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<TablixCells>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="TextboxDate">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Дата создания</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="TextboxCount">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Количество заказов</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="TextboxSum">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Общая сумма заказов</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
</TablixCells>
|
||||||
|
</TablixRow>
|
||||||
|
<TablixRow>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<TablixCells>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="Date">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Fields!Date.Value</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>Date</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="OrdersCount">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Fields!OrdersCount.Value</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>OrdersCount</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
<TablixCell>
|
||||||
|
<CellContents>
|
||||||
|
<Textbox Name="OrdersSum">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Fields!OrdersSum.Value</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style />
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<rd:DefaultName>OrdersSum</rd:DefaultName>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Color>LightGrey</Color>
|
||||||
|
<Style>Solid</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</CellContents>
|
||||||
|
</TablixCell>
|
||||||
|
</TablixCells>
|
||||||
|
</TablixRow>
|
||||||
|
</TablixRows>
|
||||||
|
</TablixBody>
|
||||||
|
<TablixColumnHierarchy>
|
||||||
|
<TablixMembers>
|
||||||
|
<TablixMember />
|
||||||
|
<TablixMember />
|
||||||
|
<TablixMember />
|
||||||
|
</TablixMembers>
|
||||||
|
</TablixColumnHierarchy>
|
||||||
|
<TablixRowHierarchy>
|
||||||
|
<TablixMembers>
|
||||||
|
<TablixMember>
|
||||||
|
<KeepWithGroup>After</KeepWithGroup>
|
||||||
|
</TablixMember>
|
||||||
|
<TablixMember>
|
||||||
|
<Group Name="Подробности" />
|
||||||
|
</TablixMember>
|
||||||
|
</TablixMembers>
|
||||||
|
</TablixRowHierarchy>
|
||||||
|
<DataSetName>DataSetGroupedOrders</DataSetName>
|
||||||
|
<Top>1.88242cm</Top>
|
||||||
|
<Left>2.68676cm</Left>
|
||||||
|
<Height>1.2cm</Height>
|
||||||
|
<Width>11.53578cm</Width>
|
||||||
|
<ZIndex>2</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
</Style>
|
||||||
|
</Tablix>
|
||||||
|
<Textbox Name="TextboxResout">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>Итого:</Value>
|
||||||
|
<Style />
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Right</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<Top>3.29409cm</Top>
|
||||||
|
<Left>8.06542cm</Left>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<Width>2.5cm</Width>
|
||||||
|
<ZIndex>3</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
<Textbox Name="TextboxFullSum">
|
||||||
|
<CanGrow>true</CanGrow>
|
||||||
|
<KeepTogether>true</KeepTogether>
|
||||||
|
<Paragraphs>
|
||||||
|
<Paragraph>
|
||||||
|
<TextRuns>
|
||||||
|
<TextRun>
|
||||||
|
<Value>=Sum(Fields!OrdersSum.Value, "DataSetGroupedOrders")</Value>
|
||||||
|
<Style>
|
||||||
|
<Format>0.00;(0.00)</Format>
|
||||||
|
</Style>
|
||||||
|
</TextRun>
|
||||||
|
</TextRuns>
|
||||||
|
<Style>
|
||||||
|
<TextAlign>Right</TextAlign>
|
||||||
|
</Style>
|
||||||
|
</Paragraph>
|
||||||
|
</Paragraphs>
|
||||||
|
<Top>3.29409cm</Top>
|
||||||
|
<Left>10.70653cm</Left>
|
||||||
|
<Height>0.6cm</Height>
|
||||||
|
<Width>3.48072cm</Width>
|
||||||
|
<ZIndex>4</ZIndex>
|
||||||
|
<Style>
|
||||||
|
<Border>
|
||||||
|
<Style>None</Style>
|
||||||
|
</Border>
|
||||||
|
<PaddingLeft>2pt</PaddingLeft>
|
||||||
|
<PaddingRight>2pt</PaddingRight>
|
||||||
|
<PaddingTop>2pt</PaddingTop>
|
||||||
|
<PaddingBottom>2pt</PaddingBottom>
|
||||||
|
</Style>
|
||||||
|
</Textbox>
|
||||||
|
</ReportItems>
|
||||||
|
<Height>2in</Height>
|
||||||
|
<Style />
|
||||||
|
</Body>
|
||||||
|
<Width>6.5in</Width>
|
||||||
|
<Page>
|
||||||
|
<PageHeight>29.7cm</PageHeight>
|
||||||
|
<PageWidth>21cm</PageWidth>
|
||||||
|
<LeftMargin>2cm</LeftMargin>
|
||||||
|
<RightMargin>2cm</RightMargin>
|
||||||
|
<TopMargin>2cm</TopMargin>
|
||||||
|
<BottomMargin>2cm</BottomMargin>
|
||||||
|
<ColumnSpacing>0.13cm</ColumnSpacing>
|
||||||
|
<Style />
|
||||||
|
</Page>
|
||||||
|
</ReportSection>
|
||||||
|
</ReportSections>
|
||||||
|
<ReportParameters>
|
||||||
|
<ReportParameter Name="ReportParameterPeriod">
|
||||||
|
<DataType>String</DataType>
|
||||||
|
<Nullable>true</Nullable>
|
||||||
|
<Prompt>ReportParameter1</Prompt>
|
||||||
|
</ReportParameter>
|
||||||
|
</ReportParameters>
|
||||||
|
<ReportParametersLayout>
|
||||||
|
<GridLayoutDefinition>
|
||||||
|
<NumberOfColumns>4</NumberOfColumns>
|
||||||
|
<NumberOfRows>2</NumberOfRows>
|
||||||
|
<CellDefinitions>
|
||||||
|
<CellDefinition>
|
||||||
|
<ColumnIndex>0</ColumnIndex>
|
||||||
|
<RowIndex>0</RowIndex>
|
||||||
|
<ParameterName>ReportParameterPeriod</ParameterName>
|
||||||
|
</CellDefinition>
|
||||||
|
</CellDefinitions>
|
||||||
|
</GridLayoutDefinition>
|
||||||
|
</ReportParametersLayout>
|
||||||
|
<rd:ReportUnitType>Cm</rd:ReportUnitType>
|
||||||
|
<rd:ReportID>b5a8ad5e-1151-4687-8576-a5270295c079</rd:ReportID>
|
||||||
|
</Report>
|
@ -15,17 +15,16 @@ namespace TravelCompanyBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
public class OrderLogic : IOrderLogic
|
public class OrderLogic : IOrderLogic
|
||||||
{
|
{
|
||||||
//Класс с логикой для заказов будет отвечать за получение списка заказов,
|
|
||||||
//создания заказа и смены его статусов. Следует учитывать, что у заказа можно
|
|
||||||
//менять статус на новый, если его текущий статус предшествует новому
|
|
||||||
|
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
|
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopStorage shopStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
|
@ -5,27 +5,27 @@ using TravelCompanyContracts.BusinessLogicsContracts;
|
|||||||
using TravelCompanyContracts.SearchModels;
|
using TravelCompanyContracts.SearchModels;
|
||||||
using TravelCompanyContracts.StoragesContracts;
|
using TravelCompanyContracts.StoragesContracts;
|
||||||
using TravelCompanyContracts.ViewModels;
|
using TravelCompanyContracts.ViewModels;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace TravelCompanyBusinessLogic.BusinessLogic
|
namespace TravelCompanyBusinessLogic.BusinessLogics
|
||||||
{
|
{
|
||||||
public class ReportLogic : IReportLogic
|
public class ReportLogic : IReportLogic
|
||||||
{
|
{
|
||||||
private readonly IComponentStorage _componentStorage;
|
private readonly IComponentStorage _componentStorage;
|
||||||
private readonly ITravelStorage _TravelStorage;
|
private readonly ITravelStorage _TravelStorage;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
private readonly AbstractSaveToExcel _saveToExcel;
|
private readonly AbstractSaveToExcel _saveToExcel;
|
||||||
private readonly AbstractSaveToWord _saveToWord;
|
private readonly AbstractSaveToWord _saveToWord;
|
||||||
private readonly AbstractSaveToPdf _saveToPdf;
|
private readonly AbstractSaveToPdf _saveToPdf;
|
||||||
public ReportLogic(ITravelStorage TravelStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
|
||||||
|
public ReportLogic(ITravelStorage TravelStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, IShopStorage shopStorage,
|
||||||
|
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||||
{
|
{
|
||||||
_TravelStorage = TravelStorage;
|
_TravelStorage = TravelStorage;
|
||||||
_componentStorage = componentStorage;
|
_componentStorage = componentStorage;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
|
|
||||||
_saveToExcel = saveToExcel;
|
_saveToExcel = saveToExcel;
|
||||||
_saveToWord = saveToWord;
|
_saveToWord = saveToWord;
|
||||||
_saveToPdf = saveToPdf;
|
_saveToPdf = saveToPdf;
|
||||||
@ -33,63 +33,44 @@ namespace TravelCompanyBusinessLogic.BusinessLogic
|
|||||||
|
|
||||||
public List<ReportTravelComponentViewModel> GetTravelComponents()
|
public List<ReportTravelComponentViewModel> GetTravelComponents()
|
||||||
{
|
{
|
||||||
var components = _componentStorage.GetFullList();
|
return _TravelStorage.GetFullList().Select(x => new ReportTravelComponentViewModel
|
||||||
var Travels = _TravelStorage.GetFullList();
|
|
||||||
var list = new List<ReportTravelComponentViewModel>();
|
|
||||||
foreach (var Travel in Travels)
|
|
||||||
{
|
{
|
||||||
var record = new ReportTravelComponentViewModel
|
TravelName = x.TravelName,
|
||||||
{
|
Components = x.TravelComponents.Select(x => (x.Value.Item1.ComponentName, x.Value.Item2)).ToList(),
|
||||||
TravelName = Travel.TravelName,
|
TotalCount = x.TravelComponents.Select(x => x.Value.Item2).Sum()
|
||||||
Components = new List<(string Component, int Count)>(),
|
}).ToList();
|
||||||
TotalCount = 0
|
|
||||||
};
|
|
||||||
foreach (var component in components)
|
|
||||||
{
|
|
||||||
if (Travel.TravelComponents.ContainsKey(component.Id))
|
|
||||||
{
|
|
||||||
record.Components.Add(new(component.ComponentName, Travel.TravelComponents[component.Id].Item2));
|
|
||||||
record.TotalCount += Travel.TravelComponents[component.Id].Item2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list.Add(record);
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
return _orderStorage.GetFilteredList(new OrderSearchModel
|
return _orderStorage.GetFilteredList(new OrderSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo })
|
||||||
{
|
|
||||||
DateFrom = model.DateFrom,
|
|
||||||
DateTo = model.DateTo
|
|
||||||
})
|
|
||||||
.Select(x => new ReportOrdersViewModel
|
.Select(x => new ReportOrdersViewModel
|
||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
DateCreate = x.DateCreate,
|
DateCreate = x.DateCreate,
|
||||||
TravelName = x.TravelName,
|
TravelName = x.TravelName,
|
||||||
Sum = x.Sum,
|
Sum = x.Sum,
|
||||||
Status = x.Status.ToString(),
|
OrderStatus = x.Status.ToString()
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveTravelsToWordFile(ReportBindingModel model)
|
public void SaveTravelsToWordFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
_saveToWord.CreateDoc(new WordInfo
|
_saveToWord.CreateTravelDoc(new WordInfo
|
||||||
{
|
{
|
||||||
FileName = model.FileName,
|
FileName = model.FileName,
|
||||||
Title = "Список ЖИ",
|
Title = "Список путевок",
|
||||||
Travels = _TravelStorage.GetFullList()
|
Travels = _TravelStorage.GetFullList()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveTravelComponentToExcelFile(ReportBindingModel model)
|
public void SaveTravelComponentToExcelFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
_saveToExcel.CreateReport(new ExcelInfo
|
_saveToExcel.CreateReport(new ExcelInfo
|
||||||
{
|
{
|
||||||
FileName = model.FileName,
|
FileName = model.FileName,
|
||||||
Title = "Список ЖИ",
|
Title = "Список путевок",
|
||||||
TravelComponents = GetTravelComponents()
|
TravelComponents = GetTravelComponents()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -106,5 +87,54 @@ namespace TravelCompanyBusinessLogic.BusinessLogic
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<ReportShopsViewModel> GetShops()
|
||||||
|
{
|
||||||
|
return _shopStorage.GetFullList().Select(x => new ReportShopsViewModel
|
||||||
|
{
|
||||||
|
ShopName = x.ShopName,
|
||||||
|
Travels = x.ShopTravels.Select(x => (x.Value.Item1.TravelName, x.Value.Item2)).ToList(),
|
||||||
|
TotalCount = x.ShopTravels.Select(x => x.Value.Item2).Sum()
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ReportGroupOrdersViewModel> GetGroupedOrders()
|
||||||
|
{
|
||||||
|
return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date).Select(x => new ReportGroupOrdersViewModel
|
||||||
|
{
|
||||||
|
Date = x.Key,
|
||||||
|
OrdersCount = x.Count(),
|
||||||
|
OrdersSum = x.Select(y => y.Sum).Sum()
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveShopsToWordFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToWord.CreateShopsDoc(new WordShopInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список магазинов",
|
||||||
|
Shops = _shopStorage.GetFullList()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveShopsToExcelFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToExcel.CreateShopTravelsReport(new ExcelShop
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Наполненость магазинов",
|
||||||
|
ShopTravels = GetShops()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveGroupedOrdersToPdfFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToPdf.CreateGroupedOrdersDoc(new PdfGroupedOrdersInfo
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список заказов сгруппированных по дате заказов",
|
||||||
|
GroupedOrders = GetGroupedOrders()
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,192 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.BusinessLogicsContracts;
|
||||||
|
using TravelCompanyContracts.SearchModels;
|
||||||
|
using TravelCompanyContracts.StoragesContracts;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace TravelCompanyBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ShopLogic : IShopLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IShopStorage _shopStorage;
|
||||||
|
private readonly ITravelStorage _TravelStorage;
|
||||||
|
|
||||||
|
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage, ITravelStorage TravelStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
|
_TravelStorage = TravelStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. ShopName:{ShopName}.Id:{ Id}", model?.ShopName, model?.Id);
|
||||||
|
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? ReadElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.ShopName, model.Id);
|
||||||
|
var element = _shopStorage.GetElement(model);
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadElement element not found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Create(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_shopStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_shopStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||||
|
if (_shopStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool MakeSupply(SupplyBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (model.Count <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Количество изделий должно быть больше 0");
|
||||||
|
}
|
||||||
|
var shop = _shopStorage.GetElement(new ShopSearchModel
|
||||||
|
{
|
||||||
|
Id = model.ShopId
|
||||||
|
});
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Магазина не существует");
|
||||||
|
}
|
||||||
|
if (shop.ShopTravels.ContainsKey(model.TravelId))
|
||||||
|
{
|
||||||
|
var oldValue = shop.ShopTravels[model.TravelId];
|
||||||
|
oldValue.Item2 += model.Count;
|
||||||
|
shop.ShopTravels[model.TravelId] = oldValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var Travel = _TravelStorage.GetElement(new TravelSearchModel
|
||||||
|
{
|
||||||
|
Id = model.TravelId
|
||||||
|
});
|
||||||
|
if (Travel == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"Поставка: Товар с id:{model.TravelId} не найденн");
|
||||||
|
}
|
||||||
|
if (shop.ShopTravels.Sum(kv => kv.Value.Item2) + model.Count > shop.TravelMaxCount)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Превышена максимальная вместимость магазина");
|
||||||
|
}
|
||||||
|
shop.ShopTravels.Add(model.TravelId, (Travel, model.Count));
|
||||||
|
}
|
||||||
|
|
||||||
|
_shopStorage.Update(new ShopBindingModel()
|
||||||
|
{
|
||||||
|
Id = shop.Id,
|
||||||
|
ShopName = shop.ShopName,
|
||||||
|
Adress = shop.Adress,
|
||||||
|
OpeningDate = shop.OpeningDate,
|
||||||
|
ShopTravels = shop.ShopTravels,
|
||||||
|
TravelMaxCount = shop.TravelMaxCount,
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Adress))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Адрес магазина длжен быть заполнен", nameof(model.Adress));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Название магазина должно быть заполнено", nameof(model.ShopName));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Shop. ShopName:{ShopName}.Adres:{Adres}.OpeningDate:{OpeningDate}.Id:{ Id}", model.ShopName, model.Adress, model.OpeningDate, model.Id);
|
||||||
|
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||||
|
{
|
||||||
|
ShopName = model.ShopName
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Sale(SupplySearchModel model)
|
||||||
|
{
|
||||||
|
if (!model.TravelId.HasValue || !model.Count.HasValue)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Check Travel count in all shops");
|
||||||
|
if (_shopStorage.Sale(model))
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Selling sucsess");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Selling failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -74,10 +74,83 @@ namespace TravelCompanyBusinessLogic.OfficePackage
|
|||||||
}
|
}
|
||||||
SaveExcel(info);
|
SaveExcel(info);
|
||||||
}
|
}
|
||||||
protected abstract void CreateExcel(ExcelInfo info);
|
|
||||||
|
public void CreateShopTravelsReport(ExcelShop info)
|
||||||
|
{
|
||||||
|
CreateExcel(info);
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = 1,
|
||||||
|
Text = info.Title,
|
||||||
|
StyleInfo = ExcelStyleInfoType.Title
|
||||||
|
});
|
||||||
|
|
||||||
|
MergeCells(new ExcelMergeParameters
|
||||||
|
{
|
||||||
|
CellFromName = "A1",
|
||||||
|
CellToName = "C1"
|
||||||
|
});
|
||||||
|
|
||||||
|
uint rowIndex = 2;
|
||||||
|
foreach (var sr in info.ShopTravels)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = sr.ShopName,
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
rowIndex++;
|
||||||
|
|
||||||
|
foreach (var (Travel, Count) in sr.Travels)
|
||||||
|
{
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "B",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = Travel,
|
||||||
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "C",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = Count.ToString(),
|
||||||
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||||
|
});
|
||||||
|
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "A",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = "Итого",
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
{
|
||||||
|
ColumnName = "C",
|
||||||
|
RowIndex = rowIndex,
|
||||||
|
Text = sr.TotalCount.ToString(),
|
||||||
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
|
});
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveExcel(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void CreateExcel(IDocument info);
|
||||||
protected abstract void InsertCellInWorksheet(ExcelCellParameters
|
protected abstract void InsertCellInWorksheet(ExcelCellParameters
|
||||||
excelParams);
|
excelParams);
|
||||||
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
protected abstract void MergeCells(ExcelMergeParameters excelParams);
|
||||||
protected abstract void SaveExcel(ExcelInfo info);
|
protected abstract void SaveExcel(IDocument info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
CreateRow(new PdfRowParameters
|
CreateRow(new PdfRowParameters
|
||||||
{
|
{
|
||||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.TravelName, order.Sum.ToString(), order.Status },
|
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.TravelName, order.Sum.ToString(), order.OrderStatus },
|
||||||
Style = "Normal",
|
Style = "Normal",
|
||||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
});
|
});
|
||||||
@ -50,10 +50,39 @@ namespace TravelCompanyBusinessLogic.OfficePackage
|
|||||||
SavePdf(info);
|
SavePdf(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void CreatePdf(PdfInfo info);
|
public void CreateGroupedOrdersDoc(PdfGroupedOrdersInfo info)
|
||||||
|
{
|
||||||
|
CreatePdf(info);
|
||||||
|
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
|
|
||||||
|
CreateTable(new List<string> { "4cm", "3cm", "2cm" });
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Дата заказа", "Кол-во", "Сумма" },
|
||||||
|
Style = "NormalTitle",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var groupedOrder in info.GroupedOrders)
|
||||||
|
{
|
||||||
|
CreateRow(new PdfRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { groupedOrder.Date.ToShortDateString(), groupedOrder.OrdersCount.ToString(), groupedOrder.OrdersSum.ToString() },
|
||||||
|
Style = "Normal",
|
||||||
|
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.GroupedOrders.Sum(x => x.OrdersSum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||||
|
|
||||||
|
SavePdf(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void CreatePdf(IDocument info);
|
||||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||||
protected abstract void CreateTable(List<string> columns);
|
protected abstract void CreateTable(List<string> columns);
|
||||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||||
protected abstract void SavePdf(PdfInfo info);
|
protected abstract void SavePdf(IDocument info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
public abstract class AbstractSaveToWord
|
public abstract class AbstractSaveToWord
|
||||||
{
|
{
|
||||||
public void CreateDoc(WordInfo info)
|
public void CreateTravelDoc(WordInfo info)
|
||||||
{
|
{
|
||||||
CreateWord(info);
|
CreateWord(info);
|
||||||
CreateParagraph(new WordParagraph
|
CreateParagraph(new WordParagraph
|
||||||
@ -38,9 +38,52 @@ WordTextProperties { Bold = true, Size = "24", }) },
|
|||||||
}
|
}
|
||||||
SaveWord(info);
|
SaveWord(info);
|
||||||
}
|
}
|
||||||
protected abstract void CreateWord(WordInfo info);
|
|
||||||
|
public void CreateShopsDoc(WordShopInfo info)
|
||||||
|
{
|
||||||
|
CreateWord(info);
|
||||||
|
CreateParagraph(new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
JustificationType = WordJustificationType.Center
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
CreateTable(new List<string> { "3000", "3000", "3000" });
|
||||||
|
CreateRow(new WordRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { "Название", "Адрес", "Дата открытия" },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "24",
|
||||||
|
Bold = true,
|
||||||
|
JustificationType = WordJustificationType.Center
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach (var shop in info.Shops)
|
||||||
|
{
|
||||||
|
CreateRow(new WordRowParameters
|
||||||
|
{
|
||||||
|
Texts = new List<string> { shop.ShopName, shop.Adress, shop.OpeningDate.ToString() },
|
||||||
|
TextProperties = new WordTextProperties
|
||||||
|
{
|
||||||
|
Size = "22",
|
||||||
|
JustificationType = WordJustificationType.Both
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveWord(info);
|
||||||
|
}
|
||||||
|
protected abstract void CreateWord(IDocument info);
|
||||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||||
protected abstract void SaveWord(WordInfo info);
|
protected abstract void SaveWord(IDocument info);
|
||||||
|
protected abstract void CreateTable(List<string> colums);
|
||||||
|
protected abstract void CreateRow(WordRowParameters rowParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
|
namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class ExcelInfo
|
public class ExcelInfo : IDocument
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class ExcelShop : IDocument
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public List<ReportShopsViewModel> ShopTravels { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class PdfGroupedOrdersInfo : IDocument
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public DateTime DateFrom { get; set; }
|
||||||
|
public DateTime DateTo { get; set; }
|
||||||
|
public List<ReportGroupOrdersViewModel> GroupedOrders { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
|
namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class PdfInfo
|
public class PdfInfo : IDocument
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
|
namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
|
||||||
{
|
{
|
||||||
public class WordInfo
|
public class WordInfo : IDocument
|
||||||
{
|
{
|
||||||
public string FileName { get; set; } = string.Empty;
|
public string FileName { get; set; } = string.Empty;
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordRowParameters
|
||||||
|
{
|
||||||
|
public List<string> Texts { get; set; } = new();
|
||||||
|
public WordTextProperties TextProperties { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
|
||||||
|
{
|
||||||
|
public class WordShopInfo : IDocument
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public List<ShopViewModel> Shops { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyBusinessLogic.OfficePackage
|
||||||
|
{
|
||||||
|
public interface IDocument
|
||||||
|
{
|
||||||
|
public string FileName { get; set; }
|
||||||
|
public string Title { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -203,7 +203,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage.Implements
|
|||||||
_ => 0U,
|
_ => 0U,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
protected override void CreateExcel(ExcelInfo info)
|
protected override void CreateExcel(IDocument info)
|
||||||
{
|
{
|
||||||
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
|
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
|
||||||
SpreadsheetDocumentType.Workbook);
|
SpreadsheetDocumentType.Workbook);
|
||||||
@ -326,7 +326,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage.Implements
|
|||||||
};
|
};
|
||||||
mergeCells.Append(mergeCell);
|
mergeCells.Append(mergeCell);
|
||||||
}
|
}
|
||||||
protected override void SaveExcel(ExcelInfo info)
|
protected override void SaveExcel(IDocument info)
|
||||||
{
|
{
|
||||||
if (_spreadsheetDocument == null)
|
if (_spreadsheetDocument == null)
|
||||||
{
|
{
|
||||||
|
@ -39,7 +39,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage.Implements
|
|||||||
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
style = document.Styles.AddStyle("NormalTitle", "Normal");
|
||||||
style.Font.Bold = true;
|
style.Font.Bold = true;
|
||||||
}
|
}
|
||||||
protected override void CreatePdf(PdfInfo info)
|
protected override void CreatePdf(IDocument info)
|
||||||
{
|
{
|
||||||
_document = new Document();
|
_document = new Document();
|
||||||
DefineStyles(_document);
|
DefineStyles(_document);
|
||||||
@ -93,7 +93,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage.Implements
|
|||||||
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
row.Cells[i].VerticalAlignment = VerticalAlignment.Center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override void SavePdf(PdfInfo info)
|
protected override void SavePdf(IDocument info)
|
||||||
{
|
{
|
||||||
var renderer = new PdfDocumentRenderer(true)
|
var renderer = new PdfDocumentRenderer(true)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage.Implements
|
|||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CreateWord(WordInfo info)
|
protected override void CreateWord(IDocument info)
|
||||||
{
|
{
|
||||||
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
_wordDocument = WordprocessingDocument.Create(info.FileName, WordprocessingDocumentType.Document);
|
||||||
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
|
||||||
@ -105,7 +105,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage.Implements
|
|||||||
_docBody.AppendChild(docParagraph);
|
_docBody.AppendChild(docParagraph);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SaveWord(WordInfo info)
|
protected override void SaveWord(IDocument info)
|
||||||
{
|
{
|
||||||
if (_docBody == null || _wordDocument == null)
|
if (_docBody == null || _wordDocument == null)
|
||||||
{
|
{
|
||||||
@ -117,5 +117,77 @@ namespace TravelCompanyBusinessLogic.OfficePackage.Implements
|
|||||||
|
|
||||||
_wordDocument.Dispose();
|
_wordDocument.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Table? _lastTable;
|
||||||
|
protected override void CreateTable(List<string> columns)
|
||||||
|
{
|
||||||
|
if (_docBody == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_lastTable = new Table();
|
||||||
|
|
||||||
|
var tableProp = new TableProperties();
|
||||||
|
tableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
|
||||||
|
tableProp.AppendChild(new TableBorders(
|
||||||
|
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||||
|
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 }
|
||||||
|
));
|
||||||
|
tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
|
||||||
|
_lastTable.AppendChild(tableProp);
|
||||||
|
|
||||||
|
TableGrid tableGrid = new TableGrid();
|
||||||
|
foreach (var column in columns)
|
||||||
|
{
|
||||||
|
tableGrid.AppendChild(new GridColumn() { Width = column });
|
||||||
|
}
|
||||||
|
_lastTable.AppendChild(tableGrid);
|
||||||
|
|
||||||
|
_docBody.AppendChild(_lastTable);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CreateRow(WordRowParameters rowParameters)
|
||||||
|
{
|
||||||
|
if (_docBody == null || _lastTable == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
TableRow docRow = new TableRow();
|
||||||
|
foreach (var column in rowParameters.Texts)
|
||||||
|
{
|
||||||
|
var docParagraph = new Paragraph();
|
||||||
|
WordParagraph paragraph = new WordParagraph
|
||||||
|
{
|
||||||
|
Texts = new List<(string, WordTextProperties)> { (column, rowParameters.TextProperties) },
|
||||||
|
TextProperties = rowParameters.TextProperties
|
||||||
|
};
|
||||||
|
|
||||||
|
docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
|
||||||
|
|
||||||
|
foreach (var run in paragraph.Texts)
|
||||||
|
{
|
||||||
|
var docRun = new Run();
|
||||||
|
|
||||||
|
var properties = new RunProperties();
|
||||||
|
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||||
|
if (run.Item2.Bold)
|
||||||
|
{
|
||||||
|
properties.AppendChild(new Bold());
|
||||||
|
}
|
||||||
|
docRun.AppendChild(properties);
|
||||||
|
|
||||||
|
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||||
|
|
||||||
|
docParagraph.AppendChild(docRun);
|
||||||
|
}
|
||||||
|
|
||||||
|
TableCell docCell = new TableCell();
|
||||||
|
docCell.AppendChild(docParagraph);
|
||||||
|
docRow.AppendChild(docCell);
|
||||||
|
}
|
||||||
|
_lastTable.AppendChild(docRow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
using TravelCompanyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ShopBindingModel : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
public string Adress { get; set; } = string.Empty;
|
||||||
|
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||||
|
public Dictionary<int, (ITravelModel, int)> ShopTravels { get; set; } = new();
|
||||||
|
public int TravelMaxCount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
using TravelCompanyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class SupplyBindingModel : ISupplyModel
|
||||||
|
{
|
||||||
|
public int ShopId { get; set; }
|
||||||
|
public int TravelId { get; set; }
|
||||||
|
public int Count { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -12,8 +12,13 @@ namespace TravelCompanyContracts.BusinessLogicsContracts
|
|||||||
{
|
{
|
||||||
List<ReportTravelComponentViewModel> GetTravelComponents();
|
List<ReportTravelComponentViewModel> GetTravelComponents();
|
||||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||||
|
List<ReportShopsViewModel> GetShops();
|
||||||
|
List<ReportGroupOrdersViewModel> GetGroupedOrders();
|
||||||
void SaveTravelsToWordFile(ReportBindingModel model);
|
void SaveTravelsToWordFile(ReportBindingModel model);
|
||||||
void SaveTravelComponentToExcelFile(ReportBindingModel model);
|
void SaveTravelComponentToExcelFile(ReportBindingModel model);
|
||||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||||
|
void SaveShopsToWordFile(ReportBindingModel model);
|
||||||
|
void SaveShopsToExcelFile(ReportBindingModel model);
|
||||||
|
void SaveGroupedOrdersToPdfFile(ReportBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.SearchModels;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IShopLogic
|
||||||
|
{
|
||||||
|
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||||
|
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||||
|
bool Create(ShopBindingModel model);
|
||||||
|
bool Update(ShopBindingModel model);
|
||||||
|
bool Delete(ShopBindingModel model);
|
||||||
|
bool MakeSupply(SupplyBindingModel model);
|
||||||
|
bool Sale(SupplySearchModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ShopSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
public string? ShopName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class SupplySearchModel
|
||||||
|
{
|
||||||
|
public int? TravelId { get; set; }
|
||||||
|
public int? Count { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.SearchModels;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IShopStorage
|
||||||
|
{
|
||||||
|
List<ShopViewModel> GetFullList();
|
||||||
|
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||||
|
ShopViewModel? GetElement(ShopSearchModel model);
|
||||||
|
ShopViewModel? Insert(ShopBindingModel model);
|
||||||
|
ShopViewModel? Update(ShopBindingModel model);
|
||||||
|
ShopViewModel? Delete(ShopBindingModel model);
|
||||||
|
bool Sale(SupplySearchModel model);
|
||||||
|
bool RestockingShops(SupplyBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportGroupOrdersViewModel
|
||||||
|
{
|
||||||
|
public DateTime Date { get; set; } = DateTime.Now;
|
||||||
|
public int OrdersCount { get; set; }
|
||||||
|
public double OrdersSum { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -11,8 +11,9 @@ namespace TravelCompanyContracts.ViewModels
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public DateTime DateCreate { get; set; }
|
public DateTime DateCreate { get; set; }
|
||||||
public string TravelName { get; set; } = string.Empty;
|
public string TravelName { get; set; } = string.Empty;
|
||||||
|
public string OrderStatus { get; set; } = string.Empty;
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
public string Status { get; set; } = string.Empty;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ReportShopsViewModel
|
||||||
|
{
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
public int TotalCount { get; set; }
|
||||||
|
public List<(string Travel, int count)> Travels { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
namespace TravelCompanyContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ShopTravelViewModel
|
||||||
|
{
|
||||||
|
public ShopViewModel Shop { get; set; } = new();
|
||||||
|
public Dictionary<int, TravelCount> ShopTravel { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
using TravelCompanyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ShopViewModel : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
[DisplayName("Название")]
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Адрес")]
|
||||||
|
public string Adress { get; set; } = string.Empty;
|
||||||
|
[DisplayName("Дата открытия")]
|
||||||
|
public DateTime OpeningDate { get; set; }
|
||||||
|
public Dictionary<int, (ITravelModel, int)> ShopTravels { get; set; } = new();
|
||||||
|
[DisplayName("Вместимость")]
|
||||||
|
public int TravelMaxCount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
namespace TravelCompanyContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class TravelCount
|
||||||
|
{
|
||||||
|
public TravelViewModel Travel { get; set; }
|
||||||
|
public int Count { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
19
TravelCompany/TravelCompanyDataModels/Models/IShopModel.cs
Normal file
19
TravelCompany/TravelCompanyDataModels/Models/IShopModel.cs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
using TravelCompanyDataModels;
|
||||||
|
using TravelCompanyDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IShopModel : IId
|
||||||
|
{
|
||||||
|
string ShopName { get; }
|
||||||
|
string Adress { get; }
|
||||||
|
DateTime OpeningDate { get; }
|
||||||
|
Dictionary<int, (ITravelModel, int)> ShopTravels { get; }
|
||||||
|
public int TravelMaxCount { get; }
|
||||||
|
}
|
||||||
|
}
|
15
TravelCompany/TravelCompanyDataModels/Models/ISupplyModel.cs
Normal file
15
TravelCompany/TravelCompanyDataModels/Models/ISupplyModel.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyDataModels.Models
|
||||||
|
{
|
||||||
|
public interface ISupplyModel
|
||||||
|
{
|
||||||
|
int ShopId { get; }
|
||||||
|
int TravelId { get; }
|
||||||
|
int Count { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,185 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.SearchModels;
|
||||||
|
using TravelCompanyContracts.StoragesContracts;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using TravelCompanyDatabaseImplement.Models;
|
||||||
|
|
||||||
|
namespace TravelCompanyDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ShopStorage : IShopStorage
|
||||||
|
{
|
||||||
|
public List<ShopViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new TravelCompanyDataBase();
|
||||||
|
return context.Shops.Include(x => x.Travels).ThenInclude(x => x.Travel).ToList().
|
||||||
|
Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new TravelCompanyDataBase();
|
||||||
|
return context.Shops.Include(x => x.Travels).ThenInclude(x => x.Travel).Where(x => x.ShopName.Contains(model.ShopName)).
|
||||||
|
ToList().Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new TravelCompanyDataBase();
|
||||||
|
return context.Shops.Include(x => x.Travels).ThenInclude(x => x.Travel)
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
(!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) ||
|
||||||
|
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Insert(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new TravelCompanyDataBase();
|
||||||
|
var newShop = Shop.Create(context, model);
|
||||||
|
if (newShop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
context.Shops.Add(newShop);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newShop.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new TravelCompanyDataBase();
|
||||||
|
using var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var shop = context.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
shop.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
shop.UpdateTravels(context, model);
|
||||||
|
transaction.Commit();
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new TravelCompanyDataBase();
|
||||||
|
var shop = context.Shops.Include(x => x.Travels).FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (shop != null)
|
||||||
|
{
|
||||||
|
context.Shops.Remove(shop);
|
||||||
|
context.SaveChanges();
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RestockingShops(SupplyBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new TravelCompanyDataBase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
var Shops = context.Shops.Include(x => x.Travels).ThenInclude(x => x.Travel).ToList().
|
||||||
|
Where(x => x.TravelMaxCount > x.ShopTravels.Select(x => x.Value.Item2).Sum()).ToList();
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (Shop shop in Shops)
|
||||||
|
{
|
||||||
|
int difference = shop.TravelMaxCount - shop.ShopTravels.Select(x => x.Value.Item2).Sum();
|
||||||
|
int refill = Math.Min(difference, model.Count);
|
||||||
|
model.Count -= refill;
|
||||||
|
if (shop.ShopTravels.ContainsKey(model.TravelId))
|
||||||
|
{
|
||||||
|
var datePair = shop.ShopTravels[model.TravelId];
|
||||||
|
datePair.Item2 += refill;
|
||||||
|
shop.ShopTravels[model.TravelId] = datePair;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var Travel = context.Travels.First(x => x.Id == model.TravelId);
|
||||||
|
shop.ShopTravels.Add(model.TravelId, (Travel, refill));
|
||||||
|
}
|
||||||
|
shop.TravelsDictionatyUpdate(context);
|
||||||
|
if (model.Count == 0)
|
||||||
|
{
|
||||||
|
transaction.Commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
transaction.Rollback();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Sale(SupplySearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new TravelCompanyDataBase();
|
||||||
|
var transaction = context.Database.BeginTransaction();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var shops = context.Shops.Include(x => x.Travels).ThenInclude(x => x.Travel).ToList().
|
||||||
|
Where(x => x.ShopTravels.ContainsKey(model.TravelId.Value)).OrderByDescending(x => x.ShopTravels[model.TravelId.Value].Item2).ToList();
|
||||||
|
|
||||||
|
foreach (var shop in shops)
|
||||||
|
{
|
||||||
|
int residue = model.Count.Value - shop.ShopTravels[model.TravelId.Value].Item2;
|
||||||
|
if (residue > 0)
|
||||||
|
{
|
||||||
|
shop.ShopTravels.Remove(model.TravelId.Value);
|
||||||
|
shop.TravelsDictionatyUpdate(context);
|
||||||
|
context.SaveChanges();
|
||||||
|
model.Count = residue;
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (residue == 0)
|
||||||
|
shop.ShopTravels.Remove(model.TravelId.Value);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var dataPair = shop.ShopTravels[model.TravelId.Value];
|
||||||
|
dataPair.Item2 = -residue;
|
||||||
|
shop.ShopTravels[model.TravelId.Value] = dataPair;
|
||||||
|
}
|
||||||
|
|
||||||
|
shop.TravelsDictionatyUpdate(context);
|
||||||
|
transaction.Commit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
transaction.Rollback();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
transaction.Rollback();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,7 @@ using TravelCompanyDatabaseImplement;
|
|||||||
namespace TravelCompanyDatabaseImplement.Migrations
|
namespace TravelCompanyDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(TravelCompanyDataBase))]
|
[DbContext(typeof(TravelCompanyDataBase))]
|
||||||
[Migration("20240418113410_InitialCreate")]
|
[Migration("20240502175943_Initial-Create")]
|
||||||
partial class InitialCreate
|
partial class InitialCreate
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -108,6 +108,59 @@ namespace TravelCompanyDatabaseImplement.Migrations
|
|||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Adress")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("OpeningDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("ShopName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("TravelMaxCount")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Shops");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.ShopTravels", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ShopId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("TravelId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ShopId");
|
||||||
|
|
||||||
|
b.HasIndex("TravelId");
|
||||||
|
|
||||||
|
b.ToTable("ShopTravels");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b =>
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -173,6 +226,25 @@ namespace TravelCompanyDatabaseImplement.Migrations
|
|||||||
b.Navigation("Travel");
|
b.Navigation("Travel");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.ShopTravels", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("TravelCompanyDatabaseImplement.Models.Shop", "Shop")
|
||||||
|
.WithMany("Travels")
|
||||||
|
.HasForeignKey("ShopId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("TravelCompanyDatabaseImplement.Models.Travel", "Travel")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("TravelId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Shop");
|
||||||
|
|
||||||
|
b.Navigation("Travel");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.TravelComponent", b =>
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.TravelComponent", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("TravelCompanyDatabaseImplement.Models.Component", "Component")
|
b.HasOne("TravelCompanyDatabaseImplement.Models.Component", "Component")
|
||||||
@ -202,6 +274,11 @@ namespace TravelCompanyDatabaseImplement.Migrations
|
|||||||
b.Navigation("TravelComponents");
|
b.Navigation("TravelComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Travels");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b =>
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Components");
|
b.Navigation("Components");
|
@ -40,6 +40,22 @@ namespace TravelCompanyDatabaseImplement.Migrations
|
|||||||
table.PrimaryKey("PK_Components", x => x.Id);
|
table.PrimaryKey("PK_Components", x => x.Id);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Shops",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Adress = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
OpeningDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
|
TravelMaxCount = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "Travels",
|
name: "Travels",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -85,6 +101,33 @@ namespace TravelCompanyDatabaseImplement.Migrations
|
|||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ShopTravels",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
TravelId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ShopId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Count = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ShopTravels", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ShopTravels_Shops_ShopId",
|
||||||
|
column: x => x.ShopId,
|
||||||
|
principalTable: "Shops",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ShopTravels_Travels_TravelId",
|
||||||
|
column: x => x.TravelId,
|
||||||
|
principalTable: "Travels",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
migrationBuilder.CreateTable(
|
||||||
name: "TravelComponents",
|
name: "TravelComponents",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -122,6 +165,16 @@ namespace TravelCompanyDatabaseImplement.Migrations
|
|||||||
table: "Orders",
|
table: "Orders",
|
||||||
column: "TravelId");
|
column: "TravelId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ShopTravels_ShopId",
|
||||||
|
table: "ShopTravels",
|
||||||
|
column: "ShopId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ShopTravels_TravelId",
|
||||||
|
table: "ShopTravels",
|
||||||
|
column: "TravelId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_TravelComponents_ComponentId",
|
name: "IX_TravelComponents_ComponentId",
|
||||||
table: "TravelComponents",
|
table: "TravelComponents",
|
||||||
@ -139,12 +192,18 @@ namespace TravelCompanyDatabaseImplement.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Orders");
|
name: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ShopTravels");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "TravelComponents");
|
name: "TravelComponents");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Clients");
|
name: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Shops");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Components");
|
name: "Components");
|
||||||
|
|
@ -105,6 +105,59 @@ namespace TravelCompanyDatabaseImplement.Migrations
|
|||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Adress")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime>("OpeningDate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("ShopName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("TravelMaxCount")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Shops");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.ShopTravels", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ShopId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("TravelId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ShopId");
|
||||||
|
|
||||||
|
b.HasIndex("TravelId");
|
||||||
|
|
||||||
|
b.ToTable("ShopTravels");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b =>
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -170,6 +223,25 @@ namespace TravelCompanyDatabaseImplement.Migrations
|
|||||||
b.Navigation("Travel");
|
b.Navigation("Travel");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.ShopTravels", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("TravelCompanyDatabaseImplement.Models.Shop", "Shop")
|
||||||
|
.WithMany("Travels")
|
||||||
|
.HasForeignKey("ShopId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("TravelCompanyDatabaseImplement.Models.Travel", "Travel")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("TravelId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Shop");
|
||||||
|
|
||||||
|
b.Navigation("Travel");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.TravelComponent", b =>
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.TravelComponent", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("TravelCompanyDatabaseImplement.Models.Component", "Component")
|
b.HasOne("TravelCompanyDatabaseImplement.Models.Component", "Component")
|
||||||
@ -199,6 +271,11 @@ namespace TravelCompanyDatabaseImplement.Migrations
|
|||||||
b.Navigation("TravelComponents");
|
b.Navigation("TravelComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Travels");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b =>
|
modelBuilder.Entity("TravelCompanyDatabaseImplement.Models.Travel", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Components");
|
b.Navigation("Components");
|
||||||
|
114
TravelCompany/TravelCompanyDatabaseImplement/Models/Shop.cs
Normal file
114
TravelCompany/TravelCompanyDatabaseImplement/Models/Shop.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using TravelCompanyDataModels.Models;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace TravelCompanyDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Shop : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ShopName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Adress { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime OpeningDate { get; set; }
|
||||||
|
|
||||||
|
public int TravelMaxCount { get; set; }
|
||||||
|
|
||||||
|
private Dictionary<int, (ITravelModel, int)>? _shopTravels = null;
|
||||||
|
|
||||||
|
public Dictionary<int, (ITravelModel, int)> ShopTravels
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_shopTravels == null)
|
||||||
|
{
|
||||||
|
if (_shopTravels == null)
|
||||||
|
{
|
||||||
|
_shopTravels = Travels
|
||||||
|
.ToDictionary(recSP => recSP.TravelId, recSP => (recSP.Travel as ITravelModel, recSP.Count));
|
||||||
|
}
|
||||||
|
return _shopTravels;
|
||||||
|
}
|
||||||
|
return _shopTravels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[ForeignKey("ShopId")]
|
||||||
|
public List<ShopTravels> Travels { get; set; } = new();
|
||||||
|
|
||||||
|
public static Shop Create(TravelCompanyDataBase context, ShopBindingModel model)
|
||||||
|
{
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShopName = model.ShopName,
|
||||||
|
Adress = model.Adress,
|
||||||
|
OpeningDate = model.OpeningDate,
|
||||||
|
Travels = model.ShopTravels.Select(x => new ShopTravels
|
||||||
|
{
|
||||||
|
Travel = context.Travels.First(y => y.Id == x.Key),
|
||||||
|
Count = x.Value.Item2
|
||||||
|
}).ToList(),
|
||||||
|
TravelMaxCount = model.TravelMaxCount
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
ShopName = model.ShopName;
|
||||||
|
Adress = model.Adress;
|
||||||
|
OpeningDate = model.OpeningDate;
|
||||||
|
TravelMaxCount = model.TravelMaxCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopName = ShopName,
|
||||||
|
Adress = Adress,
|
||||||
|
OpeningDate = OpeningDate,
|
||||||
|
ShopTravels = ShopTravels,
|
||||||
|
TravelMaxCount = TravelMaxCount
|
||||||
|
};
|
||||||
|
|
||||||
|
public void UpdateTravels(TravelCompanyDataBase context, ShopBindingModel model)
|
||||||
|
{
|
||||||
|
var ShopTravels = context.ShopTravels.Where(rec => rec.ShopId == model.Id).ToList();
|
||||||
|
if (ShopTravels != null && ShopTravels.Count > 0)
|
||||||
|
{
|
||||||
|
context.ShopTravels.RemoveRange(ShopTravels.Where(rec => !model.ShopTravels.ContainsKey(rec.TravelId)));
|
||||||
|
context.SaveChanges();
|
||||||
|
ShopTravels = context.ShopTravels.Where(rec => rec.ShopId == model.Id).ToList();
|
||||||
|
foreach (var updateTravel in ShopTravels)
|
||||||
|
{
|
||||||
|
updateTravel.Count = model.ShopTravels[updateTravel.TravelId].Item2;
|
||||||
|
model.ShopTravels.Remove(updateTravel.TravelId);
|
||||||
|
}
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
var shop = context.Shops.First(x => x.Id == Id);
|
||||||
|
foreach (var ar in model.ShopTravels)
|
||||||
|
{
|
||||||
|
context.ShopTravels.Add(new ShopTravels
|
||||||
|
{
|
||||||
|
Shop = shop,
|
||||||
|
Travel = context.Travels.First(x => x.Id == ar.Key),
|
||||||
|
Count = ar.Value.Item2
|
||||||
|
});
|
||||||
|
context.SaveChanges();
|
||||||
|
}
|
||||||
|
_shopTravels = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TravelsDictionatyUpdate(TravelCompanyDataBase context)
|
||||||
|
{
|
||||||
|
UpdateTravels(context, new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopTravels = ShopTravels,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace TravelCompanyDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class ShopTravels
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int TravelId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int ShopId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
public virtual Shop Shop { get; set; } = new();
|
||||||
|
|
||||||
|
public virtual Travel Travel { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,7 @@ optionsBuilder)
|
|||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured == false)
|
if (optionsBuilder.IsConfigured == false)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D5A5OOG\GOLDFEST;Initial Catalog=TravelCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-D5A5OOG\GOLDFEST;Initial Catalog=Hard;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
@ -25,6 +25,8 @@ optionsBuilder)
|
|||||||
public virtual DbSet<TravelComponent> TravelComponents { set; get; }
|
public virtual DbSet<TravelComponent> TravelComponents { set; get; }
|
||||||
public virtual DbSet<Order> Orders { set; get; }
|
public virtual DbSet<Order> Orders { set; get; }
|
||||||
public virtual DbSet<Client> Clients { set; get; }
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
|
public virtual DbSet<Shop> Shops { get; set; }
|
||||||
|
public virtual DbSet<ShopTravels> ShopTravels { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,12 @@ namespace TravelCompanyFileImplement
|
|||||||
private readonly string OrderFileName = "Order.xml";
|
private readonly string OrderFileName = "Order.xml";
|
||||||
private readonly string TravelFileName = "Travel.xml";
|
private readonly string TravelFileName = "Travel.xml";
|
||||||
private readonly string ClientFileName = "Client.xml";
|
private readonly string ClientFileName = "Client.xml";
|
||||||
|
private readonly string ShopFileName = "Shop.xml";
|
||||||
public List<Component> Components { get; private set; }
|
public List<Component> Components { get; private set; }
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Travel> Travels { get; private set; }
|
public List<Travel> Travels { get; private set; }
|
||||||
public List<Client> Clients { get; private set; }
|
public List<Client> Clients { get; private set; }
|
||||||
|
public List<Shop> Shops { get; private set; }
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
@ -32,6 +34,8 @@ namespace TravelCompanyFileImplement
|
|||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
public void SaveClients() => SaveData(Clients, ClientFileName,
|
public void SaveClients() => SaveData(Clients, ClientFileName,
|
||||||
"Clients", x => x.GetXElement);
|
"Clients", x => x.GetXElement);
|
||||||
|
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||||
|
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||||
@ -39,6 +43,8 @@ namespace TravelCompanyFileImplement
|
|||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
Clients = LoadData(ClientFileName, "Client", x =>
|
Clients = LoadData(ClientFileName, "Client", x =>
|
||||||
Client.Create(x)!)!;
|
Client.Create(x)!)!;
|
||||||
|
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||||
|
|
||||||
}
|
}
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,154 @@
|
|||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.SearchModels;
|
||||||
|
using TravelCompanyContracts.StoragesContracts;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using TravelCompanyFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class ShopStorage : IShopStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton source;
|
||||||
|
|
||||||
|
public ShopStorage()
|
||||||
|
{
|
||||||
|
source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return source.Shops.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
return source.Shops.Where(x => x.ShopName.Contains(model.ShopName)).Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return source.Shops.FirstOrDefault(x =>
|
||||||
|
(!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) ||
|
||||||
|
(model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Insert(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = source.Shops.Count > 0 ? source.Shops.Max(x => x.Id) + 1 : 1;
|
||||||
|
var newShop = Shop.Create(model);
|
||||||
|
if (newShop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
source.Shops.Add(newShop);
|
||||||
|
source.SaveShops();
|
||||||
|
return newShop.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
shop.Update(model);
|
||||||
|
source.SaveShops();
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (shop != null)
|
||||||
|
{
|
||||||
|
source.Shops.Remove(shop);
|
||||||
|
source.SaveShops();
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Sale(SupplySearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null || !model.TravelId.HasValue || !model.Count.HasValue)
|
||||||
|
return false;
|
||||||
|
int remainingSpace = source.Shops.Select(x => x.Travels.ContainsKey(model.TravelId.Value) ? x.Travels[model.TravelId.Value] : 0).Sum();
|
||||||
|
if (remainingSpace < model.Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var shops = source.Shops.Where(x => x.Travels.ContainsKey(model.TravelId.Value)).OrderByDescending(x => x.Travels[model.TravelId.Value]).ToList();
|
||||||
|
foreach (var shop in shops)
|
||||||
|
{
|
||||||
|
int residue = model.Count.Value - shop.Travels[model.TravelId.Value];
|
||||||
|
if (residue > 0)
|
||||||
|
{
|
||||||
|
shop.Travels.Remove(model.TravelId.Value);
|
||||||
|
shop.TravelsUpdate();
|
||||||
|
model.Count = residue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (residue == 0)
|
||||||
|
{
|
||||||
|
shop.Travels.Remove(model.TravelId.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shop.Travels[model.TravelId.Value] = -residue;
|
||||||
|
}
|
||||||
|
shop.TravelsUpdate();
|
||||||
|
source.SaveShops();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
source.SaveShops();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RestockingShops(SupplyBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null || source.Shops.Select(x => x.TravelMaxCount - x.ShopTravels.Select(y => y.Value.Item2).Sum()).Sum() < model.Count)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach (Shop shop in source.Shops)
|
||||||
|
{
|
||||||
|
int free_places = shop.TravelMaxCount - shop.ShopTravels.Select(x => x.Value.Item2).Sum();
|
||||||
|
if (free_places <= 0)
|
||||||
|
continue;
|
||||||
|
free_places = Math.Min(free_places, model.Count);
|
||||||
|
model.Count -= free_places;
|
||||||
|
if (shop.Travels.ContainsKey(model.TravelId))
|
||||||
|
{
|
||||||
|
shop.Travels[model.TravelId] += free_places;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
shop.Travels.Add(model.TravelId, free_places);
|
||||||
|
}
|
||||||
|
shop.TravelsUpdate();
|
||||||
|
if (model.Count == 0)
|
||||||
|
{
|
||||||
|
source.SaveShops();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
111
TravelCompany/TravelCompanyFileImplement/Models/Shop.cs
Normal file
111
TravelCompany/TravelCompanyFileImplement/Models/Shop.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using TravelCompanyDataModels.Models;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace TravelCompanyFileImplement.Models
|
||||||
|
{
|
||||||
|
public class Shop : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public string ShopName { get; private set; } = string.Empty;
|
||||||
|
public string Adress { get; private set; } = string.Empty;
|
||||||
|
public DateTime OpeningDate { get; private set; }
|
||||||
|
public Dictionary<int, int> Travels { get; private set; } = new();
|
||||||
|
private Dictionary<int, (ITravelModel, int)>? _shopTravels = null;
|
||||||
|
|
||||||
|
public Dictionary<int, (ITravelModel, int)> ShopTravels
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_shopTravels == null)
|
||||||
|
{
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
_shopTravels = Travels.ToDictionary(x => x.Key, y => ((source.Travels.FirstOrDefault(z => z.Id == y.Key) as ITravelModel)!, y.Value));
|
||||||
|
}
|
||||||
|
return _shopTravels;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int TravelMaxCount { get; private set; }
|
||||||
|
|
||||||
|
public static Shop? Create(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShopName = model.ShopName,
|
||||||
|
Adress = model.Adress,
|
||||||
|
OpeningDate = model.OpeningDate,
|
||||||
|
Travels = model.ShopTravels.ToDictionary(x => x.Key, x => x.Value.Item2),
|
||||||
|
TravelMaxCount = model.TravelMaxCount
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Shop? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
ShopName = element.Element("ShopName")!.Value,
|
||||||
|
Adress = element.Element("Adress")!.Value,
|
||||||
|
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
|
||||||
|
Travels = element.Element("ShopTravels")!.Elements("ShopTravel")!.ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||||
|
x => Convert.ToInt32(x.Element("Value")?.Value)),
|
||||||
|
TravelMaxCount = Convert.ToInt32(element.Element("TravelMaxCount")!.Value)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ShopName = model.ShopName;
|
||||||
|
Adress = model.Adress;
|
||||||
|
OpeningDate = model.OpeningDate;
|
||||||
|
TravelMaxCount = model.TravelMaxCount;
|
||||||
|
Travels = model.ShopTravels.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||||
|
_shopTravels = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopName = ShopName,
|
||||||
|
Adress = Adress,
|
||||||
|
OpeningDate = OpeningDate,
|
||||||
|
ShopTravels = ShopTravels,
|
||||||
|
TravelMaxCount = TravelMaxCount
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("Shop",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("ShopName", ShopName),
|
||||||
|
new XElement("Adress", Adress),
|
||||||
|
new XElement("OpeningDate", OpeningDate.ToString()),
|
||||||
|
new XElement("ShopTravels", Travels.Select(
|
||||||
|
x => new XElement("ShopTravel", new XElement("Key", x.Key), new XElement("Value", x.Value))).ToArray()),
|
||||||
|
new XElement("TravelMaxCount", TravelMaxCount.ToString())
|
||||||
|
);
|
||||||
|
|
||||||
|
public void TravelsUpdate()
|
||||||
|
{
|
||||||
|
_shopTravels = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,12 +14,16 @@ namespace TravelCompanyListImplement
|
|||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<Travel> Travels { get; set; }
|
public List<Travel> Travels { get; set; }
|
||||||
public List<Client> Clients { get; set; }
|
public List<Client> Clients { get; set; }
|
||||||
|
public List<Shop> Shops { get; set; }
|
||||||
|
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Components = new List<Component>();
|
Components = new List<Component>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Travels = new List<Travel>();
|
Travels = new List<Travel>();
|
||||||
Clients = new List<Client>();
|
Clients = new List<Client>();
|
||||||
|
Shops = new List<Shop>();
|
||||||
|
|
||||||
}
|
}
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,123 @@
|
|||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.SearchModels;
|
||||||
|
using TravelCompanyContracts.StoragesContracts;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using TravelCompanyListImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyListImplement.Implements
|
||||||
|
{
|
||||||
|
public class ShopStorage : IShopStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
|
||||||
|
public ShopStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<ShopViewModel>();
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
result.Add(shop.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
var result = new List<ShopViewModel>();
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if (shop.ShopName.Contains(model.ShopName))
|
||||||
|
{
|
||||||
|
result.Add(shop.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) ||
|
||||||
|
(model.Id.HasValue && shop.Id == model.Id))
|
||||||
|
{
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Insert(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = 1;
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if (model.Id <= shop.Id)
|
||||||
|
{
|
||||||
|
model.Id = shop.Id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var newShop = Shop.Create(model);
|
||||||
|
if (newShop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Shops.Add(newShop);
|
||||||
|
return newShop.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
foreach (var shop in _source.Shops)
|
||||||
|
{
|
||||||
|
if (shop.Id == model.Id)
|
||||||
|
{
|
||||||
|
shop.Update(model);
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel? Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||||
|
{
|
||||||
|
if (_source.Shops[i].Id == model.Id)
|
||||||
|
{
|
||||||
|
var element = _source.Shops[i];
|
||||||
|
_source.Shops.RemoveAt(i);
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Sale(SupplySearchModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RestockingShops(SupplyBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
59
TravelCompany/TravelCompanyListImplement/Models/Shop.cs
Normal file
59
TravelCompany/TravelCompanyListImplement/Models/Shop.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using TravelCompanyDataModels.Models;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TravelCompanyListImplement.Models
|
||||||
|
{
|
||||||
|
public class Shop : IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
public string ShopName { get; private set; } = string.Empty;
|
||||||
|
public string Adress { get; private set; } = string.Empty;
|
||||||
|
public DateTime OpeningDate { get; private set; }
|
||||||
|
public Dictionary<int, (ITravelModel, int)> ShopTravels { get; private set; } = new();
|
||||||
|
public int TravelMaxCount { get; private set; }
|
||||||
|
|
||||||
|
public static Shop? Create(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShopName = model.ShopName,
|
||||||
|
Adress = model.Adress,
|
||||||
|
OpeningDate = model.OpeningDate,
|
||||||
|
TravelMaxCount = model.TravelMaxCount,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ShopBindingModel? model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ShopName = model.ShopName;
|
||||||
|
Adress = model.Adress;
|
||||||
|
OpeningDate = model.OpeningDate;
|
||||||
|
TravelMaxCount = model.TravelMaxCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopName = ShopName,
|
||||||
|
Adress = Adress,
|
||||||
|
OpeningDate = OpeningDate,
|
||||||
|
ShopTravels = ShopTravels,
|
||||||
|
TravelMaxCount = TravelMaxCount,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
13
TravelCompany/TravelCompanyRestApi/APIConfig.cs
Normal file
13
TravelCompany/TravelCompanyRestApi/APIConfig.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
namespace TravelCompanyRestApi
|
||||||
|
{
|
||||||
|
public class APIConfig
|
||||||
|
{
|
||||||
|
public static string? ShopPassword;
|
||||||
|
|
||||||
|
public static void LoadData(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
ShopPassword = configuration["ShopAPIPassword"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
156
TravelCompany/TravelCompanyRestApi/Controllers/ShopController.cs
Normal file
156
TravelCompany/TravelCompanyRestApi/Controllers/ShopController.cs
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.BusinessLogicsContracts;
|
||||||
|
using TravelCompanyContracts.SearchModels;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace TravelCompanyRestApi.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class ShopController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
private readonly IShopLogic _shopLogic;
|
||||||
|
|
||||||
|
public ShopController(ILogger<ShopController> logger, IShopLogic shopLogic)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_shopLogic = shopLogic;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public bool Authentication(string password)
|
||||||
|
{
|
||||||
|
return CheckPassword(password);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public List<ShopViewModel>? GetShopList(string password)
|
||||||
|
{
|
||||||
|
if (!CheckPassword(password))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return _shopLogic.ReadList(null);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения списка магазинов");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public ShopTravelViewModel? GetShop(int shopId, string password)
|
||||||
|
{
|
||||||
|
if (!CheckPassword(password))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var shop = _shopLogic.ReadElement(new ShopSearchModel { Id = shopId });
|
||||||
|
return new ShopTravelViewModel
|
||||||
|
{
|
||||||
|
Shop = shop,
|
||||||
|
ShopTravel = shop.ShopTravels.ToDictionary(x => x.Key, x => new TravelCount
|
||||||
|
{
|
||||||
|
Travel = new TravelViewModel()
|
||||||
|
{
|
||||||
|
Id = x.Value.Item1.Id,
|
||||||
|
TravelName = x.Value.Item1.TravelName,
|
||||||
|
TravelComponents = x.Value.Item1.TravelComponents,
|
||||||
|
Price = x.Value.Item1.Price,
|
||||||
|
},
|
||||||
|
Count = x.Value.Item2
|
||||||
|
})
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка получения магазина");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void CreateShop(ShopBindingModel model, string password)
|
||||||
|
{
|
||||||
|
if (!CheckPassword(password))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_shopLogic.Create(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания магазина");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void UpdateShop(ShopBindingModel model, string password)
|
||||||
|
{
|
||||||
|
if (!CheckPassword(password))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_shopLogic.Update(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка обновления магазина");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete]
|
||||||
|
public void DeleteShop(int shopId, string password)
|
||||||
|
{
|
||||||
|
if (!CheckPassword(password))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_shopLogic.Delete(new ShopBindingModel { Id = shopId });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void MakeSupply(SupplyBindingModel model, string password)
|
||||||
|
{
|
||||||
|
if (!CheckPassword(password))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_shopLogic.MakeSupply(model);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания поставки в магазин");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool CheckPassword(string password)
|
||||||
|
{
|
||||||
|
return APIConfig.ShopPassword == password;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@ using TravelCompanyContracts.BusinessLogicsContracts;
|
|||||||
using TravelCompanyContracts.StoragesContracts;
|
using TravelCompanyContracts.StoragesContracts;
|
||||||
using TravelCompanyDatabaseImplement.Implements;
|
using TravelCompanyDatabaseImplement.Implements;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
using TravelCompanyBusinessLogic.BusinessLogics;
|
||||||
|
using TravelCompanyRestApi;
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
||||||
builder.Logging.AddLog4Net("log4net.config");
|
builder.Logging.AddLog4Net("log4net.config");
|
||||||
@ -10,9 +12,13 @@ builder.Logging.AddLog4Net("log4net.config");
|
|||||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
builder.Services.AddTransient<ITravelStorage, TravelStorage>();
|
builder.Services.AddTransient<ITravelStorage, TravelStorage>();
|
||||||
|
builder.Services.AddTransient<IShopStorage, ShopStorage>();
|
||||||
|
|
||||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
builder.Services.AddTransient<ITravelLogic, TravelLogic>();
|
builder.Services.AddTransient<ITravelLogic, TravelLogic>();
|
||||||
|
builder.Services.AddTransient<IShopLogic, ShopLogic>();
|
||||||
|
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
// Learn more about configuring Swagger/OpenAPI at
|
// Learn more about configuring Swagger/OpenAPI at
|
||||||
https://aka.ms/aspnetcore/swashbuckle
|
https://aka.ms/aspnetcore/swashbuckle
|
||||||
@ -27,6 +33,7 @@ builder.Services.AddSwaggerGen(c =>
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
APIConfig.LoadData(builder.Configuration);
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
if (app.Environment.IsDevelopment())
|
if (app.Environment.IsDevelopment())
|
||||||
{
|
{
|
||||||
|
@ -5,5 +5,6 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"ShopAPIPassword": "5558"
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<log4net>
|
<log4net>
|
||||||
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
|
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
|
||||||
<file value="c:/temp/PizzeriaRestApi.log" />
|
<file value="c:/temp/TravelCompanyRestApi.log" />
|
||||||
<appendToFile value="true" />
|
<appendToFile value="true" />
|
||||||
<maximumFileSize value="100KB" />
|
<maximumFileSize value="100KB" />
|
||||||
<maxSizeRollBackups value="2" />
|
<maxSizeRollBackups value="2" />
|
||||||
|
59
TravelCompany/TravelCompanyShopApp/APIClient.cs
Normal file
59
TravelCompany/TravelCompanyShopApp/APIClient.cs
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Net.Http.Headers;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace TravelCompanyShopApp
|
||||||
|
{
|
||||||
|
public class APIClient
|
||||||
|
{
|
||||||
|
private static readonly HttpClient _client = new();
|
||||||
|
|
||||||
|
public static string? Password { get; set; }
|
||||||
|
|
||||||
|
public static void Connect(IConfiguration configuration)
|
||||||
|
{
|
||||||
|
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||||
|
_client.DefaultRequestHeaders.Accept.Clear();
|
||||||
|
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T? GetRequest<T>(string requestUrl)
|
||||||
|
{
|
||||||
|
var response = _client.GetAsync(requestUrl);
|
||||||
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
|
if (response.Result.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
return JsonConvert.DeserializeObject<T>(result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void PostRequest<T>(string requestUrl, T model)
|
||||||
|
{
|
||||||
|
var json = JsonConvert.SerializeObject(model);
|
||||||
|
var data = new StringContent(json, Encoding.UTF8, "application/json");
|
||||||
|
|
||||||
|
var response = _client.PostAsync(requestUrl, data);
|
||||||
|
|
||||||
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
|
if (!response.Result.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DeleteRequest(string requestUrl)
|
||||||
|
{
|
||||||
|
var response = _client.DeleteAsync(requestUrl);
|
||||||
|
var result = response.Result.Content.ReadAsStringAsync().Result;
|
||||||
|
if (!response.Result.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
throw new Exception(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
149
TravelCompany/TravelCompanyShopApp/Controllers/HomeController.cs
Normal file
149
TravelCompany/TravelCompanyShopApp/Controllers/HomeController.cs
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using TravelCompanyContracts.BindingModels;
|
||||||
|
using TravelCompanyContracts.ViewModels;
|
||||||
|
using TravelCompanyShopApp.Models;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
namespace TravelCompanyShopApp.Controllers
|
||||||
|
{
|
||||||
|
public class HomeController : Controller
|
||||||
|
{
|
||||||
|
private readonly ILogger<HomeController> _logger;
|
||||||
|
|
||||||
|
public HomeController(ILogger<HomeController> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult Index()
|
||||||
|
{
|
||||||
|
if (APIClient.Password == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View(APIClient.GetRequest<List<ShopViewModel>>($"api/shop/getshoplist?password={APIClient.Password}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Enter()
|
||||||
|
{
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Enter(string password)
|
||||||
|
{
|
||||||
|
bool resout = APIClient.GetRequest<bool>($"/api/shop/authentication?password={password}");
|
||||||
|
if (!resout)
|
||||||
|
{
|
||||||
|
Response.Redirect("../Home/Enter");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
APIClient.Password = password;
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Create()
|
||||||
|
{
|
||||||
|
if (APIClient.Password == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View("Shop");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Create(int id, string shopname, string adress, DateTime openingdate, int maxcount)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(shopname) || string.IsNullOrEmpty(adress))
|
||||||
|
{
|
||||||
|
throw new Exception("Название или адрес не может быть пустым");
|
||||||
|
}
|
||||||
|
if (openingdate == default(DateTime))
|
||||||
|
{
|
||||||
|
throw new Exception("Дата открытия не может быть пустой");
|
||||||
|
}
|
||||||
|
|
||||||
|
APIClient.PostRequest($"api/shop/createshop?password={APIClient.Password}", new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
ShopName = shopname,
|
||||||
|
Adress = adress,
|
||||||
|
OpeningDate = openingdate,
|
||||||
|
TravelMaxCount = maxcount
|
||||||
|
});
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Update(int Id)
|
||||||
|
{
|
||||||
|
if (APIClient.Password == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
return View("Shop", APIClient.GetRequest<ShopTravelViewModel>($"api/shop/getshop?shopId={Id}&password={APIClient.Password}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Update(int id, string shopname, string adress, DateTime openingdate, int maxcount)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(shopname) || string.IsNullOrEmpty(adress))
|
||||||
|
{
|
||||||
|
throw new Exception("Название или адрес не может быть пустым");
|
||||||
|
}
|
||||||
|
if (openingdate == default(DateTime))
|
||||||
|
{
|
||||||
|
throw new Exception("Дата открытия не может быть пустой");
|
||||||
|
}
|
||||||
|
APIClient.PostRequest($"api/shop/updateshop?password={APIClient.Password}", new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
ShopName = shopname,
|
||||||
|
Adress = adress,
|
||||||
|
OpeningDate = openingdate,
|
||||||
|
TravelMaxCount = maxcount
|
||||||
|
});
|
||||||
|
Response.Redirect("../Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Delete(int Id)
|
||||||
|
{
|
||||||
|
APIClient.DeleteRequest($"api/shop/deleteshop?shopId={Id}&password={APIClient.Password}");
|
||||||
|
Response.Redirect("../Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult Supply()
|
||||||
|
{
|
||||||
|
if (APIClient.Password == null)
|
||||||
|
{
|
||||||
|
return Redirect("~/Home/Enter");
|
||||||
|
}
|
||||||
|
|
||||||
|
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>($"api/shop/getshoplist?password={APIClient.Password}");
|
||||||
|
ViewBag.Travels = APIClient.GetRequest<List<TravelViewModel>>($"api/main/getTravellist");
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public void Supply(int shop, int Travel, int count)
|
||||||
|
{
|
||||||
|
APIClient.PostRequest($"api/shop/makesupply?password={APIClient.Password}", new SupplyBindingModel
|
||||||
|
{
|
||||||
|
ShopId = shop,
|
||||||
|
TravelId = Travel,
|
||||||
|
Count = count
|
||||||
|
});
|
||||||
|
Response.Redirect("Index");
|
||||||
|
}
|
||||||
|
|
||||||
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||||
|
public IActionResult Error()
|
||||||
|
{
|
||||||
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
namespace TravelCompanyShopApp.Models
|
||||||
|
{
|
||||||
|
public class ErrorViewModel
|
||||||
|
{
|
||||||
|
public string? RequestId { get; set; }
|
||||||
|
|
||||||
|
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||||
|
}
|
||||||
|
}
|
30
TravelCompany/TravelCompanyShopApp/Program.cs
Normal file
30
TravelCompany/TravelCompanyShopApp/Program.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using TravelCompanyShopApp;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
// Add services to the container.
|
||||||
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
APIClient.Connect(builder.Configuration);
|
||||||
|
|
||||||
|
// Configure the HTTP request pipeline.
|
||||||
|
if (!app.Environment.IsDevelopment())
|
||||||
|
{
|
||||||
|
app.UseExceptionHandler("/Home/Error");
|
||||||
|
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||||
|
app.UseHsts();
|
||||||
|
}
|
||||||
|
|
||||||
|
app.UseHttpsRedirection();
|
||||||
|
app.UseStaticFiles();
|
||||||
|
|
||||||
|
app.UseRouting();
|
||||||
|
|
||||||
|
app.UseAuthorization();
|
||||||
|
|
||||||
|
app.MapControllerRoute(
|
||||||
|
name: "default",
|
||||||
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||||
|
|
||||||
|
app.Run();
|
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:24695",
|
||||||
|
"sslPort": 44336
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"TravelCompanyShopApp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"dotnetRunMessages": true,
|
||||||
|
"launchBrowser": true,
|
||||||
|
"applicationUrl": "https://localhost:7003;http://localhost:5078",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\TravelCompanyContracts\TravelCompanyContracts.csproj" />
|
||||||
|
<ProjectReference Include="..\TravelCompanyDataModels\TravelCompanyDataModels.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
15
TravelCompany/TravelCompanyShopApp/Views/Home/Enter.cshtml
Normal file
15
TravelCompany/TravelCompanyShopApp/Views/Home/Enter.cshtml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Enter";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Вход в систему</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Пароль</label>
|
||||||
|
<input class="form-control" type="password" name="password">
|
||||||
|
</div>
|
||||||
|
<input type="submit" value="Вход" class="btn btn-primary" />
|
||||||
|
</form>
|
68
TravelCompany/TravelCompanyShopApp/Views/Home/Index.cshtml
Normal file
68
TravelCompany/TravelCompanyShopApp/Views/Home/Index.cshtml
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
@using TravelCompanyContracts.ViewModels
|
||||||
|
|
||||||
|
@model List<ShopViewModel>
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Home Page";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
<h1 class="display-4">Магазины</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="text-center ">
|
||||||
|
<p>
|
||||||
|
<a asp-action="Create">Создать магазин</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
Номер
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Название
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Адрес
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Дата открытия
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Максимальная вместимость
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Id)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.ShopName)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.Adress)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.OpeningDate)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@Html.DisplayFor(modelItem => item.TravelMaxCount)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<a class="btn btn-primary" asp-action="Update" asp-route-Id="@(item.Id)" role="button">Изменить</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
75
TravelCompany/TravelCompanyShopApp/Views/Home/Shop.cshtml
Normal file
75
TravelCompany/TravelCompanyShopApp/Views/Home/Shop.cshtml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
@using TravelCompanyDataModels.Models;
|
||||||
|
@using TravelCompanyContracts.ViewModels;
|
||||||
|
|
||||||
|
@model ShopTravelViewModel
|
||||||
|
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Shop";
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="text-center">
|
||||||
|
@{
|
||||||
|
if (Model == null)
|
||||||
|
{
|
||||||
|
<h2 class="display-4">Создание магазина</h2>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<h2 class="display-4">Изменение магазина</h2>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Название</label>
|
||||||
|
<input type="text" class="form-control" name="shopname" id="shopname" value="@(Model==null ? "" : Model.Shop?.ShopName)" />
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Адрес</label>
|
||||||
|
<input type="text" class="form-control" name="adress" id="adress" value="@(Model==null ? "" : Model.Shop?.Adress)" />
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="startDate">Дата открытия</label>
|
||||||
|
<input class="form-control" type="date" name="openingdate" id="openingdate" value="@(Model==null ? "" : Model.Shop?.OpeningDate.ToString("yyyy-MM-dd"))" />
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Вместимость</label>
|
||||||
|
<input type="number" min="0" step="1" pattern="[0-9]" class="form-control" name="maxcount" id="maxcount" value="@(Model==null ? "" : Model.Shop?.TravelMaxCount)" />
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 ">
|
||||||
|
<input class="btn btn-primary" type="submit" value="Сохранить">
|
||||||
|
@{
|
||||||
|
if (Model != null && Model.Shop != null)
|
||||||
|
{
|
||||||
|
<input class="btn btn-danger" asp-action="Delete" type="submit" value="Удалить" asp-route-Id="@(Model==null ? 0 : Model.Shop.Id.ToString())">
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
@{
|
||||||
|
if (Model != null && Model.Shop != null)
|
||||||
|
{
|
||||||
|
<div>
|
||||||
|
<h6>Содержимое магазина</h6>
|
||||||
|
</div>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Название</th>
|
||||||
|
<th>Количество</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@foreach (var item in Model.ShopTravel)
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>@Html.DisplayFor(modelItem => item.Value.Travel.TravelName)</td>
|
||||||
|
<td>@Html.DisplayFor(modelItem => item.Value.Count)</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
}
|
||||||
|
}
|
22
TravelCompany/TravelCompanyShopApp/Views/Home/Supply.cshtml
Normal file
22
TravelCompany/TravelCompanyShopApp/Views/Home/Supply.cshtml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
@{
|
||||||
|
ViewData["Title"] = "Supply";
|
||||||
|
}
|
||||||
|
<div class="text-center">
|
||||||
|
<h2 class="display-4">Создание поставки</h2>
|
||||||
|
</div>
|
||||||
|
<form method="post">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Магазин</label>
|
||||||
|
<select class="form-select form-select-lg" id="shop" name="shop" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Путёвка</label>
|
||||||
|
<select class="form-select form-select-lg" id="travel" name="travel" asp-items="@(new SelectList(@ViewBag.Travels,"Id", "TravelName"))"></select>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label">Колличество</label>
|
||||||
|
<input type="number" min="0" step="1" pattern="[0-9]" class="form-control" name="count" id="count">
|
||||||
|
</div>
|
||||||
|
<input class="btn btn-success" type="submit" value="Создать поставку">
|
||||||
|
<a class="btn btn-primary" href="./Index" role="button">Отмена</a>
|
||||||
|
</form>
|
25
TravelCompany/TravelCompanyShopApp/Views/Shared/Error.cshtml
Normal file
25
TravelCompany/TravelCompanyShopApp/Views/Shared/Error.cshtml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
@model ErrorViewModel
|
||||||
|
@{
|
||||||
|
ViewData["Title"] = "Error";
|
||||||
|
}
|
||||||
|
|
||||||
|
<h1 class="text-danger">Error.</h1>
|
||||||
|
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||||
|
|
||||||
|
@if (Model.ShowRequestId)
|
||||||
|
{
|
||||||
|
<p>
|
||||||
|
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h3>Development Mode</h3>
|
||||||
|
<p>
|
||||||
|
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||||
|
It can result in displaying sensitive information from exceptions to end users.
|
||||||
|
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||||
|
and restarting the app.
|
||||||
|
</p>
|
@ -0,0 +1,49 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>@ViewData["Title"] - TravelCompanyShopApp</title>
|
||||||
|
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||||
|
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||||
|
<link rel="stylesheet" href="~/TravelCompanyShopApp.styles.css" asp-append-version="true" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">TravelCompanyShopApp</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||||
|
aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||||
|
<ul class="navbar-nav flex-grow-1">
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Supply">Поставка</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
<div class="container">
|
||||||
|
<main role="main" class="pb-3">
|
||||||
|
@RenderBody()
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="border-top footer text-muted">
|
||||||
|
<div class="container">
|
||||||
|
© 2024 - TravelCompanyShopApp - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
<script src="~/lib/jquery/dist/jquery.min.js"></script>
|
||||||
|
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||||
|
@await RenderSectionAsync("Scripts", required: false)
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,48 @@
|
|||||||
|
/* Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||||
|
for details on configuring this project to bundle and minify static web assets. */
|
||||||
|
|
||||||
|
a.navbar-brand {
|
||||||
|
white-space: normal;
|
||||||
|
text-align: center;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #0077cc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #1b6ec2;
|
||||||
|
border-color: #1861ac;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #1b6ec2;
|
||||||
|
border-color: #1861ac;
|
||||||
|
}
|
||||||
|
|
||||||
|
.border-top {
|
||||||
|
border-top: 1px solid #e5e5e5;
|
||||||
|
}
|
||||||
|
.border-bottom {
|
||||||
|
border-bottom: 1px solid #e5e5e5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.box-shadow {
|
||||||
|
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
button.accept-policy {
|
||||||
|
font-size: 1rem;
|
||||||
|
line-height: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.footer {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
white-space: nowrap;
|
||||||
|
line-height: 60px;
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
|
||||||
|
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
|
@ -0,0 +1,3 @@
|
|||||||
|
@using TravelCompanyShopApp
|
||||||
|
@using TravelCompanyShopApp.Models
|
||||||
|
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@ -0,0 +1,3 @@
|
|||||||
|
@{
|
||||||
|
Layout = "_Layout";
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
TravelCompany/TravelCompanyShopApp/appsettings.json
Normal file
11
TravelCompany/TravelCompanyShopApp/appsettings.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"IPAddress": "http://localhost:5247/"
|
||||||
|
|
||||||
|
}
|
18
TravelCompany/TravelCompanyShopApp/wwwroot/css/site.css
Normal file
18
TravelCompany/TravelCompanyShopApp/wwwroot/css/site.css
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
html {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
html {
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
position: relative;
|
||||||
|
min-height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin-bottom: 60px;
|
||||||
|
}
|
BIN
TravelCompany/TravelCompanyShopApp/wwwroot/favicon.ico
Normal file
BIN
TravelCompany/TravelCompanyShopApp/wwwroot/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
4
TravelCompany/TravelCompanyShopApp/wwwroot/js/site.js
Normal file
4
TravelCompany/TravelCompanyShopApp/wwwroot/js/site.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
|
||||||
|
// for details on configuring this project to bundle and minify static web assets.
|
||||||
|
|
||||||
|
// Write your JavaScript code.
|
@ -0,0 +1,22 @@
|
|||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2011-2021 Twitter, Inc.
|
||||||
|
Copyright (c) 2011-2021 The Bootstrap Authors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
4997
TravelCompany/TravelCompanyShopApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css
vendored
Normal file
4997
TravelCompany/TravelCompanyShopApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
TravelCompany/TravelCompanyShopApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css.map
vendored
Normal file
1
TravelCompany/TravelCompanyShopApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css.map
vendored
Normal file
File diff suppressed because one or more lines are too long
7
TravelCompany/TravelCompanyShopApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css
vendored
Normal file
7
TravelCompany/TravelCompanyShopApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
TravelCompany/TravelCompanyShopApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css.map
vendored
Normal file
1
TravelCompany/TravelCompanyShopApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.min.css.map
vendored
Normal file
File diff suppressed because one or more lines are too long
4996
TravelCompany/TravelCompanyShopApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css
vendored
Normal file
4996
TravelCompany/TravelCompanyShopApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user