From 9d28d844f7c1f88d7432065b8b805315582b6e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=9C=D0=B0=D0=BB?= =?UTF-8?q?=D0=B0=D1=84=D0=B5=D0=B5=D0=B2?= Date: Sat, 18 May 2024 13:05:40 +0400 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B8=D0=B4=D0=B8=D0=BC=20=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B0=D0=B5=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Attributes/ColumnAttribute.cs | 31 +++++++++++++++++++ .../Attributes/GridViewAutoSize.cs | 27 ++++++++++++++++ .../ViewModels/ClientViewModel.cs | 8 +++-- .../ViewModels/ComponentViewModel.cs | 8 +++-- .../ViewModels/ImplementerViewModel.cs | 16 +++++----- .../ViewModels/JewelViewModel.cs | 9 ++++-- .../ViewModels/MessageInfoViewModel.cs | 16 +++++----- .../ViewModels/OrderViewModel.cs | 26 +++++++++------- 8 files changed, 107 insertions(+), 34 deletions(-) create mode 100644 JewelryStore/JewelryStoreContracts/Attributes/ColumnAttribute.cs create mode 100644 JewelryStore/JewelryStoreContracts/Attributes/GridViewAutoSize.cs diff --git a/JewelryStore/JewelryStoreContracts/Attributes/ColumnAttribute.cs b/JewelryStore/JewelryStoreContracts/Attributes/ColumnAttribute.cs new file mode 100644 index 0000000..db1513d --- /dev/null +++ b/JewelryStore/JewelryStoreContracts/Attributes/ColumnAttribute.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JewelryStoreContracts.Attributes +{ + [AttributeUsage(AttributeTargets.Property)] + public class ColumnAttribute : Attribute + { + 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; } + + 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; + } + } +} diff --git a/JewelryStore/JewelryStoreContracts/Attributes/GridViewAutoSize.cs b/JewelryStore/JewelryStoreContracts/Attributes/GridViewAutoSize.cs new file mode 100644 index 0000000..d8ef20a --- /dev/null +++ b/JewelryStore/JewelryStoreContracts/Attributes/GridViewAutoSize.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace JewelryStoreContracts.Attributes +{ + public enum GridViewAutoSize + { + NotSet = 0, + + None = 1, + + ColumnHeader = 2, + + AllCellsExceptHeader = 4, + + AllCells = 6, + + DisplayedCellsExceptHeader = 8, + + DisplayedCells = 10, + + Fill = 16 + } +} diff --git a/JewelryStore/JewelryStoreContracts/ViewModels/ClientViewModel.cs b/JewelryStore/JewelryStoreContracts/ViewModels/ClientViewModel.cs index 62a8dcd..8d7fc67 100644 --- a/JewelryStore/JewelryStoreContracts/ViewModels/ClientViewModel.cs +++ b/JewelryStore/JewelryStoreContracts/ViewModels/ClientViewModel.cs @@ -5,17 +5,19 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using JewelryStoreContracts.Attributes; namespace JewelryStoreContracts.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/JewelryStore/JewelryStoreContracts/ViewModels/ComponentViewModel.cs b/JewelryStore/JewelryStoreContracts/ViewModels/ComponentViewModel.cs index f1b9409..8be8be7 100644 --- a/JewelryStore/JewelryStoreContracts/ViewModels/ComponentViewModel.cs +++ b/JewelryStore/JewelryStoreContracts/ViewModels/ComponentViewModel.cs @@ -1,4 +1,5 @@ -using JewerlyStoreDataModels.Models; +using JewelryStoreContracts.Attributes; +using JewerlyStoreDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,12 +11,13 @@ namespace JewelryStoreContracts.ViewModels { public class ComponentViewModel : IComponentModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название компонента")] + [Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ComponentName { get; set; } = string.Empty; - [DisplayName("Цена")] + [Column(title: "Цена", width: 150)] public double Cost { get; set; } } diff --git a/JewelryStore/JewelryStoreContracts/ViewModels/ImplementerViewModel.cs b/JewelryStore/JewelryStoreContracts/ViewModels/ImplementerViewModel.cs index 07d8cdd..338005c 100644 --- a/JewelryStore/JewelryStoreContracts/ViewModels/ImplementerViewModel.cs +++ b/JewelryStore/JewelryStoreContracts/ViewModels/ImplementerViewModel.cs @@ -1,4 +1,5 @@ -using JewerlyStoreDataModels.Models; +using JewelryStoreContracts.Attributes; +using JewerlyStoreDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -9,19 +10,20 @@ using System.Threading.Tasks; namespace JewelryStoreContracts.ViewModels { public class ImplementerViewModel : IImplementerModel - { - public int Id { get; set; } + { + [Column(visible: false)] + public int Id { get; set; } - [DisplayName("ФИО исполнителя")] + [Column(title: "ФИО исполнителя", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column(title: "Пароль", width: 100)] public string Password { get; set; } = string.Empty; - [DisplayName("Стаж работы")] + [Column(title: "Стаж работы", width: 60)] public int WorkExperience { get; set; } - [DisplayName("Квалификация")] + [Column(title: "Квалификация", width: 60)] public int Qualification { get; set; } } } diff --git a/JewelryStore/JewelryStoreContracts/ViewModels/JewelViewModel.cs b/JewelryStore/JewelryStoreContracts/ViewModels/JewelViewModel.cs index 638e84f..d337174 100644 --- a/JewelryStore/JewelryStoreContracts/ViewModels/JewelViewModel.cs +++ b/JewelryStore/JewelryStoreContracts/ViewModels/JewelViewModel.cs @@ -1,4 +1,5 @@ -using JewerlyStoreDataModels.Models; +using JewelryStoreContracts.Attributes; +using JewerlyStoreDataModels.Models; using System; using System.Collections.Generic; using System.ComponentModel; @@ -10,13 +11,15 @@ namespace JewelryStoreContracts.ViewModels { public class JewelViewModel : IJewelModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Название изделия")] + [Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string JewelName { get; set; } = string.Empty; - [DisplayName("Цена")] + [Column(title: "Цена", width: 70)] public double Price { get; set; } + [Column(visible: false)] public Dictionary JewelComponents { get; set; } = new(); } diff --git a/JewelryStore/JewelryStoreContracts/ViewModels/MessageInfoViewModel.cs b/JewelryStore/JewelryStoreContracts/ViewModels/MessageInfoViewModel.cs index e0699fa..0a0be52 100644 --- a/JewelryStore/JewelryStoreContracts/ViewModels/MessageInfoViewModel.cs +++ b/JewelryStore/JewelryStoreContracts/ViewModels/MessageInfoViewModel.cs @@ -5,21 +5,23 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using JewelryStoreContracts.Attributes; namespace JewelryStoreContracts.ViewModels { public class MessageInfoViewModel : IMessageInfoModel { - public string MessageId { get; set; } = string.Empty; - - public int? ClientId { get; set; } - [DisplayName("Имя отправителя")] + [Column(visible: false)] + public string MessageId { get; set; } = string.Empty; + [Column(visible: false)] + public int? ClientId { get; set; } + [Column(title: "Имя отправителя", width: 150)] public string SenderName { get; set; } = string.Empty; - [DisplayName("Дата доставки")] + [Column(title: "Дата доставки", width: 120)] public DateTime DateDelivery { get; set; } - [DisplayName("Тема письма")] + [Column(title: "Тема письма", width: 120)] public string Subject { get; set; } = string.Empty; - [DisplayName("Внутренности письма")] + [Column(title: "Внутренности письма", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Body { get; set; } = string.Empty; } } diff --git a/JewelryStore/JewelryStoreContracts/ViewModels/OrderViewModel.cs b/JewelryStore/JewelryStoreContracts/ViewModels/OrderViewModel.cs index a6c3655..4914b32 100644 --- a/JewelryStore/JewelryStoreContracts/ViewModels/OrderViewModel.cs +++ b/JewelryStore/JewelryStoreContracts/ViewModels/OrderViewModel.cs @@ -6,37 +6,41 @@ using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using JewelryStoreContracts.Attributes; namespace JewelryStoreContracts.ViewModels { public class OrderViewModel : IOrderModel { - [DisplayName("Номер")] + [Column(title: "Номер", width: 90)] public int Id { get; set; } + [Column(visible: false)] public int ClientId { get; set; } - [DisplayName("Клиент")] + [Column(title: "Клиент", width: 190)] public string ClientFIO { get; set; } = string.Empty; - public int? ImplementerId { get; set; } - [DisplayName("ФИО исполнителя")] + [Column(visible: false)] + public int? ImplementerId { get; set; } + [Column(title: "ФИО исполнителя", width: 150)] public string ImplementerFIO { get; set; } = string.Empty; - public int JewelId { get; set; } + [Column(visible: false)] + public int JewelId { get; set; } - [DisplayName("Изделие")] + [Column(title: "Изделие", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string JewelName { get; set; } = string.Empty; - [DisplayName("Количество")] + [Column(title: "Количество", width: 100)] public int Count { get; set; } - [DisplayName("Сумма")] + [Column(title: "Сумма", width: 120)] public double Sum { get; set; } - [DisplayName("Статус")] + [Column(title: "Статус", width: 70)] public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; - [DisplayName("Дата создания")] + [Column(title: "Дата создания", width: 120)] public DateTime DateCreate { get; set; } = DateTime.Now; - [DisplayName("Дата выполнения")] + [Column(title: "Дата выполнения", width: 120)] public DateTime? DateImplement { get; set; } }