PIbd - 21 Bakalskaya E.D. LabWork01 HARD #8

Closed
ekallin wants to merge 8 commits from LabWork11 into LabWork01
7 changed files with 211 additions and 47 deletions
Showing only changes of commit 7f730736d9 - Show all commits

View File

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

View File

@ -2,6 +2,7 @@
using SushiBar;
using SushiBarContracts.BindingModel;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarView.Shops;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -61,7 +62,13 @@ namespace SushiBarView
private void сушиToolStripMenuItem_Click(object sender, EventArgs e)
{
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)
@ -148,7 +155,5 @@ namespace SushiBarView
{
LoadData();
}
}
}

View File

@ -6,6 +6,7 @@ using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.StoragesContracts;
using SushiBarListImplements.Implements;
using SushiBarView;
using SushiBarView.Shops;
namespace SushiBar
{
@ -51,6 +52,8 @@ namespace SushiBar
services.AddTransient<FormSushi>();
services.AddTransient<FormSushiComponent>();
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.ComponentModel;
using System.Data;
@ -7,14 +11,77 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace SushiBarView.Shops
{
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();
}
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>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "FormShops";
dataGridView = new DataGridView();
buttonRefresh = new Button();
buttonRemove = new Button();
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
private DataGridView dataGridView;
private Button buttonRefresh;
private Button buttonRemove;
private Button buttonUpdate;
private Button buttonAdd;
}
}

View File

@ -1,20 +1,18 @@
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 Microsoft.Extensions.Logging;
using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.SearchModel;
using SushiBarDataModels.Models;
using System.Windows.Forms;
namespace SushiBarView.Shops
{
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"?>
<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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->