Example #1
0
        async private void UpdateChildList()
        {
            ChildDatabaseAccess childDatabase = new ChildDatabaseAccess();
            await childDatabase.InitializeAsync();

            List <Child> children = childDatabase.GetAllUserChildrenAsync().Result;

            this.ChildList.ItemsSource = children;
        }
Example #2
0
    /**
     * Add or update milestone response history for the given milestone ID and BinaryAnswer.
     **/
    public Boolean RemoveFromVaccineHistory(int vaccineID)
    {
        ChildDatabaseAccess childDB = new ChildDatabaseAccess();

        childDB.InitializeSync();
        Vaccinations.RemoveFromVaccinationHistory(vaccineID);
        childDB.SaveUserChildSync(this);
        childDB.CloseSyncConnection();
        return(true);
    }
Example #3
0
    /**
     * Adds a measurement to a Child profile. This will update the Child's entry in the local database to reflect the change.
     **/
    public Boolean AddMeasurementForDateAndType(DateTime date, MeasurementType measurementType, Units currentUnits, double value)
    {
        ChildDatabaseAccess childDB = new ChildDatabaseAccess();

        childDB.InitializeSync();
        Measurements.AddMeasurementForDateAndType(date, measurementType, currentUnits, value);
        childDB.SaveUserChildSync(this);
        childDB.CloseSyncConnection();
        return(true);
    }
Example #4
0
 /**
  * Checks a ChildDatabase object to see if it is null or is unconnected. Creates new ChildDatabase and/or initialize connection
  *  as necessary.
  **/
 private ChildDatabaseAccess CheckChildDatabaseConnection(ChildDatabaseAccess childDatabase)
 {
     if (null == childDatabase)
     {
         childDatabase = new ChildDatabaseAccess();
     }
     if (!childDatabase.IsConnected)
     {
         childDatabase.InitializeSync();
     }
     return(childDatabase);
 }
Example #5
0
    /**
     * Add or update milestone response history for the given milestone ID and BinaryAnswer.
     **/
    public Boolean AddOrUpdateMilestoneHistory(int milestoneID, BinaryAnswer answer)
    {
        ChildDatabaseAccess childDB = new ChildDatabaseAccess();

        childDB.InitializeSync();
        Milestones.AddOrUpdateMilestoneHistory(milestoneID, answer);
        childDB.SaveUserChildSync(this);

        childDB.CloseSyncConnection();

        return(true);
    }
Example #6
0
 /**
  * Retrieve Child from database corresponding to the current value of ChildID. Return null if Context null or if no child selected for context.
  **/
 public Child GetSelectedChild()
 {
     if (this == null)
     {
         return(null);
     }
     // Retrieve child object if child selected. This can break and return null if child has been deleted and Context hasn't been reset.
     if (_childId != ContextBuilder.NO_CHILD_SELECTED)
     {
         ChildDatabaseAccess childDBAccess = new ChildDatabaseAccess();
         childDBAccess.InitializeSync();
         return(childDBAccess.GetUserChildSync(_childId));
     }
     else
     {
         return(null);
     }
 }
Example #7
0
        async void OnDelete(object sender, System.EventArgs e)
        {
            MenuItem item  = (MenuItem)sender;
            Child    C     = (Child)item.CommandParameter;
            var      alert = await DisplayAlert("Warning", "Are You Sure You Want To Delete Child: " + C.Name, "Delete", "Cancel");

            if (alert.Equals(true))
            {
                var try1 = item.GetType();
                ChildDatabaseAccess childDatabase = new ChildDatabaseAccess();
                await childDatabase.InitializeAsync();

                await childDatabase.DeleteUserChildAsync(C);

                UpdateChildList();
                await Task.Run(async() => { await UpdateChild(null); });
            }
        }
