Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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();
            }
        }
Beispiel #3
0
 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);
     }
 }
Beispiel #4
0
 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);
     }
 }
Beispiel #5
0
        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);
            }
        }
Beispiel #6
0
        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);
            }
        }
Beispiel #7
0
 public DrinkLogPrev(DrinkLog obj)
 {
     this.volumeML = obj.volumeML;
     this.iconRef  = obj.iconRef;
 }