Переделывание под новые требования

This commit is contained in:
prodigygirl 2023-04-23 12:14:24 +04:00
parent 17a17a5403
commit e7941ff84c
10 changed files with 74 additions and 72 deletions

View File

@ -17,6 +17,7 @@ namespace FurnitureAssemFileImplement
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IFurnitureStorage, FurnitureStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
DependencyManager.Instance.RegisterType<IShopStorage, ShopStorage>();
}
}
}

View File

@ -3,19 +3,24 @@ using FurnitureAssemblyDataModels.Models;
using FurnitureAssemblyContracts.ViewModels;
using System.Xml.Linq;
using System.Diagnostics;
using System.Runtime.Serialization;
namespace FurnitureAssemFileImplement.Models
{
[DataContract]
public class Shop : IShopModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ShopName { get; private set; } = string.Empty;
[DataMember]
public string Address { get; private set; } = string.Empty;
[DataMember]
public DateTime DateOpening { get; private set; }
private Dictionary<int, (IFurnitureModel, int)>? _furnitures = null;
[DataMember]
public Dictionary<int, (IFurnitureModel, int)> Furnitures
{
get
@ -32,6 +37,7 @@ namespace FurnitureAssemFileImplement.Models
}
private set { }
}
[DataMember]
public int MaxCount { get; private set; }
public Dictionary<int, int> CurrentCount { get; private set; } = new();

View File

@ -1,5 +1,6 @@
using FurnitureAssemblyBusinessLogic;
using FurnitureAssemblyContracts.BusinessLogicsContarcts;
using FurnitureAssemblyContracts.DI;
using Microsoft.Extensions.Logging;
using System.Windows.Forms;
@ -82,15 +83,14 @@ namespace FurnitureAssembly
{
if (dataGridViewMail.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormOneMail));
if (service is FormOneMail form)
var form = DependencyManager.Instance.Resolve<FormOneMail>();
form.MessageId = (string)dataGridViewMail.SelectedRows[0].Cells["MessageId"].Value;
if (form.ShowDialog() == DialogResult.OK)
{
form.MessageId = (string)dataGridViewMail.SelectedRows[0].Cells["MessageId"].Value;
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
LoadData();
}
}
}
}

View File

@ -157,29 +157,26 @@ namespace FurnitureAssembly
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
if (service is FormShops form)
{
form.ShowDialog();
}
var form = DependencyManager.Instance.Resolve<FormShops>();
form.ShowDialog();
}
private void ReplenishmentToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReplenishmentShop));
if (service is FormReplenishmentShop form)
{
form.ShowDialog();
}
var form = DependencyManager.Instance.Resolve<FormReplenishmentShop>();
form.ShowDialog();
}
private void buttonSell_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSell));
if (service is FormSell form)
{
form.ShowDialog();
}
var form = DependencyManager.Instance.Resolve<FormSell>();
form.ShowDialog();
}
private void FurnituresToolStripMenuItem_Click(object sender, EventArgs
@ -227,20 +224,18 @@ namespace FurnitureAssembly
private void ShopsFurnituresToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportShopFurnitures));
if (service is FormReportShopFurnitures form)
{
form.ShowDialog();
}
var form = DependencyManager.Instance.Resolve<FormReportShopFurnitures>();
form.ShowDialog();
}
private void OrderDateToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportCountOrdersByPeriod));
if (service is FormReportCountOrdersByPeriod form)
{
form.ShowDialog();
}
var form = DependencyManager.Instance.Resolve<FormReportCountOrdersByPeriod>();
form.ShowDialog();
}
private void ClientsMenuItem_Click(object sender, EventArgs e)

View File

