PIbd-33_Nevaeva_KA_COP_28/NevaevaLibrary/AccountsView/FormMain.cs
2023-12-01 01:17:26 +04:00

70 lines
1.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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();
}
}
}
}
}