Esempio n. 1
0
        //set enrolement fees button
        async private void SetEnrolementFees(object sender, EventArgs e)
        {
            int cost = 0;
            var item = new EnrolementFees();

            try
            {
                cost      = int.Parse(EnrolementCost.Text);
                item.id   = 0;
                item.cost = cost;

                await App.Database.SaveEnrolementFeesAsync(item);

                item = await App.Database.GetEnrolementFeesAsync(0);

                errorEnrolementMessage.IsVisible = false;
                await Navigation.PushAsync(new SetParameters());

                toast.ShowToast(uploadSuccessfullMessage);
            }
            catch (Exception)
            {
                DisplayAlert(alertTitle, notNumberErrorMessage, alertCheck);
            }
        }
Esempio n. 2
0
        async public Task <int> SaveEnrolementFeesAsync(EnrolementFees enrolementFees)
        {
            var checkIfexists = new EnrolementFees();

            checkIfexists = await GetEnrolementFeesAsync(enrolementFees.id);


            if (checkIfexists != null)
            {
                return(await _database.UpdateAsync(enrolementFees));
            }
            else
            {
                return(await _database.InsertAsync(enrolementFees));
            }
        }
Esempio n. 3
0
 //Mandatory Fees
 async public void addEnrolementFees(int cost)
 {
     EnrolementFees enrolementFees = new EnrolementFees(); enrolementFees.id = 0; enrolementFees.cost = cost;
     await App.Database.SaveEnrolementFeesAsync(enrolementFees);;
 }
