ISEbd-21 Melnikov I. O. Lab Work 05 Advanced #31
@ -19,7 +19,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopDatabaseI
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopRestAPI", "BlacksmithWorkshopRestAPI\BlacksmithWorkshopRestAPI.csproj", "{B873C1C6-126A-4BB9-A7F7-56F36B1CBD0E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopClientApp", "BlacksmithWorkshopClientApp\BlacksmithWorkshopClientApp.csproj", "{F9968453-3EF6-4D82-A1A7-85658B68492D}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlacksmithWorkshopClientApp", "BlacksmithWorkshopClientApp\BlacksmithWorkshopClientApp.csproj", "{F9968453-3EF6-4D82-A1A7-85658B68492D}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopStoreApp", "BlacksmithWorkshopStoreApp\BlacksmithWorkshopStoreApp.csproj", "{CAD6D089-FCE1-4727-BE7D-51EB3CCE8A21}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -63,6 +65,10 @@ Global
|
||||
{F9968453-3EF6-4D82-A1A7-85658B68492D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F9968453-3EF6-4D82-A1A7-85658B68492D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F9968453-3EF6-4D82-A1A7-85658B68492D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CAD6D089-FCE1-4727-BE7D-51EB3CCE8A21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CAD6D089-FCE1-4727-BE7D-51EB3CCE8A21}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CAD6D089-FCE1-4727-BE7D-51EB3CCE8A21}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CAD6D089-FCE1-4727-BE7D-51EB3CCE8A21}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -10,6 +10,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="nlog.config" />
|
||||
<None Remove="ReportGroupOrders.rdlc" />
|
||||
<None Remove="ReportOrders.rdlc" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -20,6 +21,9 @@
|
||||
<EmbeddedResource Include="ReportOrders.rdlc">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ReportGroupOrders.rdlc">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -40,4 +44,10 @@
|
||||
<ProjectReference Include="..\BlacksmithWorkshopListImplement\BlacksmithWorkshopListImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="FormReportGroupOrders.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
145
BlacksmithWorkshop/BlacksmithWorkshop/FormFillStore.Designer.cs
generated
Normal file
145
BlacksmithWorkshop/BlacksmithWorkshop/FormFillStore.Designer.cs
generated
Normal file
@ -0,0 +1,145 @@
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
partial class FormFillStore
|
||||
{
|
||||
/// <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.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.labelManufacture = new System.Windows.Forms.Label();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxManufacture = new System.Windows.Forms.ComboBox();
|
||||
this.comboBoxStore = new System.Windows.Forms.ComboBox();
|
||||
this.labelStore = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(258, 100);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 9;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(177, 100);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonSave.TabIndex = 10;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(14, 44);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(72, 15);
|
||||
this.labelCount.TabIndex = 7;
|
||||
this.labelCount.Text = "Количество";
|
||||
//
|
||||
// labelManufacture
|
||||
//
|
||||
this.labelManufacture.AutoSize = true;
|
||||
this.labelManufacture.Location = new System.Drawing.Point(14, 15);
|
||||
this.labelManufacture.Name = "labelManufacture";
|
||||
this.labelManufacture.Size = new System.Drawing.Size(53, 15);
|
||||
this.labelManufacture.TabIndex = 8;
|
||||
this.labelManufacture.Text = "Изделие";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(109, 41);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(224, 23);
|
||||
this.textBoxCount.TabIndex = 6;
|
||||
//
|
||||
// comboBoxManufacture
|
||||
//
|
||||
this.comboBoxManufacture.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxManufacture.FormattingEnabled = true;
|
||||
this.comboBoxManufacture.Location = new System.Drawing.Point(109, 12);
|
||||
this.comboBoxManufacture.Name = "comboBoxManufacture";
|
||||
this.comboBoxManufacture.Size = new System.Drawing.Size(224, 23);
|
||||
this.comboBoxManufacture.TabIndex = 5;
|
||||
//
|
||||
// comboBoxStore
|
||||
//
|
||||
this.comboBoxStore.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxStore.FormattingEnabled = true;
|
||||
this.comboBoxStore.Location = new System.Drawing.Point(109, 71);
|
||||
this.comboBoxStore.Name = "comboBoxStore";
|
||||
this.comboBoxStore.Size = new System.Drawing.Size(224, 23);
|
||||
this.comboBoxStore.TabIndex = 5;
|
||||
//
|
||||
// labelStore
|
||||
//
|
||||
this.labelStore.AutoSize = true;
|
||||
this.labelStore.Location = new System.Drawing.Point(14, 74);
|
||||
this.labelStore.Name = "labelStore";
|
||||
this.labelStore.Size = new System.Drawing.Size(54, 15);
|
||||
this.labelStore.TabIndex = 8;
|
||||
this.labelStore.Text = "Магазин";
|
||||
//
|
||||
// FormFillStore
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(348, 130);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelStore);
|
||||
this.Controls.Add(this.labelManufacture);
|
||||
this.Controls.Add(this.comboBoxStore);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.comboBoxManufacture);
|
||||
this.Name = "FormFillStore";
|
||||
this.Text = "Пополнение магазина";
|
||||
this.Load += new System.EventHandler(this.FormFillStore_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private Label labelCount;
|
||||
private Label labelManufacture;
|
||||
private TextBox textBoxCount;
|
||||
private ComboBox comboBoxManufacture;
|
||||
private ComboBox comboBoxStore;
|
||||
private Label labelStore;
|
||||
}
|
||||
}
|
88
BlacksmithWorkshop/BlacksmithWorkshop/FormFillStore.cs
Normal file
88
BlacksmithWorkshop/BlacksmithWorkshop/FormFillStore.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicContracts;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
public partial class FormFillStore : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStoreLogic _logicS;
|
||||
private readonly IManufactureLogic _logicM;
|
||||
public FormFillStore(ILogger<FormCreateOrder> logger, IStoreLogic logicS, IManufactureLogic logicM)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicS = logicS;
|
||||
_logicM = logicM;
|
||||
}
|
||||
private void FormFillStore_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазинов и изделий");
|
||||
var listS = _logicS.ReadList(null);
|
||||
if (listS != null)
|
||||
{
|
||||
comboBoxStore.DisplayMember = "StoreName";
|
||||
comboBoxStore.ValueMember = "Id";
|
||||
comboBoxStore.DataSource = listS;
|
||||
comboBoxStore.SelectedItem = null;
|
||||
}
|
||||
var listM = _logicM.ReadList(null);
|
||||
if (listM != null)
|
||||
{
|
||||
comboBoxManufacture.DisplayMember = "ManufactureName";
|
||||
comboBoxManufacture.ValueMember = "Id";
|
||||
comboBoxManufacture.DataSource = listM;
|
||||
comboBoxManufacture.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxStore.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxManufacture.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Пополнение магазина");
|
||||
try
|
||||
{
|
||||
var addedManufacture = _logicM.ReadElement(new ManufactureSearchModel
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxManufacture.SelectedValue)
|
||||
});
|
||||
if (addedManufacture == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var operationResult = _logicS.AddManufacture(addedManufacture, new StoreSearchModel
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxStore.SelectedValue)
|
||||
}, 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();
|
||||
}
|
||||
}
|
||||
}
|
60
BlacksmithWorkshop/BlacksmithWorkshop/FormFillStore.resx
Normal file
60
BlacksmithWorkshop/BlacksmithWorkshop/FormFillStore.resx
Normal file
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
@ -32,17 +32,22 @@
|
||||
this.refbooksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.manufacturesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.clientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.reportsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.storesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.reportToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.reportComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.reportManufactureComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.reportOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.reportStoresToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.reportManufacturesInStoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
||||
this.buttonOrderReady = new System.Windows.Forms.Button();
|
||||
this.buttonIssuedOrder = new System.Windows.Forms.Button();
|
||||
this.buttonRef = new System.Windows.Forms.Button();
|
||||
this.buttonFillStore = new System.Windows.Forms.Button();
|
||||
this.buttonSellManufacture = new System.Windows.Forms.Button();
|
||||
this.reportGroupOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -51,10 +56,10 @@
|
||||
//
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.refbooksToolStripMenuItem,
|
||||
this.reportsToolStripMenuItem});
|
||||
this.reportToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(1294, 24);
|
||||
this.menuStrip.Size = new System.Drawing.Size(1108, 24);
|
||||
this.menuStrip.TabIndex = 0;
|
||||
this.menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
@ -63,7 +68,7 @@
|
||||
this.refbooksToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.componentsToolStripMenuItem,
|
||||
this.manufacturesToolStripMenuItem,
|
||||
this.clientsToolStripMenuItem});
|
||||
this.storesToolStripMenuItem});
|
||||
this.refbooksToolStripMenuItem.Name = "refbooksToolStripMenuItem";
|
||||
this.refbooksToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
||||
this.refbooksToolStripMenuItem.Text = "Справочники";
|
||||
@ -82,22 +87,25 @@
|
||||
this.manufacturesToolStripMenuItem.Text = "Изделия";
|
||||
this.manufacturesToolStripMenuItem.Click += new System.EventHandler(this.ManufacturesToolStripMenuItem_Click);
|
||||
//
|
||||
// clientsToolStripMenuItem
|
||||
// storesToolStripMenuItem
|
||||
//
|
||||
this.clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
|
||||
this.clientsToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
||||
this.clientsToolStripMenuItem.Text = "Клиенты";
|
||||
this.clientsToolStripMenuItem.Click += new System.EventHandler(this.ClientsToolStripMenuItem_Click);
|
||||
this.storesToolStripMenuItem.Name = "storesToolStripMenuItem";
|
||||
this.storesToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
||||
this.storesToolStripMenuItem.Text = "Магазины";
|
||||
this.storesToolStripMenuItem.Click += new System.EventHandler(this.StoresToolStripMenuItem_Click);
|
||||
//
|
||||
// reportsToolStripMenuItem
|
||||
// reportToolStripMenuItem
|
||||
//
|
||||
this.reportsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.reportToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.reportComponentsToolStripMenuItem,
|
||||
this.reportManufactureComponentsToolStripMenuItem,
|
||||
this.reportOrdersToolStripMenuItem});
|
||||
this.reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
|
||||
this.reportsToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
|
||||
this.reportsToolStripMenuItem.Text = "Отчеты";
|
||||
this.reportOrdersToolStripMenuItem,
|
||||
this.reportStoresToolStripMenuItem,
|
||||
this.reportManufacturesInStoreToolStripMenuItem,
|
||||
this.reportGroupOrdersToolStripMenuItem});
|
||||
this.reportToolStripMenuItem.Name = "reportToolStripMenuItem";
|
||||
this.reportToolStripMenuItem.Size = new System.Drawing.Size(51, 20);
|
||||
this.reportToolStripMenuItem.Text = "Отчет";
|
||||
//
|
||||
// reportComponentsToolStripMenuItem
|
||||
//
|
||||
@ -120,6 +128,20 @@
|
||||
this.reportOrdersToolStripMenuItem.Text = "Список заказов";
|
||||
this.reportOrdersToolStripMenuItem.Click += new System.EventHandler(this.ReportOrdersToolStripMenuItem_Click);
|
||||
//
|
||||
// reportStoresToolStripMenuItem
|
||||
//
|
||||
this.reportStoresToolStripMenuItem.Name = "reportStoresToolStripMenuItem";
|
||||
this.reportStoresToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
|
||||
this.reportStoresToolStripMenuItem.Text = "Список магазинов";
|
||||
this.reportStoresToolStripMenuItem.Click += new System.EventHandler(this.ReportStoresToolStripMenuItem_Click);
|
||||
//
|
||||
// reportManufacturesInStoreToolStripMenuItem
|
||||
//
|
||||
this.reportManufacturesInStoreToolStripMenuItem.Name = "reportManufacturesInStoreToolStripMenuItem";
|
||||
this.reportManufacturesInStoreToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
|
||||
this.reportManufacturesInStoreToolStripMenuItem.Text = "Изделия в магазинах";
|
||||
this.reportManufacturesInStoreToolStripMenuItem.Click += new System.EventHandler(this.ReportManufacturesInStoreToolStripMenuItem_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
@ -127,12 +149,12 @@
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 27);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(981, 456);
|
||||
this.dataGridView.Size = new System.Drawing.Size(795, 456);
|
||||
this.dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
this.buttonCreateOrder.Location = new System.Drawing.Point(999, 27);
|
||||
this.buttonCreateOrder.Location = new System.Drawing.Point(813, 27);
|
||||
this.buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
this.buttonCreateOrder.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
this.buttonCreateOrder.Size = new System.Drawing.Size(283, 23);
|
||||
@ -143,7 +165,7 @@
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(999, 56);
|
||||
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(813, 56);
|
||||
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
this.buttonTakeOrderInWork.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(283, 23);
|
||||
@ -154,7 +176,7 @@
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
this.buttonOrderReady.Location = new System.Drawing.Point(999, 85);
|
||||
this.buttonOrderReady.Location = new System.Drawing.Point(813, 85);
|
||||
this.buttonOrderReady.Name = "buttonOrderReady";
|
||||
this.buttonOrderReady.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
this.buttonOrderReady.Size = new System.Drawing.Size(283, 23);
|
||||
@ -165,7 +187,7 @@
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(1000, 114);
|
||||
this.buttonIssuedOrder.Location = new System.Drawing.Point(814, 114);
|
||||
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
this.buttonIssuedOrder.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
this.buttonIssuedOrder.Size = new System.Drawing.Size(283, 23);
|
||||
@ -176,7 +198,7 @@
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
this.buttonRef.Location = new System.Drawing.Point(999, 143);
|
||||
this.buttonRef.Location = new System.Drawing.Point(813, 143);
|
||||
this.buttonRef.Name = "buttonRef";
|
||||
this.buttonRef.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
this.buttonRef.Size = new System.Drawing.Size(283, 23);
|
||||
@ -185,11 +207,41 @@
|
||||
this.buttonRef.UseVisualStyleBackColor = true;
|
||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// buttonFillStore
|
||||
//
|
||||
this.buttonFillStore.Location = new System.Drawing.Point(813, 172);
|
||||
this.buttonFillStore.Name = "buttonFillStore";
|
||||
this.buttonFillStore.RightToLeft = System.Windows.Forms.RightToLeft.No;
|
||||
this.buttonFillStore.Size = new System.Drawing.Size(283, 23);
|
||||
this.buttonFillStore.TabIndex = 2;
|
||||
this.buttonFillStore.Text = "Пополнить магазин";
|
||||
this.buttonFillStore.UseVisualStyleBackColor = true;
|
||||
this.buttonFillStore.Click += new System.EventHandler(this.ButtonFillStore_Click);
|
||||
//
|
||||
// buttonSellManufacture
|
||||
//
|
||||
this.buttonSellManufacture.Location = new System.Drawing.Point(814, 201);
|
||||
this.buttonSellManufacture.Name = "buttonSellManufacture";
|
||||
this.buttonSellManufacture.Size = new System.Drawing.Size(282, 23);
|
||||
this.buttonSellManufacture.TabIndex = 3;
|
||||
this.buttonSellManufacture.Text = "Продать изделие";
|
||||
this.buttonSellManufacture.UseVisualStyleBackColor = true;
|
||||
this.buttonSellManufacture.Click += new System.EventHandler(this.ButtonSellManufacture_Click);
|
||||
//
|
||||
// reportGroupOrdersToolStripMenuItem
|
||||
//
|
||||
this.reportGroupOrdersToolStripMenuItem.Name = "reportGroupOrdersToolStripMenuItem";
|
||||
this.reportGroupOrdersToolStripMenuItem.Size = new System.Drawing.Size(218, 22);
|
||||
this.reportGroupOrdersToolStripMenuItem.Text = "Заказы по датам";
|
||||
this.reportGroupOrdersToolStripMenuItem.Click += new System.EventHandler(this.ReportGroupOrdersToolStripMenuItem_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1294, 504);
|
||||
this.ClientSize = new System.Drawing.Size(1108, 504);
|
||||
this.Controls.Add(this.buttonSellManufacture);
|
||||
this.Controls.Add(this.buttonFillStore);
|
||||
this.Controls.Add(this.buttonRef);
|
||||
this.Controls.Add(this.buttonIssuedOrder);
|
||||
this.Controls.Add(this.buttonOrderReady);
|
||||
@ -221,10 +273,15 @@
|
||||
private Button buttonOrderReady;
|
||||
private Button buttonIssuedOrder;
|
||||
private Button buttonRef;
|
||||
private ToolStripMenuItem reportsToolStripMenuItem;
|
||||
private ToolStripMenuItem reportComponentsToolStripMenuItem;
|
||||
private ToolStripMenuItem reportManufactureComponentsToolStripMenuItem;
|
||||
private ToolStripMenuItem reportOrdersToolStripMenuItem;
|
||||
private ToolStripMenuItem clientsToolStripMenuItem;
|
||||
}
|
||||
private ToolStripMenuItem storesToolStripMenuItem;
|
||||
private Button buttonFillStore;
|
||||
private Button buttonSellManufacture;
|
||||
private ToolStripMenuItem reportToolStripMenuItem;
|
||||
private ToolStripMenuItem reportComponentsToolStripMenuItem;
|
||||
private ToolStripMenuItem reportManufactureComponentsToolStripMenuItem;
|
||||
private ToolStripMenuItem reportOrdersToolStripMenuItem;
|
||||
private ToolStripMenuItem reportStoresToolStripMenuItem;
|
||||
private ToolStripMenuItem reportManufacturesInStoreToolStripMenuItem;
|
||||
private ToolStripMenuItem reportGroupOrdersToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -150,41 +150,86 @@ namespace BlacksmithWorkshopView
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void ReportComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveComponentsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
private void ReportManufactureComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportManufactureComponents));
|
||||
if (service is FormReportManufactureComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private void ReportOrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void StoresToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStores));
|
||||
if (service is FormStores form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ButtonFillStore_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormFillStore));
|
||||
if (service is FormFillStore form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ButtonSellManufacture_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSellManufacture));
|
||||
if (service is FormSellManufacture form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ReportComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveComponentsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
private void ReportManufactureComponentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportManufactureComponents));
|
||||
if (service is FormReportManufactureComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
private void ReportOrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportStoresToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveStoresToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportManufacturesInStoreToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportManufacturesInStore));
|
||||
if (service is FormReportManufacturesInStore form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportGroupOrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupOrders));
|
||||
if (service is FormReportGroupOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Reporting.WinForms;
|
||||
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
public partial class FormReportGroupOrders : Form
|
||||
{
|
||||
private readonly ReportViewer reportViewer;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IReportLogic _logic;
|
||||
|
||||
public FormReportGroupOrders(ILogger<FormReportOrders> logger, IReportLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
reportViewer = new ReportViewer
|
||||
{
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupOrders.rdlc", FileMode.Open));
|
||||
Controls.Clear();
|
||||
Controls.Add(reportViewer);
|
||||
Controls.Add(panel);
|
||||
}
|
||||
|
||||
private void ButtonMake_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dataSource = _logic.GetGroupOrders();
|
||||
var source = new ReportDataSource("DataSetOrders", dataSource);
|
||||
reportViewer.LocalReport.DataSources.Clear();
|
||||
reportViewer.LocalReport.DataSources.Add(source);
|
||||
|
||||
reportViewer.RefreshReport();
|
||||
}
|
||||
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.SaveGroupOrdersToPdfFile(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
92
BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupOrders.designer.cs
generated
Normal file
92
BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupOrders.designer.cs
generated
Normal file
@ -0,0 +1,92 @@
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
partial class FormReportGroupOrders
|
||||
{
|
||||
/// <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.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.panel.Name = "panel";
|
||||
this.panel.Size = new System.Drawing.Size(1031, 40);
|
||||
this.panel.TabIndex = 0;
|
||||
//
|
||||
// buttonToPdf
|
||||
//
|
||||
this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonToPdf.Location = new System.Drawing.Point(878, 8);
|
||||
this.buttonToPdf.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.buttonToPdf.Name = "buttonToPdf";
|
||||
this.buttonToPdf.Size = new System.Drawing.Size(139, 27);
|
||||
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(13, 8);
|
||||
this.buttonMake.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.buttonMake.Name = "buttonMake";
|
||||
this.buttonMake.Size = new System.Drawing.Size(139, 27);
|
||||
this.buttonMake.TabIndex = 4;
|
||||
this.buttonMake.Text = "Сформировать";
|
||||
this.buttonMake.UseVisualStyleBackColor = true;
|
||||
this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click);
|
||||
//
|
||||
// FormReportGroupOrders
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1031, 647);
|
||||
this.Controls.Add(this.panel);
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.Name = "FormReportGroupOrders";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Заказы";
|
||||
this.panel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel panel;
|
||||
private System.Windows.Forms.Button buttonToPdf;
|
||||
private System.Windows.Forms.Button buttonMake;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
103
BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufacturesInStore.Designer.cs
generated
Normal file
103
BlacksmithWorkshop/BlacksmithWorkshop/FormReportManufacturesInStore.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
partial class FormReportManufacturesInStore
|
||||
{
|
||||
/// <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.buttonSaveToExcel = new System.Windows.Forms.Button();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ColumnStore = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnManufacture = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonSaveToExcel
|
||||
//
|
||||
this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 6);
|
||||
this.buttonSaveToExcel.Name = "buttonSaveToExcel";
|
||||
this.buttonSaveToExcel.Size = new System.Drawing.Size(188, 23);
|
||||
this.buttonSaveToExcel.TabIndex = 3;
|
||||
this.buttonSaveToExcel.Text = "Сохранить в Excel";
|
||||
this.buttonSaveToExcel.UseVisualStyleBackColor = true;
|
||||
this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ColumnStore,
|
||||
this.ColumnManufacture,
|
||||
this.ColumnCount});
|
||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 45);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(800, 405);
|
||||
this.dataGridView.TabIndex = 2;
|
||||
//
|
||||
// ColumnStore
|
||||
//
|
||||
this.ColumnStore.HeaderText = "Магазин";
|
||||
this.ColumnStore.Name = "ColumnStore";
|
||||
//
|
||||
// ColumnManufacture
|
||||
//
|
||||
this.ColumnManufacture.HeaderText = "Изделие";
|
||||
this.ColumnManufacture.Name = "ColumnManufacture";
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
this.ColumnCount.HeaderText = "Количество";
|
||||
this.ColumnCount.Name = "ColumnCount";
|
||||
//
|
||||
// FormReportManufacturesInStore
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.buttonSaveToExcel);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormReportManufacturesInStore";
|
||||
this.Text = "Изделия в магазине";
|
||||
this.Load += new System.EventHandler(this.FormReportManufacturesInStore_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSaveToExcel;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn ColumnStore;
|
||||
private DataGridViewTextBoxColumn ColumnManufacture;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
public partial class FormReportManufacturesInStore : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportLogic _logic;
|
||||
public FormReportManufacturesInStore(ILogger<FormReportManufacturesInStore> logger, IReportLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "xlsx|*.xlsx"
|
||||
};
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveStoresToExcelFile(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FormReportManufacturesInStore_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.GetManufacturesInStore();
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var elem in list)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { elem.StoreName, "", "" });
|
||||
foreach (var listElem in elem.Manufactures)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2});
|
||||
}
|
||||
dataGridView.Rows.Add(new object[] {"Заполнено", $"{elem.HasManufactures} из {elem.MaxManufactures}", ""});
|
||||
}
|
||||
}
|
||||
_logger.LogInformation("Загрузка списка изделий по компонентам");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
<root>
|
||||
<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>
|
||||
<metadata name="ColumnStore.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnManufacture.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
121
BlacksmithWorkshop/BlacksmithWorkshop/FormSellManufacture.Designer.cs
generated
Normal file
121
BlacksmithWorkshop/BlacksmithWorkshop/FormSellManufacture.Designer.cs
generated
Normal file
@ -0,0 +1,121 @@
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
partial class FormSellManufacture
|
||||
{
|
||||
/// <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.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonSell = new System.Windows.Forms.Button();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.labelManufacture = new System.Windows.Forms.Label();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxManufacture = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(256, 70);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 15;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// buttonSell
|
||||
//
|
||||
this.buttonSell.Location = new System.Drawing.Point(175, 70);
|
||||
this.buttonSell.Name = "buttonSell";
|
||||
this.buttonSell.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonSell.TabIndex = 16;
|
||||
this.buttonSell.Text = "Продать";
|
||||
this.buttonSell.UseVisualStyleBackColor = true;
|
||||
this.buttonSell.Click += new System.EventHandler(this.ButtonSell_Click);
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(12, 44);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(72, 15);
|
||||
this.labelCount.TabIndex = 13;
|
||||
this.labelCount.Text = "Количество";
|
||||
//
|
||||
// labelManufacture
|
||||
//
|
||||
this.labelManufacture.AutoSize = true;
|
||||
this.labelManufacture.Location = new System.Drawing.Point(12, 15);
|
||||
this.labelManufacture.Name = "labelManufacture";
|
||||
this.labelManufacture.Size = new System.Drawing.Size(53, 15);
|
||||
this.labelManufacture.TabIndex = 14;
|
||||
this.labelManufacture.Text = "Изделие";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(107, 41);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(224, 23);
|
||||
this.textBoxCount.TabIndex = 12;
|
||||
//
|
||||
// comboBoxManufacture
|
||||
//
|
||||
this.comboBoxManufacture.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxManufacture.FormattingEnabled = true;
|
||||
this.comboBoxManufacture.Location = new System.Drawing.Point(107, 12);
|
||||
this.comboBoxManufacture.Name = "comboBoxManufacture";
|
||||
this.comboBoxManufacture.Size = new System.Drawing.Size(224, 23);
|
||||
this.comboBoxManufacture.TabIndex = 11;
|
||||
//
|
||||
// FormSellManufacture
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(347, 107);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSell);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelManufacture);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.comboBoxManufacture);
|
||||
this.Name = "FormSellManufacture";
|
||||
this.Text = "Продажа изделия";
|
||||
this.Load += new System.EventHandler(this.FormFillStore_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCancel;
|
||||
private Button buttonSell;
|
||||
private Label labelCount;
|
||||
private Label labelManufacture;
|
||||
private TextBox textBoxCount;
|
||||
private ComboBox comboBoxManufacture;
|
||||
}
|
||||
}
|
65
BlacksmithWorkshop/BlacksmithWorkshop/FormSellManufacture.cs
Normal file
65
BlacksmithWorkshop/BlacksmithWorkshop/FormSellManufacture.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using BlacksmithWorkshopContracts.BusinessLogicContracts;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
public partial class FormSellManufacture : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStoreLogic _logicS;
|
||||
private readonly IManufactureLogic _logicM;
|
||||
public FormSellManufacture(ILogger<FormCreateOrder> logger, IStoreLogic logicS, IManufactureLogic logicM)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicS = logicS;
|
||||
_logicM = logicM;
|
||||
}
|
||||
private void FormFillStore_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий");
|
||||
var listM = _logicM.ReadList(null);
|
||||
if (listM != null)
|
||||
{
|
||||
comboBoxManufacture.DisplayMember = "ManufactureName";
|
||||
comboBoxManufacture.ValueMember = "Id";
|
||||
comboBoxManufacture.DataSource = listM;
|
||||
comboBoxManufacture.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
private void ButtonSell_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxManufacture.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (Convert.ToInt32(textBoxCount.Text) <= 0)
|
||||
{
|
||||
MessageBox.Show("Количество должно быть больше нуля", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
var count = Convert.ToInt32(textBoxCount.Text);
|
||||
var manufacture = _logicM.ReadElement(new()
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxManufacture.SelectedValue)
|
||||
});
|
||||
if (manufacture == null || !_logicS.SellManufactures(manufacture, count))
|
||||
{
|
||||
MessageBox.Show("Не удалось продать изделия. Информацию смотрите в логах", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
206
BlacksmithWorkshop/BlacksmithWorkshop/FormStore.Designer.cs
generated
Normal file
206
BlacksmithWorkshop/BlacksmithWorkshop/FormStore.Designer.cs
generated
Normal file
@ -0,0 +1,206 @@
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
partial class FormStore
|
||||
{
|
||||
/// <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.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.labelAddress = new System.Windows.Forms.Label();
|
||||
this.labelName = new System.Windows.Forms.Label();
|
||||
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||
this.labelOpeningDate = new System.Windows.Forms.Label();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ColumnManufactureName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnPrice = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.textBoxMaxManufactures = new System.Windows.Forms.TextBox();
|
||||
this.labelMaxManufactures = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(316, 41);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 7;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.buttonSave.Location = new System.Drawing.Point(316, 12);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonSave.TabIndex = 8;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
this.labelAddress.AutoSize = true;
|
||||
this.labelAddress.Location = new System.Drawing.Point(17, 44);
|
||||
this.labelAddress.Name = "labelAddress";
|
||||
this.labelAddress.Size = new System.Drawing.Size(40, 15);
|
||||
this.labelAddress.TabIndex = 5;
|
||||
this.labelAddress.Text = "Адрес";
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
this.labelName.AutoSize = true;
|
||||
this.labelName.Location = new System.Drawing.Point(17, 15);
|
||||
this.labelName.Name = "labelName";
|
||||
this.labelName.Size = new System.Drawing.Size(59, 15);
|
||||
this.labelName.TabIndex = 6;
|
||||
this.labelName.Text = "Название";
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
this.textBoxAddress.Location = new System.Drawing.Point(82, 41);
|
||||
this.textBoxAddress.Name = "textBoxAddress";
|
||||
this.textBoxAddress.Size = new System.Drawing.Size(228, 23);
|
||||
this.textBoxAddress.TabIndex = 3;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(82, 12);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(228, 23);
|
||||
this.textBoxName.TabIndex = 4;
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
this.dateTimePicker.Location = new System.Drawing.Point(110, 76);
|
||||
this.dateTimePicker.Name = "dateTimePicker";
|
||||
this.dateTimePicker.Size = new System.Drawing.Size(200, 23);
|
||||
this.dateTimePicker.TabIndex = 9;
|
||||
//
|
||||
// labelOpeningDate
|
||||
//
|
||||
this.labelOpeningDate.AutoSize = true;
|
||||
this.labelOpeningDate.Location = new System.Drawing.Point(17, 76);
|
||||
this.labelOpeningDate.Name = "labelOpeningDate";
|
||||
this.labelOpeningDate.Size = new System.Drawing.Size(87, 15);
|
||||
this.labelOpeningDate.TabIndex = 5;
|
||||
this.labelOpeningDate.Text = "Дата открытия";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ColumnManufactureName,
|
||||
this.ColumnPrice,
|
||||
this.ColumnCount});
|
||||
this.dataGridView.Location = new System.Drawing.Point(17, 118);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(608, 450);
|
||||
this.dataGridView.TabIndex = 10;
|
||||
//
|
||||
// ColumnManufactureName
|
||||
//
|
||||
this.ColumnManufactureName.HeaderText = "Название";
|
||||
this.ColumnManufactureName.Name = "ColumnManufactureName";
|
||||
//
|
||||
// ColumnPrice
|
||||
//
|
||||
this.ColumnPrice.HeaderText = "Цена";
|
||||
this.ColumnPrice.Name = "ColumnPrice";
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
this.ColumnCount.HeaderText = "Количество";
|
||||
this.ColumnCount.Name = "ColumnCount";
|
||||
//
|
||||
// textBoxMaxManufactures
|
||||
//
|
||||
this.textBoxMaxManufactures.Location = new System.Drawing.Point(493, 15);
|
||||
this.textBoxMaxManufactures.Name = "textBoxMaxManufactures";
|
||||
this.textBoxMaxManufactures.Size = new System.Drawing.Size(132, 23);
|
||||
this.textBoxMaxManufactures.TabIndex = 4;
|
||||
//
|
||||
// labelMaxManufactures
|
||||
//
|
||||
this.labelMaxManufactures.AutoSize = true;
|
||||
this.labelMaxManufactures.Location = new System.Drawing.Point(400, 18);
|
||||
this.labelMaxManufactures.Name = "labelMaxManufactures";
|
||||
this.labelMaxManufactures.Size = new System.Drawing.Size(87, 15);
|
||||
this.labelMaxManufactures.TabIndex = 6;
|
||||
this.labelMaxManufactures.Text = "Макс. изделий";
|
||||
//
|
||||
// FormStore
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(641, 594);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.dateTimePicker);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.labelOpeningDate);
|
||||
this.Controls.Add(this.labelAddress);
|
||||
this.Controls.Add(this.labelMaxManufactures);
|
||||
this.Controls.Add(this.labelName);
|
||||
this.Controls.Add(this.textBoxAddress);
|
||||
this.Controls.Add(this.textBoxMaxManufactures);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Name = "FormStore";
|
||||
this.Text = "Магазин";
|
||||
this.Load += new System.EventHandler(this.FormStore_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private Label labelAddress;
|
||||
private Label labelName;
|
||||
private TextBox textBoxAddress;
|
||||
private TextBox textBoxName;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Label labelOpeningDate;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn ColumnManufactureName;
|
||||
private DataGridViewTextBoxColumn ColumnPrice;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
private TextBox textBoxMaxManufactures;
|
||||
private Label labelMaxManufactures;
|
||||
}
|
||||
}
|
140
BlacksmithWorkshop/BlacksmithWorkshop/FormStore.cs
Normal file
140
BlacksmithWorkshop/BlacksmithWorkshop/FormStore.cs
Normal file
@ -0,0 +1,140 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicContracts;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Reflection;
|
||||
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
public partial class FormStore : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStoreLogic _logicS;
|
||||
private readonly IComponentLogic _logicC;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormStore(ILogger<FormComponent> logger, IStoreLogic logicS, IComponentLogic logicC)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicS = logicS;
|
||||
_logicC = logicC;
|
||||
}
|
||||
private void FormStore_Load(object sender, EventArgs e)
|
||||
{
|
||||
dataGridView.Columns["ColumnManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение магазина");
|
||||
var view = _logicS.ReadElement(new StoreSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.StoreName;
|
||||
textBoxAddress.Text = view.Address;
|
||||
dateTimePicker.Value = view.OpeningDate;
|
||||
textBoxMaxManufactures.Text = view.MaxManufactures.ToString();
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
if (_id == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
var list = _logicS.ReadElement(new StoreSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
})?.Manufactures;
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var el in list)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { el.Value.Item1.ManufactureName, el.Value.Item1.Price, el.Value.Item2 });
|
||||
}
|
||||
}
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
}
|
||||
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(textBoxAddress.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxMaxManufactures.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните максимальное количество изделий", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
int maxManufactures;
|
||||
try//штоб программа не упала
|
||||
{
|
||||
maxManufactures = Convert.ToInt32(textBoxMaxManufactures.Text);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.Show("Неверное значение в поле Макс. изделий", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
try
|
||||
{
|
||||
var model = new StoreBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
StoreName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
OpeningDate = dateTimePicker.Value,
|
||||
MaxManufactures = maxManufactures
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logicS.Update(model) : _logicS.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();
|
||||
}
|
||||
}
|
||||
}
|
69
BlacksmithWorkshop/BlacksmithWorkshop/FormStore.resx
Normal file
69
BlacksmithWorkshop/BlacksmithWorkshop/FormStore.resx
Normal file
@ -0,0 +1,69 @@
|
||||
<root>
|
||||
<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>
|
||||
<metadata name="ColumnManufactureName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
115
BlacksmithWorkshop/BlacksmithWorkshop/FormStores.Designer.cs
generated
Normal file
115
BlacksmithWorkshop/BlacksmithWorkshop/FormStores.Designer.cs
generated
Normal file
@ -0,0 +1,115 @@
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
partial class FormStores
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.Windows.Forms.Button buttonRef;
|
||||
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();
|
||||
buttonRef = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
this.Load += new System.EventHandler(this.FormStores_Load);
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
buttonRef.Location = new System.Drawing.Point(620, 99);
|
||||
buttonRef.Name = "buttonRef";
|
||||
buttonRef.Size = new System.Drawing.Size(174, 23);
|
||||
buttonRef.TabIndex = 3;
|
||||
buttonRef.Text = "Обновить";
|
||||
buttonRef.UseVisualStyleBackColor = true;
|
||||
buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
this.buttonDel.Location = new System.Drawing.Point(620, 70);
|
||||
this.buttonDel.Name = "buttonDel";
|
||||
this.buttonDel.Size = new System.Drawing.Size(174, 23);
|
||||
this.buttonDel.TabIndex = 4;
|
||||
this.buttonDel.Text = "Удалить";
|
||||
this.buttonDel.UseVisualStyleBackColor = true;
|
||||
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
this.buttonUpd.Location = new System.Drawing.Point(620, 41);
|
||||
this.buttonUpd.Name = "buttonUpd";
|
||||
this.buttonUpd.Size = new System.Drawing.Size(174, 23);
|
||||
this.buttonUpd.TabIndex = 5;
|
||||
this.buttonUpd.Text = "Изменить";
|
||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(620, 12);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(174, 23);
|
||||
this.buttonAdd.TabIndex = 6;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(6, 0);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(608, 450);
|
||||
this.dataGridView.TabIndex = 2;
|
||||
//
|
||||
// FormStores
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(buttonRef);
|
||||
this.Controls.Add(this.buttonDel);
|
||||
this.Controls.Add(this.buttonUpd);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormStores";
|
||||
this.Text = "Магазины";
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
100
BlacksmithWorkshop/BlacksmithWorkshop/FormStores.cs
Normal file
100
BlacksmithWorkshop/BlacksmithWorkshop/FormStores.cs
Normal file
@ -0,0 +1,100 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicContracts;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
public partial class FormStores : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStoreLogic _logic;
|
||||
public FormStores(ILogger<FormComponents> logger, IStoreLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
private void FormStores_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["StoreName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Manufactures"].Visible = false;
|
||||
}
|
||||
_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(FormStore));
|
||||
if (service is FormStore 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(FormStore));
|
||||
if (service is FormStore 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 StoreBindingModel
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
63
BlacksmithWorkshop/BlacksmithWorkshop/FormStores.resx
Normal file
63
BlacksmithWorkshop/BlacksmithWorkshop/FormStores.resx
Normal file
@ -0,0 +1,63 @@
|
||||
<root>
|
||||
<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>
|
||||
<metadata name="buttonRef.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
</root>
|
@ -37,25 +37,32 @@ namespace BlacksmithWorkshopView
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IManufactureStorage, ManufactureStorage>();
|
||||
services.AddTransient<IStoreStorage, StoreStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IManufactureLogic, ManufactureLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IStoreLogic, StoreLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
services.AddTransient<FormComponents>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormManufacture>();
|
||||
services.AddTransient<FormManufactureComponent>();
|
||||
services.AddTransient<FormManufactures>();
|
||||
services.AddTransient<FormReportManufactureComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormClients>();
|
||||
}
|
||||
services.AddTransient<FormStore>();
|
||||
services.AddTransient<FormStores>();
|
||||
services.AddTransient<FormFillStore>();
|
||||
services.AddTransient<FormSellManufacture>();
|
||||
services.AddTransient<FormReportManufactureComponents>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormReportManufacturesInStore>();
|
||||
services.AddTransient<FormReportGroupOrders>();
|
||||
}
|
||||
}
|
||||
}
|
459
BlacksmithWorkshop/BlacksmithWorkshop/ReportGroupOrders.rdlc
Normal file
459
BlacksmithWorkshop/BlacksmithWorkshop/ReportGroupOrders.rdlc
Normal file
@ -0,0 +1,459 @@
|
||||
<?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="BlacksmithWorkshopContractsViewModels">
|
||||
<ConnectionProperties>
|
||||
<DataProvider>System.Data.DataSet</DataProvider>
|
||||
<ConnectString>/* Local Connection */</ConnectString>
|
||||
</ConnectionProperties>
|
||||
<rd:DataSourceID>10791c83-cee8-4a38-bbd0-245fc17cefb3</rd:DataSourceID>
|
||||
</DataSource>
|
||||
</DataSources>
|
||||
<DataSets>
|
||||
<DataSet Name="DataSetOrders">
|
||||
<Query>
|
||||
<DataSourceName>BlacksmithWorkshopContractsViewModels</DataSourceName>
|
||||
<CommandText>/* Local Query */</CommandText>
|
||||
</Query>
|
||||
<Fields>
|
||||
<Field Name="Date">
|
||||
<DataField>Date</DataField>
|
||||
<rd:TypeName>System.DateTime</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="Count">
|
||||
<DataField>Count</DataField>
|
||||
<rd:TypeName>System.Int32</rd:TypeName>
|
||||
</Field>
|
||||
<Field Name="Sum">
|
||||
<DataField>Sum</DataField>
|
||||
<rd:TypeName>System.Double</rd:TypeName>
|
||||
</Field>
|
||||
</Fields>
|
||||
<rd:DataSetInfo>
|
||||
<rd:DataSetName>BlacksmithWorkshopContracts.ViewModels</rd:DataSetName>
|
||||
<rd:TableName>ReportOrdersViewModel</rd:TableName>
|
||||
<rd:ObjectDataSourceType>BlacksmithWorkshopContracts.ViewModels.ReportOrdersViewModel, BlacksmithWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
||||
</rd:DataSetInfo>
|
||||
</DataSet>
|
||||
</DataSets>
|
||||
<ReportSections>
|
||||
<ReportSection>
|
||||
<Body>
|
||||
<ReportItems>
|
||||
<Textbox Name="ReportParameterPeriod">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Parameters!ReportParameterPeriod.Value</Value>
|
||||
<Style>
|
||||
<FontSize>14pt</FontSize>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Center</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>ReportParameterPeriod</rd:DefaultName>
|
||||
<Top>1cm</Top>
|
||||
<Height>1cm</Height>
|
||||
<Width>12.40104cm</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="TextboxTitle">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Заказы</Value>
|
||||
<Style>
|
||||
<FontSize>16pt</FontSize>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Center</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Height>1cm</Height>
|
||||
<Width>12.40104cm</Width>
|
||||
<ZIndex>1</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>None</Style>
|
||||
</Border>
|
||||
<VerticalAlign>Middle</VerticalAlign>
|
||||
<PaddingLeft>2pt</PaddingLeft>
|
||||
<PaddingRight>2pt</PaddingRight>
|
||||
<PaddingTop>2pt</PaddingTop>
|
||||
<PaddingBottom>2pt</PaddingBottom>
|
||||
</Style>
|
||||
</Textbox>
|
||||
<Tablix Name="Tablix1">
|
||||
<TablixBody>
|
||||
<TablixColumns>
|
||||
<TablixColumn>
|
||||
<Width>3.21438cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>3.53188cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>4.35209cm</Width>
|
||||
</TablixColumn>
|
||||
</TablixColumns>
|
||||
<TablixRows>
|
||||
<TablixRow>
|
||||
<Height>0.6cm</Height>
|
||||
<TablixCells>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Textbox1">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Дата создания</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox1</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="Textbox3">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Количество заказов</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox3</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="Textbox7">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Сумма</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox7</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>
|
||||
<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>
|
||||
<Format>d</Format>
|
||||
</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="Count">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!Count.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Count</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="Sum">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!Sum.Value</Value>
|
||||
<Style />
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Sum</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>DataSetOrders</DataSetName>
|
||||
<Top>2.48391cm</Top>
|
||||
<Left>0.55245cm</Left>
|
||||
<Height>1.2cm</Height>
|
||||
<Width>11.09835cm</Width>
|
||||
<ZIndex>2</ZIndex>
|
||||
<Style>
|
||||
<Border>
|
||||
<Style>Double</Style>
|
||||
</Border>
|
||||
</Style>
|
||||
</Tablix>
|
||||
<Textbox Name="TextboxTotalSum">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Итого:</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Right</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Top>4cm</Top>
|
||||
<Left>6.6508cm</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="SumTotal">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Sum(Fields!Sum.Value, "DataSetOrders")</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Right</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Top>4cm</Top>
|
||||
<Left>9.1508cm</Left>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>2.5cm</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>5.72875cm</Height>
|
||||
<Style />
|
||||
</Body>
|
||||
<Width>12.40104cm</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>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID>
|
||||
</Report>
|
@ -1,5 +1,6 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicContracts;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
@ -12,10 +13,14 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
private readonly IManufactureStorage _manufactureStorage;
|
||||
private readonly IStoreLogic _storeLogic;
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IManufactureStorage manufactureStorage, IStoreLogic storeLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_manufactureStorage = manufactureStorage;
|
||||
_storeLogic = storeLogic;
|
||||
}
|
||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||
{
|
||||
@ -39,6 +44,21 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
|
||||
model.Status = vm?.Status ?? OrderStatus.Неизвестен;
|
||||
if ((int)model.Status == (int)newstatus - 1)
|
||||
{
|
||||
if (newstatus == OrderStatus.Выдан)
|
||||
{
|
||||
if (vm == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var manufacture = _manufactureStorage.GetElement(new ManufactureSearchModel
|
||||
{
|
||||
Id = vm.ManufactureId
|
||||
});
|
||||
if (manufacture == null || !_storeLogic.FillStore(manufacture, vm.Count))
|
||||
{
|
||||
throw new Exception("Не удалось заполнить магазины");
|
||||
}
|
||||
}
|
||||
model.Status = newstatus;
|
||||
if (newstatus == OrderStatus.Готов)
|
||||
{
|
||||
@ -48,7 +68,7 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
_logger.LogWarning($"Changing order status of order {model.Id} to {newstatus} failed");
|
||||
return false;
|
||||
}
|
||||
|
@ -15,16 +15,18 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
|
||||
{
|
||||
private readonly IComponentStorage _componentStorage;
|
||||
private readonly IManufactureStorage _manufactureStorage;
|
||||
private readonly IStoreStorage _storeStorage;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly AbstractSaveToExcel _saveToExcel;
|
||||
private readonly AbstractSaveToWord _saveToWord;
|
||||
private readonly AbstractSaveToPdf _saveToPdf;
|
||||
public ReportLogic(IManufactureStorage manufactureStorage, IComponentStorage componentStorage, IOrderStorage orderStorage,
|
||||
public ReportLogic(IManufactureStorage manufactureStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, IStoreStorage storeStorage,
|
||||
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||
{
|
||||
_manufactureStorage = manufactureStorage;
|
||||
_componentStorage = componentStorage;
|
||||
_orderStorage = orderStorage;
|
||||
_storeStorage = storeStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
@ -57,6 +59,26 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
|
||||
}
|
||||
return list;
|
||||
}
|
||||
public List<ReportManufactureInStoreViewModel> GetManufacturesInStore()
|
||||
{
|
||||
var stores = _storeStorage.GetFullList();
|
||||
var result = new List<ReportManufactureInStoreViewModel>();
|
||||
foreach (var store in stores)
|
||||
{
|
||||
var record = new ReportManufactureInStoreViewModel()
|
||||
{
|
||||
StoreName = store.StoreName,
|
||||
MaxManufactures = store.MaxManufactures,
|
||||
HasManufactures = store.Manufactures.Select(x => x.Value.Item2).Sum()
|
||||
};
|
||||
foreach (var manufacture in store.Manufactures)
|
||||
{
|
||||
record.Manufactures.Add((manufacture.Value.Item1.ManufactureName.ToString(), manufacture.Value.Item2));
|
||||
}
|
||||
result.Add(record);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение списка заказов за определенный период
|
||||
/// </summary>
|
||||
@ -92,11 +114,24 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
|
||||
Manufactures = _manufactureStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение изделий с указаеним продуктов в файл-Excel
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void SaveManufactureComponentToExcelFile(ReportBindingModel model)
|
||||
/// <summary>
|
||||
/// Сохранение магазинов в файл-Word
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void SaveStoresToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDocStores(new WordInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список магазинов",
|
||||
Stores = _storeStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение изделий с указаеним продуктов в файл-Excel
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void SaveManufactureComponentToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelInfo
|
||||
{
|
||||
@ -106,10 +141,23 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение заказов в файл-Pdf
|
||||
/// Сохранение информации о магазинах в файл-Excel
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||
public void SaveStoresToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateStoresReport(new ExcelInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список магазинов",
|
||||
ManufacturesInStore = GetManufacturesInStore()
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение заказов в файл-Pdf
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfo
|
||||
{
|
||||
@ -120,5 +168,30 @@ namespace BlacksmithWorkShopBusinessLogic.BusinessLogics
|
||||
Orders = GetOrders(model)
|
||||
});
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение заказов по группам в файл-Pdf
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
public void SaveGroupOrdersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список заказов по датам",
|
||||
GroupOrders = GetGroupOrders()
|
||||
});
|
||||
}
|
||||
public List<ReportGroupOrdersViewModel> GetGroupOrders()
|
||||
{
|
||||
return _orderStorage.GetFullList()
|
||||
.GroupBy(x => x.DateCreate.Date)
|
||||
.Select(x => new ReportGroupOrdersViewModel
|
||||
{
|
||||
Date = x.Key,
|
||||
Count = x.Count(),
|
||||
Sum = x.Sum(y => y.Sum)
|
||||
}).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,228 @@
|
||||
using BlacksmithWorkShopBusinessLogic.BusinessLogics;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class StoreLogic : IStoreLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStoreStorage _storeStorage;
|
||||
public StoreLogic(ILogger<ComponentLogic> logger, IStoreStorage storeStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_storeStorage = storeStorage;
|
||||
}
|
||||
public List<StoreViewModel>? ReadList(StoreSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("Readlist. StoreName: {Storename}. Id: {Id}", model?.StoreName, model?.Id);
|
||||
var list = model == null ? _storeStorage.GetFullList() : _storeStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("Readlist. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public StoreViewModel? ReadElement(StoreSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. StoreName: {StoreName}. Id: {Id}", model.StoreName, model.Id);
|
||||
var element = _storeStorage.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(StoreBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_storeStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(StoreBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_storeStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(StoreBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_storeStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void SaveChanges(StoreViewModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_storeStorage.Update(new StoreBindingModel()
|
||||
{
|
||||
Id = model.Id,
|
||||
StoreName = model.StoreName,
|
||||
Address = model.Address,
|
||||
OpeningDate = model.OpeningDate,
|
||||
Manufactures = model.Manufactures,
|
||||
});
|
||||
}
|
||||
public bool AddManufacture(IManufactureModel manufacture, StoreSearchModel model, int count)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException("Невозможно найти магазин", nameof(model));
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Количество добавляемых изделий должно быть больше нуля");
|
||||
}
|
||||
_logger.LogInformation("Adding manufacture {manufacture} in store {store}. Id = {id}", manufacture.ManufactureName, model.StoreName, model.Id);
|
||||
//ищем магазин
|
||||
StoreViewModel? selectedStore = _storeStorage.GetElement(model);
|
||||
if (selectedStore == null)
|
||||
{
|
||||
_logger.LogWarning("Store with id {Id} not found", model.Id);
|
||||
return false;
|
||||
}
|
||||
var placeLeft = _storeStorage.GetPlaceLeft(selectedStore);
|
||||
if (placeLeft < count)
|
||||
{
|
||||
_logger.LogWarning("Store with id {Id} can't accomodate {Count} items", model.Id, count);
|
||||
return false;
|
||||
}
|
||||
//ищем изделие в магазине
|
||||
if (selectedStore.Manufactures.TryGetValue(manufacture.Id, out var manufactureInStore))
|
||||
{
|
||||
selectedStore.Manufactures[manufacture.Id] = (manufacture, manufactureInStore.Item2 + count);//если изделие уже есть в магазине, увеличиваем его количество
|
||||
_logger.LogInformation("Filled store Id = {storeId} with manufacture Id = {manufactureId}. Count = {count}", model.Id, manufacture.Id, count);
|
||||
SaveChanges(selectedStore);
|
||||
return true;
|
||||
}
|
||||
//иначе добавляем изделие в магазин в указанном количестве
|
||||
selectedStore.Manufactures.Add(manufacture.Id, (manufacture, count));
|
||||
SaveChanges(selectedStore);
|
||||
_logger.LogInformation("Added new manufacture Id = {manufactureId} in store Id = {storeId}. Count = {count}", manufacture.Id, model.Id, count);
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(StoreBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.StoreName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия магазина", nameof(model.StoreName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Address))
|
||||
{
|
||||
throw new ArgumentNullException("Нет адреса магазина", nameof(model.StoreName));
|
||||
}
|
||||
_logger.LogInformation("Store. StoreName: {StoreName}. Address: {Address}. Id: {Id}", model.StoreName, model.Address, model.Id);
|
||||
var element = _storeStorage.GetElement(new StoreSearchModel
|
||||
{
|
||||
StoreName = model.StoreName
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
if (model.MaxManufactures <= 0)
|
||||
{
|
||||
throw new ArgumentException("Максимальное количество изделий не может быть меньше единицы", nameof(model.MaxManufactures));
|
||||
}
|
||||
}
|
||||
public int GetFreePlace(int count)
|
||||
{
|
||||
int result;
|
||||
var stores = _storeStorage.GetFullList();
|
||||
result = stores//Получаем общее число свободных мест в магазине
|
||||
.Select(x => x.MaxManufactures/*максимальное число мест в магазине*/ - x.Manufactures.Select(m => m.Value.Item2).Sum()).Sum()/*количество занятых мест до добавления изделия*/;
|
||||
result -= count;//Получаем общее число свободных мест после добавления изделия
|
||||
return result;
|
||||
}
|
||||
public bool FillStore(IManufactureModel manufacture, int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
_logger.LogWarning("Количество добавляемых изделий должно быть больше 0.");
|
||||
return false;
|
||||
}
|
||||
var freePlaces = GetFreePlace(count);
|
||||
if (freePlaces < 0)
|
||||
{
|
||||
_logger.LogInformation("Магазины переполнены.");
|
||||
return false;
|
||||
}
|
||||
foreach (var store in _storeStorage.GetFullList())//добавляем изделие во все магазины
|
||||
{
|
||||
var cnt = Math.Min(count, store.MaxManufactures - store.Manufactures.Select(x => x.Value.Item2).Sum());
|
||||
if (cnt <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!AddManufacture(manufacture, new StoreSearchModel()
|
||||
{
|
||||
Id = store.Id
|
||||
}, cnt))
|
||||
{
|
||||
_logger.LogWarning("При добавлении изделий произошла ошибка");
|
||||
return false;
|
||||
}
|
||||
count -= cnt;
|
||||
if (count == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool SellManufactures(IManufactureModel manufacture, int count)
|
||||
{
|
||||
return _storeStorage.SellManufacture(manufacture, count);
|
||||
}
|
||||
public List<ManufactureInStoreViewModel> ReadManufacturesInStore(StoreSearchModel? model)
|
||||
{
|
||||
if (model != null)
|
||||
{
|
||||
var result = _storeStorage.GetManufacturesInStore(model);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums;
|
||||
using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml.Drawing;
|
||||
|
||||
namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
{
|
||||
@ -109,11 +110,95 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
}
|
||||
SaveExcel(info);
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание excel-файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void CreateExcel(ExcelInfo info);
|
||||
/// <summary>
|
||||
/// Создание отчета
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
public void CreateStoresReport(ExcelInfo 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 MIS in info.ManufacturesInStore)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = MIS.StoreName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = "Изделие",
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = "Количество",
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
rowIndex++;
|
||||
foreach (var rec in MIS.Manufactures)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = rec.Item1,
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = rec.Item2.ToString(),
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
rowIndex++;
|
||||
}
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = "Заполнено",
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = $"{MIS.HasManufactures} из {MIS.MaxManufactures}",
|
||||
StyleInfo =
|
||||
ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
rowIndex++;
|
||||
}
|
||||
SaveExcel(info);
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание excel-файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void CreateExcel(ExcelInfo info);
|
||||
/// <summary>
|
||||
/// Добавляем новую ячейку в лист
|
||||
/// </summary>
|
||||
|
@ -3,72 +3,98 @@ using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels;
|
||||
|
||||
namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToPdf
|
||||
{
|
||||
public void CreateDoc(PdfInfo info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = info.Title,
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма", "Статус" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var order in info.Orders)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.ManufactureName, order.Sum.ToString(), order.Status },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
||||
});
|
||||
SavePdf(info);
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание doc-файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
/// <summary>
|
||||
/// Создание параграфа с текстом
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="style"></param>
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
/// <summary>
|
||||
/// Создание таблицы
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="style"></param>
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
/// <summary>
|
||||
/// Создание и заполнение строки
|
||||
/// </summary>
|
||||
/// <param name="rowParameters"></param>
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
/// <summary>
|
||||
/// Сохранение файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
}
|
||||
public abstract class AbstractSaveToPdf
|
||||
{
|
||||
public void CreateDoc(PdfInfo info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = info.Title,
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
if (info.Orders.Count != 0)
|
||||
{
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма", "Статус" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var order in info.Orders)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.ManufactureName, order.Sum.ToString(), order.Status },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
||||
});
|
||||
}
|
||||
else if (info.GroupOrders.Count != 0)
|
||||
{
|
||||
CreateTable(new List<string> { "3cm", "4cm", "5cm" });
|
||||
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Дата", "Количество", "Сумма" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
foreach (var order in info.GroupOrders)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { order.Date.ToShortDateString(), order.Count.ToString(), order.Sum.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.GroupOrders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right });
|
||||
}
|
||||
SavePdf(info);
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание doc-файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
/// <summary>
|
||||
/// Создание параграфа с текстом
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="style"></param>
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
/// <summary>
|
||||
/// Создание таблицы
|
||||
/// </summary>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="style"></param>
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
/// <summary>
|
||||
/// Создание и заполнение строки
|
||||
/// </summary>
|
||||
/// <param name="rowParameters"></param>
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
/// <summary>
|
||||
/// Сохранение файла
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
}
|
||||
}
|
||||
|
@ -37,8 +37,39 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
}
|
||||
});
|
||||
}
|
||||
SaveWord(info);
|
||||
SaveWord(info);
|
||||
}
|
||||
public void CreateDocStores(WordInfo 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()
|
||||
{
|
||||
("Название", 3000),
|
||||
("Дата", null),
|
||||
("Адрес открытия", 4500),
|
||||
},
|
||||
info.Stores
|
||||
.Select(x => new List<string>
|
||||
{
|
||||
x.StoreName,
|
||||
Convert.ToString(x.OpeningDate),
|
||||
x.Address,
|
||||
})
|
||||
.ToList());
|
||||
SaveWord(info);
|
||||
}
|
||||
/// <summary>
|
||||
/// Создание doc-файла
|
||||
/// </summary>
|
||||
@ -55,6 +86,6 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
/// </summary>
|
||||
/// <param name="info"></param>
|
||||
protected abstract void SaveWord(WordInfo info);
|
||||
|
||||
}
|
||||
protected abstract void CreateTable(List<(string, int?)> nameAndWidthColumns, List<List<string>> rows);
|
||||
}
|
||||
}
|
||||
|
@ -7,5 +7,6 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ReportManufactureComponentViewModel> ManufactureComponents { get; set; } = new();
|
||||
public List<ReportManufactureInStoreViewModel> ManufacturesInStore { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -9,5 +9,6 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
public DateTime DateFrom { get; set; }
|
||||
public DateTime DateTo { get; set; }
|
||||
public List<ReportOrdersViewModel> Orders { get; set; } = new();
|
||||
public List<ReportGroupOrdersViewModel> GroupOrders { get; set; } = new();
|
||||
}
|
||||
}
|
@ -7,5 +7,6 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
public string FileName { get; set; } = string.Empty;
|
||||
public string Title { get; set; } = string.Empty;
|
||||
public List<ManufactureViewModel> Manufactures { get; set; } = new();
|
||||
public List<StoreViewModel> Stores { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -117,5 +117,43 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
|
||||
_wordDocument.MainDocumentPart!.Document.Save();
|
||||
_wordDocument.Close();
|
||||
}
|
||||
}
|
||||
private static TableCell GetTableCell(string text, int? widthCell = null)
|
||||
{
|
||||
|
||||
TableCell cell = new(new Paragraph(new Run(new Text(text))));
|
||||
if (widthCell != null)
|
||||
{
|
||||
cell.Append(new TableCellProperties()
|
||||
{
|
||||
TableCellWidth = new() { Width = widthCell.ToString() }
|
||||
});
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
protected override void CreateTable(List<(string, int?)> nameAndWidthColumns, List<List<string>> rows)
|
||||
{
|
||||
if (_docBody == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Table table = new();
|
||||
TableProperties tblProp = new TableProperties(
|
||||
new TableBorders(
|
||||
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.BasicBlackDashes), Size = 3 },
|
||||
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.BasicBlackDashes), Size = 3 },
|
||||
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.BasicBlackDashes), Size = 3 },
|
||||
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.BasicBlackDashes), Size = 3 },
|
||||
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.BasicBlackDashes), Size = 3 },
|
||||
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.BasicBlackDashes), Size = 3 }
|
||||
)
|
||||
);
|
||||
table.AppendChild(tblProp);
|
||||
|
||||
table.Append(new TableRow(nameAndWidthColumns.Select(x => GetTableCell(x.Item1, x.Item2))));
|
||||
|
||||
table.Append(rows.Select(x => new TableRow(x.Select(y => GetTableCell(y)))));
|
||||
|
||||
_docBody.Append(table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return
|
||||
View(APIClient.GetRequest<List<OrderViewModel>>($"https://localhost:7195/api/main/getorders?clientId={APIClient.Client.Id}"));
|
||||
View(APIClient.GetRequest<List<OrderViewModel>>($"api/main/getorders?clientId={APIClient.Client.Id}"));
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
@ -43,7 +43,7 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
APIClient.PostRequest("https://localhost:7195/api/client/updatedata", new
|
||||
APIClient.PostRequest("api/client/updatedata", new
|
||||
ClientBindingModel
|
||||
{
|
||||
Id = APIClient.Client.Id,
|
||||
@ -80,7 +80,7 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
throw new Exception("Введите логин и пароль");
|
||||
}
|
||||
APIClient.Client =
|
||||
APIClient.GetRequest<ClientViewModel>($"https://localhost:7195/api/client/login?login={login}&password={password}");
|
||||
APIClient.GetRequest<ClientViewModel>($"api/client/login?login={login}&password={password}");
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Неверный логин/пароль");
|
||||
@ -99,7 +99,7 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
{
|
||||
throw new Exception("Введите логин, пароль и ФИО");
|
||||
}
|
||||
APIClient.PostRequest("https://localhost:7195/api/client/register", new
|
||||
APIClient.PostRequest("api/client/register", new
|
||||
ClientBindingModel
|
||||
{
|
||||
ClientFIO = fio,
|
||||
@ -113,7 +113,7 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
public IActionResult Create()
|
||||
{
|
||||
ViewBag.Manufactures =
|
||||
APIClient.GetRequest<List<ManufactureViewModel>>("https://localhost:7195/api/main/getmanufacturelist");
|
||||
APIClient.GetRequest<List<ManufactureViewModel>>("api/main/getmanufacturelist");
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
@ -127,7 +127,7 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
{
|
||||
throw new Exception("Количество и сумма должны быть больше 0");
|
||||
}
|
||||
APIClient.PostRequest("https://localhost:7195/api/main/createorder", new
|
||||
APIClient.PostRequest("api/main/createorder", new
|
||||
OrderBindingModel
|
||||
{
|
||||
ClientId = APIClient.Client.Id,
|
||||
@ -141,7 +141,7 @@ namespace BlacksmithWorkshopClientApp.Controllers
|
||||
public double Calc(int count, int manufacture)
|
||||
{
|
||||
var manuf =
|
||||
APIClient.GetRequest<ManufactureViewModel>($"https://localhost:7195/api/main/getmanufacture?manufactureId={manufacture}"
|
||||
APIClient.GetRequest<ManufactureViewModel>($"api/main/getmanufacture?manufactureId={manufacture}"
|
||||
);
|
||||
return count * (manuf?.Price ?? 1);
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
using BlacksmithWorkshopClientApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
@ -13,6 +15,8 @@ if (!app.Environment.IsDevelopment())
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
APIClient.Connect(builder.Configuration);
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
namespace BlacksmithWorkshopContracts.BindingModels
|
||||
{
|
||||
public class FillingStoreBindingModel
|
||||
{
|
||||
public int Store { get; set; }
|
||||
public int Manufacture { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BindingModels
|
||||
{
|
||||
public class StoreBindingModel : IStoreModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string StoreName { get; set; } = string.Empty;
|
||||
public string Address { get; set; } = string.Empty;
|
||||
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// Изделия в магазине
|
||||
/// </summary>
|
||||
public Dictionary<int, (IManufactureModel, int)> Manufactures { get; set; } = new();
|
||||
public int MaxManufactures { get; set; }
|
||||
}
|
||||
}
|
@ -17,6 +17,12 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
/// <returns></returns>
|
||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Получение списка изделий в магазине
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
List<ReportManufactureInStoreViewModel> GetManufacturesInStore();
|
||||
/// <summary>
|
||||
/// Сохранение компонент в файл-Word
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
@ -31,5 +37,21 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
/// <summary>
|
||||
/// Сохранение магазинов в файл-Word
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveStoresToWordFile(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Сохранение магазинов в файл-Excel
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
void SaveStoresToExcelFile(ReportBindingModel model);
|
||||
/// <summary>
|
||||
/// Получение группированного списка заказов
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
List<ReportGroupOrdersViewModel> GetGroupOrders();
|
||||
void SaveGroupOrdersToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IStoreLogic
|
||||
{
|
||||
List<StoreViewModel>? ReadList(StoreSearchModel? model);
|
||||
StoreViewModel? ReadElement(StoreSearchModel model);
|
||||
bool Create(StoreBindingModel model);
|
||||
bool Update(StoreBindingModel model);
|
||||
bool Delete(StoreBindingModel model);
|
||||
/// <summary>
|
||||
/// Добавление изделия в магазин
|
||||
/// </summary>
|
||||
/// <param name="manufacture">Изделие</param>
|
||||
/// <param name="model">Модель для поиска нужного магазина</param>
|
||||
/// <param name="count">Количество изделий</param>
|
||||
/// <returns></returns>
|
||||
bool AddManufacture(IManufactureModel manufacture, StoreSearchModel model, int count);
|
||||
int GetFreePlace(int count);
|
||||
bool FillStore(IManufactureModel manufacture, int count);
|
||||
public bool SellManufactures(IManufactureModel manufacture, int needCount);
|
||||
public List<ManufactureInStoreViewModel> ReadManufacturesInStore(StoreSearchModel? model);
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace BlacksmithWorkshopContracts.SearchModels
|
||||
{
|
||||
public class StoreSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? StoreName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.StoragesContracts
|
||||
{
|
||||
public interface IStoreStorage
|
||||
{
|
||||
List<StoreViewModel> GetFullList();
|
||||
List<StoreViewModel> GetFilteredList(StoreSearchModel model);
|
||||
StoreViewModel? GetElement(StoreSearchModel model);
|
||||
StoreViewModel? Insert(StoreBindingModel model);
|
||||
StoreViewModel? Update(StoreBindingModel model);
|
||||
StoreViewModel? Delete(StoreBindingModel model);
|
||||
/// <summary>
|
||||
/// Проверка наличия изделия в нужном количестве
|
||||
/// </summary>
|
||||
/// <param name="manufacture">Изделие</param>
|
||||
/// <param name="count">Количество</param>
|
||||
/// <returns></returns>
|
||||
bool HasManufactures(IManufactureModel manufacture, int count);
|
||||
/// <summary>
|
||||
/// Продажа изделия в нужном количестве
|
||||
/// </summary>
|
||||
/// <param name="manufacture">Изделие</param>
|
||||
/// <param name="count">Количество</param>
|
||||
/// <returns></returns>
|
||||
bool SellManufacture(IManufactureModel manufacture, int count);
|
||||
int GetPlaceLeft(IStoreModel store);
|
||||
List<ManufactureInStoreViewModel> GetManufacturesInStore(StoreSearchModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace BlacksmithWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ManufactureInStoreViewModel
|
||||
{
|
||||
public string ManufactureName { get; set; } = string.Empty;
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace BlacksmithWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ReportGroupOrdersViewModel
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public int Count { get; set; }
|
||||
public double Sum { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
namespace BlacksmithWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ReportManufactureInStoreViewModel
|
||||
{
|
||||
public string StoreName { get; set; } = string.Empty;
|
||||
public int MaxManufactures { get; set; }
|
||||
public int HasManufactures { get; set; }
|
||||
public List<(string, int)> Manufactures { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.ViewModels
|
||||
{
|
||||
public class StoreViewModel : IStoreModel
|
||||
{
|
||||
[DisplayName("Номер магазина")]
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название магазина")]
|
||||
public string StoreName { get; set; } = string.Empty;
|
||||
[DisplayName("Адрес магазина")]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime OpeningDate { get; set; } = DateTime.Now;
|
||||
/// <summary>
|
||||
/// Изделия в магазине
|
||||
/// </summary>
|
||||
public Dictionary<int, (IManufactureModel, int)> Manufactures { get; set; } = new();
|
||||
[DisplayName("Макс. изделий")]
|
||||
public int MaxManufactures { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
namespace BlacksmithWorkshopDataModels.Models
|
||||
{
|
||||
public interface IStoreModel : IId
|
||||
{
|
||||
string StoreName { get; }
|
||||
string Address { get; }
|
||||
DateTime OpeningDate { get; }
|
||||
Dictionary<int, (IManufactureModel, int)> Manufactures { get; }
|
||||
int MaxManufactures { get; }
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ namespace BlacksmithWorkshopDatabaseImplement
|
||||
optionsBuilder.UseSqlServer
|
||||
(
|
||||
@"Data Source=IGORS_2011;
|
||||
Initial Catalog=BlacksmithWorkshopDatabaseFull;
|
||||
Initial Catalog=BlacksmithWorkshopDatabaseFullAdv;
|
||||
Integrated Security=True;
|
||||
MultipleActiveResultSets=True;
|
||||
TrustServerCertificate=True"
|
||||
@ -24,6 +24,8 @@ namespace BlacksmithWorkshopDatabaseImplement
|
||||
public virtual DbSet<Manufacture> Manufactures { set; get; }
|
||||
public virtual DbSet<ManufactureComponent> ManufactureComponents { set; get; }
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
}
|
||||
public virtual DbSet<Store> Stores { set; get; }
|
||||
public virtual DbSet<ManufactureInStore> ManufacturesInStore { set; get; }
|
||||
public virtual DbSet<Client> Clients { set; get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDatabaseImplement;
|
||||
using BlacksmithWorkshopDatabaseImplement.Models;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
{
|
||||
public class StoreStorage : IStoreStorage
|
||||
{
|
||||
public StoreViewModel? Delete(StoreBindingModel model)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
var element = context.Stores.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Stores.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public StoreViewModel? GetElement(StoreSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
return context.Stores
|
||||
.Include(x => x.ManufacturesInStore)
|
||||
.ThenInclude(x => x.Manufacture)
|
||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public List<StoreViewModel> GetFilteredList(StoreSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.StoreName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
return context.Stores
|
||||
.Include(x => x.ManufacturesInStore)
|
||||
.ThenInclude(x => x.Manufacture)
|
||||
.Select(x => x.GetViewModel)
|
||||
.Where(x => x.StoreName.Contains(model.StoreName ?? string.Empty))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<StoreViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
return context.Stores
|
||||
.Include(x => x.ManufacturesInStore)
|
||||
.ThenInclude(x => x.Manufacture)
|
||||
.Select(shop => shop.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public StoreViewModel? Insert(StoreBindingModel model)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
try
|
||||
{
|
||||
var newShop = Store.Create(context, model);
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (context.Stores.Any(x => x.StoreName == newShop.StoreName))
|
||||
{
|
||||
throw new Exception("Не должно быть два магазина с одним названием");
|
||||
}
|
||||
context.Stores.Add(newShop);
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public StoreViewModel? Update(StoreBindingModel model)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
var store = context.Stores.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (store == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
store.Update(model);
|
||||
if (model.Manufactures.Count != 0)
|
||||
{
|
||||
store.UpdateManufactures(context, model);
|
||||
}
|
||||
context.SaveChanges();
|
||||
return store.GetViewModel;
|
||||
}
|
||||
|
||||
public bool HasManufactures(IManufactureModel manufacture, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool SellManufacture(IManufactureModel manufacture, int count)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
foreach (var MIS in context.ManufacturesInStore.Where(x => x.ManufactureId == manufacture.Id))
|
||||
{
|
||||
var res = Math.Min(count, MIS.Count);
|
||||
MIS.Count -= res;
|
||||
count -= res;
|
||||
if (MIS.Count == 0)
|
||||
{
|
||||
context.ManufacturesInStore.Remove(MIS);
|
||||
}
|
||||
if (count == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (count == 0)
|
||||
{
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
transaction.Rollback();
|
||||
}
|
||||
return count == 0;
|
||||
}
|
||||
|
||||
public int GetPlaceLeft(IStoreModel store)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
var selectedStore = context.Stores.FirstOrDefault(x => x.Id == store.Id);
|
||||
if (selectedStore == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return selectedStore.MaxManufactures - selectedStore.Manufactures.Select(x => x.Value.Item2).Sum();
|
||||
}
|
||||
|
||||
public List<ManufactureInStoreViewModel> GetManufacturesInStore(StoreSearchModel model)
|
||||
{
|
||||
var store = GetElement(model);
|
||||
List<ManufactureInStoreViewModel> result = store?.Manufactures.Select(x => new ManufactureInStoreViewModel() { ManufactureName = x.Value.Item1.ManufactureName, Count = x.Value.Item2}).ToList() ?? new();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatebaseImplement.Migrations
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BlacksmithWorkshopDatabase))]
|
||||
[Migration("20230326142752_InitMigration")]
|
||||
|
@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatebaseImplement.Migrations
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitMigration : Migration
|
||||
|
@ -0,0 +1,246 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BlacksmithWorkshopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BlacksmithWorkshopDatabase))]
|
||||
[Migration("20230509130456_Lab3AdvMigration")]
|
||||
partial class Lab3AdvMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ManufactureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Manufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.ToTable("ManufactureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureInStore", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("StoreId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.HasIndex("StoreId");
|
||||
|
||||
b.ToTable("ManufacturesInStore");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Store", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MaxManufactures")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("OpeningDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("StoreName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Stores");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ManufactureComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureInStore", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany()
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Store", "Store")
|
||||
.WithMany("ManufacturesInStore")
|
||||
.HasForeignKey("StoreId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
|
||||
b.Navigation("Store");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", null)
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ManufactureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Store", b =>
|
||||
{
|
||||
b.Navigation("ManufacturesInStore");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Lab3AdvMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Stores",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
StoreName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
OpeningDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
MaxManufactures = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Stores", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ManufacturesInStore",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ManufactureId = table.Column<int>(type: "int", nullable: false),
|
||||
StoreId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ManufacturesInStore", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ManufacturesInStore_Manufactures_ManufactureId",
|
||||
column: x => x.ManufactureId,
|
||||
principalTable: "Manufactures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ManufacturesInStore_Stores_StoreId",
|
||||
column: x => x.StoreId,
|
||||
principalTable: "Stores",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ManufacturesInStore_ManufactureId",
|
||||
table: "ManufacturesInStore",
|
||||
column: "ManufactureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ManufacturesInStore_StoreId",
|
||||
table: "ManufacturesInStore",
|
||||
column: "StoreId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ManufacturesInStore");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Stores");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,289 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using BlacksmithWorkshopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BlacksmithWorkshopDatabase))]
|
||||
[Migration("20230606173901_Lab5AdvMigration")]
|
||||
partial class Lab5AdvMigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ClientFIO")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Clients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ManufactureName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Manufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.ToTable("ManufactureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureInStore", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("StoreId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.HasIndex("StoreId");
|
||||
|
||||
b.ToTable("ManufacturesInStore");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Store", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MaxManufactures")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("OpeningDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("StoreName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Stores");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("ManufactureComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureInStore", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany()
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Store", "Store")
|
||||
.WithMany("ManufacturesInStore")
|
||||
.HasForeignKey("StoreId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
|
||||
b.Navigation("Store");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", null)
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("ManufactureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Store", b =>
|
||||
{
|
||||
b.Navigation("ManufacturesInStore");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Lab5AdvMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatebaseImplement.Migrations
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(BlacksmithWorkshopDatabase))]
|
||||
partial class BlacksmithWorkshopDatabaseModelSnapshot : ModelSnapshot
|
||||
@ -113,6 +113,32 @@ namespace BlacksmithWorkshopDatebaseImplement.Migrations
|
||||
b.ToTable("ManufactureComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureInStore", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ManufactureId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("StoreId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.HasIndex("StoreId");
|
||||
|
||||
b.ToTable("ManufacturesInStore");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -151,6 +177,33 @@ namespace BlacksmithWorkshopDatebaseImplement.Migrations
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Store", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("MaxManufactures")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("OpeningDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<string>("StoreName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Stores");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureComponent", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Component", "Component")
|
||||
@ -170,6 +223,25 @@ namespace BlacksmithWorkshopDatebaseImplement.Migrations
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureInStore", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany()
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Store", "Store")
|
||||
.WithMany("ManufacturesInStore")
|
||||
.HasForeignKey("StoreId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
|
||||
b.Navigation("Store");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client")
|
||||
@ -203,6 +275,11 @@ namespace BlacksmithWorkshopDatebaseImplement.Migrations
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Store", b =>
|
||||
{
|
||||
b.Navigation("ManufacturesInStore");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
{
|
||||
public class ManufactureInStore
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public int ManufactureId { get; set; }
|
||||
[Required]
|
||||
public int StoreId { get; set; }
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
public virtual Store Store { get; set; } = new();
|
||||
public virtual Manufacture Manufacture { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
{
|
||||
public class Store : IStoreModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string StoreName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public DateTime OpeningDate { get; private set; }
|
||||
[Required]
|
||||
public int MaxManufactures { get; private set; }
|
||||
private Dictionary<int, (IManufactureModel, int)>? _manufactures = null;
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IManufactureModel, int)> Manufactures
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_manufactures == null)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
_manufactures = ManufacturesInStore
|
||||
.ToDictionary(x => x.ManufactureId, x => (context.Manufactures
|
||||
.FirstOrDefault(y => y.Id == x.ManufactureId)! as IManufactureModel, x.Count));
|
||||
}
|
||||
return _manufactures;
|
||||
}
|
||||
}
|
||||
[ForeignKey("StoreId")]
|
||||
public virtual List<ManufactureInStore> ManufacturesInStore { get; set; } = new();
|
||||
|
||||
public static Store? Create(BlacksmithWorkshopDatabase context, StoreBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Store()
|
||||
{
|
||||
Id = model.Id,
|
||||
StoreName = model.StoreName,
|
||||
Address = model.Address,
|
||||
OpeningDate = model.OpeningDate,
|
||||
MaxManufactures = model.MaxManufactures,
|
||||
ManufacturesInStore = model.Manufactures.Select(x => new ManufactureInStore
|
||||
{
|
||||
Manufacture = context.Manufactures.FirstOrDefault(y => y.Id == x.Key)!,
|
||||
Count = x.Value.Item2,
|
||||
}).ToList()
|
||||
};
|
||||
}
|
||||
public void Update(StoreBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
StoreName = model.StoreName;
|
||||
Address = model.Address;
|
||||
OpeningDate = model.OpeningDate;
|
||||
}
|
||||
public StoreViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
StoreName = StoreName,
|
||||
Address = Address,
|
||||
Manufactures = Manufactures,
|
||||
OpeningDate = OpeningDate,
|
||||
MaxManufactures = MaxManufactures,
|
||||
};
|
||||
|
||||
public void UpdateManufactures(BlacksmithWorkshopDatabase context, StoreBindingModel model)
|
||||
{
|
||||
var manufacturesInStore = context.ManufacturesInStore
|
||||
.Where(rec => rec.StoreId == model.Id)
|
||||
.ToList();
|
||||
// удалили те, которых нет в модели
|
||||
if (manufacturesInStore != null && manufacturesInStore.Count > 0)
|
||||
{
|
||||
context.ManufacturesInStore
|
||||
.RemoveRange(manufacturesInStore
|
||||
.Where(rec => !model.Manufactures
|
||||
.ContainsKey(rec.ManufactureId)));
|
||||
// обновили количество у существующих записей
|
||||
foreach (var updateManufacture in manufacturesInStore.Where(x => model.Manufactures.ContainsKey(x.ManufactureId)))
|
||||
{
|
||||
updateManufacture.Count = model.Manufactures[updateManufacture.ManufactureId].Item2;
|
||||
model.Manufactures.Remove(updateManufacture.ManufactureId);
|
||||
}
|
||||
}
|
||||
var store = context.Stores.First(x => x.Id == model.Id);
|
||||
store.ManufacturesInStore.AddRange(model.Manufactures.Select(x => new ManufactureInStore
|
||||
{
|
||||
Manufacture = context.Manufactures.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2,
|
||||
}).Except(manufacturesInStore ?? new()));
|
||||
context.SaveChanges();
|
||||
_manufactures = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -8,10 +8,12 @@ namespace BlacksmithWorkshopFileImplement
|
||||
private readonly string ComponentFileName = "Component.xml";
|
||||
private readonly string OrderFileName = "Order.xml";
|
||||
private readonly string ManufactureFileName = "Manufacture.xml";
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
private readonly string StoreFileName = "Store.xml";
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
public List<Component> Components { get; private set; }
|
||||
public List<Order> Orders { get; private set; }
|
||||
public List<Manufacture> Manufactures { get; private set; }
|
||||
public List<Store> Stores { get; private set; }
|
||||
public List<Client> Clients { get; private set; }
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
@ -24,14 +26,16 @@ namespace BlacksmithWorkshopFileImplement
|
||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||
public void SaveManufactures() => SaveData(Manufactures, ManufactureFileName, "Manufactures", x => x.GetXElement);
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||
private DataFileSingleton()
|
||||
public void SaveStores() => SaveData(Stores, StoreFileName, "Stores", x => x.GetXElement);
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||
private DataFileSingleton()
|
||||
{
|
||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||
Manufactures = LoadData(ManufactureFileName, "Manufacture", x => Manufacture.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||
}
|
||||
Stores = LoadData(StoreFileName, "Store", x => Store.Create(x)!)!;
|
||||
Clients = LoadData(StoreFileName, "Client", x => Client.Create(x)!)!;
|
||||
}
|
||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||
{
|
||||
if (File.Exists(filename))
|
||||
|
@ -0,0 +1,132 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using BlacksmithWorkshopFileImplement.Models;
|
||||
|
||||
namespace BlacksmithWorkshopFileImplement.Implements
|
||||
{
|
||||
public class StoreStorage : IStoreStorage
|
||||
{
|
||||
private readonly DataFileSingleton source;
|
||||
public StoreStorage()
|
||||
{
|
||||
source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
public List<StoreViewModel> GetFullList()
|
||||
{
|
||||
return source.Stores
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
public List<StoreViewModel> GetFilteredList(StoreSearchModel model)
|
||||
{
|
||||
if (model.Id.HasValue)//сначала ищем по Id
|
||||
{
|
||||
return source.Stores
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(model.StoreName))//далее по названию магазина
|
||||
{
|
||||
return source.Stores
|
||||
.Where(x => x.StoreName.Contains(model.StoreName))
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public StoreViewModel? GetElement(StoreSearchModel model)
|
||||
{
|
||||
if (model.Id.HasValue)//сначала ищем по Id
|
||||
{
|
||||
return source.Stores
|
||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(model.StoreName))//далее по названию магазина
|
||||
{
|
||||
return source.Stores
|
||||
.FirstOrDefault(x => x.StoreName.Contains(model.StoreName))?.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public StoreViewModel? Insert(StoreBindingModel model)
|
||||
{
|
||||
model.Id = source.Stores.Count > 0 ? source.Stores.Max(x => x.Id) + 1 : 1;
|
||||
var newStore = Store.Create(model);
|
||||
if (newStore == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
source.Stores.Add(newStore);
|
||||
source.SaveStores();
|
||||
return newStore.GetViewModel;
|
||||
}
|
||||
public StoreViewModel? Update(StoreBindingModel model)
|
||||
{
|
||||
var store = source.Stores.FirstOrDefault(x => x.StoreName == model.StoreName);
|
||||
if (store == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
store.Update(model);
|
||||
source.SaveStores();
|
||||
return store.GetViewModel;
|
||||
}
|
||||
public StoreViewModel? Delete(StoreBindingModel model)
|
||||
{
|
||||
var element = source.Stores.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
source.Stores.Remove(element);
|
||||
source.SaveStores();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public bool HasManufactures(IManufactureModel manufacture, int count)
|
||||
{
|
||||
var currentCount = source.Stores
|
||||
.Select(x => x.Manufactures
|
||||
.FirstOrDefault(x => x.Key == manufacture.Id).Value.Item2)
|
||||
.Sum();
|
||||
return currentCount >= count;
|
||||
}
|
||||
public bool SellManufacture(IManufactureModel manufacture, int count)
|
||||
{
|
||||
if (!HasManufactures(manufacture, count))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach (var store in source.Stores.Where(x => x.Manufactures.ContainsKey(manufacture.Id)))
|
||||
{
|
||||
var difference = Math.Min(store.Manufactures[manufacture.Id].Item2, count);
|
||||
store.Manufactures[manufacture.Id] = (store.Manufactures[manufacture.Id].Item1, store.Manufactures[manufacture.Id].Item2 - difference);
|
||||
|
||||
count -= difference;
|
||||
if (count <= 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public int GetPlaceLeft(IStoreModel model)
|
||||
{
|
||||
var store = source.Stores.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (store == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return store.MaxManufactures - store.Manufactures.Select(x => x.Value.Item2).Sum();
|
||||
}
|
||||
public List<ManufactureInStoreViewModel> GetManufacturesInStore(StoreSearchModel model)
|
||||
{
|
||||
var store = GetElement(model);
|
||||
List<ManufactureInStoreViewModel> result = store?.Manufactures.Select(x => new ManufactureInStoreViewModel() { ManufactureName = x.Value.Item1.ManufactureName, Count = x.Value.Item2 }).ToList() ?? new();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace BlacksmithWorkshopFileImplement.Models
|
||||
{
|
||||
public class Store : IStoreModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string StoreName { get; private set; } = string.Empty;
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
public DateTime OpeningDate { get; private set; } = DateTime.Now;
|
||||
public Dictionary<int, int> SavedManufactures { get; private set; } = new();
|
||||
private Dictionary<int, (IManufactureModel, int)>? _manufactures = null;
|
||||
public Dictionary<int, (IManufactureModel, int)> Manufactures
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_manufactures == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_manufactures = SavedManufactures.ToDictionary(x => x.Key, y =>
|
||||
((source.Manufactures.FirstOrDefault(z => z.Id == y.Key) as IManufactureModel)!,
|
||||
y.Value));
|
||||
}
|
||||
return _manufactures;
|
||||
}
|
||||
}
|
||||
public int MaxManufactures { get; private set; }
|
||||
public static Store? Create(StoreBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Store()
|
||||
{
|
||||
Id = model.Id,
|
||||
StoreName = model.StoreName,
|
||||
Address = model.Address,
|
||||
OpeningDate = model.OpeningDate,
|
||||
SavedManufactures = model.Manufactures.ToDictionary(x => x.Value.Item1.Id, x => x.Value.Item2),
|
||||
MaxManufactures = model.MaxManufactures,
|
||||
};
|
||||
}
|
||||
public static Store? Create(XElement element)
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Store()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
StoreName = element.Element("StoreName")!.Value,
|
||||
Address = element.Element("Address")!.Value,
|
||||
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
|
||||
SavedManufactures = element.Element("Manufactures")!.Elements("Manufacture").ToDictionary
|
||||
(
|
||||
x => Convert.ToInt32(x.Element("Key")?.Value),
|
||||
x => Convert.ToInt32(x.Element("Value")?.Value)
|
||||
),
|
||||
MaxManufactures = Convert.ToInt32(element.Element("MaxManufactures")!.Value)
|
||||
};
|
||||
}
|
||||
public void Update(StoreBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
StoreName = model.StoreName;
|
||||
Address = model.Address;
|
||||
OpeningDate= model.OpeningDate;
|
||||
SavedManufactures = model.Manufactures.ToDictionary(x => x.Value.Item1.Id, x => x.Value.Item2);
|
||||
_manufactures = null;
|
||||
}
|
||||
public StoreViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
StoreName = StoreName,
|
||||
Address = Address,
|
||||
OpeningDate = OpeningDate,
|
||||
Manufactures = Manufactures,
|
||||
MaxManufactures = MaxManufactures
|
||||
};
|
||||
public XElement GetXElement => new
|
||||
(
|
||||
"Store",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("StoreName", StoreName),
|
||||
new XElement("Address", Address),
|
||||
new XElement("OpeningDate", OpeningDate),
|
||||
new XElement("Manufactures", SavedManufactures.Select
|
||||
(x => new XElement
|
||||
(
|
||||
"Manufacture",
|
||||
new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value)
|
||||
)
|
||||
).ToArray()),
|
||||
new XElement("MaxManufactures", MaxManufactures)
|
||||
);
|
||||
}
|
||||
}
|
@ -8,12 +8,14 @@ namespace BlacksmithWorkshopListImplement
|
||||
public List<Component> Components { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Manufacture> Manufactures { get; set; }
|
||||
public List<Store> Stores { get; set; }
|
||||
public List<Client> Clients { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Manufactures = new List<Manufacture>();
|
||||
Stores = new List<Store>();
|
||||
Clients = new List<Client>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
|
@ -0,0 +1,123 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using BlacksmithWorkshopListImplement;
|
||||
using BlacksmithWorkshopListImplement.Models;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement.Implements
|
||||
{
|
||||
public class StoreStorage : IStoreStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public StoreStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<StoreViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<StoreViewModel>();
|
||||
foreach (var store in _source.Stores)
|
||||
{
|
||||
result.Add(store.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<StoreViewModel> GetFilteredList(StoreSearchModel model)
|
||||
{
|
||||
var result = new List<StoreViewModel>();
|
||||
if (string.IsNullOrEmpty(model.StoreName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var store in _source.Stores)
|
||||
{
|
||||
if (store.StoreName.Contains(model.StoreName ?? string.Empty))
|
||||
{
|
||||
result.Add(store.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public StoreViewModel? GetElement(StoreSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.StoreName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var store in _source.Stores)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.StoreName) &&
|
||||
store.StoreName == model.StoreName) ||
|
||||
(model.Id.HasValue && store.Id == model.Id))
|
||||
{
|
||||
return store.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public StoreViewModel? Insert(StoreBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var store in _source.Stores)
|
||||
{
|
||||
if (model.Id <= store.Id)
|
||||
{
|
||||
model.Id = store.Id + 1;
|
||||
}
|
||||
}
|
||||
var newStore = Store.Create(model);
|
||||
if (newStore == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Stores.Add(newStore);
|
||||
return newStore.GetViewModel;
|
||||
}
|
||||
public StoreViewModel? Update(StoreBindingModel model)
|
||||
{
|
||||
foreach (var store in _source.Stores)
|
||||
{
|
||||
if (store.Id == model.Id)
|
||||
{
|
||||
store.Update(model);
|
||||
return store.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public StoreViewModel? Delete(StoreBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Stores.Count; ++i)
|
||||
{
|
||||
if (_source.Stores[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Stores[i];
|
||||
_source.Stores.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public bool HasManufactures(IManufactureModel manufacture, int count)
|
||||
{
|
||||
throw new NotImplementedException("Не применяется в данной реализации");
|
||||
}
|
||||
public bool SellManufacture(IManufactureModel manufacture, int count)
|
||||
{
|
||||
throw new NotImplementedException("Не применяется в данной реализации");
|
||||
}
|
||||
|
||||
public int GetPlaceLeft(IStoreModel store)
|
||||
{
|
||||
throw new NotImplementedException("Не применяется в данной реализации");
|
||||
}
|
||||
public List<ManufactureInStoreViewModel> GetManufacturesInStore(StoreSearchModel model)
|
||||
{
|
||||
var store = GetElement(model);
|
||||
List<ManufactureInStoreViewModel> result = store?.Manufactures.Select(x => new ManufactureInStoreViewModel() { ManufactureName = x.Value.Item1.ManufactureName, Count = x.Value.Item2 }).ToList() ?? new();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement.Models
|
||||
{
|
||||
public class Store : IStoreModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string StoreName { get; private set; } = string.Empty;
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
public DateTime OpeningDate { get; private set; }
|
||||
public Dictionary<int, (IManufactureModel, int)> Manufactures { get; private set; } = new();
|
||||
public int MaxManufactures { get; private set; }
|
||||
public static Store? Create(StoreBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Store()
|
||||
{
|
||||
Id = model.Id,
|
||||
StoreName = model.StoreName,
|
||||
Address = model.Address,
|
||||
OpeningDate = model.OpeningDate,
|
||||
Manufactures = new(),
|
||||
MaxManufactures = model.MaxManufactures
|
||||
};
|
||||
}
|
||||
public void Update(StoreBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
StoreName = model.StoreName;
|
||||
Address = model.Address;
|
||||
OpeningDate = model.OpeningDate;
|
||||
Manufactures = model.Manufactures;
|
||||
MaxManufactures = model.MaxManufactures;
|
||||
}
|
||||
public StoreViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
StoreName = StoreName,
|
||||
Address = Address,
|
||||
OpeningDate = OpeningDate,
|
||||
Manufactures = Manufactures,
|
||||
MaxManufactures = MaxManufactures
|
||||
};
|
||||
}
|
||||
}
|
@ -30,6 +30,7 @@ namespace BlacksmithWorkshopRestAPI.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
_logger.LogError(ex, "Ошибка входа в систему");
|
||||
throw;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace BlacksmithWorkshopRestAPI.Controllers
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка продуктов");
|
||||
_logger.LogError(ex, "Ошибка получения списка изделий");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,100 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BlacksmithWorkshopRestAPI.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class StoreController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStoreLogic _logic;
|
||||
public StoreController(ILogger<StoreController> logger, IStoreLogic logic)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
[HttpGet]
|
||||
public List<StoreViewModel> GetStores()
|
||||
{
|
||||
_logger.LogInformation("Чтение списка магазинов");
|
||||
var result = _logic.ReadList(null);
|
||||
return result ?? new();
|
||||
}
|
||||
[HttpGet]
|
||||
public StoreViewModel GetStore(int id)
|
||||
{
|
||||
StoreViewModel? result = _logic.ReadElement(new() { Id = id });
|
||||
return result ?? new();
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateStore(StoreBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при создании магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void UpdateStore(StoreBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при обновлении магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void DeleteStore(StoreBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void AddManufacture(FillingStoreBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.AddManufacture(new ManufactureBindingModel() { Id = model.Manufacture }, new() { Id = model.Store }, model.Count);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при пополнении магазина");
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<ManufactureInStoreViewModel> GetManufacturesInStore(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var result = _logic.ReadManufacturesInStore(new() { Id = id });
|
||||
return result;
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске изделий");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -16,10 +16,12 @@ builder.Logging.AddLog4Net("log4net.config");
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IManufactureStorage, ManufactureStorage>();
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IStoreStorage, StoreStorage>();
|
||||
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IManufactureLogic, ManufactureLogic>();
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<IStoreLogic, StoreLogic>();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
|
44
BlacksmithWorkshop/BlacksmithWorkshopStoreApp/APIClient.cs
Normal file
44
BlacksmithWorkshop/BlacksmithWorkshopStoreApp/APIClient.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
||||
namespace BlacksmithWorkshopStoreApp
|
||||
{
|
||||
public static class APIClient
|
||||
{
|
||||
public static string Password { get; set; } = string.Empty;
|
||||
|
||||
public static bool AccessGranted { get; set; } = false;
|
||||
eegov
commented
private set private set
|
||||
private static readonly HttpClient _client = new();
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
Password = configuration["Password"];
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<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="..\BlacksmithWorkshopContracts\BlacksmithWorkshopContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,98 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using BlacksmithWorkshopStoreApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace BlacksmithWorkshopStoreApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (!APIClient.AccessGranted)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.Stores = APIClient.GetRequest<List<StoreViewModel>>("/api/store/getstores");
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
APIClient.AccessGranted = false;
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult Enter(string password)
|
||||
{
|
||||
if (password == APIClient.Password)
|
||||
{
|
||||
APIClient.AccessGranted = true;
|
||||
}
|
||||
return Redirect("~/Home/Index");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Create()
|
||||
{
|
||||
if (!APIClient.AccessGranted)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult Create(StoreBindingModel model)
|
||||
{
|
||||
APIClient.PostRequest("/api/store/createstore", model);
|
||||
return Redirect("~/Home/Index");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Update(int id)
|
||||
{
|
||||
StoreViewModel? store = APIClient.GetRequest<StoreViewModel>($"/api/store/getstore?id={id}");
|
||||
List<ManufactureInStoreViewModel>? man = APIClient.GetRequest<List<ManufactureInStoreViewModel>>($"/api/store/getmanufacturesinstore?id={id}");
|
||||
ViewBag.Store = store;
|
||||
ViewBag.Manufactures = man;
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult Update(StoreViewModel model)
|
||||
{
|
||||
APIClient.PostRequest("/api/store/updatestore", model);
|
||||
return Redirect("~/Home/Index");
|
||||
}
|
||||
public IActionResult Delete(int id)
|
||||
{
|
||||
APIClient.PostRequest($"/api/store/deletestore", new StoreBindingModel { Id = id });
|
||||
return Redirect("~/Home/Index");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult FillStore(int id)
|
||||
{
|
||||
ViewBag.Store = id;
|
||||
var manufactures = APIClient.GetRequest<List<ManufactureViewModel>>("/api/main/getmanufacturelist");
|
||||
ViewBag.Manufactures = manufactures;
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult FillStore(int store, int manufacture, int count)
|
||||
{
|
||||
FillingStoreBindingModel model = new() { Store = store, Manufacture = manufacture, Count = count };
|
||||
APIClient.PostRequest($"/api/store/addmanufacture", model);
|
||||
return Redirect($"~/Home/Update/{store}");
|
||||
}
|
||||
[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 BlacksmithWorkshopStoreApp.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
31
BlacksmithWorkshop/BlacksmithWorkshopStoreApp/Program.cs
Normal file
31
BlacksmithWorkshop/BlacksmithWorkshopStoreApp/Program.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using BlacksmithWorkshopStoreApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
APIClient.Connect(builder.Configuration);
|
||||
|
||||
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:18833",
|
||||
"sslPort": 44311
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"BlacksmithWorkshopStoreApp": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7010;http://localhost:5015",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
@{
|
||||
ViewData["Title"] = "Создание магазина";
|
||||
}
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Название магазина:</div>
|
||||
<div class="col-8"><input type="text" name="StoreName" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Адрес:</div>
|
||||
<div class="col-8"><input type="text" name="Address" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата открытия:</div>
|
||||
<div class="col-8"><input type="date" name="OpeningDate" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Макс. изделий:</div>
|
||||
<div class="col-8"><input type="text" name="MaxManufactures" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div><button asp-controller="Home" asp-action="Create" class="btn btn-primary">Добавить</button></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,16 @@
|
||||
@{
|
||||
ViewData["Title"] = "Вход";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Вход в приложение</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Пароль:</div>
|
||||
<div class="col-8"><input type="password" name="password" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div><button asp-controller="Home" asp-action="Enter" type="submit" class="btn btn-primary">Вход</button></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,12 @@
|
||||
@{
|
||||
ViewData["Title"] = "Создание магазина";
|
||||
}
|
||||
<form method="post">
|
||||
<div hidden><input name="store" value="@ViewBag.Store" /></div>
|
||||
@foreach (var manufacture in ViewBag.Manufactures)
|
||||
{
|
||||
<p><input type="radio" id="@manufacture.Id" name="manufacture" value="@manufacture.Id">@manufacture.ManufactureName</p>
|
||||
}
|
||||
<p><input name="count" type="number">Количество</p>
|
||||
<div><center><input type="submit" value="Добавить изделие" class="btn btn-primary" /></center></div>
|
||||
</form>
|
@ -0,0 +1,41 @@
|
||||
@{
|
||||
ViewData["Title"] = "Магазины";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Список магазинов</h1>
|
||||
</div>
|
||||
@if (ViewBag.Stores.Count != 0)
|
||||
{
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Название</th>
|
||||
<th>Адрес</th>
|
||||
<th>Дата открытия</th>
|
||||
<th>Макс. изделий</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var store in ViewBag.Stores)
|
||||
{
|
||||
<tr>
|
||||
<td name="StoreName">@store.StoreName</td>
|
||||
<td>@store.Address</td>
|
||||
<td>@store.OpeningDate.ToShortDateString()</td>
|
||||
<td>@store.MaxManufactures</td>
|
||||
<td><a href="/home/update/@store.Id">Изменить</a></td>
|
||||
<td><a href="/home/delete/@store.Id">Удалить</a></td>
|
||||
<td><a href="/home/fillstore/@store.Id">Поставить изделие</a></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div>Магазинов нет</div>
|
||||
}
|
||||
<form method="get">
|
||||
<button asp-controller="Home" asp-action="Create" class="btn btn-primary">Добавить магазин</button>
|
||||
</form>
|
@ -0,0 +1,31 @@
|
||||
@{
|
||||
ViewData["Title"] = "Изменение магазина";
|
||||
}
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Название магазина:</div>
|
||||
<div class="col-8"><input value="@ViewBag.Store.StoreName" type="text" name="StoreName" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Адрес:</div>
|
||||
<div class="col-8"><input value="@ViewBag.Store.Address" type="text" name="Address" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата открытия:</div>
|
||||
<div class="col-8"><input value="@ViewBag.Store.OpeningDate.ToShortDateString()" type="date" name="OpeningDate" /></div>
|
||||
</div>
|
||||
<div hidden class="row">
|
||||
<div class="col-4">Макс. изделий:</div>
|
||||
<div class="col-8"><input value="@ViewBag.Store.MaxManufactures" type="text" name="MaxManufactures" /></div>
|
||||
</div>
|
||||
<hr />
|
||||
@foreach (var manufacture in ViewBag.Manufactures)
|
||||
{
|
||||
<p>Изделие: @manufacture.ManufactureName</p>
|
||||
<p>Количество: @manufacture.Count</p>
|
||||
<hr />
|
||||
}
|
||||
<div class="row">
|
||||
<div><button asp-controller="Home" asp-action="Update" class="btn btn-primary">Сохранить</button></div>
|
||||
</div>
|
||||
</form>
|
@ -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"] - Работа с магазинами</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="~/BlacksmithWorkshopStoreApp.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">Магазины</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">Список магазинов</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</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">
|
||||
© 2023 - BlacksmithWorkshopStoreApp - <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 BlacksmithWorkshopStoreApp
|
||||
@using BlacksmithWorkshopStoreApp.Models
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
@ -0,0 +1,3 @@
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"IPAddress": "https://localhost:7195",
|
||||
"Password": "1"
|
||||
}
|
@ -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;
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 5.3 KiB |
@ -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
BlacksmithWorkshop/BlacksmithWorkshopStoreApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css
vendored
Normal file
4997
BlacksmithWorkshop/BlacksmithWorkshopStoreApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
4996
BlacksmithWorkshop/BlacksmithWorkshopStoreApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css
vendored
Normal file
4996
BlacksmithWorkshop/BlacksmithWorkshopStoreApp/wwwroot/lib/bootstrap/dist/css/bootstrap-grid.rtl.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
427
BlacksmithWorkshop/BlacksmithWorkshopStoreApp/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css
vendored
Normal file
427
BlacksmithWorkshop/BlacksmithWorkshopStoreApp/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css
vendored
Normal file
@ -0,0 +1,427 @@
|
||||
/*!
|
||||
* Bootstrap Reboot v5.1.0 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2021 The Bootstrap Authors
|
||||
* Copyright 2011-2021 Twitter, Inc.
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
|
||||
*/
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
:root {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: var(--bs-body-font-family);
|
||||
font-size: var(--bs-body-font-size);
|
||||
font-weight: var(--bs-body-font-weight);
|
||||
line-height: var(--bs-body-line-height);
|
||||
color: var(--bs-body-color);
|
||||
text-align: var(--bs-body-text-align);
|
||||
background-color: var(--bs-body-bg);
|
||||
-webkit-text-size-adjust: 100%;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
hr {
|
||||
margin: 1rem 0;
|
||||
color: inherit;
|
||||
background-color: currentColor;
|
||||
border: 0;
|
||||
opacity: 0.25;
|
||||
}
|
||||
|
||||
hr:not([size]) {
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
h6, h5, h4, h3, h2, h1 {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
font-weight: 500;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: calc(1.375rem + 1.5vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: calc(1.325rem + 0.9vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h2 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: calc(1.3rem + 0.6vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h3 {
|
||||
font-size: 1.75rem;
|
||||
}
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: calc(1.275rem + 0.3vw);
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
h4 {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
abbr[title],
|
||||
abbr[data-bs-original-title] {
|
||||
-webkit-text-decoration: underline dotted;
|
||||
text-decoration: underline dotted;
|
||||
cursor: help;
|
||||
-webkit-text-decoration-skip-ink: none;
|
||||
text-decoration-skip-ink: none;
|
||||
}
|
||||
|
||||
address {
|
||||
margin-bottom: 1rem;
|
||||
font-style: normal;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
ol,
|
||||
ul {
|
||||
padding-left: 2rem;
|
||||
}
|
||||
|
||||
ol,
|
||||
ul,
|
||||
dl {
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
ol ol,
|
||||
ul ul,
|
||||
ol ul,
|
||||
ul ol {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
dt {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
dd {
|
||||
margin-bottom: 0.5rem;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
b,
|
||||
strong {
|
||||
font-weight: bolder;
|
||||
}
|
||||
|
||||
small {
|
||||
font-size: 0.875em;
|
||||
}
|
||||
|
||||
mark {
|
||||
padding: 0.2em;
|
||||
background-color: #fcf8e3;
|
||||
}
|
||||
|
||||
sub,
|
||||
sup {
|
||||
position: relative;
|
||||
font-size: 0.75em;
|
||||
line-height: 0;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
sub {
|
||||
bottom: -0.25em;
|
||||
}
|
||||
|
||||
sup {
|
||||
top: -0.5em;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #0d6efd;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:hover {
|
||||
color: #0a58ca;
|
||||
}
|
||||
|
||||
a:not([href]):not([class]), a:not([href]):not([class]):hover {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
pre,
|
||||
code,
|
||||
kbd,
|
||||
samp {
|
||||
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
||||
font-size: 1em;
|
||||
direction: ltr /* rtl:ignore */;
|
||||
unicode-bidi: bidi-override;
|
||||
}
|
||||
|
||||
pre {
|
||||
display: block;
|
||||
margin-top: 0;
|
||||
margin-bottom: 1rem;
|
||||
overflow: auto;
|
||||
font-size: 0.875em;
|
||||
}
|
||||
pre code {
|
||||
font-size: inherit;
|
||||
color: inherit;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
code {
|
||||
font-size: 0.875em;
|
||||
color: #d63384;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
a > code {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
kbd {
|
||||
padding: 0.2rem 0.4rem;
|
||||
font-size: 0.875em;
|
||||
color: #fff;
|
||||
background-color: #212529;
|
||||
border-radius: 0.2rem;
|
||||
}
|
||||
kbd kbd {
|
||||
padding: 0;
|
||||
font-size: 1em;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
figure {
|
||||
margin: 0 0 1rem;
|
||||
}
|
||||
|
||||
img,
|
||||
svg {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
table {
|
||||
caption-side: bottom;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
caption {
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem;
|
||||
color: #6c757d;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
th {
|
||||
text-align: inherit;
|
||||
text-align: -webkit-match-parent;
|
||||
}
|
||||
|
||||
thead,
|
||||
tbody,
|
||||
tfoot,
|
||||
tr,
|
||||
td,
|
||||
th {
|
||||
border-color: inherit;
|
||||
border-style: solid;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
label {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
button:focus:not(:focus-visible) {
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
input,
|
||||
button,
|
||||
select,
|
||||
optgroup,
|
||||
textarea {
|
||||
margin: 0;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
}
|
||||
|
||||
button,
|
||||
select {
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
[role=button] {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
select {
|
||||
word-wrap: normal;
|
||||
}
|
||||
select:disabled {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
[list]::-webkit-calendar-picker-indicator {
|
||||
display: none;
|
||||
}
|
||||
|
||||
button,
|
||||
[type=button],
|
||||
[type=reset],
|
||||
[type=submit] {
|
||||
-webkit-appearance: button;
|
||||
}
|
||||
button:not(:disabled),
|
||||
[type=button]:not(:disabled),
|
||||
[type=reset]:not(:disabled),
|
||||
[type=submit]:not(:disabled) {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
::-moz-focus-inner {
|
||||
padding: 0;
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
textarea {
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
fieldset {
|
||||
min-width: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
border: 0;
|
||||
}
|
||||
|
||||
legend {
|
||||
float: left;
|
||||
width: 100%;
|
||||
padding: 0;
|
||||
margin-bottom: 0.5rem;
|
||||
font-size: calc(1.275rem + 0.3vw);
|
||||
line-height: inherit;
|
||||
}
|
||||
@media (min-width: 1200px) {
|
||||
legend {
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
}
|
||||
legend + * {
|
||||
clear: left;
|
||||
}
|
||||
|
||||
::-webkit-datetime-edit-fields-wrapper,
|
||||
::-webkit-datetime-edit-text,
|
||||
::-webkit-datetime-edit-minute,
|
||||
::-webkit-datetime-edit-hour-field,
|
||||
::-webkit-datetime-edit-day-field,
|
||||
::-webkit-datetime-edit-month-field,
|
||||
::-webkit-datetime-edit-year-field {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
::-webkit-inner-spin-button {
|
||||
height: auto;
|
||||
}
|
||||
|
||||
[type=search] {
|
||||
outline-offset: -2px;
|
||||
-webkit-appearance: textfield;
|
||||
}
|
||||
|
||||
/* rtl:raw:
|
||||
[type="tel"],
|
||||
[type="url"],
|
||||
[type="email"],
|
||||
[type="number"] {
|
||||
direction: ltr;
|
||||
}
|
||||
*/
|
||||
::-webkit-search-decoration {
|
||||
-webkit-appearance: none;
|
||||
}
|
||||
|
||||
::-webkit-color-swatch-wrapper {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
::file-selector-button {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
::-webkit-file-upload-button {
|
||||
font: inherit;
|
||||
-webkit-appearance: button;
|
||||
}
|
||||
|
||||
output {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
iframe {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
summary {
|
||||
display: list-item;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
progress {
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=bootstrap-reboot.css.map */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user
private set