66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using ConfectioneryContracts.BusinessLogicsContracts;
|
|
using ConfectioneryContracts.ViewModels;
|
|
using Microsoft.Extensions.Logging;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace ConfectioneryView
|
|
{
|
|
public partial class FormShop : Form
|
|
{
|
|
private readonly List<ShopViewModel>? _list;
|
|
private readonly IShopLogic _logic;
|
|
private readonly ILogger _logger;
|
|
|
|
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
|
{
|
|
InitializeComponent();
|
|
_logger = logger;
|
|
_list = logic.ReadList(null);
|
|
_logic = logic;
|
|
if (_list != null)
|
|
{
|
|
comboBoxShop.DisplayMember = "Name";
|
|
comboBoxShop.ValueMember = "Id";
|
|
comboBoxShop.DataSource = _list;
|
|
comboBoxShop.SelectedItem = null;
|
|
}
|
|
}
|
|
|
|
private void LoadData()
|
|
{
|
|
try
|
|
{
|
|
var list = _logic.ReadList(null);
|
|
if (list != null)
|
|
{
|
|
dataGridView.DataSource = list;
|
|
dataGridView.Columns["Id"].Visible = false;
|
|
dataGridView.Columns["Name"].AutoSizeMode =
|
|
DataGridViewAutoSizeColumnMode.Fill;
|
|
}
|
|
_logger.LogInformation("Загрузка магазинов");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void ComboBoxShop_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
LoadData();
|
|
}
|
|
}
|
|
}
|