Пример #1
0
        //Fixed charges
        async private void UpdateFixedChargeButton(object sender, EventArgs e)
        {
            try
            {
                yearPicker = YearPicker as Picker;
                int yearCost     = 0;
                var fixedCharges = new FixedCharges();

                fixedCharges.yearName = yearPicker.SelectedItem.ToString();
                try
                {
                    fixedCharges.cost = int.Parse(FixedChargeCost.Text);
                }
                catch (Exception)
                {
                    DisplayAlert(alertTitle, notNumberErrorMessage, alertCheck);
                }
                await App.Database.SaveFixedChargesAsync(fixedCharges);

                toast.ShowToast(uploadSuccessfullMessage);
            }
            catch (Exception)
            {
                DisplayAlert(alertTitle, nullNameErrorMessage, alertCheck);
            }
        }
Пример #2
0
        public ActionResult NewOrEdit(FixedCharges model)
        {
            try
            {
                var db = DB.Entities;

                if (model.ID == 0)
                {
                    // Edit
                    db.FixedCharges.AddObject(model);
                }
                else
                {
                    // Add new
                    db.AttachTo("FixedCharges", model);
                    db.ObjectStateManager.ChangeObjectState(model, System.Data.EntityState.Modified);
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
            }
            SelectOption(model);
            return(View(model));
        }
Пример #3
0
        void SelectOption(FixedCharges obj)
        {
            #region SELECT OPTION
            string dataDriver_Info = "<option value=''>--Select Driver_Info--</option>";
            foreach (var item in NationalIT.DB.Entities.Driver_Info)
            {
                if (obj.DriverID.HasValue && item.ID == obj.DriverID.Value)
                {
                    dataDriver_Info += string.Format("<option value='{0}' selected='selected'>{1} {2}</option>", item.ID, item.Last_name, item.First_name);
                }
                else
                {
                    dataDriver_Info += string.Format("<option value='{0}'>{1} {2}</option>", item.ID, item.Last_name, item.First_name);
                }
            }

            ViewBag.dataDriver_Info = dataDriver_Info;
            string dataFrequency = "<option value='0'>-:-</option>";
            foreach (var item in NationalIT.DB.Entities.Frequency)
            {
                if (obj.Frequency != 0)
                {
                    dataFrequency += string.Format("<option value='{0}' selected='selected'>{1}</option>", item.ID, item.Title);
                }
                else
                {
                    dataFrequency += string.Format("<option value='{0}'>{1}</option>", item.ID, item.Title);
                }
            }

            ViewBag.dataFrequency = dataFrequency;

            #endregion
        }
Пример #4
0
        public ActionResult NewOrEdit(int?driverID, int?id = 0)
        {
            var obj = DB.Entities.FixedCharges.FirstOrDefault(m => m.ID == id);

            if (obj == null)
            {
                obj = new FixedCharges()
                {
                    DriverID = driverID.HasValue ? driverID.Value : 0
                };
            }
            SelectOption(obj);
            return(View(obj));
        }
Пример #5
0
        async public Task <int> SaveFixedChargesAsync(FixedCharges fixedCharges)
        {
            var checkIfexists = new FixedCharges();

            checkIfexists = await GetFixedChargesAsync(fixedCharges.yearName);


            if (checkIfexists != null)
            {
                return(await _database.UpdateAsync(fixedCharges));
            }
            else
            {
                return(await _database.InsertAsync(fixedCharges));
            }
        }
Пример #6
0
        async private void DeleteYearFeesButton(object sender, EventArgs e)
        {
            try
            {
                // delete tuition fees
                yearPicker = YearPicker as Picker;
                var tuitionfees = new TuitionFees();

                tuitionfees.yearName = yearPicker.SelectedItem.ToString();
                await App.Database.DeleteTuitionFeesAsync(tuitionfees);

                //delete fixed charge
                var fixedCharges = new FixedCharges();

                fixedCharges.yearName = yearPicker.SelectedItem.ToString();
                await App.Database.DeleteFixedChargesAsync(fixedCharges);

                // delete external examination fees
                var externalExaminationFees = new ExternalExaminationFees();

                externalExaminationFees.yearName = yearPicker.SelectedItem.ToString();
                await App.Database.DeleteExternalExaminationFeesAsync(externalExaminationFees);

                // delete school meals
                var schoolMeals = new SchoolMeals();

                schoolMeals.yearName = yearPicker.SelectedItem.ToString();
                await App.Database.DeleteSchoolMealsAsync(schoolMeals);

                //deleste wednseday meals
                var wednesdayMeals = new WednesdayMeals();

                wednesdayMeals.yearName = yearPicker.SelectedItem.ToString();
                await App.Database.DeleteWednesdayMealsAsync(wednesdayMeals);

                await Navigation.PushAsync(new UpdateParameters());

                toast.ShowToast(deleteMessage);
            }
            catch (Exception)
            {
                DisplayAlert(alertTitle, nullNameErrorMessage, alertCheck);
            }
        }
Пример #7
0
        //set fixed charges button
        async private void SetFixedCharges(object sender, EventArgs e)
        {
            int cost         = 0;
            var fixedCharges = new FixedCharges();;

            if (!(string.IsNullOrEmpty(FixedChargesYear.Text)))
            {
                try
                {
                    cost = int.Parse(FixedChargesCost.Text);
                }
                catch (Exception)
                {
                    DisplayAlert(alertTitle, notNumberErrorMessage, alertCheck);
                }
                try
                {
                    fixedCharges.yearName = FixedChargesYear.Text;
                    await App.Database.SaveFixedChargesAsync(fixedCharges);

                    fixedCharges = await App.Database.GetFixedChargesAsync(FixedChargesYear.Text);

                    errorFixedChargesCostMessage.IsVisible = false;
                    fixedCharges.cost = cost;
                    await Navigation.PushAsync(new SetParameters());

                    toast.ShowToast(uploadSuccessfullMessage);
                }
                catch (Exception)
                {
                    DisplayAlert(alertTitle, nullNameErrorMessage, alertCheck);
                }
            }
            else
            {
                DisplayAlert(alertTitle, nullNameErrorMessage, alertCheck);
            }
        }
Пример #8
0
 async public void addFixedCharges(String year, int cost)
 {
     FixedCharges fixedCharges = new FixedCharges(); fixedCharges.yearName = year; fixedCharges.cost = cost;
     await App.Database.SaveFixedChargesAsync(fixedCharges);
 }
Пример #9
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;
        }
Пример #10
0
 public Task <int> DeleteFixedChargesAsync(FixedCharges fixedCharges)
 {
     return(_database.DeleteAsync(fixedCharges));
 }