64 lines
1.5 KiB
C#
64 lines
1.5 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
using PlumbingRepairContracts.DI;
|
|
|
|
namespace PlumbingRepairView
|
|
{
|
|
public partial class FormMails : Form
|
|
{
|
|
private readonly ILogger _logger;
|
|
private readonly IMessageInfoLogic _logic;
|
|
private readonly int pageSize = 5;
|
|
private int pageNumber = 0;
|
|
public FormMails(ILogger<FormMails> logger, IMessageInfoLogic logic)
|
|
{
|
|
InitializeComponent();
|
|
_logger = logger;
|
|
_logic = logic;
|
|
}
|
|
private void FormMails_Load(object sender, EventArgs e)
|
|
{
|
|
LoadData(0);
|
|
}
|
|
private void LoadData(int page)
|
|
{
|
|
try
|
|
{
|
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
|
_logger.LogInformation("Загрузка сообщений");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка загрузки сообщений");
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
private void ButtonBack_Click(object sender, EventArgs e)
|
|
{
|
|
if (pageNumber != 0)
|
|
{
|
|
pageNumber--;
|
|
}
|
|
LoadData(pageNumber);
|
|
}
|
|
private void ButtonForward_Click(object sender, EventArgs e)
|
|
{
|
|
pageNumber++;
|
|
LoadData(pageNumber);
|
|
}
|
|
private void ButtonOpen_Click(object sender, EventArgs e)
|
|
{
|
|
if (dataGridView.SelectedRows.Count == 1)
|
|
{
|
|
var form = DependencyManager.Instance.Resolve<FormMail>();
|
|
form.ShowDialog();
|
|
}
|
|
}
|
|
|
|
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|