first step

This commit is contained in:
gaoyuan
2022-03-02 22:29:13 +08:00
parent 51f8e4f2e8
commit 9929eee056
17 changed files with 343 additions and 60 deletions

View File

@ -49,29 +49,27 @@ namespace Billing.Views
public event EventHandler<AccountEventArgs> AccountChecked;
public AddAccountPage()
{
CheckAccount = new Command(OnCheckAccount);
SelectIcon = new Command(OnSelectIcon);
SelectCategory = new Command(OnSelectCategory);
AccountIcon = BaseModel.ICON_DEFAULT;
Category = AccountCategory.Cash;
InitializeComponent();
}
public AddAccountPage(Account account)
public AddAccountPage(Account account = null)
{
CheckAccount = new Command(OnCheckAccount);
SelectIcon = new Command(OnSelectIcon);
SelectCategory = new Command(OnSelectCategory);
Title = Resource.EditAccount;
this.account = account;
AccountName = account.Name;
AccountIcon = account.Icon;
Category = account.Category;
Initial = account.Initial.ToString();
Memo = account.Memo;
if (account == null)
{
AccountIcon = BaseModel.ICON_DEFAULT;
Category = AccountCategory.Cash;
}
else
{
AccountName = account.Name;
AccountIcon = account.Icon;
Category = account.Category;
Initial = account.Initial.ToString();
Memo = account.Memo;
}
InitializeComponent();
}
@ -83,13 +81,26 @@ namespace Billing.Views
}
using (Tap.Start())
{
if (string.IsNullOrWhiteSpace(AccountName))
{
await this.ShowMessage(Resource.AccountRequired);
return;
}
await Navigation.PopAsync();
_ = decimal.TryParse(Initial, out decimal initial);
if (account != null)
{
account.Name = AccountName;
account.Icon = AccountIcon;
account.Category = Category;
account.Initial = initial;
account.Memo = Memo;
}
AccountChecked?.Invoke(this, new AccountEventArgs
{
Account = new Account
Account = account ?? new Account
{
Id = account?.Id ?? -1,
Id = -1,
Name = AccountName,
Icon = AccountIcon,
Category = Category,