private async void StackLayout_Focused(object sender, FocusEventArgs e) { try { addSalary add = new addSalary() { mySalary = Salary.Text, mySource = source.Text, date = DateTime.Now.ToString() }; } catch (Exception ex) { await DisplayAlert("Alert", ex.ToString(), "OK"); } }
private async void ButtonSalary_Clicked(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(Salary.Text) || String.IsNullOrEmpty(source.Text)) { await DisplayAlert("Alert", "Please enter all fields? ", "OK"); } else { var result = await DisplayAlert("Confirmation", "Are you sure? ", "Yes", "Cancel"); if (result == true) { addSalary add = new addSalary() { mySalary = Salary.Text, mySource = source.Text, date = DateTime.Now.ToString() }; using (SQLiteConnection conn = new SQLiteConnection(App.filePath)) { conn.CreateTable <addSalary>(); int rows = conn.Insert(add); } // if (result == true && !Salary.Text.Equals("") && !source.Text.Equals("")) { using (SQLiteConnection conn = new SQLiteConnection(App.filePath)) { conn.CreateTable <ActiveMoney>(); var foreign = conn.Query <ActiveMoney>("SELECT mySalary FROM ActiveMoney"); if (foreign.Count == 0) { ActiveMoney addFunds = new ActiveMoney() { mySalary = Salary.Text, }; conn.CreateTable <ActiveMoney>(); int rows = conn.Insert(addFunds); } else { global = new globals(); total = global.calculateTotal(double.Parse(Salary.Text)); var updateMarks = conn.ExecuteScalar <ActiveMoney>("UPDATE ActiveMoney Set mySalary = ?", total); } } Salary.Text = ""; source.Text = ""; } OnAppearing(); } } } catch (Exception ex) { await DisplayAlert("Alert", ex.ToString(), "OK"); } }