формат вывода на списке

This commit is contained in:
kotcheshir73 2021-04-03 13:50:58 +04:00
parent 6368698bff
commit 34ff70b8ca
9 changed files with 67 additions and 69 deletions

View File

@ -173,9 +173,13 @@ namespace DesktopTools.Controls
Name = string.Format("Column{0}", property.Name), Name = string.Format("Column{0}", property.Name),
ReadOnly = true, ReadOnly = true,
Visible = !attr.IsHide, Visible = !attr.IsHide,
Width = attr.ColumnWidth ?? 0, Width = attr.ColumnWidth,
AutoSizeMode = attr.ColumnWidth.HasValue ? DataGridViewAutoSizeColumnMode.None : DataGridViewAutoSizeColumnMode.Fill AutoSizeMode = attr.ColumnWidth != 0 ? DataGridViewAutoSizeColumnMode.None : DataGridViewAutoSizeColumnMode.Fill
}); });
if (attr.DefaultCellStyleFormat.IsNotEmpty())
{
dataGridViewList.Columns[colIndex].DefaultCellStyle.Format = attr.DefaultCellStyleFormat;
}
} }
} }

View File

@ -22,7 +22,12 @@ namespace ModuleTools.Attributes
/// <summary> /// <summary>
/// Ширина колонки /// Ширина колонки
/// </summary> /// </summary>
public int? ColumnWidth { get; set; } = null; public int ColumnWidth { get; set; } = 0;
/// <summary>
/// Формат вывода в колонке
/// </summary>
public string DefaultCellStyleFormat { get; set; } = null;
/// <summary> /// <summary>
/// Настройка отображения элемента в контролах /// Настройка отображения элемента в контролах
@ -32,16 +37,5 @@ namespace ModuleTools.Attributes
{ {
DisplayName = displayName; DisplayName = displayName;
} }
/// <summary>
/// Настройка отображения элемента в контролах
/// </summary>
/// <param name="displayName">Название на форме</param>
/// <param name="columnWidth">Ширина колонки</param>
public ViewModelControlListPropertyAttribute(string displayName, int columnWidth)
{
DisplayName = displayName;
ColumnWidth = columnWidth;
}
} }
} }

View File

@ -17,7 +17,7 @@ namespace DepartmentBusinessLogic.ViewModels
[ViewModelControlElementClass()] [ViewModelControlElementClass()]
public class ClassroomViewModel : ElementViewModel public class ClassroomViewModel : ElementViewModel
{ {
[ViewModelControlListProperty("Номер", 80)] [ViewModelControlListProperty("Номер", ColumnWidth = 80)]
[ViewModelControlElementProperty("Номер аудитории", ControlType.ControlString, MustHaveValue = true)] [ViewModelControlElementProperty("Номер аудитории", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("Number")] [MapConfiguration("Number")]
public string Number { get; set; } public string Number { get; set; }
@ -39,15 +39,15 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("ClassroomType")] [MapConfiguration("ClassroomType")]
public ClassroomType ClassroomType { get; set; } public ClassroomType ClassroomType { get; set; }
[ViewModelControlListProperty("Тип", 120)] [ViewModelControlListProperty("Тип", ColumnWidth = 120)]
public string ClassroomTypeTitle => ClassroomType.ToString("G"); public string ClassroomTypeTitle => ClassroomType.ToString("G");
[ViewModelControlListProperty("Площадь", 90)] [ViewModelControlListProperty("Площадь", ColumnWidth = 90)]
[ViewModelControlElementProperty("Площадь", ControlType.ControlDecimal, MustHaveValue = true)] [ViewModelControlElementProperty("Площадь", ControlType.ControlDecimal, MustHaveValue = true)]
[MapConfiguration("Square")] [MapConfiguration("Square")]
public decimal Square { get; set; } public decimal Square { get; set; }
[ViewModelControlListProperty("Кол-во мест", 100)] [ViewModelControlListProperty("Кол-во мест", ColumnWidth = 100)]
[ViewModelControlElementProperty("Кол-во мест", ControlType.ControlInt, MustHaveValue = true)] [ViewModelControlElementProperty("Кол-во мест", ControlType.ControlInt, MustHaveValue = true)]
[MapConfiguration("Capacity")] [MapConfiguration("Capacity")]
public int Capacity { get; set; } public int Capacity { get; set; }

View File

@ -32,7 +32,7 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("EmployeePost.EmployeePostName", IsDifficle = true)] [MapConfiguration("EmployeePost.EmployeePostName", IsDifficle = true)]
public string EmployeePostName { get; set; } public string EmployeePostName { get; set; }
[ViewModelControlListProperty("Ставка", 80)] [ViewModelControlListProperty("Ставка", ColumnWidth = 80, DefaultCellStyleFormat = "N1")]
[ViewModelControlElementProperty("Ставка", ControlType.ControlDecimal, DecimalPlaces = 1, MustHaveValue = true)] [ViewModelControlElementProperty("Ставка", ControlType.ControlDecimal, DecimalPlaces = 1, MustHaveValue = true)]
[MapConfiguration("Rate")] [MapConfiguration("Rate")]
public decimal Rate { get; set; } public decimal Rate { get; set; }
@ -41,14 +41,14 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("IsInternalCombination")] [MapConfiguration("IsInternalCombination")]
public bool IsInternalCombination { get; set; } public bool IsInternalCombination { get; set; }
[ViewModelControlListProperty("Внутр. совм.", 80)] [ViewModelControlListProperty("Внутр. совм.", ColumnWidth = 80)]
public string InternalCombination => IsInternalCombination ? "Да" : "Нет"; public string InternalCombination => IsInternalCombination ? "Да" : "Нет";
[ViewModelControlElementProperty("Внеш. совм.", ControlType.ControlBool, MustHaveValue = true)] [ViewModelControlElementProperty("Внеш. совм.", ControlType.ControlBool, MustHaveValue = true)]
[MapConfiguration("IsExternalCombination")] [MapConfiguration("IsExternalCombination")]
public bool IsExternalCombination { get; set; } public bool IsExternalCombination { get; set; }
[ViewModelControlListProperty("Внеш. совм.", 80)] [ViewModelControlListProperty("Внеш. совм.", ColumnWidth = 80)]
public string ExternalCombination => IsExternalCombination ? "Да" : "Нет"; public string ExternalCombination => IsExternalCombination ? "Да" : "Нет";
public override string ToString() => $"{EmployeeName}-{EmployeePostName}"; public override string ToString() => $"{EmployeeName}-{EmployeePostName}";

