да хватит скидывать формы
This commit is contained in:
parent
9d7448d69f
commit
4c0de91edb
2
ProjectFlowerShop/FormComponents.Designer.cs
generated
2
ProjectFlowerShop/FormComponents.Designer.cs
generated
@ -123,7 +123,7 @@
|
||||
Controls.Add(buttonChange);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormComponents";
|
||||
//Name = "FormComponents";
|
||||
Text = "Компоненты";
|
||||
Load += FormComponents_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
|
45
ProjectFlowerShop/FormCreateOrder.Designer.cs
generated
Normal file
45
ProjectFlowerShop/FormCreateOrder.Designer.cs
generated
Normal file
@ -0,0 +1,45 @@
|
||||
namespace ProjectFlowerShop
|
||||
{
|
||||
partial class FormCreateOrder
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
SuspendLayout();
|
||||
//
|
||||
// FormCreateOrder
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(517, 193);
|
||||
Name = "FormCreateOrder";
|
||||
Text = "Заказ";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
20
ProjectFlowerShop/FormCreateOrder.cs
Normal file
20
ProjectFlowerShop/FormCreateOrder.cs
Normal file
@ -0,0 +1,20 @@
|
||||
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 ProjectFlowerShop
|
||||
{
|
||||
public partial class FormCreateOrder : Form
|
||||
{
|
||||
public FormCreateOrder()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
120
ProjectFlowerShop/FormCreateOrder.resx
Normal file
120
ProjectFlowerShop/FormCreateOrder.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
242
ProjectFlowerShop/FormProduct.Designer.cs
generated
Normal file
242
ProjectFlowerShop/FormProduct.Designer.cs
generated
Normal file
@ -0,0 +1,242 @@
|
||||
namespace ProjectFlowerShop
|
||||
{
|
||||
partial class FormProduct
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelName = new Label();
|
||||
labelPrice = new Label();
|
||||
textBoxName = new TextBox();
|
||||
textBoxPrice = new TextBox();
|
||||
groupBoxComponent = new GroupBox();
|
||||
buttonRefresh = new Button();
|
||||
buttonRemove = new Button();
|
||||
buttonChange = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
Save = new Button();
|
||||
buttonCancel = new Button();
|
||||
Name = new DataGridViewTextBoxColumn();
|
||||
Component = new DataGridViewTextBoxColumn();
|
||||
idd = new DataGridViewTextBoxColumn();
|
||||
Numbers = new DataGridViewTextBoxColumn();
|
||||
groupBoxComponent.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(18, 18);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(77, 20);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "Название";
|
||||
//
|
||||
// labelPrice
|
||||
//
|
||||
labelPrice.AutoSize = true;
|
||||
labelPrice.Location = new Point(18, 59);
|
||||
labelPrice.Name = "labelPrice";
|
||||
labelPrice.Size = new Size(45, 20);
|
||||
labelPrice.TabIndex = 1;
|
||||
labelPrice.Text = "Цена";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(101, 15);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(204, 27);
|
||||
textBoxName.TabIndex = 2;
|
||||
textBoxName.TextChanged += textBox1_TextChanged;
|
||||
//
|
||||
// textBoxPrice
|
||||
//
|
||||
textBoxPrice.Location = new Point(101, 56);
|
||||
textBoxPrice.Name = "textBoxPrice";
|
||||
textBoxPrice.Size = new Size(204, 27);
|
||||
textBoxPrice.TabIndex = 3;
|
||||
//
|
||||
// groupBoxComponent
|
||||
//
|
||||
groupBoxComponent.Controls.Add(buttonRefresh);
|
||||
groupBoxComponent.Controls.Add(buttonRemove);
|
||||
groupBoxComponent.Controls.Add(buttonChange);
|
||||
groupBoxComponent.Controls.Add(buttonAdd);
|
||||
groupBoxComponent.Controls.Add(dataGridView);
|
||||
groupBoxComponent.Location = new Point(12, 144);
|
||||
groupBoxComponent.Name = "groupBoxComponent";
|
||||
groupBoxComponent.Size = new Size(646, 294);
|
||||
groupBoxComponent.TabIndex = 4;
|
||||
groupBoxComponent.TabStop = false;
|
||||
groupBoxComponent.Text = "Компоненты";
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
buttonRefresh.Location = new Point(450, 173);
|
||||
buttonRefresh.Name = "buttonRefresh";
|
||||
buttonRefresh.Size = new Size(190, 29);
|
||||
buttonRefresh.TabIndex = 4;
|
||||
buttonRefresh.Text = "Обновить";
|
||||
buttonRefresh.UseVisualStyleBackColor = true;
|
||||
buttonRefresh.Click += buttonRefresh_Click;
|
||||
//
|
||||
// buttonRemove
|
||||
//
|
||||
buttonRemove.Location = new Point(450, 122);
|
||||
buttonRemove.Name = "buttonRemove";
|
||||
buttonRemove.Size = new Size(190, 29);
|
||||
buttonRemove.TabIndex = 3;
|
||||
buttonRemove.Text = "Удалить";
|
||||
buttonRemove.UseVisualStyleBackColor = true;
|
||||
buttonRemove.Click += buttonRemove_Click;
|
||||
//
|
||||
// buttonChange
|
||||
//
|
||||
buttonChange.Location = new Point(450, 74);
|
||||
buttonChange.Name = "buttonChange";
|
||||
buttonChange.Size = new Size(190, 29);
|
||||
buttonChange.TabIndex = 2;
|
||||
buttonChange.Text = "Изменить";
|
||||
buttonChange.UseVisualStyleBackColor = true;
|
||||
buttonChange.Click += buttonChange_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(450, 26);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(190, 29);
|
||||
buttonAdd.TabIndex = 1;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Component, idd, Numbers });
|
||||
dataGridView.Location = new Point(6, 26);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(432, 262);
|
||||
dataGridView.TabIndex = 0;
|
||||
dataGridView.CellContentClick += dataGridView_CellContentClick;
|
||||
//
|
||||
// Save
|
||||
//
|
||||
Save.Location = new Point(462, 446);
|
||||
Save.Name = "Save";
|
||||
Save.Size = new Size(94, 29);
|
||||
Save.TabIndex = 5;
|
||||
Save.Text = "Сохранить";
|
||||
Save.UseVisualStyleBackColor = true;
|
||||
Save.Click += Save_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(564, 446);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 6;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// Name
|
||||
//
|
||||
Name.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
Name.HeaderText = "Компонент";
|
||||
Name.MinimumWidth = 6;
|
||||
Name.Name = "Name";
|
||||
//
|
||||
// Component
|
||||
//
|
||||
Component.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
Component.HeaderText = "Компонент";
|
||||
Component.MinimumWidth = 6;
|
||||
Component.Name = "Component";
|
||||
//
|
||||
// idd
|
||||
//
|
||||
idd.HeaderText = "idd";
|
||||
idd.MinimumWidth = 6;
|
||||
idd.Name = "idd";
|
||||
idd.Visible = false;
|
||||
idd.Width = 125;
|
||||
//
|
||||
// Numbers
|
||||
//
|
||||
Numbers.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
Numbers.HeaderText = "Количество";
|
||||
Numbers.MinimumWidth = 6;
|
||||
Numbers.Name = "Numbers";
|
||||
//
|
||||
// FormProduct
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(670, 479);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(Save);
|
||||
Controls.Add(groupBoxComponent);
|
||||
Controls.Add(textBoxPrice);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelPrice);
|
||||
Controls.Add(labelName);
|
||||
// Name = "FormProduct";
|
||||
Text = "Изделие";
|
||||
Load += FormProduct_Load;
|
||||
groupBoxComponent.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private Label labelPrice;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxPrice;
|
||||
private GroupBox groupBoxComponent;
|
||||
private Button buttonRefresh;
|
||||
private Button buttonRemove;
|
||||
private Button buttonChange;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
private Button Save;
|
||||
private Button buttonCancel;
|
||||
// private DataGridViewTextBoxColumn Id;
|
||||
private DataGridViewTextBoxColumn Name;
|
||||
private DataGridViewTextBoxColumn Number;
|
||||
//private DataGridViewTextBoxColumn Id;
|
||||
private DataGridViewTextBoxColumn Component;
|
||||
private DataGridViewTextBoxColumn idd;
|
||||
private DataGridViewTextBoxColumn Numbers;
|
||||
}
|
||||
}
|
242
ProjectFlowerShop/FormProduct.cs
Normal file
242
ProjectFlowerShop/FormProduct.cs
Normal file
@ -0,0 +1,242 @@
|
||||
using FlowerShopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using FlowerShopContracts.BusinessLogicsContracts;
|
||||
using FlowerShopContracts.SearchModels;
|
||||
using FlowerShopContracts.BindingModels;
|
||||
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 ProjectFlowerShop
|
||||
{
|
||||
public partial class FormProduct : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFlowerLogic _logic;
|
||||
private int? _id;
|
||||
private Dictionary<int, (IComponentModel, int)> _flowerComponents;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormProduct(ILogger<FormProduct> logger, IFlowerLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_flowerComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||
}
|
||||
|
||||
private void textBox1_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void FormProduct_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделия");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new FlowerSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.FlowerName;
|
||||
textBoxPrice.Text = view.Price.ToString();
|
||||
_flowerComponents = view.FlowerComponents ?? new
|
||||
Dictionary<int, (IComponentModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка компонент изделия");
|
||||
try
|
||||
{
|
||||
if (_flowerComponents != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var pc in _flowerComponents)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
||||
}
|
||||
textBoxPrice.Text = CalcPrice().ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormProductComponent));
|
||||
if (service is FormProductComponent form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление нового компонента:{ ComponentName}- { Count} ", form.ComponentModel.ComponentName, form.Count);
|
||||
if (_flowerComponents.ContainsKey(form.Id))
|
||||
{
|
||||
_flowerComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
_flowerComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buttonChange_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service =
|
||||
Program.ServiceProvider?.GetService(typeof(FormProductComponent));
|
||||
if (service is FormProductComponent form)
|
||||
{
|
||||
int id =
|
||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _flowerComponents[id].Item2;
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.ComponentModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Изменение компонента:{ ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
_flowerComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buttonRemove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Удаление компонента: { ComponentName}- { Count}", dataGridView.SelectedRows[0].Cells[1].Value);
|
||||
_flowerComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void Save_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (_flowerComponents == null || _flowerComponents.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Заполните компоненты", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение изделия");
|
||||
try
|
||||
{
|
||||
var model = new FlowerBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
FlowerName = textBoxName.Text,
|
||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||
FlowerComponents = _flowerComponents
|
||||
};
|
||||
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();
|
||||
}
|
||||
|
||||
private double CalcPrice()
|
||||
{
|
||||
double price = 0;
|
||||
foreach (var elem in _flowerComponents)
|
||||
{
|
||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||
}
|
||||
return Math.Round(price * 1.1, 2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
141
ProjectFlowerShop/FormProduct.resx
Normal file
141
ProjectFlowerShop/FormProduct.resx
Normal file
@ -0,0 +1,141 @@
|
||||
<?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>
|
||||
<metadata name="Component.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="idd.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Numbers.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Component.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="idd.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Numbers.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user