Detaljvisning per mottagare fixad
This commit is contained in:
@ -7,20 +7,23 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using WinFormDiApp;
|
||||
|
||||
namespace WinFormDi.UserControls
|
||||
{
|
||||
public partial class ucCustomerValue : UserControl
|
||||
{
|
||||
private readonly frmSearchData _parentForm;
|
||||
|
||||
public ucCustomerValue()
|
||||
public ucCustomerValue(frmSearchData parentForm)
|
||||
{
|
||||
InitializeComponent();
|
||||
_parentForm = parentForm;
|
||||
}
|
||||
|
||||
private void btnShowMore_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
_parentForm.ShowDetails(Convert.ToString(this.Tag));
|
||||
}
|
||||
|
||||
public string Receiver { get => lblCustName.Text; set => lblCustName.Text = value; }
|
||||
|
||||
1
WinFormDi/frmPayments.Designer.cs
generated
1
WinFormDi/frmPayments.Designer.cs
generated
@ -100,6 +100,7 @@
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "frmPayments";
|
||||
Load += frmPayments_Load;
|
||||
Shown += frmPayments_Shown;
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using WinFormDiApp.BL.Models;
|
||||
using WinFormDiApp.BLI;
|
||||
|
||||
namespace WinFormDiApp
|
||||
@ -21,19 +22,22 @@ namespace WinFormDiApp
|
||||
lvPayments.Items.Clear();
|
||||
_accountRecordRepository = accountRecordRepository;
|
||||
}
|
||||
|
||||
public IEnumerable<AccountRecord>? CustomPayments { get; set; } = null;
|
||||
private void frmPayments_Load(object sender, EventArgs e)
|
||||
{
|
||||
//MessageBox.Show("Load");
|
||||
lvPayments.Items.Clear();
|
||||
var payments = _accountRecordRepository.GetAllAccounts();
|
||||
foreach (var account in payments)
|
||||
if (CustomPayments != null)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,5 +45,25 @@ namespace WinFormDiApp
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,16 +16,21 @@ namespace WinFormDiApp
|
||||
{
|
||||
public partial class frmSearchData : Form
|
||||
{
|
||||
private class AccCount : AccountRecord
|
||||
IEnumerable<AccountRecord>? foundRecs = null;
|
||||
private class AccCount
|
||||
{
|
||||
public AccountRecord? AcRec { get; set; }
|
||||
public int NoOfRecs { get; set; }
|
||||
public double SearchedSum { get; set; }
|
||||
}
|
||||
private readonly IAccountRecordRepository _accountRecordRepository;
|
||||
private readonly frmPayments _showPayments;
|
||||
|
||||
public frmSearchData(IAccountRecordRepository accountRecordRepository)
|
||||
public frmSearchData(IAccountRecordRepository accountRecordRepository,frmPayments showPayments)
|
||||
{
|
||||
InitializeComponent();
|
||||
_accountRecordRepository = accountRecordRepository;
|
||||
_showPayments = showPayments;
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e)
|
||||
@ -36,8 +41,8 @@ namespace WinFormDiApp
|
||||
private void btnStartSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
flpPanel1.Controls.Clear();
|
||||
var result = _accountRecordRepository.GetAllAccBetweenDates(dtpFrom.Value, dtpTo.Value);
|
||||
var aggregates = aggegateAccounts(result);
|
||||
foundRecs = _accountRecordRepository.GetAllAccBetweenDates(dtpFrom.Value, dtpTo.Value);
|
||||
var aggregates = aggegateAccounts(foundRecs);
|
||||
foreach (var account in aggregates)
|
||||
{
|
||||
var ucCustV = createAndFillUCcv(account);
|
||||
@ -47,10 +52,11 @@ namespace WinFormDiApp
|
||||
|
||||
private ucCustomerValue createAndFillUCcv(AccCount account)
|
||||
{
|
||||
var result = new ucCustomerValue();
|
||||
result.Amount = String.Format("{0:0.00}", account.Belopp).adjustRight();
|
||||
result.Receiver = account.Mottagare;
|
||||
var result = new ucCustomerValue(this);
|
||||
result.Amount = String.Format("{0:0.00}", account.SearchedSum).adjustRight();
|
||||
result.Receiver = account.AcRec.Mottagare;
|
||||
result.Number = Convert.ToString(account.NoOfRecs);
|
||||
result.Tag = account.AcRec.Konto;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -63,7 +69,7 @@ namespace WinFormDiApp
|
||||
{
|
||||
if (accountRecord.Mottagare == oldMott)
|
||||
{
|
||||
wrkRec.Belopp += accountRecord.Belopp;
|
||||
wrkRec.SearchedSum += accountRecord.Belopp;
|
||||
wrkRec.NoOfRecs++;
|
||||
}
|
||||
else
|
||||
@ -88,14 +94,16 @@ namespace WinFormDiApp
|
||||
{
|
||||
AccCount acc = new AccCount();
|
||||
acc.NoOfRecs = 1;
|
||||
acc.BetalDatum = accountRecord.BetalDatum;
|
||||
acc.Stored = accountRecord.Stored;
|
||||
acc.Mottagare = accountRecord.Mottagare;
|
||||
acc.Konto = accountRecord.Konto;
|
||||
acc.Avisering = accountRecord.Avisering;
|
||||
acc.Belopp = accountRecord.Belopp;
|
||||
acc.Id = accountRecord.Id;
|
||||
acc.AcRec = accountRecord;
|
||||
acc.SearchedSum = accountRecord.Belopp;
|
||||
return acc;
|
||||
}
|
||||
|
||||
public void ShowDetails(string accountNo)
|
||||
{
|
||||
IEnumerable<AccountRecord> detailRecs = foundRecs.Where(fr => fr.Konto==accountNo);
|
||||
_showPayments.CustomPayments = detailRecs;
|
||||
_showPayments.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user