public void onClickAddDrink(object sender, EventArgs e) { if (!FindViewById <EditText>(Resource.Id.editText_customAddWater).Text.Trim().Equals("")) { DrinkLog newDrinkLog = new DrinkLog(double.Parse(FindViewById <EditText>(Resource.Id.editText_customAddWater).Text)); drinkLogList.Add(newDrinkLog); DBServices.Instance.AddDrinkLogEntry(newDrinkLog); ((TodayDrinkLogGridAdapter)FindViewById <GridView>(Resource.Id.TodayDrinkLogGrid).Adapter).NotifyDataSetChanged(); showHideNoDrinkDefaultText(); computeProgressTexts(); //clear editbox FindViewById <EditText>(Resource.Id.editText_customAddWater).Text = ""; FindViewById <EditText>(Resource.Id.editText_customAddWater).ClearFocus(); //remove keyboard InputMethodManager imm = (InputMethodManager)GetSystemService(Context.InputMethodService); imm.HideSoftInputFromWindow(FindViewById <EditText>(Resource.Id.editText_customAddWater).WindowToken, 0); //record last drink log DBServices.Instance.UpdatePrevDrinkLog(newDrinkLog); } }
public void onClickRepeatDrink(object sender, EventArgs e) { DrinkLog prev_drink_log = DBServices.Instance.SelectDrinkLogPrev(); if (prev_drink_log != null) { drinkLogList.Add(prev_drink_log); DBServices.Instance.AddDrinkLogEntry(prev_drink_log); ((TodayDrinkLogGridAdapter)FindViewById <GridView>(Resource.Id.TodayDrinkLogGrid).Adapter).NotifyDataSetChanged(); showHideNoDrinkDefaultText(); computeProgressTexts(); } }
public int DeleteDrinkLogEntry(DrinkLog obj) { try { if (db_connection != null) { return(db_connection.CreateCommand("DELETE FROM DrinkLog WHERE ID=?", obj.ID).ExecuteNonQuery()); } Log.Warn("DBServices", "DB connection does not exist"); return(-1); } catch (SQLiteException ex) { Log.Warn("DBServices", ex.Message); return(-1); } }
public string AddDrinkLogEntry(DrinkLog obj) { try { if (db_connection != null) { return(db_connection.Insert(obj).ToString()); } Log.Warn("DBServices", "DB connection does not exist"); return("DB connection does not exist"); } catch (SQLiteException ex) { Log.Warn("DBServices", ex.Message); return(ex.Message); } }
public string UpdatePrevDrinkLog(DrinkLog obj) { try { if (db_connection != null) { // Only one row should be there in DrinkLogPrev table db_connection.CreateCommand("DELETE FROM DrinkLogPrev").ExecuteNonQuery(); return(db_connection.Insert(new DrinkLogPrev(obj)).ToString()); } Log.Warn("DBServices", "DB connection does not exist"); return("DB connection does not exist"); } catch (SQLiteException ex) { Log.Warn("DBServices", ex.Message); return(ex.Message); } }
public string UpdateDrinkLogEntry(DrinkLog obj) { try { if (db_connection != null) { int rowsAffected = db_connection.Update(obj); if (rowsAffected == 0) { Log.Warn("DBServices", "No records found with the primary key of the obj"); return("No records found with the primary key of the obj"); } return(rowsAffected.ToString()); } Log.Warn("DBServices", "DB connection does not exist"); return("DB connection does not exist"); } catch (SQLiteException ex) { Log.Warn("DBServices", ex.Message); return(ex.Message); } }
public DrinkLogPrev(DrinkLog obj) { this.volumeML = obj.volumeML; this.iconRef = obj.iconRef; }