1 hard laba had finished

This commit is contained in:
Алина 2024-04-10 22:03:41 +04:00
parent c983359831
commit 4eed09cfff
23 changed files with 1888 additions and 261 deletions

View File

@ -0,0 +1,164 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.SearchModels;
using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels;
namespace TypographyBusinessLogic.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;
}
public bool SupplyPrinteds(ShopSearchModel shop, PrintedBindingModel printed, int amount)
{
if (shop == null)
{
throw new ArgumentNullException(nameof(shop));
}
if (printed == null)
{
throw new ArgumentNullException(nameof(printed));
}
if (amount <= 0)
{
throw new ArgumentNullException("Кол-во печатных изделий должно быть больше 0", nameof(amount));
}
var shopView = _shopStorage.GetElement(shop);
if (shopView == null)
{
_logger.LogWarning("SupplyPrinteds. Shop not found");
return false;
}
_logger.LogInformation("SupplyPrinteds. Shop find. Id: {Id}", shopView.Id);
if (shopView.ShopPrinteds.TryGetValue(printed.Id, out var shopPrinted))
{
shopView.ShopPrinteds[printed.Id] = (printed, shopPrinted.Item2 + amount);
}
else
{
shopView.ShopPrinteds.Add(printed.Id, (printed, amount));
}
if (_shopStorage.Update(new ShopBindingModel()
{
Id = shopView.Id,
ShopName = shopView.ShopName,
Address = shopView.Address,
OpeningDate = shopView.OpeningDate,
ShopPrinteds = shopView.ShopPrinteds
}) == null)
{
_logger.LogWarning("SupplyPrinteds. Update 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));
}
if (string.IsNullOrEmpty(model.Address))
{
throw new ArgumentNullException("Нет адреса магазина", nameof(model.Address));
}
_logger.LogInformation("Shop. ShopName: {ShopName}. Addres: {Addres}. Id: {Id}",
model.ShopName, model.Address, model.Id);
var element = _shopStorage.GetElement(new ShopSearchModel { ShopName = model.ShopName });
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Магазин с таким названием уже есть");
}
}
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TypographyDataModels.Models;
namespace TypographyContracts.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 OpeningDate { get; set; } = DateTime.Now;
public Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; set; } = new();
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
using TypographyContracts.ViewModels;
namespace TypographyContracts.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 SupplyPrinteds(ShopSearchModel shop, PrintedBindingModel printed, int amount);
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TypographyContracts.SearchModels
{
public class ShopSearchModel
{
public int? Id { get; set; }
public string? ShopName { get; set; }
}
}

View File

@ -0,0 +1,16 @@
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
using TypographyContracts.ViewModels;
namespace TypographyContracts.StoragesContracts
{
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);
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TypographyDataModels.Models;
namespace TypographyContracts.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 OpeningDate { get; set; } = DateTime.Now;
public Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; set; } = new();
}
}

View File

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TypographyDataModels.Models
{
public interface IShopModel : IId
{
string ShopName { get; }
string Address { get; }
DateTime OpeningDate { get; }
Dictionary<int, (IPrintedModel, int)> ShopPrinteds { get; }
}
}

View File

@ -14,11 +14,14 @@ namespace TypographyListImplement
public List<Order> Orders { get; set; }
public List<Printed> Printeds { get; set; }
public List<Shop> Shops { get; set; }
private DataListSingleton()
{
Components = new List<Component>();
Orders = new List<Order>();
Printeds = new List<Printed>();
Shops = new List<Shop>();
}
public static DataListSingleton GetInstance()

View File

@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TypographyContracts.BindingModels;
using TypographyContracts.SearchModels;
using TypographyContracts.StoragesContracts;
using TypographyContracts.ViewModels;
using TypographyListImplement.Models;
namespace TypographyListImplement.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))
{
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;
}
}
}

View File

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TypographyContracts.BindingModels;
using TypographyContracts.ViewModels;
using TypographyDataModels.Models;
namespace TypographyListImplement.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 OpeningDate { get; private set; } = DateTime.Now;
public Dictionary<int, (IPrintedModel, int)> ShopPrinteds { 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,
OpeningDate = model.OpeningDate,
ShopPrinteds = new()
};
}
public void Update(ShopBindingModel? model)
{
if (model == null)
{
return;
}
ShopName = model.ShopName;
Address = model.Address;
OpeningDate = model.OpeningDate;
ShopPrinteds = model.ShopPrinteds;
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Address = Address,
OpeningDate = OpeningDate,
ShopPrinteds = ShopPrinteds
};
}
}