@ -1,5 +1,6 @@
using FurnitureAssemblyContracts.BindingModels;
using FurnitureAssemblyContracts.BusinessLogicsContarcts;
using FurnitureAssemblyContracts.DI;
using Microsoft.Extensions.Logging;
@ -19,14 +20,13 @@ namespace FurnitureAssembly
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
if (service is FormShop form)
var form = DependencyManager.Instance.Resolve<FormShop>();
if (form.ShowDialog() == DialogResult.OK)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
LoadData();
}
}
private void FormShops_Load(object sender, EventArgs e)
@ -38,14 +38,7 @@ namespace FurnitureAssembly
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["Furnitures"].Visible = false;
}
dataGridView.FillandConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка магазинов");
}
catch (Exception ex)
@ -60,16 +53,14 @@ namespace FurnitureAssembly
{
if (dataGridView.SelectedRows.Count == 1)
{
var service =
Program.ServiceProvider?.GetService(typeof(FormShop));
if (service is FormShop form)
var form = DependencyManager.Instance.Resolve<FormShop>();
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
LoadData();
}
}
}

View File

@ -1,25 +1,21 @@
using FurnitureAssemblyDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FurnitureAssemblyContracts.Attributes;
using FurnitureAssemblyDataModels.Models;
namespace FurnitureAssemblyContracts.ViewModels
{
public class ShopViewModel : IShopModel
{
public int Id { get; set; }
[DisplayName("Название магазина")]
[Column(title: "Название магазина", isUseAutoSize: true, gridViewAutoSize: GridViewAutoSize.Fill)]
public string ShopName { get; set; } = string.Empty;
[DisplayName("Адрес магазина")]
[Column(title: "Адрес магазина", isUseAutoSize: true, gridViewAutoSize: GridViewAutoSize.Fill)]
public string Address { get; set; } = string.Empty;
[DisplayName("Дата открытия")]
[Column(title: "Дата открытия", width: 100)]
public DateTime DateOpening { get; set; }
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; set; } = new();
[DisplayName("Вместимость")]
[Column(title: "Вместимость", isUseAutoSize: true, gridViewAutoSize: GridViewAutoSize.Fill)]
public int MaxCount { get; set; }
}
}

View File

@ -17,6 +17,7 @@ namespace FurnitureAssemblyDatabaseImplement
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IFurnitureStorage, FurnitureStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
DependencyManager.Instance.RegisterType<IShopStorage, ShopStorage>();
}
}
}

View File

@ -7,23 +7,30 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyDatabaseImplement.Models
{
[DataContract]
public class Shop : IShopModel
{
[DataMember]
public int Id { get; private set; }
[Required]
[DataMember]
public string ShopName { get; private set; } = string.Empty;
[Required]
[DataMember]
public string Address { get; private set; } = string.Empty;
[Required]
[DataMember]
public DateTime DateOpening { get; private set; }
private Dictionary<int, (IFurnitureModel, int)>? _furnitures = null;
[NotMapped]
[DataMember]
public Dictionary<int, (IFurnitureModel, int)> Furnitures
{
get
@ -39,7 +46,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
}
private set { }
}
[DataMember]
public int MaxCount { get; private set; }
[ForeignKey("ShopId")]

View File

@ -17,6 +17,7 @@ namespace FurnitureAssemblyListImplement
DependencyManager.Instance.RegisterType<IOrderStorage, OrderStorage>();
DependencyManager.Instance.RegisterType<IFurnitureStorage, FurnitureStorage>();
DependencyManager.Instance.RegisterType<IBackUpInfo, BackUpInfo>();
DependencyManager.Instance.RegisterType<IShopStorage, ShopStorage>();
}
}
}

View File

@ -5,22 +5,26 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace FurnitureAssemblyListImplement.Models
{
[DataContract]
public class Shop : IShopModel
{
[DataMember]
public int Id { get; private set; }
[DataMember]
public string ShopName { get; private set; } = string.Empty;
[DataMember]
public string Address { get; private set; } = string.Empty;
[DataMember]
public DateTime DateOpening { get; private set; }
[DataMember]
public Dictionary<int, (IFurnitureModel, int)> Furnitures { get; private set; } = new();
[DataMember]
public int MaxCount { get; private set; }
public static Shop? Create(ShopBindingModel? model)