PIbd-33_Nevaeva_KA_COP_28/NevaevaLibrary/AccountsView/FormMain.cs

63 lines
1.7 KiB
C#
Raw Normal View History

2023-12-01 01:01:22 +04:00
using AccountContracts.BusinessLogicsContracts;
using ControlsLibraryNet60.Core;
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;
namespace AccountsView
{
public partial class FormMain : Form
{
private IAccountLogic _logic;
public FormMain(IAccountLogic logic)
{
InitializeComponent();
_logic = logic;
abazovTreeView.setHierarchy(new List<(string, bool)> { ("RoleName", false), ("Rating", true), ("Id", true), ("Login", true) });
}
private void ролиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormRoles));
if (service is FormRoles form)
{
form.ShowDialog();
}
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
abazovTreeView.clear();
var accounts = _logic.ReadList(null);
if (accounts != null)
{
abazovTreeView.addItems(accounts);
}
}
private void создатьToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormAccount));
if (service is FormAccount form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
}