diff --git a/ComputerShopContracts/Attributes/ColumnAttribute.cs b/ComputerShopContracts/Attributes/ColumnAttribute.cs new file mode 100644 index 0000000..8833023 --- /dev/null +++ b/ComputerShopContracts/Attributes/ColumnAttribute.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.Attributes +{ + [AttributeUsage(AttributeTargets.Property)] + public class ColumnAttribute : Attribute + { + public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false) + { + Title = title; + Visible = visible; + Width = width; + GridViewAutoSize = gridViewAutoSize; + IsUseAutoSize = isUseAutoSize; + } + public string Title { get; private set; } + public bool Visible { get; private set; } + public int Width { get; private set; } + public GridViewAutoSize GridViewAutoSize { get; private set; } + public bool IsUseAutoSize { get; private set; } + } +} diff --git a/ComputerShopContracts/Attributes/GridViewAutoSize.cs b/ComputerShopContracts/Attributes/GridViewAutoSize.cs new file mode 100644 index 0000000..8e6f7e5 --- /dev/null +++ b/ComputerShopContracts/Attributes/GridViewAutoSize.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ComputerShopContracts.Attributes +{ + public enum GridViewAutoSize + { + NotSet = 0, + None = 1, + ColumnHeader = 2, + AllCellsExceptHeader = 4, + AllCells = 6, + DisplayedCellsExceptHeader = 8, + DisplayedCells = 10, + Fill = 16 + } +} diff --git a/ComputerShopContracts/ViewModels/ClientViewModel.cs b/ComputerShopContracts/ViewModels/ClientViewModel.cs index 3b26224..953a0c0 100644 --- a/ComputerShopContracts/ViewModels/ClientViewModel.cs +++ b/ComputerShopContracts/ViewModels/ClientViewModel.cs @@ -1,4 +1,5 @@ -using ComputerShopDataModels.Models; +using ComputerShopContracts.Attributes; +using ComputerShopDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,12 +11,13 @@ namespace ComputerShopContracts.ViewModels { public class ClientViewModel : IClientModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("ФИО клиента")] + [Column(title: "ФИО клиента", width: 150)] public string ClientFIO { get; set; } = string.Empty; - [DisplayName("Логин (эл. почта)")] + [Column(title: "Логин (эл.почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Email { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column(title: "Пароль", width: 150)] public string Password { get; set; } = string.Empty; } } diff --git a/ComputerShopContracts/ViewModels/ComponentViewModel.cs b/ComputerShopContracts/ViewModels/ComponentViewModel.cs index 661912e..200766a 100644 --- a/ComputerShopContracts/ViewModels/ComponentViewModel.cs +++ b/ComputerShopContracts/ViewModels/ComponentViewModel.cs @@ -1,4 +1,5 @@ -using ComputerShopDataModels.Models; +using ComputerShopContracts.Attributes; +using ComputerShopDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,10 +11,11 @@ namespace ComputerShopContracts.ViewModels { public class ComponentViewModel : IComponentModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название компонента")] + [Column("Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ComponentName { get; set; } = string.Empty; - [DisplayName("Цена")] + [Column("Цена", width: 100)] public double Cost { get; set; } } } diff --git a/ComputerShopContracts/ViewModels/ComputerViewModel.cs b/ComputerShopContracts/ViewModels/ComputerViewModel.cs index 8022b33..0f728d0 100644 --- a/ComputerShopContracts/ViewModels/ComputerViewModel.cs +++ b/ComputerShopContracts/ViewModels/ComputerViewModel.cs @@ -1,4 +1,5 @@ -using ComputerShopDataModels.Models; +using ComputerShopContracts.Attributes; +using ComputerShopDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,11 +11,13 @@ namespace ComputerShopContracts.ViewModels { public class ComputerViewModel : IComputerModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название изделия")] + [Column("Название компьютера", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ComputerName { get; set; } = string.Empty; - [DisplayName("Цена")] + [Column("Цена", width: 100)] public double Price { get; set; } + [Column(visible: false)] public Dictionary ComputerComponents { get; diff --git a/ComputerShopContracts/ViewModels/ImplementerViewModel.cs b/ComputerShopContracts/ViewModels/ImplementerViewModel.cs index a7b530e..82bf2d0 100644 --- a/ComputerShopContracts/ViewModels/ImplementerViewModel.cs +++ b/ComputerShopContracts/ViewModels/ImplementerViewModel.cs @@ -1,4 +1,5 @@ -using ComputerShopDataModels.Models; +using ComputerShopContracts.Attributes; +using ComputerShopDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,18 +11,19 @@ namespace ComputerShopContracts.ViewModels { public class ImplementerViewModel : IImplementerModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("ФИО")] + [Column("ФИО", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column("Пароль", width: 200)] public string Password { get; set; } = string.Empty; - [DisplayName("Трудовой стаж")] + [Column("Трудовой стаж", width: 200)] public int WorkExperience { get; set; } - [DisplayName("Квалификация")] + [Column("Квалификация", width: 200)] public int Qualification { get; set; } } } diff --git a/ComputerShopContracts/ViewModels/MessageInfoViewModel.cs b/ComputerShopContracts/ViewModels/MessageInfoViewModel.cs index e242362..7c3012b 100644 --- a/ComputerShopContracts/ViewModels/MessageInfoViewModel.cs +++ b/ComputerShopContracts/ViewModels/MessageInfoViewModel.cs @@ -1,4 +1,5 @@ -using ComputerShopDataModels.Models; +using ComputerShopContracts.Attributes; +using ComputerShopDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,16 +11,17 @@ namespace ComputerShopContracts.ViewModels { public class MessageInfoViewModel : IMessageInfoModel { + [Column(visible: false)] public string MessageId { get; set; } = string.Empty; - + [Column(visible: false)] public int? ClientId { get; set; } - [DisplayName("Отправитель")] + [Column("Отправитель", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)] public string SenderName { get; set; } = string.Empty; - [DisplayName("Дата письма")] + [Column("Дата письма", width: 100)] public DateTime DateDelivery { get; set; } - [DisplayName("Заголовок")] + [Column("Заголовок", width: 150)] public string Subject { get; set; } = string.Empty; - [DisplayName("Текст")] + [Column("Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Body { get; set; } = string.Empty; } } diff --git a/ComputerShopContracts/ViewModels/OrderViewModel.cs b/ComputerShopContracts/ViewModels/OrderViewModel.cs index 5b36388..da1a7c9 100644 --- a/ComputerShopContracts/ViewModels/OrderViewModel.cs +++ b/ComputerShopContracts/ViewModels/OrderViewModel.cs @@ -1,4 +1,5 @@ -using ComputerShopDataModels.Enums; +using ComputerShopContracts.Attributes; +using ComputerShopDataModels.Enums; using ComputerShopDataModels.Models; using System; using System.Collections.Generic; @@ -11,30 +12,32 @@ namespace ComputerShopContracts.ViewModels { public class OrderViewModel : IOrderModel { + [Column(visible: false)] public int ComputerId { get; set; } - [DisplayName("Номер")] + [Column("Номер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public int Id { get; set; } - [DisplayName("Компьютер")] + [Column("Компьютер", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public string ComputerName { get; set; } = string.Empty; - + [Column(visible: false)] public int ClientId { get; set; } - [DisplayName("ФИО клиента")] + [Column("ФИО клиента", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public string ClientFIO { get; set; } = string.Empty; + [Column(visible: false)] public int? ImplementerId { get; set; } - [DisplayName("ФИО исполнителя")] + [Column("ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Количество")] + [Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public int Count { get; set; } - [DisplayName("Сумма")] + [Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public double Sum { get; set; } - [DisplayName("Статус")] + [Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)] public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; - [DisplayName("Дата создания")] + [Column("Дата создания", width: 100)] public DateTime DateCreate { get; set; } = DateTime.Now; - [DisplayName("Дата выполнения")] + [Column("Дата выполнения", width: 100)] public DateTime? DateImplement { get; set; } } }