2024-10-06 17:23:42 +04:00
|
|
|
|
using System;
|
|
|
|
|
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-10-22 19:58:21 +04:00
|
|
|
|
using ComponentsLibraryNet60;
|
|
|
|
|
using Contracts.BusinessLogicsContracts;
|
|
|
|
|
using Contracts.ViewModels;
|
|
|
|
|
using ControlsLibraryNet60.Data;
|
|
|
|
|
using ControlsLibraryNet60.Models;
|
2024-10-06 17:23:42 +04:00
|
|
|
|
|
|
|
|
|
namespace Forms
|
|
|
|
|
{
|
|
|
|
|
public partial class MainForm : Form
|
|
|
|
|
{
|
2024-10-22 19:58:21 +04:00
|
|
|
|
|
|
|
|
|
private readonly IProviderLogic _logic;
|
|
|
|
|
|
|
|
|
|
public MainForm(IProviderLogic logic)
|
2024-10-06 17:23:42 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2024-10-22 19:58:21 +04:00
|
|
|
|
_logic = logic;
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadData()
|
|
|
|
|
{
|
|
|
|
|
var list = _logic.ReadList(null);
|
|
|
|
|
if (list != null)
|
|
|
|
|
{
|
|
|
|
|
DataTreeNodeConfig treeConfig = new();
|
|
|
|
|
treeConfig.NodeNames = new();
|
|
|
|
|
treeConfig.NodeNames.Enqueue("OrganisationType");
|
|
|
|
|
treeConfig.NodeNames.Enqueue("DateLastDelivery");
|
|
|
|
|
treeConfig.NodeNames.Enqueue("Id");
|
|
|
|
|
treeConfig.NodeNames.Enqueue("Name");
|
|
|
|
|
|
|
|
|
|
controlDataTreeTable.LoadConfig(treeConfig);
|
|
|
|
|
controlDataTreeTable.AddTable(list);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void organisationTypesToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(OrganisationTypeForm));
|
|
|
|
|
if (service is OrganisationTypeForm form)
|
|
|
|
|
{
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addProviderToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(ProviderForm));
|
|
|
|
|
if (service is ProviderForm form)
|
|
|
|
|
{
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void editProviderToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(ProviderForm));
|
|
|
|
|
if(service is ProviderForm form)
|
|
|
|
|
{
|
|
|
|
|
int id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<ProviderViewModel>()?.Id);
|
|
|
|
|
form.Id = id;
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-06 17:23:42 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|