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 WinFormDiApp.BL.Models; using WinFormDiApp.BLI; namespace WinFormDiApp { public partial class frmPayments : Form { private readonly IAccountRecordRepository _accountRecordRepository; public frmPayments(IAccountRecordRepository accountRecordRepository) { InitializeComponent(); lvPayments.Items.Clear(); _accountRecordRepository = accountRecordRepository; } public IEnumerable? CustomPayments { get; set; } = null; private void frmPayments_Load(object sender, EventArgs e) { //MessageBox.Show("Load"); lvPayments.Items.Clear(); if (CustomPayments != null) { foreach (var account in CustomPayments) { 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); } } } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } private void frmPayments_Shown(object sender, EventArgs e) { //MessageBox.Show("Shown"); if (CustomPayments == null) { 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); } } else CustomPayments = null; } } }