Ошибочка

This commit is contained in:
maxnes3 2023-04-24 16:39:16 +04:00
parent 1bf503cc92
commit 0626e3d50a
11 changed files with 800 additions and 487 deletions

View File

@ -11,7 +11,6 @@ namespace ComputersShopDataModels.Models
public string ShopName { get; } public string ShopName { get; }
public string ShopAddress { get; } public string ShopAddress { get; }
DateTime DateOpening { get; } DateTime DateOpening { get; }
public int Capacity { get; } public int Capacity { get; }
Dictionary<int, (IComputerModel, int)> Computers { get; } Dictionary<int, (IComputerModel, int)> Computers { get; }
} }

View File

@ -61,7 +61,7 @@ namespace ComputersShopFileImplement.Models
{ {
Id = Convert.ToInt32(element.Attribute("Id")!.Value), Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ShopName = element.Element("ShopName")!.Value, ShopName = element.Element("ShopName")!.Value,
ShopAddress = element.Element("Address")!.Value, ShopAddress = element.Element("ShopAddress")!.Value,
DateOpening = Convert.ToDateTime(element.Element("DateOpening")!.Value), DateOpening = Convert.ToDateTime(element.Element("DateOpening")!.Value),
Capacity = Convert.ToInt32(element.Element("Capacity")!.Value), Capacity = Convert.ToInt32(element.Element("Capacity")!.Value),
ComputersCount = element.Element("Computers")!.Elements("Computer") ComputersCount = element.Element("Computers")!.Elements("Computer")

View File

@ -28,152 +28,154 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.menuStrip = new System.Windows.Forms.MenuStrip(); menuStrip = new MenuStrip();
this.справочникToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); справочникToolStripMenuItem = new ToolStripMenuItem();
this.computerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); computerToolStripMenuItem = new ToolStripMenuItem();
this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); componentsToolStripMenuItem = new ToolStripMenuItem();
this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); магазиныToolStripMenuItem = new ToolStripMenuItem();
this.пополнениеМагазинаToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); пополнениеМагазинаToolStripMenuItem = new ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView(); продатьКомпьютеромToolStripMenuItem = new ToolStripMenuItem();
this.buttonCreateOrder = new System.Windows.Forms.Button(); dataGridView = new DataGridView();
this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); buttonCreateOrder = new Button();
this.buttonOrderReady = new System.Windows.Forms.Button(); buttonTakeOrderInWork = new Button();
this.buttonIssuedOrder = new System.Windows.Forms.Button(); buttonOrderReady = new Button();
this.buttonRef = new System.Windows.Forms.Button(); buttonIssuedOrder = new Button();
this.menuStrip.SuspendLayout(); buttonRef = new Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); menuStrip.SuspendLayout();
this.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
// //
// menuStrip // menuStrip
// //
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { menuStrip.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, пополнениеМагазинаToolStripMenuItem, продатьКомпьютеромToolStripMenuItem });
this.справочникToolStripMenuItem, menuStrip.Location = new Point(0, 0);
this.пополнениеМагазинаToolStripMenuItem}); menuStrip.Name = "menuStrip";
this.menuStrip.Location = new System.Drawing.Point(0, 0); menuStrip.Size = new Size(1047, 24);
this.menuStrip.Name = "menuStrip"; menuStrip.TabIndex = 0;
this.menuStrip.Size = new System.Drawing.Size(1047, 24); menuStrip.Text = "menuStrip1";
this.menuStrip.TabIndex = 0;
this.menuStrip.Text = "menuStrip1";
// //
// справочникToolStripMenuItem // справочникToolStripMenuItem
// //
this.справочникToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { справочникToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { computerToolStripMenuItem, componentsToolStripMenuItem, магазиныToolStripMenuItem });
this.computerToolStripMenuItem, справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
this.componentsToolStripMenuItem, справочникToolStripMenuItem.Size = new Size(92, 20);
this.магазиныToolStripMenuItem}); справочникToolStripMenuItem.Text = "справочники";
this.справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
this.справочникToolStripMenuItem.Size = new System.Drawing.Size(92, 20);
this.справочникToolStripMenuItem.Text = "справочники";
// //
// computerToolStripMenuItem // computerToolStripMenuItem
// //
this.computerToolStripMenuItem.Name = "computerToolStripMenuItem"; computerToolStripMenuItem.Name = "computerToolStripMenuItem";
this.computerToolStripMenuItem.Size = new System.Drawing.Size(146, 22); computerToolStripMenuItem.Size = new Size(146, 22);
this.computerToolStripMenuItem.Text = "компьютеры"; computerToolStripMenuItem.Text = "компьютеры";
this.computerToolStripMenuItem.Click += new System.EventHandler(this.ComputersToolStripMenuItem_Click); computerToolStripMenuItem.Click += ComputersToolStripMenuItem_Click;
// //
// componentsToolStripMenuItem // componentsToolStripMenuItem
// //
this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
this.componentsToolStripMenuItem.Size = new System.Drawing.Size(146, 22); componentsToolStripMenuItem.Size = new Size(146, 22);
this.componentsToolStripMenuItem.Text = "компоненты"; componentsToolStripMenuItem.Text = "компоненты";
this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
// //
// магазиныToolStripMenuItem // магазиныToolStripMenuItem
// //
this.магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem"; магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem";
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(146, 22); магазиныToolStripMenuItem.Size = new Size(146, 22);
this.магазиныToolStripMenuItem.Text = "магазины"; магазиныToolStripMenuItem.Text = "магазины";
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopToolStripMenuItem_Click); магазиныToolStripMenuItem.Click += ShopToolStripMenuItem_Click;
// //
// пополнениеМагазинаToolStripMenuItem // пополнениеМагазинаToolStripMenuItem
// //
this.пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem"; пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
this.пополнениеМагазинаToolStripMenuItem.Size = new System.Drawing.Size(141, 20); пополнениеМагазинаToolStripMenuItem.Size = new Size(141, 20);
this.пополнениеМагазинаToolStripMenuItem.Text = "пополнение магазина"; пополнениеМагазинаToolStripMenuItem.Text = "пополнение магазина";
this.пополнениеМагазинаToolStripMenuItem.Click += new System.EventHandler(this.shopReplenishmentToolStripMenuItem_Click); пополнениеМагазинаToolStripMenuItem.Click += shopReplenishmentToolStripMenuItem_Click;
//
// продатьКомпьютеромToolStripMenuItem
//
продатьКомпьютеромToolStripMenuItem.Name = "продатьКомпьютеромToolStripMenuItem";
продатьКомпьютеромToolStripMenuItem.Size = new Size(129, 20);
продатьКомпьютеромToolStripMenuItem.Text = "продать компьютер";
продатьКомпьютеромToolStripMenuItem.Click += ButtonSellComputer_Click;
// //
// dataGridView // dataGridView
// //
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 27); dataGridView.Location = new Point(12, 27);
this.dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25; dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(817, 411); dataGridView.Size = new Size(817, 411);
this.dataGridView.TabIndex = 1; dataGridView.TabIndex = 1;
// //
// buttonCreateOrder // buttonCreateOrder
// //
this.buttonCreateOrder.Location = new System.Drawing.Point(835, 50); buttonCreateOrder.Location = new Point(835, 50);
this.buttonCreateOrder.Name = "buttonCreateOrder"; buttonCreateOrder.Name = "buttonCreateOrder";
this.buttonCreateOrder.Size = new System.Drawing.Size(200, 23); buttonCreateOrder.Size = new Size(200, 23);
this.buttonCreateOrder.TabIndex = 2; buttonCreateOrder.TabIndex = 2;
this.buttonCreateOrder.Text = "Создать заказ"; buttonCreateOrder.Text = "Создать заказ";
this.buttonCreateOrder.UseVisualStyleBackColor = true; buttonCreateOrder.UseVisualStyleBackColor = true;
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); buttonCreateOrder.Click += ButtonCreateOrder_Click;
// //
// buttonTakeOrderInWork // buttonTakeOrderInWork
// //
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(835, 101); buttonTakeOrderInWork.Location = new Point(835, 101);
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(200, 23); buttonTakeOrderInWork.Size = new Size(200, 23);
this.buttonTakeOrderInWork.TabIndex = 3; buttonTakeOrderInWork.TabIndex = 3;
this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; buttonTakeOrderInWork.Text = "Отдать на выполнение";
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; buttonTakeOrderInWork.UseVisualStyleBackColor = true;
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
// //
// buttonOrderReady // buttonOrderReady
// //
this.buttonOrderReady.Location = new System.Drawing.Point(835, 156); buttonOrderReady.Location = new Point(835, 156);
this.buttonOrderReady.Name = "buttonOrderReady"; buttonOrderReady.Name = "buttonOrderReady";
this.buttonOrderReady.Size = new System.Drawing.Size(200, 23); buttonOrderReady.Size = new Size(200, 23);
this.buttonOrderReady.TabIndex = 4; buttonOrderReady.TabIndex = 4;
this.buttonOrderReady.Text = "Заказ готов"; buttonOrderReady.Text = "Заказ готов";
this.buttonOrderReady.UseVisualStyleBackColor = true; buttonOrderReady.UseVisualStyleBackColor = true;
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); buttonOrderReady.Click += ButtonOrderReady_Click;
// //
// buttonIssuedOrder // buttonIssuedOrder
// //
this.buttonIssuedOrder.Location = new System.Drawing.Point(835, 212); buttonIssuedOrder.Location = new Point(835, 212);
this.buttonIssuedOrder.Name = "buttonIssuedOrder"; buttonIssuedOrder.Name = "buttonIssuedOrder";
this.buttonIssuedOrder.Size = new System.Drawing.Size(200, 23); buttonIssuedOrder.Size = new Size(200, 23);
this.buttonIssuedOrder.TabIndex = 5; buttonIssuedOrder.TabIndex = 5;
this.buttonIssuedOrder.Text = "Заказ выдан"; buttonIssuedOrder.Text = "Заказ выдан";
this.buttonIssuedOrder.UseVisualStyleBackColor = true; buttonIssuedOrder.UseVisualStyleBackColor = true;
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
// //
// buttonRef // buttonRef
// //
this.buttonRef.Location = new System.Drawing.Point(835, 269); buttonRef.Location = new Point(835, 269);
this.buttonRef.Name = "buttonRef"; buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(200, 23); buttonRef.Size = new Size(200, 23);
this.buttonRef.TabIndex = 6; buttonRef.TabIndex = 6;
this.buttonRef.Text = "Обновить список"; buttonRef.Text = "Обновить список";
this.buttonRef.UseVisualStyleBackColor = true; buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); buttonRef.Click += ButtonRef_Click;
// //
// FormMain // FormMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1047, 450); ClientSize = new Size(1047, 450);
this.Controls.Add(this.buttonRef); Controls.Add(buttonRef);
this.Controls.Add(this.buttonIssuedOrder); Controls.Add(buttonIssuedOrder);
this.Controls.Add(this.buttonOrderReady); Controls.Add(buttonOrderReady);
this.Controls.Add(this.buttonTakeOrderInWork); Controls.Add(buttonTakeOrderInWork);
this.Controls.Add(this.buttonCreateOrder); Controls.Add(buttonCreateOrder);
this.Controls.Add(this.dataGridView); Controls.Add(dataGridView);
this.Controls.Add(this.menuStrip); Controls.Add(menuStrip);
this.MainMenuStrip = this.menuStrip; MainMenuStrip = menuStrip;
this.Name = "FormMain"; Name = "FormMain";
this.Text = "Магазин электроники"; Text = "Магазин электроники";
this.Load += new System.EventHandler(this.FormMain_Load); Load += FormMain_Load;
this.menuStrip.ResumeLayout(false); menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout(); menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
this.ResumeLayout(false); ResumeLayout(false);
this.PerformLayout(); PerformLayout();
} }
#endregion #endregion
@ -190,5 +192,6 @@
private ToolStripMenuItem componentsToolStripMenuItem; private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem магазиныToolStripMenuItem; private ToolStripMenuItem магазиныToolStripMenuItem;
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem; private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
private ToolStripMenuItem продатьКомпьютеромToolStripMenuItem;
} }
} }