Example #8
0
    /**
     * Removes a measurement from a Child profile. This will update the Child's entry in the database to reflect the change.
     **/
    public Boolean RemoveMeasurementForDateAndType(DateTime date, MeasurementType measurementType)
    {
        ChildDatabaseAccess childDB = new ChildDatabaseAccess();

        childDB.InitializeSync();
        Boolean data_removed = this.Measurements.RemoveMeasurementForDateAndType(date, measurementType);

        if (data_removed)
        {
            childDB.SaveUserChildSync(this);
            childDB.CloseSyncConnection();
            return(true);
        }
        else
        {
            childDB.CloseSyncConnection();
            return(false);
        }
    }
        private void TryLoadingMeasurementDataForDateAndChild(DateTime date, Child child)
        {
            if (date == null || child == null)
            {
                return;
            }
            ChildDatabaseAccess childDatabaseAccess = new ChildDatabaseAccess();
            GrowthMeasurement   height = child.GetMeasurementForDateAndType(date, MeasurementType.HEIGHT);

            if (height != null)
            {
                HeightEntry.Text = height.Value.ToString();
            }
            else
            {
                HeightEntry.Text = "";
            }
            GrowthMeasurement weight = child.GetMeasurementForDateAndType(date, MeasurementType.WEIGHT);

            if (weight != null)
            {
                WeightEntry.Text = weight.Value.ToString();
            }
            else
            {
                WeightEntry.Text = "";
            }
            GrowthMeasurement headC = child.GetMeasurementForDateAndType(date, MeasurementType.HEAD_CIRCUMFERENCE);

            if (headC != null)
            {
                HeadEntry.Text = headC.Value.ToString();
            }
            else
            {
                HeadEntry.Text = "";
            }
        }
        async void AddChildButton_Clicked(object sender, EventArgs e)
        {
            string nameEntered = nameEntry.Text;

            DateTime birthdayEntered = birthdayEntry.Date;

            Gender genderSelected = newChildGender;

            Boolean missingInfo = false;

            int index = SexEntry.SelectedIndex;

            string sex;

            if (nameEntered == null || nameEntered == "")
            {
                await DisplayAlert("Failed", "Please Enter your child's Name", "OK");

                missingInfo = true;
            }
            else if (birthdayEntered == null)
            {
                await DisplayAlert("Failed", "Please Enter your child's birthday.", "OK");

                missingInfo = true;
            }
            else if (SexEntry.SelectedIndex == -1)
            {
                await DisplayAlert("Failed", "Please Enter your child's sex.", "OK");

                missingInfo = true;
            }
            if (missingInfo)
            {
                return;
            }
            else
            {
                sex = (string)SexEntry.ItemsSource[index];
                if (sex == "Male")
                {
                    newChildGender = Gender.MALE;
                }
                else
                {
                    newChildGender = Gender.FEMALE;
                }
                ChildDatabaseAccess childDatabase = new ChildDatabaseAccess();
                childDatabase.InitializeSync();
                Child newChild = new Child(nameEntered, birthdayEntered, newChildGender);
                childDatabase.SaveUserChildSync(newChild);
                childDatabase.CloseSyncConnection();
                ContextDatabaseAccess contextDB = new ContextDatabaseAccess();
                contextDB.InitializeSync();
                Context context = contextDB.GetContextSync();
                context.ChildId = newChild.ID;
                contextDB.SaveContextSync(context);
                contextDB.CloseSyncConnection();
            }

            await Navigation.PopModalAsync();
        }
        /// <summary>
        /// Submit Height, Weight, and HeadC
        /// </summary>
        async void OnSubmitClicked(object sender, EventArgs args)
        {
            Double Height = DEFAULT_MEASUREMENT_VALUE;
            Double Weight = DEFAULT_MEASUREMENT_VALUE;
            Double HeadC  = DEFAULT_MEASUREMENT_VALUE;

            try
            {
                Height = Double.Parse(HeightEntry.Text);
            }
            catch
            {
            }
            try
            {
                Weight = Double.Parse(WeightEntry.Text);
            }
            catch
            {
            }
            try
            {
                HeadC = Double.Parse(HeadEntry.Text);
            }
            catch
            {
            }

            Button button = (Button)sender;

            //TODO STEFAN: Replace this with an await call to SQLite
            ChildDatabaseAccess childDatabase = new ChildDatabaseAccess();
            DateTime            selectedDate  = GetSelectedDate();
            Units currentUnits = GetCurrentUnits();

            if (CurrentChild != null)
            {
                try
                {
                    if (DEFAULT_MEASUREMENT_VALUE != Height)
                    {
                        CurrentChild.AddMeasurementForDateAndType(selectedDate, MeasurementType.HEIGHT, currentUnits, Height);
                    }
                    if (DEFAULT_MEASUREMENT_VALUE != Weight)
                    {
                        CurrentChild.AddMeasurementForDateAndType(selectedDate, MeasurementType.WEIGHT, currentUnits, Weight);
                    }
                    if (DEFAULT_MEASUREMENT_VALUE != HeadC)
                    {
                        CurrentChild.AddMeasurementForDateAndType(selectedDate, MeasurementType.HEAD_CIRCUMFERENCE, currentUnits, HeadC);
                    }
                    UpdateSelectedMeasurements();
                }
                catch (Exception e)
                {
                }

                List <Points> points = _currentChild.GetSortedMeasurementListByType(MeasurementType.WEIGHT);
                if (points == null)
                {
                    _currentChild.AddMeasurementForDateAndType(_currentChild.Birthday, MeasurementType.WEIGHT, CurrentContext.CurrentUnits, 0.0);
                    return;
                }
                foreach (Points pt in points)
                {
                    viewModel.InputData.Add(pt);
                }
            }
        }