From 11bd076201e1ec2a63b8d21fb1d8923e5d2d4737 Mon Sep 17 00:00:00 2001 From: prodigygirl Date: Sun, 23 Apr 2023 12:20:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=AD=D1=82=D0=B0=D0=BF=201.=20=D0=A4=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=D0=B0=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=B2=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=BE=D0=BD=D0=BA=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FurnitureAssembly/DataGridViewExtension.cs | 4 ++++ .../Attributes/ColumnAttribute.cs | 8 +++++++- .../ViewModels/ComponentViewModel.cs | 2 +- .../ViewModels/FurnitureViewModel.cs | 2 +- .../ViewModels/MessageInfoViewModel.cs | 6 +++--- .../ViewModels/OrderViewModel.cs | 6 +++--- .../ViewModels/ShopViewModel.cs | 2 +- 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/FurnitureAssembly/FurnitureAssembly/DataGridViewExtension.cs b/FurnitureAssembly/FurnitureAssembly/DataGridViewExtension.cs index 6952f2e..7a53b7a 100644 --- a/FurnitureAssembly/FurnitureAssembly/DataGridViewExtension.cs +++ b/FurnitureAssembly/FurnitureAssembly/DataGridViewExtension.cs @@ -44,6 +44,10 @@ namespace FurnitureAssembly { column.Width = columnAttr.Width; } + if (columnAttr.IsFormatable) + { + column.DefaultCellStyle.Format = columnAttr.Formatter; + } } } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/Attributes/ColumnAttribute.cs b/FurnitureAssembly/FurnitureAssemblyContracts/Attributes/ColumnAttribute.cs index f453606..8e7aab7 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/Attributes/ColumnAttribute.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/Attributes/ColumnAttribute.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.Serialization; namespace FurnitureAssemblyContracts.Attributes { @@ -7,18 +8,23 @@ namespace FurnitureAssemblyContracts.Attributes { public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool - isUseAutoSize = false) + isUseAutoSize = false, bool isFormatable = false, string? formatter = null) { Title = title; Visible = visible; Width = width; GridViewAutoSize = gridViewAutoSize; IsUseAutoSize = isUseAutoSize; + IsFormatable = isFormatable; + Formatter = formatter; + } 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 bool IsFormatable { get; private set; } + public string? Formatter { get; private set; } } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs index 88c8df3..144db76 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ComponentViewModel.cs @@ -10,7 +10,7 @@ namespace FurnitureAssemblyContracts.ViewModels public int Id { get; set; } [Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ComponentName { get; set; } = string.Empty; - [Column(title: "Цена", width: 70)] + [Column(title: "Цена", width: 70, isFormatable: true, formatter: "0.00##")] public double Cost { get; set; } } } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/FurnitureViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/FurnitureViewModel.cs index 9dd4ce6..3f7355a 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/FurnitureViewModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/FurnitureViewModel.cs @@ -14,7 +14,7 @@ namespace FurnitureAssemblyContracts.ViewModels public int Id { get; set; } [Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string FurnitureName { get; set; } = string.Empty; - [Column(title: "Цена", width: 70)] + [Column(title: "Цена", width: 70, isFormatable: true, formatter: "0.00##")] public double Price { get; set; } [Column(visible: false)] public Dictionary FurnitureComponents{ get; set; } = new(); diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/MessageInfoViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/MessageInfoViewModel.cs index 2723ba9..e92813a 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/MessageInfoViewModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/MessageInfoViewModel.cs @@ -12,15 +12,15 @@ namespace FurnitureAssemblyContracts.ViewModels public int? ClientId { get; set; } [Column(title: "Отправитель", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string SenderName { get; set; } = string.Empty; - [Column(title: "Дата письма", width: 100)] + [Column(title: "Дата письма", width: 100, isFormatable: true, formatter: "dd/MM/yyyy")] public DateTime DateDelivery { get; set; } [Column(title: "Заголовок", width: 170)] public string Subject { get; set; } = string.Empty; [Column(title: "Текст", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Body { get; set; } = string.Empty; - [DisplayName("Прочитано")] + [Column(title: "Прочитано", width: 10)] public bool IsRead { get; set; } - [DisplayName("Ответ")] + [Column(title: "Ответ", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string? Reply { get; set; } public int Id => throw new NotImplementedException(); diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/OrderViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/OrderViewModel.cs index f8ff5de..a353a4f 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/OrderViewModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/OrderViewModel.cs @@ -23,13 +23,13 @@ namespace FurnitureAssemblyContracts.ViewModels public string FurnitureName { get; set; } = string.Empty; [Column(title: "Количество", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public int Count { get; set; } - [Column(title: "Сумма", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] + [Column(title: "Сумма", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true, isFormatable: true, formatter: "0.00##")] public double Sum { get; set; } [Column(title: "Статус", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; - [Column(title: "Дата создания", width: 100)] + [Column(title: "Дата создания", width: 100, isFormatable: true, formatter: "dd/MM/yyyy")] public DateTime DateCreate { get; set; } = DateTime.Now; - [Column(title: "Дата выполнения", width: 100)] + [Column(title: "Дата выполнения", width: 100, isFormatable: true, formatter: "dd/MM/yyyy")] public DateTime? DateImplement { get; set; } [Column(visible: false)] public int? ImplementerId { get; set; } diff --git a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ShopViewModel.cs b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ShopViewModel.cs index c4e811e..8157048 100644 --- a/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ShopViewModel.cs +++ b/FurnitureAssembly/FurnitureAssemblyContracts/ViewModels/ShopViewModel.cs @@ -11,7 +11,7 @@ namespace FurnitureAssemblyContracts.ViewModels public string ShopName { get; set; } = string.Empty; [Column(title: "Адрес магазина", isUseAutoSize: true, gridViewAutoSize: GridViewAutoSize.Fill)] public string Address { get; set; } = string.Empty; - [Column(title: "Дата открытия", width: 100)] + [Column(title: "Дата открытия", width: 100, isFormatable: true, formatter: "dd/MM/yyyy")] public DateTime DateOpening { get; set; } public Dictionary Furnitures { get; set; } = new();