работа с datagridview

This commit is contained in:
Мк Игорь 2023-05-09 13:36:18 +04:00
parent a33e89a0dd
commit 4860a2940c
10 changed files with 62 additions and 77 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)
{

View File

@ -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)
{

View File

@ -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)

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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<int, (IComponentModel, int)> 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<int, (IComponentModel, int)> ManufactureComponents { get; set; } = new();
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}