private async void Button_OnClicked(object sender, EventArgs e) { var cats = await _connection.QueryAsync <SQL_Category>("SELECT Name FROM SQL_Category"); foreach (var item in cats) { catList.Add(item.Name.ToLower()); } if (string.IsNullOrWhiteSpace(Naam.Text)) { await DisplayAlert("Alert", "Categorie heeft geen naam", "OK"); } else if (Category.SelectedItem == null) { await DisplayAlert("Alert", "Kies een Type categorie", "OK"); } else if (catList.Contains(Naam.Text.ToLower())) { await DisplayAlert("Alert", "Categorie bestaat al", "OK"); } else { var category = new SQL_Category { }; category.Name = Naam.Text; if (Category.SelectedIndex == 0) { category.Income = false; } else { category.Income = true; } await _connection.InsertAsync(category); await DisplayAlert("Gelukt", "Categorie succesvol toegevoegd", "OK"); Navigation.RemovePage(this); } }
protected async override void OnStart() { AppCenter.LogLevel = LogLevel.Verbose; //Connect to Analytics to collect those juicy statss AppCenter.Start("android=a9636b16-80a9-46ca-8381-91c6f1b44948;" + "ios=8fc92317-8677-4269-b461-548ebb3469f8", typeof(Analytics), typeof(Crashes), typeof(Push)); //Create SQL Connection await _connection.CreateTableAsync <SQL_Buttons>(); int allItems_Buttons = await _connection.Table <SQL_Buttons>().CountAsync(); System.Diagnostics.Debug.WriteLine(allItems_Buttons); if (allItems_Buttons == 0) { var buttons = new SQL_Buttons { }; buttons.Value = "Inkomsten"; buttons.Name = "Button1"; await _connection.InsertAsync(buttons); buttons.Value = "Uitgaven"; buttons.Name = "Button2"; await _connection.InsertAsync(buttons); buttons.Value = "Spaardoelen"; buttons.Name = "Button3"; await _connection.InsertAsync(buttons); buttons.Value = "Overzicht"; buttons.Name = "Button4"; await _connection.InsertAsync(buttons); } int allItems_Budget = await _connection.Table <SQL_Budget>().CountAsync(); System.Diagnostics.Debug.WriteLine(allItems_Buttons); if (allItems_Budget == 0) { var Budget = new SQL_Budget(); Budget.Value = 0.00; Budget.Name = "Budget"; Budget.Date = DateTime.Now; await _connection.InsertAsync(Budget); } await _connection.CreateTableAsync <SQL_Settings>(); int allItems = await _connection.Table <SQL_Settings>().CountAsync(); System.Diagnostics.Debug.WriteLine(allItems); if (allItems == 0) { // only insert the data if it doesn't already exist var settings = new SQL_Settings { }; settings.Name = "DB_Version"; settings.Value = "2"; await _connection.InsertAsync(settings); settings.Name = "Last_Seen"; settings.Value = DateTime.Now.ToString(); await _connection.InsertAsync(settings); } //Create SQL Connection await _connection.CreateTableAsync <SQL_Transacties>(); int allItems_Uitgaven = await _connection.Table <SQL_Transacties>().CountAsync(); System.Diagnostics.Debug.WriteLine(allItems); await _connection.CreateTableAsync <SQL_SpaarDoelen>(); int allItems_SpaarDoelen = await _connection.Table <SQL_SpaarDoelen>().CountAsync(); System.Diagnostics.Debug.WriteLine(allItems); await _connection.CreateTableAsync <SQL_Category>(); int allItems_Category = await _connection.Table <SQL_Category>().CountAsync(); System.Diagnostics.Debug.WriteLine(allItems); if (allItems_Category == 0) { var Category = new SQL_Category { }; Category.Name = "Kleding"; Category.Income = false; await _connection.InsertAsync(Category); Category.Name = "Drinken"; Category.Income = false; await _connection.InsertAsync(Category); Category.Name = "Eten"; Category.Income = false; await _connection.InsertAsync(Category); Category.Name = "Boodschappen"; Category.Income = false; await _connection.InsertAsync(Category); Category.Name = "Zorg"; Category.Income = false; await _connection.InsertAsync(Category); Category.Name = "Amusement"; Category.Income = false; await _connection.InsertAsync(Category); Category.Name = "Abonnementen"; Category.Income = false; await _connection.InsertAsync(Category); Category.Name = "Loon"; Category.Income = true; await _connection.InsertAsync(Category); Category.Name = "Cadeau"; Category.Income = true; await _connection.InsertAsync(Category); Category.Name = "Winst"; Category.Income = true; await _connection.InsertAsync(Category); Category.Name = "Uitkering"; Category.Income = true; await _connection.InsertAsync(Category); Category.Name = "Creditering"; Category.Income = true; await _connection.InsertAsync(Category); Category.Name = "Inleg Spaardoel"; Category.Income = false; await _connection.InsertAsync(Category); Category.Name = "Toeslagen"; Category.Income = true; await _connection.InsertAsync(Category); } BudgetPlayback(); //DailyBudgetAdd(); }