fix issue

This commit is contained in:
2022-03-15 20:12:40 +08:00
parent 5b209cc19c
commit 8ba6f4bf85
8 changed files with 70 additions and 13 deletions

View File

@@ -85,7 +85,7 @@ namespace Billing
public static bool OpenUrl(Uri uri)
{
if (uri == null)
if (uri == null || !uri.IsFile)
{
return true;
}
@@ -96,7 +96,7 @@ namespace Billing
Task.Run(async () =>
{
var result = await StoreHelper.ReloadDatabase(url);
//if (result)
if (result)
{
await InitializeData();

View File

@@ -17,7 +17,7 @@ namespace Billing.Store
public static string DatabasePath => Path.Combine(PersonalFolder, dbfile);
#region Sqlite3
private const string dbfile = "data.db3";
private const string dbfile = ".master.db3";
private static SQLiteAsyncConnection database;
#endregion
@@ -42,6 +42,7 @@ namespace Billing.Store
try
{
File.Copy(file, path, true);
File.Delete(file);
}
catch (Exception ex)
{
@@ -167,7 +168,15 @@ namespace Billing.Store
public static async Task<int> GetLogsCount()
{
await Instance;
return await database.ExecuteScalarAsync<int>("SELECT COUNT(Id) FROM [Logs]");
try
{
return await database.ExecuteScalarAsync<int>("SELECT COUNT(Id) FROM [Logs]");
}
catch (SQLiteException)
{
await database.CreateTableAsync<Logs>();
return 0;
}
}
public static async Task<int> SaveLogItemAsync(Logs log)
{

View File

@@ -50,6 +50,17 @@ namespace Billing.Views
groupLayout.Refresh(accounts);
}
protected override void OnRefresh()
{
accounts.Clear();
foreach (var account in App.Accounts)
{
AddToAccountGroup(account);
}
RefreshBalance(true);
groupLayout.Refresh(accounts);
}
private void RefreshBalance(bool calc = false)
{
if (calc)

View File

@@ -60,19 +60,23 @@ namespace Billing.Views
billingDate.SetDateTime(DateTime.Today);
}
private void OnDateSelected(object sender, DateEventArgs e)
protected override void OnRefresh()
{
SelectedDate = e.Date;
Task.Run(() =>
{
var bills = App.Bills.Where(b => Helper.IsSameDay(b.CreateTime, e.Date));
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);
MainThread.BeginInvokeOnMainThread(async () => await scrollView.ScrollToAsync(0, 0, true));
});
}
private void OnDateSelected(object sender, DateEventArgs e)
{
SelectedDate = e.Date;
OnRefresh();
}
private void RefreshBalance(List<UIBill> bills)
{
SetValue(NoBillsProperty, bills.Count == 0);

View File

@@ -229,6 +229,11 @@ namespace Billing.Views
}
}
protected override void OnRefresh()
{
OnDateChanged(this);
}
private void OnDateTypeCommand(DateType index)
{
if (index < DateType.Monthly || index > DateType.Total)

View File

@@ -59,6 +59,12 @@ namespace Billing.Views
//Light.Instance.RefreshColor(Color.FromHex(color));
}
protected override async void OnRefresh()
{
var count = await StoreHelper.GetLogsCount();
SetValue(ManyRecordsProperty, string.Format(Resource.ManyRecords, count));
}
private async void OnShareCommand()
{
if (Tap.IsBusy)