Finish hard
This commit is contained in:
parent
a0f9235e3d
commit
f134d1fb63
@ -86,6 +86,20 @@ namespace SewingDressesBusinessLogic.BusinessLogic
|
||||
_logger.LogWarning("Status change failed");
|
||||
throw new InvalidOperationException("Невозможно перевести состояние заказа");
|
||||
}
|
||||
if (status == OrderStatus.Готов)
|
||||
{
|
||||
var dress = _dressStorage.GetElement(new DressSearchModel() { Id = model.DressId });
|
||||
if (dress == null)
|
||||
{
|
||||
_logger.LogWarning("Status change error. Dress not found");
|
||||
return false;
|
||||
}
|
||||
if (!CheckSupply(dress, model.Count))
|
||||
{
|
||||
_logger.LogWarning("Status change error. Shop doesnt have dresses");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
model.Status = status;
|
||||
if (model.Status == OrderStatus.Выдан) model.DateImplement = DateTime.Now;
|
||||
_orderStorage.Update(model);
|
||||
|
11
SewingDresses/SewingDressesView/MainForm.Designer.cs
generated
11
SewingDresses/SewingDressesView/MainForm.Designer.cs
generated
@ -40,6 +40,7 @@
|
||||
платьяToolStripMenuItem = new ToolStripMenuItem();
|
||||
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||
поставкиToolStripMenuItem = new ToolStripMenuItem();
|
||||
продажаToolStripMenuItem = new ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
@ -116,7 +117,7 @@
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, платьяToolStripMenuItem, магазиныToolStripMenuItem, поставкиToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, платьяToolStripMenuItem, магазиныToolStripMenuItem, поставкиToolStripMenuItem, продажаToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
@ -149,6 +150,13 @@
|
||||
поставкиToolStripMenuItem.Text = "Поставки";
|
||||
поставкиToolStripMenuItem.Click += SupplyToolStripMenuItem_Click;
|
||||
//
|
||||
// продажаToolStripMenuItem
|
||||
//
|
||||
продажаToolStripMenuItem.Name = "продажаToolStripMenuItem";
|
||||
продажаToolStripMenuItem.Size = new Size(224, 26);
|
||||
продажаToolStripMenuItem.Text = "Продажа";
|
||||
продажаToolStripMenuItem.Click += SellToolStripMenuItem_Click;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
@ -186,5 +194,6 @@
|
||||
private ToolStripMenuItem платьяToolStripMenuItem;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private ToolStripMenuItem поставкиToolStripMenuItem;
|
||||
private ToolStripMenuItem продажаToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ namespace SewingDressesView
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["DressId"].Visible = false;
|
||||
dataGridView.Columns["DressName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["DressName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
|
||||
}
|
||||
_logger.LogInformation("Load orders");
|
||||
}
|
||||
@ -166,5 +166,14 @@ namespace SewingDressesView
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void SellToolStripMenuItem_Click(Object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(SellForm));
|
||||
if (service is SellForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ namespace SewingDressesView
|
||||
services.AddTransient<ShopForm>();
|
||||
services.AddTransient<ShopsForm>();
|
||||
services.AddTransient<SupplyForm>();
|
||||
services.AddTransient<SellForm>();
|
||||
}
|
||||
}
|
||||
}
|
118
SewingDresses/SewingDressesView/SellForm.Designer.cs
generated
Normal file
118
SewingDresses/SewingDressesView/SellForm.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
||||
namespace SewingDressesView
|
||||
{
|
||||
partial class SellForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
comboBoxDress = new ComboBox();
|
||||
textBoxCount = new TextBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// comboBoxDress
|
||||
//
|
||||
comboBoxDress.FormattingEnabled = true;
|
||||
comboBoxDress.Location = new Point(126, 30);
|
||||
comboBoxDress.Name = "comboBoxDress";
|
||||
comboBoxDress.Size = new Size(151, 28);
|
||||
comboBoxDress.TabIndex = 0;
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(126, 95);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(151, 27);
|
||||
textBoxCount.TabIndex = 1;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(45, 172);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 2;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(183, 172);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 3;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(27, 33);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(58, 20);
|
||||
label1.TabIndex = 4;
|
||||
label1.Text = "Платье";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(27, 98);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(90, 20);
|
||||
label2.TabIndex = 5;
|
||||
label2.Text = "Количество";
|
||||
//
|
||||
// SellForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(306, 234);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(comboBoxDress);
|
||||
Name = "SellForm";
|
||||
Text = "Продажа";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox comboBoxDress;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
}
|
||||
}
|
120
SewingDresses/SewingDressesView/SellForm.cs
Normal file
120
SewingDresses/SewingDressesView/SellForm.cs
Normal file
@ -0,0 +1,120 @@
|
||||
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;
|
||||
using SewingDressesContracts.BusinessLogicsContracts;
|
||||
using SewingDressesContracts.ViewModels;
|
||||
using SewingDressesDataModels.Models;
|
||||
|
||||
namespace SewingDressesView
|
||||
{
|
||||
public partial class SellForm : Form
|
||||
{
|
||||
private readonly List<DressViewModel>? _dressList;
|
||||
IShopLogic _shopLogic;
|
||||
IDressLogic _dressLogic;
|
||||
public SellForm(IDressLogic dressLogic, IShopLogic shopLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_shopLogic = shopLogic;
|
||||
_dressLogic = dressLogic;
|
||||
_dressList = dressLogic.ReadList(null);
|
||||
if (_dressList != null)
|
||||
{
|
||||
comboBoxDress.DisplayMember = "DressName";
|
||||
comboBoxDress.ValueMember = "Id";
|
||||
comboBoxDress.DataSource = _dressList;
|
||||
comboBoxDress.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
public int DressId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(comboBoxDress.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
comboBoxDress.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IDressModel? IceCreamModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dressList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var elem in _dressList)
|
||||
{
|
||||
if (elem.Id == DressId)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||
set
|
||||
{ textBoxCount.Text = value.ToString(); }
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxDress.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите мороженное", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
|
||||
bool res = _shopLogic.MakeSell(
|
||||
_dressLogic.ReadElement(new() { Id = Convert.ToInt32(comboBoxDress.SelectedValue) }),
|
||||
count
|
||||
);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
throw new Exception("Ошибка при продаже.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Продажа прошла успешно");
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
MessageBox.Show("Ошибка продажи");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
SewingDresses/SewingDressesView/SellForm.resx
Normal file
120
SewingDresses/SewingDressesView/SellForm.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>
|
Loading…
x
Reference in New Issue
Block a user