merge
This commit is contained in:
commit
5aeb4bbc37
@ -14,11 +14,13 @@ namespace BlacksmithWorkshopListImplement
|
||||
public List<Component> Components { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Manufacture> Manufactures { get; set; }
|
||||
public List<Shop> Shops { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Manufactures = new List<Manufacture>();
|
||||
Shops = new List<Shop>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
|
@ -0,0 +1,107 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StorageContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopListImplement.Models;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public ShopStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.ShopName.Contains(model.ShopName ?? string.Empty))
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.ShopName) &&
|
||||
shop.ShopName == model.ShopName) ||
|
||||
(model.Id.HasValue && shop.Id == model.Id))
|
||||
{
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (model.Id <= shop.Id)
|
||||
{
|
||||
model.Id = shop.Id + 1;
|
||||
}
|
||||
}
|
||||
var newShop = Shop.Create(model);
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Shops.Add(newShop);
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.Id == model.Id)
|
||||
{
|
||||
shop.Update(model);
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||
{
|
||||
if (_source.Shops[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Shops[i];
|
||||
_source.Shops.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
58
BlacksmithWorkshop/BlacksmithListImplement/Models/Shop.cs
Normal file
58
BlacksmithWorkshop/BlacksmithListImplement/Models/Shop.cs
Normal file
@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopListImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ShopName { get; private set; } = string.Empty;
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
public DateTime DateOpening { get; private set; }
|
||||
public Dictionary<int, (IManufactureModel, int)> ListManufacture
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = new();
|
||||
public static Shop? Create(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpening = model.DateOpening,
|
||||
ListManufacture = new()
|
||||
};
|
||||
}
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpening = model.DateOpening;
|
||||
ListManufacture = model.ListManufacture;
|
||||
}
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
ListManufacture = ListManufacture,
|
||||
DateOpening = DateOpening,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.StorageContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class ShopLogic : IShopLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopStorage _shopStorage;
|
||||
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_shopStorage = shopStorage;
|
||||
}
|
||||
public List<ShopViewModel>? ReadList(ShopSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ShopName: {ShopName}. Id: {Id}", model?.ShopName, model?.Id);
|
||||
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public ShopViewModel? ReadElement(ShopSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. ShopName: {ShopName}. Id: {Id}", model.ShopName, model.Id);
|
||||
var element = _shopStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id: {Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
public bool Create(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_shopStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Update(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_shopStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||
if (_shopStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName));
|
||||
}
|
||||
_logger.LogInformation("Shop. ShopName:{0}. Address:{1}. Id:{2}", model.ShopName, model.Address, model.Id);
|
||||
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
ShopName = model.ShopName
|
||||
});
|
||||
if (element != null && element.Id != model.Id && element.ShopName == model.ShopName)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
public bool AddManufactureInShop(ShopSearchModel model, IManufactureModel manufacture, int count)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (count <= 0)
|
||||
{
|
||||
throw new ArgumentException("Количество изделий должно быть больше 0", nameof(count));
|
||||
}
|
||||
_logger.LogInformation("AddManufactureInShop. ShopName:{ShopName}. Id:{Id}", model.ShopName, model.Id);
|
||||
var element = _shopStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("AddManufactureInShop element not found");
|
||||
return false;
|
||||
}
|
||||
_logger.LogInformation("AddManufactureInShop find. Id:{Id}", element.Id);
|
||||
|
||||
if (element.ListManufacture.TryGetValue(manufacture.Id, out var pair))
|
||||
{
|
||||
element.ListManufacture[manufacture.Id] = (manufacture, count + pair.Item2);
|
||||
_logger.LogInformation("AddManufactureInShop. Added {count} {manufacture} to '{ShopName}' shop",
|
||||
count, manufacture.ManufactureName, element.ShopName);
|
||||
}
|
||||
else
|
||||
{
|
||||
element.ListManufacture[manufacture.Id] = (manufacture, count);
|
||||
_logger.LogInformation("AddManufactureInShop. Added {count} new manufacture {manufacture} to '{ShopName}' shop",
|
||||
count, manufacture.ManufactureName, element.ShopName);
|
||||
}
|
||||
_shopStorage.Update(new()
|
||||
{
|
||||
Id = element.Id,
|
||||
Address = element.Address,
|
||||
ShopName = element.ShopName,
|
||||
DateOpening = element.DateOpening,
|
||||
ListManufacture = element.ListManufacture
|
||||
});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BindingModels
|
||||
{
|
||||
public class ShopBindingModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
public string Address { get; set; } = string.Empty;
|
||||
public DateTime DateOpening { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, (IManufactureModel, int)> ListManufacture
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IShopLogic
|
||||
{
|
||||
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||
bool Create(ShopBindingModel model);
|
||||
bool Update(ShopBindingModel model);
|
||||
bool Delete(ShopBindingModel model);
|
||||
bool AddManufactureInShop(ShopSearchModel model, IManufactureModel manufacture, int count);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? ShopName { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.StorageContracts
|
||||
{
|
||||
public interface IShopStorage
|
||||
{
|
||||
List<ShopViewModel> GetFullList();
|
||||
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||
ShopViewModel? GetElement(ShopSearchModel model);
|
||||
ShopViewModel? Insert(ShopBindingModel model);
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название магазина")]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Адрес магазина")]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpening { get; set; } = DateTime.Now;
|
||||
|
||||
public Dictionary<int, (IManufactureModel, int)> ListManufacture
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BlacksmithWorkshopDataModels.Models
|
||||
{
|
||||
public class IShopModel
|
||||
{
|
||||
string ShopName { get; }
|
||||
string Address { get; }
|
||||
DateTime DateOpening { get; }
|
||||
Dictionary<int, (IManufactureModel, int)> ListManufacture { get; }
|
||||
}
|
||||
}
|
@ -32,12 +32,14 @@
|
||||
this.guideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.goodsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ShopsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.buttonCreateOrder = new System.Windows.Forms.Button();
|
||||
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
|
||||
this.buttonOrderReady = new System.Windows.Forms.Button();
|
||||
this.buttonIssuedOrder = new System.Windows.Forms.Button();
|
||||
this.buttonRef = new System.Windows.Forms.Button();
|
||||
this.buttonAddManufactureInShop = new System.Windows.Forms.Button();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
@ -58,7 +60,8 @@
|
||||
//
|
||||
this.guideToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.componentsToolStripMenuItem,
|
||||
this.goodsToolStripMenuItem});
|
||||
this.goodsToolStripMenuItem,
|
||||
this.ShopsToolStripMenuItem});
|
||||
this.guideToolStripMenuItem.Name = "guideToolStripMenuItem";
|
||||
this.guideToolStripMenuItem.Size = new System.Drawing.Size(87, 20);
|
||||
this.guideToolStripMenuItem.Text = "Справочник";
|
||||
@ -66,17 +69,24 @@
|
||||
// componentsToolStripMenuItem
|
||||
//
|
||||
this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
|
||||
this.componentsToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
||||
this.componentsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.componentsToolStripMenuItem.Text = "Компоненты";
|
||||
this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
||||
//
|
||||
// goodsToolStripMenuItem
|
||||
//
|
||||
this.goodsToolStripMenuItem.Name = "goodsToolStripMenuItem";
|
||||
this.goodsToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
||||
this.goodsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.goodsToolStripMenuItem.Text = "Изделия";
|
||||
this.goodsToolStripMenuItem.Click += new System.EventHandler(this.GoodsToolStripMenuItem_Click);
|
||||
//
|
||||
// ShopsToolStripMenuItem
|
||||
//
|
||||
this.ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem";
|
||||
this.ShopsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.ShopsToolStripMenuItem.Text = "Магазины";
|
||||
this.ShopsToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
@ -146,11 +156,22 @@
|
||||
this.buttonRef.UseVisualStyleBackColor = true;
|
||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// buttonAddManufactureInShop
|
||||
//
|
||||
this.buttonAddManufactureInShop.Location = new System.Drawing.Point(898, 249);
|
||||
this.buttonAddManufactureInShop.Name = "buttonAddManufactureInShop";
|
||||
this.buttonAddManufactureInShop.Size = new System.Drawing.Size(216, 22);
|
||||
this.buttonAddManufactureInShop.TabIndex = 7;
|
||||
this.buttonAddManufactureInShop.Text = "Пополнение магазина";
|
||||
this.buttonAddManufactureInShop.UseVisualStyleBackColor = true;
|
||||
this.buttonAddManufactureInShop.Click += new System.EventHandler(this.buttonAddManufactureInShop_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1149, 319);
|
||||
this.Controls.Add(this.buttonAddManufactureInShop);
|
||||
this.Controls.Add(this.buttonRef);
|
||||
this.Controls.Add(this.buttonIssuedOrder);
|
||||
this.Controls.Add(this.buttonOrderReady);
|
||||
@ -183,5 +204,7 @@
|
||||
private Button buttonOrderReady;
|
||||
private Button buttonIssuedOrder;
|
||||
private Button buttonRef;
|
||||
private ToolStripMenuItem ShopsToolStripMenuItem;
|
||||
private Button buttonAddManufactureInShop;
|
||||
}
|
||||
}
|
@ -174,5 +174,21 @@ namespace BlacksmithWorkshopView
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void buttonAddManufactureInShop_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShopManufacture));
|
||||
if (service is FormShopManufacture form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
|
||||
if (service is FormShops form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
204
BlacksmithWorkshop/BlacksmithWorkshopView/FormShop.Designer.cs
generated
Normal file
204
BlacksmithWorkshop/BlacksmithWorkshopView/FormShop.Designer.cs
generated
Normal file
@ -0,0 +1,204 @@
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
partial class FormShop
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
||||
this.labelTime = new System.Windows.Forms.Label();
|
||||
this.labelAddress = new System.Windows.Forms.Label();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ColumnID = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnManufactureName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.labelShop = new System.Windows.Forms.Label();
|
||||
this.textBoxShop = new System.Windows.Forms.TextBox();
|
||||
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonSave.Location = new System.Drawing.Point(521, 503);
|
||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(171, 37);
|
||||
this.buttonSave.TabIndex = 17;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonCancel.Location = new System.Drawing.Point(700, 503);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(147, 38);
|
||||
this.buttonCancel.TabIndex = 16;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// textBoxAddress
|
||||
//
|
||||
this.textBoxAddress.Location = new System.Drawing.Point(227, 45);
|
||||
this.textBoxAddress.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.textBoxAddress.Name = "textBoxAddress";
|
||||
this.textBoxAddress.Size = new System.Drawing.Size(314, 31);
|
||||
this.textBoxAddress.TabIndex = 14;
|
||||
//
|
||||
// labelTime
|
||||
//
|
||||
this.labelTime.AutoSize = true;
|
||||
this.labelTime.Location = new System.Drawing.Point(551, 15);
|
||||
this.labelTime.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelTime.Name = "labelTime";
|
||||
this.labelTime.Size = new System.Drawing.Size(131, 25);
|
||||
this.labelTime.TabIndex = 13;
|
||||
this.labelTime.Text = "Дата открытия";
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
this.labelAddress.AutoSize = true;
|
||||
this.labelAddress.Location = new System.Drawing.Point(227, 15);
|
||||
this.labelAddress.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelAddress.Name = "labelAddress";
|
||||
this.labelAddress.Size = new System.Drawing.Size(62, 25);
|
||||
this.labelAddress.TabIndex = 12;
|
||||
this.labelAddress.Text = "Адрес";
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.ColumnID,
|
||||
this.ColumnManufactureName,
|
||||
this.ColumnCount});
|
||||
this.dataGridView.Location = new System.Drawing.Point(17, 93);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 62;
|
||||
this.dataGridView.RowTemplate.Height = 25;
|
||||
this.dataGridView.Size = new System.Drawing.Size(830, 400);
|
||||
this.dataGridView.TabIndex = 11;
|
||||
//
|
||||
// ColumnID
|
||||
//
|
||||
this.ColumnID.HeaderText = "ID";
|
||||
this.ColumnID.MinimumWidth = 8;
|
||||
this.ColumnID.Name = "ColumnID";
|
||||
this.ColumnID.Visible = false;
|
||||
this.ColumnID.Width = 150;
|
||||
//
|
||||
// ColumnManufactureName
|
||||
//
|
||||
this.ColumnManufactureName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.ColumnManufactureName.HeaderText = "Поездка";
|
||||
this.ColumnManufactureName.MinimumWidth = 8;
|
||||
this.ColumnManufactureName.Name = "ColumnManufactureName";
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
this.ColumnCount.HeaderText = "Количество";
|
||||
this.ColumnCount.MinimumWidth = 8;
|
||||
this.ColumnCount.Name = "ColumnCount";
|
||||
this.ColumnCount.Width = 150;
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
this.labelShop.AutoSize = true;
|
||||
this.labelShop.Location = new System.Drawing.Point(17, 15);
|
||||
this.labelShop.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.labelShop.Name = "labelShop";
|
||||
this.labelShop.Size = new System.Drawing.Size(81, 25);
|
||||
this.labelShop.TabIndex = 9;
|
||||
this.labelShop.Text = "Магазин";
|
||||
//
|
||||
// textBoxShop
|
||||
//
|
||||
this.textBoxShop.Location = new System.Drawing.Point(17, 45);
|
||||
this.textBoxShop.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.textBoxShop.Name = "textBoxShop";
|
||||
this.textBoxShop.Size = new System.Drawing.Size(200, 31);
|
||||
this.textBoxShop.TabIndex = 18;
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
this.dateTimePicker.Location = new System.Drawing.Point(551, 45);
|
||||
this.dateTimePicker.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.dateTimePicker.Name = "dateTimePicker";
|
||||
this.dateTimePicker.Size = new System.Drawing.Size(294, 31);
|
||||
this.dateTimePicker.TabIndex = 19;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(864, 562);
|
||||
this.Controls.Add(this.dateTimePicker);
|
||||
this.Controls.Add(this.textBoxShop);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.textBoxAddress);
|
||||
this.Controls.Add(this.labelTime);
|
||||
this.Controls.Add(this.labelAddress);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.labelShop);
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.Name = "FormShop";
|
||||
this.Text = "Магазин";
|
||||
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||
this.Click += new System.EventHandler(this.FormShop_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private TextBox textBoxAddress;
|
||||
private Label labelTime;
|
||||
private Label labelAddress;
|
||||
private DataGridView dataGridView;
|
||||
private Label labelShop;
|
||||
private TextBox textBoxShop;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private DataGridViewTextBoxColumn ColumnID;
|
||||
private DataGridViewTextBoxColumn ColumnManufactureName;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
}
|
||||
}
|
125
BlacksmithWorkshop/BlacksmithWorkshopView/FormShop.cs
Normal file
125
BlacksmithWorkshop/BlacksmithWorkshopView/FormShop.cs
Normal file
@ -0,0 +1,125 @@
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.SearchModels;
|
||||
using BlacksmithWorkshopDataModels.Models;
|
||||
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
public partial class FormShop : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
private int? _id;
|
||||
private Dictionary<int, (IManufactureModel, int)> _shopListManufacture;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_shopListManufacture = new();
|
||||
}
|
||||
private void FormShop_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазина");
|
||||
try
|
||||
{
|
||||
var view = _logic.ReadElement(new ShopSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxShop.Text = view.ShopName;
|
||||
textBoxAddress.Text = view.Address;
|
||||
dateTimePicker.Text = view.DateOpening.ToString();
|
||||
_shopListManufacture = view.ListManufacture ?? new Dictionary<int, (IManufactureModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазина");
|
||||
try
|
||||
{
|
||||
if (_shopListManufacture != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var elem in _shopListManufacture)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { elem.Key, elem.Value.Item1.ManufactureName, elem.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxShop.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
try
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxShop.Text,
|
||||
Address = textBoxAddress.Text,
|
||||
DateOpening = dateTimePicker.Value.Date
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
BlacksmithWorkshop/BlacksmithWorkshopView/FormShop.resx
Normal file
120
BlacksmithWorkshop/BlacksmithWorkshopView/FormShop.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
151
BlacksmithWorkshop/BlacksmithWorkshopView/FormShopManufacture.Designer.cs
generated
Normal file
151
BlacksmithWorkshop/BlacksmithWorkshopView/FormShopManufacture.Designer.cs
generated
Normal file
@ -0,0 +1,151 @@
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
partial class FormShopManufacture
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.numericUpDownCount = new System.Windows.Forms.NumericUpDown();
|
||||
this.comboBoxManufacture = new System.Windows.Forms.ComboBox();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.labelManufacture = new System.Windows.Forms.Label();
|
||||
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
||||
this.labelShop = new System.Windows.Forms.Label();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// numericUpDownCount
|
||||
//
|
||||
this.numericUpDownCount.Location = new System.Drawing.Point(87, 62);
|
||||
this.numericUpDownCount.Maximum = new decimal(new int[] {
|
||||
1410065408,
|
||||
2,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownCount.Name = "numericUpDownCount";
|
||||
this.numericUpDownCount.Size = new System.Drawing.Size(344, 23);
|
||||
this.numericUpDownCount.TabIndex = 13;
|
||||
//
|
||||
// comboBoxManufacture
|
||||
//
|
||||
this.comboBoxManufacture.FormattingEnabled = true;
|
||||
this.comboBoxManufacture.Location = new System.Drawing.Point(86, 35);
|
||||
this.comboBoxManufacture.Name = "comboBoxManufacture";
|
||||
this.comboBoxManufacture.Size = new System.Drawing.Size(345, 23);
|
||||
this.comboBoxManufacture.TabIndex = 12;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(9, 64);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(72, 15);
|
||||
this.labelCount.TabIndex = 11;
|
||||
this.labelCount.Text = "Количество";
|
||||
//
|
||||
// labelManufacture
|
||||
//
|
||||
this.labelManufacture.AutoSize = true;
|
||||
this.labelManufacture.Location = new System.Drawing.Point(29, 38);
|
||||
this.labelManufacture.Name = "labelManufacture";
|
||||
this.labelManufacture.Size = new System.Drawing.Size(53, 15);
|
||||
this.labelManufacture.TabIndex = 10;
|
||||
this.labelManufacture.Text = "Изделие";
|
||||
//
|
||||
// comboBoxShop
|
||||
//
|
||||
this.comboBoxShop.FormattingEnabled = true;
|
||||
this.comboBoxShop.Location = new System.Drawing.Point(86, 8);
|
||||
this.comboBoxShop.Name = "comboBoxShop";
|
||||
this.comboBoxShop.Size = new System.Drawing.Size(345, 23);
|
||||
this.comboBoxShop.TabIndex = 9;
|
||||
//
|
||||
// labelShop
|
||||
//
|
||||
this.labelShop.AutoSize = true;
|
||||
this.labelShop.Location = new System.Drawing.Point(26, 11);
|
||||
this.labelShop.Name = "labelShop";
|
||||
this.labelShop.Size = new System.Drawing.Size(54, 15);
|
||||
this.labelShop.TabIndex = 8;
|
||||
this.labelShop.Text = "Магазин";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonCancel.Location = new System.Drawing.Point(356, 94);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 15;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonSave.Location = new System.Drawing.Point(275, 94);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonSave.TabIndex = 14;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// FormShopManufacture
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(443, 129);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.numericUpDownCount);
|
||||
this.Controls.Add(this.comboBoxManufacture);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.labelManufacture);
|
||||
this.Controls.Add(this.comboBoxShop);
|
||||
this.Controls.Add(this.labelShop);
|
||||
this.Name = "FormShopManufacture";
|
||||
this.Text = "Добавление изделия в магазин";
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private NumericUpDown numericUpDownCount;
|
||||
private ComboBox comboBoxManufacture;
|
||||
private Label labelCount;
|
||||
private Label labelManufacture;
|
||||
private ComboBox comboBoxShop;
|
||||
private Label labelShop;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
}
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.ViewModels;
|
||||
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
public partial class FormShopManufacture : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _shopLogic;
|
||||
private readonly IManufactureLogic _manufactureLogic;
|
||||
private readonly List<ShopViewModel>? _listShops;
|
||||
private readonly List<ManufactureViewModel>? _listManufacture;
|
||||
public FormShopManufacture(ILogger<FormShopManufacture> logger, IShopLogic shopLogic, IManufactureLogic manufactureLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_shopLogic = shopLogic;
|
||||
_manufactureLogic = manufactureLogic;
|
||||
_logger = logger;
|
||||
_listShops = shopLogic.ReadList(null);
|
||||
if (_listShops != null)
|
||||
{
|
||||
comboBoxShop.DisplayMember = "ShopName";
|
||||
comboBoxShop.ValueMember = "Id";
|
||||
comboBoxShop.DataSource = _listShops;
|
||||
comboBoxShop.SelectedItem = null;
|
||||
}
|
||||
|
||||
_listManufacture = manufactureLogic.ReadList(null);
|
||||
if (_listManufacture != null)
|
||||
{
|
||||
comboBoxManufacture.DisplayMember = "ManufactureName";
|
||||
comboBoxManufacture.ValueMember = "Id";
|
||||
comboBoxManufacture.DataSource = _listManufacture;
|
||||
comboBoxManufacture.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (comboBoxShop.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxManufacture.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Добавление изделия в магазин");
|
||||
try
|
||||
{
|
||||
var manufacture = _manufactureLogic.ReadElement(new()
|
||||
{
|
||||
Id = (int)comboBoxManufacture.SelectedValue
|
||||
});
|
||||
if (manufacture == null)
|
||||
{
|
||||
throw new Exception("Изделие не найдено. Дополнительная информация в логах.");
|
||||
}
|
||||
var resultOperation = _shopLogic.AddManufactureInShop(
|
||||
model: new() { Id = (int)comboBoxShop.SelectedValue },
|
||||
manufacture: manufacture,
|
||||
count: (int)numericUpDownCount.Value
|
||||
);
|
||||
if (!resultOperation)
|
||||
{
|
||||
throw new Exception("Ошибка при добавлении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения поездки");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
121
BlacksmithWorkshop/BlacksmithWorkshopView/FormShops.Designer.cs
generated
Normal file
121
BlacksmithWorkshop/BlacksmithWorkshopView/FormShops.Designer.cs
generated
Normal file
@ -0,0 +1,121 @@
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
partial class FormShops
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.buttonUpd = new System.Windows.Forms.Button();
|
||||
this.buttonDel = new System.Windows.Forms.Button();
|
||||
this.buttonRef = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 62;
|
||||
this.dataGridView.RowTemplate.Height = 33;
|
||||
this.dataGridView.Size = new System.Drawing.Size(433, 269);
|
||||
this.dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(456, 7);
|
||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(84, 30);
|
||||
this.buttonAdd.TabIndex = 2;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
this.buttonUpd.Location = new System.Drawing.Point(456, 47);
|
||||
this.buttonUpd.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.buttonUpd.Name = "buttonUpd";
|
||||
this.buttonUpd.Size = new System.Drawing.Size(84, 30);
|
||||
this.buttonUpd.TabIndex = 3;
|
||||
this.buttonUpd.Text = "Изменить";
|
||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
this.buttonDel.Location = new System.Drawing.Point(456, 88);
|
||||
this.buttonDel.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.buttonDel.Name = "buttonDel";
|
||||
this.buttonDel.Size = new System.Drawing.Size(84, 30);
|
||||
this.buttonDel.TabIndex = 4;
|
||||
this.buttonDel.Text = "Удалить";
|
||||
this.buttonDel.UseVisualStyleBackColor = true;
|
||||
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
this.buttonRef.Location = new System.Drawing.Point(456, 128);
|
||||
this.buttonRef.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.buttonRef.Name = "buttonRef";
|
||||
this.buttonRef.Size = new System.Drawing.Size(84, 30);
|
||||
this.buttonRef.TabIndex = 5;
|
||||
this.buttonRef.Text = "Обновить";
|
||||
this.buttonRef.UseVisualStyleBackColor = true;
|
||||
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// FormShops
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(560, 270);
|
||||
this.Controls.Add(this.buttonRef);
|
||||
this.Controls.Add(this.buttonDel);
|
||||
this.Controls.Add(this.buttonUpd);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
|
||||
this.Name = "FormShops";
|
||||
this.Text = "Магазины";
|
||||
this.Load += new System.EventHandler(this.FormShops_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonAdd;
|
||||
private Button buttonUpd;
|
||||
private Button buttonDel;
|
||||
private Button buttonRef;
|
||||
}
|
||||
}
|
108
BlacksmithWorkshop/BlacksmithWorkshopView/FormShops.cs
Normal file
108
BlacksmithWorkshop/BlacksmithWorkshopView/FormShops.cs
Normal file
@ -0,0 +1,108 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace BlacksmithWorkshopView
|
||||
{
|
||||
public partial class FormShops : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
public FormShops(ILogger<FormShops> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
private void FormShops_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ListManufacture"].Visible = false;
|
||||
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
if (service is FormShop form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||
if (service is FormShop form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление магазина");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ShopBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
BlacksmithWorkshop/BlacksmithWorkshopView/FormShops.resx
Normal file
120
BlacksmithWorkshop/BlacksmithWorkshopView/FormShops.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1,5 +1,6 @@
|
||||
using BlacksmithWorkshopBusinessLogic.BusinessLogics;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopContracts.StorageContracts;
|
||||
using BlacksmithWorkshopContracts.StoragesContracts;
|
||||
using BlacksmithWorkshopFileImplement.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -40,6 +41,8 @@ namespace BlacksmithWorkshopView
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IManufactureLogic, ManufactureLogic>();
|
||||
services.AddTransient<IShopLogic, ShopLogic>();
|
||||
services.AddTransient<IShopStorage, ShopStorage>();
|
||||
services.AddTransient<FormMain>();
|
||||
services.AddTransient<FormComponent>();
|
||||
services.AddTransient<FormComponents>();
|
||||
@ -47,6 +50,9 @@ namespace BlacksmithWorkshopView
|
||||
services.AddTransient<FormManufacture>();
|
||||
services.AddTransient<FormManufactureComponent>();
|
||||
services.AddTransient<FormManufacturies>();
|
||||
services.AddTransient<FormShopManufacture>();
|
||||
services.AddTransient<FormShops>();
|
||||
services.AddTransient<FormShop>();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user