fix: account page refresh issue when modify the initial amount

This commit is contained in:
Tsanie 2022-03-03 17:11:45 +08:00
parent 030993b40e
commit 42c09c719a

View File

@ -43,23 +43,22 @@ namespace Billing.Views
accounts.Clear();
foreach (var account in App.Accounts)
{
account.Balance = account.Initial + App.Bills.Where(b => b.WalletId == account.Id).Sum(b => b.Amount);
AddToAccountGroup(account);
}
}
else
groupLayout.Refresh(accounts);
RefreshBalance(true);
}
private void RefreshBalance(bool calc = false)
{
if (calc)
{
foreach (var account in App.Accounts)
{
account.Balance = account.Initial + App.Bills.Where(b => b.WalletId == account.Id).Sum(b => b.Amount);
}
}
groupLayout.Refresh(accounts);
RefreshBalance();
}
private void RefreshBalance()
{
}
SetValue(BalanceProperty, App.Accounts.Sum(a => a.Balance));
}
@ -139,13 +138,14 @@ namespace Billing.Views
private void AccountChecked(object sender, AccountEventArgs e)
{
if (e.Account.Id < 0)
var add = e.Account.Id < 0;
if (add)
{
App.Accounts.Add(e.Account);
AddToAccountGroup(e.Account);
}
groupLayout.Refresh(accounts);
RefreshBalance();
RefreshBalance(!add);
Task.Run(App.WriteAccounts);
}