Compare commits

...

2 Commits

Author SHA1 Message Date
4860a2940c работа с datagridview 2023-05-09 13:36:18 +04:00
a33e89a0dd работа с бэкапом 2023-05-09 12:39:23 +04:00
14 changed files with 122 additions and 92 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

@ -39,11 +39,12 @@
this.reportManufactureComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.reportOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.doWorkToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mailsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonCreateOrder = new System.Windows.Forms.Button();
this.buttonIssuedOrder = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
this.mailsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.backupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
@ -54,7 +55,8 @@
this.refbooksToolStripMenuItem,
this.reportsToolStripMenuItem,
this.doWorkToolStripMenuItem,
this.mailsToolStripMenuItem});
this.mailsToolStripMenuItem,
this.backupToolStripMenuItem});
this.menuStrip.Location = new System.Drawing.Point(0, 0);
this.menuStrip.Name = "menuStrip";
this.menuStrip.Size = new System.Drawing.Size(1795, 24);
@ -138,6 +140,13 @@
this.doWorkToolStripMenuItem.Text = "Запуск работ";
this.doWorkToolStripMenuItem.Click += new System.EventHandler(this.DoWorkToolStripMenuItem_Click);
//
// mailsToolStripMenuItem
//
this.mailsToolStripMenuItem.Name = "mailsToolStripMenuItem";
this.mailsToolStripMenuItem.Size = new System.Drawing.Size(62, 20);
this.mailsToolStripMenuItem.Text = "Письма";
this.mailsToolStripMenuItem.Click += new System.EventHandler(this.MailsToolStripMenuItem_Click);
//
// dataGridView
//
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
@ -181,12 +190,12 @@
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// mailsToolStripMenuItem
// backupToolStripMenuItem
//
this.mailsToolStripMenuItem.Name = "mailsToolStripMenuItem";
this.mailsToolStripMenuItem.Size = new System.Drawing.Size(62, 20);
this.mailsToolStripMenuItem.Text = "Письма";
this.mailsToolStripMenuItem.Click += new System.EventHandler(this.MailsToolStripMenuItem_Click);
this.backupToolStripMenuItem.Name = "backupToolStripMenuItem";
this.backupToolStripMenuItem.Size = new System.Drawing.Size(51, 20);
this.backupToolStripMenuItem.Text = "Бэкап";
this.backupToolStripMenuItem.Click += new System.EventHandler(this.BackupToolStripMenuItem_Click);
//
// FormMain
//
@ -228,5 +237,6 @@
private ToolStripMenuItem implementersToolStripMenuItem;
private ToolStripMenuItem doWorkToolStripMenuItem;
private ToolStripMenuItem mailsToolStripMenuItem;
private ToolStripMenuItem backupToolStripMenuItem;
}
}

View File

@ -14,7 +14,8 @@ namespace BlacksmithWorkshopView
private readonly IReportLogic _reportLogic;
private readonly IImplementerLogic _implementerLogic;
private readonly IWorkProcess _workProcess;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IImplementerLogic implementerLogic, IMessageInfoLogic messageInfoLogic)
private readonly IBackupLogic _backupLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess, IImplementerLogic implementerLogic, IMessageInfoLogic messageInfoLogic, IBackupLogic backupLogic)
{
InitializeComponent();
_logger = logger;
@ -22,6 +23,7 @@ namespace BlacksmithWorkshopView
_reportLogic = reportLogic;
_workProcess = workProcess;
_implementerLogic = implementerLogic;
_backupLogic = backupLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
@ -32,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)
{
@ -191,5 +185,15 @@ namespace BlacksmithWorkshopView
form.ShowDialog();
LoadData();
}
private void BackupToolStripMenuItem_Click(object sender, EventArgs e)
{
using var dialog = new FolderBrowserDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
_backupLogic.CreateBackup(new() { FolderName = dialog.SelectedPath});
MessageBox.Show("Бэкап сохранен", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
}

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

@ -48,8 +48,7 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics
var assembly = typeIId.Assembly;
if (assembly == null)
{
throw new ArgumentNullException("Сборка не найдена",
nameof(assembly));
throw new ArgumentNullException("Сборка не найдена", nameof(assembly));
}
var types = assembly.GetTypes();
var method = GetType().GetMethod("SaveToFile", BindingFlags.NonPublic | BindingFlags.Instance);

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

View File

@ -0,0 +1,29 @@
using BlacksmithWorkshopContracts.StoragesContracts;
using BlacksmithWorkshopDatabaseImplement.Implements;
namespace BlacksmithWorkshopDatabaseImplement
{
public class BackupInfo : IBackupInfo
{
public List<T>? GetList<T>() where T : class, new()
{
using var context = new BlacksmithWorkshopDatabase();
return context.Set<T>().ToList();
}
public Type? GetTypeByModelInterface(string modelInterfaceName)
{
var assembly = typeof(BackupInfo).Assembly;
var types = assembly.GetTypes();
foreach (var type in types)
{
if (type.IsClass &&
type.GetInterface(modelInterfaceName) != null)
{
return type;
}
}
return null;
}
}
}

View File

@ -1,9 +1,4 @@
using BlacksmithWorkshopContracts.StoragesContracts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BlacksmithWorkshopListImplement.Implements
{