дело сделано
This commit is contained in:
parent
f0ccd349ca
commit
ca694284f4
@ -14,9 +14,11 @@ namespace ComputersShopFileImplements
|
|||||||
public readonly string ComponentFileName = "Component.xml";
|
public readonly string ComponentFileName = "Component.xml";
|
||||||
public readonly string OrderFileName = "Order.xml";
|
public readonly string OrderFileName = "Order.xml";
|
||||||
public readonly string ComputerFileName = "Computer.xml";
|
public readonly string ComputerFileName = "Computer.xml";
|
||||||
|
public readonly string ShopFileName = "Shop.xml";
|
||||||
public List<Component> Components { get; private set; }
|
public List<Component> Components { get; private set; }
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Computer> Computers { get; private set; }
|
public List<Computer> Computers { get; private set; }
|
||||||
|
public List<Shop> Shops { get; private set; }
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
@ -31,14 +33,16 @@ namespace ComputersShopFileImplements
|
|||||||
"Computers", x => x.GetXElement);
|
"Computers", x => x.GetXElement);
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName,
|
public void SaveOrders() => SaveData(Orders, OrderFileName,
|
||||||
"Orders", x => x.GetXElement);
|
"Orders", x => x.GetXElement);
|
||||||
|
public void SaveShops() => SaveData(Shops, ShopFileName,
|
||||||
|
"Shops", x => x.GetXElement);
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||||
Computers = LoadData(ComputerFileName, "Computer", x => Computer.Create(x)!)!;
|
Computers = LoadData(ComputerFileName, "Computer", x => Computer.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
|
Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!;
|
||||||
}
|
}
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)
|
||||||
Func<XElement, T> selectFunction)
|
|
||||||
{
|
{
|
||||||
if (File.Exists(filename))
|
if (File.Exists(filename))
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,127 @@
|
|||||||
|
using ComputersShopContracts.BindingModels;
|
||||||
|
using ComputersShopContracts.SearchModels;
|
||||||
|
using ComputersShopContracts.StoragesContracts;
|
||||||
|
using ComputersShopContracts.ViewModels;
|
||||||
|
using ComputersShopDataModels.Models;
|
||||||
|
using ComputersShopFileImplements.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ComputersShopFileImplements.Implements
|
||||||
|
{
|
||||||
|
public class ShopStorage: IShopStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton source;
|
||||||
|
|
||||||
|
public ShopStorage()
|
||||||
|
{
|
||||||
|
source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
public List<ShopViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return source.Shops.Select(x => x.GetViewModel).ToList();
|
||||||
|
}
|
||||||
|
public List<ShopViewModel> GetFiltredList(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
return source.Shops
|
||||||
|
.Where(x => x.ShopName.Contains(model.Name))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return source.Shops
|
||||||
|
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) &&
|
||||||
|
x.ShopName == model.Name) || (model.Id.HasValue &&
|
||||||
|
x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
public ShopViewModel? Insert(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = source.Shops.Count > 0 ? source.Shops.Max(x => x.Id) + 1 : 1;
|
||||||
|
var newShop = Shop.Create(model);
|
||||||
|
if (newShop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
source.Shops.Add(newShop);
|
||||||
|
source.SaveComputers();
|
||||||
|
return newShop.GetViewModel;
|
||||||
|
}
|
||||||
|
public ShopViewModel? Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (shop == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
shop.Update(model);
|
||||||
|
source.SaveComputers();
|
||||||
|
return shop.GetViewModel;
|
||||||
|
}
|
||||||
|
public ShopViewModel? Delete(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
var element = source.Shops.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
source.Shops.Remove(element);
|
||||||
|
source.SaveComputers();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public bool CheckAvailability(int computerId, int count)
|
||||||
|
{
|
||||||
|
int store = source.Shops.Select(x => x.ShopComputers.Select(y => (y.Value.Item1.Id == computerId ? y.Value.Item2 : 0)).Sum()).Sum();
|
||||||
|
return store >= count;
|
||||||
|
}
|
||||||
|
public bool SellComputers(IComputerModel model, int count)
|
||||||
|
{
|
||||||
|
var computer = source.Computers.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
|
||||||
|
if (computer == null || !CheckAvailability(model.Id, count))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < source.Shops.Count; i++)
|
||||||
|
{
|
||||||
|
var shop = source.Shops[i];
|
||||||
|
var computers = shop.ShopComputers;
|
||||||
|
foreach (var comp in computers.Where(x => x.Value.Item1.Id == computer.Id))
|
||||||
|
{
|
||||||
|
var selling = Math.Min(comp.Value.Item2, count);
|
||||||
|
computers[comp.Value.Item1.Id] = (comp.Value.Item1, comp.Value.Item2 - selling);
|
||||||
|
|
||||||
|
count -= selling;
|
||||||
|
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
shop.Update(new ShopBindingModel
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShopName = shop.ShopName,
|
||||||
|
Address = shop.Address,
|
||||||
|
MaxCount = shop.MaxCount,
|
||||||
|
DateOpen = shop.DateOpen,
|
||||||
|
ShopComputers = computers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
source.SaveShops();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
102
ComputersShop/ComputerShopFileImplements/Models/Shop.cs
Normal file
102
ComputersShop/ComputerShopFileImplements/Models/Shop.cs
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
using ComputersShopContracts.BindingModels;
|
||||||
|
using ComputersShopContracts.ViewModels;
|
||||||
|
using ComputersShopDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace ComputersShopFileImplements.Models
|
||||||
|
{
|
||||||
|
public class Shop: IShopModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string ShopName { get; set;}
|
||||||
|
public string Address { get; set;}
|
||||||
|
public DateTime DateOpen { get; set;}
|
||||||
|
public int MaxCount { get; set;}
|
||||||
|
public Dictionary<int, int> Computers { get; private set; } = new();
|
||||||
|
private Dictionary<int, (IComputerModel, int)>? _shopComputers = null;
|
||||||
|
public Dictionary<int, (IComputerModel, int)> ShopComputers
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_shopComputers == null)
|
||||||
|
{
|
||||||
|
var source = DataFileSingleton.GetInstance();
|
||||||
|
_shopComputers = Computers.ToDictionary(x => x.Key, y => ((source.Computers.FirstOrDefault(z => z.Id == y.Key) as IComputerModel)!, y.Value));
|
||||||
|
}
|
||||||
|
return _shopComputers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static Shop? Create(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ShopName = model.ShopName,
|
||||||
|
Address = model.Address,
|
||||||
|
MaxCount = model.MaxCount,
|
||||||
|
DateOpen = model.DateOpen,
|
||||||
|
Computers = model.ShopComputers.ToDictionary(x => x.Key, x => x.Value.Item2)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public static Shop? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Shop()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
MaxCount = Convert.ToInt32(element.Element("MaxCount")!.Value),
|
||||||
|
ShopName = element.Element("ShopName")!.Value,
|
||||||
|
Address = element.Element("Address")!.Value,
|
||||||
|
DateOpen = Convert.ToDateTime(element.Element("DateOpen")!.Value),
|
||||||
|
|
||||||
|
Computers = element.Element("ShopComputers")!.Elements("ShopComputer").ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
public void Update(ShopBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ShopName = model.ShopName;
|
||||||
|
Address = model.Address;
|
||||||
|
MaxCount = model.MaxCount;
|
||||||
|
DateOpen = model.DateOpen;
|
||||||
|
if (model.ShopComputers.Count > 0)
|
||||||
|
{
|
||||||
|
Computers = model.ShopComputers.ToDictionary(x => x.Key, x => x.Value.Item2);
|
||||||
|
_shopComputers = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ShopViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ShopName = ShopName,
|
||||||
|
Address = Address,
|
||||||
|
MaxCount = MaxCount,
|
||||||
|
DateOpen = DateOpen,
|
||||||
|
ShopComputers = ShopComputers
|
||||||
|
};
|
||||||
|
public XElement GetXElement => new("Shop",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("ShopName", ShopName),
|
||||||
|
new XElement("Address", Address.ToString()),
|
||||||
|
new XElement("MaxCount", MaxCount.ToString()),
|
||||||
|
new XElement("DateOpen", DateOpen.ToString()),
|
||||||
|
new XElement("ShopComputers", Computers.Select(x => new XElement("ShopComputer", new XElement("Key", x.Key),
|
||||||
|
new XElement("Value", x.Value))).ToArray()));
|
||||||
|
}
|
||||||
|
}
|
394
ComputersShop/ComputersShop/FormMain.Designer.cs
generated
394
ComputersShop/ComputersShop/FormMain.Designer.cs
generated
@ -1,198 +1,212 @@
|
|||||||
namespace ComputersShop
|
namespace ComputersShop
|
||||||
{
|
{
|
||||||
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()
|
||||||
{
|
{
|
||||||
menuStrip = new MenuStrip();
|
menuStrip = new MenuStrip();
|
||||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
комьютерыToolStripMenuItem = new ToolStripMenuItem();
|
комьютерыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
buttonTakeOrderInWork = new Button();
|
buttonTakeOrderInWork = new Button();
|
||||||
buttonOrderReady = new Button();
|
buttonOrderReady = new Button();
|
||||||
buttonIssuedOrder = new Button();
|
buttonIssuedOrder = new Button();
|
||||||
buttonUpdate = new Button();
|
buttonUpdate = new Button();
|
||||||
buttonSupplyShop = new Button();
|
buttonSupplyShop = new Button();
|
||||||
menuStrip.SuspendLayout();
|
buttonSell = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
//
|
SuspendLayout();
|
||||||
// menuStrip
|
//
|
||||||
//
|
// menuStrip
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
|
//
|
||||||
menuStrip.Location = new Point(0, 0);
|
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem });
|
||||||
menuStrip.Name = "menuStrip";
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip.Size = new Size(984, 24);
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip.TabIndex = 0;
|
menuStrip.Size = new Size(984, 24);
|
||||||
menuStrip.Text = "menuStrip1";
|
menuStrip.TabIndex = 0;
|
||||||
//
|
menuStrip.Text = "menuStrip1";
|
||||||
// справочникиToolStripMenuItem
|
//
|
||||||
//
|
// справочникиToolStripMenuItem
|
||||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, комьютерыToolStripMenuItem, магазиныToolStripMenuItem });
|
//
|
||||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, комьютерыToolStripMenuItem, магазиныToolStripMenuItem });
|
||||||
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||||
справочникиToolStripMenuItem.Text = "Справочники";
|
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
||||||
//
|
справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
// компонентыToolStripMenuItem
|
//
|
||||||
//
|
// компонентыToolStripMenuItem
|
||||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
//
|
||||||
компонентыToolStripMenuItem.Size = new Size(180, 22);
|
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
компонентыToolStripMenuItem.Size = new Size(145, 22);
|
||||||
компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||||
//
|
компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
||||||
// комьютерыToolStripMenuItem
|
//
|
||||||
//
|
// комьютерыToolStripMenuItem
|
||||||
комьютерыToolStripMenuItem.Name = "комьютерыToolStripMenuItem";
|
//
|
||||||
комьютерыToolStripMenuItem.Size = new Size(180, 22);
|
комьютерыToolStripMenuItem.Name = "комьютерыToolStripMenuItem";
|
||||||
комьютерыToolStripMenuItem.Text = "Комьютеры";
|
комьютерыToolStripMenuItem.Size = new Size(145, 22);
|
||||||
комьютерыToolStripMenuItem.Click += КомпьютерыToolStripMenuItem_Click;
|
комьютерыToolStripMenuItem.Text = "Комьютеры";
|
||||||
//
|
комьютерыToolStripMenuItem.Click += КомпьютерыToolStripMenuItem_Click;
|
||||||
// магазиныToolStripMenuItem
|
//
|
||||||
//
|
// магазиныToolStripMenuItem
|
||||||
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
//
|
||||||
магазиныToolStripMenuItem.Size = new Size(180, 22);
|
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||||
магазиныToolStripMenuItem.Text = "Магазины";
|
магазиныToolStripMenuItem.Size = new Size(145, 22);
|
||||||
магазиныToolStripMenuItem.Click += МагазиныToolStripMenuItem_Click;
|
магазиныToolStripMenuItem.Text = "Магазины";
|
||||||
//
|
магазиныToolStripMenuItem.Click += МагазиныToolStripMenuItem_Click;
|
||||||
// dataGridView
|
//
|
||||||
//
|
// dataGridView
|
||||||
dataGridView.AllowUserToAddRows = false;
|
//
|
||||||
dataGridView.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
||||||
dataGridView.Location = new Point(0, 27);
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.MultiSelect = false;
|
dataGridView.Location = new Point(0, 27);
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.MultiSelect = false;
|
||||||
dataGridView.ReadOnly = true;
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.RowHeadersVisible = false;
|
dataGridView.ReadOnly = true;
|
||||||
dataGridView.RowTemplate.Height = 25;
|
dataGridView.RowHeadersVisible = false;
|
||||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.RowTemplate.Height = 25;
|
||||||
dataGridView.Size = new Size(780, 425);
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView.TabIndex = 1;
|
dataGridView.Size = new Size(780, 425);
|
||||||
//
|
dataGridView.TabIndex = 1;
|
||||||
// buttonCreateOrder
|
//
|
||||||
//
|
// buttonCreateOrder
|
||||||
buttonCreateOrder.Location = new Point(792, 27);
|
//
|
||||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
buttonCreateOrder.Location = new Point(792, 27);
|
||||||
buttonCreateOrder.Size = new Size(180, 35);
|
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||||
buttonCreateOrder.TabIndex = 2;
|
buttonCreateOrder.Size = new Size(180, 35);
|
||||||
buttonCreateOrder.Text = "Создать заказ";
|
buttonCreateOrder.TabIndex = 2;
|
||||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
buttonCreateOrder.Text = "Создать заказ";
|
||||||
buttonCreateOrder.Click += ButtonCreateOrder_Click;
|
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||||
//
|
buttonCreateOrder.Click += ButtonCreateOrder_Click;
|
||||||
// buttonTakeOrderInWork
|
//
|
||||||
//
|
// buttonTakeOrderInWork
|
||||||
buttonTakeOrderInWork.Location = new Point(792, 87);
|
//
|
||||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
buttonTakeOrderInWork.Location = new Point(792, 87);
|
||||||
buttonTakeOrderInWork.Size = new Size(180, 35);
|
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||||
buttonTakeOrderInWork.TabIndex = 3;
|
buttonTakeOrderInWork.Size = new Size(180, 35);
|
||||||
buttonTakeOrderInWork.Text = "Отправить на выполнение";
|
buttonTakeOrderInWork.TabIndex = 3;
|
||||||
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
buttonTakeOrderInWork.Text = "Отправить на выполнение";
|
||||||
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
|
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||||
//
|
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
|
||||||
// buttonOrderReady
|
//
|
||||||
//
|
// buttonOrderReady
|
||||||
buttonOrderReady.Location = new Point(792, 147);
|
//
|
||||||
buttonOrderReady.Name = "buttonOrderReady";
|
buttonOrderReady.Location = new Point(792, 147);
|
||||||
buttonOrderReady.Size = new Size(180, 35);
|
buttonOrderReady.Name = "buttonOrderReady";
|
||||||
buttonOrderReady.TabIndex = 4;
|
buttonOrderReady.Size = new Size(180, 35);
|
||||||
buttonOrderReady.Text = "Заказ готов";
|
buttonOrderReady.TabIndex = 4;
|
||||||
buttonOrderReady.UseVisualStyleBackColor = true;
|
buttonOrderReady.Text = "Заказ готов";
|
||||||
buttonOrderReady.Click += ButtonOrderReady_Click;
|
buttonOrderReady.UseVisualStyleBackColor = true;
|
||||||
//
|
buttonOrderReady.Click += ButtonOrderReady_Click;
|
||||||
// buttonIssuedOrder
|
//
|
||||||
//
|
// buttonIssuedOrder
|
||||||
buttonIssuedOrder.Location = new Point(792, 207);
|
//
|
||||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
buttonIssuedOrder.Location = new Point(792, 207);
|
||||||
buttonIssuedOrder.Size = new Size(180, 35);
|
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||||
buttonIssuedOrder.TabIndex = 5;
|
buttonIssuedOrder.Size = new Size(180, 35);
|
||||||
buttonIssuedOrder.Text = "Заказ выдан";
|
buttonIssuedOrder.TabIndex = 5;
|
||||||
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
buttonIssuedOrder.Text = "Заказ выдан";
|
||||||
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||||
//
|
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
||||||
// buttonUpdate
|
//
|
||||||
//
|
// buttonUpdate
|
||||||
buttonUpdate.Location = new Point(792, 267);
|
//
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
buttonUpdate.Location = new Point(792, 267);
|
||||||
buttonUpdate.Size = new Size(180, 35);
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
buttonUpdate.TabIndex = 6;
|
buttonUpdate.Size = new Size(180, 35);
|
||||||
buttonUpdate.Text = "Обновить список";
|
buttonUpdate.TabIndex = 6;
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
buttonUpdate.Text = "Обновить список";
|
||||||
buttonUpdate.Click += ButtonUpd_Click;
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
//
|
buttonUpdate.Click += ButtonUpd_Click;
|
||||||
// buttonSupplyShop
|
//
|
||||||
//
|
// buttonSupplyShop
|
||||||
buttonSupplyShop.Location = new Point(792, 327);
|
//
|
||||||
buttonSupplyShop.Name = "buttonSupplyShop";
|
buttonSupplyShop.Location = new Point(792, 327);
|
||||||
buttonSupplyShop.Size = new Size(180, 35);
|
buttonSupplyShop.Name = "buttonSupplyShop";
|
||||||
buttonSupplyShop.TabIndex = 7;
|
buttonSupplyShop.Size = new Size(180, 35);
|
||||||
buttonSupplyShop.Text = "Пополнение магазина";
|
buttonSupplyShop.TabIndex = 7;
|
||||||
buttonSupplyShop.UseVisualStyleBackColor = true;
|
buttonSupplyShop.Text = "Пополнение магазина";
|
||||||
buttonSupplyShop.Click += buttonSupplyShop_Click;
|
buttonSupplyShop.UseVisualStyleBackColor = true;
|
||||||
//
|
buttonSupplyShop.Click += buttonSupplyShop_Click;
|
||||||
// FormMain
|
//
|
||||||
//
|
// buttonSell
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
//
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
buttonSell.Location = new Point(792, 387);
|
||||||
ClientSize = new Size(984, 450);
|
buttonSell.Name = "buttonSell";
|
||||||
Controls.Add(buttonSupplyShop);
|
buttonSell.Size = new Size(180, 35);
|
||||||
Controls.Add(buttonUpdate);
|
buttonSell.TabIndex = 8;
|
||||||
Controls.Add(buttonIssuedOrder);
|
buttonSell.Text = "Продажа";
|
||||||
Controls.Add(buttonOrderReady);
|
buttonSell.UseVisualStyleBackColor = true;
|
||||||
Controls.Add(buttonTakeOrderInWork);
|
buttonSell.Click += buttonSell_Click;
|
||||||
Controls.Add(buttonCreateOrder);
|
//
|
||||||
Controls.Add(dataGridView);
|
// FormMain
|
||||||
Controls.Add(menuStrip);
|
//
|
||||||
MainMenuStrip = menuStrip;
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
Name = "FormMain";
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
Text = "Компьютерный магазин";
|
ClientSize = new Size(984, 450);
|
||||||
menuStrip.ResumeLayout(false);
|
Controls.Add(buttonSell);
|
||||||
menuStrip.PerformLayout();
|
Controls.Add(buttonSupplyShop);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
Controls.Add(buttonUpdate);
|
||||||
ResumeLayout(false);
|
Controls.Add(buttonIssuedOrder);
|
||||||
PerformLayout();
|
Controls.Add(buttonOrderReady);
|
||||||
}
|
Controls.Add(buttonTakeOrderInWork);
|
||||||
|
Controls.Add(buttonCreateOrder);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(menuStrip);
|
||||||
|
MainMenuStrip = menuStrip;
|
||||||
|
Name = "FormMain";
|
||||||
|
Text = "Компьютерный магазин";
|
||||||
|
Load += FormMain_Load;
|
||||||
|
menuStrip.ResumeLayout(false);
|
||||||
|
menuStrip.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private MenuStrip menuStrip;
|
private MenuStrip menuStrip;
|
||||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||||
private ToolStripMenuItem комьютерыToolStripMenuItem;
|
private ToolStripMenuItem комьютерыToolStripMenuItem;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private Button buttonCreateOrder;
|
private Button buttonCreateOrder;
|
||||||
private Button buttonTakeOrderInWork;
|
private Button buttonTakeOrderInWork;
|
||||||
private Button buttonOrderReady;
|
private Button buttonOrderReady;
|
||||||
private Button buttonIssuedOrder;
|
private Button buttonIssuedOrder;
|
||||||
private Button buttonUpdate;
|
private Button buttonUpdate;
|
||||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||||
private Button buttonSupplyShop;
|
private Button buttonSupplyShop;
|
||||||
}
|
private Button buttonSell;
|
||||||
|
}
|
||||||
}
|
}
|
@ -13,162 +13,173 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace ComputersShop
|
namespace ComputersShop
|
||||||
{
|
{
|
||||||
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()
|
||||||
{
|
{
|
||||||
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;
|
||||||
dataGridView.Columns["ComputerName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["ComputerName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Orders loading");
|
_logger.LogInformation("Orders loading");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Orders loading error");
|
_logger.LogError(ex, "Orders loading error");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void КомпонентыToolStripMenuItem_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 КомпьютерыToolStripMenuItem_Click(object sender, EventArgs e)
|
private void КомпьютерыToolStripMenuItem_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 МагазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
private void МагазиныToolStripMenuItem_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("Order №{id}. Status changes to 'В работе'", id);
|
_logger.LogInformation("Order №{id}. Status changes to 'В работе'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error taking an order to work");
|
_logger.LogError(ex, "Error taking an order to work");
|
||||||
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("Order №{id}. Status changes to 'Готов'", id);
|
var computerId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ComputerId"].Value);
|
||||||
try
|
var count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value);
|
||||||
{
|
_logger.LogInformation("Order №{id}. Status changes to 'Готов'", id);
|
||||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
|
try
|
||||||
if (!operationResult)
|
{
|
||||||
{
|
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id, ComputerId = computerId, Count = count });
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
if (!operationResult)
|
||||||
}
|
{
|
||||||
LoadData();
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
LoadData();
|
||||||
{
|
}
|
||||||
_logger.LogError(ex, "Order readiness marking error");
|
catch (Exception ex)
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
{
|
||||||
}
|
_logger.LogError(ex, "Order readiness marking 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("Order №{id}. Status changes to 'Выдан'", id);
|
_logger.LogInformation("Order №{id}. Status changes to 'Выдан'", id);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
|
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Order №{id} issued", id);
|
_logger.LogInformation("Order №{id} issued", id);
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Order issue marking error");
|
_logger.LogError(ex, "Order issue marking error");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonSupplyShop_Click(object sender, EventArgs e)
|
private void buttonSupplyShop_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShopSupply));
|
var service = Program.ServiceProvider?.GetService(typeof(FormShopSupply));
|
||||||
if (service is FormShopSupply form)
|
if (service is FormShopSupply form)
|
||||||
{
|
{
|
||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private void buttonSell_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormSell));
|
||||||
|
if (service is FormSell form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
119
ComputersShop/ComputersShop/FormSell.Designer.cs
generated
Normal file
119
ComputersShop/ComputersShop/FormSell.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
namespace ComputersShop
|
||||||
|
{
|
||||||
|
partial class FormSell
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
labelComputer = new Label();
|
||||||
|
comboBoxComputer = new ComboBox();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonSave = new Button();
|
||||||
|
textBoxCount = new TextBox();
|
||||||
|
labelCount = new Label();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelComputer
|
||||||
|
//
|
||||||
|
labelComputer.AutoSize = true;
|
||||||
|
labelComputer.Location = new Point(12, 9);
|
||||||
|
labelComputer.Name = "labelComputer";
|
||||||
|
labelComputer.Size = new Size(74, 15);
|
||||||
|
labelComputer.TabIndex = 23;
|
||||||
|
labelComputer.Text = "Компьютер:";
|
||||||
|
//
|
||||||
|
// comboBoxComputer
|
||||||
|
//
|
||||||
|
comboBoxComputer.FormattingEnabled = true;
|
||||||
|
comboBoxComputer.Location = new Point(90, 6);
|
||||||
|
comboBoxComputer.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
comboBoxComputer.Name = "comboBoxComputer";
|
||||||
|
comboBoxComputer.Size = new Size(280, 23);
|
||||||
|
comboBoxComputer.TabIndex = 22;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(270, 70);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(100, 30);
|
||||||
|
buttonCancel.TabIndex = 19;
|
||||||
|
buttonCancel.Text = "Отменить";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(160, 70);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(100, 30);
|
||||||
|
buttonSave.TabIndex = 18;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += buttonSave_Click;
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
textBoxCount.Location = new Point(90, 34);
|
||||||
|
textBoxCount.Name = "textBoxCount";
|
||||||
|
textBoxCount.Size = new Size(280, 23);
|
||||||
|
textBoxCount.TabIndex = 17;
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
labelCount.AutoSize = true;
|
||||||
|
labelCount.Location = new Point(12, 37);
|
||||||
|
labelCount.Name = "labelCount";
|
||||||
|
labelCount.Size = new Size(75, 15);
|
||||||
|
labelCount.TabIndex = 16;
|
||||||
|
labelCount.Text = "Количество:";
|
||||||
|
//
|
||||||
|
// FormSell
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(385, 116);
|
||||||
|
Controls.Add(labelComputer);
|
||||||
|
Controls.Add(comboBoxComputer);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(textBoxCount);
|
||||||
|
Controls.Add(labelCount);
|
||||||
|
Name = "FormSell";
|
||||||
|
Text = "FormSell";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelComputer;
|
||||||
|
private ComboBox comboBoxComputer;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private Label labelCount;
|
||||||
|
}
|
||||||
|
}
|
124
ComputersShop/ComputersShop/FormSell.cs
Normal file
124
ComputersShop/ComputersShop/FormSell.cs
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
using ComputersShopContracts.BuisnessLogicsContracts;
|
||||||
|
using ComputersShopContracts.BusinessLogicsContracts;
|
||||||
|
using ComputersShopContracts.ViewModels;
|
||||||
|
using ComputersShopDataModels.Models;
|
||||||
|
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 ComputersShop
|
||||||
|
{
|
||||||
|
public partial class FormSell : Form
|
||||||
|
{
|
||||||
|
private readonly List<ComputerViewModel>? _computerList;
|
||||||
|
IShopLogic _shopLogic;
|
||||||
|
IComputerLogic _computerLogic;
|
||||||
|
public FormSell(IComputerLogic computerLogic, IShopLogic shopLogic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_computerLogic = computerLogic;
|
||||||
|
_shopLogic = shopLogic;
|
||||||
|
_computerList = computerLogic.ReadList(null);
|
||||||
|
if (_computerList != null)
|
||||||
|
{
|
||||||
|
comboBoxComputer.DisplayMember = "ComputerName";
|
||||||
|
comboBoxComputer.ValueMember = "Id";
|
||||||
|
comboBoxComputer.DataSource = _computerList;
|
||||||
|
comboBoxComputer.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int ComputerId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Convert.ToInt32(comboBoxComputer.SelectedValue);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
comboBoxComputer.SelectedValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IComputerModel? ComputerModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_computerList == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var elem in _computerList)
|
||||||
|
{
|
||||||
|
if (elem.Id == ComputerId)
|
||||||
|
{
|
||||||
|
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 (comboBoxComputer.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите компьютер", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int count = Convert.ToInt32(textBoxCount.Text);
|
||||||
|
|
||||||
|
bool res = _shopLogic.MakeSell(_computerLogic.ReadElement(new()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(comboBoxComputer.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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
ComputersShop/ComputersShop/FormSell.resx
Normal file
60
ComputersShop/ComputersShop/FormSell.resx
Normal 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>
|
384
ComputersShop/ComputersShop/FormShop.Designer.cs
generated
384
ComputersShop/ComputersShop/FormShop.Designer.cs
generated
@ -1,188 +1,212 @@
|
|||||||
namespace ComputersShop
|
namespace ComputersShop
|
||||||
{
|
{
|
||||||
partial class FormShop
|
partial class FormShop
|
||||||
{
|
{
|
||||||
/// <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()
|
||||||
{
|
{
|
||||||
textBoxName = new TextBox();
|
textBoxName = new TextBox();
|
||||||
labelAddress = new Label();
|
labelAddress = new Label();
|
||||||
labelName = new Label();
|
labelName = new Label();
|
||||||
DateTimePickerDateOpen = new DateTimePicker();
|
DateTimePickerDateOpen = new DateTimePicker();
|
||||||
labelDateOpen = new Label();
|
labelDateOpen = new Label();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
ColumnId = new DataGridViewTextBoxColumn();
|
ColumnId = new DataGridViewTextBoxColumn();
|
||||||
ColumnComputer = new DataGridViewTextBoxColumn();
|
ColumnComputer = new DataGridViewTextBoxColumn();
|
||||||
ColumnCount = new DataGridViewTextBoxColumn();
|
ColumnCount = new DataGridViewTextBoxColumn();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
textBoxAddress = new TextBox();
|
textBoxAddress = new TextBox();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
labelMaxCount = new Label();
|
||||||
SuspendLayout();
|
numericUpDownMaxCount = new NumericUpDown();
|
||||||
//
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
// textBoxName
|
((System.ComponentModel.ISupportInitialize)numericUpDownMaxCount).BeginInit();
|
||||||
//
|
SuspendLayout();
|
||||||
textBoxName.Location = new Point(105, 6);
|
//
|
||||||
textBoxName.Name = "textBoxName";
|
// textBoxName
|
||||||
textBoxName.Size = new Size(235, 23);
|
//
|
||||||
textBoxName.TabIndex = 11;
|
textBoxName.Location = new Point(105, 6);
|
||||||
//
|
textBoxName.Name = "textBoxName";
|
||||||
// labelAddress
|
textBoxName.Size = new Size(235, 23);
|
||||||
//
|
textBoxName.TabIndex = 11;
|
||||||
labelAddress.AutoSize = true;
|
//
|
||||||
labelAddress.Location = new Point(12, 42);
|
// labelAddress
|
||||||
labelAddress.Name = "labelAddress";
|
//
|
||||||
labelAddress.Size = new Size(43, 15);
|
labelAddress.AutoSize = true;
|
||||||
labelAddress.TabIndex = 9;
|
labelAddress.Location = new Point(12, 42);
|
||||||
labelAddress.Text = "Адрес:";
|
labelAddress.Name = "labelAddress";
|
||||||
//
|
labelAddress.Size = new Size(43, 15);
|
||||||
// labelName
|
labelAddress.TabIndex = 9;
|
||||||
//
|
labelAddress.Text = "Адрес:";
|
||||||
labelName.AutoSize = true;
|
//
|
||||||
labelName.Location = new Point(12, 9);
|
// labelName
|
||||||
labelName.Name = "labelName";
|
//
|
||||||
labelName.Size = new Size(62, 15);
|
labelName.AutoSize = true;
|
||||||
labelName.TabIndex = 8;
|
labelName.Location = new Point(12, 9);
|
||||||
labelName.Text = "Название:";
|
labelName.Name = "labelName";
|
||||||
//
|
labelName.Size = new Size(62, 15);
|
||||||
// DateTimePickerDateOpen
|
labelName.TabIndex = 8;
|
||||||
//
|
labelName.Text = "Название:";
|
||||||
DateTimePickerDateOpen.Location = new Point(105, 72);
|
//
|
||||||
DateTimePickerDateOpen.Name = "DateTimePickerDateOpen";
|
// DateTimePickerDateOpen
|
||||||
DateTimePickerDateOpen.Size = new Size(235, 23);
|
//
|
||||||
DateTimePickerDateOpen.TabIndex = 15;
|
DateTimePickerDateOpen.Location = new Point(105, 72);
|
||||||
//
|
DateTimePickerDateOpen.Name = "DateTimePickerDateOpen";
|
||||||
// labelDateOpen
|
DateTimePickerDateOpen.Size = new Size(235, 23);
|
||||||
//
|
DateTimePickerDateOpen.TabIndex = 15;
|
||||||
labelDateOpen.AutoSize = true;
|
//
|
||||||
labelDateOpen.Location = new Point(12, 75);
|
// labelDateOpen
|
||||||
labelDateOpen.Name = "labelDateOpen";
|
//
|
||||||
labelDateOpen.Size = new Size(87, 15);
|
labelDateOpen.AutoSize = true;
|
||||||
labelDateOpen.TabIndex = 16;
|
labelDateOpen.Location = new Point(12, 75);
|
||||||
labelDateOpen.Text = "Дата открытия";
|
labelDateOpen.Name = "labelDateOpen";
|
||||||
//
|
labelDateOpen.Size = new Size(87, 15);
|
||||||
// dataGridView
|
labelDateOpen.TabIndex = 16;
|
||||||
//
|
labelDateOpen.Text = "Дата открытия";
|
||||||
dataGridView.AllowUserToAddRows = false;
|
//
|
||||||
dataGridView.AllowUserToDeleteRows = false;
|
// dataGridView
|
||||||
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
//
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnComputer, ColumnCount });
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView.Location = new Point(12, 110);
|
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
||||||
dataGridView.MultiSelect = false;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnComputer, ColumnCount });
|
||||||
dataGridView.ReadOnly = true;
|
dataGridView.Location = new Point(12, 160);
|
||||||
dataGridView.RowHeadersVisible = false;
|
dataGridView.MultiSelect = false;
|
||||||
dataGridView.RowTemplate.Height = 25;
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.ReadOnly = true;
|
||||||
dataGridView.Size = new Size(535, 250);
|
dataGridView.RowHeadersVisible = false;
|
||||||
dataGridView.TabIndex = 17;
|
dataGridView.RowTemplate.Height = 25;
|
||||||
//
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
// ColumnId
|
dataGridView.Size = new Size(535, 250);
|
||||||
//
|
dataGridView.TabIndex = 17;
|
||||||
ColumnId.HeaderText = "Id";
|
//
|
||||||
ColumnId.Name = "ColumnId";
|
// ColumnId
|
||||||
ColumnId.ReadOnly = true;
|
//
|
||||||
ColumnId.Visible = false;
|
ColumnId.HeaderText = "Id";
|
||||||
//
|
ColumnId.Name = "ColumnId";
|
||||||
// ColumnComputer
|
ColumnId.ReadOnly = true;
|
||||||
//
|
ColumnId.Visible = false;
|
||||||
ColumnComputer.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
//
|
||||||
ColumnComputer.HeaderText = "Компьютер";
|
// ColumnComputer
|
||||||
ColumnComputer.Name = "ColumnComputer";
|
//
|
||||||
ColumnComputer.ReadOnly = true;
|
ColumnComputer.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
//
|
ColumnComputer.HeaderText = "Компьютер";
|
||||||
// ColumnCount
|
ColumnComputer.Name = "ColumnComputer";
|
||||||
//
|
ColumnComputer.ReadOnly = true;
|
||||||
ColumnCount.HeaderText = "Количество";
|
//
|
||||||
ColumnCount.Name = "ColumnCount";
|
// ColumnCount
|
||||||
ColumnCount.ReadOnly = true;
|
//
|
||||||
//
|
ColumnCount.HeaderText = "Количество";
|
||||||
// buttonCancel
|
ColumnCount.Name = "ColumnCount";
|
||||||
//
|
ColumnCount.ReadOnly = true;
|
||||||
buttonCancel.Location = new Point(447, 369);
|
//
|
||||||
buttonCancel.Name = "buttonCancel";
|
// buttonCancel
|
||||||
buttonCancel.Size = new Size(100, 30);
|
//
|
||||||
buttonCancel.TabIndex = 19;
|
buttonCancel.Location = new Point(445, 420);
|
||||||
buttonCancel.Text = "Отменить";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.Size = new Size(100, 30);
|
||||||
buttonCancel.Click += buttonCancel_Click;
|
buttonCancel.TabIndex = 19;
|
||||||
//
|
buttonCancel.Text = "Отменить";
|
||||||
// buttonSave
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
//
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
buttonSave.Location = new Point(337, 369);
|
//
|
||||||
buttonSave.Name = "buttonSave";
|
// buttonSave
|
||||||
buttonSave.Size = new Size(100, 30);
|
//
|
||||||
buttonSave.TabIndex = 18;
|
buttonSave.Location = new Point(335, 420);
|
||||||
buttonSave.Text = "Сохранить";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.Size = new Size(100, 30);
|
||||||
buttonSave.Click += buttonSave_Click;
|
buttonSave.TabIndex = 18;
|
||||||
//
|
buttonSave.Text = "Сохранить";
|
||||||
// textBoxAddress
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
//
|
buttonSave.Click += buttonSave_Click;
|
||||||
textBoxAddress.Location = new Point(105, 39);
|
//
|
||||||
textBoxAddress.Name = "textBoxAddress";
|
// textBoxAddress
|
||||||
textBoxAddress.Size = new Size(235, 23);
|
//
|
||||||
textBoxAddress.TabIndex = 20;
|
textBoxAddress.Location = new Point(105, 39);
|
||||||
//
|
textBoxAddress.Name = "textBoxAddress";
|
||||||
// FormShop
|
textBoxAddress.Size = new Size(235, 23);
|
||||||
//
|
textBoxAddress.TabIndex = 20;
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
//
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
// labelMaxCount
|
||||||
ClientSize = new Size(559, 411);
|
//
|
||||||
Controls.Add(textBoxAddress);
|
labelMaxCount.AutoSize = true;
|
||||||
Controls.Add(buttonCancel);
|
labelMaxCount.Location = new Point(12, 108);
|
||||||
Controls.Add(buttonSave);
|
labelMaxCount.Name = "labelMaxCount";
|
||||||
Controls.Add(dataGridView);
|
labelMaxCount.Size = new Size(80, 15);
|
||||||
Controls.Add(labelDateOpen);
|
labelMaxCount.TabIndex = 21;
|
||||||
Controls.Add(DateTimePickerDateOpen);
|
labelMaxCount.Text = "Макс. кол-во";
|
||||||
Controls.Add(textBoxName);
|
//
|
||||||
Controls.Add(labelAddress);
|
// numericUpDownMaxCount
|
||||||
Controls.Add(labelName);
|
//
|
||||||
Name = "FormShop";
|
numericUpDownMaxCount.Location = new Point(105, 105);
|
||||||
Text = "Магазин";
|
numericUpDownMaxCount.Name = "numericUpDownMaxCount";
|
||||||
Load += FormShop_Load;
|
numericUpDownMaxCount.Size = new Size(235, 23);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
numericUpDownMaxCount.TabIndex = 22;
|
||||||
ResumeLayout(false);
|
//
|
||||||
PerformLayout();
|
// FormShop
|
||||||
}
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(559, 461);
|
||||||
|
Controls.Add(numericUpDownMaxCount);
|
||||||
|
Controls.Add(labelMaxCount);
|
||||||
|
Controls.Add(textBoxAddress);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(labelDateOpen);
|
||||||
|
Controls.Add(DateTimePickerDateOpen);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(labelAddress);
|
||||||
|
Controls.Add(labelName);
|
||||||
|
Name = "FormShop";
|
||||||
|
Text = "Магазин";
|
||||||
|
Load += FormShop_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownMaxCount).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private TextBox textBoxName;
|
private TextBox textBoxName;
|
||||||
private Label labelAddress;
|
private Label labelAddress;
|
||||||
private Label labelName;
|
private Label labelName;
|
||||||
private DateTimePicker DateTimePickerDateOpen;
|
private DateTimePicker DateTimePickerDateOpen;
|
||||||
private Label labelDateOpen;
|
private Label labelDateOpen;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private DataGridViewTextBoxColumn ColumnId;
|
private DataGridViewTextBoxColumn ColumnId;
|
||||||
private DataGridViewTextBoxColumn ColumnComputer;
|
private DataGridViewTextBoxColumn ColumnComputer;
|
||||||
private DataGridViewTextBoxColumn ColumnCount;
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private TextBox textBoxAddress;
|
private TextBox textBoxAddress;
|
||||||
}
|
private Label labelMaxCount;
|
||||||
|
private NumericUpDown numericUpDownMaxCount;
|
||||||
|
}
|
||||||
}
|
}
|
@ -15,120 +15,122 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace ComputersShop
|
namespace ComputersShop
|
||||||
{
|
{
|
||||||
public partial class FormShop : Form
|
public partial class FormShop : Form
|
||||||
{
|
{
|
||||||
private readonly IShopLogic _logic;
|
private readonly IShopLogic _logic;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private Dictionary<int, (IComputerModel, int)> _shopComputers;
|
private Dictionary<int, (IComputerModel, int)> _shopComputers;
|
||||||
private int? _id;
|
private int? _id;
|
||||||
public int Id { set { _id = value; } }
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
_shopComputers = new();
|
_shopComputers = new();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormShop_Load(object sender, EventArgs e)
|
private void FormShop_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_id.HasValue)
|
if (_id.HasValue)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Loading shop");
|
_logger.LogInformation("Loading shop");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var shop = _logic.ReadElement(new ShopSearchModel { Id = _id });
|
var shop = _logic.ReadElement(new ShopSearchModel { Id = _id });
|
||||||
|
|
||||||
if (shop != null)
|
if (shop != null)
|
||||||
{
|
{
|
||||||
textBoxName.Text = shop.ShopName;
|
textBoxName.Text = shop.ShopName;
|
||||||
textBoxAddress.Text = shop.Address;
|
textBoxAddress.Text = shop.Address;
|
||||||
DateTimePickerDateOpen.Value = shop.DateOpen;
|
DateTimePickerDateOpen.Value = shop.DateOpen;
|
||||||
_shopComputers = shop.ShopComputers ?? new Dictionary<int, (IComputerModel, int)>();
|
numericUpDownMaxCount.Value = shop.MaxCount;
|
||||||
LoadData();
|
_shopComputers = shop.ShopComputers ?? new Dictionary<int, (IComputerModel, int)>();
|
||||||
}
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
}
|
||||||
{
|
catch (Exception ex)
|
||||||
_logger.LogError(ex, "Error during loading shop");
|
{
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
_logger.LogError(ex, "Error during loading shop");
|
||||||
}
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Loading shop's bouquets");
|
_logger.LogInformation("Loading shop's bouquets");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_shopComputers != null)
|
if (_shopComputers != null)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Clear();
|
dataGridView.Rows.Clear();
|
||||||
foreach (var computer in _shopComputers)
|
foreach (var computer in _shopComputers)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[] { computer.Key, computer.Value.Item1.ComputerName, computer.Value.Item2 });
|
dataGridView.Rows.Add(new object[] { computer.Key, computer.Value.Item1.ComputerName, computer.Value.Item2 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error during loading shop's computers");
|
_logger.LogError(ex, "Error during loading shop's computers");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonSave_Click(object sender, EventArgs e)
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Saving shop");
|
_logger.LogInformation("Saving shop");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var model = new ShopBindingModel
|
var model = new ShopBindingModel
|
||||||
{
|
{
|
||||||
Id = _id ?? 0,
|
Id = _id ?? 0,
|
||||||
ShopName = textBoxName.Text,
|
ShopName = textBoxName.Text,
|
||||||
Address = textBoxAddress.Text,
|
Address = textBoxAddress.Text,
|
||||||
DateOpen = DateTimePickerDateOpen.Value,
|
DateOpen = DateTimePickerDateOpen.Value,
|
||||||
ShopComputers = _shopComputers
|
MaxCount = (int)numericUpDownMaxCount.Value,
|
||||||
};
|
ShopComputers = _shopComputers
|
||||||
|
};
|
||||||
|
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||||
|
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error during saving shop");
|
_logger.LogError(ex, "Error during saving shop");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCancel_Click(object sender, EventArgs e)
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult = DialogResult.Cancel;
|
DialogResult = DialogResult.Cancel;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,4 +66,13 @@
|
|||||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnComputer.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
278
ComputersShop/ComputersShop/FormShopSupply.Designer.cs
generated
278
ComputersShop/ComputersShop/FormShopSupply.Designer.cs
generated
@ -1,147 +1,147 @@
|
|||||||
namespace ComputersShop
|
namespace ComputersShop
|
||||||
{
|
{
|
||||||
partial class FormShopSupply
|
partial class FormShopSupply
|
||||||
{
|
{
|
||||||
/// <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()
|
||||||
{
|
{
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
textBoxCount = new TextBox();
|
textBoxCount = new TextBox();
|
||||||
labelCount = new Label();
|
labelCount = new Label();
|
||||||
labelShop = new Label();
|
labelShop = new Label();
|
||||||
comboBoxShop = new ComboBox();
|
comboBoxShop = new ComboBox();
|
||||||
comboBoxComputer = new ComboBox();
|
comboBoxComputer = new ComboBox();
|
||||||
labelComputer = new Label();
|
labelComputer = new Label();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(270, 100);
|
buttonCancel.Location = new Point(270, 100);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(100, 30);
|
buttonCancel.Size = new Size(100, 30);
|
||||||
buttonCancel.TabIndex = 11;
|
buttonCancel.TabIndex = 11;
|
||||||
buttonCancel.Text = "Отменить";
|
buttonCancel.Text = "Отменить";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += buttonCancel_Click;
|
buttonCancel.Click += buttonCancel_Click;
|
||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(160, 100);
|
buttonSave.Location = new Point(160, 100);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(100, 30);
|
buttonSave.Size = new Size(100, 30);
|
||||||
buttonSave.TabIndex = 10;
|
buttonSave.TabIndex = 10;
|
||||||
buttonSave.Text = "Сохранить";
|
buttonSave.Text = "Сохранить";
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
buttonSave.Click += buttonSave_Click;
|
buttonSave.Click += buttonSave_Click;
|
||||||
//
|
//
|
||||||
// textBoxCount
|
// textBoxCount
|
||||||
//
|
//
|
||||||
textBoxCount.Location = new Point(90, 64);
|
textBoxCount.Location = new Point(90, 64);
|
||||||
textBoxCount.Name = "textBoxCount";
|
textBoxCount.Name = "textBoxCount";
|
||||||
textBoxCount.Size = new Size(282, 23);
|
textBoxCount.Size = new Size(280, 23);
|
||||||
textBoxCount.TabIndex = 9;
|
textBoxCount.TabIndex = 9;
|
||||||
//
|
//
|
||||||
// labelCount
|
// labelCount
|
||||||
//
|
//
|
||||||
labelCount.AutoSize = true;
|
labelCount.AutoSize = true;
|
||||||
labelCount.Location = new Point(12, 67);
|
labelCount.Location = new Point(12, 67);
|
||||||
labelCount.Name = "labelCount";
|
labelCount.Name = "labelCount";
|
||||||
labelCount.Size = new Size(75, 15);
|
labelCount.Size = new Size(75, 15);
|
||||||
labelCount.TabIndex = 7;
|
labelCount.TabIndex = 7;
|
||||||
labelCount.Text = "Количество:";
|
labelCount.Text = "Количество:";
|
||||||
//
|
//
|
||||||
// labelShop
|
// labelShop
|
||||||
//
|
//
|
||||||
labelShop.AutoSize = true;
|
labelShop.AutoSize = true;
|
||||||
labelShop.Location = new Point(12, 9);
|
labelShop.Location = new Point(12, 9);
|
||||||
labelShop.Name = "labelShop";
|
labelShop.Name = "labelShop";
|
||||||
labelShop.Size = new Size(57, 15);
|
labelShop.Size = new Size(57, 15);
|
||||||
labelShop.TabIndex = 12;
|
labelShop.TabIndex = 12;
|
||||||
labelShop.Text = "Магазин:";
|
labelShop.Text = "Магазин:";
|
||||||
//
|
//
|
||||||
// comboBoxShop
|
// comboBoxShop
|
||||||
//
|
//
|
||||||
comboBoxShop.FormattingEnabled = true;
|
comboBoxShop.FormattingEnabled = true;
|
||||||
comboBoxShop.Location = new Point(90, 6);
|
comboBoxShop.Location = new Point(90, 6);
|
||||||
comboBoxShop.Margin = new Padding(3, 2, 3, 2);
|
comboBoxShop.Margin = new Padding(3, 2, 3, 2);
|
||||||
comboBoxShop.Name = "comboBoxShop";
|
comboBoxShop.Name = "comboBoxShop";
|
||||||
comboBoxShop.Size = new Size(280, 23);
|
comboBoxShop.Size = new Size(280, 23);
|
||||||
comboBoxShop.TabIndex = 13;
|
comboBoxShop.TabIndex = 13;
|
||||||
//
|
//
|
||||||
// comboBoxComputer
|
// comboBoxComputer
|
||||||
//
|
//
|
||||||
comboBoxComputer.FormattingEnabled = true;
|
comboBoxComputer.FormattingEnabled = true;
|
||||||
comboBoxComputer.Location = new Point(90, 36);
|
comboBoxComputer.Location = new Point(90, 36);
|
||||||
comboBoxComputer.Margin = new Padding(3, 2, 3, 2);
|
comboBoxComputer.Margin = new Padding(3, 2, 3, 2);
|
||||||
comboBoxComputer.Name = "comboBoxComputer";
|
comboBoxComputer.Name = "comboBoxComputer";
|
||||||
comboBoxComputer.Size = new Size(280, 23);
|
comboBoxComputer.Size = new Size(280, 23);
|
||||||
comboBoxComputer.TabIndex = 14;
|
comboBoxComputer.TabIndex = 14;
|
||||||
//
|
//
|
||||||
// labelComputer
|
// labelComputer
|
||||||
//
|
//
|
||||||
labelComputer.AutoSize = true;
|
labelComputer.AutoSize = true;
|
||||||
labelComputer.Location = new Point(12, 39);
|
labelComputer.Location = new Point(12, 39);
|
||||||
labelComputer.Name = "labelComputer";
|
labelComputer.Name = "labelComputer";
|
||||||
labelComputer.Size = new Size(74, 15);
|
labelComputer.Size = new Size(74, 15);
|
||||||
labelComputer.TabIndex = 15;
|
labelComputer.TabIndex = 15;
|
||||||
labelComputer.Text = "Компьютер:";
|
labelComputer.Text = "Компьютер:";
|
||||||
//
|
//
|
||||||
// FormShopSupply
|
// FormShopSupply
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(384, 139);
|
ClientSize = new Size(384, 139);
|
||||||
Controls.Add(labelComputer);
|
Controls.Add(labelComputer);
|
||||||
Controls.Add(comboBoxComputer);
|
Controls.Add(comboBoxComputer);
|
||||||
Controls.Add(comboBoxShop);
|
Controls.Add(comboBoxShop);
|
||||||
Controls.Add(labelShop);
|
Controls.Add(labelShop);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(textBoxCount);
|
Controls.Add(textBoxCount);
|
||||||
Controls.Add(labelCount);
|
Controls.Add(labelCount);
|
||||||
Name = "FormShopSupply";
|
Name = "FormShopSupply";
|
||||||
Text = "FormShopSupply";
|
Text = "FormShopSupply";
|
||||||
Load += FormShopSupply_Load;
|
Load += FormShopSupply_Load;
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private TextBox textBoxCount;
|
private TextBox textBoxCount;
|
||||||
private TextBox textBoxName;
|
private TextBox textBoxName;
|
||||||
private Label labelCount;
|
private Label labelCount;
|
||||||
private Label labelName;
|
private Label labelName;
|
||||||
private TextBox textBox1;
|
private TextBox textBox1;
|
||||||
private Label labelShop;
|
private Label labelShop;
|
||||||
private ComboBox comboBoxShop;
|
private ComboBox comboBoxShop;
|
||||||
private ComboBox comboBoxComputer;
|
private ComboBox comboBoxComputer;
|
||||||
private Label labelComputer;
|
private Label labelComputer;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,113 +15,113 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace ComputersShop
|
namespace ComputersShop
|
||||||
{
|
{
|
||||||
public partial class FormShopSupply : Form
|
public partial class FormShopSupply : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IComputerLogic _logicComputer;
|
private readonly IComputerLogic _logicComputer;
|
||||||
private readonly IShopLogic _logicShop;
|
private readonly IShopLogic _logicShop;
|
||||||
|
|
||||||
public FormShopSupply(ILogger<FormShopSupply> logger, IComputerLogic logicBouquet, IShopLogic logicShop)
|
public FormShopSupply(ILogger<FormShopSupply> logger, IComputerLogic logicBouquet, IShopLogic logicShop)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logicComputer = logicBouquet;
|
_logicComputer = logicBouquet;
|
||||||
_logicShop = logicShop;
|
_logicShop = logicShop;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormShopSupply_Load(object sender, EventArgs e)
|
private void FormShopSupply_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Loading computers for supplying");
|
_logger.LogInformation("Loading computers for supplying");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logicComputer.ReadList(null);
|
var list = _logicComputer.ReadList(null);
|
||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
comboBoxComputer.DisplayMember = "ComputerName";
|
comboBoxComputer.DisplayMember = "ComputerName";
|
||||||
comboBoxComputer.ValueMember = "Id";
|
comboBoxComputer.ValueMember = "Id";
|
||||||
comboBoxComputer.DataSource = list;
|
comboBoxComputer.DataSource = list;
|
||||||
comboBoxComputer.SelectedItem = null;
|
comboBoxComputer.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error during loading bouquets for supplying");
|
_logger.LogError(ex, "Error during loading bouquets for supplying");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Loading shops for supplying");
|
_logger.LogInformation("Loading shops for supplying");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logicShop.ReadList(null);
|
var list = _logicShop.ReadList(null);
|
||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
comboBoxShop.DisplayMember = "ShopName";
|
comboBoxShop.DisplayMember = "ShopName";
|
||||||
comboBoxShop.ValueMember = "Id";
|
comboBoxShop.ValueMember = "Id";
|
||||||
comboBoxShop.DataSource = list;
|
comboBoxShop.DataSource = list;
|
||||||
comboBoxShop.SelectedItem = null;
|
comboBoxShop.SelectedItem = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error during loading shops for supplying");
|
_logger.LogError(ex, "Error during loading shops for supplying");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonSave_Click(object sender, EventArgs e)
|
private void buttonSave_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comboBoxComputer.SelectedValue == null)
|
if (comboBoxComputer.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите букет", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите букет", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (comboBoxShop.SelectedValue == null)
|
if (comboBoxShop.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Creation of supply");
|
_logger.LogInformation("Creation of supply");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _logicShop.SupplyComputers(
|
var operationResult = _logicShop.SupplyComputers(
|
||||||
new ShopSearchModel { Id = Convert.ToInt32(comboBoxShop.SelectedValue), Name = comboBoxShop.Text },
|
new ShopSearchModel { Id = Convert.ToInt32(comboBoxShop.SelectedValue), Name = comboBoxShop.Text },
|
||||||
new ComputerBindingModel { Id = Convert.ToInt32(comboBoxComputer.SelectedValue), ComputerName = comboBoxComputer.Text },
|
new ComputerBindingModel { Id = Convert.ToInt32(comboBoxComputer.SelectedValue), ComputerName = comboBoxComputer.Text },
|
||||||
Convert.ToInt32(textBoxCount.Text)
|
Convert.ToInt32(textBoxCount.Text)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!operationResult)
|
if (!operationResult)
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error during creation of supply");
|
_logger.LogError(ex, "Error during creation of supply");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonCancel_Click(object sender, EventArgs e)
|
private void buttonCancel_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult = DialogResult.Cancel;
|
DialogResult = DialogResult.Cancel;
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
282
ComputersShop/ComputersShop/FormShops.Designer.cs
generated
282
ComputersShop/ComputersShop/FormShops.Designer.cs
generated
@ -1,149 +1,149 @@
|
|||||||
namespace ComputersShop
|
namespace ComputersShop
|
||||||
{
|
{
|
||||||
partial class FormShops
|
partial class FormShops
|
||||||
{
|
{
|
||||||
/// <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()
|
||||||
{
|
{
|
||||||
DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
|
DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
|
||||||
DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
|
DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
|
||||||
DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
|
DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
|
||||||
buttonReload = new Button();
|
buttonReload = new Button();
|
||||||
buttonDelete = new Button();
|
buttonDelete = new Button();
|
||||||
buttonUpdate = new Button();
|
buttonUpdate = new Button();
|
||||||
buttonAdd = new Button();
|
buttonAdd = new Button();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// buttonReload
|
// buttonReload
|
||||||
//
|
//
|
||||||
buttonReload.Location = new Point(332, 123);
|
buttonReload.Location = new Point(432, 123);
|
||||||
buttonReload.Name = "buttonReload";
|
buttonReload.Name = "buttonReload";
|
||||||
buttonReload.Size = new Size(140, 30);
|
buttonReload.Size = new Size(140, 30);
|
||||||
buttonReload.TabIndex = 13;
|
buttonReload.TabIndex = 13;
|
||||||
buttonReload.Text = "Обновить";
|
buttonReload.Text = "Обновить";
|
||||||
buttonReload.UseVisualStyleBackColor = true;
|
buttonReload.UseVisualStyleBackColor = true;
|
||||||
buttonReload.Click += buttonUpdate_Click;
|
buttonReload.Click += buttonUpdate_Click;
|
||||||
//
|
//
|
||||||
// buttonDelete
|
// buttonDelete
|
||||||
//
|
//
|
||||||
buttonDelete.Location = new Point(332, 87);
|
buttonDelete.Location = new Point(432, 87);
|
||||||
buttonDelete.Name = "buttonDelete";
|
buttonDelete.Name = "buttonDelete";
|
||||||
buttonDelete.Size = new Size(140, 30);
|
buttonDelete.Size = new Size(140, 30);
|
||||||
buttonDelete.TabIndex = 12;
|
buttonDelete.TabIndex = 12;
|
||||||
buttonDelete.Text = "Удалить";
|
buttonDelete.Text = "Удалить";
|
||||||
buttonDelete.UseVisualStyleBackColor = true;
|
buttonDelete.UseVisualStyleBackColor = true;
|
||||||
buttonDelete.Click += buttonDelete_Click;
|
buttonDelete.Click += buttonDelete_Click;
|
||||||
//
|
//
|
||||||
// buttonUpdate
|
// buttonUpdate
|
||||||
//
|
//
|
||||||
buttonUpdate.Location = new Point(332, 51);
|
buttonUpdate.Location = new Point(432, 51);
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
buttonUpdate.Size = new Size(140, 30);
|
buttonUpdate.Size = new Size(140, 30);
|
||||||
buttonUpdate.TabIndex = 11;
|
buttonUpdate.TabIndex = 11;
|
||||||
buttonUpdate.Text = "Изменить";
|
buttonUpdate.Text = "Изменить";
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
buttonUpdate.Click += buttonEdit_Click;
|
buttonUpdate.Click += buttonEdit_Click;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
buttonAdd.Location = new Point(332, 15);
|
buttonAdd.Location = new Point(432, 15);
|
||||||
buttonAdd.Name = "buttonAdd";
|
buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(140, 30);
|
buttonAdd.Size = new Size(140, 30);
|
||||||
buttonAdd.TabIndex = 10;
|
buttonAdd.TabIndex = 10;
|
||||||
buttonAdd.Text = "Добавить";
|
buttonAdd.Text = "Добавить";
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
buttonAdd.Click += buttonAdd_Click;
|
buttonAdd.Click += buttonAdd_Click;
|
||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.AllowUserToAddRows = false;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
dataGridView.AllowUserToDeleteRows = false;
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
|
||||||
dataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleLeft;
|
dataGridViewCellStyle1.Alignment = DataGridViewContentAlignment.MiddleLeft;
|
||||||
dataGridViewCellStyle1.BackColor = SystemColors.Control;
|
dataGridViewCellStyle1.BackColor = SystemColors.Control;
|
||||||
dataGridViewCellStyle1.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
dataGridViewCellStyle1.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
dataGridViewCellStyle1.ForeColor = SystemColors.WindowText;
|
dataGridViewCellStyle1.ForeColor = SystemColors.WindowText;
|
||||||
dataGridViewCellStyle1.SelectionBackColor = SystemColors.Highlight;
|
dataGridViewCellStyle1.SelectionBackColor = SystemColors.Highlight;
|
||||||
dataGridViewCellStyle1.SelectionForeColor = SystemColors.HighlightText;
|
dataGridViewCellStyle1.SelectionForeColor = SystemColors.HighlightText;
|
||||||
dataGridViewCellStyle1.WrapMode = DataGridViewTriState.True;
|
dataGridViewCellStyle1.WrapMode = DataGridViewTriState.True;
|
||||||
dataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
|
dataGridView.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridViewCellStyle2.Alignment = DataGridViewContentAlignment.MiddleLeft;
|
dataGridViewCellStyle2.Alignment = DataGridViewContentAlignment.MiddleLeft;
|
||||||
dataGridViewCellStyle2.BackColor = SystemColors.Window;
|
dataGridViewCellStyle2.BackColor = SystemColors.Window;
|
||||||
dataGridViewCellStyle2.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
dataGridViewCellStyle2.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
dataGridViewCellStyle2.ForeColor = SystemColors.ControlText;
|
dataGridViewCellStyle2.ForeColor = SystemColors.ControlText;
|
||||||
dataGridViewCellStyle2.SelectionBackColor = SystemColors.Highlight;
|
dataGridViewCellStyle2.SelectionBackColor = SystemColors.Highlight;
|
||||||
dataGridViewCellStyle2.SelectionForeColor = SystemColors.HighlightText;
|
dataGridViewCellStyle2.SelectionForeColor = SystemColors.HighlightText;
|
||||||
dataGridViewCellStyle2.WrapMode = DataGridViewTriState.False;
|
dataGridViewCellStyle2.WrapMode = DataGridViewTriState.False;
|
||||||
dataGridView.DefaultCellStyle = dataGridViewCellStyle2;
|
dataGridView.DefaultCellStyle = dataGridViewCellStyle2;
|
||||||
dataGridView.Dock = DockStyle.Left;
|
dataGridView.Dock = DockStyle.Left;
|
||||||
dataGridView.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
dataGridView.MultiSelect = false;
|
dataGridView.MultiSelect = false;
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.ReadOnly = true;
|
dataGridView.ReadOnly = true;
|
||||||
dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleLeft;
|
dataGridViewCellStyle3.Alignment = DataGridViewContentAlignment.MiddleLeft;
|
||||||
dataGridViewCellStyle3.BackColor = SystemColors.Control;
|
dataGridViewCellStyle3.BackColor = SystemColors.Control;
|
||||||
dataGridViewCellStyle3.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
dataGridViewCellStyle3.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
dataGridViewCellStyle3.ForeColor = SystemColors.WindowText;
|
dataGridViewCellStyle3.ForeColor = SystemColors.WindowText;
|
||||||
dataGridViewCellStyle3.SelectionBackColor = SystemColors.Highlight;
|
dataGridViewCellStyle3.SelectionBackColor = SystemColors.Highlight;
|
||||||
dataGridViewCellStyle3.SelectionForeColor = SystemColors.HighlightText;
|
dataGridViewCellStyle3.SelectionForeColor = SystemColors.HighlightText;
|
||||||
dataGridViewCellStyle3.WrapMode = DataGridViewTriState.True;
|
dataGridViewCellStyle3.WrapMode = DataGridViewTriState.True;
|
||||||
dataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
|
dataGridView.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
|
||||||
dataGridView.RowHeadersVisible = false;
|
dataGridView.RowHeadersVisible = false;
|
||||||
dataGridView.RowTemplate.Height = 25;
|
dataGridView.RowTemplate.Height = 25;
|
||||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView.Size = new Size(300, 361);
|
dataGridView.Size = new Size(400, 361);
|
||||||
dataGridView.TabIndex = 9;
|
dataGridView.TabIndex = 9;
|
||||||
//
|
//
|
||||||
// FormShops
|
// FormShops
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(484, 361);
|
ClientSize = new Size(584, 361);
|
||||||
Controls.Add(buttonReload);
|
Controls.Add(buttonReload);
|
||||||
Controls.Add(buttonDelete);
|
Controls.Add(buttonDelete);
|
||||||
Controls.Add(buttonUpdate);
|
Controls.Add(buttonUpdate);
|
||||||
Controls.Add(buttonAdd);
|
Controls.Add(buttonAdd);
|
||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Name = "FormShops";
|
Name = "FormShops";
|
||||||
Text = "Магазины";
|
Text = "Магазины";
|
||||||
Load += FormShops_Load;
|
Load += FormShops_Load;
|
||||||
Click += FormShops_Load;
|
Click += FormShops_Load;
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Button buttonReload;
|
private Button buttonReload;
|
||||||
private Button buttonDelete;
|
private Button buttonDelete;
|
||||||
private Button buttonUpdate;
|
private Button buttonUpdate;
|
||||||
private Button buttonAdd;
|
private Button buttonAdd;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,110 +13,110 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace ComputersShop
|
namespace ComputersShop
|
||||||
{
|
{
|
||||||
public partial class FormShops : Form
|
public partial class FormShops : Form
|
||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IShopLogic _logic;
|
private readonly IShopLogic _logic;
|
||||||
|
|
||||||
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormShops_Load(object sender, EventArgs e)
|
private void FormShops_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
var list = _logic.ReadList(null);
|
||||||
|
|
||||||
if (list != null)
|
if (list != null)
|
||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
dataGridView.Columns["Address"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["Address"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
dataGridView.Columns["DateOpen"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["DateOpen"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
dataGridView.Columns["ShopComputers"].Visible = false;
|
dataGridView.Columns["ShopComputers"].Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation("Loading shops");
|
_logger.LogInformation("Loading shops");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error during loading shops");
|
_logger.LogError(ex, "Error during loading shops");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||||
|
|
||||||
if (service is FormShop form)
|
if (service is FormShop form)
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonEdit_Click(object sender, EventArgs e)
|
private void buttonEdit_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||||
|
|
||||||
if (service is FormShop form)
|
if (service is FormShop form)
|
||||||
{
|
{
|
||||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonDelete_Click(object sender, EventArgs e)
|
private void buttonDelete_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
if (MessageBox.Show("Удалить магазин?", "Подтверждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
if (MessageBox.Show("Удалить магазин?", "Подтверждение", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
_logger.LogInformation("Deleting shop");
|
_logger.LogInformation("Deleting shop");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_logic.Delete(new ShopBindingModel { Id = id }))
|
if (!_logic.Delete(new ShopBindingModel { Id = id }))
|
||||||
{
|
{
|
||||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error during deleting shop");
|
_logger.LogError(ex, "Error during deleting shop");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ namespace ComputersShop
|
|||||||
services.AddTransient<FormShop>();
|
services.AddTransient<FormShop>();
|
||||||
services.AddTransient<FormShops>();
|
services.AddTransient<FormShops>();
|
||||||
services.AddTransient<FormShopSupply>();
|
services.AddTransient<FormShopSupply>();
|
||||||
|
services.AddTransient<FormSell>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,11 @@
|
|||||||
using ComputersShopContracts.BindingModels;
|
using ComputersShopContracts.BindingModels;
|
||||||
using ComputersShopContracts.BuisnessLogicsContracts;
|
using ComputersShopContracts.BuisnessLogicsContracts;
|
||||||
|
using ComputersShopContracts.BusinessLogicsContracts;
|
||||||
using ComputersShopContracts.SearchModels;
|
using ComputersShopContracts.SearchModels;
|
||||||
using ComputersShopContracts.StoragesContracts;
|
using ComputersShopContracts.StoragesContracts;
|
||||||
using ComputersShopContracts.ViewModels;
|
using ComputersShopContracts.ViewModels;
|
||||||
using ComputersShopDataModels.Enums;
|
using ComputersShopDataModels.Enums;
|
||||||
|
using ComputersShopDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -17,10 +19,18 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly IOrderStorage _orderStorage;
|
private readonly IOrderStorage _orderStorage;
|
||||||
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage)
|
private readonly IShopStorage _shopStorage;
|
||||||
|
private readonly IShopLogic _shopLogic;
|
||||||
|
private readonly IComputerStorage _computerStorage;
|
||||||
|
|
||||||
|
public OrderLogic(ILogger<OrderLogic> logger, IOrderStorage orderStorage,
|
||||||
|
IShopStorage shopStorage, IShopLogic shopLogic, IComputerStorage computerStorage)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_orderStorage = orderStorage;
|
_orderStorage = orderStorage;
|
||||||
|
_shopStorage = shopStorage;
|
||||||
|
_shopLogic = shopLogic;
|
||||||
|
_computerStorage = computerStorage;
|
||||||
}
|
}
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
@ -63,25 +73,26 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newStatus == OrderStatus.Готов)
|
||||||
|
{
|
||||||
|
var computer = _computerStorage.GetElement(new ComputerSearchModel() { Id = model.ComputerId });
|
||||||
|
if (computer == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Status change error. Dress not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!CheckSupply(computer, model.Count))
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Status change error. Shop doesnt have dresses");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
model.Status = newStatus;
|
model.Status = newStatus;
|
||||||
model.ComputerId = viewModel.ComputerId;
|
if (model.Status == OrderStatus.Выдан)
|
||||||
model.Count = viewModel.Count;
|
|
||||||
model.Sum = viewModel.Sum;
|
|
||||||
model.DateCreate = viewModel.DateCreate;
|
|
||||||
if (model.Status == OrderStatus.Готов)
|
|
||||||
{
|
{
|
||||||
model.DateImplement = DateTime.Now;
|
model.DateImplement = DateTime.Now;
|
||||||
}
|
}
|
||||||
else
|
_orderStorage.Update(model);
|
||||||
{
|
|
||||||
model.DateImplement = viewModel.DateImplement;
|
|
||||||
}
|
|
||||||
CheckModel(model, false);
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Status change operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
public bool TakeOrderInWork(OrderBindingModel model)
|
public bool TakeOrderInWork(OrderBindingModel model)
|
||||||
@ -120,5 +131,64 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
_logger.LogInformation("Order. Id:{Id}. Sum:{Sum}. ComputerId:{ComputerId}", model.Id, model.Sum, model.ComputerId);
|
_logger.LogInformation("Order. Id:{Id}. Sum:{Sum}. ComputerId:{ComputerId}", model.Id, model.Sum, model.ComputerId);
|
||||||
}
|
}
|
||||||
|
public bool CheckSupply(IComputerModel computer, int count)
|
||||||
|
{
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Check supply operation error. Dress count < 0");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int sumCapacity = _shopStorage.GetFullList().Select(x => x.MaxCount).Sum();
|
||||||
|
int sumCount = _shopStorage.GetFullList().Select(x => x.ShopComputers.Select(y => y.Value.Item2).Sum()).Sum();
|
||||||
|
int free = sumCapacity - sumCount;
|
||||||
|
|
||||||
|
if (free < count)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Check supply error. No place for new Computers");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach (var shop in _shopStorage.GetFullList())
|
||||||
|
{
|
||||||
|
free = shop.MaxCount;
|
||||||
|
foreach (var comp in shop.ShopComputers)
|
||||||
|
{
|
||||||
|
free -= comp.Value.Item2;
|
||||||
|
}
|
||||||
|
if (free == 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (free >= count)
|
||||||
|
{
|
||||||
|
if (_shopLogic.SupplyComputers(new()
|
||||||
|
{
|
||||||
|
Id = shop.Id
|
||||||
|
}, computer, count))
|
||||||
|
{
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Supply error");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_shopLogic.SupplyComputers(new() { Id = shop.Id }, computer, free))
|
||||||
|
count -= free;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Supply error");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (count <= 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,6 +114,10 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
|||||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public bool MakeSell(IComputerModel model, int count)
|
||||||
|
{
|
||||||
|
return _shopStorage.SellComputers(model, count);
|
||||||
|
}
|
||||||
|
|
||||||
public bool SupplyComputers(ShopSearchModel model, IComputerModel computer, int count)
|
public bool SupplyComputers(ShopSearchModel model, IComputerModel computer, int count)
|
||||||
{
|
{
|
||||||
@ -137,6 +141,13 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
_logger.LogInformation("Make Supply. Id: {Id}. ShopName: {Name}", model.Id, model.Name);
|
_logger.LogInformation("Make Supply. Id: {Id}. ShopName: {Name}", model.Id, model.Name);
|
||||||
|
|
||||||
|
var countItems = currentShop.ShopComputers.Select(x => x.Value.Item2).Sum();
|
||||||
|
if (currentShop.MaxCount - countItems < count)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Shop is full");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (currentShop.ShopComputers.TryGetValue(computer.Id, out var pair))
|
if (currentShop.ShopComputers.TryGetValue(computer.Id, out var pair))
|
||||||
{
|
{
|
||||||
currentShop.ShopComputers[computer.Id] = (pair.Item1, pair.Item2 + count);
|
currentShop.ShopComputers[computer.Id] = (pair.Item1, pair.Item2 + count);
|
||||||
@ -154,6 +165,7 @@ namespace ComputersShopBusinessLogic.BusinessLogics
|
|||||||
ShopName = currentShop.ShopName,
|
ShopName = currentShop.ShopName,
|
||||||
DateOpen = currentShop.DateOpen,
|
DateOpen = currentShop.DateOpen,
|
||||||
Address = currentShop.Address,
|
Address = currentShop.Address,
|
||||||
|
MaxCount = currentShop.MaxCount,
|
||||||
ShopComputers = currentShop.ShopComputers,
|
ShopComputers = currentShop.ShopComputers,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ namespace ComputersShopContracts.BindingModels
|
|||||||
public string ShopName { get; set; }
|
public string ShopName { get; set; }
|
||||||
public string Address { get; set; }
|
public string Address { get; set; }
|
||||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||||
|
public int MaxCount { get; set; }
|
||||||
public Dictionary<int, (IComputerModel, int)> ShopComputers{ get; set; } = new();
|
public Dictionary<int, (IComputerModel, int)> ShopComputers{ get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,5 +18,6 @@ namespace ComputersShopContracts.BusinessLogicsContracts
|
|||||||
bool Update(ShopBindingModel model);
|
bool Update(ShopBindingModel model);
|
||||||
bool Delete(ShopBindingModel model);
|
bool Delete(ShopBindingModel model);
|
||||||
bool SupplyComputers(ShopSearchModel model, IComputerModel computer, int count);
|
bool SupplyComputers(ShopSearchModel model, IComputerModel computer, int count);
|
||||||
}
|
bool MakeSell(IComputerModel model, int count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using ComputersShopContracts.BindingModels;
|
using ComputersShopContracts.BindingModels;
|
||||||
using ComputersShopContracts.SearchModels;
|
using ComputersShopContracts.SearchModels;
|
||||||
using ComputersShopContracts.ViewModels;
|
using ComputersShopContracts.ViewModels;
|
||||||
|
using ComputersShopDataModels.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -17,5 +18,6 @@ namespace ComputersShopContracts.StoragesContracts
|
|||||||
ShopViewModel? Insert(ShopBindingModel model);
|
ShopViewModel? Insert(ShopBindingModel model);
|
||||||
ShopViewModel? Update(ShopBindingModel model);
|
ShopViewModel? Update(ShopBindingModel model);
|
||||||
ShopViewModel? Delete(ShopBindingModel model);
|
ShopViewModel? Delete(ShopBindingModel model);
|
||||||
}
|
bool SellComputers(IComputerModel model, int count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,9 @@ namespace ComputersShopContracts.ViewModels
|
|||||||
public string Address { get; set; } = string.Empty;
|
public string Address { get; set; } = string.Empty;
|
||||||
[DisplayName("Дата открытия")]
|
[DisplayName("Дата открытия")]
|
||||||
public DateTime DateOpen { get; set; } = DateTime.Now;
|
public DateTime DateOpen { get; set; } = DateTime.Now;
|
||||||
|
[DisplayName("Макс кол-во компьютеров")]
|
||||||
|
public int MaxCount { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, (IComputerModel, int)> ShopComputers { get; set; } = new();
|
public Dictionary<int, (IComputerModel, int)> ShopComputers { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,5 +11,6 @@ namespace ComputersShopDataModels.Models
|
|||||||
string ShopName { get; }
|
string ShopName { get; }
|
||||||
string Address { get; }
|
string Address { get; }
|
||||||
DateTime DateOpen { get; }
|
DateTime DateOpen { get; }
|
||||||
|
int MaxCount { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using ComputersShopContracts.SearchModels;
|
using ComputersShopContracts.SearchModels;
|
||||||
using ComputersShopContracts.StoragesContracts;
|
using ComputersShopContracts.StoragesContracts;
|
||||||
using ComputersShopContracts.ViewModels;
|
using ComputersShopContracts.ViewModels;
|
||||||
|
using ComputersShopDataModels.Models;
|
||||||
using ComputersShopListImplement.Models;
|
using ComputersShopListImplement.Models;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -102,5 +103,13 @@ namespace ComputersShopListImplement.Implements
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
public bool CheckAvailability(int computerId, int count)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public bool SellComputers(IComputerModel model, int count)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ namespace ComputersShopListImplement.Models
|
|||||||
public string ShopName { get; private set; }
|
public string ShopName { get; private set; }
|
||||||
public string Address { get; private set; }
|
public string Address { get; private set; }
|
||||||
public DateTime DateOpen { get; private set; }
|
public DateTime DateOpen { get; private set; }
|
||||||
|
public int MaxCount { get; private set; }
|
||||||
public Dictionary<int, (IComputerModel, int)> ShopComputers { get; private set; } = new();
|
public Dictionary<int, (IComputerModel, int)> ShopComputers { get; private set; } = new();
|
||||||
|
|
||||||
public static Shop? Create(ShopBindingModel model)
|
public static Shop? Create(ShopBindingModel model)
|
||||||
@ -29,6 +30,7 @@ namespace ComputersShopListImplement.Models
|
|||||||
ShopName = model.ShopName,
|
ShopName = model.ShopName,
|
||||||
Address = model.Address,
|
Address = model.Address,
|
||||||
DateOpen = model.DateOpen,
|
DateOpen = model.DateOpen,
|
||||||
|
MaxCount = model.MaxCount,
|
||||||
ShopComputers = new()
|
ShopComputers = new()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -41,6 +43,7 @@ namespace ComputersShopListImplement.Models
|
|||||||
ShopName = model.ShopName;
|
ShopName = model.ShopName;
|
||||||
Address = model.Address;
|
Address = model.Address;
|
||||||
DateOpen = model.DateOpen;
|
DateOpen = model.DateOpen;
|
||||||
|
MaxCount = model.MaxCount;
|
||||||
ShopComputers = model.ShopComputers;
|
ShopComputers = model.ShopComputers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +53,8 @@ namespace ComputersShopListImplement.Models
|
|||||||
ShopName = ShopName,
|
ShopName = ShopName,
|
||||||
Address = Address,
|
Address = Address,
|
||||||
DateOpen = DateOpen,
|
DateOpen = DateOpen,
|
||||||
ShopComputers = ShopComputers
|
MaxCount = MaxCount,
|
||||||
|
ShopComputers = ShopComputers
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user