issue fix
This commit is contained in:
@ -64,17 +64,6 @@ namespace Billing.Views
|
||||
|
||||
private void AddToAccountGroup(Account account)
|
||||
{
|
||||
int maxId;
|
||||
if (accounts.Count > 0)
|
||||
{
|
||||
maxId = accounts.Max(g => g.Max(a => a.Id));
|
||||
}
|
||||
else
|
||||
{
|
||||
maxId = -1;
|
||||
}
|
||||
account.Id = maxId + 1;
|
||||
|
||||
var group = accounts.FirstOrDefault(g => g.Key == account.Category);
|
||||
if (group == null)
|
||||
{
|
||||
@ -142,7 +131,7 @@ namespace Billing.Views
|
||||
|
||||
private async void AccountChecked(object sender, AccountEventArgs e)
|
||||
{
|
||||
var add = e.Account.Id < 0;
|
||||
var add = e.Account.Id <= 0;
|
||||
if (add)
|
||||
{
|
||||
App.Accounts.Add(e.Account);
|
||||
|
@ -105,7 +105,6 @@ namespace Billing.Views
|
||||
{
|
||||
Account = account ?? new Account
|
||||
{
|
||||
Id = -1,
|
||||
Name = AccountName,
|
||||
Icon = AccountIcon,
|
||||
Category = Category,
|
||||
|
@ -162,7 +162,6 @@ namespace Billing.Views
|
||||
}
|
||||
BillChecked?.Invoke(this, bill ?? new Bill
|
||||
{
|
||||
Id = -1,
|
||||
Amount = amount,
|
||||
Name = name,
|
||||
CategoryId = categoryId,
|
||||
|
@ -108,7 +108,6 @@ namespace Billing.Views
|
||||
{
|
||||
CategoryChecked?.Invoke(this, new Category
|
||||
{
|
||||
Id = -1,
|
||||
Name = CategoryName,
|
||||
Icon = CategoryIcon,
|
||||
TintColor = color,
|
||||
|
@ -101,6 +101,7 @@
|
||||
CommandParameter="{Binding .}"/>
|
||||
</Grid.GestureRecognizers>
|
||||
<ui:TintImage Source="{Binding Icon, Converter={StaticResource iconConverter}}"
|
||||
ui:TintHelper.TintColor="{Binding TintColor}"
|
||||
WidthRequest="26" HeightRequest="20" VerticalOptions="Center"/>
|
||||
<Label Grid.Column="1" Text="{Binding Name}" TextColor="{DynamicResource TextColor}"
|
||||
VerticalOptions="Center"
|
||||
|
@ -167,18 +167,8 @@ namespace Billing.Views
|
||||
|
||||
private async void OnBillChecked(object sender, Bill e)
|
||||
{
|
||||
if (e.Id < 0)
|
||||
if (e.Id <= 0)
|
||||
{
|
||||
int maxId;
|
||||
if (App.Bills.Count > 0)
|
||||
{
|
||||
maxId = App.Bills.Max(b => b.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
maxId = -1;
|
||||
}
|
||||
e.Id = maxId + 1;
|
||||
App.Bills.Add(e);
|
||||
var bills = Bills;
|
||||
bills.Add(Helper.WrapBill(e));
|
||||
@ -189,7 +179,21 @@ namespace Billing.Views
|
||||
var bill = Bills.FirstOrDefault(b => b.Bill == e);
|
||||
if (bill != null)
|
||||
{
|
||||
UpdateBill(bill);
|
||||
if (bill.DateCreation != e.CreateTime)
|
||||
{
|
||||
var bills = App.Bills.Where(b => Helper.IsSameDay(b.CreateTime, SelectedDate));
|
||||
Bills = new List<UIBill>(bills.OrderBy(b => b.CreateTime).Select(b => Helper.WrapBill(b)));
|
||||
RefreshBalance(Bills);
|
||||
|
||||
RankPage.Instance?.SetNeedRefresh();
|
||||
|
||||
await StoreHelper.SaveBillItemAsync(e);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateBill(bill);
|
||||
}
|
||||
}
|
||||
}
|
||||
RefreshBalance(Bills);
|
||||
@ -203,6 +207,7 @@ namespace Billing.Views
|
||||
public class UIBill : BindableObject
|
||||
{
|
||||
public static readonly BindableProperty IconProperty = Helper.Create<string, UIBill>(nameof(Icon));
|
||||
public static readonly BindableProperty TintColorProperty = Helper.Create<Color, UIBill>(nameof(TintColor));
|
||||
public static readonly BindableProperty NameProperty = Helper.Create<string, UIBill>(nameof(Name));
|
||||
public static readonly BindableProperty DateCreationProperty = Helper.Create<DateTime, UIBill>(nameof(DateCreation));
|
||||
public static readonly BindableProperty AmountProperty = Helper.Create<decimal, UIBill>(nameof(Amount));
|
||||
@ -213,6 +218,11 @@ namespace Billing.Views
|
||||
get => (string)GetValue(IconProperty);
|
||||
set => SetValue(IconProperty, value);
|
||||
}
|
||||
public Color TintColor
|
||||
{
|
||||
get => (Color)GetValue(TintColorProperty);
|
||||
set => SetValue(TintColorProperty, value);
|
||||
}
|
||||
public string Name
|
||||
{
|
||||
get => (string)GetValue(NameProperty);
|
||||
|
@ -146,19 +146,9 @@ namespace Billing.Views
|
||||
|
||||
private async void OnCategoryChecked(object sender, Category category)
|
||||
{
|
||||
if (category.Id < 0)
|
||||
if (category.Id <= 0)
|
||||
{
|
||||
// add
|
||||
int maxId;
|
||||
if (App.Categories.Count > 0)
|
||||
{
|
||||
maxId = App.Categories.Max(b => b.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
maxId = -1;
|
||||
}
|
||||
category.Id = maxId + 1;
|
||||
App.Categories.Add(category);
|
||||
Categories.Add(WrapCategory(category));
|
||||
}
|
||||
|
@ -116,6 +116,7 @@
|
||||
CommandParameter="{Binding .}"/>
|
||||
</Grid.GestureRecognizers>
|
||||
<ui:TintImage Source="{Binding Icon, Converter={StaticResource iconConverter}}"
|
||||
ui:TintHelper.TintColor="{Binding TintColor}"
|
||||
WidthRequest="26" HeightRequest="20" VerticalOptions="Center"/>
|
||||
<Label Grid.Column="1" Text="{Binding Name}" TextColor="{DynamicResource TextColor}"
|
||||
VerticalOptions="Center"
|
||||
|
Reference in New Issue
Block a user