Добавлен форматированный вывод столбцов для даты, времени и вещественных чисел
This commit is contained in:
parent
1b0d2b6b0f
commit
47c38ea718
@ -31,6 +31,7 @@ namespace ConfectioneryView
|
||||
{
|
||||
column.HeaderText = columnAttr.Title;
|
||||
column.Visible = columnAttr.Visible;
|
||||
column.DefaultCellStyle.Format = columnAttr.Format;
|
||||
if (columnAttr.IsUseAutoSize)
|
||||
{
|
||||
column.AutoSizeMode = (DataGridViewAutoSizeColumnMode)Enum.Parse(typeof(DataGridViewAutoSizeColumnMode), columnAttr.GridViewAutoSize.ToString());
|
||||
|
@ -23,16 +23,7 @@ namespace ConfectioneryView
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["Pastries"].Visible = false;
|
||||
dataGridView.Columns["Name"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -19,13 +19,16 @@ namespace ConfectioneryContracts.Attributes
|
||||
|
||||
public bool IsUseAutoSize { get; private set; }
|
||||
|
||||
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false)
|
||||
public string Format { get; private set; }
|
||||
|
||||
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false, string format = "")
|
||||
{
|
||||
Title = title;
|
||||
Visible = visible;
|
||||
Width = width;
|
||||
GridViewAutoSize = gridViewAutoSize;
|
||||
IsUseAutoSize = isUseAutoSize;
|
||||
Format = format;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ namespace ConfectioneryContracts.ViewModels
|
||||
[Column("Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
|
||||
[Column("Цена", width: 80)]
|
||||
[Column("Цена", width: 80, format: "0.00")]
|
||||
public double Cost { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace ConfectioneryContracts.ViewModels
|
||||
[Column("Отправитель", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
|
||||
public string SenderName { get; set; } = string.Empty;
|
||||
|
||||
[Column("Дата письма", width: 100)]
|
||||
[Column("Дата письма", width: 100, format: "D")]
|
||||
public DateTime DateDelivery { get; set; }
|
||||
|
||||
[Column("Заголовок", width: 150)]
|
||||
|
@ -36,16 +36,16 @@ namespace ConfectioneryContracts.ViewModels
|
||||
[Column("Количество", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public int Count { get; set; }
|
||||
|
||||
[Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
[Column("Сумма", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true, format: "0.00")]
|
||||
public double Sum { get; set; }
|
||||
|
||||
[Column("Статус", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
|
||||
[Column("Дата создания", width: 100)]
|
||||
[Column("Дата создания", width: 100, format: "D")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
|
||||
[Column("Дата выполнения", width: 100)]
|
||||
[Column("Дата выполнения", width: 100, format: "D")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ namespace ConfectioneryContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
[Column("Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string PastryName { get; set; } = string.Empty;
|
||||
[Column("Цена", width: 100)]
|
||||
|
||||
[Column("Цена", width: 100, format: "0.00")]
|
||||
public double Price { get; set; }
|
||||
[Column(visible: false)]
|
||||
public Dictionary<int, (IComponentModel, int)> PastryComponents
|
||||
|
@ -1,4 +1,5 @@
|
||||
using ConfectioneryDataModels;
|
||||
using ConfectioneryContracts.Attributes;
|
||||
using ConfectioneryDataModels;
|
||||
using ConfectioneryDataModels.Models;
|
||||
using System.ComponentModel;
|
||||
|
||||
@ -6,24 +7,26 @@ namespace ConfectioneryContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel : IShopModel
|
||||
{
|
||||
[DisplayName("Название магазина")]
|
||||
[Column("Название магазина", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true)]
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Адрес магазина")]
|
||||
[Column("Адрес магазина", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
|
||||
public string Address { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Максимальное количество изделий в магазине")]
|
||||
[Column("Максимальное количество изделий в магазине", gridViewAutoSize: GridViewAutoSize.DisplayedCells, isUseAutoSize: true)]
|
||||
public int MaxCountPastries { get; set; }
|
||||
|
||||
[DisplayName("Время открытия")]
|
||||
[Column("Время открытия", gridViewAutoSize: GridViewAutoSize.AllCells, isUseAutoSize: true, format: "f")]
|
||||
public DateTime DateOpening { get; set; } = DateTime.Now;
|
||||
|
||||
[Column(visible: false)]
|
||||
public Dictionary<int, (IPastryModel, int)> Pastries
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = new();
|
||||
|
||||
[Column(visible: false)]
|
||||
public int Id { get; set; }
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user