Esempio n. 4
0
        //Calculate the total and display errors
        async void Button_Calculate(object sender, EventArgs e)
        {
            //scroll to the end
            await ChildScrollView.ScrollToAsync(ResultLabel, ScrollToPosition.End, true).ConfigureAwait(true);

            //set all pickers
            Picker yearPicker         = YearPicker as Picker;
            Picker termDiscountPicker = TermDiscountPicker as Picker;
            Picker zonePicker         = ZonePicker as Picker;
            Picker supervisionPicker  = SupervisionPicker as Picker;
            Picker supportPicker      = SupportPicker as Picker;
            //set all picked parameters
            string year;
            string zone;
            string assistanceDicountName;
            string siblingDicountName;
            string termDiscountName;
            string supervisionName;
            string supportName;

            child = (Child)BindingContext;

            try
            {
                year = yearPicker.SelectedItem.ToString();

                if (year == "<Empty>")
                {
                    child.yearName                = null;
                    child.tuitionFees             = 0;
                    child.fixedCharges            = 0;
                    child.externalExaminationFees = 0;
                    child.schoolMeals             = 0;
                    child.wednesdayMeals          = 0;
                }
                //Get all corresponding cost

                EnrolementFees enrolementFee = await App.Database.GetEnrolementFeesAsync(0);

                TuitionFees tuitionFees = await App.Database.GetTuitionFeesAsync(year);

                FixedCharges fixedCharges = await App.Database.GetFixedChargesAsync(year);

                ExternalExaminationFees examinationFees = await App.Database.GetExternalExaminationFeesAsync(year);

                //set mandatory fees Child with entries provided by user
                child.yearName                = year;
                child.enrolementFee           = enrolementFee.cost;
                child.tuitionFees             = tuitionFees.cost;
                child.recalculatedTuitionFees = tuitionFees.cost;
                child.fixedCharges            = fixedCharges.cost;
                child.externalExaminationFees = examinationFees.cost;

                // enrolementFeeValue.Text = n.ToNumberFormat() + devise;
                enrolementFeeValue.Text           = n.ToNumberFormat(child.enrolementFee) + devise;
                tuitionFeesValue.Text             = n.ToNumberFormat(child.tuitionFees) + devise;
                fixedChargesValue.Text            = n.ToNumberFormat(child.fixedCharges) + devise;
                externalExaminationFeesValue.Text = n.ToNumberFormat(child.externalExaminationFees) + devise;
            }
            catch (Exception) { }

            // set Optionnal assistance discount
            try
            {
                assistanceDicountName = childrenNr[0];
                if (assistanceDiscountCheckBox.IsChecked == false)
                {
                    child.assistanceDiscountName = null;
                    child.assistanceDiscount     = 0;
                }
                else
                {
                    AssistanceDiscount assistanceDiscount = await App.Database.GetAssistanceDiscountAsync(assistanceDicountName);

                    child.assistanceDiscount     = assistanceDiscount.discountPercentage;
                    child.assistanceDiscountName = assistanceDicountName;
                }
                assistanceDiscountValue.Text  = n.ToNumberFormat(child.assistanceDiscount * child.tuitionFees / 100) + devise;
                child.recalculatedTuitionFees = child.tuitionFees * (100 + child.assistanceDiscount) / 100;
            }
            catch (Exception) { }

            // set Optionnal sibling discount
            try
            {
                siblingDicountName = childrenNr[1];
                if (siblingDiscountCheckBox.IsChecked == false)
                {
                    child.siblingDiscountName = null;
                    child.siblingDiscount     = 0;
                }
                else
                {
                    AssistanceDiscount siblingDiscount = await App.Database.GetAssistanceDiscountAsync(siblingDicountName);

                    child.siblingDiscount     = siblingDiscount.discountPercentage;
                    child.siblingDiscountName = siblingDicountName;
                }
                siblingDiscountValue.Text     = n.ToNumberFormat(child.siblingDiscount * (child.recalculatedTuitionFees) / 100) + devise;
                child.recalculatedTuitionFees = child.recalculatedTuitionFees * (100 + child.siblingDiscount) / 100;
            }
            catch (Exception) { }


            // set Optionnal term discount
            try
            {
                termDiscountName = termDiscountPicker.SelectedItem.ToString();
                if (termDiscountName == "<Empty>")
                {
                    child.termDiscountName = null;
                    child.termDiscount     = 0;
                }
                else
                {
                    TermDiscount termDiscount = await App.Database.GetTermDiscountAsync(termDiscountName);

                    child.termDiscount     = termDiscount.discountPercentage;
                    child.termDiscountName = termDiscountName;
                }
                termDiscountValue.Text        = n.ToNumberFormat(child.termDiscount * (child.tuitionFees - child.assistanceDiscount) / 100) + devise;
                child.recalculatedTuitionFees = (child.recalculatedTuitionFees - child.assistanceDiscount - child.siblingDiscount) * (100 + child.termDiscount) / 100;
            }
            catch (Exception) { }

            // set Optionnal school meal
            try
            {
                if (schoolMealsCheckBox.IsChecked)
                {
                    year = yearPicker.SelectedItem.ToString();
                    SchoolMeals schoolMeals = await App.Database.GetSchoolMealsAsync(year);

                    child.schoolMeals = schoolMeals.cost;
                }
                else
                {
                    child.schoolMeals = 0;
                }
                schoolMealsValue.Text = n.ToNumberFormat(child.schoolMeals) + devise;
            }
            catch (Exception) { }

            // set Optionnal wednesday meal
            try
            {
                if (wednesdayMealsCheckBox.IsChecked)
                {
                    year = yearPicker.SelectedItem.ToString();
                    WednesdayMeals wednesdayMeals = await App.Database.GetWednesdayMealsAsync(year);

                    child.wednesdayMeals = wednesdayMeals.cost;
                }
                else
                {
                    child.wednesdayMeals = 0;
                }
                wednesdayMealsValue.Text = n.ToNumberFormat(child.wednesdayMeals) + devise;
            }
            catch (Exception) { }

            // set Optionnal school transport
            try
            {
                zone = zonePicker.SelectedItem.ToString();
                if (zone == "<Empty>")
                {
                    child.zoneName        = null;
                    child.schoolTransport = 0;
                }
                else
                {
                    SchoolTransport schoolTransport = await App.Database.GetSchoolTransportAsync(zone);

                    child.schoolTransport = schoolTransport.cost;
                    child.zoneName        = zone;
                }
                schoolTransportValue.Text = n.ToNumberFormat(child.schoolTransport) + devise;
            }
            catch (Exception) { }

            // set Optionnal supervision
            try
            {
                supervisionName = supervisionPicker.SelectedItem.ToString();
                if (supervisionName == "<Empty>")
                {
                    child.supervisionName = null;
                    child.supervision     = 0;
                }
                else
                {
                    Supervision supervision = await App.Database.GetSupervisionAsync(supervisionName);

                    child.supervision     = supervision.cost;
                    child.supervisionName = supervisionName;
                }
                supervisionValue.Text = n.ToNumberFormat(child.supervision) + devise;
            }
            catch (Exception) { }
            // set Optionnal support transport
            try
            {
                supportName = supportPicker.SelectedItem.ToString();
                if (supportName == "<Empty>")
                {
                    child.supportName = null;
                    child.support     = 0;
                }
                else
                {
                    Support support = await App.Database.GetSupportAsync(supportName);

                    child.support     = support.cost;
                    child.supportName = supportName;
                }
                supportValue.Text = n.ToNumberFormat(child.support) + devise;
            }
            catch (Exception) { }
            child.childName = ChildNameValue.Text; //set the child name if it has been modified
            //set total child cost
            child.cost = (child.fixedCharges + child.recalculatedTuitionFees + child.enrolementFee + child.externalExaminationFees + child.schoolMeals + child.schoolTransport + child.supervision + child.support);
            Family family = await App.Database.GetFamilyByIdAsync(child.familyId);

            family.totalCost = family.totalCost + child.cost;
            await App.Database.SaveFamilyAsync(family);

            //save child in database
            await App.Database.SaveChildAsync(child);

            //Display result
            ResultLabel.Text = n.ToNumberFormat(child.cost) + devise;
        }