View File

@ -22,7 +22,7 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("EmployeePostName")] [MapConfiguration("EmployeePostName")]
public string EmployeePostName { get; set; } public string EmployeePostName { get; set; }
[ViewModelControlListProperty("Порядок", 100)] [ViewModelControlListProperty("Порядок", ColumnWidth = 100)]
[ViewModelControlElementProperty("Порядок", ControlType.ControlInt, MustHaveValue = true)] [ViewModelControlElementProperty("Порядок", ControlType.ControlInt, MustHaveValue = true)]
[MapConfiguration("Order")] [MapConfiguration("Order")]
public int Order { get; set; } public int Order { get; set; }

View File

@ -40,27 +40,27 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("Patronymic")] [MapConfiguration("Patronymic")]
public string Patronymic { get; set; } public string Patronymic { get; set; }
[ViewModelControlListProperty("Дата рожд.", 100)] [ViewModelControlListProperty("Дата рожд.", ColumnWidth = 100, DefaultCellStyleFormat = "dd.MM.yyyy")]
[ViewModelControlElementProperty("Дата рожд.", ControlType.ControlDateTime, MustHaveValue = true )] [ViewModelControlElementProperty("Дата рожд.", ControlType.ControlDateTime, MustHaveValue = true )]
[MapConfiguration("DateBirth", AllowCopyWithoutRigth = false)] [MapConfiguration("DateBirth", AllowCopyWithoutRigth = false)]
public DateTime DateBirth { get; set; } public DateTime DateBirth { get; set; }
[ViewModelControlListProperty("Адрес", 90)] [ViewModelControlListProperty("Адрес", ColumnWidth = 90)]
[ViewModelControlElementProperty("Адрес", ControlType.ControlString, MustHaveValue = true)] [ViewModelControlElementProperty("Адрес", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("Address", AllowCopyWithoutRigth = false)] [MapConfiguration("Address", AllowCopyWithoutRigth = false)]
public string Address { get; set; } public string Address { get; set; }
[ViewModelControlListProperty("Эл. почта", 90)] [ViewModelControlListProperty("Эл. почта", ColumnWidth = 90)]
[ViewModelControlElementProperty("Эл. почта", ControlType.ControlString, MustHaveValue = true)] [ViewModelControlElementProperty("Эл. почта", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("Email", AllowCopyWithoutRigth = false)] [MapConfiguration("Email", AllowCopyWithoutRigth = false)]
public string Email { get; set; } public string Email { get; set; }
[ViewModelControlListProperty("Моб. номер", 100)] [ViewModelControlListProperty("Моб. номер", ColumnWidth = 100)]
[ViewModelControlElementProperty("Моб. номер", ControlType.ControlString, MustHaveValue = true)] [ViewModelControlElementProperty("Моб. номер", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("MobileNumber", AllowCopyWithoutRigth = false)] [MapConfiguration("MobileNumber", AllowCopyWithoutRigth = false)]
public string MobileNumber { get; set; } public string MobileNumber { get; set; }
[ViewModelControlListProperty("Дом. номер", 100)] [ViewModelControlListProperty("Дом. номер", ColumnWidth = 100)]
[ViewModelControlElementProperty("Дом. номер", ControlType.ControlString)] [ViewModelControlElementProperty("Дом. номер", ControlType.ControlString)]
[MapConfiguration("HomeNumber", AllowCopyWithoutRigth = false)] [MapConfiguration("HomeNumber", AllowCopyWithoutRigth = false)]
public string HomeNumber { get; set; } public string HomeNumber { get; set; }
@ -73,7 +73,7 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("Photo")] [MapConfiguration("Photo")]
public byte[] Photo { get; set; } public byte[] Photo { get; set; }
[ViewModelControlListProperty("Гр. эл.без.", 90)] [ViewModelControlListProperty("Гр. эл.без.", ColumnWidth = 90)]
[ViewModelControlElementProperty("Группа эл.безоп", ControlType.ControlString, MustHaveValue = true)] [ViewModelControlElementProperty("Группа эл.безоп", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("GroupElectricalSafety")] [MapConfiguration("GroupElectricalSafety")]
public string GroupElectricalSafety { get; set; } public string GroupElectricalSafety { get; set; }

View File

@ -20,7 +20,7 @@ namespace SecurityBusinessLogic.ViewModels
[ViewModelControlElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = true, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlRoleList, SecurityWindowsDesktop")] [ViewModelControlElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = true, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlRoleList, SecurityWindowsDesktop")]
public Guid RoleId { get; set; } public Guid RoleId { get; set; }
[ViewModelControlListProperty("Роль", 100)] [ViewModelControlListProperty("Роль", ColumnWidth = 100)]
[MapConfiguration("Role.RoleName", IsDifficle = true, AllowCopyWithoutRigth = false)] [MapConfiguration("Role.RoleName", IsDifficle = true, AllowCopyWithoutRigth = false)]
public string RoleName { get; set; } public string RoleName { get; set; }
@ -35,7 +35,7 @@ namespace SecurityBusinessLogic.ViewModels
[ViewModelControlElementProperty("Тип", ControlType.ControlEnum, MustHaveValue = true)] [ViewModelControlElementProperty("Тип", ControlType.ControlEnum, MustHaveValue = true)]
public AccessType AccessType { get; set; } public AccessType AccessType { get; set; }
[ViewModelControlListProperty("Тип", 150)] [ViewModelControlListProperty("Тип", ColumnWidth = 150)]
public string AccessTypeTitle => AccessType switch public string AccessTypeTitle => AccessType switch
{ {
AccessType.Delete => "Полные права", AccessType.Delete => "Полные права",

View File

@ -24,7 +24,7 @@ namespace SecurityBusinessLogic.ViewModels
[MapConfiguration("RoleName")] [MapConfiguration("RoleName")]
public string RoleName { get; set; } public string RoleName { get; set; }
[ViewModelControlListProperty("Приоритет", 100)] [ViewModelControlListProperty("Приоритет", ColumnWidth = 100)]
[ViewModelControlElementProperty("Приоритет", ControlType.ControlInt, MustHaveValue = true)] [ViewModelControlElementProperty("Приоритет", ControlType.ControlInt, MustHaveValue = true)]
[MapConfiguration("RolePriority")] [MapConfiguration("RolePriority")]
public int RolePriority { get; set; } public int RolePriority { get; set; }

View File

@ -30,7 +30,7 @@ namespace SecurityBusinessLogic.ViewModels
[ViewModelControlElementProperty("Фото", ControlType.ControlImage, Width = 200, Height = 200)] [ViewModelControlElementProperty("Фото", ControlType.ControlImage, Width = 200, Height = 200)]
public byte[] Avatar { get; set; } public byte[] Avatar { get; set; }
[ViewModelControlListProperty("Посл. визит", 100)] [ViewModelControlListProperty("Посл. визит", ColumnWidth = 100, DefaultCellStyleFormat = "dd.MM.yyyy")]
[MapConfiguration("DateLastVisit")] [MapConfiguration("DateLastVisit")]
public DateTime? DateLastVisit { get; set; } public DateTime? DateLastVisit { get; set; }
@ -38,14 +38,14 @@ namespace SecurityBusinessLogic.ViewModels
[ViewModelControlElementProperty("Заблокирован", ControlType.ControlBool, MustHaveValue = true)] [ViewModelControlElementProperty("Заблокирован", ControlType.ControlBool, MustHaveValue = true)]
public bool IsBanned { get; set; } public bool IsBanned { get; set; }
[ViewModelControlListProperty("Блокир.", 80)] [ViewModelControlListProperty("Блокир.", ColumnWidth = 80)]
public string Banned => IsBanned ? "Да" : "Нет"; public string Banned => IsBanned ? "Да" : "Нет";
[MapConfiguration("DateBanned", AllowCopyWithoutRigth = false)] [MapConfiguration("DateBanned", AllowCopyWithoutRigth = false)]
[ViewModelControlElementProperty("Дата блокировки", ControlType.ControlDateTime, ReadOnly = true)] [ViewModelControlElementProperty("Дата блокировки", ControlType.ControlDateTime, ReadOnly = true)]
public DateTime? DateBanned { get; set; } public DateTime? DateBanned { get; set; }
[ViewModelControlListProperty("Дата Б.", 100)] [ViewModelControlListProperty("Дата Б.", ColumnWidth = 100)]
public string DateBannedTitle => DateBanned.HasValue ? DateBanned.Value.ToShortDateString() : string.Empty; public string DateBannedTitle => DateBanned.HasValue ? DateBanned.Value.ToShortDateString() : string.Empty;
[MapConfiguration("CountAttempt", AllowCopyWithoutRigth = false)] [MapConfiguration("CountAttempt", AllowCopyWithoutRigth = false)]