View File

@ -1,24 +1,24 @@
namespace TypographyView
{
partial class FormMain
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
partial class FormMain
{
/// <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);
}
/// <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
@ -28,153 +28,175 @@
/// </summary>
private void InitializeComponent()
{
this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
this.buttonIssuedOrder = new System.Windows.Forms.Button();
this.dataGridViewOrders = new System.Windows.Forms.DataGridView();
this.buttonRef = new System.Windows.Forms.Button();
this.buttonOrderReady = new System.Windows.Forms.Button();
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.directoriesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.printedsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dataGridViewOrders)).BeginInit();
this.menuStrip.SuspendLayout();
this.SuspendLayout();
buttonCreateOrder = new Button();
buttonTakeOrderInWork = new Button();
buttonIssuedOrder = new Button();
dataGridViewOrders = new DataGridView();
buttonRef = new Button();
buttonOrderReady = new Button();
menuStrip = new MenuStrip();
directoriesToolStripMenuItem = new ToolStripMenuItem();
componentsToolStripMenuItem = new ToolStripMenuItem();
printedsToolStripMenuItem = new ToolStripMenuItem();
shopsToolStripMenuItem = new ToolStripMenuItem();
supplyToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).BeginInit();
menuStrip.SuspendLayout();
SuspendLayout();
//
// buttonCreateOrder
//
this.buttonCreateOrder.Location = new System.Drawing.Point(1100, 31);
this.buttonCreateOrder.Name = "buttonCreateOrder";
this.buttonCreateOrder.Size = new System.Drawing.Size(203, 29);
this.buttonCreateOrder.TabIndex = 0;
this.buttonCreateOrder.Text = "Создать заказ";
this.buttonCreateOrder.UseVisualStyleBackColor = true;
this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
buttonCreateOrder.Location = new Point(1224, 70);
buttonCreateOrder.Margin = new Padding(5, 5, 5, 5);
buttonCreateOrder.Name = "buttonCreateOrder";
buttonCreateOrder.Size = new Size(330, 46);
buttonCreateOrder.TabIndex = 0;
buttonCreateOrder.Text = "Создать заказ";
buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.Click += ButtonCreateOrder_Click;
//
// buttonTakeOrderInWork
//
this.buttonTakeOrderInWork.Location = new System.Drawing.Point(1100, 66);
this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
this.buttonTakeOrderInWork.Size = new System.Drawing.Size(203, 29);
this.buttonTakeOrderInWork.TabIndex = 1;
this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
buttonTakeOrderInWork.Location = new Point(1224, 162);
buttonTakeOrderInWork.Margin = new Padding(5, 5, 5, 5);
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
buttonTakeOrderInWork.Size = new Size(330, 46);
buttonTakeOrderInWork.TabIndex = 1;
buttonTakeOrderInWork.Text = "Отдать на выполнение";
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
//
// buttonIssuedOrder
//
this.buttonIssuedOrder.Location = new System.Drawing.Point(1100, 136);
this.buttonIssuedOrder.Name = "buttonIssuedOrder";
this.buttonIssuedOrder.Size = new System.Drawing.Size(203, 29);
this.buttonIssuedOrder.TabIndex = 2;
this.buttonIssuedOrder.Text = "Заказ выдан";
this.buttonIssuedOrder.UseVisualStyleBackColor = true;
this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
buttonIssuedOrder.Location = new Point(1224, 379);
buttonIssuedOrder.Margin = new Padding(5, 5, 5, 5);
buttonIssuedOrder.Name = "buttonIssuedOrder";
buttonIssuedOrder.Size = new Size(330, 46);
buttonIssuedOrder.TabIndex = 2;
buttonIssuedOrder.Text = "Заказ выдан";
buttonIssuedOrder.UseVisualStyleBackColor = true;
buttonIssuedOrder.Click += ButtonIssuedOrder_Click;
//
// dataGridViewOrders
//
this.dataGridViewOrders.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridViewOrders.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridViewOrders.Location = new System.Drawing.Point(0, 31);
this.dataGridViewOrders.Name = "dataGridViewOrders";
this.dataGridViewOrders.RowHeadersVisible = false;
this.dataGridViewOrders.RowHeadersWidth = 51;
this.dataGridViewOrders.RowTemplate.Height = 29;
this.dataGridViewOrders.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridViewOrders.Size = new System.Drawing.Size(1078, 402);
this.dataGridViewOrders.TabIndex = 3;
dataGridViewOrders.BackgroundColor = SystemColors.ControlLightLight;
dataGridViewOrders.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewOrders.Location = new Point(0, 50);
dataGridViewOrders.Margin = new Padding(5, 5, 5, 5);
dataGridViewOrders.Name = "dataGridViewOrders";
dataGridViewOrders.RowHeadersVisible = false;
dataGridViewOrders.RowHeadersWidth = 51;
dataGridViewOrders.RowTemplate.Height = 29;
dataGridViewOrders.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewOrders.Size = new Size(1156, 506);
dataGridViewOrders.TabIndex = 3;
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(1100, 171);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(203, 29);
this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить список";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
buttonRef.Location = new Point(1224, 487);
buttonRef.Margin = new Padding(5, 5, 5, 5);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(330, 46);
buttonRef.TabIndex = 4;
buttonRef.Text = "Обновить список";
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
//
// buttonOrderReady
//
this.buttonOrderReady.Location = new System.Drawing.Point(1100, 101);
this.buttonOrderReady.Name = "buttonOrderReady";
this.buttonOrderReady.Size = new System.Drawing.Size(203, 29);
this.buttonOrderReady.TabIndex = 5;
this.buttonOrderReady.Text = "Заказ готов";
this.buttonOrderReady.UseVisualStyleBackColor = true;
this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
buttonOrderReady.Location = new Point(1224, 265);
buttonOrderReady.Margin = new Padding(5, 5, 5, 5);
buttonOrderReady.Name = "buttonOrderReady";
buttonOrderReady.Size = new Size(330, 46);
buttonOrderReady.TabIndex = 5;
buttonOrderReady.Text = "Заказ готов";
buttonOrderReady.UseVisualStyleBackColor = true;
buttonOrderReady.Click += ButtonOrderReady_Click;
//
// menuStrip
//
this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.directoriesToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(1315, 28);
this.menuStrip.TabIndex = 6;
this.menuStrip.Text = "menuStrip1";
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { directoriesToolStripMenuItem, supplyToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Padding = new Padding(10, 3, 0, 3);
menuStrip.Size = new Size(1580, 42);
menuStrip.TabIndex = 6;
menuStrip.Text = "menuStrip1";
//
// directoriesToolStripMenuItem
//
this.directoriesToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.componentsToolStripMenuItem,
this.printedsToolStripMenuItem});
this.directoriesToolStripMenuItem.Name = "directoriesToolStripMenuItem";
this.directoriesToolStripMenuItem.Size = new System.Drawing.Size(117, 24);
this.directoriesToolStripMenuItem.Text = "Справочники";
directoriesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, printedsToolStripMenuItem, shopsToolStripMenuItem });
directoriesToolStripMenuItem.Name = "directoriesToolStripMenuItem";
directoriesToolStripMenuItem.Size = new Size(184, 36);
directoriesToolStripMenuItem.Text = "Справочники";
//
// componentsToolStripMenuItem
//
this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
this.componentsToolStripMenuItem.Size = new System.Drawing.Size(237, 26);
this.componentsToolStripMenuItem.Text = "Компоненты";
this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
componentsToolStripMenuItem.Size = new Size(377, 44);
componentsToolStripMenuItem.Text = "Компоненты";
componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
//
// printedsToolStripMenuItem
//
this.printedsToolStripMenuItem.Name = "printedsToolStripMenuItem";
this.printedsToolStripMenuItem.Size = new System.Drawing.Size(237, 26);
this.printedsToolStripMenuItem.Text = "Печатная продукция";
this.printedsToolStripMenuItem.Click += new System.EventHandler(this.PrintedsToolStripMenuItem_Click);
printedsToolStripMenuItem.Name = "printedsToolStripMenuItem";
printedsToolStripMenuItem.Size = new Size(377, 44);
printedsToolStripMenuItem.Text = "Печатная продукция";
printedsToolStripMenuItem.Click += PrintedsToolStripMenuItem_Click;
//
// shopsToolStripMenuItem
//
shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
shopsToolStripMenuItem.Size = new Size(377, 44);
shopsToolStripMenuItem.Text = "Магазины";
shopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click;
//
// supplyToolStripMenuItem
//
supplyToolStripMenuItem.Name = "supplyToolStripMenuItem";
supplyToolStripMenuItem.Size = new Size(282, 36);
supplyToolStripMenuItem.Text = "Пополнение магазина";
supplyToolStripMenuItem.Click += SupplyToolStripMenuItem_Click;
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1315, 433);
this.Controls.Add(this.buttonOrderReady);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.dataGridViewOrders);
this.Controls.Add(this.buttonIssuedOrder);
this.Controls.Add(this.buttonTakeOrderInWork);
this.Controls.Add(this.buttonCreateOrder);
this.Controls.Add(this.menuStrip);
this.MainMenuStrip = this.menuStrip;
this.Name = "FormMain";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Типография";
this.Load += new System.EventHandler(this.FormMain_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridViewOrders)).EndInit();
this.menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1580, 605);
Controls.Add(buttonOrderReady);
Controls.Add(buttonRef);
Controls.Add(dataGridViewOrders);
Controls.Add(buttonIssuedOrder);
Controls.Add(buttonTakeOrderInWork);
Controls.Add(buttonCreateOrder);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Margin = new Padding(5, 5, 5, 5);
Name = "FormMain";
StartPosition = FormStartPosition.CenterScreen;
Text = "Типография";
Load += FormMain_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewOrders).EndInit();
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCreateOrder;
private Button buttonTakeOrderInWork;
private Button buttonIssuedOrder;
private DataGridView dataGridViewOrders;
private Button buttonRef;
private Button buttonOrderReady;
private MenuStrip menuStrip;
private ToolStripMenuItem directoriesToolStripMenuItem;
private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem printedsToolStripMenuItem;
}
private Button buttonTakeOrderInWork;
private Button buttonIssuedOrder;
private DataGridView dataGridViewOrders;
private Button buttonRef;
private Button buttonOrderReady;
private MenuStrip menuStrip;
private ToolStripMenuItem directoriesToolStripMenuItem;
private ToolStripMenuItem componentsToolStripMenuItem;
private ToolStripMenuItem printedsToolStripMenuItem;
private ToolStripMenuItem shopsToolStripMenuItem;
private ToolStripMenuItem supplyToolStripMenuItem;
}
}

