Infört en möjlighet att rensa transtabellen

This commit is contained in:
2024-02-01 11:44:45 +01:00
parent ef14ce2aaa
commit 05dfd1f35b
6 changed files with 117 additions and 22 deletions

View File

@ -14,8 +14,21 @@ namespace WinFormDiApp
{
public partial class frmPayments : Form
{
private bool _enableClearing;
private readonly IAccountRecordRepository _accountRecordRepository;
public bool EnableClearing
{
get
{
return _enableClearing;
}
set
{
_enableClearing = value;
}
}
public frmPayments(IAccountRecordRepository accountRecordRepository)
{
InitializeComponent();
@ -26,7 +39,9 @@ namespace WinFormDiApp
private void frmPayments_Load(object sender, EventArgs e)
{
//MessageBox.Show("Load");
btnRensa.Visible = _enableClearing;
lvPayments.Items.Clear();
if (CustomPayments != null)
{
foreach (var account in CustomPayments)
@ -65,5 +80,26 @@ namespace WinFormDiApp
}
else CustomPayments = null;
}
private void btnRensa_Click(object sender, EventArgs e)
{
if(MessageBox.Show("Verkligen Säker på att rensa DB?","Payments", MessageBoxButtons.YesNo, MessageBoxIcon.Question)==DialogResult.Yes)
{
MessageBox.Show("Nu rensar vi");
_accountRecordRepository.DeleteAllAccountRecords();
lvPayments.Items.Clear();
var payments = _accountRecordRepository.GetAllAccounts();
foreach (var account in payments)
{
var lvitem = lvPayments.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);
}
}
}
}
}