PIbd-21_RazubaevSM_Plumbing.../PlumbingRepair/PlumbingRepairView/FormMails.cs

64 lines
1.5 KiB
C#
Raw Normal View History

2024-05-02 22:08:35 +04:00
using Microsoft.Extensions.Logging;
using PlumbingRepairContracts.BusinessLogicsContracts;
2024-05-16 17:37:12 +04:00
using PlumbingRepairContracts.DI;
2024-05-02 22:08:35 +04:00
namespace PlumbingRepairView
{
public partial class FormMails : Form
{
private readonly ILogger _logger;
private readonly IMessageInfoLogic _logic;
private readonly int pageSize = 5;
private int pageNumber = 0;
2024-05-02 22:08:35 +04:00
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)
2024-05-02 22:08:35 +04:00
{
try
{
2024-05-16 17:00:28 +04:00
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
2024-05-16 17:37:12 +04:00
_logger.LogInformation("Загрузка сообщений");
2024-05-02 22:08:35 +04:00
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки сообщений");
2024-05-02 22:08:35 +04:00
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)
{
2024-05-16 17:37:12 +04:00
var form = DependencyManager.Instance.Resolve<FormMail>();
form.ShowDialog();
}
}
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
2024-05-02 22:08:35 +04:00
}
}