2024-11-18 20:15:31 +04:00
|
|
|
|
using Contracts.BindlingModels;
|
2024-11-06 02:29:24 +04:00
|
|
|
|
using Contracts.BusinessLogicContracts;
|
|
|
|
|
using Contracts.ViewModels;
|
|
|
|
|
using Controls;
|
|
|
|
|
using ControlsLibraryNet60.Data;
|
|
|
|
|
using ControlsLibraryNet60.Models;
|
|
|
|
|
using CustomComponents;
|
2024-11-18 20:15:31 +04:00
|
|
|
|
using CustomComponents.NonViewComponents.Enums;
|
|
|
|
|
using CustomComponents.NonViewComponents.SupportClasses;
|
|
|
|
|
using CustomComponents.NonViewComponents;
|
2024-11-06 02:29:24 +04:00
|
|
|
|
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;
|
2024-11-18 20:15:31 +04:00
|
|
|
|
using DatabaseImplement.Models;
|
|
|
|
|
using ComponentsLibraryNet60.DocumentWithTable;
|
|
|
|
|
using ComponentsLibraryNet60.Models;
|
|
|
|
|
using NotVisualComponent.Models;
|
|
|
|
|
using NotVisualComponent;
|
2024-09-06 00:43:56 +04:00
|
|
|
|
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);
|
2024-11-18 20:15:31 +04:00
|
|
|
|
var data = list
|
|
|
|
|
.Where(x => x.DeliveryDate != "Даты доставки нет")
|
|
|
|
|
.GroupBy(x => x.DeliveryType)
|
|
|
|
|
.Select(g => (type: g.Key, Value: g.Count()))
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
var categoriesX = data.Select(d => d.type).ToList();
|
|
|
|
|
var valuesY = data.Select(d => (double)d.Value).ToList();
|
|
|
|
|
|
|
|
|
|
var series = new List<SeriesData>
|
2024-11-06 02:29:24 +04:00
|
|
|
|
{
|
2024-11-18 20:15:31 +04:00
|
|
|
|
new()
|
2024-11-06 02:29:24 +04:00
|
|
|
|
{
|
2024-11-18 20:15:31 +04:00
|
|
|
|
SeriesName = "Количество доставок",
|
|
|
|
|
ValuesY = valuesY,
|
|
|
|
|
Color = Color.FromArgb(100, 150, 200)
|
2024-11-06 02:29:24 +04:00
|
|
|
|
}
|
2024-11-18 20:15:31 +04:00
|
|
|
|
};
|
|
|
|
|
pieChartWord1.CreateDiagramDocument(new PieChartData()
|
|
|
|
|
{
|
|
|
|
|
FileName = path,
|
|
|
|
|
DocumentTitle = "Диаграмма",
|
|
|
|
|
DiagramTitle = "Количество доставок по типам",
|
|
|
|
|
LegendLayout = PieChartLegendAlign.Bottom,
|
|
|
|
|
CategoriesX = categoriesX,
|
|
|
|
|
SeriesData = series
|
|
|
|
|
});
|
|
|
|
|
MessageBox.Show("Отчет готов");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void excelОтчётToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
|
|
|
|
saveFileDialog.ShowDialog();
|
|
|
|
|
string path = saveFileDialog.FileName + ".xlsx";
|
|
|
|
|
var list = _dlogic.ReadList(null);
|
|
|
|
|
|
|
|
|
|
excelHardTable1.CreateDoc(new TableWithHeaderConfig<DeliveryViewModel>
|
2024-11-06 02:29:24 +04:00
|
|
|
|
{
|
|
|
|
|
FilePath = path,
|
2024-11-18 20:15:31 +04:00
|
|
|
|
Header = "Deliveryies",
|
|
|
|
|
ColumnsRowsWidth = new List<(int Column, int Row)> { (5, 5), (20, 5), (10, 0), (15, 0), },
|
|
|
|
|
Headers = new List<(int ColumnIndex, int RowIndex, string Header, string PropertyName)>
|
|
|
|
|
{
|
|
|
|
|
(0, 0, "Id", "Id"),
|
|
|
|
|
(1, 0, "FCs", "FCs"),
|
|
|
|
|
(2, 0, "DeliveryType", "DeliveryType"),
|
|
|
|
|
(3, 0, "DeliveryDate", "DeliveryDate"),
|
|
|
|
|
},
|
|
|
|
|
Data = list
|
|
|
|
|
});
|
2024-11-06 02:29:24 +04:00
|
|
|
|
MessageBox.Show("Отчет готов");
|
2024-11-18 20:15:31 +04:00
|
|
|
|
|
2024-11-06 02:29:24 +04:00
|
|
|
|
}
|
2024-09-06 00:43:56 +04:00
|
|
|
|
}
|
|
|
|
|
}
|