в програм добавлены нужные зависимости, нужно изменить форму магазина и везде прописать логику

This commit is contained in:
ekallin 2024-03-10 23:53:01 +04:00
parent 85e2c1f027
commit 7f730736d9
7 changed files with 211 additions and 47 deletions

View File

@ -38,6 +38,7 @@
buttonOrderReady = new Button(); buttonOrderReady = new Button();
buttonOrderIssued = new Button(); buttonOrderIssued = new Button();
buttonRefreshOrders = new Button(); buttonRefreshOrders = new Button();
магазиныToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout(); menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); SuspendLayout();
@ -54,7 +55,7 @@
// //
// ToolStripMenuItemRef // ToolStripMenuItemRef
// //
ToolStripMenuItemRef.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, сушиToolStripMenuItem }); ToolStripMenuItemRef.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, сушиToolStripMenuItem, магазиныToolStripMenuItem });
ToolStripMenuItemRef.Name = "ToolStripMenuItemRef"; ToolStripMenuItemRef.Name = "ToolStripMenuItemRef";
ToolStripMenuItemRef.Size = new Size(117, 24); ToolStripMenuItemRef.Size = new Size(117, 24);
ToolStripMenuItemRef.Text = "Справочники"; ToolStripMenuItemRef.Text = "Справочники";
@ -62,14 +63,14 @@
// компонентыToolStripMenuItem // компонентыToolStripMenuItem
// //
компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem"; компонентыToolStripMenuItem.Name = омпонентыToolStripMenuItem";
компонентыToolStripMenuItem.Size = new Size(182, 26); компонентыToolStripMenuItem.Size = new Size(224, 26);
компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Text = "Компоненты";
компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click; компонентыToolStripMenuItem.Click += компонентыToolStripMenuItem_Click;
// //
// сушиToolStripMenuItem // сушиToolStripMenuItem
// //
сушиToolStripMenuItem.Name = "сушиToolStripMenuItem"; сушиToolStripMenuItem.Name = "сушиToolStripMenuItem";
сушиToolStripMenuItem.Size = new Size(182, 26); сушиToolStripMenuItem.Size = new Size(224, 26);
сушиToolStripMenuItem.Text = "Суши"; сушиToolStripMenuItem.Text = "Суши";
сушиToolStripMenuItem.Click += сушиToolStripMenuItem_Click; сушиToolStripMenuItem.Click += сушиToolStripMenuItem_Click;
// //
@ -134,6 +135,13 @@
buttonRefreshOrders.Text = "Обновить заказы"; buttonRefreshOrders.Text = "Обновить заказы";
buttonRefreshOrders.UseVisualStyleBackColor = true; buttonRefreshOrders.UseVisualStyleBackColor = true;
// //
// магазиныToolStripMenuItem
//
магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem";
магазиныToolStripMenuItem.Size = new Size(224, 26);
магазиныToolStripMenuItem.Text = "Магазины";
магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click;
//
// FormMain // FormMain
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(8F, 20F);
@ -170,5 +178,6 @@
private Button buttonRefreshOrders; private Button buttonRefreshOrders;
private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem;
private ToolStripMenuItem сушиToolStripMenuItem; private ToolStripMenuItem сушиToolStripMenuItem;
private ToolStripMenuItem магазиныToolStripMenuItem;
} }
} }

View File

@ -2,6 +2,7 @@
using SushiBar; using SushiBar;
using SushiBarContracts.BindingModel; using SushiBarContracts.BindingModel;
using SushiBarContracts.BusinessLogicsContracts; using SushiBarContracts.BusinessLogicsContracts;
using SushiBarView.Shops;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -61,7 +62,13 @@ namespace SushiBarView
private void сушиToolStripMenuItem_Click(object sender, EventArgs e) private void сушиToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormSushis)); var service = Program.ServiceProvider?.GetService(typeof(FormSushis));
if(service is FormSushis formSushis) { formSushis.ShowDialog(); } if (service is FormSushis formSushis) { formSushis.ShowDialog(); }
}
private void магазиныToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
if(service is FormShops formShops) { formShops.ShowDialog(); }
} }
private void buttonCreateOrder_Click(object sender, EventArgs e) private void buttonCreateOrder_Click(object sender, EventArgs e)
@ -148,7 +155,5 @@ namespace SushiBarView
{ {
LoadData(); LoadData();
} }
} }
} }

View File

