67 lines
2.1 KiB
C#
67 lines
2.1 KiB
C#
using ProjectSellPC.Repos;
|
|
using Unity;
|
|
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;
|
|
|
|
namespace ProjectSellPC.Forms.Receipt
|
|
{
|
|
public partial class ChequeForm : Form
|
|
{
|
|
private readonly IUnityContainer _container;
|
|
private readonly IChequeRepository _ChequeRepository;
|
|
private readonly IClientRepository _clientRepository;
|
|
|
|
public ChequeForm(IUnityContainer unityContainer, IChequeRepository ChequeRepository, IClientRepository clientRepository)
|
|
{
|
|
InitializeComponent();
|
|
|
|
_container = unityContainer ?? throw new ArgumentNullException(nameof(unityContainer));
|
|
_ChequeRepository = ChequeRepository ?? throw new ArgumentNullException(nameof(ChequeRepository));
|
|
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
|
|
}
|
|
|
|
private void ChequeForm_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
LoadList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
|
|
private void LoadList()
|
|
{
|
|
var checks = _ChequeRepository.ReadAll();
|
|
|
|
foreach (var check in checks)
|
|
{
|
|
check.Client = _clientRepository.Read(check.ClientId);
|
|
}
|
|
|
|
ChequesDataGridView.DataSource = checks;
|
|
}
|
|
private void addButton_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
_container.Resolve<ChequeSettingsForm>().ShowDialog();
|
|
LoadList();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
}
|