2023-01-30 09:20:55 +04:00
|
|
|
|
using LawFirm;
|
2023-03-11 20:24:11 +04:00
|
|
|
|
using LawFirmBusinessLogic.BusinessLogics;
|
2023-01-30 09:20:55 +04:00
|
|
|
|
using LawFirmContracts.BindingModels;
|
|
|
|
|
using LawFirmContracts.BusinessLogicContracts;
|
|
|
|
|
using LawFirmDataModels.Enums;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System;
|
2023-01-29 19:37:04 +04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace LawFirmView
|
|
|
|
|
{
|
2023-01-30 09:20:55 +04:00
|
|
|
|
|
2023-01-29 19:37:04 +04:00
|
|
|
|
public partial class FormMain : Form
|
|
|
|
|
{
|
2023-01-30 09:20:55 +04:00
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
private readonly IOrderLogic _orderLogic;
|
2023-03-11 20:24:11 +04:00
|
|
|
|
private readonly IReportLogic _reportLogic;
|
2023-04-08 13:43:04 +04:00
|
|
|
|
private readonly IWorkProcess _workProcess;
|
|
|
|
|
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess)
|
2023-01-29 19:37:04 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2023-01-30 09:20:55 +04:00
|
|
|
|
_logger = logger;
|
|
|
|
|
_orderLogic = orderLogic;
|
2023-03-11 20:24:11 +04:00
|
|
|
|
_reportLogic = reportLogic;
|
2023-04-08 13:43:04 +04:00
|
|
|
|
_workProcess = workProcess;
|
2023-01-30 09:20:55 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FormMain_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
private void LoadData()
|
|
|
|
|
{
|
|
|
|
|
_logger.LogInformation("Загрузка заказов");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var list = _orderLogic.ReadList(null);
|
|
|
|
|
if (list != null)
|
|
|
|
|
{
|
|
|
|
|
dataGridView.DataSource = list;
|
|
|
|
|
dataGridView.Columns["DocumentId"].Visible = false;
|
2023-03-25 18:09:34 +04:00
|
|
|
|
dataGridView.Columns["ClientId"].Visible = false;
|
2023-04-08 13:43:04 +04:00
|
|
|
|
dataGridView.Columns["ImplementerId"].Visible = false;
|
2023-01-30 09:20:55 +04:00
|
|
|
|
}
|
|
|
|
|
_logger.LogInformation("Загрузка заказов");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка загрузки заказов");
|
|
|
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void бланкиToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormBlanks));
|
|
|
|
|
if (service is FormBlanks form)
|
|
|
|
|
{
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void документыToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormDocuments));
|
|
|
|
|
if (service is FormDocuments form)
|
|
|
|
|
{
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-25 18:09:34 +04:00
|
|
|
|
private void клиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
|
|
|
|
if (service is FormClients form)
|
|
|
|
|
{
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-08 13:43:04 +04:00
|
|
|
|
private void исполнителиToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
|
|
|
|
|
if (service is FormImplementers form)
|
|
|
|
|
{
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-11 14:29:44 +04:00
|
|
|
|
private void бланкиПоДокументамToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks));
|
|
|
|
|
if (service is FormReportDocumentBlanks form)
|
|
|
|
|
{
|
|
|
|
|
form.ShowDialog();
|
2023-03-11 17:17:29 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormReportOrder));
|
|
|
|
|
if (service is FormReportOrder form)
|
|
|
|
|
{
|
|
|
|
|
form.ShowDialog();
|
2023-03-11 14:29:44 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-11 20:24:11 +04:00
|
|
|
|
private void списокДокументовToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
|
|
|
|
if (dialog.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
_reportLogic.SaveDocumentsToWordFile(new ReportBindingModel
|
|
|
|
|
{
|
|
|
|
|
FileName = dialog.FileName
|
|
|
|
|
});
|
|
|
|
|
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-30 09:20:55 +04:00
|
|
|
|
private void buttonCreateOrder_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
|
|
|
|
if (service is FormCreateOrder form)
|
|
|
|
|
{
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonSetToFinish_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (dataGridView.SelectedRows.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
|
|
|
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
|
|
|
|
{
|
2023-02-13 08:57:11 +04:00
|
|
|
|
Id = id
|
2023-01-30 09:20:55 +04:00
|
|
|
|
});
|
|
|
|
|
if (!operationResult)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
|
|
|
|
}
|
|
|
|
|
_logger.LogInformation("Заказ №{id} выдан", id);
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
|
|
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void buttonUpdate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoadData();
|
2023-01-29 19:37:04 +04:00
|
|
|
|
}
|
2023-04-08 13:43:04 +04:00
|
|
|
|
|
|
|
|
|
private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
_workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
|
|
|
|
|
MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
|
|
|
|
|
}
|
2023-01-29 19:37:04 +04:00
|
|
|
|
}
|
|
|
|
|
}
|