исправления

This commit is contained in:
sardq 2024-05-16 19:02:46 +04:00
parent 8f1bcf00fc
commit 8cf0e3d114
9 changed files with 31 additions and 26 deletions

View File

@ -12,16 +12,19 @@
public GridViewAutoSize GridViewAutoSize { get; private set; } public GridViewAutoSize GridViewAutoSize { get; private set; }
public bool IsUseAutoSize { get; private set; } public bool IsUseAutoSize { get; private set; }
public string Format { get; private set; } public bool FormattedDate { get; private set; }
public bool FormattedNumber { get; private set; }
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false, string format = "")
public ColumnAttribute(string title = "", bool visible = true, int width = 0, GridViewAutoSize gridViewAutoSize = GridViewAutoSize.None, bool isUseAutoSize = false, bool formatDate = false, bool formattedNumber = false)
{ {
Title = title; Title = title;
Visible = visible; Visible = visible;
Width = width; Width = width;
GridViewAutoSize = gridViewAutoSize; GridViewAutoSize = gridViewAutoSize;
IsUseAutoSize = isUseAutoSize; IsUseAutoSize = isUseAutoSize;
Format = format; FormattedDate = formatDate;
} FormattedNumber = formattedNumber;
}
} }
} }

View File

@ -12,7 +12,7 @@ namespace PlumbingRepairContracts.ViewModels
[Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] [Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string ComponentName { get; set; } = string.Empty; public string ComponentName { get; set; } = string.Empty;
[Column(title: "Цена", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] [Column(title: "Цена", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true, formattedNumber: true)]
public double Cost { get; set; } public double Cost { get; set; }
} }
} }

View File

@ -12,7 +12,7 @@ namespace PlumbingRepairContracts.ViewModels
public int? ClientId { get; set; } public int? ClientId { get; set; }
[Column(title: "Отправитель", width: 150)] [Column(title: "Отправитель", width: 150)]
public string SenderName { get; set; } = string.Empty; public string SenderName { get; set; } = string.Empty;
[Column(title: "Дата отправления", width: 150, format: "Date: dd/MM/yyyy")] [Column(title: "Дата отправления", width: 150, formatDate: true)]
public DateTime DateDelivery { get; set; } public DateTime DateDelivery { get; set; }
[Column(title: "Заголовок", width: 150)] [Column(title: "Заголовок", width: 150)]
public string Subject { get; set; } = string.Empty; public string Subject { get; set; } = string.Empty;

View File

@ -30,16 +30,16 @@ namespace PlumbingRepairContracts.ViewModels
[Column(title: "Количество", width: 150)] [Column(title: "Количество", width: 150)]
public int Count { get; set; } public int Count { get; set; }
[Column(title: "Сумма", width: 150)] [Column(title: "Сумма", width: 150, formattedNumber: true)]
public double Sum { get; set; } public double Sum { get; set; }
[Column(title: "Статус", width: 150)] [Column(title: "Статус", width: 150)]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[Column(title: "Дата создания", width: 150, format: "Date: dd/MM/yyyy")] [Column(title: "Дата создания", width: 150, formatDate: true)]
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
[Column(title: "Дата выполнения", width: 150, format: "Date: dd/MM/yyyy")] [Column(title: "Дата выполнения", width: 150, formatDate: true)]
public DateTime? DateImplement { get; set; } public DateTime? DateImplement { get; set; }
} }
} }

View File

@ -16,9 +16,10 @@ namespace PlumbingRepairContracts.ViewModels
public string Address { get; set; } = string.Empty; public string Address { get; set; } = string.Empty;
[Column(title: "Максимальное количество работ", width: 150)] [Column(title: "Максимальное количество работ", width: 150)]
public int maxCountWorks { get; set; } public int maxCountWorks { get; set; }
[Column(title: "Дата открытия", width: 150, format: "Date: dd/MM/yyyy")] [Column(title: "Дата открытия", width: 150, formatDate: true)]
public DateTime DateOpening { get; set; } public DateTime DateOpening { get; set; }
public Dictionary<int, (IWorkModel, int)> ShopWorks { get; set; } = new(); [Column(visible: false)]
public Dictionary<int, (IWorkModel, int)> ShopWorks { get; set; } = new();
} }
} }

View File

@ -12,7 +12,7 @@ namespace PlumbingRepairContracts.ViewModels
[Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] [Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
public string WorkName { get; set; } = string.Empty; public string WorkName { get; set; } = string.Empty;
[Column(title: "Цена", width: 150)] [Column(title: "Цена", width: 150, formattedNumber: true)]
public double Price { get; set; } public double Price { get; set; }
[Column(visible: false)] [Column(visible: false)]
public Dictionary<int, (IComponentModel, int)> WorkComponents { get; set; } = new(); public Dictionary<int, (IComponentModel, int)> WorkComponents { get; set; } = new();

View File

@ -39,7 +39,15 @@ namespace PlumbingRepairView
{ {
column.Width = columnAttr.Width; column.Width = columnAttr.Width;
} }
} if (columnAttr.FormattedDate && (column.ValueType == typeof(DateTime) || column.ValueType == typeof(DateTime?)))
{
column.DefaultCellStyle.Format = "dd MMMM yy, HH:mm:ss";
}
if (columnAttr.FormattedNumber && column.ValueType == typeof(double))
{
column.DefaultCellStyle.Format = "N2";
}
}
} }
} }
} }

View File

@ -27,16 +27,8 @@ namespace PlumbingRepairView
{ {
try try
{ {
var list = _logic.ReadList(null); dataGridView.FillAndConfigGrid(_logic.ReadList(null));
if (list != null) _logger.LogInformation("Загрузка магазинов");
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ShopWorks"].Visible = false;
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка магазинов");
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -1,10 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
using PlumbingRepairBusinessLogic.BusinessLogics; using PlumbingRepairBusinessLogic.BusinessLogics;
using PlumbingRepairContracts.BusinessLogicsContracts; using PlumbingRepairContracts.BusinessLogicsContracts;
using PlumbingRepairContracts.StoragesContracts;
using PlumbingRepairFileImplement.Implements;
using PlumbingRepairBusinessLogic.OfficePackage; using PlumbingRepairBusinessLogic.OfficePackage;
using PlumbingRepairBusinessLogic.OfficePackage.Implements; using PlumbingRepairBusinessLogic.OfficePackage.Implements;
using PlumbingRepairBusinessLogic.MailWorker; using PlumbingRepairBusinessLogic.MailWorker;
@ -69,6 +66,7 @@ namespace PlumbingRepairView
DependencyManager.Instance.RegisterType<FormComponents>(); DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>(); DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormWork>(); DependencyManager.Instance.RegisterType<FormWork>();
DependencyManager.Instance.RegisterType<FormWorkComponent>();
DependencyManager.Instance.RegisterType<FormWorks>(); DependencyManager.Instance.RegisterType<FormWorks>();
DependencyManager.Instance.RegisterType<FormReportShopWorks>(); DependencyManager.Instance.RegisterType<FormReportShopWorks>();
DependencyManager.Instance.RegisterType<FormReportWorkComponents>(); DependencyManager.Instance.RegisterType<FormReportWorkComponents>();
@ -78,6 +76,9 @@ namespace PlumbingRepairView
DependencyManager.Instance.RegisterType<FormImplementer>(); DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMail>(); DependencyManager.Instance.RegisterType<FormMail>();
DependencyManager.Instance.RegisterType<FormMails>(); DependencyManager.Instance.RegisterType<FormMails>();
DependencyManager.Instance.RegisterType<FormShops>();
DependencyManager.Instance.RegisterType<FormShop>();
} }
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck(); private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();