diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs index 2a3849a..ada7462 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormComponents.cs @@ -23,13 +23,7 @@ namespace BlacksmithWorkshopView { try { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } + dataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка компонентов"); } catch (Exception ex) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs index bc321d5..3eec99a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormImplementers.cs @@ -23,13 +23,7 @@ namespace BlacksmithWorkshopView { try { - var list = _implementerLogic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - //dataGridView.Columns["Id"].Visible = false; - //dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } + dataGridView.FillandConfigGrid(_implementerLogic.ReadList(null)); _logger.LogInformation("Загрузка сотрудников"); } catch (Exception ex) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.cs index 13936eb..3e69517 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMails.cs @@ -18,10 +18,7 @@ namespace BlacksmithWorkshopView try { _logger.LogInformation("Загрузка списка писем"); - dataGridView.DataSource = _messageLogic.ReadList(null); - dataGridView.Columns["MessageId"].Visible = false; - dataGridView.Columns["ClientId"].Visible = false; - dataGridView.Columns["Body"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.FillandConfigGrid(_messageLogic.ReadList(null)); } catch (Exception ex) { diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index 418b6ca..d12c208 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -34,15 +34,7 @@ namespace BlacksmithWorkshopView _logger.LogInformation("Загрузка заказов"); try { - var list = _orderLogic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["ManufactureId"].Visible = false; - dataGridView.Columns["ImplementerId"].Visible = false; - dataGridView.Columns["ClientId"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - } + dataGridView.FillandConfigGrid(_orderLogic.ReadList(null)); } catch (Exception ex) { diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs index 69339dd..941a1fa 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormManufactures.cs @@ -23,14 +23,7 @@ namespace BlacksmithWorkshopView { try { - var list = _logic.ReadList(null); - if (list != null) - { - dataGridView.DataSource = list; - dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - dataGridView.Columns["ManufactureComponents"].Visible = false; - } + dataGridView.FillandConfigGrid(_logic.ReadList(null)); _logger.LogInformation("Загрузка компонентов"); } catch (Exception ex) diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ComponentViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ComponentViewModel.cs index 945cc46..32b1a67 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ComponentViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ComponentViewModel.cs @@ -1,14 +1,16 @@ -using BlacksmithWorkshopDataModels.Models; +using BlacksmithWorkshopContracts.Attributes; +using BlacksmithWorkshopDataModels.Models; using System.ComponentModel; namespace BlacksmithWorkshopContracts.ViewModels { public class ComponentViewModel : IComponentModel { - public int Id { get; set; } - [DisplayName("Название компонента")] - public string ComponentName { get; set; } = string.Empty; - [DisplayName("Цена")] - public double Cost { get; set; } + [Column(visible: false)] + public int Id { get; set; } + [Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] + public string ComponentName { get; set; } = string.Empty; + [Column(title: "Цена", gridViewAutoSize: GridViewAutoSize.ColumnHeader, width: 150)] + public double Cost { get; set; } } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ImplementerViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ImplementerViewModel.cs index 4a9acfd..08bc925 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ImplementerViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ImplementerViewModel.cs @@ -1,18 +1,20 @@ -using BlacksmithWorkshopDataModels.Models; +using BlacksmithWorkshopContracts.Attributes; +using BlacksmithWorkshopDataModels.Models; using System.ComponentModel; namespace BlacksmithWorkshopContracts.ViewModels { public class ImplementerViewModel : IImplementerModel { + [Column(visible: false)] public int Id { get; set; } - [DisplayName("Имя")] + [Column(title: "Имя", width: 150, gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; - [DisplayName("Пароль")] + [Column(title: "Пароль", width: 150)] public string Password { get; set; } = string.Empty; - [DisplayName("Опыт")] + [Column(title: "Опыт", width: 150)] public int WorkExperience { get; set; } - [DisplayName("Квалификация")] + [Column(title: "Квалификация", width: 150)] public int Qualification { get; set; } } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs index 25732a6..f9c86fb 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ManufactureViewModel.cs @@ -1,15 +1,18 @@ -using BlacksmithWorkshopDataModels.Models; +using BlacksmithWorkshopContracts.Attributes; +using BlacksmithWorkshopDataModels.Models; using System.ComponentModel; namespace BlacksmithWorkshopContracts.ViewModels { public class ManufactureViewModel : IManufactureModel { - public int Id { get; set; } - [DisplayName("Название изделия")] - public string ManufactureName { get; set; } = string.Empty; - [DisplayName("Цена")] - public double Price { get; set; } - public Dictionary ManufactureComponents { get; set; } = new(); + [Column(visible: false)] + public int Id { get; set; } + [Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] + public string ManufactureName { get; set; } = string.Empty; + [Column(title: "Цена", gridViewAutoSize: GridViewAutoSize.ColumnHeader, width: 150)] + public double Price { get; set; } + [Column(visible: false)] + public Dictionary ManufactureComponents { get; set; } = new(); } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs index 1957662..1708292 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/MessageInfoViewModel.cs @@ -1,20 +1,24 @@ -using BlacksmithWorkshopDataModels.Models; +using BlacksmithWorkshopContracts.Attributes; +using BlacksmithWorkshopDataModels.Models; using System.ComponentModel; namespace BlacksmithWorkshopContracts.ViewModels { public class MessageInfoViewModel : IMessageInfoModel { + [Column(visible: false)] public int Id { get; set; } + [Column(visible: false)] public string MessageId { get; set; } = string.Empty; + [Column(visible: false)] public int? ClientId { get; set; } - [DisplayName("Отправитель")] + [Column(title: "Отправитель", width: 150)] public string SenderName { get; set; } = string.Empty; - [DisplayName("Дата")] + [Column(title: "Дата", width: 150)] public DateTime DateDelivery { get; set; } = DateTime.Now; - [DisplayName("Заголовок")] + [Column(title: "Заголовок", width: 150)] public string Subject { get; set; } = string.Empty; - [DisplayName("Текст")] + [Column(title: "Текст", width: 150, gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Body { get; set; } = string.Empty; } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs index 8e6e8e3..e9d2f78 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/OrderViewModel.cs @@ -1,4 +1,5 @@ -using BlacksmithWorkshopDataModels.Enums; +using BlacksmithWorkshopContracts.Attributes; +using BlacksmithWorkshopDataModels.Enums; using BlacksmithWorkshopDataModels.Models; using System.ComponentModel; @@ -6,26 +7,29 @@ namespace BlacksmithWorkshopContracts.ViewModels { public class OrderViewModel : IOrderModel { - [DisplayName("Номер")] - public int Id { get; set; } - public int ManufactureId { get; set; } - public int ClientId { get; set; } - [DisplayName("Изделие")] - public string ManufactureName { get; set; } = string.Empty; - [DisplayName("Количество")] - public int Count { get; set; } - [DisplayName("Сумма")] - public double Sum { get; set; } - [DisplayName("Статус")] - public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; - [DisplayName("Дата создания")] - public DateTime DateCreate { get; set; } = DateTime.Now; - [DisplayName("Дата выполнения")] - public DateTime? DateImplement { get; set; } - [DisplayName("Клиент")] + [Column(title: "Номер", gridViewAutoSize: GridViewAutoSize.ColumnHeader, width: 100, isUseAutoSize: true)] + public int Id { get; set; } + [Column(visible: false)] + public int ManufactureId { get; set; } + [Column(visible: false)] + public int ClientId { get; set; } + [Column(title: "Изделие", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] + public string ManufactureName { get; set; } = string.Empty; + [Column(title: "Количество", gridViewAutoSize: GridViewAutoSize.ColumnHeader, width: 100)] + public int Count { get; set; } + [Column(title: "Сумма", gridViewAutoSize: GridViewAutoSize.ColumnHeader, width: 100)] + public double Sum { get; set; } + [Column(title: "Статус", gridViewAutoSize: GridViewAutoSize.ColumnHeader, width: 100)] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + [Column(title: "Дата создания", gridViewAutoSize: GridViewAutoSize.ColumnHeader, isUseAutoSize: true)] + public DateTime DateCreate { get; set; } = DateTime.Now; + [Column(title: "Дата выполнения", gridViewAutoSize: GridViewAutoSize.ColumnHeader, isUseAutoSize: true)] + public DateTime? DateImplement { get; set; } + [Column(title: "Клиент", gridViewAutoSize: GridViewAutoSize.ColumnHeader, width: 500, isUseAutoSize: true)] public string ClientFIO { get; set; } = string.Empty; + [Column(visible: false)] public int? ImplementerId { get; set; } - [DisplayName("Исполнитель")] + [Column(title: "Исполнитель", gridViewAutoSize: GridViewAutoSize.ColumnHeader, width: 150, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; } } \ No newline at end of file