46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
|
using ClientsContracts.BusinessLogicContracts;
|
|||
|
using Unity;
|
|||
|
|
|||
|
namespace WinForms
|
|||
|
{
|
|||
|
public partial class FormMain : Form
|
|||
|
{
|
|||
|
private readonly IClientLogic _clientLogic;
|
|||
|
private readonly IStatusLogic _statusLogic;
|
|||
|
public FormMain(IClientLogic clientLogic, IStatusLogic statusLogic)
|
|||
|
{
|
|||
|
_clientLogic = clientLogic;
|
|||
|
_statusLogic = statusLogic;
|
|||
|
InitializeComponent();
|
|||
|
List<string> stringToHierachy = new List<string>() { "Status", "Amount", "Id", "Name" };
|
|||
|
myTreeView1.addToHierarchy(stringToHierachy);
|
|||
|
}
|
|||
|
private void FormMain_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
LoadData();
|
|||
|
}
|
|||
|
|
|||
|
private void LoadData()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var list = _clientLogic.Read(null);
|
|||
|
myTreeView1.LoadTree(list);
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void AddNewElement()
|
|||
|
{
|
|||
|
var form = Program.Container.Resolve<FormClient>();
|
|||
|
if (form.ShowDialog() == DialogResult.OK)
|
|||
|
{
|
|||
|
LoadData();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|