53 lines
1.5 KiB
C#
53 lines
1.5 KiB
C#
using Publication.Repositories;
|
|
using Publication.Repositories.Implementations;
|
|
using System;
|
|
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;
|
|
using Unity;
|
|
|
|
namespace Publication.Forms;
|
|
|
|
public partial class FormOrders : Form
|
|
{
|
|
private readonly IUnityContainer container;
|
|
private readonly IOrderRepository orderRepository;
|
|
public FormOrders(IUnityContainer _container,IOrderRepository _orderRepository)
|
|
{
|
|
container = _container ?? throw new ArgumentNullException(nameof(_container));
|
|
orderRepository = _orderRepository ?? throw new ArgumentNullException(nameof(_orderRepository));
|
|
InitializeComponent();
|
|
}
|
|
private void buttonAdd_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
container.Resolve<FormOrder>().ShowDialog();
|
|
LoadList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void FormOrders_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
LoadList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
private void LoadList() => dataGridView.DataSource = orderRepository.ReadOrders();
|
|
}
|