diff --git a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs
index 1fd90c6..aed5d74 100644
--- a/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs
+++ b/DepartmentPortal/Common/DesktopTools/MainControls/GenericControlEntityList.cs
@@ -173,9 +173,13 @@ namespace DesktopTools.Controls
Name = string.Format("Column{0}", property.Name),
ReadOnly = true,
Visible = !attr.IsHide,
- Width = attr.ColumnWidth ?? 0,
- AutoSizeMode = attr.ColumnWidth.HasValue ? DataGridViewAutoSizeColumnMode.None : DataGridViewAutoSizeColumnMode.Fill
+ Width = attr.ColumnWidth,
+ AutoSizeMode = attr.ColumnWidth != 0 ? DataGridViewAutoSizeColumnMode.None : DataGridViewAutoSizeColumnMode.Fill
});
+ if (attr.DefaultCellStyleFormat.IsNotEmpty())
+ {
+ dataGridViewList.Columns[colIndex].DefaultCellStyle.Format = attr.DefaultCellStyleFormat;
+ }
}
}
@@ -571,7 +575,7 @@ namespace DesktopTools.Controls
StartPosition = FormStartPosition.CenterScreen,
ControlBox = false
};
- control.Open( new ControlOpenModel
+ control.Open(new ControlOpenModel
{
OpenMode = ControlOpenMode.List,
ElementId = id,
diff --git a/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelControlListPropertyAttribute.cs b/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelControlListPropertyAttribute.cs
index 75df843..2773012 100644
--- a/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelControlListPropertyAttribute.cs
+++ b/DepartmentPortal/Common/ModuleTools/Attributes/ViewModelControlListPropertyAttribute.cs
@@ -22,7 +22,12 @@ namespace ModuleTools.Attributes
///
/// Ширина колонки
///
- public int? ColumnWidth { get; set; } = null;
+ public int ColumnWidth { get; set; } = 0;
+
+ ///
+ /// Формат вывода в колонке
+ ///
+ public string DefaultCellStyleFormat { get; set; } = null;
///
/// Настройка отображения элемента в контролах
@@ -32,16 +37,5 @@ namespace ModuleTools.Attributes
{
DisplayName = displayName;
}
-
- ///
- /// Настройка отображения элемента в контролах
- ///
- /// Название на форме
- /// Ширина колонки
- public ViewModelControlListPropertyAttribute(string displayName, int columnWidth)
- {
- DisplayName = displayName;
- ColumnWidth = columnWidth;
- }
}
}
\ No newline at end of file
diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/ClassroomViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/ClassroomViewModels.cs
index 9df76f0..e15e0e9 100644
--- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/ClassroomViewModels.cs
+++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/ClassroomViewModels.cs
@@ -17,7 +17,7 @@ namespace DepartmentBusinessLogic.ViewModels
[ViewModelControlElementClass()]
public class ClassroomViewModel : ElementViewModel
{
- [ViewModelControlListProperty("Номер", 80)]
+ [ViewModelControlListProperty("Номер", ColumnWidth = 80)]
[ViewModelControlElementProperty("Номер аудитории", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("Number")]
public string Number { get; set; }
@@ -39,15 +39,15 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("ClassroomType")]
public ClassroomType ClassroomType { get; set; }
- [ViewModelControlListProperty("Тип", 120)]
+ [ViewModelControlListProperty("Тип", ColumnWidth = 120)]
public string ClassroomTypeTitle => ClassroomType.ToString("G");
- [ViewModelControlListProperty("Площадь", 90)]
+ [ViewModelControlListProperty("Площадь", ColumnWidth = 90)]
[ViewModelControlElementProperty("Площадь", ControlType.ControlDecimal, MustHaveValue = true)]
[MapConfiguration("Square")]
public decimal Square { get; set; }
- [ViewModelControlListProperty("Кол-во мест", 100)]
+ [ViewModelControlListProperty("Кол-во мест", ColumnWidth = 100)]
[ViewModelControlElementProperty("Кол-во мест", ControlType.ControlInt, MustHaveValue = true)]
[MapConfiguration("Capacity")]
public int Capacity { get; set; }
diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeEmployeePostViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeEmployeePostViewModels.cs
index 502b374..2f97791 100644
--- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeEmployeePostViewModels.cs
+++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeEmployeePostViewModels.cs
@@ -32,7 +32,7 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("EmployeePost.EmployeePostName", IsDifficle = true)]
public string EmployeePostName { get; set; }
- [ViewModelControlListProperty("Ставка", 80)]
+ [ViewModelControlListProperty("Ставка", ColumnWidth = 80, DefaultCellStyleFormat = "N1")]
[ViewModelControlElementProperty("Ставка", ControlType.ControlDecimal, DecimalPlaces = 1, MustHaveValue = true)]
[MapConfiguration("Rate")]
public decimal Rate { get; set; }
@@ -41,14 +41,14 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("IsInternalCombination")]
public bool IsInternalCombination { get; set; }
- [ViewModelControlListProperty("Внутр. совм.", 80)]
+ [ViewModelControlListProperty("Внутр. совм.", ColumnWidth = 80)]
public string InternalCombination => IsInternalCombination ? "Да" : "Нет";
[ViewModelControlElementProperty("Внеш. совм.", ControlType.ControlBool, MustHaveValue = true)]
[MapConfiguration("IsExternalCombination")]
public bool IsExternalCombination { get; set; }
- [ViewModelControlListProperty("Внеш. совм.", 80)]
+ [ViewModelControlListProperty("Внеш. совм.", ColumnWidth = 80)]
public string ExternalCombination => IsExternalCombination ? "Да" : "Нет";
public override string ToString() => $"{EmployeeName}-{EmployeePostName}";
diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeePostViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeePostViewModels.cs
index 8610d7f..4c0af27 100644
--- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeePostViewModels.cs
+++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeePostViewModels.cs
@@ -22,7 +22,7 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("EmployeePostName")]
public string EmployeePostName { get; set; }
- [ViewModelControlListProperty("Порядок", 100)]
+ [ViewModelControlListProperty("Порядок", ColumnWidth = 100)]
[ViewModelControlElementProperty("Порядок", ControlType.ControlInt, MustHaveValue = true)]
[MapConfiguration("Order")]
public int Order { get; set; }
diff --git a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs
index 8ce886f..01b5611 100644
--- a/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs
+++ b/DepartmentPortal/Department/DepartmentBusinessLogic/ViewModels/EmployeeViewModels.cs
@@ -40,27 +40,27 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("Patronymic")]
public string Patronymic { get; set; }
- [ViewModelControlListProperty("Дата рожд.", 100)]
+ [ViewModelControlListProperty("Дата рожд.", ColumnWidth = 100, DefaultCellStyleFormat = "dd.MM.yyyy")]
[ViewModelControlElementProperty("Дата рожд.", ControlType.ControlDateTime, MustHaveValue = true )]
[MapConfiguration("DateBirth", AllowCopyWithoutRigth = false)]
public DateTime DateBirth { get; set; }
- [ViewModelControlListProperty("Адрес", 90)]
+ [ViewModelControlListProperty("Адрес", ColumnWidth = 90)]
[ViewModelControlElementProperty("Адрес", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("Address", AllowCopyWithoutRigth = false)]
public string Address { get; set; }
- [ViewModelControlListProperty("Эл. почта", 90)]
+ [ViewModelControlListProperty("Эл. почта", ColumnWidth = 90)]
[ViewModelControlElementProperty("Эл. почта", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("Email", AllowCopyWithoutRigth = false)]
public string Email { get; set; }
- [ViewModelControlListProperty("Моб. номер", 100)]
+ [ViewModelControlListProperty("Моб. номер", ColumnWidth = 100)]
[ViewModelControlElementProperty("Моб. номер", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("MobileNumber", AllowCopyWithoutRigth = false)]
public string MobileNumber { get; set; }
- [ViewModelControlListProperty("Дом. номер", 100)]
+ [ViewModelControlListProperty("Дом. номер", ColumnWidth = 100)]
[ViewModelControlElementProperty("Дом. номер", ControlType.ControlString)]
[MapConfiguration("HomeNumber", AllowCopyWithoutRigth = false)]
public string HomeNumber { get; set; }
@@ -73,7 +73,7 @@ namespace DepartmentBusinessLogic.ViewModels
[MapConfiguration("Photo")]
public byte[] Photo { get; set; }
- [ViewModelControlListProperty("Гр. эл.без.", 90)]
+ [ViewModelControlListProperty("Гр. эл.без.", ColumnWidth = 90)]
[ViewModelControlElementProperty("Группа эл.безоп", ControlType.ControlString, MustHaveValue = true)]
[MapConfiguration("GroupElectricalSafety")]
public string GroupElectricalSafety { get; set; }
diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs
index 0627066..105e6b9 100644
--- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs
+++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/AccessViewModels.cs
@@ -20,7 +20,7 @@ namespace SecurityBusinessLogic.ViewModels
[ViewModelControlElementProperty("Роль", ControlType.ControlGuid, MustHaveValue = true, ReadOnly = true, ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlRoleList, SecurityWindowsDesktop")]
public Guid RoleId { get; set; }
- [ViewModelControlListProperty("Роль", 100)]
+ [ViewModelControlListProperty("Роль", ColumnWidth = 100)]
[MapConfiguration("Role.RoleName", IsDifficle = true, AllowCopyWithoutRigth = false)]
public string RoleName { get; set; }
@@ -35,7 +35,7 @@ namespace SecurityBusinessLogic.ViewModels
[ViewModelControlElementProperty("Тип", ControlType.ControlEnum, MustHaveValue = true)]
public AccessType AccessType { get; set; }
- [ViewModelControlListProperty("Тип", 150)]
+ [ViewModelControlListProperty("Тип", ColumnWidth = 150)]
public string AccessTypeTitle => AccessType switch
{
AccessType.Delete => "Полные права",
diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs
index dd08b4b..62bb806 100644
--- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs
+++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/RoleViewModels.cs
@@ -24,7 +24,7 @@ namespace SecurityBusinessLogic.ViewModels
[MapConfiguration("RoleName")]
public string RoleName { get; set; }
- [ViewModelControlListProperty("Приоритет", 100)]
+ [ViewModelControlListProperty("Приоритет", ColumnWidth = 100)]
[ViewModelControlElementProperty("Приоритет", ControlType.ControlInt, MustHaveValue = true)]
[MapConfiguration("RolePriority")]
public int RolePriority { get; set; }
diff --git a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs
index ff359d3..11694ee 100644
--- a/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs
+++ b/DepartmentPortal/Security/SecurityBusinessLogic/ViewModels/UserViewModels.cs
@@ -5,54 +5,54 @@ using System;
namespace SecurityBusinessLogic.ViewModels
{
- ///
- /// Список пользователей
- ///
+ ///
+ /// Список пользователей
+ ///
public class UserListViewModel : ListViewModel { }
- ///
- /// Элемент пользователей
- ///
+ ///
+ /// Элемент пользователей
+ ///
[ViewModelControlElementClass(HaveDependenceEntities = true, Width = 800, Height = 500)]
- [ViewModelControlElementDependenceEntity(Title = "Роли", Order = 1, ParentPropertyName = "UserId",
- ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlUserRoleList, SecurityWindowsDesktop")]
- public class UserViewModel : ElementViewModel
- {
- [ViewModelControlListProperty("Пользователь")]
- [ViewModelControlElementProperty("Логин", ControlType.ControlString, MustHaveValue = true)]
- [MapConfiguration("UserName")]
- public string Login { get; set; }
+ [ViewModelControlElementDependenceEntity(Title = "Роли", Order = 1, ParentPropertyName = "UserId",
+ ControlTypeObject = "SecurityWindowsDesktop.EntityControls.ControlUserRoleList, SecurityWindowsDesktop")]
+ public class UserViewModel : ElementViewModel
+ {
+ [ViewModelControlListProperty("Пользователь")]
+ [ViewModelControlElementProperty("Логин", ControlType.ControlString, MustHaveValue = true)]
+ [MapConfiguration("UserName")]
+ public string Login { get; set; }
- [MapConfiguration("PasswordHash", AllowCopyWithoutRigth = false)]
- public string Password { get; set; }
+ [MapConfiguration("PasswordHash", AllowCopyWithoutRigth = false)]
+ public string Password { get; set; }
- [MapConfiguration("Avatar")]
- [ViewModelControlElementProperty("Фото", ControlType.ControlImage, Width = 200, Height = 200)]
- public byte[] Avatar { get; set; }
+ [MapConfiguration("Avatar")]
+ [ViewModelControlElementProperty("Фото", ControlType.ControlImage, Width = 200, Height = 200)]
+ public byte[] Avatar { get; set; }
- [ViewModelControlListProperty("Посл. визит", 100)]
- [MapConfiguration("DateLastVisit")]
- public DateTime? DateLastVisit { get; set; }
+ [ViewModelControlListProperty("Посл. визит", ColumnWidth = 100, DefaultCellStyleFormat = "dd.MM.yyyy")]
+ [MapConfiguration("DateLastVisit")]
+ public DateTime? DateLastVisit { get; set; }
- [MapConfiguration("IsBanned", AllowCopyWithoutRigth = false)]
- [ViewModelControlElementProperty("Заблокирован", ControlType.ControlBool, MustHaveValue = true)]
- public bool IsBanned { get; set; }
+ [MapConfiguration("IsBanned", AllowCopyWithoutRigth = false)]
+ [ViewModelControlElementProperty("Заблокирован", ControlType.ControlBool, MustHaveValue = true)]
+ public bool IsBanned { get; set; }
- [ViewModelControlListProperty("Блокир.", 80)]
- public string Banned => IsBanned ? "Да" : "Нет";
+ [ViewModelControlListProperty("Блокир.", ColumnWidth = 80)]
+ public string Banned => IsBanned ? "Да" : "Нет";
- [MapConfiguration("DateBanned", AllowCopyWithoutRigth = false)]
- [ViewModelControlElementProperty("Дата блокировки", ControlType.ControlDateTime, ReadOnly = true)]
- public DateTime? DateBanned { get; set; }
+ [MapConfiguration("DateBanned", AllowCopyWithoutRigth = false)]
+ [ViewModelControlElementProperty("Дата блокировки", ControlType.ControlDateTime, ReadOnly = true)]
+ public DateTime? DateBanned { get; set; }
- [ViewModelControlListProperty("Дата Б.", 100)]
- public string DateBannedTitle => DateBanned.HasValue ? DateBanned.Value.ToShortDateString() : string.Empty;
+ [ViewModelControlListProperty("Дата Б.", ColumnWidth = 100)]
+ public string DateBannedTitle => DateBanned.HasValue ? DateBanned.Value.ToShortDateString() : string.Empty;
- [MapConfiguration("CountAttempt", AllowCopyWithoutRigth = false)]
- [ViewModelControlElementProperty("Попытки входа", ControlType.ControlInt , ReadOnly = true)]
- public int CountAttempt { get; set; }
+ [MapConfiguration("CountAttempt", AllowCopyWithoutRigth = false)]
+ [ViewModelControlElementProperty("Попытки входа", ControlType.ControlInt, ReadOnly = true)]
+ public int CountAttempt { get; set; }
- public override string ToString() => Login;
+ public override string ToString() => Login;
- }
+ }
}
\ No newline at end of file