Eliseev E.E. LabWork05_Hard #11
@ -13,6 +13,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BlacksmithWorkshopBusinessLogic\BlacksmithWorkshopBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\BlacksmithWorkshopContracts\BlacksmithWorkshopContracts.csproj" />
|
||||
<ProjectReference Include="..\BlacksmithWorkshopDatabaseImplement\BlacksmithWorkshopDatabaseImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -73,7 +73,7 @@ namespace BlacksmithWorkshopRestApi.Controllers
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка заказов клиента id ={ Id}", clientId);
|
||||
throw;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,110 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BlacksmithWorkshopRestApi.Controllers
|
||||
{
|
||||
//настройка у контроллера, так как снова используем несколько Post и Get запросов
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ShopController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
public ShopController(IShopLogic logic, ILogger<ShopController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public List<ShopViewModel>? GetShopList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка магазинов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public ShopViewModel? GetShop(int shopId)
|
||||
{
|
||||
try
|
||||
{
|
||||
return _logic.ReadElement(new ShopSearchModel { Id = shopId });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения магазина по id={Id}", shopId);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void CreateShop(ShopBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
//создание магазина
|
||||
_logic.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void UpdateShop(ShopBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
//изменение магазина
|
||||
_logic.Update(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка обновления данных магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void DeleteShop(ShopBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.Delete(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void AddManufacture(Tuple<ShopSearchModel, ManufactureBindingModel, int> model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.AddManufacture(model.Item1, model.Item2, model.Item3);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка добавления изделия в магазин");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -14,10 +14,12 @@ builder.Logging.AddLog4Net("log4net.config");
|
||||
builder.Services.AddTransient<IClientStorage, ClientStorage>();
|
||||
builder.Services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
builder.Services.AddTransient<IManufactureStorage, ManufactureStorage>();
|
||||
builder.Services.AddTransient<IShopStorage, ShopStorage>();
|
||||
|
||||
builder.Services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
builder.Services.AddTransient<IClientLogic, ClientLogic>();
|
||||
builder.Services.AddTransient<IManufactureLogic, ManufactureLogic>();
|
||||
builder.Services.AddTransient<IShopLogic, ShopLogic>();
|
||||
|
||||
builder.Services.AddControllers();
|
||||
|
||||
|
@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopRestApi",
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopClientApp", "BlacksmithWorkshopClientApp\BlacksmithWorkshopClientApp.csproj", "{FCA95914-11AF-494A-8116-BB7B3253D925}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlacksmithWorkshopShopApp", "BlacksmithWorkshopShopApp\BlacksmithWorkshopShopApp.csproj", "{3ADC69D9-EACA-4D59-840E-EB4A7F40BAEE}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -63,6 +65,10 @@ Global
|
||||
{FCA95914-11AF-494A-8116-BB7B3253D925}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FCA95914-11AF-494A-8116-BB7B3253D925}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FCA95914-11AF-494A-8116-BB7B3253D925}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3ADC69D9-EACA-4D59-840E-EB4A7F40BAEE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3ADC69D9-EACA-4D59-840E-EB4A7F40BAEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3ADC69D9-EACA-4D59-840E-EB4A7F40BAEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3ADC69D9-EACA-4D59-840E-EB4A7F40BAEE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -9,15 +9,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.1.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.ReportingServices.ReportViewerControl.Winforms" Version="140.340.80" />
|
||||
<PackageReference Include="Microsoft.SqlServer.Types" Version="160.1000.6" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.2" />
|
||||
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
|
||||
</ItemGroup>
|
||||
|
151
BlacksmithWorkshop/BlacksmithWorkshop/FormAddManufacture.Designer.cs
generated
Normal file
151
BlacksmithWorkshop/BlacksmithWorkshop/FormAddManufacture.Designer.cs
generated
Normal file
@ -0,0 +1,151 @@
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
partial class FormAddManufacture
|
||||
{
|
||||
/// <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.labelIceCream = new System.Windows.Forms.Label();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.labelShop = new System.Windows.Forms.Label();
|
||||
this.comboBoxManufacture = new System.Windows.Forms.ComboBox();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelIceCream
|
||||
//
|
||||
this.labelIceCream.AutoSize = true;
|
||||
this.labelIceCream.Location = new System.Drawing.Point(28, 58);
|
||||
this.labelIceCream.Name = "labelIceCream";
|
||||
this.labelIceCream.Size = new System.Drawing.Size(56, 15);
|
||||
this.labelIceCream.TabIndex = 0;
|
||||
this.labelIceCream.Text = "Изделие:";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(28, 91);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(75, 15);
|
||||
this.labelCount.TabIndex = 1;
|
||||
this.labelCount.Text = "Количество:";
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
this.labelShop.AutoSize = true;
|
||||
this.labelShop.Location = new System.Drawing.Point(28, 23);
|
||||
this.labelShop.Name = "labelShop";
|
||||
this.labelShop.Size = new System.Drawing.Size(57, 15);
|
||||
this.labelShop.TabIndex = 2;
|
||||
this.labelShop.Text = "Магазин:";
|
||||
//
|
||||
// comboBoxManufacture
|
||||
//
|
||||
this.comboBoxManufacture.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxManufacture.FormattingEnabled = true;
|
||||
this.comboBoxManufacture.Location = new System.Drawing.Point(149, 55);
|
||||
this.comboBoxManufacture.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.comboBoxManufacture.Name = "comboBoxManufacture";
|
||||
this.comboBoxManufacture.Size = new System.Drawing.Size(230, 23);
|
||||
this.comboBoxManufacture.TabIndex = 3;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(149, 88);
|
||||
this.textBoxCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(230, 23);
|
||||
this.textBoxCount.TabIndex = 4;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(209, 123);
|
||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(82, 22);
|
||||
this.buttonSave.TabIndex = 6;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(297, 123);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(82, 22);
|
||||
this.buttonCancel.TabIndex = 7;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// comboBoxShop
|
||||
//
|
||||
this.comboBoxShop.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxShop.FormattingEnabled = true;
|
||||
this.comboBoxShop.Location = new System.Drawing.Point(149, 23);
|
||||
this.comboBoxShop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.comboBoxShop.Name = "comboBoxShop";
|
||||
this.comboBoxShop.Size = new System.Drawing.Size(230, 23);
|
||||
this.comboBoxShop.TabIndex = 8;
|
||||
//
|
||||
// FormAddManufacture
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(394, 159);
|
||||
this.Controls.Add(this.comboBoxShop);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.comboBoxManufacture);
|
||||
this.Controls.Add(this.labelShop);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelIceCream);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormAddManufacture";
|
||||
this.Text = "Пополнение магазина";
|
||||
this.Load += new System.EventHandler(this.FormAddManufacture_Load_1);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelIceCream;
|
||||
private Label labelCount;
|
||||
private Label labelShop;
|
||||
private ComboBox comboBoxManufacture;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private ComboBox comboBoxShop;
|
||||
}
|
||||
}
|
128
BlacksmithWorkshop/BlacksmithWorkshop/FormAddManufacture.cs
Normal file
128
BlacksmithWorkshop/BlacksmithWorkshop/FormAddManufacture.cs
Normal file
@ -0,0 +1,128 @@
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
public partial class FormAddManufacture : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IManufactureLogic _logicI;
|
||||
private readonly IShopLogic _logicS;
|
||||
|
||||
public FormAddManufacture(ILogger<FormAddManufacture> logger, IManufactureLogic logicI, IShopLogic logicS)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicI = logicI;
|
||||
_logicS = logicS;
|
||||
}
|
||||
|
||||
private void FormAddManufacture_Load_1(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка списка изделий для пополнения");
|
||||
|
||||
try
|
||||
{
|
||||
var list = _logicI.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxManufacture.DisplayMember = "ManufactureName";
|
||||
comboBoxManufacture.ValueMember = "Id";
|
||||
comboBoxManufacture.DataSource = list;
|
||||
comboBoxManufacture.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка изделий");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка списка магазинов для пополнения");
|
||||
try
|
||||
{
|
||||
var list = _logicS.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxShop.DisplayMember = "ShopName";
|
||||
comboBoxShop.ValueMember = "Id";
|
||||
comboBoxShop.DataSource = list;
|
||||
comboBoxShop.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
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(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxManufacture.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxShop.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Пополнение магазина");
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _logicS.AddManufacture(new ShopSearchModel
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxShop.SelectedValue)
|
||||
},
|
||||
|
||||
_logicI.ReadElement(new ManufactureSearchModel()
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxManufacture.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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
@ -38,12 +38,16 @@
|
||||
toolStripMenuItem = new ToolStripMenuItem();
|
||||
workPieceToolStripMenuItem = new ToolStripMenuItem();
|
||||
manufactureToolStripMenuItem = new ToolStripMenuItem();
|
||||
reportsToolStripMenuItem = new ToolStripMenuItem();
|
||||
workPiecesToolStripMenuItem = new ToolStripMenuItem();
|
||||
shopToolStripMenuItem = new ToolStripMenuItem();
|
||||
addManufactureToolStripMenuItem = new ToolStripMenuItem();
|
||||
reportToolStripMenuItem = new ToolStripMenuItem();
|
||||
groupedOrdersReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
ordersReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
workloadStoresReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
shopsReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
reportManufactureToolStripMenuItem = new ToolStripMenuItem();
|
||||
workPieceManufacturesToolStripMenuItem = new ToolStripMenuItem();
|
||||
ordersToolStripMenuItem = new ToolStripMenuItem();
|
||||
workWithClientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
clientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
buttonSellManufacture = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
menuStrip.SuspendLayout();
|
||||
SuspendLayout();
|
||||
@ -51,16 +55,16 @@
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(12, 36);
|
||||
dataGridView.Location = new Point(11, 36);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(1209, 402);
|
||||
dataGridView.Size = new Size(937, 448);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
buttonCreateOrder.Location = new Point(1247, 70);
|
||||
buttonCreateOrder.Location = new Point(1014, 67);
|
||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
buttonCreateOrder.Size = new Size(235, 29);
|
||||
buttonCreateOrder.TabIndex = 1;
|
||||
@ -70,7 +74,7 @@
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
buttonTakeOrderInWork.Location = new Point(1247, 147);
|
||||
buttonTakeOrderInWork.Location = new Point(1014, 143);
|
||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
buttonTakeOrderInWork.Size = new Size(235, 29);
|
||||
buttonTakeOrderInWork.TabIndex = 2;
|
||||
@ -80,7 +84,7 @@
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
buttonOrderReady.Location = new Point(1247, 224);
|
||||
buttonOrderReady.Location = new Point(1014, 220);
|
||||
buttonOrderReady.Name = "buttonOrderReady";
|
||||
buttonOrderReady.Size = new Size(235, 29);
|
||||
buttonOrderReady.TabIndex = 3;
|
||||
@ -90,7 +94,7 @@
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
buttonIssuedOrder.Location = new Point(1247, 300);
|
||||
buttonIssuedOrder.Location = new Point(1014, 296);
|
||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
buttonIssuedOrder.Size = new Size(235, 29);
|
||||
buttonIssuedOrder.TabIndex = 4;
|
||||
@ -100,7 +104,7 @@
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
buttonRef.Location = new Point(1247, 373);
|
||||
buttonRef.Location = new Point(1014, 369);
|
||||
buttonRef.Name = "buttonRef";
|
||||
buttonRef.Size = new Size(235, 29);
|
||||
buttonRef.TabIndex = 5;
|
||||
@ -111,16 +115,17 @@
|
||||
// menuStrip
|
||||
//
|
||||
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, reportsToolStripMenuItem, workWithClientsToolStripMenuItem });
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, reportToolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(1506, 28);
|
||||
menuStrip.Padding = new Padding(6, 3, 0, 3);
|
||||
menuStrip.Size = new Size(1297, 30);
|
||||
menuStrip.TabIndex = 6;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// toolStripMenuItem
|
||||
//
|
||||
toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { workPieceToolStripMenuItem, manufactureToolStripMenuItem });
|
||||
toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { workPieceToolStripMenuItem, manufactureToolStripMenuItem, shopToolStripMenuItem, addManufactureToolStripMenuItem });
|
||||
toolStripMenuItem.Name = "toolStripMenuItem";
|
||||
toolStripMenuItem.Size = new Size(117, 24);
|
||||
toolStripMenuItem.Text = "Справочники";
|
||||
@ -128,64 +133,96 @@
|
||||
// workPieceToolStripMenuItem
|
||||
//
|
||||
workPieceToolStripMenuItem.Name = "workPieceToolStripMenuItem";
|
||||
workPieceToolStripMenuItem.Size = new Size(162, 26);
|
||||
workPieceToolStripMenuItem.Size = new Size(251, 26);
|
||||
workPieceToolStripMenuItem.Text = "Заготовки";
|
||||
workPieceToolStripMenuItem.Click += WorkPieceToolStripMenuItem_Click;
|
||||
//
|
||||
// manufactureToolStripMenuItem
|
||||
//
|
||||
manufactureToolStripMenuItem.Name = "manufactureToolStripMenuItem";
|
||||
manufactureToolStripMenuItem.Size = new Size(162, 26);
|
||||
manufactureToolStripMenuItem.Size = new Size(251, 26);
|
||||
manufactureToolStripMenuItem.Text = "Изделия";
|
||||
manufactureToolStripMenuItem.Click += ManufactureToolStripMenuItem_Click;
|
||||
//
|
||||
// reportsToolStripMenuItem
|
||||
// shopToolStripMenuItem
|
||||
//
|
||||
reportsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { workPiecesToolStripMenuItem, workPieceManufacturesToolStripMenuItem, ordersToolStripMenuItem });
|
||||
reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
|
||||
reportsToolStripMenuItem.Size = new Size(73, 24);
|
||||
reportsToolStripMenuItem.Text = "Отчёты";
|
||||
shopToolStripMenuItem.Name = "shopToolStripMenuItem";
|
||||
shopToolStripMenuItem.Size = new Size(251, 26);
|
||||
shopToolStripMenuItem.Text = "Магазины";
|
||||
shopToolStripMenuItem.Click += ShopToolStripMenuItem_Click;
|
||||
//
|
||||
// workPiecesToolStripMenuItem
|
||||
// addManufactureToolStripMenuItem
|
||||
//
|
||||
workPiecesToolStripMenuItem.Name = "workPiecesToolStripMenuItem";
|
||||
workPiecesToolStripMenuItem.Size = new Size(256, 26);
|
||||
workPiecesToolStripMenuItem.Text = "Список заготовок";
|
||||
workPiecesToolStripMenuItem.Click += WorkPiecesToolStripMenuItem_Click;
|
||||
addManufactureToolStripMenuItem.Name = "addManufactureToolStripMenuItem";
|
||||
addManufactureToolStripMenuItem.Size = new Size(251, 26);
|
||||
addManufactureToolStripMenuItem.Text = "Пополнение магазина";
|
||||
addManufactureToolStripMenuItem.Click += AddManufactureToolStripMenuItem_Click;
|
||||
//
|
||||
// reportToolStripMenuItem
|
||||
//
|
||||
reportToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { groupedOrdersReportToolStripMenuItem, ordersReportToolStripMenuItem, workloadStoresReportToolStripMenuItem, shopsReportToolStripMenuItem, reportManufactureToolStripMenuItem, workPieceManufacturesToolStripMenuItem });
|
||||
reportToolStripMenuItem.Name = "reportToolStripMenuItem";
|
||||
reportToolStripMenuItem.Size = new Size(73, 24);
|
||||
reportToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// groupedOrdersReportToolStripMenuItem
|
||||
//
|
||||
groupedOrdersReportToolStripMenuItem.Name = "groupedOrdersReportToolStripMenuItem";
|
||||
groupedOrdersReportToolStripMenuItem.Size = new Size(310, 26);
|
||||
groupedOrdersReportToolStripMenuItem.Text = "Список заказов за весь период";
|
||||
groupedOrdersReportToolStripMenuItem.Click += GroupedOrdersReportToolStripMenuItem_Click;
|
||||
//
|
||||
// ordersReportToolStripMenuItem
|
||||
//
|
||||
ordersReportToolStripMenuItem.Name = "ordersReportToolStripMenuItem";
|
||||
ordersReportToolStripMenuItem.Size = new Size(310, 26);
|
||||
ordersReportToolStripMenuItem.Text = "Список заказов";
|
||||
ordersReportToolStripMenuItem.Click += OrdersReportToolStripMenuItem_Click;
|
||||
//
|
||||
// workloadStoresReportToolStripMenuItem
|
||||
//
|
||||
workloadStoresReportToolStripMenuItem.Name = "workloadStoresReportToolStripMenuItem";
|
||||
workloadStoresReportToolStripMenuItem.Size = new Size(310, 26);
|
||||
workloadStoresReportToolStripMenuItem.Text = "Загруженность магазинов";
|
||||
workloadStoresReportToolStripMenuItem.Click += WorkloadStoresReportToolStripMenuItem_Click;
|
||||
//
|
||||
// shopsReportToolStripMenuItem
|
||||
//
|
||||
shopsReportToolStripMenuItem.Name = "shopsReportToolStripMenuItem";
|
||||
shopsReportToolStripMenuItem.Size = new Size(310, 26);
|
||||
shopsReportToolStripMenuItem.Text = "Таблица магазинов";
|
||||
shopsReportToolStripMenuItem.Click += ShopsReportToolStripMenuItem_Click;
|
||||
//
|
||||
// reportManufactureToolStripMenuItem
|
||||
//
|
||||
reportManufactureToolStripMenuItem.Name = "reportManufactureToolStripMenuItem";
|
||||
reportManufactureToolStripMenuItem.Size = new Size(310, 26);
|
||||
reportManufactureToolStripMenuItem.Text = "Список изделий";
|
||||
reportManufactureToolStripMenuItem.Click += ReportManufactureToolStripMenuItem_Click;
|
||||
//
|
||||
// workPieceManufacturesToolStripMenuItem
|
||||
//
|
||||
workPieceManufacturesToolStripMenuItem.Name = "workPieceManufacturesToolStripMenuItem";
|
||||
workPieceManufacturesToolStripMenuItem.Size = new Size(256, 26);
|
||||
workPieceManufacturesToolStripMenuItem.Size = new Size(310, 26);
|
||||
workPieceManufacturesToolStripMenuItem.Text = "Заготовки по изделиям";
|
||||
workPieceManufacturesToolStripMenuItem.Click += WorkPieceManufacturesToolStripMenuItem_Click;
|
||||
//
|
||||
// ordersToolStripMenuItem
|
||||
// buttonSellManufacture
|
||||
//
|
||||
ordersToolStripMenuItem.Name = "ordersToolStripMenuItem";
|
||||
ordersToolStripMenuItem.Size = new Size(256, 26);
|
||||
ordersToolStripMenuItem.Text = "Список заказов";
|
||||
ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
||||
//
|
||||
// workWithClientsToolStripMenuItem
|
||||
//
|
||||
workWithClientsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { clientsToolStripMenuItem });
|
||||
workWithClientsToolStripMenuItem.Name = "workWithClientsToolStripMenuItem";
|
||||
workWithClientsToolStripMenuItem.Size = new Size(161, 24);
|
||||
workWithClientsToolStripMenuItem.Text = "Работа с клиентами";
|
||||
//
|
||||
// clientsToolStripMenuItem
|
||||
//
|
||||
clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
|
||||
clientsToolStripMenuItem.Size = new Size(152, 26);
|
||||
clientsToolStripMenuItem.Text = "Клиенты";
|
||||
clientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
|
||||
buttonSellManufacture.Location = new Point(1014, 440);
|
||||
buttonSellManufacture.Name = "buttonSellManufacture";
|
||||
buttonSellManufacture.Size = new Size(233, 29);
|
||||
buttonSellManufacture.TabIndex = 7;
|
||||
buttonSellManufacture.Text = "Продажа изделий";
|
||||
buttonSellManufacture.UseVisualStyleBackColor = true;
|
||||
buttonSellManufacture.Click += ButtonSellManufacture_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1506, 450);
|
||||
ClientSize = new Size(1297, 496);
|
||||
Controls.Add(buttonSellManufacture);
|
||||
Controls.Add(buttonRef);
|
||||
Controls.Add(buttonIssuedOrder);
|
||||
Controls.Add(buttonOrderReady);
|
||||
@ -216,11 +253,15 @@
|
||||
private ToolStripMenuItem toolStripMenuItem;
|
||||
private ToolStripMenuItem workPieceToolStripMenuItem;
|
||||
private ToolStripMenuItem manufactureToolStripMenuItem;
|
||||
private ToolStripMenuItem reportsToolStripMenuItem;
|
||||
private ToolStripMenuItem workPiecesToolStripMenuItem;
|
||||
private ToolStripMenuItem shopToolStripMenuItem;
|
||||
private ToolStripMenuItem addManufactureToolStripMenuItem;
|
||||
private Button buttonSellManufacture;
|
||||
private ToolStripMenuItem reportToolStripMenuItem;
|
||||
private ToolStripMenuItem groupedOrdersReportToolStripMenuItem;
|
||||
private ToolStripMenuItem ordersReportToolStripMenuItem;
|
||||
private ToolStripMenuItem workloadStoresReportToolStripMenuItem;
|
||||
private ToolStripMenuItem shopsReportToolStripMenuItem;
|
||||
private ToolStripMenuItem reportManufactureToolStripMenuItem;
|
||||
private ToolStripMenuItem workPieceManufacturesToolStripMenuItem;
|
||||
private ToolStripMenuItem ordersToolStripMenuItem;
|
||||
private ToolStripMenuItem workWithClientsToolStripMenuItem;
|
||||
private ToolStripMenuItem clientsToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -49,9 +49,6 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["ManufactureId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
@ -174,22 +171,94 @@ namespace BlacksmithWorkshop
|
||||
|
||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void WorkPiecesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void ButtonSellManufacture_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSellManufacture));
|
||||
if (service is FormSellManufacture form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShopToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||
|
||||
if (service is FormShops form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void AddManufactureToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormAddManufacture));
|
||||
|
||||
if (service is FormAddManufacture form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void GroupedOrdersReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupedOrders));
|
||||
|
||||
if (service is FormReportGroupedOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void OrdersReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void WorkloadStoresReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportShopManufactures));
|
||||
|
||||
if (service is FormReportShopManufactures form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShopsReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveShopsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
|
||||
private void ReportManufactureToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
|
||||
@ -213,25 +282,5 @@ namespace BlacksmithWorkshop
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
|
||||
|
||||
if (service is FormReportOrders form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||
|
||||
if (service is FormClients form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -61,6 +61,6 @@
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>81</value>
|
||||
<value>63</value>
|
||||
</metadata>
|
||||
</root>
|
92
BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupedOrders.Designer.cs
generated
Normal file
92
BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupedOrders.Designer.cs
generated
Normal file
@ -0,0 +1,92 @@
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
partial class FormReportGroupedOrders
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
panel = new Panel();
|
||||
buttonToPdf = new Button();
|
||||
buttonMake = new Button();
|
||||
panel.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel
|
||||
//
|
||||
panel.Controls.Add(buttonToPdf);
|
||||
panel.Controls.Add(buttonMake);
|
||||
panel.Dock = DockStyle.Top;
|
||||
panel.Location = new Point(0, 0);
|
||||
panel.Margin = new Padding(4, 3, 4, 3);
|
||||
panel.Name = "panel";
|
||||
panel.Size = new Size(1031, 40);
|
||||
panel.TabIndex = 0;
|
||||
//
|
||||
// buttonToPdf
|
||||
//
|
||||
buttonToPdf.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
buttonToPdf.Location = new Point(878, 8);
|
||||
buttonToPdf.Margin = new Padding(4, 3, 4, 3);
|
||||
buttonToPdf.Name = "buttonToPdf";
|
||||
buttonToPdf.Size = new Size(139, 27);
|
||||
buttonToPdf.TabIndex = 5;
|
||||
buttonToPdf.Text = "В Pdf";
|
||||
buttonToPdf.UseVisualStyleBackColor = true;
|
||||
buttonToPdf.Click += ButtonToPdf_Click;
|
||||
//
|
||||
// buttonMake
|
||||
//
|
||||
buttonMake.Location = new Point(476, 8);
|
||||
buttonMake.Margin = new Padding(4, 3, 4, 3);
|
||||
buttonMake.Name = "buttonMake";
|
||||
buttonMake.Size = new Size(139, 27);
|
||||
buttonMake.TabIndex = 4;
|
||||
buttonMake.Text = "Сформировать";
|
||||
buttonMake.UseVisualStyleBackColor = true;
|
||||
buttonMake.Click += ButtonMake_Click;
|
||||
//
|
||||
// FormReportOrders
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1031, 647);
|
||||
Controls.Add(panel);
|
||||
Margin = new Padding(4, 3, 4, 3);
|
||||
Name = "FormReportOrders";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Заказы";
|
||||
panel.ResumeLayout(false);
|
||||
panel.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel;
|
||||
private Button buttonToPdf;
|
||||
private Button buttonMake;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Reporting.WinForms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
public partial class FormReportGroupedOrders : Form
|
||||
{
|
||||
private readonly ReportViewer reportViewer;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IReportLogic _logic;
|
||||
|
||||
public FormReportGroupedOrders(ILogger<FormReportGroupedOrders> logger, IReportLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
|
||||
reportViewer = new ReportViewer
|
||||
{
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
|
||||
reportViewer.LocalReport.LoadReportDefinition(new FileStream("C:\\Users\\Programmist73\\Desktop\\Практика\\2-й курс\\4-й семестр\\PIbd-21_Eliseev_E.E._BlacksmithWorkshop\\BlacksmithWorkshop\\BlacksmithWorkshop\\ReportGroupedOrders.rdlc", FileMode.Open));
|
||||
Controls.Clear();
|
||||
Controls.Add(reportViewer);
|
||||
Controls.Add(panel);
|
||||
}
|
||||
|
||||
private void ButtonMake_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dataSource = _logic.GetGroupedOrders();
|
||||
var source = new ReportDataSource("DataSetGroupedOrders", dataSource);
|
||||
|
||||
reportViewer.LocalReport.DataSources.Clear();
|
||||
reportViewer.LocalReport.DataSources.Add(source);
|
||||
|
||||
reportViewer.RefreshReport();
|
||||
_logger.LogInformation("Загрузка списка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonToPdf_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveGroupedOrdersToPdfFile(new ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
|
||||
_logger.LogInformation("Загрузка списка заказов");
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка заказов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -28,81 +28,92 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonSaveToExcel = new System.Windows.Forms.Button();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ColumWorkPiece = 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();
|
||||
dataGridView = new DataGridView();
|
||||
buttonSaveToExcel = new Button();
|
||||
ColumnManufacture = new DataGridViewTextBoxColumn();
|
||||
ColumnWorkPiece = new DataGridViewTextBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSaveToExcel
|
||||
// dataGridView
|
||||
//
|
||||
this.buttonSaveToExcel.Location = new System.Drawing.Point(33, 25);
|
||||
this.buttonSaveToExcel.Name = "buttonSaveToExcel";
|
||||
this.buttonSaveToExcel.Size = new System.Drawing.Size(256, 29);
|
||||
this.buttonSaveToExcel.TabIndex = 0;
|
||||
this.buttonSaveToExcel.Text = "Сохранить в Excel";
|
||||
this.buttonSaveToExcel.UseVisualStyleBackColor = true;
|
||||
this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToOrderColumns = true;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnManufacture, ColumnWorkPiece, ColumnCount });
|
||||
dataGridView.Dock = DockStyle.Bottom;
|
||||
dataGridView.Location = new Point(0, 63);
|
||||
dataGridView.Margin = new Padding(4, 5, 4, 5);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.Size = new Size(704, 680);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// dataGridView
|
||||
// buttonSaveToExcel
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ColumWorkPiece,
|
||||
this.ColumnManufacture,
|
||||
this.ColumnCount});
|
||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 73);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(800, 395);
|
||||
this.dataGridView.TabIndex = 1;
|
||||
buttonSaveToExcel.Location = new Point(16, 18);
|
||||
buttonSaveToExcel.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonSaveToExcel.Name = "buttonSaveToExcel";
|
||||
buttonSaveToExcel.Size = new Size(212, 35);
|
||||
buttonSaveToExcel.TabIndex = 1;
|
||||
buttonSaveToExcel.Text = "Сохранить в Excel";
|
||||
buttonSaveToExcel.UseVisualStyleBackColor = true;
|
||||
buttonSaveToExcel.Click += ButtonSaveToExcel_Click;
|
||||
//
|
||||
// ColumWorkPiece
|
||||
// ColumnManufacture
|
||||
//
|
||||
this.ColumWorkPiece.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.ColumWorkPiece.HeaderText = "Заготовка";
|
||||
this.ColumWorkPiece.MinimumWidth = 6;
|
||||
this.ColumWorkPiece.Name = "ColumWorkPiece";
|
||||
ColumnManufacture.HeaderText = "Изделие";
|
||||
ColumnManufacture.MinimumWidth = 6;
|
||||
ColumnManufacture.Name = "ColumnManufacture";
|
||||
ColumnManufacture.ReadOnly = true;
|
||||
ColumnManufacture.Width = 200;
|
||||
//
|
||||
// ColumnManufacture
|
||||
// ColumnWorkPiece
|
||||
//
|
||||
this.ColumnManufacture.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.ColumnManufacture.HeaderText = "Изделие";
|
||||
this.ColumnManufacture.MinimumWidth = 6;
|
||||
this.ColumnManufacture.Name = "ColumnManufacture";
|
||||
ColumnWorkPiece.HeaderText = "Заготовка";
|
||||
ColumnWorkPiece.MinimumWidth = 6;
|
||||
ColumnWorkPiece.Name = "ColumnWorkPiece";
|
||||
ColumnWorkPiece.ReadOnly = true;
|
||||
ColumnWorkPiece.Width = 200;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
this.ColumnCount.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.ColumnCount.HeaderText = "Количество";
|
||||
this.ColumnCount.MinimumWidth = 6;
|
||||
this.ColumnCount.Name = "ColumnCount";
|
||||
ColumnCount.HeaderText = "Количество";
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
ColumnCount.ReadOnly = true;
|
||||
ColumnCount.Width = 125;
|
||||
//
|
||||
// FormReportManufactureWorkPieces
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 468);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.buttonSaveToExcel);
|
||||
this.Name = "FormReportManufactureWorkPieces";
|
||||
this.Text = "Заготовки по изделиям";
|
||||
this.Load += new System.EventHandler(this.FormReportManufactureWorkPieces_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(704, 743);
|
||||
Controls.Add(buttonSaveToExcel);
|
||||
Controls.Add(dataGridView);
|
||||
Margin = new Padding(4, 5, 4, 5);
|
||||
Name = "FormReportManufactureWorkPieces";
|
||||
Text = "Заготовки по изделиям";
|
||||
Load += FormReportManufactureWorkPieces_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonSaveToExcel;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn ColumWorkPiece;
|
||||
private DataGridViewTextBoxColumn ColumnManufacture;
|
||||
private DataGridViewTextBoxColumn ColumnWorkPiece;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
}
|
||||
}
|
@ -34,7 +34,9 @@
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker();
|
||||
this.labelTo = new System.Windows.Forms.Label();
|
||||
this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker();
|
||||
this.labelFrom = new System.Windows.Forms.Label();
|
||||
this.panel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@ -45,18 +47,23 @@
|
||||
this.panel.Controls.Add(this.label2);
|
||||
this.panel.Controls.Add(this.label1);
|
||||
this.panel.Controls.Add(this.dateTimePickerTo);
|
||||
this.panel.Controls.Add(this.labelTo);
|
||||
this.panel.Controls.Add(this.dateTimePickerFrom);
|
||||
this.panel.Controls.Add(this.labelFrom);
|
||||
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(1112, 51);
|
||||
this.panel.Size = new System.Drawing.Size(1031, 40);
|
||||
this.panel.TabIndex = 0;
|
||||
//
|
||||
// buttonToPdf
|
||||
//
|
||||
this.buttonToPdf.Location = new System.Drawing.Point(894, 10);
|
||||
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(157, 29);
|
||||
this.buttonToPdf.Size = new System.Drawing.Size(139, 27);
|
||||
this.buttonToPdf.TabIndex = 5;
|
||||
this.buttonToPdf.Text = "В Pdf";
|
||||
this.buttonToPdf.UseVisualStyleBackColor = true;
|
||||
@ -64,53 +71,60 @@
|
||||
//
|
||||
// buttonMake
|
||||
//
|
||||
this.buttonMake.Location = new System.Drawing.Point(612, 10);
|
||||
this.buttonMake.Location = new System.Drawing.Point(476, 8);
|
||||
this.buttonMake.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.buttonMake.Name = "buttonMake";
|
||||
this.buttonMake.Size = new System.Drawing.Size(157, 29);
|
||||
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);
|
||||
//
|
||||
// label2
|
||||
// dateTimePickerTo
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(263, 17);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(27, 20);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "по";
|
||||
this.dateTimePickerTo.Location = new System.Drawing.Point(237, 7);
|
||||
this.dateTimePickerTo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.dateTimePickerTo.Name = "dateTimePickerTo";
|
||||
this.dateTimePickerTo.Size = new System.Drawing.Size(163, 23);
|
||||
this.dateTimePickerTo.TabIndex = 3;
|
||||
//
|
||||
// label1
|
||||
// labelTo
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(25, 17);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(18, 20);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "С";
|
||||
//
|
||||
// dateTimePickerTo
|
||||
//
|
||||
this.dateTimePickerTo.Location = new System.Drawing.Point(313, 12);
|
||||
this.dateTimePickerTo.Name = "dateTimePickerTo";
|
||||
this.dateTimePickerTo.Size = new System.Drawing.Size(169, 27);
|
||||
this.dateTimePickerTo.TabIndex = 1;
|
||||
this.labelTo.AutoSize = true;
|
||||
this.labelTo.Location = new System.Drawing.Point(208, 10);
|
||||
this.labelTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelTo.Name = "labelTo";
|
||||
this.labelTo.Size = new System.Drawing.Size(21, 15);
|
||||
this.labelTo.TabIndex = 2;
|
||||
this.labelTo.Text = "по";
|
||||
//
|
||||
// dateTimePickerFrom
|
||||
//
|
||||
this.dateTimePickerFrom.Location = new System.Drawing.Point(65, 12);
|
||||
this.dateTimePickerFrom.Location = new System.Drawing.Point(37, 7);
|
||||
this.dateTimePickerFrom.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.dateTimePickerFrom.Name = "dateTimePickerFrom";
|
||||
this.dateTimePickerFrom.Size = new System.Drawing.Size(176, 27);
|
||||
this.dateTimePickerFrom.TabIndex = 0;
|
||||
this.dateTimePickerFrom.Size = new System.Drawing.Size(163, 23);
|
||||
this.dateTimePickerFrom.TabIndex = 1;
|
||||
//
|
||||
// labelFrom
|
||||
//
|
||||
this.labelFrom.AutoSize = true;
|
||||
this.labelFrom.Location = new System.Drawing.Point(14, 10);
|
||||
this.labelFrom.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelFrom.Name = "labelFrom";
|
||||
this.labelFrom.Size = new System.Drawing.Size(15, 15);
|
||||
this.labelFrom.TabIndex = 0;
|
||||
this.labelFrom.Text = "С";
|
||||
//
|
||||
// FormReportOrders
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1112, 450);
|
||||
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 = "FormReportOrders";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "Заказы";
|
||||
this.panel.ResumeLayout(false);
|
||||
this.panel.PerformLayout();
|
||||
@ -121,11 +135,13 @@
|
||||
#endregion
|
||||
|
||||
private Panel panel;
|
||||
private Button buttonToPdf;
|
||||
private Button buttonMake;
|
||||
private Label label2;
|
||||
private Label label1;
|
||||
private DateTimePicker dateTimePickerTo;
|
||||
private Label labelTo;
|
||||
private DateTimePicker dateTimePickerFrom;
|
||||
private Button buttonToPdf;
|
||||
private Label labelFrom;
|
||||
}
|
||||
}
|
@ -46,9 +46,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date)
|
||||
{
|
||||
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
try
|
||||
@ -64,14 +62,14 @@ namespace BlacksmithWorkshop
|
||||
reportViewer.LocalReport.DataSources.Clear();
|
||||
reportViewer.LocalReport.DataSources.Add(source);
|
||||
|
||||
var parameters = new[] { new ReportParameter("ReportParameterPeriod",
|
||||
var parameters = new[] { new ReportParameter("ReportParameterPeriod",
|
||||
$"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") };
|
||||
|
||||
reportViewer.LocalReport.SetParameters(parameters);
|
||||
|
||||
reportViewer.RefreshReport();
|
||||
|
||||
_logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(),
|
||||
dateTimePickerTo.Value.ToShortDateString());
|
||||
_logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -89,10 +87,7 @@ namespace BlacksmithWorkshop
|
||||
return;
|
||||
}
|
||||
|
||||
using var dialog = new SaveFileDialog
|
||||
{
|
||||
Filter = "pdf|*.pdf"
|
||||
};
|
||||
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@ -105,9 +100,7 @@ namespace BlacksmithWorkshop
|
||||
DateTo = dateTimePickerTo.Value
|
||||
});
|
||||
|
||||
_logger.LogInformation("Сохранение списка заказов на период {From}-{To}",
|
||||
dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
|
||||
|
||||
_logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,4 +1,63 @@
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
118
BlacksmithWorkshop/BlacksmithWorkshop/FormReportShopManufactures.Designer.cs
generated
Normal file
118
BlacksmithWorkshop/BlacksmithWorkshop/FormReportShopManufactures.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
partial class FormReportShopManufactures
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonSaveToExcel = new Button();
|
||||
ColumnShop = new DataGridViewTextBoxColumn();
|
||||
ColumnManufacture = new DataGridViewTextBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToOrderColumns = true;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnShop, ColumnManufacture, ColumnCount });
|
||||
dataGridView.Dock = DockStyle.Bottom;
|
||||
dataGridView.Location = new Point(0, 63);
|
||||
dataGridView.Margin = new Padding(4, 5, 4, 5);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.Size = new Size(704, 680);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonSaveToExcel
|
||||
//
|
||||
buttonSaveToExcel.Location = new Point(16, 18);
|
||||
buttonSaveToExcel.Margin = new Padding(4, 5, 4, 5);
|
||||
buttonSaveToExcel.Name = "buttonSaveToExcel";
|
||||
buttonSaveToExcel.Size = new Size(212, 35);
|
||||
buttonSaveToExcel.TabIndex = 1;
|
||||
buttonSaveToExcel.Text = "Сохранить в Excel";
|
||||
buttonSaveToExcel.UseVisualStyleBackColor = true;
|
||||
buttonSaveToExcel.Click += ButtonSaveToExcel_Click;
|
||||
//
|
||||
// ColumnShop
|
||||
//
|
||||
ColumnShop.HeaderText = "Магазин";
|
||||
ColumnShop.MinimumWidth = 6;
|
||||
ColumnShop.Name = "ColumnShop";
|
||||
ColumnShop.ReadOnly = true;
|
||||
ColumnShop.Width = 200;
|
||||
//
|
||||
// ColumnManufacture
|
||||
//
|
||||
ColumnManufacture.HeaderText = "Изделие";
|
||||
ColumnManufacture.MinimumWidth = 6;
|
||||
ColumnManufacture.Name = "ColumnManufacture";
|
||||
ColumnManufacture.ReadOnly = true;
|
||||
ColumnManufacture.Width = 200;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.HeaderText = "Количество";
|
||||
ColumnCount.MinimumWidth = 6;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
ColumnCount.ReadOnly = true;
|
||||
ColumnCount.Width = 125;
|
||||
//
|
||||
// FormReportShopManufactures
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(704, 743);
|
||||
Controls.Add(buttonSaveToExcel);
|
||||
Controls.Add(dataGridView);
|
||||
Margin = new Padding(4, 5, 4, 5);
|
||||
Name = "FormReportShopManufactures";
|
||||
Text = "Загруженность магазинов";
|
||||
Load += FormReportShopManufactures_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonSaveToExcel;
|
||||
private DataGridViewTextBoxColumn ColumnShop;
|
||||
private DataGridViewTextBoxColumn ColumnManufacture;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
}
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
public partial class FormReportShopManufactures : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IReportLogic _logic;
|
||||
|
||||
public FormReportShopManufactures(ILogger<FormReportShopManufactures> logger, IReportLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormReportShopManufactures_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dict = _logic.GetShopManufactures();
|
||||
|
||||
if (dict != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
|
||||
foreach (var elem in dict)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" });
|
||||
|
||||
foreach (var listElem in elem.Manufactures)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||
}
|
||||
|
||||
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
|
||||
dataGridView.Rows.Add(Array.Empty<object>());
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка списка магазинов по изделиям");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка магазинов по изделиям");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveShopManufacturesToExcelFile(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
121
BlacksmithWorkshop/BlacksmithWorkshop/FormSellManufacture.Designer.cs
generated
Normal file
121
BlacksmithWorkshop/BlacksmithWorkshop/FormSellManufacture.Designer.cs
generated
Normal file
@ -0,0 +1,121 @@
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
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.labelManufacture = new System.Windows.Forms.Label();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.comboBoxManufacture = new System.Windows.Forms.ComboBox();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelManufacture
|
||||
//
|
||||
this.labelManufacture.AutoSize = true;
|
||||
this.labelManufacture.Location = new System.Drawing.Point(32, 32);
|
||||
this.labelManufacture.Name = "labelManufacture";
|
||||
this.labelManufacture.Size = new System.Drawing.Size(71, 20);
|
||||
this.labelManufacture.TabIndex = 0;
|
||||
this.labelManufacture.Text = "Изделие:";
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(34, 85);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(93, 20);
|
||||
this.labelCount.TabIndex = 1;
|
||||
this.labelCount.Text = "Количество:";
|
||||
//
|
||||
// comboBoxManufacture
|
||||
//
|
||||
this.comboBoxManufacture.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxManufacture.FormattingEnabled = true;
|
||||
this.comboBoxManufacture.Location = new System.Drawing.Point(170, 32);
|
||||
this.comboBoxManufacture.Name = "comboBoxManufacture";
|
||||
this.comboBoxManufacture.Size = new System.Drawing.Size(262, 28);
|
||||
this.comboBoxManufacture.TabIndex = 3;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(170, 85);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(262, 27);
|
||||
this.textBoxCount.TabIndex = 4;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(239, 141);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonSave.TabIndex = 6;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(339, 141);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonCancel.TabIndex = 7;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormSellManufacture
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(440, 180);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.comboBoxManufacture);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelManufacture);
|
||||
this.Name = "FormSellManufacture";
|
||||
this.Text = "Продажа изделий";
|
||||
this.Load += new System.EventHandler(this.FormSellManufacture_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelManufacture;
|
||||
private Label labelCount;
|
||||
private ComboBox comboBoxManufacture;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
100
BlacksmithWorkshop/BlacksmithWorkshop/FormSellManufacture.cs
Normal file
100
BlacksmithWorkshop/BlacksmithWorkshop/FormSellManufacture.cs
Normal file
@ -0,0 +1,100 @@
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
public partial class FormSellManufacture : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IManufactureLogic _logicI;
|
||||
|
||||
private readonly IShopLogic _logicS;
|
||||
|
||||
public FormSellManufacture(ILogger<FormAddManufacture> logger, IManufactureLogic logicI, IShopLogic logicS)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logicI = logicI;
|
||||
_logicS = logicS;
|
||||
}
|
||||
|
||||
private void FormSellManufacture_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка списка изделий для продажи");
|
||||
|
||||
try
|
||||
{
|
||||
var list = _logicI.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxManufacture.DisplayMember = "ManufactureName";
|
||||
comboBoxManufacture.ValueMember = "Id";
|
||||
comboBoxManufacture.DataSource = list;
|
||||
comboBoxManufacture.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
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(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxManufacture.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Продажа изделия");
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _logicS.SellManufatures(_logicI.ReadElement(new ManufactureSearchModel()
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxManufacture.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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
229
BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs
generated
Normal file
229
BlacksmithWorkshop/BlacksmithWorkshop/FormShop.Designer.cs
generated
Normal file
@ -0,0 +1,229 @@
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
partial class FormShop
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.labelName = new System.Windows.Forms.Label();
|
||||
this.labelAddress = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
||||
this.groupBoxIceCreams = new System.Windows.Forms.GroupBox();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnManufactureName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.labelDate = new System.Windows.Forms.Label();
|
||||
this.dateTimePickerDate = new System.Windows.Forms.DateTimePicker();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.numericUpDownCount = new System.Windows.Forms.NumericUpDown();
|
||||
this.groupBoxIceCreams.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
this.labelName.AutoSize = true;
|
||||
this.labelName.Location = new System.Drawing.Point(21, 13);
|
||||
this.labelName.Name = "labelName";
|
||||
this.labelName.Size = new System.Drawing.Size(80, 20);
|
||||
this.labelName.TabIndex = 0;
|
||||
this.labelName.Text = "Название:";
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
this.labelAddress.AutoSize = true;
|
||||
this.labelAddress.Location = new System.Drawing.Point(304, 12);
|
||||
this.labelAddress.Name = "labelAddress";
|
||||
this.labelAddress.Size = new System.Drawing.Size(54, 20);
|
||||
this.labelAddress.TabIndex = 1;
|
||||
this.labelAddress.Text = "Адрес:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(107, 10);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(157, 27);
|
||||
this.textBoxName.TabIndex = 2;
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
this.textBoxAddress.Location = new System.Drawing.Point(364, 9);
|
||||
this.textBoxAddress.Name = "textBoxAddress";
|
||||
this.textBoxAddress.Size = new System.Drawing.Size(157, 27);
|
||||
this.textBoxAddress.TabIndex = 3;
|
||||
//
|
||||
// groupBoxIceCreams
|
||||
//
|
||||
this.groupBoxIceCreams.Controls.Add(this.dataGridView);
|
||||
this.groupBoxIceCreams.Location = new System.Drawing.Point(14, 94);
|
||||
this.groupBoxIceCreams.Name = "groupBoxIceCreams";
|
||||
this.groupBoxIceCreams.Size = new System.Drawing.Size(823, 275);
|
||||
this.groupBoxIceCreams.TabIndex = 4;
|
||||
this.groupBoxIceCreams.TabStop = false;
|
||||
this.groupBoxIceCreams.Text = "Изделия";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ID,
|
||||
this.ColumnManufactureName,
|
||||
this.ColumnCount});
|
||||
this.dataGridView.Location = new System.Drawing.Point(6, 27);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(810, 243);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ID
|
||||
//
|
||||
this.ID.HeaderText = "ID";
|
||||
this.ID.MinimumWidth = 6;
|
||||
this.ID.Name = "ID";
|
||||
this.ID.Visible = false;
|
||||
this.ID.Width = 125;
|
||||
//
|
||||
// ColumnManufactureName
|
||||
//
|
||||
this.ColumnManufactureName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.ColumnManufactureName.HeaderText = "Изделие";
|
||||
this.ColumnManufactureName.MinimumWidth = 6;
|
||||
this.ColumnManufactureName.Name = "ColumnManufactureName";
|
||||
this.ColumnManufactureName.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
this.ColumnCount.HeaderText = "Количество";
|
||||
this.ColumnCount.MinimumWidth = 6;
|
||||
this.ColumnCount.Name = "ColumnCount";
|
||||
this.ColumnCount.Width = 125;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(470, 381);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(155, 29);
|
||||
this.buttonSave.TabIndex = 5;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(662, 381);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(155, 29);
|
||||
this.buttonCancel.TabIndex = 6;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
this.labelDate.AutoSize = true;
|
||||
this.labelDate.Location = new System.Drawing.Point(562, 12);
|
||||
this.labelDate.Name = "labelDate";
|
||||
this.labelDate.Size = new System.Drawing.Size(113, 20);
|
||||
this.labelDate.TabIndex = 7;
|
||||
this.labelDate.Text = "Дата открытия:";
|
||||
//
|
||||
// dateTimePickerDate
|
||||
//
|
||||
this.dateTimePickerDate.Location = new System.Drawing.Point(681, 9);
|
||||
this.dateTimePickerDate.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.dateTimePickerDate.Name = "dateTimePickerDate";
|
||||
this.dateTimePickerDate.Size = new System.Drawing.Size(145, 27);
|
||||
this.dateTimePickerDate.TabIndex = 9;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(21, 55);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(173, 20);
|
||||
this.labelCount.TabIndex = 10;
|
||||
this.labelCount.Text = "Вместимость магазина:";
|
||||
//
|
||||
// numericUpDownCount
|
||||
//
|
||||
this.numericUpDownCount.Location = new System.Drawing.Point(200, 53);
|
||||
this.numericUpDownCount.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.numericUpDownCount.Name = "numericUpDownCount";
|
||||
this.numericUpDownCount.Size = new System.Drawing.Size(145, 27);
|
||||
this.numericUpDownCount.TabIndex = 11;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(850, 425);
|
||||
this.Controls.Add(this.numericUpDownCount);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.dateTimePickerDate);
|
||||
this.Controls.Add(this.labelDate);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.groupBoxIceCreams);
|
||||
this.Controls.Add(this.textBoxAddress);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.labelAddress);
|
||||
this.Controls.Add(this.labelName);
|
||||
this.Name = "FormShop";
|
||||
this.Text = "Магазин";
|
||||
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||
this.groupBoxIceCreams.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private Label labelAddress;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxAddress;
|
||||
private GroupBox groupBoxIceCreams;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label labelDate;
|
||||
private DateTimePicker dateTimePickerDate;
|
||||
private DataGridViewTextBoxColumn ID;
|
||||
private DataGridViewTextBoxColumn ColumnManufactureName;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
private Label labelCount;
|
||||
private NumericUpDown numericUpDownCount;
|
||||
}
|
||||
}
|
138
BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs
Normal file
138
BlacksmithWorkshop/BlacksmithWorkshop/FormShop.cs
Normal file
@ -0,0 +1,138 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
public partial class FormShop : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
private int? _id;
|
||||
|
||||
private Dictionary<int, (IManufactureModel, int)> _shopManufactures;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_shopManufactures = new Dictionary<int, (IManufactureModel, int)>();
|
||||
}
|
||||
|
||||
private void FormShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазина");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ShopSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAddress.Text = view.Address.ToString();
|
||||
dateTimePickerDate.Value = view.DateOpen;
|
||||
numericUpDownCount.Value = view.MaxCountManufactures;
|
||||
_shopManufactures = view.ShopManufactures ?? new Dictionary<int, (IManufactureModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий в магазине");
|
||||
try
|
||||
{
|
||||
if (_shopManufactures != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var element in _shopManufactures)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { element.Key, element.Value.Item1.ManufactureName, element.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий в магазине");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
try
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpen = dateTimePickerDate.Value.Date,
|
||||
MaxCountManufactures = (int)numericUpDownCount.Value
|
||||
};
|
||||
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
60
BlacksmithWorkshop/BlacksmithWorkshop/FormShop.resx
Normal file
60
BlacksmithWorkshop/BlacksmithWorkshop/FormShop.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>
|
121
BlacksmithWorkshop/BlacksmithWorkshop/FormShops.Designer.cs
generated
Normal file
121
BlacksmithWorkshop/BlacksmithWorkshop/FormShops.Designer.cs
generated
Normal file
@ -0,0 +1,121 @@
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
partial class FormShops
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonUpd = new System.Windows.Forms.Button();
|
||||
this.buttonDel = new System.Windows.Forms.Button();
|
||||
this.buttonRef = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(10, 9);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(444, 320);
|
||||
this.dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(465, 37);
|
||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(133, 22);
|
||||
this.buttonAdd.TabIndex = 2;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
this.buttonUpd.Location = new System.Drawing.Point(465, 119);
|
||||
this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonUpd.Name = "buttonUpd";
|
||||
this.buttonUpd.Size = new System.Drawing.Size(133, 22);
|
||||
this.buttonUpd.TabIndex = 3;
|
||||
this.buttonUpd.Text = "Изменить";
|
||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
this.buttonDel.Location = new System.Drawing.Point(465, 197);
|
||||
this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonDel.Name = "buttonDel";
|
||||
this.buttonDel.Size = new System.Drawing.Size(133, 22);
|
||||
this.buttonDel.TabIndex = 4;
|
||||
this.buttonDel.Text = "Удалить";
|
||||
this.buttonDel.UseVisualStyleBackColor = true;
|
||||
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
this.buttonRef.Location = new System.Drawing.Point(465, 274);
|
||||
this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonRef.Name = "buttonRef";
|
||||
this.buttonRef.Size = new System.Drawing.Size(133, 22);
|
||||
this.buttonRef.TabIndex = 5;
|
||||
this.buttonRef.Text = "Обновить";
|
||||
this.buttonRef.UseVisualStyleBackColor = true;
|
||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// FormShops
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(610, 338);
|
||||
this.Controls.Add(this.buttonRef);
|
||||
this.Controls.Add(this.buttonDel);
|
||||
this.Controls.Add(this.buttonUpd);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormShops";
|
||||
this.Text = "Магазины";
|
||||
this.Load += new System.EventHandler(this.FormShops_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonAdd;
|
||||
private Button buttonUpd;
|
||||
private Button buttonDel;
|
||||
private Button buttonRef;
|
||||
}
|
||||
}
|
119
BlacksmithWorkshop/BlacksmithWorkshop/FormShops.cs
Normal file
119
BlacksmithWorkshop/BlacksmithWorkshop/FormShops.cs
Normal file
@ -0,0 +1,119 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
public partial class FormShops : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
|
||||
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormShops_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ShopManufactures"].Visible = false;
|
||||
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
if (service is FormShop form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
if (service is FormShop form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление магазина");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ShopBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
60
BlacksmithWorkshop/BlacksmithWorkshop/FormShops.resx
Normal file
60
BlacksmithWorkshop/BlacksmithWorkshop/FormShops.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>
|
@ -1,6 +1,6 @@
|
||||
using BlacksmithWorkshopBusinessLogic.BusinessLogic;
|
||||
using BlacksmithWorkshopBusinessLogic.OfficePackage;
|
||||
using BlacksmithWorkshopBusinessLogic.OfficePackage.Implements;
|
||||
using BlacksmithWorkshopBusinessLogic.OfficePackage;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopDatabaseImplement.Implements;
|
||||
@ -42,28 +42,33 @@ namespace BlacksmithWorkshop
|
||||
services.AddTransient<IWorkPieceStorage, WorkPieceStorage>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IManufactureStorage, ManufactureStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IShopStorage, ShopStorage>();
|
||||
|
||||
services.AddTransient<IWorkPieceLogic, WorkPieceLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IManufactureLogic, ManufactureLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IShopLogic, ShopLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormWorkPiece>();
|
||||
services.AddTransient<FormWorkPieces>();
|
||||
services.AddTransient<FormCreateOrder>();
|
||||
services.AddTransient<FormManufacture>();
|
||||
services.AddTransient<FormManufactures>();
|
||||
services.AddTransient<FormManufactureWorkPiece>();
|
||||
services.AddTransient<FormReportManufactureWorkPieces>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormClients>();
|
||||
}
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormAddManufacture>();
|
||||
services.AddTransient<FormSellManufacture>();
|
||||
services.AddTransient<FormReportManufactureWorkPieces>();
|
||||
services.AddTransient<FormReportShopManufactures>();
|
||||
services.AddTransient<FormReportOrders>();
|
||||
services.AddTransient<FormReportGroupedOrders>();
|
||||
}
|
||||
}
|
||||
}
|
410
BlacksmithWorkshop/BlacksmithWorkshop/ReportGroupedOrders.rdlc
Normal file
410
BlacksmithWorkshop/BlacksmithWorkshop/ReportGroupedOrders.rdlc
Normal file
@ -0,0 +1,410 @@
|
||||
<?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="DataSetGroupedOrders">
|
||||
<Query>
|
||||
<DataSourceName>BlacksmithWorkshopContractsViewModels</DataSourceName>
|
||||
<CommandText>/* Local Query */</CommandText>
|
||||
</Query>
|
||||
<Fields>
|
||||
<Field Name="DateCreate">
|
||||
<DataField>DateCreate</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.Decimal</rd:TypeName>
|
||||
</Field>
|
||||
</Fields>
|
||||
<rd:DataSetInfo>
|
||||
<rd:DataSetName>BlacksmithWorkshopContracts.ViewModels</rd:DataSetName>
|
||||
<rd:TableName>ReportGroupedOrdersViewModel</rd:TableName>
|
||||
<rd:ObjectDataSourceType>BlacksmithWorkshopContracts.ViewModels.ReportGroupedOrdersViewModel, BlacksmithWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
|
||||
</rd:DataSetInfo>
|
||||
</DataSet>
|
||||
</DataSets>
|
||||
<ReportSections>
|
||||
<ReportSection>
|
||||
<Body>
|
||||
<ReportItems>
|
||||
<Textbox Name="TextboxTitle">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Заказы</Value>
|
||||
<Style>
|
||||
<FontSize>16pt</FontSize>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Center</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Height>1cm</Height>
|
||||
<Width>10.19559cm</Width>
|
||||
<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.21438cm</Width>
|
||||
</TablixColumn>
|
||||
<TablixColumn>
|
||||
<Width>3.21438cm</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="Textbox2">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Сумма по заказам</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>Textbox2</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="DateCreate">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>=Fields!DateCreate.Value</Value>
|
||||
<Style>
|
||||
<Format>d</Format>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>DateCreate</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>DataSetGroupedOrders</DataSetName>
|
||||
<Top>2.48391cm</Top>
|
||||
<Left>0.55245cm</Left>
|
||||
<Height>1.2cm</Height>
|
||||
<Width>9.64314cm</Width>
|
||||
<ZIndex>1</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>5.19559cm</Left>
|
||||
<Height>0.6cm</Height>
|
||||
<Width>2.5cm</Width>
|
||||
<ZIndex>2</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, "DataSetGroupedOrders")</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
</TextRun>
|
||||
</TextRuns>
|
||||
<Style>
|
||||
<TextAlign>Right</TextAlign>
|
||||
</Style>
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<Top>4cm</Top>
|
||||
<Left>7.69559cm</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>
|
||||
</ReportItems>
|
||||
<Height>5.62292cm</Height>
|
||||
<Style />
|
||||
</Body>
|
||||
<Width>10.23146cm</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>
|
||||
<ReportParametersLayout>
|
||||
<GridLayoutDefinition>
|
||||
<NumberOfColumns>4</NumberOfColumns>
|
||||
<NumberOfRows>2</NumberOfRows>
|
||||
</GridLayoutDefinition>
|
||||
</ReportParametersLayout>
|
||||
<rd:ReportUnitType>Cm</rd:ReportUnitType>
|
||||
<rd:ReportID>2de0031a-4d17-449d-922d-d9fc54572312</rd:ReportID>
|
||||
</Report>
|
@ -236,38 +236,6 @@
|
||||
</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>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="Textbox2">
|
||||
<CanGrow>true</CanGrow>
|
||||
@ -299,6 +267,38 @@
|
||||
</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>
|
||||
@ -397,36 +397,6 @@
|
||||
</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>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="OrderStatus">
|
||||
<CanGrow>true</CanGrow>
|
||||
@ -455,6 +425,36 @@
|
||||
</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>
|
||||
|
@ -7,9 +7,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.19.0" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="2.20.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="MigraDocCore.DocumentObjectModel" Version="1.3.49" />
|
||||
<PackageReference Include="MigraDocCore.Rendering" Version="1.3.49" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard.DocumentObjectModel" Version="1.51.15" />
|
||||
<PackageReference Include="PdfSharpStand.MigraDoc.DocumentObjectModel.NetStandard" Version="1.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -20,10 +20,16 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
||||
private readonly IShopLogic _shopLogic;
|
||||
|
||||
private readonly IManufactureStorage _manufactureStorage;
|
||||
|
||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage, IShopLogic shopLogic, IManufactureStorage manufactureStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderStorage = orderStorage;
|
||||
_shopLogic = shopLogic;
|
||||
_manufactureStorage = manufactureStorage;
|
||||
}
|
||||
|
||||
//вывод отфильтрованного списка компонентов
|
||||
@ -151,9 +157,21 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
model.Status = newOrderStatus;
|
||||
|
||||
//проверка на выдачу
|
||||
if (model.Status == OrderStatus.Выдан)
|
||||
if (model.Status == OrderStatus.Готов)
|
||||
{
|
||||
model.DateImplement = DateTime.Now;
|
||||
|
||||
var manufacture = _manufactureStorage.GetElement(new() { Id = viewModel.ManufactureId });
|
||||
|
||||
if (manufacture == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(manufacture));
|
||||
}
|
||||
|
||||
if (!_shopLogic.AddManufactures(manufacture, viewModel.Count))
|
||||
{
|
||||
throw new Exception($"AddManufactures operation failed. Shop is full.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
using BlacksmithWorkshopBusinessLogic.OfficePackage;
|
||||
using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels;
|
||||
using BlacksmithWorkshopBusinessLogic.OfficePackage;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
@ -20,26 +21,27 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
|
||||
private readonly IShopStorage _shopStorage;
|
||||
|
||||
private readonly AbstractSaveToExcel _saveToExcel;
|
||||
|
||||
private readonly AbstractSaveToWord _saveToWord;
|
||||
|
||||
private readonly AbstractSaveToPdf _saveToPdf;
|
||||
|
||||
//инициализируем поля класса через контейнер
|
||||
public ReportLogic(IManufactureStorage manufactureStorage,
|
||||
IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel,
|
||||
AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||
public ReportLogic(IManufactureStorage manufactureStorage, IOrderStorage orderStorage, IShopStorage shopStorage,
|
||||
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||
{
|
||||
_manufactureStorage = manufactureStorage;
|
||||
_orderStorage = orderStorage;
|
||||
_shopStorage = shopStorage;
|
||||
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
|
||||
//Получение списка компонент с указанием, в каких изделиях используются
|
||||
//Получение списка заготовок с указанием, в каких изделиях используются
|
||||
public List<ReportManufactureWorkPieceViewModel> GetManufactureWorkPiece()
|
||||
{
|
||||
var manufactures = _manufactureStorage.GetFullList();
|
||||
@ -57,7 +59,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
|
||||
foreach (var workPiece in manufacture.ManufactureWorkPieces)
|
||||
{
|
||||
record.WorkPieces.Add(new (workPiece.Value.Item1.WorkPieceName, workPiece.Value.Item2));
|
||||
record.WorkPieces.Add(new(workPiece.Value.Item1.WorkPieceName, workPiece.Value.Item2));
|
||||
record.TotalCount += workPiece.Value.Item2;
|
||||
}
|
||||
|
||||
@ -67,6 +69,34 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
return list;
|
||||
}
|
||||
|
||||
//Получение списка изделий с указанием, в каких магазинах в наличии
|
||||
public List<ReportShopManufacturesViewModel> GetShopManufactures()
|
||||
{
|
||||
var shops = _shopStorage.GetFullList();
|
||||
|
||||
var list = new List<ReportShopManufacturesViewModel>();
|
||||
|
||||
foreach (var shop in shops)
|
||||
{
|
||||
var record = new ReportShopManufacturesViewModel
|
||||
{
|
||||
ShopName = shop.ShopName,
|
||||
Manufactures = new List<(string, int)>(),
|
||||
TotalCount = 0
|
||||
};
|
||||
|
||||
foreach (var manufacture in shop.ShopManufactures)
|
||||
{
|
||||
record.Manufactures.Add(new(manufacture.Value.Item1.ManufactureName, manufacture.Value.Item2));
|
||||
record.TotalCount += manufacture.Value.Item2;
|
||||
}
|
||||
|
||||
list.Add(record);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
//Получение списка заказов за определенный период
|
||||
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
||||
{
|
||||
@ -82,7 +112,21 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
.ToList();
|
||||
}
|
||||
|
||||
//Сохранение мороженных в файл-Word
|
||||
//Получение списка заказов за весь период
|
||||
public List<ReportGroupedOrdersViewModel> GetGroupedOrders()
|
||||
{
|
||||
return _orderStorage.GetFullList()
|
||||
.GroupBy(x => x.DateCreate.Date)
|
||||
.Select(x => new ReportGroupedOrdersViewModel
|
||||
{
|
||||
DateCreate = x.Key,
|
||||
Count = x.Count(),
|
||||
Sum = x.Sum(x => x.Sum)
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
//Сохранение изделий в файл-Word
|
||||
public void SaveManufacturesToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDoc(new WordInfo
|
||||
@ -93,7 +137,18 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
});
|
||||
}
|
||||
|
||||
//Сохранение заготовок с указаеним изделий в файл-Excel
|
||||
//Сохранение магазинов в файл-Word
|
||||
public void SaveShopsToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateTable(new WordInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Таблица магазинов",
|
||||
Shops = _shopStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
|
||||
//Сохранение изделий с указаеним заготовок в файл-Excel
|
||||
public void SaveManufactureWorkPieceToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateReport(new ExcelInfo
|
||||
@ -104,6 +159,17 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
});
|
||||
}
|
||||
|
||||
//Сохранение магазинов с указанием изделий в файл-Excel
|
||||
public void SaveShopManufacturesToExcelFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToExcel.CreateShopReport(new ExcelInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список магазинов",
|
||||
ShopManufactures = GetShopManufactures()
|
||||
});
|
||||
}
|
||||
|
||||
//Сохранение заказов в файл-Pdf
|
||||
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
@ -116,5 +182,16 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
Orders = GetOrders(model)
|
||||
});
|
||||
}
|
||||
|
||||
//Сохранение заказов за весь период в файл-Pdf
|
||||
public void SaveGroupedOrdersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateGroupedDoc(new PdfInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список заказов",
|
||||
GroupedOrders = GetGroupedOrders()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,250 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ShopLogic : IShopLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopStorage _shopStorage;
|
||||
|
||||
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_shopStorage = shopStorage;
|
||||
}
|
||||
|
||||
public ShopViewModel? ReadElement(ShopSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement. ShopName:{ShopName}. Id:{Id}", model.ShopName, model.Id);
|
||||
var element = _shopStorage.GetElement(model);
|
||||
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ShopName:{ShopName}. Id: {Id}", model?.ShopName, model?.Id);
|
||||
|
||||
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public bool AddManufacture(ShopSearchModel model, IManufactureModel manufacture, int count)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество добавляемых изделий должно быть больше 0", nameof(count));
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddManufacture. ShopName:{ShopName}. Id: {Id}", model?.ShopName, model?.Id);
|
||||
var shop = _shopStorage.GetElement(model);
|
||||
|
||||
if (shop == null)
|
||||
{
|
||||
_logger.LogWarning("Add Manufacture operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (shop.MaxCountManufactures - shop.ShopManufactures.Select(x => x.Value.Item2).Sum() < count)
|
||||
{
|
||||
throw new ArgumentNullException("Слишком много изделий для одного магазина", nameof(count));
|
||||
}
|
||||
|
||||
if (!shop.ShopManufactures.ContainsKey(manufacture.Id))
|
||||
{
|
||||
shop.ShopManufactures[manufacture.Id] = (manufacture, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
shop.ShopManufactures[manufacture.Id] = (manufacture, shop.ShopManufactures[manufacture.Id].Item2 + count);
|
||||
}
|
||||
|
||||
_shopStorage.Update(new ShopBindingModel()
|
||||
{
|
||||
Id = shop.Id,
|
||||
ShopName = shop.ShopName,
|
||||
Address = shop.Address,
|
||||
DateOpen = shop.DateOpen,
|
||||
MaxCountManufactures = shop.MaxCountManufactures,
|
||||
ShopManufactures = shop.ShopManufactures
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Create(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_shopStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
|
||||
if (_shopStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Delete(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
|
||||
if (_shopStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
throw new ArgumentNullException("Отсутствует названия магазина", nameof(model.ShopName));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.Address))
|
||||
{
|
||||
throw new ArgumentNullException("Отсутствует адреса магазина", nameof(model.Address));
|
||||
}
|
||||
|
||||
_logger.LogInformation("Shop. ShopName:{ShopName}. Address:{Address}. Id: {Id}", model.ShopName, model.Address, model.Id);
|
||||
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
ShopName = model.ShopName
|
||||
});
|
||||
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
|
||||
public bool AddManufactures(IManufactureModel model, int count)
|
||||
{
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество добавляемых изделий должно быть больше 0", nameof(count));
|
||||
}
|
||||
|
||||
_logger.LogInformation("AddManufactures. Manufacture: {Manufacture}. Count: {Count}", model?.ManufactureName, count);
|
||||
|
||||
var capacity = _shopStorage.GetFullList().Select(x => x.MaxCountManufactures - x.ShopManufactures.Select(x => x.Value.Item2).Sum()).Sum() - count;
|
||||
|
||||
if (capacity < 0)
|
||||
{
|
||||
_logger.LogWarning("AddManufactures operation failed. Sell {count} Manufactures ", -capacity);
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var shop in _shopStorage.GetFullList())
|
||||
{
|
||||
if (shop.MaxCountManufactures - shop.ShopManufactures.Select(x => x.Value.Item2).Sum() < count)
|
||||
{
|
||||
if (!AddManufacture(new() { Id = shop.Id }, model, shop.MaxCountManufactures - shop.ShopManufactures.Select(x => x.Value.Item2).Sum()))
|
||||
{
|
||||
_logger.LogWarning("AddManufactures operation failed.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
count -= shop.MaxCountManufactures - shop.ShopManufactures.Select(x => x.Value.Item2).Sum();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!AddManufacture(new() { Id = shop.Id }, model, count))
|
||||
{
|
||||
_logger.LogWarning("AddManufactures operation failed.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
count -= count;
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SellManufatures(IManufactureModel model, int count)
|
||||
{
|
||||
return _shopStorage.SellManufactures(model, count);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
{
|
||||
public abstract class AbstractSaveToExcel
|
||||
{
|
||||
//Создание отчета. Описание методов ниже
|
||||
//Создание отчета
|
||||
public void CreateReport(ExcelInfo info)
|
||||
{
|
||||
CreateExcel(info);
|
||||
@ -50,7 +50,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = WorkPiece,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
@ -58,7 +58,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = Count.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
@ -86,6 +86,81 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
SaveExcel(info);
|
||||
}
|
||||
|
||||
public void CreateShopReport(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 sm in info.ShopManufactures)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = sm.ShopName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
|
||||
foreach (var (Manufacture, Count) in sm.Manufactures)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "B",
|
||||
RowIndex = rowIndex,
|
||||
Text = Manufacture,
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = Count.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.TextWithBorder
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = "Итого",
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
ColumnName = "C",
|
||||
RowIndex = rowIndex,
|
||||
Text = sm.TotalCount.ToString(),
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
}
|
||||
|
||||
SaveExcel(info);
|
||||
}
|
||||
|
||||
//Создание excel-файла
|
||||
protected abstract void CreateExcel(ExcelInfo info);
|
||||
|
||||
|
@ -15,60 +15,77 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
{
|
||||
CreatePdf(info);
|
||||
|
||||
CreateParagraph(new PdfParagraph
|
||||
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
|
||||
{
|
||||
Text = info.Title,
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Статус заказа", "Сумма" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
CreateParagraph(new PdfParagraph
|
||||
foreach (var order in info.Orders)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }",
|
||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.ManufactureName, order.OrderStatus, order.Sum.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "3cm" });
|
||||
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right });
|
||||
|
||||
SavePdf(info);
|
||||
}
|
||||
|
||||
public void CreateGroupedDoc(PdfInfo info)
|
||||
{
|
||||
CreatePdf(info);
|
||||
|
||||
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
|
||||
CreateTable(new List<string> { "3cm", "3cm", "3cm" });
|
||||
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма", "Статус заказа" },
|
||||
Texts = new List<string> { "Дата заказа", "Количество заказов", "Сумма" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
|
||||
foreach (var order in info.Orders)
|
||||
foreach (var order in info.GroupedOrders)
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.ManufactureName, order.Sum.ToString(), order.OrderStatus },
|
||||
Texts = new List<string> { order.DateCreate.ToShortDateString(), order.Count.ToString(), order.Sum.ToString() },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
}
|
||||
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"\nИтого: {info.Orders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Right
|
||||
});
|
||||
CreateParagraph(new PdfParagraph { Text = $"Итого: {info.GroupedOrders.Sum(x => x.Sum)}\t", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });
|
||||
|
||||
SavePdf(info);
|
||||
}
|
||||
|
||||
/// Создание pdf-файла
|
||||
//Создание doc-файла
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
|
||||
/// Создание параграфа с текстом
|
||||
//Создание параграфа с текстом
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
|
||||
/// Создание таблицы
|
||||
//Создание таблицы
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
|
||||
/// Создание и заполнение строки
|
||||
//Создание и заполнение строки
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
|
||||
/// Сохранение файла
|
||||
//Сохранение файла
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
//создание ряда абзацев
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24" }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
@ -31,7 +31,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> { (manufacture.ManufactureName + " ", new WordTextProperties { Bold = true, Size = "24", }),
|
||||
Texts = new List<(string, WordTextProperties)> { (manufacture.ManufactureName + " ", new WordTextProperties { Bold = true, Size = "24" }),
|
||||
(manufacture.Price.ToString(), new WordTextProperties { Size = "24" }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
@ -41,16 +41,68 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage
|
||||
});
|
||||
}
|
||||
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
public void CreateTable(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
|
||||
}
|
||||
});
|
||||
|
||||
List<List<(string, WordTextProperties)>> rowList = new()
|
||||
{
|
||||
new()
|
||||
{
|
||||
new("Название", new WordTextProperties { Bold = true, Size = "24" } ),
|
||||
new("Адрес", new WordTextProperties { Bold = true, Size = "24" } ),
|
||||
new("Дата открытия", new WordTextProperties { Bold = true, Size = "24" } )
|
||||
}
|
||||
};
|
||||
|
||||
foreach (var shop in info.Shops)
|
||||
{
|
||||
List<(string, WordTextProperties)> cellList = new()
|
||||
{
|
||||
new(shop.ShopName, new WordTextProperties { Size = "24" }),
|
||||
new(shop.Address, new WordTextProperties { Size = "24" }),
|
||||
new(shop.DateOpen.ToShortDateString(), new WordTextProperties { Size = "24"})
|
||||
};
|
||||
|
||||
rowList.Add(cellList);
|
||||
}
|
||||
|
||||
CreateTable(new WordParagraph
|
||||
{
|
||||
RowTexts = rowList,
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
|
||||
SaveWord(info);
|
||||
}
|
||||
|
||||
// Создание doc-файла
|
||||
//Создание doc-файла
|
||||
protected abstract void CreateWord(WordInfo info);
|
||||
|
||||
// Создание абзаца с текстом
|
||||
//Создание абзаца с текстом
|
||||
protected abstract void CreateParagraph(WordParagraph paragraph);
|
||||
|
||||
// Сохранение файла
|
||||
//Создание таблицы
|
||||
protected abstract void CreateTable(WordParagraph paragraph);
|
||||
|
||||
//Сохранение файла
|
||||
protected abstract void SaveWord(WordInfo info);
|
||||
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperEnums
|
||||
//просто текст
|
||||
Text,
|
||||
|
||||
//текст в рамке
|
||||
TextWithBroder
|
||||
TextWithBorder
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,16 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
//заголовок
|
||||
public string Title { get; set; } = string.Empty;
|
||||
|
||||
//список заготовок по изделиям
|
||||
public List<ReportManufactureWorkPieceViewModel> ManufactureWorkPieces { get; set; } = new();
|
||||
public List<ReportManufactureWorkPieceViewModel> ManufactureWorkPieces
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
|
||||
public List<ReportShopManufacturesViewModel> ShopManufactures
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
||||
|
@ -20,5 +20,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
|
||||
//перечень заказов за указанный период для вывода/сохранения
|
||||
public List<ReportOrdersViewModel> Orders { get; set; } = new();
|
||||
|
||||
public List<ReportGroupedOrdersViewModel> GroupedOrders { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -16,5 +16,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
|
||||
//список заготовок для вывода и сохранения
|
||||
public List<ManufactureViewModel> Manufactures { get; set; } = new();
|
||||
|
||||
public List<ShopViewModel> Shops { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -14,5 +14,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels
|
||||
|
||||
//свойства параграфа, если они есть
|
||||
public WordTextProperties? TextProperties { get; set; }
|
||||
|
||||
public List<List<(string, WordTextProperties)>> RowTexts { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,6 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
Uri = "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
|
||||
};
|
||||
|
||||
stylesheetExtension1.AddNamespaceDeclaration("x14", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
|
||||
stylesheetExtension1.Append(new SlicerStyles()
|
||||
{
|
||||
@ -227,7 +226,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
|
||||
return styleInfo switch
|
||||
{
|
||||
ExcelStyleInfoType.Title => 2U,
|
||||
ExcelStyleInfoType.TextWithBroder => 1U,
|
||||
ExcelStyleInfoType.TextWithBorder => 1U,
|
||||
ExcelStyleInfoType.Text => 0U,
|
||||
_ => 0U,
|
||||
};
|
||||
@ -331,6 +330,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
|
||||
};
|
||||
|
||||
row.InsertBefore(newCell, refCell);
|
||||
|
||||
cell = newCell;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
|
||||
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
|
@ -3,6 +3,12 @@ using BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using DocumentFormat.OpenXml;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
@ -68,10 +74,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
|
||||
|
||||
if (!string.IsNullOrEmpty(paragraphProperties.Size))
|
||||
{
|
||||
paragraphMarkRunProperties.AppendChild(new FontSize
|
||||
{
|
||||
Val = paragraphProperties.Size
|
||||
});
|
||||
paragraphMarkRunProperties.AppendChild(new FontSize { Val = paragraphProperties.Size });
|
||||
}
|
||||
|
||||
properties.AppendChild(paragraphMarkRunProperties);
|
||||
@ -112,7 +115,6 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
|
||||
var docRun = new Run();
|
||||
var properties = new RunProperties();
|
||||
|
||||
//задание свойств текста - размер и жирность
|
||||
properties.AppendChild(new FontSize { Val = run.Item2.Size });
|
||||
|
||||
if (run.Item2.Bold)
|
||||
@ -122,11 +124,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
|
||||
|
||||
docRun.AppendChild(properties);
|
||||
|
||||
docRun.AppendChild(new Text
|
||||
{
|
||||
Text = run.Item1,
|
||||
Space = SpaceProcessingModeValues.Preserve
|
||||
});
|
||||
docRun.AppendChild(new Text { Text = run.Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||
|
||||
docParagraph.AppendChild(docRun);
|
||||
}
|
||||
@ -150,5 +148,75 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements
|
||||
|
||||
_wordDocument.Close();
|
||||
}
|
||||
|
||||
protected override void CreateTable(WordParagraph paragraph)
|
||||
{
|
||||
if (_docBody == null || paragraph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Table table = new Table();
|
||||
|
||||
var tableProp = new TableProperties();
|
||||
|
||||
tableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
|
||||
tableProp.AppendChild(new TableBorders(
|
||||
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 },
|
||||
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 }
|
||||
));
|
||||
tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
|
||||
|
||||
table.AppendChild(tableProp);
|
||||
|
||||
TableGrid tableGrid = new TableGrid();
|
||||
|
||||
for (int j = 0; j < paragraph.RowTexts[0].Count; ++j)
|
||||
{
|
||||
tableGrid.AppendChild(new GridColumn() { Width = "3000" });
|
||||
}
|
||||
|
||||
table.AppendChild(tableGrid);
|
||||
|
||||
for (int i = 0; i < paragraph.RowTexts.Count; ++i)
|
||||
{
|
||||
TableRow docRow = new TableRow();
|
||||
|
||||
for (int j = 0; j < paragraph.RowTexts[i].Count; ++j)
|
||||
{
|
||||
var docParagraph = new Paragraph();
|
||||
|
||||
docParagraph.AppendChild(CreateParagraphProperties(paragraph.RowTexts[i][j].Item2));
|
||||
|
||||
var docRun = new Run();
|
||||
|
||||
var properties = new RunProperties();
|
||||
|
||||
properties.AppendChild(new FontSize { Val = paragraph.RowTexts[i][j].Item2.Size });
|
||||
|
||||
if (paragraph.RowTexts[i][j].Item2.Bold)
|
||||
{
|
||||
properties.AppendChild(new Bold());
|
||||
}
|
||||
|
||||
docRun.AppendChild(properties);
|
||||
|
||||
docRun.AppendChild(new Text { Text = paragraph.RowTexts[i][j].Item1, Space = SpaceProcessingModeValues.Preserve });
|
||||
|
||||
docParagraph.AppendChild(docRun);
|
||||
TableCell docCell = new TableCell();
|
||||
docCell.AppendChild(docParagraph);
|
||||
docRow.AppendChild(docCell);
|
||||
}
|
||||
|
||||
table.AppendChild(docRow);
|
||||
}
|
||||
|
||||
_docBody.AppendChild(table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,6 @@ namespace BlacksmithWorkshopContracts.BindingModels
|
||||
|
||||
public DateTime? DateFrom { get; set; }
|
||||
|
||||
public DateTime? DateTo { get; set;}
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BindingModels
|
||||
{
|
||||
public class ShopBindingModel : IShopModel
|
||||
{
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||
|
||||
public Dictionary<int, (IManufactureModel, int)> ShopManufactures { get; set; } = new();
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public int MaxCountManufactures { get; set; }
|
||||
}
|
||||
}
|
@ -10,19 +10,34 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportLogic
|
||||
{
|
||||
//Получение списка заготовок с указанием, в каких изделиях используются
|
||||
//Получение списка добавок с указанием, в каких мороженых используются
|
||||
List<ReportManufactureWorkPieceViewModel> GetManufactureWorkPiece();
|
||||
|
||||
//Получение списка мороженых с указанием, в каких магазинах в наличии
|
||||
List<ReportShopManufacturesViewModel> GetShopManufactures();
|
||||
|
||||
//Получение списка заказов за определенный период
|
||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||
|
||||
//Сохранение изделий в файл-Word
|
||||
//Получение списка заказов за весь период
|
||||
List<ReportGroupedOrdersViewModel> GetGroupedOrders();
|
||||
|
||||
//Сохранение добавок в файл-Word
|
||||
void SaveManufacturesToWordFile(ReportBindingModel model);
|
||||
|
||||
//Сохранение заготовок с указанием изделий в файл-Excel
|
||||
//Сохранение магазинов в виде таблицы в файл-Word
|
||||
void SaveShopsToWordFile(ReportBindingModel model);
|
||||
|
||||
//Сохранение добавок с указаеним мороженых в файл-Excel
|
||||
void SaveManufactureWorkPieceToExcelFile(ReportBindingModel model);
|
||||
|
||||
//Сохранение магазинов с указанием мороженых в файл-Excel
|
||||
void SaveShopManufacturesToExcelFile(ReportBindingModel model);
|
||||
|
||||
//Сохранение заказов в файл-Pdf
|
||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||
|
||||
//Сохранение заказов за весь период в файл-Pdf
|
||||
void SaveGroupedOrdersToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IShopLogic
|
||||
{
|
||||
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||
|
||||
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||
|
||||
bool Create(ShopBindingModel model);
|
||||
|
||||
bool Update(ShopBindingModel model);
|
||||
|
||||
bool Delete(ShopBindingModel model);
|
||||
|
||||
bool AddManufacture(ShopSearchModel model, IManufactureModel manufacture, int count);
|
||||
|
||||
bool SellManufatures(IManufactureModel model, int count);
|
||||
|
||||
bool AddManufactures(IManufactureModel model, int count);
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@ namespace BlacksmithWorkshopContracts.SearchModels
|
||||
//два поля для возможности производить выборку
|
||||
public DateTime? DateFrom { get; set; }
|
||||
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
//для поиска по идентификатору
|
||||
public int? Id { get; set; }
|
||||
|
||||
//для поиска по названию
|
||||
public string? ShopName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.StoragesContracts
|
||||
{
|
||||
public interface IShopStorage
|
||||
{
|
||||
List<ShopViewModel> GetFullList();
|
||||
|
||||
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||
|
||||
ShopViewModel? GetElement(ShopSearchModel model);
|
||||
|
||||
ShopViewModel? Insert(ShopBindingModel model);
|
||||
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
|
||||
bool SellManufactures(IManufactureModel model, int count);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ReportGroupedOrdersViewModel
|
||||
{
|
||||
public DateTime DateCreate { get; set; }
|
||||
|
||||
public int Count { get; set; }
|
||||
|
||||
public double Sum { get; set; }
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using BlacksmithWorkshopDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ReportShopManufacturesViewModel
|
||||
{
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
public int TotalCount { get; set; }
|
||||
|
||||
public List<(string Manufacture, int Count)> Manufactures { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[DisplayName("Название магазина")]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Адрес магазина")]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||
|
||||
public Dictionary<int, (IManufactureModel, int)> ShopManufactures { get; set; } = new();
|
||||
|
||||
[DisplayName("Вместимость магазина")]
|
||||
public int MaxCountManufactures { get; set; }
|
||||
|
||||
public List<Tuple<ManufactureViewModel, int>> ShopManufactureList { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
using BlacksmithWorkshopDataModels.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopDataModels.Models
|
||||
{
|
||||
//интерфес сущности "Магазин"
|
||||
public interface IShopModel : IId
|
||||
{
|
||||
//название магазина
|
||||
string ShopName { get; }
|
||||
|
||||
//адрес магазина
|
||||
string Address { get; }
|
||||
|
||||
//дата открытия магазина
|
||||
DateTime DateOpen { get; }
|
||||
|
||||
//максимальное кол-во изделий в магазине
|
||||
int MaxCountManufactures { get; }
|
||||
|
||||
//изделия в магазине
|
||||
Dictionary<int, (IManufactureModel, int)> ShopManufactures { get; }
|
||||
}
|
||||
}
|
@ -29,6 +29,10 @@ namespace BlacksmithWorkshopDatabaseImplement
|
||||
|
||||
public virtual DbSet<Order> Orders { set; get; }
|
||||
|
||||
public virtual DbSet<Shop> Shops { set; get; }
|
||||
|
||||
public virtual DbSet<ShopManufacture> ShopManufactures { get; set; }
|
||||
|
||||
public virtual DbSet<Client> Clients { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -7,9 +7,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
@ -19,6 +19,7 @@ namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
|
||||
var element = context.Orders
|
||||
.Include(x => x.Manufacture)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
|
@ -0,0 +1,179 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDatabaseImplement.Models;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
|
||||
return context.Shops
|
||||
.Include(x => x.Manufactures)
|
||||
.ThenInclude(x => x.Manufacture)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
|
||||
return context.Shops
|
||||
.Include(x => x.Manufactures)
|
||||
.ThenInclude(x => x.Manufacture)
|
||||
.Where(x => x.ShopName.Contains(model.ShopName))
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
|
||||
return context.Shops
|
||||
.Include(x => x.Manufactures)
|
||||
.ThenInclude(x => x.Manufacture)
|
||||
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
var newShop = Shop.Create(context, model);
|
||||
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
context.Shops.Add(newShop);
|
||||
context.SaveChanges();
|
||||
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
var shop = context.Shops.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (shop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
shop.Update(model);
|
||||
context.SaveChanges();
|
||||
shop.UpdateManufactures(context, model);
|
||||
transaction.Commit();
|
||||
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
|
||||
var element = context.Shops
|
||||
.Include(x => x.Manufactures)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
context.Shops.Remove(element);
|
||||
context.SaveChanges();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool SellManufactures(IManufactureModel model, int count)
|
||||
{
|
||||
using var context = new BlacksmithWorkshopDatabase();
|
||||
using var transaction = context.Database.BeginTransaction();
|
||||
|
||||
try
|
||||
{
|
||||
var shops = context.ShopManufactures
|
||||
.Include(x => x.Shop)
|
||||
.ToList()
|
||||
.Where(rec => rec.ManufactureId == model.Id);
|
||||
|
||||
if (shops == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var shop in shops)
|
||||
{
|
||||
if (shop.Count < count)
|
||||
{
|
||||
count -= shop.Count;
|
||||
shop.Count = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
shop.Count = shop.Count - count;
|
||||
count -= count;
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
context.SaveChanges();
|
||||
transaction.Commit();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
transaction.Rollback();
|
||||
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.Rollback();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,250 @@
|
||||
// <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("20230324151111_ThirdHardLabWork")]
|
||||
partial class ThirdHardLabWork
|
||||
{
|
||||
/// <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.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.ManufactureWorkPiece", 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>("WorkPieceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.HasIndex("WorkPieceId");
|
||||
|
||||
b.ToTable("ManufactureWorkPieces");
|
||||
});
|
||||
|
||||
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.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("DateOpen")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("MaxCountManufactures")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", 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>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopManufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("WorkPieceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("WorkPieces");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("WorkPieces")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece")
|
||||
.WithMany("ManufactureWorkPieces")
|
||||
.HasForeignKey("WorkPieceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
|
||||
b.Navigation("WorkPiece");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Shops")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Manufactures")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Shops");
|
||||
|
||||
b.Navigation("WorkPieces");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Manufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b =>
|
||||
{
|
||||
b.Navigation("ManufactureWorkPieces");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class ThirdHardLabWork : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Shops",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
DateOpen = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
MaxCountManufactures = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ShopManufactures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ShopId = table.Column<int>(type: "int", nullable: false),
|
||||
ManufactureId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ShopManufactures", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopManufactures_Manufactures_ManufactureId",
|
||||
column: x => x.ManufactureId,
|
||||
principalTable: "Manufactures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ShopManufactures_Shops_ShopId",
|
||||
column: x => x.ShopId,
|
||||
principalTable: "Shops",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopManufactures_ManufactureId",
|
||||
table: "ShopManufactures",
|
||||
column: "ManufactureId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ShopManufactures_ShopId",
|
||||
table: "ShopManufactures",
|
||||
column: "ShopId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ShopManufactures");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Shops");
|
||||
}
|
||||
}
|
||||
}
|
250
BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411085311_NewClear.Designer.cs
generated
Normal file
250
BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230411085311_NewClear.Designer.cs
generated
Normal file
@ -0,0 +1,250 @@
|
||||
// <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("20230411085311_NewClear")]
|
||||
partial class NewClear
|
||||
{
|
||||
/// <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.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.ManufactureWorkPiece", 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>("WorkPieceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.HasIndex("WorkPieceId");
|
||||
|
||||
b.ToTable("ManufactureWorkPieces");
|
||||
});
|
||||
|
||||
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.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("DateOpen")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("MaxCountManufactures")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", 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>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopManufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("WorkPieceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("WorkPieces");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("WorkPieces")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece")
|
||||
.WithMany("ManufactureWorkPieces")
|
||||
.HasForeignKey("WorkPieceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
|
||||
b.Navigation("WorkPiece");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Shops")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Manufactures")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Shops");
|
||||
|
||||
b.Navigation("WorkPieces");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Manufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b =>
|
||||
{
|
||||
b.Navigation("ManufactureWorkPieces");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class NewClear : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.Sql("DELETE FROM [dbo].[Orders]");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
293
BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421073101_For5Hard.Designer.cs
generated
Normal file
293
BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230421073101_For5Hard.Designer.cs
generated
Normal file
@ -0,0 +1,293 @@
|
||||
// <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("20230421073101_For5Hard")]
|
||||
partial class For5Hard
|
||||
{
|
||||
/// <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.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.ManufactureWorkPiece", 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>("WorkPieceId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.HasIndex("WorkPieceId");
|
||||
|
||||
b.ToTable("ManufactureWorkPieces");
|
||||
});
|
||||
|
||||
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.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("DateOpen")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("MaxCountManufactures")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", 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>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopManufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<double>("Cost")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.Property<string>("WorkPieceName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("WorkPieces");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("WorkPieces")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece")
|
||||
.WithMany("ManufactureWorkPieces")
|
||||
.HasForeignKey("WorkPieceId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
|
||||
b.Navigation("WorkPiece");
|
||||
});
|
||||
|
||||
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", "Manufacture")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Shops")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Manufactures")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Shops");
|
||||
|
||||
b.Navigation("WorkPieces");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Manufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b =>
|
||||
{
|
||||
b.Navigation("ManufactureWorkPieces");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class For5Hard : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -131,6 +131,59 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<DateTime>("DateOpen")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("MaxCountManufactures")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ShopName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Shops");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", 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>("ShopId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ManufactureId");
|
||||
|
||||
b.HasIndex("ShopId");
|
||||
|
||||
b.ToTable("ShopManufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -189,6 +242,25 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
b.Navigation("Manufacture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ShopManufacture", b =>
|
||||
{
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
|
||||
.WithMany("Shops")
|
||||
.HasForeignKey("ManufactureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Shop", "Shop")
|
||||
.WithMany("Manufactures")
|
||||
.HasForeignKey("ShopId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Manufacture");
|
||||
|
||||
b.Navigation("Shop");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
@ -198,9 +270,16 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Shops");
|
||||
|
||||
b.Navigation("WorkPieces");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Shop", b =>
|
||||
{
|
||||
b.Navigation("Manufactures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b =>
|
||||
{
|
||||
b.Navigation("ManufactureWorkPieces");
|
||||
|
@ -47,6 +47,9 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
[ForeignKey("ManufactureId")]
|
||||
public virtual List<Order> Orders { get; set; } = new();
|
||||
|
||||
[ForeignKey("ManufactureId")]
|
||||
public virtual List<ShopManufacture> Shops { get; set; } = new();
|
||||
|
||||
public static Manufacture Create(BlacksmithWorkshopDatabase context, ManufactureBindingModel model)
|
||||
{
|
||||
return new Manufacture()
|
||||
@ -76,8 +79,6 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
ManufactureWorkPieces = ManufactureWorkPieces
|
||||
};
|
||||
|
||||
Dictionary<int, (IWorkPieceModel, int)> IManufactureModel.ManufactureWorkPieces => throw new NotImplementedException();
|
||||
|
||||
public void UpdateWorkPieces(BlacksmithWorkshopDatabase context, ManufactureBindingModel model)
|
||||
{
|
||||
var manufactureWorkPieces = context.ManufactureWorkPieces.Where(rec => rec.ManufactureId == model.Id).ToList();
|
||||
@ -100,13 +101,13 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
|
||||
var manufacture = context.Manufactures.First(x => x.Id == Id);
|
||||
|
||||
foreach (var pc in model.ManufactureWorkPieces)
|
||||
foreach (var mwp in model.ManufactureWorkPieces)
|
||||
{
|
||||
context.ManufactureWorkPieces.Add(new ManufactureWorkPiece
|
||||
{
|
||||
Manufacture = manufacture,
|
||||
WorkPiece = context.WorkPieces.First(x => x.Id == pc.Key),
|
||||
Count = pc.Value.Item2
|
||||
WorkPiece = context.WorkPieces.First(x => x.Id == mwp.Key),
|
||||
Count = mwp.Value.Item2
|
||||
});
|
||||
|
||||
context.SaveChanges();
|
||||
|
@ -29,10 +29,10 @@ namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
public double Sum { get; private set; }
|
||||
|
||||
[Required]
|
||||
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
|
||||
public OrderStatus Status { get; private set; }
|
||||
|
||||
[Required]
|
||||
public DateTime DateCreate { get; private set; } = DateTime.Now;
|
||||
public DateTime DateCreate { get; private set; }
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
|
||||
|
@ -0,0 +1,120 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public DateTime DateOpen { get; set; }
|
||||
|
||||
[Required]
|
||||
public int MaxCountManufactures { get; set; }
|
||||
|
||||
private Dictionary<int, (IManufactureModel, int)>? _shopManufactures = null;
|
||||
|
||||
[Required]
|
||||
public Dictionary<int, (IManufactureModel, int)> ShopManufactures
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_shopManufactures == null)
|
||||
{
|
||||
_shopManufactures = Manufactures.ToDictionary(recSI => recSI.ManufactureId, recSI => (recSI.Manufacture as IManufactureModel, recSI.Count));
|
||||
}
|
||||
return _shopManufactures;
|
||||
}
|
||||
}
|
||||
|
||||
[ForeignKey("ShopId")]
|
||||
public virtual List<ShopManufacture> Manufactures { get; set; } = new();
|
||||
|
||||
public static Shop? Create(BlacksmithWorkshopDatabase context, ShopBindingModel model)
|
||||
{
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpen = model.DateOpen,
|
||||
Manufactures = model.ShopManufactures.Select(x => new ShopManufacture
|
||||
{
|
||||
Manufacture = context.Manufactures.First(y => y.Id == x.Key),
|
||||
Count = x.Value.Item2
|
||||
}).ToList(),
|
||||
MaxCountManufactures = model.MaxCountManufactures
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel model)
|
||||
{
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpen = model.DateOpen;
|
||||
MaxCountManufactures = model.MaxCountManufactures;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpen = DateOpen,
|
||||
MaxCountManufactures = MaxCountManufactures,
|
||||
ShopManufactures = ShopManufactures,
|
||||
ShopManufactureList = Manufactures.Select(x => new Tuple<ManufactureViewModel, int>(x.Manufacture.GetViewModel, x.Count)).ToList()
|
||||
};
|
||||
|
||||
public void UpdateManufactures(BlacksmithWorkshopDatabase context, ShopBindingModel model)
|
||||
{
|
||||
var shopManufactures = context.ShopManufactures.Where(rec => rec.ShopId == model.Id).ToList();
|
||||
|
||||
if (shopManufactures != null && shopManufactures.Count > 0)
|
||||
{ // удалили те, которых нет в модели
|
||||
context.ShopManufactures.RemoveRange(shopManufactures.Where(rec => !model.ShopManufactures.ContainsKey(rec.ManufactureId)));
|
||||
context.SaveChanges();
|
||||
|
||||
// обновили количество у существующих записей
|
||||
foreach (var _shopManufactures in shopManufactures)
|
||||
{
|
||||
_shopManufactures.Count = model.ShopManufactures[_shopManufactures.ManufactureId].Item2;
|
||||
model.ShopManufactures.Remove(_shopManufactures.ManufactureId);
|
||||
}
|
||||
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
var shop = context.Shops.First(x => x.Id == Id);
|
||||
|
||||
foreach (var sm in model.ShopManufactures)
|
||||
{
|
||||
context.ShopManufactures.Add(new ShopManufacture
|
||||
{
|
||||
Shop = shop,
|
||||
Manufacture = context.Manufactures.First(x => x.Id == sm.Key),
|
||||
Count = sm.Value.Item2
|
||||
});
|
||||
|
||||
context.SaveChanges();
|
||||
}
|
||||
|
||||
_shopManufactures = null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopDatabaseImplement.Models
|
||||
{
|
||||
public class ShopManufacture
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ShopId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ManufactureId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Count { get; set; }
|
||||
|
||||
public virtual Shop Shop { get; set; } = new();
|
||||
|
||||
public virtual Manufacture Manufacture { get; set; } = new();
|
||||
}
|
||||
}
|
@ -18,17 +18,21 @@ namespace BlacksmithWorkshopFileImplement
|
||||
|
||||
private readonly string ManufactureFileName = "Manufacture.xml";
|
||||
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
private readonly string ShopFileName = "Shop.xml";
|
||||
|
||||
public List<WorkPiece> WorkPieces { get; private set; }
|
||||
private readonly string ClientFileName = "Client.xml";
|
||||
|
||||
public List<WorkPiece> WorkPieces { get; private set; }
|
||||
|
||||
public List<Order> Orders { get; private set; }
|
||||
|
||||
public List<Manufacture> Manufactures { get; private set; }
|
||||
|
||||
public List<Client> Clients { get; private set; }
|
||||
public List<Shop> Shops { get; private set; }
|
||||
|
||||
public static DataFileSingleton GetInstance()
|
||||
public List<Client> Clients { get; private set; }
|
||||
|
||||
public static DataFileSingleton GetInstance()
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
@ -44,13 +48,16 @@ namespace BlacksmithWorkshopFileImplement
|
||||
|
||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||
public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement);
|
||||
|
||||
private DataFileSingleton()
|
||||
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||
|
||||
private DataFileSingleton()
|
||||
{
|
||||
WorkPieces = LoadData(WorkPieceFileName, "WorkPiece", x => WorkPiece.Create(x)!)!;
|
||||
Manufactures = LoadData(ManufactureFileName, "Manufacture", x => Manufacture.Create(x)!)!;
|
||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,139 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using BlacksmithWorkshopFileImplement.Models;
|
||||
using System.Net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopFileImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataFileSingleton _source;
|
||||
|
||||
public ShopStorage()
|
||||
{
|
||||
_source = DataFileSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
return _source.Shops.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
|
||||
return _source.Shops.Where(x => x.ShopName.Contains(model.ShopName))
|
||||
.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return _source.Shops.FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName)
|
||||
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
model.Id = _source.Shops.Count > 0 ? _source.Shops.Max(x => x.Id) + 1 : 1;
|
||||
|
||||
var newShop = Shop.Create(model);
|
||||
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_source.Shops.Add(newShop);
|
||||
_source.SaveShops();
|
||||
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
var shop = _source.Shops.FirstOrDefault(x => x.ShopName.Contains(model.ShopName) || x.Id == model.Id);
|
||||
|
||||
if (shop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
shop.Update(model);
|
||||
_source.SaveShops();
|
||||
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
var element = _source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||
|
||||
if (element != null)
|
||||
{
|
||||
_source.Shops.Remove(element);
|
||||
_source.SaveShops();
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool SellManufactures(IManufactureModel model, int count)
|
||||
{
|
||||
if (_source.Shops.Select(x => x.ShopManufactures.FirstOrDefault(x => x.Key == model.Id).Value.Item2).Sum() < count)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var list = _source.Shops.Where(x => x.ShopManufactures.ContainsKey(model.Id));
|
||||
|
||||
foreach (var shop in list)
|
||||
{
|
||||
if (shop.ShopManufactures[model.Id].Item2 < count)
|
||||
{
|
||||
count -= shop.ShopManufactures[model.Id].Item2;
|
||||
shop.ShopManufactures[model.Id] = (shop.ShopManufactures[model.Id].Item1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
shop.ShopManufactures[model.Id] = (shop.ShopManufactures[model.Id].Item1, shop.ShopManufactures[model.Id].Item2 - count);
|
||||
count -= count;
|
||||
}
|
||||
|
||||
Update(new()
|
||||
{
|
||||
ShopName = shop.ShopName,
|
||||
Address = shop.Address,
|
||||
DateOpen = shop.DateOpen,
|
||||
MaxCountManufactures = shop.MaxCountManufactures,
|
||||
ShopManufactures = shop.ShopManufactures
|
||||
});
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,112 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace BlacksmithWorkshopFileImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateOpen { get; set; }
|
||||
|
||||
public int MaxCountManufactures { get; set; }
|
||||
|
||||
public Dictionary<int, int> Manufactures { get; private set; } = new();
|
||||
|
||||
public Dictionary<int, (IManufactureModel, int)> _manufactures = null;
|
||||
|
||||
public Dictionary<int, (IManufactureModel, int)> ShopManufactures
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_manufactures == null)
|
||||
{
|
||||
var source = DataFileSingleton.GetInstance();
|
||||
_manufactures = Manufactures.ToDictionary(x => x.Key, y => ((source.Manufactures.FirstOrDefault(z => z.Id == y.Key) as IManufactureModel)!, y.Value));
|
||||
}
|
||||
|
||||
return _manufactures;
|
||||
}
|
||||
}
|
||||
|
||||
public static Shop? Create(ShopBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpen = model.DateOpen,
|
||||
MaxCountManufactures = model.MaxCountManufactures,
|
||||
Manufactures = model.ShopManufactures.ToDictionary(x => x.Key, x => x.Value.Item2)
|
||||
};
|
||||
}
|
||||
|
||||
public static Shop? Create(XElement element)
|
||||
|
||||
{
|
||||
if (element == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||
ShopName = element.Element("ShopName")!.Value,
|
||||
Address = element.Element("Address")!.Value,
|
||||
DateOpen = Convert.ToDateTime(element.Element("DateOpen")!.Value),
|
||||
MaxCountManufactures = Convert.ToInt32(element.Element("MaxCountManufactures")!.Value),
|
||||
Manufactures = element.Element("Manufactures")!.Elements("Manufactures").ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpen = model.DateOpen;
|
||||
MaxCountManufactures = model.MaxCountManufactures;
|
||||
Manufactures = model.ShopManufactures.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||
_manufactures = null;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpen = DateOpen,
|
||||
MaxCountManufactures = MaxCountManufactures,
|
||||
ShopManufactures = ShopManufactures
|
||||
};
|
||||
|
||||
public XElement GetXElement => new("Shop",
|
||||
new XAttribute("Id", Id),
|
||||
new XElement("ShopName", ShopName),
|
||||
new XElement("Address", Address),
|
||||
new XElement("DateOpen", DateOpen.ToString()),
|
||||
new XElement("MaxCountManufactures", MaxCountManufactures.ToString()),
|
||||
new XElement("Manufactures", Manufactures.Select(x => new XElement("Manufactures",
|
||||
new XElement("Key", x.Key),
|
||||
new XElement("Value", x.Value))).ToArray()));
|
||||
}
|
||||
}
|
@ -21,7 +21,10 @@ namespace BlacksmithWorkshopListImplement
|
||||
//список для хранения заказов
|
||||
public List<Order> Orders { get; set; }
|
||||
|
||||
//список для хранения клиентов
|
||||
//список для хранения Магазинов
|
||||
public List<Shop> Shops { get; set; }
|
||||
|
||||
//список для хранения Магазинов
|
||||
public List<Client> Clients { get; set; }
|
||||
|
||||
public DataListSingleton()
|
||||
@ -29,6 +32,7 @@ namespace BlacksmithWorkshopListImplement
|
||||
WorkPieces = new List<WorkPiece>();
|
||||
Manufactures = new List<Manufacture>();
|
||||
Orders = new List<Order>();
|
||||
Shops = new List<Shop>();
|
||||
Clients = new List<Client>();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,134 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using BlacksmithWorkshopListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
|
||||
public ShopStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id))
|
||||
{
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.ShopName.Contains(model.ShopName))
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (model.Id <= shop.Id)
|
||||
{
|
||||
model.Id = shop.Id + 1;
|
||||
}
|
||||
}
|
||||
|
||||
var newShop = Shop.Create(model);
|
||||
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_source.Shops.Add(newShop);
|
||||
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.Id == model.Id)
|
||||
{
|
||||
shop.Update(model);
|
||||
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||
{
|
||||
if (_source.Shops[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Shops[i];
|
||||
_source.Shops.RemoveAt(i);
|
||||
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool SellManufactures(IManufactureModel model, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
public DateTime DateOpen { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
|
||||
public int MaxCountManufactures { get; set; }
|
||||
|
||||
public Dictionary<int, (IManufactureModel, int)> ShopManufactures { get; private set; } =
|
||||
new Dictionary<int, (IManufactureModel, int)>();
|
||||
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpen = model.DateOpen,
|
||||
ShopManufactures = model.ShopManufactures
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if(model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpen = model.DateOpen;
|
||||
ShopManufactures = model.ShopManufactures;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpen = DateOpen,
|
||||
ShopManufactures = ShopManufactures
|
||||
};
|
||||
}
|
||||
}
|
57
BlacksmithWorkshop/BlacksmithWorkshopShopApp/APIClient.cs
Normal file
57
BlacksmithWorkshop/BlacksmithWorkshopShopApp/APIClient.cs
Normal file
@ -0,0 +1,57 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
|
||||
namespace BlacksmithWorkshopShopApp
|
||||
{
|
||||
public class APIClient
|
||||
{
|
||||
private static readonly HttpClient _client = new();
|
||||
|
||||
public static string Password { get; private set; } = string.Empty;
|
||||
|
||||
public static bool InSystem { get; private set; }
|
||||
|
||||
public static void Connect(IConfiguration configuration)
|
||||
{
|
||||
_client.BaseAddress = new Uri(configuration["IPAddress"]);
|
||||
Password = configuration["Password"];
|
||||
_client.DefaultRequestHeaders.Accept.Clear();
|
||||
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
}
|
||||
|
||||
public static bool CheckPassword(string password)
|
||||
{
|
||||
APIClient.InSystem = password == Password;
|
||||
return APIClient.InSystem;
|
||||
}
|
||||
|
||||
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,270 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopShopApp.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace BlacksmithWorkshopShopApp.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly ILogger<HomeController> _logger;
|
||||
|
||||
public HomeController(ILogger<HomeController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public IActionResult Index()
|
||||
{
|
||||
if (!APIClient.InSystem)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<ShopViewModel>>($"api/shop/getshoplist"));
|
||||
}
|
||||
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
if (!APIClient.InSystem)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Enter()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Enter(string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(password))
|
||||
{
|
||||
throw new Exception("Введите пароль");
|
||||
}
|
||||
|
||||
if (APIClient.CheckPassword(password))
|
||||
{
|
||||
throw new Exception("Неверный пароль");
|
||||
}
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Create()
|
||||
{
|
||||
if (!APIClient.InSystem)
|
||||
{
|
||||
throw new Exception("Вход только для авторизованных пользователей");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(string name, string address, int count, DateTime date)
|
||||
{
|
||||
if (!APIClient.InSystem)
|
||||
{
|
||||
throw new Exception("Вход только для авторизованных пользователей");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Отсутствует название магазина");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(address))
|
||||
{
|
||||
throw new Exception("Отсутствует адрес магазина");
|
||||
}
|
||||
|
||||
if (date <= DateTime.MinValue)
|
||||
{
|
||||
throw new Exception("Ещё скажи, что ты с Петром 1 и Иваном Грозным знаком");
|
||||
}
|
||||
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new Exception("Вместимость магазина должна быть больше 0");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/shop/createshop", new ShopBindingModel
|
||||
{
|
||||
ShopName = name,
|
||||
MaxCountManufactures = count,
|
||||
Address = address,
|
||||
DateOpen = date
|
||||
});
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Update()
|
||||
{
|
||||
if (!APIClient.InSystem)
|
||||
{
|
||||
throw new Exception("Вход только для авторизованных пользователей");
|
||||
}
|
||||
|
||||
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>("api/shop/getshoplist");
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Update(int shop, string name, string address, int count, DateTime date)
|
||||
{
|
||||
if (!APIClient.InSystem)
|
||||
{
|
||||
throw new Exception("Вход только для авторизованных пользователей");
|
||||
}
|
||||
|
||||
if (shop <= 0)
|
||||
{
|
||||
throw new Exception("Некорректный идентификатор магазина");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(name))
|
||||
{
|
||||
throw new Exception("Отсутствует название магазина");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(address))
|
||||
{
|
||||
throw new Exception("Отсутствует адрес магазина");
|
||||
}
|
||||
|
||||
if (date <= DateTime.MinValue)
|
||||
{
|
||||
throw new Exception("Ещё скажи, что ты с Петром 1 и Иваном Грозным знаком");
|
||||
}
|
||||
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new Exception("Вместимость магазина должна быть больше 0");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/shop/updateshop", new ShopBindingModel
|
||||
{
|
||||
Id = shop,
|
||||
ShopName = name,
|
||||
MaxCountManufactures = count,
|
||||
Address = address,
|
||||
DateOpen = date
|
||||
});
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Delete()
|
||||
{
|
||||
if (!APIClient.InSystem)
|
||||
{
|
||||
throw new Exception("Вход только для авторизованных пользователей");
|
||||
}
|
||||
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>("api/shop/getshoplist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Delete(int shop)
|
||||
{
|
||||
if (!APIClient.InSystem)
|
||||
{
|
||||
throw new Exception("Вход только для авторизованных пользователей");
|
||||
}
|
||||
|
||||
if (shop <= 0)
|
||||
{
|
||||
throw new Exception("Некорректный идентификатор магазина");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/shop/deleteshop", new ShopBindingModel
|
||||
{
|
||||
Id = shop
|
||||
});
|
||||
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult AddManufacture()
|
||||
{
|
||||
ViewBag.Shops = APIClient.GetRequest<List<ShopViewModel>>("api/shop/getshoplist");
|
||||
ViewBag.Manufactures = APIClient.GetRequest<List<ManufactureViewModel>>("api/main/getmanufacturelist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void AddManufacture(int shop, int manufacture, int count)
|
||||
{
|
||||
if (!APIClient.InSystem)
|
||||
{
|
||||
throw new Exception("Вход только для авторизованных пользователей");
|
||||
}
|
||||
|
||||
if (shop <= 0)
|
||||
{
|
||||
throw new Exception("Некорректный идентификатор магазина");
|
||||
}
|
||||
|
||||
if (manufacture <= 0)
|
||||
{
|
||||
throw new Exception("Некорректный идентификатор изделия");
|
||||
}
|
||||
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new Exception("Вместимость магазина должна быть больше 0");
|
||||
}
|
||||
|
||||
APIClient.PostRequest("api/shop/addmanufacture", new Tuple<ShopSearchModel, ManufactureBindingModel, int>(new()
|
||||
{
|
||||
Id = shop
|
||||
}, new()
|
||||
{
|
||||
Id = manufacture
|
||||
}, count));
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public Tuple<ShopViewModel, string, string> GetManufactures(int shop)
|
||||
{
|
||||
var shopViewModel = APIClient.GetRequest<ShopViewModel>($"api/shop/getshop?shopId={shop}");
|
||||
|
||||
if (shopViewModel == null)
|
||||
{
|
||||
throw new Exception("Неизвестная ошибка");
|
||||
}
|
||||
|
||||
string tbody = "<td>";
|
||||
|
||||
// Самый адекватный вариант перевода даты, чтобы она отображалась в инпуте
|
||||
var correctDate = shopViewModel.DateOpen.ToString("yyyy'-'MM'-'dd'T'HH':'mm':'ss");
|
||||
|
||||
shopViewModel.ShopManufactureList.ForEach(x =>
|
||||
{
|
||||
tbody += $"<tr><td>{x.Item1.ManufactureName}</td><td>{x.Item2}</td>";
|
||||
});
|
||||
|
||||
tbody += "</td>";
|
||||
|
||||
return new Tuple<ShopViewModel, string, string>(shopViewModel, tbody, correctDate);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace BlacksmithWorkshopShopApp.Models
|
||||
{
|
||||
public class ErrorViewModel
|
||||
{
|
||||
public string? RequestId { get; set; }
|
||||
|
||||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
|
||||
}
|
||||
}
|
31
BlacksmithWorkshop/BlacksmithWorkshopShopApp/Program.cs
Normal file
31
BlacksmithWorkshop/BlacksmithWorkshopShopApp/Program.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using BlacksmithWorkshopShopApp;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
APIClient.Connect(builder.Configuration);
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
if (!app.Environment.IsDevelopment())
|
||||
{
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||||
app.UseHsts();
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
|
||||
app.Run();
|
@ -0,0 +1,28 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:1331",
|
||||
"sslPort": 44383
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"BlacksmithWorkshopShopApp": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"applicationUrl": "https://localhost:7072;http://localhost:5005",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
@{
|
||||
ViewData["Title"] = "AddManufacture";
|
||||
}
|
||||
|
||||
<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">
|
||||
<select id="shop" name="shop" class="form-control" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Изделие:</div>
|
||||
<div class="col-8">
|
||||
<select id="manufacture" name="manufacture" class="form-control" asp-items="@(new SelectList(@ViewBag.Manufactures,"Id", "ManufactureName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Количество изделий:</div>
|
||||
<div class="col-8"><input type="text" id="count" name="count" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Добавить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,29 @@
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
}
|
||||
|
||||
<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="text" name="name" id="name" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Адрес магазина:</div>
|
||||
<div class="col-8"><input type="text" name="address" id="address" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата открытия:</div>
|
||||
<div class="col-8"><input type="datetime-local" id="date" name="date" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Вместимость магазина:</div>
|
||||
<div class="col-8"><input type="text" id="count" name="count" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,19 @@
|
||||
@{
|
||||
ViewData["Title"] = "Delete";
|
||||
}
|
||||
|
||||
<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">
|
||||
<select id="shop" name="shop" class="form-control" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Удалить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,17 @@
|
||||
@{
|
||||
ViewData["Title"] = "Enter";
|
||||
}
|
||||
|
||||
<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 class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Вход" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -0,0 +1,72 @@
|
||||
@using BlacksmithWorkshopContracts.ViewModels
|
||||
|
||||
@model List<ShopViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Магазины</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Создать магазин</a>
|
||||
<a asp-action="Update">Изменить магазин</a>
|
||||
<a asp-action="Delete">Удалить магазин</a>
|
||||
<a asp-action="AddManufacture">Добавить изделие</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Адрес магазина
|
||||
</th>
|
||||
<th>
|
||||
Дата
|
||||
</th>
|
||||
<th>
|
||||
Дата открытия
|
||||
</th>
|
||||
<th>
|
||||
Вместимость магазина
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ShopName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Address)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.DateOpen)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.MaxCountManufactures)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -0,0 +1,6 @@
|
||||
@{
|
||||
ViewData["Title"] = "Privacy Policy";
|
||||
}
|
||||
<h1>@ViewData["Title"]</h1>
|
||||
|
||||
<p>Use this page to detail your site's privacy policy.</p>
|
@ -0,0 +1,90 @@
|
||||
@{
|
||||
ViewData["Title"] = "Update";
|
||||
}
|
||||
|
||||
<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">
|
||||
<select id="shop" name="shop" class="form-control" asp-items="@(new SelectList(@ViewBag.Shops,"Id", "ShopName"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Название магазина:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Адрес магазина:</div>
|
||||
<div class="col-8"><input type="text" name="address" id="address" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата открытия:</div>
|
||||
<div class="col-8"><input type="datetime-local" id="date" name="date" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Вместимость магазина:</div>
|
||||
<div class="col-8"><input type="text" id="count" name="count" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Изменить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Изделие
|
||||
</th>
|
||||
<th>
|
||||
Количество
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tablebody">
|
||||
</tbody>
|
||||
</table>
|
||||
@section Scripts{
|
||||
<script>
|
||||
$('#shop').on('change', function () {
|
||||
check();
|
||||
});
|
||||
function check() {
|
||||
var shop = $('#shop').val();
|
||||
if (shop)
|
||||
{
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/GetManufactures",
|
||||
data: { shop: shop },
|
||||
success: function (result) {
|
||||
$('#name').val(result.item1.shopName);
|
||||
$('#address').val(result.item1.address);
|
||||
$('#date').val(result.item3);
|
||||
$('#count').val(result.item1.maxCountManufactures);
|
||||
document.getElementById("tablebody").innerHTML = result.item2;
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
url: "/Home/GetManufactures",
|
||||
data: { shop: @ViewBag.Shops[0].Id},
|
||||
success: function (result) {
|
||||
$('#name').val(result.item1.shopName);
|
||||
$('#address').val(result.item1.address);
|
||||
$('#date').val(result.item3);
|
||||
$('#count').val(result.item1.maxCountManufactures);
|
||||
document.getElementById("tablebody").innerHTML = result.item2;
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
check();
|
||||
</script>
|
||||
}
|
@ -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"] - BlacksmithWorkshopShopApp</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="~/BlacksmithWorkshopShopApp.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">BlacksmithWorkshopShopApp</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</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 - BlacksmithWorkshopShopApp - <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 BlacksmithWorkshopShopApp
|
||||
@using BlacksmithWorkshopShopApp.Models
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user