вроде готовая лаба 2 хард
This commit is contained in:
parent
3c99a9a969
commit
8628d80362
18
Confectionery/ConfectioneryView/FormMain.Designer.cs
generated
18
Confectionery/ConfectioneryView/FormMain.Designer.cs
generated
@ -40,6 +40,7 @@
|
||||
this.ButtonOrderReady = new System.Windows.Forms.Button();
|
||||
this.ButtonIssuedOrder = new System.Windows.Forms.Button();
|
||||
this.ButtonRef = new System.Windows.Forms.Button();
|
||||
this.продажаВыпечкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -49,7 +50,8 @@
|
||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.справочникиToolStripMenuItem,
|
||||
this.пополнениеМагазинаToolStripMenuItem});
|
||||
this.пополнениеМагазинаToolStripMenuItem,
|
||||
this.продажаВыпечкиToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(1376, 28);
|
||||
@ -69,21 +71,21 @@
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
|
||||
this.компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
||||
//
|
||||
// изделияToolStripMenuItem
|
||||
//
|
||||
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
|
||||
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
|
||||
this.изделияToolStripMenuItem.Text = "Выпечка";
|
||||
this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(182, 26);
|
||||
this.магазиныToolStripMenuItem.Text = "Магазины";
|
||||
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.МагазиныToolStripMenuItem_Click);
|
||||
//
|
||||
@ -154,6 +156,13 @@
|
||||
this.ButtonRef.UseVisualStyleBackColor = true;
|
||||
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// продажаВыпечкиToolStripMenuItem
|
||||
//
|
||||
this.продажаВыпечкиToolStripMenuItem.Name = "продажаВыпечкиToolStripMenuItem";
|
||||
this.продажаВыпечкиToolStripMenuItem.Size = new System.Drawing.Size(151, 24);
|
||||
this.продажаВыпечкиToolStripMenuItem.Text = "Продажа выпечки";
|
||||
this.продажаВыпечкиToolStripMenuItem.Click += new System.EventHandler(this.продажаВыпечкиToolStripMenuItem_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
@ -192,5 +201,6 @@
|
||||
private Button ButtonRef;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
|
||||
private ToolStripMenuItem продажаВыпечкиToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -85,6 +85,14 @@ namespace ConfectioneryView
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void продажаВыпечкиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPastrySale));
|
||||
if (service is FormPastrySale form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreateOrder_Click(object sender, EventArgs e)
|
||||
{
|
||||
@ -179,7 +187,6 @@ namespace ConfectioneryView
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -28,12 +28,93 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.ButtonSale = new System.Windows.Forms.Button();
|
||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||
this.comboBoxPastry = new System.Windows.Forms.ComboBox();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.labelPastry = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(336, 113);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(94, 29);
|
||||
this.ButtonCancel.TabIndex = 13;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// ButtonSale
|
||||
//
|
||||
this.ButtonSale.Location = new System.Drawing.Point(191, 113);
|
||||
this.ButtonSale.Name = "ButtonSale";
|
||||
this.ButtonSale.Size = new System.Drawing.Size(94, 29);
|
||||
this.ButtonSale.TabIndex = 12;
|
||||
this.ButtonSale.Text = "Продать";
|
||||
this.ButtonSale.UseVisualStyleBackColor = true;
|
||||
this.ButtonSale.Click += new System.EventHandler(this.ButtonSale_Click);
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
this.textBoxCount.Location = new System.Drawing.Point(129, 65);
|
||||
this.textBoxCount.Name = "textBoxCount";
|
||||
this.textBoxCount.Size = new System.Drawing.Size(429, 27);
|
||||
this.textBoxCount.TabIndex = 11;
|
||||
//
|
||||
// comboBoxPastry
|
||||
//
|
||||
this.comboBoxPastry.FormattingEnabled = true;
|
||||
this.comboBoxPastry.Location = new System.Drawing.Point(129, 27);
|
||||
this.comboBoxPastry.Name = "comboBoxPastry";
|
||||
this.comboBoxPastry.Size = new System.Drawing.Size(429, 28);
|
||||
this.comboBoxPastry.TabIndex = 10;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(17, 72);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(93, 20);
|
||||
this.labelCount.TabIndex = 9;
|
||||
this.labelCount.Text = "Количество:";
|
||||
//
|
||||
// labelPastry
|
||||
//
|
||||
this.labelPastry.AutoSize = true;
|
||||
this.labelPastry.Location = new System.Drawing.Point(17, 35);
|
||||
this.labelPastry.Name = "labelPastry";
|
||||
this.labelPastry.Size = new System.Drawing.Size(72, 20);
|
||||
this.labelPastry.TabIndex = 8;
|
||||
this.labelPastry.Text = "Выпечка:";
|
||||
//
|
||||
// FormPastrySale
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "FormPastrySale";
|
||||
this.ClientSize = new System.Drawing.Size(573, 168);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.ButtonSale);
|
||||
this.Controls.Add(this.textBoxCount);
|
||||
this.Controls.Add(this.comboBoxPastry);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelPastry);
|
||||
this.Name = "FormPastrySale";
|
||||
this.Text = "Продажа выпечки";
|
||||
this.Load += new System.EventHandler(this.FormPastrySale_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button ButtonCancel;
|
||||
private Button ButtonSale;
|
||||
private TextBox textBoxCount;
|
||||
private ComboBox comboBoxPastry;
|
||||
private Label labelCount;
|
||||
private Label labelPastry;
|
||||
}
|
||||
}
|
@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||
using ConfectioneryContracts.BindingModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@ -12,9 +15,80 @@ namespace ConfectioneryView
|
||||
{
|
||||
public partial class FormPastrySale : Form
|
||||
{
|
||||
public FormPastrySale()
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IPastryLogic _logicPastry;
|
||||
|
||||
private readonly IShopLogic _logicShop;
|
||||
public FormPastrySale(ILogger<FormSupply> logger, IPastryLogic logicPastry, IShopLogic logicShop)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicPastry = logicPastry;
|
||||
_logicShop = logicShop;
|
||||
}
|
||||
private void FormPastrySale_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Pastries loading");
|
||||
try
|
||||
{
|
||||
var list = _logicPastry.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxPastry.DisplayMember = "PastryName";
|
||||
comboBoxPastry.ValueMember = "Id";
|
||||
comboBoxPastry.DataSource = list;
|
||||
comboBoxPastry.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Pastries loading error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSale_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxPastry.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите выпечку", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Pastry sale");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicShop.Sale(
|
||||
new PastryBindingModel
|
||||
{
|
||||
Id = Convert.ToInt32(comboBoxPastry.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, "Pastry sale error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,64 +1,4 @@
|
||||
<?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.
|
||||
-->
|
||||
<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">
|
||||
|
32
Confectionery/ConfectioneryView/FormShop.Designer.cs
generated
32
Confectionery/ConfectioneryView/FormShop.Designer.cs
generated
@ -41,6 +41,8 @@
|
||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.textBoxMaximum = new System.Windows.Forms.TextBox();
|
||||
this.labelMax = new System.Windows.Forms.Label();
|
||||
this.groupBoxPastries.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -102,7 +104,7 @@
|
||||
// groupBoxPastries
|
||||
//
|
||||
this.groupBoxPastries.Controls.Add(this.dataGridView);
|
||||
this.groupBoxPastries.Location = new System.Drawing.Point(31, 133);
|
||||
this.groupBoxPastries.Location = new System.Drawing.Point(23, 166);
|
||||
this.groupBoxPastries.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||
this.groupBoxPastries.Name = "groupBoxPastries";
|
||||
this.groupBoxPastries.Padding = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||
@ -160,7 +162,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(449, 529);
|
||||
this.buttonCancel.Location = new System.Drawing.Point(441, 562);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(101, 36);
|
||||
@ -171,7 +173,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(330, 529);
|
||||
this.buttonSave.Location = new System.Drawing.Point(322, 562);
|
||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(101, 36);
|
||||
@ -180,11 +182,31 @@
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// textBoxMaximum
|
||||
//
|
||||
this.textBoxMaximum.Location = new System.Drawing.Point(191, 133);
|
||||
this.textBoxMaximum.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
|
||||
this.textBoxMaximum.Name = "textBoxMaximum";
|
||||
this.textBoxMaximum.Size = new System.Drawing.Size(217, 27);
|
||||
this.textBoxMaximum.TabIndex = 17;
|
||||
//
|
||||
// labelMax
|
||||
//
|
||||
this.labelMax.AutoSize = true;
|
||||
this.labelMax.Location = new System.Drawing.Point(32, 137);
|
||||
this.labelMax.Margin = new System.Windows.Forms.Padding(5, 0, 5, 0);
|
||||
this.labelMax.Name = "labelMax";
|
||||
this.labelMax.Size = new System.Drawing.Size(149, 20);
|
||||
this.labelMax.TabIndex = 16;
|
||||
this.labelMax.Text = "Максимум выпечки:";
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(603, 578);
|
||||
this.ClientSize = new System.Drawing.Size(603, 631);
|
||||
this.Controls.Add(this.textBoxMaximum);
|
||||
this.Controls.Add(this.labelMax);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.groupBoxPastries);
|
||||
@ -219,5 +241,7 @@
|
||||
private DataGridViewTextBoxColumn ColumnId;
|
||||
private DataGridViewTextBoxColumn ColumnName;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
private TextBox textBoxMaximum;
|
||||
private Label labelMax;
|
||||
}
|
||||
}
|
@ -47,6 +47,7 @@ namespace ConfectioneryView
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAddress.Text = view.Address;
|
||||
dateTimePicker.Value = view.DateOpening;
|
||||
textBoxMaximum.Text = view.PastriesMaximum.ToString();
|
||||
_shopPastries = view.ShopPastries ?? new Dictionary<int, (IPastryModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
@ -97,6 +98,11 @@ namespace ConfectioneryView
|
||||
MessageBox.Show("Заполните дату", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxMaximum.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните максимальное количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Shop saving");
|
||||
try
|
||||
{
|
||||
@ -106,6 +112,7 @@ namespace ConfectioneryView
|
||||
ShopName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpening = dateTimePicker.Value,
|
||||
PastriesMaximum = Convert.ToInt32(textBoxMaximum.Text),
|
||||
ShopPastries = _shopPastries
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
|
@ -53,6 +53,7 @@ namespace ConfectioneryView
|
||||
services.AddTransient<FormShop>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormSupply>();
|
||||
services.AddTransient<FormPastrySale>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user