какая же у меня огромная жопа
This commit is contained in:
parent
d0e0776717
commit
86a0b43a9a
@ -18,11 +18,11 @@ namespace DatabaseImplement.Implements
|
||||
{
|
||||
using var context = new Database();
|
||||
var element = context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
//.Include(x => x.Name)
|
||||
//.Include(x => x.Price)
|
||||
//.Include(x => x.IsBeingSold)
|
||||
//.Include(x => x.Rate)
|
||||
//.Include(x => x.Amount)
|
||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
@ -41,11 +41,11 @@ namespace DatabaseImplement.Implements
|
||||
}
|
||||
using var context = new Database();
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
//.Include(x => x.Name)
|
||||
//.Include(x => x.Price)
|
||||
//.Include(x => x.IsBeingSold)
|
||||
//.Include(x => x.Rate)
|
||||
//.Include(x => x.Amount)
|
||||
.FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||
}
|
||||
|
||||
@ -59,11 +59,11 @@ namespace DatabaseImplement.Implements
|
||||
if (model.Price.HasValue)
|
||||
{
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
//.Include(x => x.Name)
|
||||
//.Include(x => x.Price)
|
||||
//.Include(x => x.IsBeingSold)
|
||||
//.Include(x => x.Rate)
|
||||
//.Include(x => x.Amount)
|
||||
.Where(x => x.Price <= model.Price)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -72,11 +72,11 @@ namespace DatabaseImplement.Implements
|
||||
if (model.Rate.HasValue)
|
||||
{
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
//.Include(x => x.Name)
|
||||
//.Include(x => x.Price)
|
||||
//.Include(x => x.IsBeingSold)
|
||||
//.Include(x => x.Rate)
|
||||
//.Include(x => x.Amount)
|
||||
.Where(x => x.Rate <= model.Rate)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -85,22 +85,22 @@ namespace DatabaseImplement.Implements
|
||||
if (model.Amount.HasValue && model.IsBeingSold.HasValue)
|
||||
{
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
//.Include(x => x.Name)
|
||||
//.Include(x => x.Price)
|
||||
//.Include(x => x.IsBeingSold)
|
||||
//.Include(x => x.Rate)
|
||||
//.Include(x => x.Amount)
|
||||
.Where(x => x.IsBeingSold == model.IsBeingSold && x.Amount >= model.Amount)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
//.Include(x => x.Name)
|
||||
//.Include(x => x.Price)
|
||||
//.Include(x => x.IsBeingSold)
|
||||
//.Include(x => x.Rate)
|
||||
//.Include(x => x.Amount)
|
||||
.Where(x => x.Name == model.Name)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
@ -111,11 +111,11 @@ namespace DatabaseImplement.Implements
|
||||
{
|
||||
using var context = new Database();
|
||||
return context.Products
|
||||
.Include(x => x.Name)
|
||||
.Include(x => x.Price)
|
||||
.Include(x => x.IsBeingSold)
|
||||
.Include(x => x.Rate)
|
||||
.Include(x => x.Amount)
|
||||
//.Include(x => x.Name)
|
||||
//.Include(x => x.Price)
|
||||
//.Include(x => x.IsBeingSold)
|
||||
//.Include(x => x.Rate)
|
||||
//.Include(x => x.Amount)
|
||||
.ToList()
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
|
32
WinFormsApp/FormMain.Designer.cs
generated
32
WinFormsApp/FormMain.Designer.cs
generated
@ -30,8 +30,10 @@
|
||||
{
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreateSupply = new Button();
|
||||
toolStrip1 = new ToolStrip();
|
||||
menuStrip1 = new MenuStrip();
|
||||
товарыToolStripMenuItem = new ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
@ -51,26 +53,37 @@
|
||||
buttonCreateSupply.Text = "Оформить поставку";
|
||||
buttonCreateSupply.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// toolStrip1
|
||||
// menuStrip1
|
||||
//
|
||||
toolStrip1.Location = new Point(0, 0);
|
||||
toolStrip1.Name = "toolStrip1";
|
||||
toolStrip1.Size = new Size(798, 25);
|
||||
toolStrip1.TabIndex = 2;
|
||||
toolStrip1.Text = "toolStrip1";
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { товарыToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(798, 24);
|
||||
menuStrip1.TabIndex = 2;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// товарыToolStripMenuItem
|
||||
//
|
||||
товарыToolStripMenuItem.Name = "товарыToolStripMenuItem";
|
||||
товарыToolStripMenuItem.Size = new Size(60, 20);
|
||||
товарыToolStripMenuItem.Text = "Товары";
|
||||
товарыToolStripMenuItem.Click += товарыToolStripMenuItem_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(798, 361);
|
||||
Controls.Add(toolStrip1);
|
||||
Controls.Add(buttonCreateSupply);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "FormMain";
|
||||
Text = "FormMain";
|
||||
Load += FormMain_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -79,6 +92,7 @@
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreateSupply;
|
||||
private ToolStrip toolStrip1;
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem товарыToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -51,5 +51,14 @@ namespace WinFormsApp
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void товарыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormProducts));
|
||||
if (service is FormProducts form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
192
WinFormsApp/FormProducts.Designer.cs
generated
Normal file
192
WinFormsApp/FormProducts.Designer.cs
generated
Normal file
@ -0,0 +1,192 @@
|
||||
namespace WinFormsApp
|
||||
{
|
||||
partial class FormProducts
|
||||
{
|
||||
/// <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();
|
||||
buttonCreateProduct = new Button();
|
||||
groupBoxControls = new GroupBox();
|
||||
groupBoxCreateProduct = new GroupBox();
|
||||
numericUpDownAmount = new NumericUpDown();
|
||||
numericUpDownPrice = new NumericUpDown();
|
||||
buttonCancel = new Button();
|
||||
buttonSaveProduct = new Button();
|
||||
checkBoxIsSold = new CheckBox();
|
||||
textBoxName = new TextBox();
|
||||
buttonUpdateProduct = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
groupBoxControls.SuspendLayout();
|
||||
groupBoxCreateProduct.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownAmount).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(12, 12);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.Size = new Size(631, 304);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonCreateProduct
|
||||
//
|
||||
buttonCreateProduct.Location = new Point(69, 22);
|
||||
buttonCreateProduct.Name = "buttonCreateProduct";
|
||||
buttonCreateProduct.Size = new Size(139, 23);
|
||||
buttonCreateProduct.TabIndex = 1;
|
||||
buttonCreateProduct.Text = "Добавить товар";
|
||||
buttonCreateProduct.UseVisualStyleBackColor = true;
|
||||
buttonCreateProduct.Click += buttonCreateProduct_Click;
|
||||
//
|
||||
// groupBoxControls
|
||||
//
|
||||
groupBoxControls.BackColor = Color.Transparent;
|
||||
groupBoxControls.Controls.Add(buttonUpdateProduct);
|
||||
groupBoxControls.Controls.Add(buttonCreateProduct);
|
||||
groupBoxControls.Location = new Point(649, 12);
|
||||
groupBoxControls.Name = "groupBoxControls";
|
||||
groupBoxControls.Size = new Size(264, 304);
|
||||
groupBoxControls.TabIndex = 2;
|
||||
groupBoxControls.TabStop = false;
|
||||
groupBoxControls.Text = "Действия";
|
||||
//
|
||||
// groupBoxCreateProduct
|
||||
//
|
||||
groupBoxCreateProduct.BackColor = Color.Transparent;
|
||||
groupBoxCreateProduct.Controls.Add(numericUpDownAmount);
|
||||
groupBoxCreateProduct.Controls.Add(numericUpDownPrice);
|
||||
groupBoxCreateProduct.Controls.Add(buttonCancel);
|
||||
groupBoxCreateProduct.Controls.Add(buttonSaveProduct);
|
||||
groupBoxCreateProduct.Controls.Add(checkBoxIsSold);
|
||||
groupBoxCreateProduct.Controls.Add(textBoxName);
|
||||
groupBoxCreateProduct.Location = new Point(649, 330);
|
||||
groupBoxCreateProduct.Name = "groupBoxCreateProduct";
|
||||
groupBoxCreateProduct.Size = new Size(257, 304);
|
||||
groupBoxCreateProduct.TabIndex = 3;
|
||||
groupBoxCreateProduct.TabStop = false;
|
||||
groupBoxCreateProduct.Text = "Создание/изменение продукта";
|
||||
//
|
||||
// numericUpDownAmount
|
||||
//
|
||||
numericUpDownAmount.Location = new Point(17, 153);
|
||||
numericUpDownAmount.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
|
||||
numericUpDownAmount.Name = "numericUpDownAmount";
|
||||
numericUpDownAmount.Size = new Size(120, 23);
|
||||
numericUpDownAmount.TabIndex = 7;
|
||||
//
|
||||
// numericUpDownPrice
|
||||
//
|
||||
numericUpDownPrice.DecimalPlaces = 2;
|
||||
numericUpDownPrice.Location = new Point(17, 94);
|
||||
numericUpDownPrice.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
|
||||
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||
numericUpDownPrice.Size = new Size(120, 23);
|
||||
numericUpDownPrice.TabIndex = 6;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(111, 235);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(75, 23);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonSaveProduct
|
||||
//
|
||||
buttonSaveProduct.Location = new Point(17, 235);
|
||||
buttonSaveProduct.Name = "buttonSaveProduct";
|
||||
buttonSaveProduct.Size = new Size(75, 23);
|
||||
buttonSaveProduct.TabIndex = 4;
|
||||
buttonSaveProduct.Text = "Сохранить";
|
||||
buttonSaveProduct.UseVisualStyleBackColor = true;
|
||||
buttonSaveProduct.Click += buttonSaveProduct_Click;
|
||||
//
|
||||
// checkBoxIsSold
|
||||
//
|
||||
checkBoxIsSold.AutoSize = true;
|
||||
checkBoxIsSold.Location = new Point(17, 210);
|
||||
checkBoxIsSold.Name = "checkBoxIsSold";
|
||||
checkBoxIsSold.Size = new Size(148, 19);
|
||||
checkBoxIsSold.TabIndex = 3;
|
||||
checkBoxIsSold.Text = "Поместить в магазин?";
|
||||
checkBoxIsSold.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(17, 40);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(100, 23);
|
||||
textBoxName.TabIndex = 0;
|
||||
//
|
||||
// buttonUpdateProduct
|
||||
//
|
||||
buttonUpdateProduct.Location = new Point(69, 62);
|
||||
buttonUpdateProduct.Name = "buttonUpdateProduct";
|
||||
buttonUpdateProduct.Size = new Size(139, 23);
|
||||
buttonUpdateProduct.TabIndex = 2;
|
||||
buttonUpdateProduct.Text = "Изменить товар";
|
||||
buttonUpdateProduct.UseVisualStyleBackColor = true;
|
||||
buttonUpdateProduct.Click += buttonUpdateProduct_Click;
|
||||
//
|
||||
// FormProducts
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(925, 646);
|
||||
Controls.Add(groupBoxCreateProduct);
|
||||
Controls.Add(groupBoxControls);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "FormProducts";
|
||||
Text = "FormProducts";
|
||||
Load += FormProducts_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
groupBoxControls.ResumeLayout(false);
|
||||
groupBoxCreateProduct.ResumeLayout(false);
|
||||
groupBoxCreateProduct.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownAmount).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreateProduct;
|
||||
private GroupBox groupBoxControls;
|
||||
private GroupBox groupBoxCreateProduct;
|
||||
private TextBox textBoxName;
|
||||
private Button buttonSaveProduct;
|
||||
private CheckBox checkBoxIsSold;
|
||||
private NumericUpDown numericUpDownAmount;
|
||||
private NumericUpDown numericUpDownPrice;
|
||||
private Button buttonCancel;
|
||||
private Button buttonUpdateProduct;
|
||||
}
|
||||
}
|
135
WinFormsApp/FormProducts.cs
Normal file
135
WinFormsApp/FormProducts.cs
Normal file
@ -0,0 +1,135 @@
|
||||
using BusinessLogic.BusinessLogic;
|
||||
using Contracts.BindingModels;
|
||||
using Contracts.BusinessLogicContracts;
|
||||
using Contracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinFormsApp
|
||||
{
|
||||
public partial class FormProducts : Form
|
||||
{
|
||||
private Guid? _id;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IProductLogic _productLogic;
|
||||
public FormProducts(ILogger<FormMain> logger, IProductLogic productLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_productLogic = productLogic;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
private void FormProducts_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
groupBoxCreateProduct.Hide();
|
||||
//groupBoxCreateProduct.Enabled = false;
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка товаров");
|
||||
try
|
||||
{
|
||||
var list = _productLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
}
|
||||
_logger.LogInformation("Загрузка товаров");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки товаров");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreateProduct_Click(object sender, EventArgs e)
|
||||
{
|
||||
//надо сделать че нибудь с фронтом а то всё грустно
|
||||
groupBoxControls.Hide();
|
||||
//groupBoxControls.Enabled = false;
|
||||
groupBoxCreateProduct.Show();
|
||||
//groupBoxCreateProduct.Enabled = true;
|
||||
}
|
||||
|
||||
private void buttonSaveProduct_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(numericUpDownPrice.Value.ToString()))
|
||||
{
|
||||
MessageBox.Show("Укажите цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(numericUpDownAmount.Value.ToString()))
|
||||
{
|
||||
MessageBox.Show("Укажите кол-во", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение товара");
|
||||
try
|
||||
{
|
||||
var model = new ProductBindingModel
|
||||
{
|
||||
Name = textBoxName.Text,
|
||||
Price = Convert.ToDouble(numericUpDownPrice.Value),
|
||||
Amount = Convert.ToInt16(numericUpDownAmount.Value),
|
||||
Rate = 0.0,
|
||||
IsBeingSold = checkBoxIsSold.Checked,
|
||||
};
|
||||
var operationResult = _productLogic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
groupBoxControls.Enabled = true;
|
||||
groupBoxControls.Show();
|
||||
groupBoxCreateProduct.Enabled = false;
|
||||
groupBoxCreateProduct.Hide();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения товара");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpdateProduct_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count <= 0) return;
|
||||
_id = (Guid)dataGridView.SelectedRows[0].Cells["Id"].Value;
|
||||
groupBoxControls.Hide();
|
||||
groupBoxCreateProduct.Show();
|
||||
_logger.LogInformation("Получение товара");
|
||||
var view = _productLogic.ReadElement(new ProductSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
textBoxName.Text = view.Name;
|
||||
numericUpDownPrice.Value = Convert.ToDecimal(view.Price);
|
||||
numericUpDownAmount.Value = view.Amount;
|
||||
checkBoxIsSold.Checked = view.IsBeingSold;
|
||||
}
|
||||
}
|
||||
}
|
120
WinFormsApp/FormProducts.resx
Normal file
120
WinFormsApp/FormProducts.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>
|
@ -45,6 +45,7 @@ namespace WinFormsApp
|
||||
services.AddTransient<IProductLogic, ProductLogic>();
|
||||
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormProducts>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user