2024-11-06 02:29:24 +04:00
|
|
|
|
using ComponentsLibraryNet60.DocumentWithChart;
|
|
|
|
|
using ComponentsLibraryNet60.Models;
|
|
|
|
|
using Contracts.BindlingModels;
|
|
|
|
|
using Contracts.BusinessLogicContracts;
|
|
|
|
|
using Contracts.ViewModels;
|
|
|
|
|
using Controls;
|
|
|
|
|
using ControlsLibraryNet60.Data;
|
|
|
|
|
using ControlsLibraryNet60.Models;
|
|
|
|
|
using CustomComponents;
|
|
|
|
|
using System;
|
2024-09-06 00:43:56 +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 Forms
|
|
|
|
|
{
|
|
|
|
|
public partial class FormMain : Form
|
|
|
|
|
{
|
2024-11-06 02:29:24 +04:00
|
|
|
|
private readonly IDeliveryLogic _dlogic;
|
|
|
|
|
private readonly IDeliveryTypeLogic _dtlogic;
|
|
|
|
|
public FormMain(IDeliveryLogic dLogic, IDeliveryTypeLogic dtLogic)
|
2024-09-06 00:43:56 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2024-11-06 02:29:24 +04:00
|
|
|
|
_dlogic = dLogic;
|
|
|
|
|
_dtlogic = dtLogic;
|
|
|
|
|
TreeConfig();
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void TreeConfig()
|
|
|
|
|
{
|
|
|
|
|
DataTreeNodeConfig treeConfig = new();
|
|
|
|
|
treeConfig.NodeNames = new();
|
|
|
|
|
treeConfig.NodeNames.Enqueue("Id");
|
|
|
|
|
treeConfig.NodeNames.Enqueue("FCs");
|
|
|
|
|
treeConfig.NodeNames.Enqueue("Wishes");
|
|
|
|
|
treeConfig.NodeNames.Enqueue("DeliveryType");
|
|
|
|
|
treeConfig.NodeNames.Enqueue("DeliveryDate");
|
|
|
|
|
|
|
|
|
|
controlDataTreeTable.LoadConfig(treeConfig);
|
|
|
|
|
}
|
|
|
|
|
private void LoadData()
|
|
|
|
|
{
|
|
|
|
|
var list = _dlogic.ReadList(null);
|
|
|
|
|
if (list != null)
|
|
|
|
|
{
|
|
|
|
|
controlDataTreeTable.Clear();
|
|
|
|
|
controlDataTreeTable.AddTable(list);
|
|
|
|
|
}
|
2024-09-06 00:43:56 +04:00
|
|
|
|
}
|
2024-10-06 18:45:39 +04:00
|
|
|
|
|
2024-11-05 22:04:24 +04:00
|
|
|
|
private void созданиеТипаДоставкиToolStripMenuItem_Click(object sender, EventArgs e)
|
2024-09-06 00:43:56 +04:00
|
|
|
|
{
|
2024-11-05 22:04:24 +04:00
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(DeliveryTypeForm));
|
|
|
|
|
if (service is DeliveryTypeForm form)
|
2024-10-06 18:45:39 +04:00
|
|
|
|
{
|
2024-11-05 22:04:24 +04:00
|
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
2024-10-06 17:39:02 +04:00
|
|
|
|
}
|
2024-11-06 02:29:24 +04:00
|
|
|
|
|
|
|
|
|
private void созданиеДоставкиToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(DeliveryForm));
|
|
|
|
|
if (service is DeliveryForm form)
|
|
|
|
|
{
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void editProviderToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<DeliveryViewModel>()?.Id);
|
|
|
|
|
DeliveryForm form = new DeliveryForm(_dlogic, _dtlogic, id);
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void deleteProviderToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var confirmResult = MessageBox.Show("Вы действительно хотите удалить запись?", "Подтвердите действие",
|
|
|
|
|
MessageBoxButtons.YesNo,
|
|
|
|
|
MessageBoxIcon.Question
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (confirmResult == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
_dlogic.Delete(new DeliveryBindingModel
|
|
|
|
|
{
|
|
|
|
|
Id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<DeliveryViewModel>()?.Id),
|
|
|
|
|
});
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void FormMain_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void pDFДокументToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
|
|
|
saveFileDialog.ShowDialog();
|
|
|
|
|
string path = saveFileDialog.FileName + ".pdf";
|
|
|
|
|
var list = _dlogic.ReadList(null);
|
|
|
|
|
if (list != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
if (item.DeliveryDate == "Даты доставки нет") i++;
|
|
|
|
|
}
|
|
|
|
|
string[] strings = new string[i];
|
|
|
|
|
int j = 0;
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
if (item.DeliveryDate == "Даты доставки нет") { strings[j] = ($"{item.FCs} : {item.Wishes}"); j++; }
|
|
|
|
|
}
|
|
|
|
|
largeTextComponent.CreateDocument(path, $"Отчет по доставкам без даты:", strings);
|
|
|
|
|
MessageBox.Show("Отчет готов");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void wordДиаграммаToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
|
|
|
saveFileDialog.ShowDialog();
|
|
|
|
|
string path = saveFileDialog.FileName + ".docx";
|
|
|
|
|
var list = _dlogic.ReadList(null);
|
|
|
|
|
var data = new List<(int Date, double Value)> { };
|
|
|
|
|
string header = "График доставок известной даты\n";
|
|
|
|
|
var chart = new Dictionary<string, List<(int Date, double Value)>> { };
|
|
|
|
|
int index = 1;
|
|
|
|
|
foreach (var type in _dtlogic.ReadList(null)!)
|
|
|
|
|
{
|
|
|
|
|
int sum = 0;
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
if (item.DeliveryType == type.Name)
|
|
|
|
|
{
|
|
|
|
|
sum++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
header += $"{index} - {type.Name}\n";
|
|
|
|
|
if (sum != 0) data.Add((index, sum));
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
chart.Add("ИП", data);
|
|
|
|
|
var conf = new ComponentDocumentWithChartConfig
|
|
|
|
|
{
|
|
|
|
|
FilePath = path,
|
|
|
|
|
Header = header,
|
|
|
|
|
ChartTitle = "Диаграмма по типам доставок",
|
|
|
|
|
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
|
|
|
|
|
Data = chart,
|
|
|
|
|
};
|
|
|
|
|
componentDocumentWithChartPieWord.CreateDoc(conf);
|
|
|
|
|
MessageBox.Show("Отчет готов");
|
|
|
|
|
}
|
2024-09-06 00:43:56 +04:00
|
|
|
|
}
|
|
|
|
|
}
|