90 lines
3.1 KiB
C#
90 lines
3.1 KiB
C#
|
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);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|