@ -6,6 +6,7 @@ using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.StoragesContracts; using SushiBarContracts.StoragesContracts;
using SushiBarListImplements.Implements; using SushiBarListImplements.Implements;
using SushiBarView; using SushiBarView;
using SushiBarView.Shops;
namespace SushiBar namespace SushiBar
{ {
@ -51,6 +52,8 @@ namespace SushiBar
services.AddTransient<FormSushi>(); services.AddTransient<FormSushi>();
services.AddTransient<FormSushiComponent>(); services.AddTransient<FormSushiComponent>();
services.AddTransient<FormSushis>(); services.AddTransient<FormSushis>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
} }
} }
} }

View File

@ -1,4 +1,8 @@
using System; using Microsoft.Extensions.Logging;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.SearchModel;
using SushiBarDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Data; using System.Data;
@ -7,14 +11,77 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace SushiBarView.Shops namespace SushiBarView.Shops
{ {
public partial class FormShop : Form public partial class FormShop : Form
{ {
public FormShop() private readonly ILogger _logger;
private readonly IShopLogic _logic;
private int? _id;
public int Id
{ {
set { _id = value; }
}
private Dictionary<int, (ISushiModel, int)> _shopSushis;
public FormShop(ILogger logger, IShopLogic shopLogic)
{
_logger = logger;
_logic = shopLogic;
_shopSushis = new Dictionary<int, (ISushiModel, int)>();
InitializeComponent(); InitializeComponent();
} }
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.Name;
textBoxAddress.Text = view.Address;
dateTimePickerDateOpening.Text = view.DateOpening.ToString();
_shopSushis = view.ShopSushis ?? new Dictionary<int, (ISushiModel, int)>();
LoadData();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки магазина");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void LoadData() {
_logger.LogInformation("Загрузка изделий магазина");
try
{
if (_shopSushis != null)
{
dataGridView.Rows.Clear();
foreach (var elem in _shopPlanes)
{
dataGridView.Rows.Add(new object[]
{
elem.Key,
elem.Value.Item1.PlaneName,
elem.Value.Item2
});
}
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки изделий магазина");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
} }
} }

View File

@ -28,12 +28,94 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); dataGridView = new DataGridView();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; buttonRefresh = new Button();
this.ClientSize = new System.Drawing.Size(800, 450); buttonRemove = new Button();
this.Text = "FormShops"; buttonUpdate = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.BackgroundColor = Color.FromArgb(150, 190, 255);
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Left;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(566, 543);
dataGridView.TabIndex = 0;
//
// buttonRefresh
//
buttonRefresh.Font = new Font("Candara", 12F);
buttonRefresh.Location = new Point(626, 453);
buttonRefresh.Name = "buttonRefresh";
buttonRefresh.Size = new Size(121, 46);
buttonRefresh.TabIndex = 8;
buttonRefresh.Text = "Обновить";
buttonRefresh.UseVisualStyleBackColor = true;
//
// buttonRemove
//
buttonRemove.Font = new Font("Candara", 12F);
buttonRemove.Location = new Point(626, 316);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(121, 46);
buttonRemove.TabIndex = 7;
buttonRemove.Text = "Удалить";
buttonRemove.UseVisualStyleBackColor = true;
//
// buttonUpdate
//
buttonUpdate.Font = new Font("Candara", 12F);
buttonUpdate.Location = new Point(626, 176);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(121, 46);
buttonUpdate.TabIndex = 6;
buttonUpdate.Text = "Изменить";
buttonUpdate.UseVisualStyleBackColor = true;
//
// buttonAdd
//
buttonAdd.Font = new Font("Candara", 12F);
buttonAdd.Location = new Point(626, 44);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(121, 46);
buttonAdd.TabIndex = 5;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// FormShops
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = Color.FromArgb(190, 220, 255);
ClientSize = new Size(800, 543);
Controls.Add(buttonRefresh);
Controls.Add(buttonRemove);
Controls.Add(buttonUpdate);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormShops";
Text = "Магазины";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
} }
#endregion #endregion
private DataGridView dataGridView;
private Button buttonRefresh;
private Button buttonRemove;
private Button buttonUpdate;
private Button buttonAdd;
} }
} }

View File

@ -1,20 +1,18 @@
using System; using Microsoft.Extensions.Logging;
using System.Collections.Generic; using SushiBarContracts.BusinessLogicsContracts;
using System.ComponentModel; using SushiBarContracts.SearchModel;
using System.Data; using SushiBarDataModels.Models;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace SushiBarView.Shops namespace SushiBarView.Shops
{ {
public partial class FormShops : Form public partial class FormShops : Form
{ {
public FormShops()
private void buttonAdd_Click(object sender, EventArgs e)
{ {
InitializeComponent();
} }
} }
} }

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->