View File

@ -188,5 +188,15 @@ namespace ComputersShopView
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ButtonSellComputer_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSellComputers));
if (service is FormSellComputers form)
{
form.ShowDialog();
LoadData();
}
}
} }
} }

View File

@ -0,0 +1,124 @@
namespace ComputersShopView
{
partial class FormSellComputers
{
/// <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()
{
ButtonCancel = new Button();
comboBoxDocuments = new ComboBox();
numericUpDownCount = new NumericUpDown();
labelDocument = new Label();
labelCount = new Label();
ButtonSave = new Button();
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
SuspendLayout();
//
// ButtonCancel
//
ButtonCancel.Location = new Point(233, 60);
ButtonCancel.Margin = new Padding(3, 2, 3, 2);
ButtonCancel.Name = "ButtonCancel";
ButtonCancel.Size = new Size(82, 22);
ButtonCancel.TabIndex = 1;
ButtonCancel.Text = "Отмена";
ButtonCancel.UseVisualStyleBackColor = true;
ButtonCancel.Click += ButtonCancel_Click;
//
// comboBoxDocuments
//
comboBoxDocuments.FormattingEnabled = true;
comboBoxDocuments.Location = new Point(89, 6);
comboBoxDocuments.Margin = new Padding(3, 2, 3, 2);
comboBoxDocuments.Name = "comboBoxDocuments";
comboBoxDocuments.Size = new Size(226, 23);
comboBoxDocuments.TabIndex = 2;
//
// numericUpDownCount
//
numericUpDownCount.Location = new Point(90, 33);
numericUpDownCount.Margin = new Padding(3, 2, 3, 2);
numericUpDownCount.Name = "numericUpDownCount";
numericUpDownCount.Size = new Size(225, 23);
numericUpDownCount.TabIndex = 3;
//
// labelDocument
//
labelDocument.AutoSize = true;
labelDocument.Location = new Point(12, 9);
labelDocument.Name = "labelDocument";
labelDocument.Size = new Size(71, 15);
labelDocument.TabIndex = 4;
labelDocument.Text = "Компьютер";
//
// labelCount
//
labelCount.AutoSize = true;
labelCount.Location = new Point(11, 35);
labelCount.Name = "labelCount";
labelCount.Size = new Size(72, 15);
labelCount.TabIndex = 5;
labelCount.Text = "Количество";
//
// ButtonSave
//
ButtonSave.Location = new Point(145, 60);
ButtonSave.Margin = new Padding(3, 2, 3, 2);
ButtonSave.Name = "ButtonSave";
ButtonSave.Size = new Size(82, 22);
ButtonSave.TabIndex = 6;
ButtonSave.Text = "Сохранить";
ButtonSave.UseVisualStyleBackColor = true;
ButtonSave.Click += ButtonSave_Click;
//
// FormSellComputers
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(326, 93);
Controls.Add(ButtonSave);
Controls.Add(labelCount);
Controls.Add(labelDocument);
Controls.Add(numericUpDownCount);
Controls.Add(comboBoxDocuments);
Controls.Add(ButtonCancel);
Margin = new Padding(3, 2, 3, 2);
Name = "FormSellComputers";
Text = "Продажа компьютеров";
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button ButtonCancel;
private ComboBox comboBoxDocuments;
private NumericUpDown numericUpDownCount;
private Label labelDocument;
private Label labelCount;
private Button ButtonSave;
}
}

View File

@ -0,0 +1,86 @@
using ComputersShopContracts.BusinessLogicContracts;
using ComputersShopContracts.ViewModels;
using Microsoft.Extensions.Logging;
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;
namespace ComputersShopView
{
public partial class FormSellComputers : Form
{
private readonly ILogger _logger;
private readonly IShopLogic _shopLogic;
private readonly IComputerLogic _computerLogic;
private readonly List<ComputerViewModel>? _listComputer;
public FormSellComputers(ILogger<FormSellComputers> logger, IShopLogic shopLogic, IComputerLogic computerLogic)
{
InitializeComponent();
_logger = logger;
_shopLogic = shopLogic;
_computerLogic = computerLogic;
_listComputer = computerLogic.ReadList(null);
if (_listComputer != null)
{
comboBoxDocuments.DisplayMember = "ComputerName";
comboBoxDocuments.ValueMember = "Id";
comboBoxDocuments.DataSource = _listComputer;
comboBoxDocuments.SelectedItem = null;
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (comboBoxDocuments.SelectedValue == null)
{
MessageBox.Show("Выберите корабль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(numericUpDownCount.Text))
{
MessageBox.Show("Заполните количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Продажа поездок");
try
{
var comp = _computerLogic.ReadElement(new()
{
Id = (int)comboBoxDocuments.SelectedValue
});
if (comp == null)
{
throw new Exception("Компьютер не найден. Дополнительная информация в логах.");
}
var operationResult = _shopLogic.SellComputers(
computer: comp,
quantity: (int)numericUpDownCount.Value
);
if (!operationResult)
{
throw new Exception("Ошибка при продаже компьютера. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения компьютера");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<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">
<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>

View File

@ -28,170 +28,195 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
dateTimePicker = new DateTimePicker(); labelShop = new Label();
labelAddress = new Label();
labelDate = new Label();
textBoxName = new TextBox(); textBoxName = new TextBox();
textBoxAddress = new TextBox(); textBoxAddress = new TextBox();
labelTime = new Label(); dateTimePicker = new DateTimePicker();
labelAddress = new Label();
dataGridView = new DataGridView(); dataGridView = new DataGridView();
ColumnID = new DataGridViewTextBoxColumn(); ButtonSave = new Button();
ColumnManufactureName = new DataGridViewTextBoxColumn(); ButtonCancel = new Button();
Цена = new DataGridViewTextBoxColumn(); numericUpDownCapacity = new NumericUpDown();
ColumnCount = new DataGridViewTextBoxColumn(); labelCapacity = new Label();
labelShop = new Label(); ID = new DataGridViewTextBoxColumn();
buttonSave = new Button(); DocumentName = new DataGridViewTextBoxColumn();
buttonCancel = new Button(); Price = new DataGridViewTextBoxColumn();
Count = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// dateTimePicker
//
dateTimePicker.Location = new Point(384, 27);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(207, 23);
dateTimePicker.TabIndex = 26;
//
// textBoxName
//
textBoxName.Location = new Point(10, 27);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(141, 23);
textBoxName.TabIndex = 25;
//
// textBoxAddress
//
textBoxAddress.Location = new Point(158, 27);
textBoxAddress.Name = "textBoxAddress";
textBoxAddress.Size = new Size(221, 23);
textBoxAddress.TabIndex = 24;
//
// labelTime
//
labelTime.AutoSize = true;
labelTime.Location = new Point(384, 9);
labelTime.Name = "labelTime";
labelTime.Size = new Size(87, 15);
labelTime.TabIndex = 23;
labelTime.Text = "Дата открытия";
//
// labelAddress
//
labelAddress.AutoSize = true;
labelAddress.Location = new Point(158, 9);
labelAddress.Name = "labelAddress";
labelAddress.Size = new Size(40, 15);
labelAddress.TabIndex = 22;
labelAddress.Text = "Адрес";
//
// dataGridView
//
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnID, ColumnManufactureName, Цена, ColumnCount });
dataGridView.Location = new Point(10, 56);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 62;
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(581, 327);
dataGridView.TabIndex = 21;
//
// ColumnID
//
ColumnID.HeaderText = "ID";
ColumnID.MinimumWidth = 8;
ColumnID.Name = "ColumnID";
ColumnID.Visible = false;
ColumnID.Width = 150;
//
// ColumnManufactureName
//
ColumnManufactureName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnManufactureName.HeaderText = "Название компьютера";
ColumnManufactureName.MinimumWidth = 8;
ColumnManufactureName.Name = "ColumnManufactureName";
//
// Цена
//
Цена.HeaderText = "Цена";
Цена.MinimumWidth = 6;
Цена.Name = "Цена";
Цена.Width = 125;
//
// ColumnCount
//
ColumnCount.HeaderText = "Количество";
ColumnCount.MinimumWidth = 8;
ColumnCount.Name = "ColumnCount";
ColumnCount.Width = 150;
//
// labelShop // labelShop
// //
labelShop.AutoSize = true; labelShop.AutoSize = true;
labelShop.Location = new Point(10, 9); labelShop.Location = new Point(10, 16);
labelShop.Name = "labelShop"; labelShop.Name = "labelShop";
labelShop.Size = new Size(54, 15); labelShop.Size = new Size(54, 15);
labelShop.TabIndex = 20; labelShop.TabIndex = 0;
labelShop.Text = "Магазин"; labelShop.Text = "Магазин";
// //
// buttonSave // labelAddress
// //
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; labelAddress.AutoSize = true;
buttonSave.Location = new Point(363, 392); labelAddress.Location = new Point(156, 16);
buttonSave.Name = "buttonSave"; labelAddress.Name = "labelAddress";
buttonSave.Size = new Size(120, 22); labelAddress.Size = new Size(40, 15);
buttonSave.TabIndex = 28; labelAddress.TabIndex = 1;
buttonSave.Text = "Сохранить"; labelAddress.Text = "Адрес";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
// //
// buttonCancel // labelDate
// //
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; labelDate.AutoSize = true;
buttonCancel.Location = new Point(488, 392); labelDate.Location = new Point(375, 16);
buttonCancel.Name = "buttonCancel"; labelDate.Name = "labelDate";
buttonCancel.Size = new Size(103, 22); labelDate.Size = new Size(87, 15);
buttonCancel.TabIndex = 27; labelDate.TabIndex = 2;
buttonCancel.Text = "Отмена"; labelDate.Text = "Дата открытия";
buttonCancel.UseVisualStyleBackColor = true; //
buttonCancel.Click += ButtonCancel_Click; // textBoxName
//
textBoxName.Location = new Point(10, 33);
textBoxName.Margin = new Padding(3, 2, 3, 2);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(140, 23);
textBoxName.TabIndex = 3;
//
// textBoxAddress
//
textBoxAddress.Location = new Point(156, 33);
textBoxAddress.Margin = new Padding(3, 2, 3, 2);
textBoxAddress.Name = "textBoxAddress";
textBoxAddress.Size = new Size(216, 23);
textBoxAddress.TabIndex = 4;
//
// dateTimePicker
//
dateTimePicker.Location = new Point(375, 33);
dateTimePicker.Margin = new Padding(3, 2, 3, 2);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(123, 23);
dateTimePicker.TabIndex = 5;
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ID, DocumentName, Price, Count });
dataGridView.Location = new Point(10, 58);
dataGridView.Margin = new Padding(3, 2, 3, 2);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(623, 248);
dataGridView.TabIndex = 6;
//
// ButtonSave
//
ButtonSave.Location = new Point(429, 310);
ButtonSave.Margin = new Padding(3, 2, 3, 2);
ButtonSave.Name = "ButtonSave";
ButtonSave.Size = new Size(97, 22);
ButtonSave.TabIndex = 7;
ButtonSave.Text = "Сохранить";
ButtonSave.UseVisualStyleBackColor = true;
ButtonSave.Click += ButtonSave_Click;
//
// ButtonCancel
//
ButtonCancel.Location = new Point(551, 310);
ButtonCancel.Margin = new Padding(3, 2, 3, 2);
ButtonCancel.Name = "ButtonCancel";
ButtonCancel.Size = new Size(82, 22);
ButtonCancel.TabIndex = 8;
ButtonCancel.Text = "Отмена";
ButtonCancel.UseVisualStyleBackColor = true;
ButtonCancel.Click += ButtonCancel_Click;
//
// numericUpDownCapacity
//
numericUpDownCapacity.Location = new Point(513, 33);
numericUpDownCapacity.Name = "numericUpDownCapacity";
numericUpDownCapacity.Size = new Size(120, 23);
numericUpDownCapacity.TabIndex = 9;
//
// labelCapacity
//
labelCapacity.AutoSize = true;
labelCapacity.Location = new Point(513, 16);
labelCapacity.Name = "labelCapacity";
labelCapacity.Size = new Size(80, 15);
labelCapacity.TabIndex = 10;
labelCapacity.Text = "Вместимость";
//
// ID
//
ID.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ID.HeaderText = "ID";
ID.MinimumWidth = 6;
ID.Name = "ID";
ID.Visible = false;
//
// DocumentName
//
DocumentName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
DocumentName.HeaderText = "Название компьютера";
DocumentName.MinimumWidth = 6;
DocumentName.Name = "DocumentName";
//
// Price
//
Price.HeaderText = "Стоимость";
Price.Name = "Price";
//
// Count
//
Count.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
Count.HeaderText = "Количество";
Count.MinimumWidth = 6;
Count.Name = "Count";
// //
// FormShop // FormShop
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(616, 425); ClientSize = new Size(648, 338);
Controls.Add(buttonSave); Controls.Add(labelCapacity);
Controls.Add(buttonCancel); Controls.Add(numericUpDownCapacity);
Controls.Add(dateTimePicker); Controls.Add(ButtonCancel);
Controls.Add(textBoxName); Controls.Add(ButtonSave);
Controls.Add(textBoxAddress);
Controls.Add(labelTime);
Controls.Add(labelAddress);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Controls.Add(dateTimePicker);
Controls.Add(textBoxAddress);
Controls.Add(textBoxName);
Controls.Add(labelDate);
Controls.Add(labelAddress);
Controls.Add(labelShop); Controls.Add(labelShop);
Margin = new Padding(3, 2, 3, 2); Margin = new Padding(3, 2, 3, 2);
Name = "FormShop"; Name = "FormShop";
Text = "FormShop"; Text = "Магазин";
Load += FormShop_Load; Load += FormShop_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
#endregion #endregion
private DateTimePicker dateTimePicker; private Label labelShop;
private Label labelAddress;
private Label labelDate;
private TextBox textBoxName; private TextBox textBoxName;
private TextBox textBoxAddress; private TextBox textBoxAddress;
private Label labelTime; private DateTimePicker dateTimePicker;
private Label labelAddress;
private DataGridView dataGridView; private DataGridView dataGridView;
private Label labelShop; private Button ButtonSave;
private Button buttonSave; private Button ButtonCancel;
private Button buttonCancel; private NumericUpDown numericUpDownCapacity;
private DataGridViewTextBoxColumn ColumnID; private Label labelCapacity;
private DataGridViewTextBoxColumn ColumnManufactureName; private DataGridViewTextBoxColumn ID;
private DataGridViewTextBoxColumn Цена; private DataGridViewTextBoxColumn DocumentName;
private DataGridViewTextBoxColumn ColumnCount; private DataGridViewTextBoxColumn Price;
private DataGridViewTextBoxColumn Count;
} }
} }

View File

@ -46,6 +46,7 @@ namespace ComputersShopView
textBoxName.Text = view.ShopName; textBoxName.Text = view.ShopName;
textBoxAddress.Text = view.ShopAddress.ToString(); textBoxAddress.Text = view.ShopAddress.ToString();
dateTimePicker.Text = view.DateOpening.ToString(); dateTimePicker.Text = view.DateOpening.ToString();
numericUpDownCapacity.Value = view.Capacity;
_shopComputers = view.Computers ?? new Dictionary<int, (IComputerModel, int)>(); _shopComputers = view.Computers ?? new Dictionary<int, (IComputerModel, int)>();
LoadData(); LoadData();
} }
@ -100,6 +101,7 @@ namespace ComputersShopView
ShopName = textBoxName.Text, ShopName = textBoxName.Text,
ShopAddress = textBoxAddress.Text, ShopAddress = textBoxAddress.Text,
DateOpening = dateTimePicker.Value.Date, DateOpening = dateTimePicker.Value.Date,
Capacity = (int)numericUpDownCapacity.Value,
Computers = _shopComputers Computers = _shopComputers
}; };
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);

View File

@ -57,4 +57,7 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="Price.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

View File

@ -54,6 +54,7 @@ namespace ComputersShopView
services.AddTransient<FormShop>(); services.AddTransient<FormShop>();
services.AddTransient<FormShops>(); services.AddTransient<FormShops>();
services.AddTransient<FormShopReplenishment>(); services.AddTransient<FormShopReplenishment>();
services.AddTransient<FormSellComputers>();
} }
} }
} }