Ошибочка

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

@ -1,194 +1,197 @@
namespace ComputersShopView namespace ComputersShopView
{ {
partial class FormMain partial class FormMain
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; private System.ComponentModel.IContainer components = null;
/// <summary> /// <summary>
/// Clean up any resources being used. /// Clean up any resources being used.
/// </summary> /// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {
if (disposing && (components != null)) if (disposing && (components != null))
{ {
components.Dispose(); components.Dispose();
} }
base.Dispose(disposing); base.Dispose(disposing);
} }
#region Windows Form Designer generated code #region Windows Form Designer generated code
/// <summary> /// <summary>
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </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[] { //
this.справочникToolStripMenuItem, menuStrip.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, пополнениеМагазинаToolStripMenuItem, продатьКомпьютеромToolStripMenuItem });
this.пополнениеМагазинаToolStripMenuItem}); menuStrip.Location = new Point(0, 0);
this.menuStrip.Location = new System.Drawing.Point(0, 0); menuStrip.Name = "menuStrip";
this.menuStrip.Name = "menuStrip"; menuStrip.Size = new Size(1047, 24);
this.menuStrip.Size = new System.Drawing.Size(1047, 24); menuStrip.TabIndex = 0;
this.menuStrip.TabIndex = 0; menuStrip.Text = "menuStrip1";
this.menuStrip.Text = "menuStrip1"; //
// // справочникToolStripMenuItem
// справочникToolStripMenuItem //
// справочникToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { computerToolStripMenuItem, componentsToolStripMenuItem, магазиныToolStripMenuItem });
this.справочникToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
this.computerToolStripMenuItem, справочникToolStripMenuItem.Size = new Size(92, 20);
this.componentsToolStripMenuItem, справочникToolStripMenuItem.Text = "справочники";
this.магазиныToolStripMenuItem}); //
this.справочникToolStripMenuItem.Name = "справочникToolStripMenuItem"; // computerToolStripMenuItem
this.справочникToolStripMenuItem.Size = new System.Drawing.Size(92, 20); //
this.справочникToolStripMenuItem.Text = "справочники"; computerToolStripMenuItem.Name = "computerToolStripMenuItem";
// computerToolStripMenuItem.Size = new Size(146, 22);
// computerToolStripMenuItem computerToolStripMenuItem.Text = "компьютеры";
// computerToolStripMenuItem.Click += ComputersToolStripMenuItem_Click;
this.computerToolStripMenuItem.Name = "computerToolStripMenuItem"; //
this.computerToolStripMenuItem.Size = new System.Drawing.Size(146, 22); // componentsToolStripMenuItem
this.computerToolStripMenuItem.Text = "компьютеры"; //
this.computerToolStripMenuItem.Click += new System.EventHandler(this.ComputersToolStripMenuItem_Click); componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
// componentsToolStripMenuItem.Size = new Size(146, 22);
// componentsToolStripMenuItem componentsToolStripMenuItem.Text = "компоненты";
// componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; //
this.componentsToolStripMenuItem.Size = new System.Drawing.Size(146, 22); // магазиныToolStripMenuItem
this.componentsToolStripMenuItem.Text = "компоненты"; //
this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem";
// магазиныToolStripMenuItem.Size = new Size(146, 22);
// магазиныToolStripMenuItem магазиныToolStripMenuItem.Text = "магазины";
// магазиныToolStripMenuItem.Click += ShopToolStripMenuItem_Click;
this.магазиныToolStripMenuItem.Name = агазиныToolStripMenuItem"; //
this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(146, 22); // пополнениеМагазинаToolStripMenuItem
this.магазиныToolStripMenuItem.Text = "магазины"; //
this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopToolStripMenuItem_Click); пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem";
// пополнениеМагазинаToolStripMenuItem.Size = new Size(141, 20);
// пополнениеМагазинаToolStripMenuItem пополнениеМагазинаToolStripMenuItem.Text = "пополнение магазина";
// пополнениеМагазинаToolStripMenuItem.Click += shopReplenishmentToolStripMenuItem_Click;
this.пополнениеМагазинаToolStripMenuItem.Name = "пополнениеМагазинаToolStripMenuItem"; //
this.пополнениеМагазинаToolStripMenuItem.Size = new System.Drawing.Size(141, 20); // продатьКомпьютеромToolStripMenuItem
this.пополнениеМагазинаToolStripMenuItem.Text = "пополнение магазина"; //
this.пополнениеМагазинаToolStripMenuItem.Click += new System.EventHandler(this.shopReplenishmentToolStripMenuItem_Click); продатьКомпьютеромToolStripMenuItem.Name = "продатьКомпьютеромToolStripMenuItem";
// продатьКомпьютеромToolStripMenuItem.Size = new Size(129, 20);
// dataGridView продатьКомпьютеромToolStripMenuItem.Text = "продать компьютер";
// продатьКомпьютеромToolStripMenuItem.Click += ButtonSellComputer_Click;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; //
this.dataGridView.Location = new System.Drawing.Point(12, 27); // dataGridView
this.dataGridView.Name = "dataGridView"; //
this.dataGridView.RowTemplate.Height = 25; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Size = new System.Drawing.Size(817, 411); dataGridView.Location = new Point(12, 27);
this.dataGridView.TabIndex = 1; dataGridView.Name = "dataGridView";
// dataGridView.RowTemplate.Height = 25;
// buttonCreateOrder dataGridView.Size = new Size(817, 411);
// dataGridView.TabIndex = 1;
this.buttonCreateOrder.Location = new System.Drawing.Point(835, 50); //
this.buttonCreateOrder.Name = "buttonCreateOrder"; // buttonCreateOrder
this.buttonCreateOrder.Size = new System.Drawing.Size(200, 23); //
this.buttonCreateOrder.TabIndex = 2; buttonCreateOrder.Location = new Point(835, 50);
this.buttonCreateOrder.Text = "Создать заказ"; buttonCreateOrder.Name = "buttonCreateOrder";
this.buttonCreateOrder.UseVisualStyleBackColor = true; buttonCreateOrder.Size = new Size(200, 23);
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); buttonCreateOrder.TabIndex = 2;
// buttonCreateOrder.Text = "Создать заказ";
// buttonTakeOrderInWork buttonCreateOrder.UseVisualStyleBackColor = true;
// buttonCreateOrder.Click += ButtonCreateOrder_Click;
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(835, 101); //
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; // buttonTakeOrderInWork
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(200, 23); //
this.buttonTakeOrderInWork.TabIndex = 3; buttonTakeOrderInWork.Location = new Point(835, 101);
this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; buttonTakeOrderInWork.Size = new Size(200, 23);
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); buttonTakeOrderInWork.TabIndex = 3;
// buttonTakeOrderInWork.Text = "Отдать на выполнение";
// buttonOrderReady buttonTakeOrderInWork.UseVisualStyleBackColor = true;
// buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
this.buttonOrderReady.Location = new System.Drawing.Point(835, 156); //
this.buttonOrderReady.Name = "buttonOrderReady"; // buttonOrderReady
this.buttonOrderReady.Size = new System.Drawing.Size(200, 23); //
this.buttonOrderReady.TabIndex = 4; buttonOrderReady.Location = new Point(835, 156);
this.buttonOrderReady.Text = "Заказ готов"; buttonOrderReady.Name = "buttonOrderReady";
this.buttonOrderReady.UseVisualStyleBackColor = true; buttonOrderReady.Size = new Size(200, 23);
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); buttonOrderReady.TabIndex = 4;
// buttonOrderReady.Text = "Заказ готов";
// buttonIssuedOrder buttonOrderReady.UseVisualStyleBackColor = true;
// buttonOrderReady.Click += ButtonOrderReady_Click;
this.buttonIssuedOrder.Location = new System.Drawing.Point(835, 212); //
this.buttonIssuedOrder.Name = "buttonIssuedOrder"; // buttonIssuedOrder
this.buttonIssuedOrder.Size = new System.Drawing.Size(200, 23); //
this.buttonIssuedOrder.TabIndex = 5; buttonIssuedOrder.Location = new Point(835, 212);
this.buttonIssuedOrder.Text = "Заказ выдан"; buttonIssuedOrder.Name = "buttonIssuedOrder";
this.buttonIssuedOrder.UseVisualStyleBackColor = true; buttonIssuedOrder.Size = new Size(200, 23);
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); buttonIssuedOrder.TabIndex = 5;
// buttonIssuedOrder.Text = "Заказ выдан";
// buttonRef buttonIssuedOrder.UseVisualStyleBackColor = true;
// buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
this.buttonRef.Location = new System.Drawing.Point(835, 269); //
this.buttonRef.Name = "buttonRef"; // buttonRef
this.buttonRef.Size = new System.Drawing.Size(200, 23); //
this.buttonRef.TabIndex = 6; buttonRef.Location = new Point(835, 269);
this.buttonRef.Text = "Обновить список"; buttonRef.Name = "buttonRef";
this.buttonRef.UseVisualStyleBackColor = true; buttonRef.Size = new Size(200, 23);
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); buttonRef.TabIndex = 6;
// buttonRef.Text = "Обновить список";
// FormMain buttonRef.UseVisualStyleBackColor = true;
// buttonRef.Click += ButtonRef_Click;
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); //
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; // FormMain
this.ClientSize = new System.Drawing.Size(1047, 450); //
this.Controls.Add(this.buttonRef); AutoScaleDimensions = new SizeF(7F, 15F);
this.Controls.Add(this.buttonIssuedOrder); AutoScaleMode = AutoScaleMode.Font;
this.Controls.Add(this.buttonOrderReady); ClientSize = new Size(1047, 450);
this.Controls.Add(this.buttonTakeOrderInWork); Controls.Add(buttonRef);
this.Controls.Add(this.buttonCreateOrder); Controls.Add(buttonIssuedOrder);
this.Controls.Add(this.dataGridView); Controls.Add(buttonOrderReady);
this.Controls.Add(this.menuStrip); Controls.Add(buttonTakeOrderInWork);
this.MainMenuStrip = this.menuStrip; Controls.Add(buttonCreateOrder);
this.Name = "FormMain"; Controls.Add(dataGridView);
this.Text = "Магазин электроники"; Controls.Add(menuStrip);
this.Load += new System.EventHandler(this.FormMain_Load); MainMenuStrip = menuStrip;
this.menuStrip.ResumeLayout(false); Name = "FormMain";
this.menuStrip.PerformLayout(); Text = "Магазин электроники";
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); Load += FormMain_Load;
this.ResumeLayout(false); menuStrip.ResumeLayout(false);
this.PerformLayout(); menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
PerformLayout();
}
} #endregion
#endregion private MenuStrip menuStrip;
private ToolStripMenuItem справочникToolStripMenuItem;
private MenuStrip menuStrip; private DataGridView dataGridView;
private ToolStripMenuItem справочникToolStripMenuItem; private Button buttonCreateOrder;
private DataGridView dataGridView; private Button buttonTakeOrderInWork;
private Button buttonCreateOrder; private Button buttonOrderReady;
private Button buttonTakeOrderInWork; private Button buttonIssuedOrder;
private Button buttonOrderReady; private Button buttonRef;
private Button buttonIssuedOrder; private ToolStripMenuItem computerToolStripMenuItem;
private Button buttonRef; private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem computerToolStripMenuItem; private ToolStripMenuItem магазиныToolStripMenuItem;
private ToolStripMenuItem componentsToolStripMenuItem; private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem;
private ToolStripMenuItem магазиныToolStripMenuItem; private ToolStripMenuItem продатьКомпьютеромToolStripMenuItem;
private ToolStripMenuItem пополнениеМагазинаToolStripMenuItem; }
}
} }

