66 lines
2.3 KiB
C#
66 lines
2.3 KiB
C#
using Microsoft.Extensions.Logging;
|
|
using WinFormDiApp.BLI;
|
|
using WinFormDiApp.BLR;
|
|
|
|
namespace WinFormDiApp
|
|
{
|
|
public partial class frmReadPayments : Form
|
|
{
|
|
private readonly IAccountRecordRepository _accountRecordRepository;
|
|
private readonly IReadingIn _readingIn;
|
|
private readonly ILogger<frmReadPayments> _logger;
|
|
|
|
public frmReadPayments(IAccountRecordRepository accountRecordRepository, IReadingIn readingIn, ILogger<frmReadPayments> logger)
|
|
{
|
|
InitializeComponent();
|
|
lvPayouts.Items.Clear();
|
|
_accountRecordRepository = accountRecordRepository;
|
|
_readingIn = readingIn;
|
|
_logger = logger;
|
|
}
|
|
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void btnChooseFile_Click(object sender, EventArgs e)
|
|
{
|
|
ofChooseFile.Title = "Välj nerladdad excel-fil (Transaktioner)";
|
|
ofChooseFile.InitialDirectory = "C:\\";
|
|
if (ofChooseFile.ShowDialog() == DialogResult.OK)
|
|
{
|
|
lblTransFileName.Text = ofChooseFile.FileName;
|
|
btnStartRead.Visible = true;
|
|
btnStartRead.Enabled = true;
|
|
}
|
|
}
|
|
|
|
private void btnStartRead_Click(object sender, EventArgs e)
|
|
{
|
|
if (!_readingIn.ReadAndSaveInvoices(lblTransFileName.Text))
|
|
{
|
|
var resUlt = _readingIn.readXLS(lblTransFileName.Text);
|
|
resUlt.ToList().ForEach(rec => _logger.LogInformation($"Konto :{rec.Konto}, {rec.Belopp}"));
|
|
}
|
|
else
|
|
{
|
|
var payments = _accountRecordRepository.GetAllAccounts();
|
|
foreach (var account in payments)
|
|
{
|
|
var lvitem = lvPayouts.Items.Add(account.Id.ToString());
|
|
lvitem.SubItems.Add(account.Mottagare);
|
|
lvitem.SubItems.Add(account.Konto);
|
|
lvitem.SubItems.Add(account.Belopp.ToString());
|
|
lvitem.SubItems.Add(account.BetalDatum.ToShortDateString());
|
|
lvitem.SubItems.Add(account.Avisering);
|
|
}
|
|
}
|
|
|
|
btnStartRead.Enabled = false;
|
|
btnStartRead.Visible = false;
|
|
}
|
|
}
|
|
}
|