SUBD_Labs/BeautySalon/FormMain.cs

99 lines
3.4 KiB
C#
Raw Normal View History

2023-05-13 19:29:18 +04:00
using BeautySalonContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
namespace BeautySalon
{
public partial class FormMain : Form
{
private readonly ILogger _logger;
private readonly IVisitLogic _visitLogic;
public FormMain(ILogger<FormMain> logger, IVisitLogic visitLogic)
{
InitializeComponent();
_logger = logger;
_visitLogic = visitLogic;
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void ButtonCreateVisit_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateVisit));
if (service is FormCreateVisit form)
{
form.ShowDialog();
LoadData();
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
private void УслугиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormServices));
if (service is FormServices form)
{
form.ShowDialog();
}
}
private void МастераToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormMasters));
if (service is FormMasters form)
{
form.ShowDialog();
}
}
private void КлиентыToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
}
}
private void LoadData()
{
_logger.LogInformation("Загрузка посещений");
try
{
var list = _visitLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["ServiceId"].Visible = false;
dataGridView.Columns["ServiceName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["DateOfVisit"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["Sum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка посещений");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки посещений");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
2023-05-17 03:35:13 +04:00
private void ТестToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTests));
if (service is FormTests form)
{
form.ShowDialog();
}
}
2023-05-13 19:29:18 +04:00
}
}