View File

@ -14,179 +14,189 @@ using System.Windows.Forms;
namespace ComputersShopView namespace ComputersShopView
{ {
public partial class FormMain : Form public partial class FormMain : Form
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic; private readonly IOrderLogic _orderLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic) public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_orderLogic = orderLogic; _orderLogic = orderLogic;
} }
private void FormMain_Load(object sender, EventArgs e) private void FormMain_Load(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void LoadData() private void LoadData()
{ {
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
try try
{ {
var list = _orderLogic.ReadList(null); var list = _orderLogic.ReadList(null);
if (list != null) if (list != null)
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["ComputerId"].Visible = false; dataGridView.Columns["ComputerId"].Visible = false;
} }
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки заказов"); _logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e) private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form) if (service is FormComponents form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ComputersToolStripMenuItem_Click(object sender, EventArgs e) private void ComputersToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormComputers)); var service = Program.ServiceProvider?.GetService(typeof(FormComputers));
if (service is FormComputers form) if (service is FormComputers form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ShopToolStripMenuItem_Click(object sender, EventArgs e) private void ShopToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormShops)); var service = Program.ServiceProvider?.GetService(typeof(FormShops));
if (service is FormShops form) if (service is FormShops form)
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
private void ButtonCreateOrder_Click(object sender, EventArgs e) private void ButtonCreateOrder_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form) if (service is FormCreateOrder form)
{ {
form.ShowDialog(); form.ShowDialog();
LoadData(); LoadData();
} }
} }
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try try
{ {
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
{ {
Id = id, Id = id,
ComputerId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ComputerId"].Value), ComputerId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ComputerId"].Value),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()) DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString())
}); });
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка передачи заказа в работу"); _logger.LogError(ex, "Ошибка передачи заказа в работу");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
private void ButtonOrderReady_Click(object sender, EventArgs e) private void ButtonOrderReady_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try try
{ {
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
{ {
Id = id, Id = id,
ComputerId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ComputerId"].Value), ComputerId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ComputerId"].Value),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()) DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString())
}); });
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка отметки о готовности заказа"); _logger.LogError(ex, "Ошибка отметки о готовности заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
private void ButtonIssuedOrder_Click(object sender, EventArgs e) private void ButtonIssuedOrder_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try try
{ {
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
{ {
Id = id, Id = id,
ComputerId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ComputerId"].Value), ComputerId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ComputerId"].Value),
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()) DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString())
}); });
if (!operationResult) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
} }
_logger.LogInformation("Заказ №{id} выдан", id); _logger.LogInformation("Заказ №{id} выдан", id);
LoadData(); LoadData();
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка отметки о выдачи заказа"); _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
} }
private void ButtonRef_Click(object sender, EventArgs e) private void ButtonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }
private void shopReplenishmentToolStripMenuItem_Click(object sender, EventArgs e) private void shopReplenishmentToolStripMenuItem_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormShopReplenishment)); var service = Program.ServiceProvider?.GetService(typeof(FormShopReplenishment));
if (service is FormShopReplenishment form) if (service is FormShopReplenishment form)
{ {
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>();
} }
} }
} }