View File

@ -5,144 +5,162 @@ using Microsoft.Extensions.Logging;
namespace TypographyView
{
public partial class FormMain : Form
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
public partial class FormMain : Form
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
}
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _orderLogic.ReadList(null);
if (list != null)
{
dataGridViewOrders.DataSource = list;
dataGridViewOrders.Columns["PrintedId"].Visible = false;
dataGridViewOrders.Columns["PrintedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка заказов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadData()
{
try
{
var list = _orderLogic.ReadList(null);
if (list != null)
{
dataGridViewOrders.DataSource = list;
dataGridViewOrders.Columns["PrintedId"].Visible = false;
dataGridViewOrders.Columns["PrintedName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка заказов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form)
{
form.ShowDialog();
}
}
private void ComponentsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
if (service is FormComponents form)
{
form.ShowDialog();
}
}
private void PrintedsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPrinteds));
if (service is FormPrinteds form)
{
form.ShowDialog();
}
}
private void PrintedsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPrinteds));
if (service is FormPrinteds form)
{
form.ShowDialog();
}
}
private void ButtonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form)
{
form.ShowDialog();
LoadData();
}
}
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
if (service is FormShops form)
{
form.ShowDialog();
}
}
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
{
if (dataGridViewOrders.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try
{
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка передачи заказа в работу");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void SupplyToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSupplies));
if (service is FormSupplies form)
{
form.ShowDialog();
}
}
private void ButtonOrderReady_Click(object sender, EventArgs e)
{
if (dataGridViewOrders.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try
{
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
if (service is FormCreateOrder form)
{
form.ShowDialog();
LoadData();
}
}
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
{
if (dataGridViewOrders.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try
{
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
_logger.LogInformation("Заказ №{id} выдан", id);
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
{
if (dataGridViewOrders.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try
{
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
if (!operationResult)
{
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();
}
}
private void ButtonOrderReady_Click(object sender, EventArgs e)
{
if (dataGridViewOrders.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try
{
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
{
if (dataGridViewOrders.SelectedRows.Count == 1)
{
int id = Convert.ToInt32(dataGridViewOrders.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try
{
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
_logger.LogInformation("Заказ №{id} выдан", id);
LoadData();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -1,4 +1,64 @@
<root>
<?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">

View File

@ -0,0 +1,229 @@
namespace TypographyView
{
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()
{
buttonCancel = new Button();
buttonSave = new Button();
groupBoxPrinteds = new GroupBox();
dataGridViewPrinteds = new DataGridView();
dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
ColumnPrintedName = new DataGridViewTextBoxColumn();
ColumnAmount = new DataGridViewTextBoxColumn();
buttonRef = new Button();
labelName = new Label();
labelAddress = new Label();
textBoxAddress = new TextBox();
textBoxName = new TextBox();
labelDate = new Label();
dateTimePickerOpening = new DateTimePicker();
groupBoxPrinteds.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewPrinteds).BeginInit();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(1086, 885);
buttonCancel.Margin = new Padding(5, 5, 5, 5);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(166, 46);
buttonCancel.TabIndex = 0;
buttonCancel.Text = "Закрыть";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(910, 885);
buttonSave.Margin = new Padding(5, 5, 5, 5);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(166, 46);
buttonSave.TabIndex = 1;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// groupBoxPrinteds
//
groupBoxPrinteds.Controls.Add(dataGridViewPrinteds);
groupBoxPrinteds.Controls.Add(buttonRef);
groupBoxPrinteds.Location = new Point(20, 178);
groupBoxPrinteds.Margin = new Padding(5, 5, 5, 5);
groupBoxPrinteds.Name = "groupBoxPrinteds";
groupBoxPrinteds.Padding = new Padding(5, 5, 5, 5);
groupBoxPrinteds.Size = new Size(1232, 698);
groupBoxPrinteds.TabIndex = 2;
groupBoxPrinteds.TabStop = false;
groupBoxPrinteds.Text = "Печатная продукция";
//
// dataGridViewPrinteds
//
dataGridViewPrinteds.BackgroundColor = SystemColors.ControlLightLight;
dataGridViewPrinteds.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewPrinteds.Columns.AddRange(new DataGridViewColumn[] { dataGridViewTextBoxColumn1, ColumnPrintedName, ColumnAmount });
dataGridViewPrinteds.GridColor = SystemColors.ControlLightLight;
dataGridViewPrinteds.Location = new Point(10, 42);
dataGridViewPrinteds.Margin = new Padding(5, 5, 5, 5);
dataGridViewPrinteds.Name = "dataGridViewPrinteds";
dataGridViewPrinteds.RowHeadersVisible = false;
dataGridViewPrinteds.RowHeadersWidth = 51;
dataGridViewPrinteds.RowTemplate.Height = 29;
dataGridViewPrinteds.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewPrinteds.Size = new Size(1037, 640);
dataGridViewPrinteds.TabIndex = 4;
//
// dataGridViewTextBoxColumn1
//
dataGridViewTextBoxColumn1.HeaderText = "Id";
dataGridViewTextBoxColumn1.MinimumWidth = 6;
dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
dataGridViewTextBoxColumn1.Visible = false;
dataGridViewTextBoxColumn1.Width = 125;
//
// ColumnPrintedName
//
ColumnPrintedName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnPrintedName.HeaderText = "Печатное изделие";
ColumnPrintedName.MinimumWidth = 6;
ColumnPrintedName.Name = "ColumnPrintedName";
//
// ColumnAmount
//
ColumnAmount.HeaderText = "Количество";
ColumnAmount.MinimumWidth = 6;
ColumnAmount.Name = "ColumnAmount";
ColumnAmount.Width = 125;
//
// buttonRef
//
buttonRef.Location = new Point(1056, 42);
buttonRef.Margin = new Padding(5, 5, 5, 5);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(166, 46);
buttonRef.TabIndex = 3;
buttonRef.Text = "Обновить";
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(20, 24);
labelName.Margin = new Padding(5, 0, 5, 0);
labelName.Name = "labelName";
labelName.Size = new Size(120, 32);
labelName.TabIndex = 0;
labelName.Text = "Название";
//
// labelAddress
//
labelAddress.AutoSize = true;
labelAddress.Location = new Point(20, 77);
labelAddress.Margin = new Padding(5, 0, 5, 0);
labelAddress.Name = "labelAddress";
labelAddress.Size = new Size(80, 32);
labelAddress.TabIndex = 1;
labelAddress.Text = "Адрес";
//
// textBoxAddress
//
textBoxAddress.Location = new Point(208, 72);
textBoxAddress.Margin = new Padding(5, 5, 5, 5);
textBoxAddress.Name = "textBoxAddress";
textBoxAddress.Size = new Size(336, 39);
textBoxAddress.TabIndex = 3;
//
// textBoxName
//
textBoxName.Location = new Point(208, 24);
textBoxName.Margin = new Padding(5, 5, 5, 5);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(336, 39);
textBoxName.TabIndex = 4;
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(20, 133);
labelDate.Margin = new Padding(5, 0, 5, 0);
labelDate.Name = "labelDate";
labelDate.Size = new Size(175, 32);
labelDate.TabIndex = 5;
labelDate.Text = "Дата открытия";
//
// dateTimePickerOpening
//
dateTimePickerOpening.Location = new Point(208, 125);
dateTimePickerOpening.Margin = new Padding(5, 5, 5, 5);
dateTimePickerOpening.Name = "dateTimePickerOpening";
dateTimePickerOpening.Size = new Size(336, 39);
dateTimePickerOpening.TabIndex = 6;
//
// FormShop
//
AutoScaleDimensions = new SizeF(13F, 32F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1271, 949);
Controls.Add(dateTimePickerOpening);
Controls.Add(labelDate);
Controls.Add(labelName);
Controls.Add(labelAddress);
Controls.Add(textBoxName);
Controls.Add(textBoxAddress);
Controls.Add(groupBoxPrinteds);
Controls.Add(buttonSave);
Controls.Add(buttonCancel);
Margin = new Padding(5, 5, 5, 5);
Name = "FormShop";
StartPosition = FormStartPosition.CenterParent;
Text = "Магазин";
Load += FormShop_Load;
groupBoxPrinteds.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewPrinteds).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private GroupBox groupBoxPrinteds;
private Label labelName;
private Label labelAddress;
private TextBox textBoxAddress;
private TextBox textBoxName;
private Button buttonRef;
private DataGridView dataGridViewPrinteds;
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
private DataGridViewTextBoxColumn ColumnPrintedName;
private DataGridViewTextBoxColumn ColumnAmount;
private Label labelDate;
private DateTimePicker dateTimePickerOpening;
}
}

View File

@ -0,0 +1,123 @@
using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.SearchModels;
using TypographyDataModels.Models;
using Microsoft.Extensions.Logging;
namespace TypographyView
{
public partial class FormShop : Form
{
private readonly ILogger _logger;
private readonly IShopLogic _logic;
private int? _id;
private Dictionary<int, (IPrintedModel, int)> _shopPrinteds;
public int Id { set { _id = value; } }
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
_shopPrinteds = new Dictionary<int, (IPrintedModel, int)>();
}
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)
{
textBoxName.Text = view.ShopName;
textBoxAddress.Text = view.Address;
dateTimePickerOpening.Value = view.OpeningDate;
_shopPrinteds = view.ShopPrinteds ?? new Dictionary<int, (IPrintedModel, int)>();
LoadData();
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки магазина");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void LoadData()
{
_logger.LogInformation("Загрузка печатной продукции магазина");
try
{
if (_shopPrinteds != null)
{
dataGridViewPrinteds.Rows.Clear();
foreach (var pr in _shopPrinteds)
{
dataGridViewPrinteds.Rows.Add(new object[] { pr.Key,
pr.Value.Item1.PrintedName, pr.Value.Item2 });
}
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки печатной продукции магазина");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.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 = textBoxName.Text,
Address = textBoxAddress.Text,
OpeningDate = dateTimePickerOpening.Value.Date,
ShopPrinteds = _shopPrinteds
};
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();
}
}
}

View File

@ -0,0 +1,138 @@
<?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>
<metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnPrintedName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnAmount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnPrintedName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnAmount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,118 @@
namespace TypographyView
{
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()
{
dataGridViewShops = new DataGridView();
buttonAdd = new Button();
buttonUpd = new Button();
buttonDel = new Button();
buttonRef = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewShops).BeginInit();
SuspendLayout();
//
// dataGridViewShops
//
dataGridViewShops.BackgroundColor = SystemColors.ControlLightLight;
dataGridViewShops.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewShops.Location = new Point(1, 1);
dataGridViewShops.Name = "dataGridViewShops";
dataGridViewShops.RowHeadersVisible = false;
dataGridViewShops.RowHeadersWidth = 51;
dataGridViewShops.RowTemplate.Height = 29;
dataGridViewShops.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewShops.Size = new Size(650, 402);
dataGridViewShops.TabIndex = 0;
//
// buttonAdd
//
buttonAdd.Location = new Point(668, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(102, 29);
buttonAdd.TabIndex = 1;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonUpd
//
buttonUpd.Location = new Point(668, 47);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(102, 29);
buttonUpd.TabIndex = 2;
buttonUpd.Text = "Изменить";
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonDel
//
buttonDel.Location = new Point(668, 82);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(102, 29);
buttonDel.TabIndex = 3;
buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonRef
//
buttonRef.Location = new Point(668, 117);
buttonRef.Name = "buttonRef";
buttonRef.Size = new Size(102, 29);
buttonRef.TabIndex = 4;
buttonRef.Text = "Обновить";
buttonRef.UseVisualStyleBackColor = true;
buttonRef.Click += ButtonRef_Click;
//
// FormShops
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(782, 403);
Controls.Add(buttonRef);
Controls.Add(buttonDel);
Controls.Add(buttonUpd);
Controls.Add(buttonAdd);
Controls.Add(dataGridViewShops);
Name = "FormShops";
StartPosition = FormStartPosition.CenterParent;
Text = "Магазины";
Load += FormShops_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewShops).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewShops;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private Button buttonRef;
}
}

View File

@ -0,0 +1,104 @@
using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace TypographyView
{
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)
{
dataGridViewShops.DataSource = list;
dataGridViewShops.Columns["Id"].Visible = false;
dataGridViewShops.Columns["ShopPrinteds"].Visible = false;
dataGridViewShops.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 (dataGridViewShops.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
if (service is FormShop form)
{
form.Id = Convert.ToInt32(dataGridViewShops.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridViewShops.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridViewShops.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();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,143 @@
namespace TypographyView
{
partial class FormSupplies
{
/// <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()
{
labelShop = new Label();
labelPrinted = new Label();
labelAmount = new Label();
comboBoxShop = new ComboBox();
comboBoxPrinted = new ComboBox();
textBoxAmount = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// labelShop
//
labelShop.AutoSize = true;
labelShop.Location = new Point(12, 15);
labelShop.Name = "labelShop";
labelShop.Size = new Size(69, 20);
labelShop.TabIndex = 0;
labelShop.Text = "Магазин";
//
// labelPrinted
//
labelPrinted.AutoSize = true;
labelPrinted.Location = new Point(12, 49);
labelPrinted.Name = "labelPrinted";
labelPrinted.Size = new Size(154, 20);
labelPrinted.TabIndex = 1;
labelPrinted.Text = "Печатная продукция";
//
// labelAmount
//
labelAmount.AutoSize = true;
labelAmount.Location = new Point(12, 83);
labelAmount.Name = "labelAmount";
labelAmount.Size = new Size(90, 20);
labelAmount.TabIndex = 2;
labelAmount.Text = "Количество";
//
// comboBoxShop
//
comboBoxShop.FormattingEnabled = true;
comboBoxShop.Location = new Point(172, 12);
comboBoxShop.Name = "comboBoxShop";
comboBoxShop.Size = new Size(240, 28);
comboBoxShop.TabIndex = 3;
//
// comboBoxPrinted
//
comboBoxPrinted.FormattingEnabled = true;
comboBoxPrinted.Location = new Point(172, 46);
comboBoxPrinted.Name = "comboBoxPrinted";
comboBoxPrinted.Size = new Size(240, 28);
comboBoxPrinted.TabIndex = 4;
//
// textBoxAmount
//
textBoxAmount.Location = new Point(172, 80);
textBoxAmount.Name = "textBoxAmount";
textBoxAmount.Size = new Size(240, 27);
textBoxAmount.TabIndex = 5;
//
// buttonSave
//
buttonSave.Location = new Point(202, 112);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(102, 29);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(310, 112);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(102, 29);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormSupplies
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(427, 153);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxAmount);
Controls.Add(comboBoxPrinted);
Controls.Add(comboBoxShop);
Controls.Add(labelAmount);
Controls.Add(labelPrinted);
Controls.Add(labelShop);
Name = "FormSupplies";
StartPosition = FormStartPosition.CenterParent;
Text = "Поставка";
Load += FormSupplies_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelShop;
private Label labelPrinted;
private Label labelAmount;
private ComboBox comboBoxShop;
private ComboBox comboBoxPrinted;
private TextBox textBoxAmount;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,99 @@
using TypographyContracts.BindingModels;
using TypographyContracts.BusinessLogicsContracts;
using TypographyContracts.SearchModels;
using Microsoft.Extensions.Logging;
namespace TypographyView
{
public partial class FormSupplies : Form
{
private readonly ILogger _logger;
private readonly IPrintedLogic _logicP;
private readonly IShopLogic _logicS;
public FormSupplies(ILogger<FormSupplies> logger, IPrintedLogic logicP, IShopLogic logicS)
{
InitializeComponent();
_logger = logger;
_logicP = logicP;
_logicS = logicS;
}
private void FormSupplies_Load(object sender, EventArgs e)
{
_logger.LogInformation("Загрузка магазинов для поставки");
var _listS = _logicS.ReadList(null);
if (_listS != null)
{
comboBoxShop.DisplayMember = "ShopName";
comboBoxShop.ValueMember = "Id";
comboBoxShop.DataSource = _listS;
comboBoxShop.SelectedItem = null;
}
_logger.LogInformation("Загрузка печатной продукции для поставки");
var _listP = _logicP.ReadList(null);
if (_listP != null)
{
comboBoxPrinted.DisplayMember = "PrintedName";
comboBoxPrinted.ValueMember = "Id";
comboBoxPrinted.DataSource = _listP;
comboBoxPrinted.SelectedItem = null;
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (comboBoxShop.SelectedValue == null)
{
MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxPrinted.SelectedValue == null)
{
MessageBox.Show("Выберите печатную продукцию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxAmount.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание поставки");
try
{
var operationResult = _logicS.SupplyPrinteds(
new ShopSearchModel()
{
Id = Convert.ToInt32(comboBoxShop.SelectedValue),
ShopName = comboBoxShop.Text
},
new PrintedBindingModel()
{
Id = Convert.ToInt32(comboBoxPrinted.SelectedValue),
PrintedName = comboBoxPrinted.Text
},
Convert.ToInt32(textBoxAmount.Text));
if (!operationResult)
{
throw new Exception("Ошибка при создании поставки. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания поставки");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -11,6 +11,7 @@ namespace TypographyView
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
@ -28,7 +29,6 @@ namespace TypographyView
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
@ -39,9 +39,13 @@ namespace TypographyView
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IPrintedStorage, PrintedStorage>();
services.AddTransient<IShopStorage, ShopStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IPrintedLogic, PrintedLogic>();
services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
@ -49,6 +53,9 @@ namespace TypographyView
services.AddTransient<FormPrinted>();
services.AddTransient<FormPrinteds>();
services.AddTransient<FormPrintedComponent>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
services.AddTransient<FormSupplies>();
}
}
}