80 lines
2.0 KiB
C#
80 lines
2.0 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using PlumbingRepairContracts.BusinessLogicsContracts;
|
|
|
|
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
|
|
{
|
|
<<<<<<< HEAD
|
|
var list = _logic.ReadList(new() { Page = page, PageSize = pageSize });
|
|
if (list != null)
|
|
{
|
|
dataGridView.DataSource = list;
|
|
dataGridView.Columns["ClientId"].Visible = false;
|
|
dataGridView.Columns["MessageId"].Visible = false;
|
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
}
|
|
_logger.LogInformation("Загрузка сообщений");
|
|
=======
|
|
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
|
|
_logger.LogInformation("Loading mails");
|
|
>>>>>>> lab_8
|
|
}
|
|
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 service = Program.ServiceProvider?.GetService(typeof(FormMail));
|
|
if (service is FormMail form)
|
|
{
|
|
form.Id = dataGridView.SelectedRows[0].Cells["MessageId"].Value.ToString();
|
|
form.ShowDialog();
|
|
LoadData(0);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|