Beispiel #1
0
        private void CalculateSalary()
        {
            Child  child = BlTools.GetChild(int.Parse(Update_Child_ID_TextBlock.Text));
            Nanny  nanny = BlTools.GetNanny(int.Parse(Update_Nanny_ID_TextBlock.Text));
            double salary;

            if (!nanny.NannyIsHourlySalary)
            {
                Payment_Method_ComboBox.IsEnabled    = false;
                Hourly_ComboBoxItem.Visibility       = Visibility.Collapsed;
                Payment_Method_ComboBox.SelectedItem = Monthly_ComboBoxItem;
                salary      = BlTools.CalculateMonthlySalary(nanny, child);
                finalSalary = salary;
                Calculated_Wage_TextBlock.Text = Convert.ToString(salary) + " NIS";
            }
            else
            {
                Hourly_ComboBoxItem.Visibility = Visibility.Visible;
                if (Payment_Method_ComboBox.SelectedItem != null)
                {
                    if (Payment_Method_ComboBox.SelectedIndex == 1)
                    {
                        salary = BlTools.CalculateMonthlySalary(nanny, child);
                        Calculated_Wage_TextBlock.Text = Convert.ToString(salary) + " NIS";
                        finalSalary = salary;
                    }
                    if (Payment_Method_ComboBox.SelectedIndex == 0)
                    {
                        salary = BlTools.CalculateHourlySalary(nanny, child);
                        Calculated_Wage_TextBlock.Text = Convert.ToString(salary) + " NIS";
                        finalSalary = salary;
                    }
                }
            }
        }
        public void AddContract(Contract inputContract)
        {
            Nanny nanny = DalTools.GetNanny(inputContract.NannyID);
            Child child = DalTools.GetChild(inputContract.ChildID);

            //cheak if the age of the infant is under 3 month
            DateTime age = (DalTools.GetChild(inputContract.ChildID)).ChildAge;

            age.AddMonths(3);
            if (DateTime.Now < age)
            {
                throw new Exception("Can't add Child to Contract under 3 months");
            }

            //checks if nanny capacity is full
            if (nanny.IsNannyCapacityIsFull())
            {
                throw new Exception("Nanny hace reached the maximum infants capacity...");
            }

            //checks if child age is not over the maximum/minimum nanny accepts
            int childAgeInMonths = child.AgeInMonths();

            if (childAgeInMonths < nanny.NannyMinInfantAge || childAgeInMonths > nanny.NannyMaxInfantAge)
            {
                throw new Exception("Nanny can't accept this age");
            }

            if (inputContract.IsContractSigned)
            {
                //checks if contract salary calculated by month or by hour and updates the salary nanny
                if (inputContract.PaymentMethod == Payment_method.hourly)
                {
                    inputContract.HourlySalary = BlTools.CalculateHourlySalary(nanny, child);
                }
                else
                {
                    inputContract.MonthlySalary = BlTools.CalculateMonthlySalary(nanny, child);
                }
            }



            BlTools.GetChild(inputContract.ChildID).IsHaveNanny = true;
            dal.AddContract(inputContract);
        }
Beispiel #3
0
        private void CalculateSalary()
        {
            Payment_Method_ComboBox.IsEnabled = true;
            Child  child = All_Childs_ComboBox.SelectedItem as Child;
            Nanny  nanny = All_Nannies_ComboBox.SelectedItem as Nanny;
            double salary;

            if (!nanny.NannyIsHourlySalary)
            {
                Payment_Method_ComboBox.IsEnabled    = false;
                Hourly_ComboBoxItem.Visibility       = Visibility.Collapsed;
                Payment_Method_ComboBox.SelectedItem = Monthly_ComboBoxItem;
                salary = BlTools.CalculateMonthlySalary(nanny, child);
                Calculated_Wage_TextBox.Text = Convert.ToString(salary) + " NIS";
                newContract.MonthlySalary    = salary;
            }
            else
            {
                Hourly_ComboBoxItem.Visibility = Visibility.Visible;
                if (Payment_Method_ComboBox.SelectedItem != null)
                {
                    if (Payment_Method_ComboBox.SelectedIndex == 1)
                    {
                        salary = BlTools.CalculateMonthlySalary(nanny, child);
                        Calculated_Wage_TextBox.Text = Convert.ToString(salary) + " NIS";
                        newContract.MonthlySalary    = salary;
                    }
                    if (Payment_Method_ComboBox.SelectedIndex == 0)
                    {
                        salary = BlTools.CalculateHourlySalary(nanny, child);
                        Calculated_Wage_TextBox.Text = Convert.ToString(salary) + " NIS";
                        newContract.HourlySalary     = salary;
                    }
                }
            }
        }