Esempio n. 1
0
 public void UpdateLogEntry(LogEntry selectedLogEntry)
 {
     using (var dbConn = new SQLiteConnection(App.DB_PATH))
     {
         dbConn.Update(selectedLogEntry);
     }
 }
Esempio n. 2
0
 public void CreateLogEntry(LogEntry myEntrie)
 {
     using (var dbConn = new SQLiteConnection(App.DB_PATH))
     {
         dbConn.Insert(myEntrie);
     }
 }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter.GetType() == typeof(Exercise))
            {
                selectedExercise = (Exercise)e.Parameter;
                int lastSetNo = _logEntryDao.GetLastSetNo(selectedExercise, pckDate.Date.Date);
                int newSetNo = ++lastSetNo;
                txtSet.Text = newSetNo.ToString();
            }
            else if (e.Parameter.GetType() == typeof(PayLoad))
            {
                PayLoad myPayload = new PayLoad();
                myPayload = (PayLoad)e.Parameter;

                selectedLogEntry = myPayload.Entry;
                selectedExercise = _exerciseDao.GetExerciseById(selectedLogEntry.ExerciseID);

                pckDate.Date = selectedLogEntry.LogDate;
                txtSet.Text = selectedLogEntry.SetNo;
                txtReps.Text =  selectedLogEntry.Reps;
                txtWeight.Text = selectedLogEntry.Weight;
                txtComments.Text = selectedLogEntry.Comments;

                if (myPayload.Status == "View")
                {
                    SetViewReadOnly();
                } else
                {
                    SetViewEdit();
                }
            }

            lblTitle.Text = selectedExercise.Name;
        }
        private async void AcceptButton_Click(object sender, RoutedEventArgs e)
        {

            if (txtReps.Text == "")
            {
                MessageDialog msgbox = new MessageDialog("No reps entered.");
                await msgbox.ShowAsync();
            }
            else if (selectedLogEntry == null)
            {
                selectedLogEntry = new LogEntry();

                selectedLogEntry = UpdateLogEntry();

                _logEntryDao.CreateLogEntry(selectedLogEntry);                            
            }
            else
            {
                selectedLogEntry = UpdateLogEntry();
                _logEntryDao.UpdateLogEntry(selectedLogEntry);
            }

            Frame.GoBack();
        }