исправления

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 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;
Visible = visible;
Width = width;
GridViewAutoSize = gridViewAutoSize;
IsUseAutoSize = isUseAutoSize;
Format = format;
FormattedDate = formatDate;
FormattedNumber = formattedNumber;
}
}
}

View File

@ -12,7 +12,7 @@ namespace PlumbingRepairContracts.ViewModels
[Column(title: "Название компонента", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]
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; }
}
}

View File

@ -12,7 +12,7 @@ namespace PlumbingRepairContracts.ViewModels
public int? ClientId { get; set; }
[Column(title: "Отправитель", width: 150)]
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; }
[Column(title: "Заголовок", width: 150)]
public string Subject { get; set; } = string.Empty;

View File

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

View File

@ -16,8 +16,9 @@ namespace PlumbingRepairContracts.ViewModels
public string Address { get; set; } = string.Empty;
[Column(title: "Максимальное количество работ", width: 150)]
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; }
[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)]
public string WorkName { get; set; } = string.Empty;
[Column(title: "Цена", width: 150)]
[Column(title: "Цена", width: 150, formattedNumber: true)]
public double Price { get; set; }
[Column(visible: false)]
public Dictionary<int, (IComponentModel, int)> WorkComponents { get; set; } = new();

View File

@ -38,6 +38,14 @@ namespace PlumbingRepairView
else
{
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,15 +27,7 @@ namespace PlumbingRepairView
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ShopWorks"].Visible = false;
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка магазинов");
}
catch (Exception ex)

View File

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