2023-11-29 23:40:28 +04:00
|
|
|
|
using AccountsContracts.BindingModels;
|
|
|
|
|
using AccountsContracts.BusinessLogicContracts;
|
|
|
|
|
using AccountsContracts.ViewModels;
|
|
|
|
|
using ControlsLibraryNet60.Core;
|
|
|
|
|
using ControlsLibraryNet60.Models;
|
|
|
|
|
using System;
|
2023-11-16 20:39:00 +04:00
|
|
|
|
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 AccountsApp
|
|
|
|
|
{
|
|
|
|
|
public partial class FormMain : Form
|
|
|
|
|
{
|
2023-11-29 23:40:28 +04:00
|
|
|
|
private IAccountLogic _logic;
|
|
|
|
|
|
|
|
|
|
public FormMain(IAccountLogic logic)
|
2023-11-16 20:39:00 +04:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2023-11-29 23:40:28 +04:00
|
|
|
|
_logic = logic;
|
|
|
|
|
controlDataTable.LoadColumns(new List<DataTableColumnConfig> {
|
|
|
|
|
new DataTableColumnConfig { ColumnHeader = "", PropertyName = "Id", Visible = false, Width = 10},
|
|
|
|
|
new DataTableColumnConfig { ColumnHeader = "Логин", PropertyName = "Login", Visible = true, Width = 200},
|
|
|
|
|
new DataTableColumnConfig { ColumnHeader = "Выбранный интерес", PropertyName = "InterestName", Visible = true, Width = 200},
|
|
|
|
|
new DataTableColumnConfig { ColumnHeader = "Email", PropertyName = "Email", Visible = true, Width = 200},
|
|
|
|
|
});
|
2023-11-16 20:39:00 +04:00
|
|
|
|
}
|
2023-11-16 23:49:40 +04:00
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
2023-11-29 23:40:28 +04:00
|
|
|
|
LoadData();
|
2023-11-16 23:49:40 +04:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void интересыToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormInterests));
|
|
|
|
|
if (service is FormInterests form)
|
|
|
|
|
{
|
|
|
|
|
form.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-29 23:40:28 +04:00
|
|
|
|
|
|
|
|
|
private void FormMain_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LoadData()
|
|
|
|
|
{
|
|
|
|
|
controlDataTable.Clear();
|
|
|
|
|
var accounts = _logic.ReadList(null);
|
|
|
|
|
if (accounts != null)
|
|
|
|
|
{
|
|
|
|
|
controlDataTable.AddTable(accounts);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void редактироватьToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var service = Program.ServiceProvider?.GetService(typeof(FormAccount));
|
|
|
|
|
if (service is FormAccount form)
|
|
|
|
|
{
|
|
|
|
|
form.Id = controlDataTable.GetSelectedObject<AccountViewModel>().Id;
|
|
|
|
|
if (form.ShowDialog() == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void удалитьToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (MessageBox.Show("Удалить запись?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
if (_logic.Delete(new AccountBindingModel { Id = controlDataTable.GetSelectedObject<AccountViewModel>().Id }))
|
|
|
|
|
{
|
|
|
|
|
LoadData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-11-16 20:39:00 +04:00
|
|
|
|
}
|
|
|
|
|
}
|