70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
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", false), ("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)
|
||
{
|
||
foreach (var account in accounts)
|
||
{
|
||
if (!account.Rating.HasValue)
|
||
{
|
||
account.Rating = 0;
|
||
}
|
||
}
|
||
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();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|