Compare commits
No commits in common. "cee98c8a702ac492293697039ad3e82100dd6249" and "aaa9b16759e274483dd8b052cae015298d44ded3" have entirely different histories.
cee98c8a70
...
aaa9b16759
@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConfectioneryContracts.BindingModels
|
||||
{
|
||||
public class BackUpSaveBinidngModel
|
||||
{
|
||||
public string FolderName { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ConfectioneryContracts.BindingModels;
|
||||
|
||||
namespace ConfectioneryContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IBackUpLogic
|
||||
{
|
||||
void CreateBackUp(BackUpSaveBinidngModel model);
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConfectioneryContracts.StoragesContracts
|
||||
{
|
||||
public interface IBackUpInfo
|
||||
{
|
||||
List<T>? GetList<T>() where T : class, new();
|
||||
|
||||
Type? GetTypeByModelInterface(string modelInterfaceName);
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
using ConfectioneryDataModels.Models;
|
||||
using ConfectioneryContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -11,11 +10,10 @@ namespace ConfectioneryContracts.ViewModels
|
||||
{
|
||||
public class ComponentViewModel : IComponentModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
[Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
[Column(title: "Цена", width: 150)]
|
||||
public double Cost { get; set; }
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название компонента")]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using ConfectioneryDataModels.Models;
|
||||
using ConfectioneryContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -11,19 +10,18 @@ namespace ConfectioneryContracts.ViewModels
|
||||
{
|
||||
public class ImplementerViewModel : IImplementerModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
[Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
[DisplayName("ФИО исполнителя")]
|
||||
public string ImplementerFIO { get; set; } = string.Empty;
|
||||
|
||||
[Column(title: "Пароль", width: 100)]
|
||||
[DisplayName("Пароль")]
|
||||
public string Password { get; set; } = string.Empty;
|
||||
|
||||
[Column(title: "Стаж работы", width: 60)]
|
||||
[DisplayName("Стаж работы")]
|
||||
public int WorkExperience { get; set; }
|
||||
|
||||
[Column(title: "Квалификация", width: 60)]
|
||||
[DisplayName("Квалификация")]
|
||||
public int Qualification { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using ConfectioneryDataModels.Models;
|
||||
using ConfectioneryContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -11,23 +10,20 @@ namespace ConfectioneryContracts.ViewModels
|
||||
{
|
||||
public class MessageInfoViewModel : IMessageInfoModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
[Column(visible: false)]
|
||||
public string MessageId { get; set; } = string.Empty;
|
||||
[Column(visible: false)]
|
||||
|
||||
public int? ClientId { get; set; }
|
||||
|
||||
[Column(title: "Отправитель", width: 150)]
|
||||
[DisplayName("Отправитель")]
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
|
||||
[Column(title: "Дата письма", width: 120)]
|
||||
[DisplayName("Дата письма")]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
|
||||
[Column(title: "Заголовок", width: 120)]
|
||||
[DisplayName("Заголовок")]
|
||||
public string Subject { get; set; } = string.Empty;
|
||||
|
||||
[Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
[DisplayName("Текст")]
|
||||
public string Body { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
using ConfectioneryDataModels.Enums;
|
||||
using ConfectioneryDataModels.Models;
|
||||
using ConfectioneryContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -12,32 +11,28 @@ namespace ConfectioneryContracts.ViewModels
|
||||
{
|
||||
public class OrderViewModel : IOrderModel
|
||||
{
|
||||
[Column(title: "Номер", width: 90)]
|
||||
public int Id { get; set; }
|
||||
[Column(visible: false)]
|
||||
public int ClientId { get; set; }
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
|
||||
[Column(title: "ФИО клиента", width: 190)]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[Column(visible: false)]
|
||||
[DisplayName("ФИО клиента")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
public string ClientEmail { get; set; } = string.Empty;
|
||||
[Column(visible: false)]
|
||||
public int? ImplementerId { get; set; }
|
||||
[Column(title: "Исполнитель", width: 150)]
|
||||
[DisplayName("Исполнитель")]
|
||||
public string? ImplementerFIO { get; set; } = null;
|
||||
[Column(visible: false)]
|
||||
public int PastryId { get; set; }
|
||||
[Column(title: "Изделие", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string PastryName { get; set; } = string.Empty;
|
||||
[Column(title: "Количество", width: 100)]
|
||||
public int Count { get; set; }
|
||||
[Column(title: "Сумма", width: 120)]
|
||||
public double Sum { get; set; }
|
||||
[Column(title: "Статус", width: 70)]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[Column(title: "Дата создания", width: 120)]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[Column(title: "Дата выполнения", width: 120)]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
[DisplayName("Изделие")]
|
||||
public string PastryName { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Дата выполнения")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using ConfectioneryDataModels.Models;
|
||||
using ConfectioneryContracts.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -11,13 +10,11 @@ namespace ConfectioneryContracts.ViewModels
|
||||
{
|
||||
public class PastryViewModel : IPastryModel
|
||||
{
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
[Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string PastryName { get; set; } = string.Empty;
|
||||
[Column(title: "Цена", width: 70)]
|
||||
public double Price { get; set; }
|
||||
[Column(visible: false)]
|
||||
public Dictionary<int, (IComponentModel, int)> PastryComponents { get; set; } = new();
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название изделия")]
|
||||
public string PastryName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Price { get; set; }
|
||||
public Dictionary<int, (IComponentModel, int)> PastryComponents { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace ConfectioneryDataModels.Models
|
||||
{
|
||||
public interface IClientModel : IId
|
||||
public interface IClientModel
|
||||
{
|
||||
string ClientFIO { get; }
|
||||
string Email { get; }
|
||||
|
@ -1,32 +0,0 @@
|
||||
using ConfectioneryContracts.StoragesContracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConfectioneryDatabaseImplement.Implements
|
||||
{
|
||||
public class BackUpInfo : IBackUpInfo
|
||||
{
|
||||
public List<T>? GetList<T>() where T : class, new()
|
||||
{
|
||||
using var context = new ConfectioneryDatabase();
|
||||
return context.Set<T>().ToList();
|
||||
}
|
||||
|
||||
public Type? GetTypeByModelInterface(string modelInterfaceName)
|
||||
{
|
||||
var assembly = typeof(BackUpInfo).Assembly;
|
||||
var types = assembly.GetTypes();
|
||||
foreach (var type in types)
|
||||
{
|
||||
if (type.IsClass && type.GetInterface(modelInterfaceName) != null)
|
||||
{
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ConfectioneryContracts.Attributes;
|
||||
|
||||
namespace ConfectioneryView
|
||||
{
|
||||
public static class DataGridViewExtension
|
||||
{
|
||||
public static void FillAndConfigGrid<T>(this DataGridView grid, List<T>? data)
|
||||
{
|
||||
if (data == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
grid.DataSource = data;
|
||||
|
||||
var type = typeof(T);
|
||||
var properties = type.GetProperties();
|
||||
foreach (DataGridViewColumn column in grid.Columns)
|
||||
{
|
||||
var property = properties.FirstOrDefault(x => x.Name == column.Name);
|
||||
if (property == null)
|
||||
{
|
||||
throw new InvalidOperationException($"В типе {type.Name} не найдено свойство с именем {column.Name}");
|
||||
}
|
||||
var attribute = property.GetCustomAttributes(typeof(ColumnAttribute), true)?.SingleOrDefault();
|
||||
if (attribute == null)
|
||||
{
|
||||
throw new InvalidOperationException($"Не найден атрибут типа ColumnAttribute для свойства {property.Name}");
|
||||
}
|
||||
|
||||
if (attribute is ColumnAttribute columnAttr)
|
||||
{
|
||||
column.HeaderText = columnAttr.Title;
|
||||
column.Visible = columnAttr.Visible;
|
||||
if (columnAttr.IsUseAutoSize)
|
||||
{
|
||||
column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
column.Width = columnAttr.Width;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -35,8 +35,14 @@ namespace ConfectioneryView
|
||||
{
|
||||
try
|
||||
{
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка списка клиентов");
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка списка клиентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -44,8 +44,15 @@ namespace ConfectioneryView
|
||||
{
|
||||
try
|
||||
{
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ComponentName"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -29,7 +29,14 @@ namespace ConfectioneryView
|
||||
{
|
||||
try
|
||||
{
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ImplementerFIO"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка исполнителей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -28,7 +28,15 @@ namespace ConfectioneryView
|
||||
{
|
||||
try
|
||||
{
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["MessageId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["Body"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка почтовых собщений");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -37,7 +37,17 @@ namespace ConfectioneryView
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
try
|
||||
{
|
||||
dataGridView.FillAndConfigGrid(_orderLogic.ReadList(null));
|
||||
var list = _orderLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["PastryId"].Visible = false;
|
||||
dataGridView.Columns["ClientId"].Visible = false;
|
||||
dataGridView.Columns["ClientEmail"].Visible = false;
|
||||
dataGridView.Columns["ImplementerId"].Visible = false;
|
||||
dataGridView.Columns["PastryName"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -32,8 +32,16 @@ namespace ConfectioneryView
|
||||
{
|
||||
try
|
||||
{
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка кондитерского изделия");
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["PastryComponents"].Visible = false;
|
||||
dataGridView.Columns["PastryName"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка кондитерского изделия");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user