/// <summary>
 /// add the mother that have enter
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void AddMotherButton_Click(object sender, RoutedEventArgs e)
 {
     if (errorMessages.Any()) //errorMessages.Count > 0
     {
         string err = "Exception:";
         foreach (var item in errorMessages)
         {
             err += "\n" + item;
         }
         System.Windows.MessageBox.Show(err);
         return;
     }
     try
     {
         #region initialization
         mother.Address = addressPlaceAutoCompleteUC.Text;
         mother.Area    = areaPlaceAutoCompleteUC.Text;
         #endregion
         bl.AddMother(mother);
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show(ex.Message);
         return;
     }
     this.Close();
 }
        private void AddMotherButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (errorMessages.Any()) //errorMessages.Count > 0
                {
                    string err = "Exception:";
                    foreach (var item in errorMessages)
                    {
                        err += "\n" + item;
                    }

                    MessageBox.Show(err);
                    return;
                }
                else
                {
                    MessageBoxResult result =
                        MessageBox.Show(
                            "Are the details correct?\n\n" + mother.ToString(),
                            "Confirm Mother Details",
                            MessageBoxButton.OKCancel,
                            MessageBoxImage.Question);

                    if (result == MessageBoxResult.OK)
                    {
                        bl.AddMother(mother);
                        MessageBox.Show(
                            $"{mother.FirstName} {mother.LastName} was added successfully!\n\n" + mother.ToString(),
                            "Add New Mother");
                        refreshData();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        /// <summary>
        /// checks exceptions and adding the mother
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            #region check exceptions

            bool isChecked = false;
            try
            {
                if (string.IsNullOrEmpty(idTextBox.Text))
                {
                    throw new Exception("fill the id!");
                }
                if (!int.TryParse(idTextBox.Text, out int i))
                {
                    throw new Exception("enter id in numbers!");
                }

                bool alreadyExist = myBl.MothersByPredicate().Any(x => x.Id == int.Parse(idTextBox.Text));
                if (alreadyExist)
                {
                    throw new Exception("The mother already exist!");
                }

                if (string.IsNullOrEmpty(firstNameTextBox.Text))
                {
                    throw new Exception("fill the first name!");
                }
                if (int.TryParse(firstNameTextBox.Text, out i))
                {
                    throw new Exception("invalid first name!");
                }

                if (string.IsNullOrEmpty(lastNameTextBox.Text))
                {
                    throw new Exception("fill the last name!");
                }
                if (int.TryParse(lastNameTextBox.Text, out i))
                {
                    throw new Exception("invalid last name!");
                }

                if (string.IsNullOrEmpty(addressTextBox.Text))
                {
                    throw new Exception("fill the address!");
                }
                if (int.TryParse(addressTextBox.Text, out i))
                {
                    throw new Exception("invalid address!");
                }

                if (string.IsNullOrEmpty(cellphoneTextBox.Text))
                {
                    throw new Exception("fill the cellphone!");
                }
                if (int.TryParse(cellphoneTextBox.Text, out i))
                {
                    throw new Exception("invalid cellphone!");
                }
                if (cellphoneTextBox.Text == "like: 052-1234578")
                {
                    throw new Exception("fill real cellphone!");
                }

                if (int.TryParse(areaNannyTextBox.Text, out i))
                {
                    throw new Exception("invalid area nanny!");
                }

                if (string.IsNullOrEmpty(notesTextBox.Text))
                {
                    throw new Exception("fill the  notes!");
                }
                if (int.TryParse(notesTextBox.Text, out i))
                {
                    throw new Exception("invalid notes!");
                }

                int enter, exit; // help variables
                if ((bool)checkSun.IsChecked)
                {
                    if (string.IsNullOrEmpty(enterSun.Text))
                    {
                        throw new Exception("fill the enter box!");
                    }
                    if (!int.TryParse(enterSun.Text, out i))
                    {
                        throw new Exception("invalid enter box!");
                    }

                    if (string.IsNullOrEmpty(exitSun.Text))
                    {
                        throw new Exception("fill the exit box!");
                    }
                    if (!int.TryParse(exitSun.Text, out i))
                    {
                        throw new Exception("invalid exit box!");
                    }

                    enter = int.Parse(enterSun.Text);
                    exit  = int.Parse(exitSun.Text);
                    if (exit < enter)
                    {
                        throw new Exception("exit time is earlier than the enter time!");
                    }
                }
                if ((bool)checkMon.IsChecked)
                {
                    if (string.IsNullOrEmpty(enterMon.Text))
                    {
                        throw new Exception("fill the enter box!");
                    }
                    if (!int.TryParse(enterMon.Text, out i))
                    {
                        throw new Exception("invalid enter box!");
                    }

                    if (string.IsNullOrEmpty(exitMon.Text))
                    {
                        throw new Exception("fill the exit box!");
                    }
                    if (!int.TryParse(exitMon.Text, out i))
                    {
                        throw new Exception("invalid exit box!");
                    }

                    enter = int.Parse(enterMon.Text);
                    exit  = int.Parse(exitMon.Text);
                    if (exit < enter)
                    {
                        throw new Exception("exit time is earlier than the enter time!");
                    }
                }

                if ((bool)checkTue.IsChecked)
                {
                    if (string.IsNullOrEmpty(enterTue.Text))
                    {
                        throw new Exception("fill the enter box!");
                    }
                    if (!int.TryParse(enterTue.Text, out i))
                    {
                        throw new Exception("invalid enter box!");
                    }

                    if (string.IsNullOrEmpty(exitTue.Text))
                    {
                        throw new Exception("fill the exit box!");
                    }
                    if (!int.TryParse(exitTue.Text, out i))
                    {
                        throw new Exception("invalid exit box!");
                    }

                    enter = int.Parse(enterTue.Text);
                    exit  = int.Parse(exitTue.Text);
                    if (exit < enter)
                    {
                        throw new Exception("exit time is earlier than the enter time!");
                    }
                }

                if ((bool)checkWed.IsChecked)
                {
                    if (string.IsNullOrEmpty(enterWed.Text))
                    {
                        throw new Exception("fill the enter box!");
                    }
                    if (!int.TryParse(enterWed.Text, out i))
                    {
                        throw new Exception("invalid enter box!");
                    }

                    if (string.IsNullOrEmpty(exitWed.Text))
                    {
                        throw new Exception("fill the exit box!");
                    }
                    if (!int.TryParse(exitWed.Text, out i))
                    {
                        throw new Exception("invalid exit box!");
                    }

                    enter = int.Parse(enterWed.Text);
                    exit  = int.Parse(exitWed.Text);
                    if (exit < enter)
                    {
                        throw new Exception("exit time is earlier than the enter time!");
                    }
                }

                if ((bool)checkThu.IsChecked)
                {
                    if (string.IsNullOrEmpty(enterThu.Text))
                    {
                        throw new Exception("fill the enter box!");
                    }
                    if (!int.TryParse(enterThu.Text, out i))
                    {
                        throw new Exception("invalid enter box!");
                    }

                    if (string.IsNullOrEmpty(exitThu.Text))
                    {
                        throw new Exception("fill the exit box!");
                    }
                    if (!int.TryParse(exitThu.Text, out i))
                    {
                        throw new Exception("invalid exit box!");
                    }

                    enter = int.Parse(enterThu.Text);
                    exit  = int.Parse(exitThu.Text);
                    if (exit < enter)
                    {
                        throw new Exception("exit time is earlier than the enter time!");
                    }
                }

                if ((bool)checkFri.IsChecked)
                {
                    if (string.IsNullOrEmpty(enterFri.Text))
                    {
                        throw new Exception("fill the enter box!");
                    }
                    if (!int.TryParse(enterFri.Text, out i))
                    {
                        throw new Exception("invalid enter box!");
                    }

                    if (string.IsNullOrEmpty(exitFri.Text))
                    {
                        throw new Exception("fill the exit box!");
                    }
                    if (!int.TryParse(exitFri.Text, out i))
                    {
                        throw new Exception("invalid exit box!");
                    }

                    enter = int.Parse(enterFri.Text);
                    exit  = int.Parse(exitFri.Text);
                    if (exit < enter)
                    {
                        throw new Exception("exit time is earlier than the enter time!");
                    }
                }

                isChecked = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "DATA ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            if (!isChecked)
            {
                return;
            }
            #endregion

            #region add the mother



            BE.Mother myMother = new BE.Mother()
            {
                Address   = addressTextBox.Text,
                Cellphone = cellphoneTextBox.Text,
                FirstName = firstNameTextBox.Text,
                Id        = int.Parse(idTextBox.Text),
                LastName  = lastNameTextBox.Text,
                AreaNanny = areaNannyTextBox.Text,
                Notes     = notesTextBox.Text
            };

            myMother.NannyDays[0] = (bool)checkSun.IsChecked;
            myMother.NannyDays[1] = (bool)checkMon.IsChecked;
            myMother.NannyDays[2] = (bool)checkTue.IsChecked;
            myMother.NannyDays[3] = (bool)checkWed.IsChecked;
            myMother.NannyDays[4] = (bool)checkThu.IsChecked;
            myMother.NannyDays[5] = (bool)checkFri.IsChecked;
            myMother.NannyDays[6] = (bool)checkSat.IsChecked;

            if ((bool)checkSun.IsChecked)
            {
                myMother.Schedule[0, 0] = int.Parse(enterSun.Text);
                myMother.Schedule[1, 0] = int.Parse(exitSun.Text);
            }
            if ((bool)checkMon.IsChecked)
            {
                myMother.Schedule[0, 1] = int.Parse(enterMon.Text);
                myMother.Schedule[1, 1] = int.Parse(exitMon.Text);
            }
            if ((bool)checkTue.IsChecked)
            {
                myMother.Schedule[0, 2] = int.Parse(enterTue.Text);
                myMother.Schedule[1, 2] = int.Parse(exitTue.Text);
            }
            if ((bool)checkWed.IsChecked)
            {
                myMother.Schedule[0, 3] = int.Parse(enterWed.Text);
                myMother.Schedule[1, 3] = int.Parse(exitWed.Text);
            }
            if ((bool)checkThu.IsChecked)
            {
                myMother.Schedule[0, 4] = int.Parse(enterThu.Text);
                myMother.Schedule[1, 4] = int.Parse(exitThu.Text);
            }
            if ((bool)checkFri.IsChecked)
            {
                myMother.Schedule[0, 5] = int.Parse(enterFri.Text);
                myMother.Schedule[1, 5] = int.Parse(exitFri.Text);
            }
            try
            {
                myBl.AddMother(myMother);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ADD MOTHER ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            #endregion

            MessageBox.Show("The mother added successfully :)", "SUCCESS", MessageBoxButton.OK, MessageBoxImage.Information);
            this.Close();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            BL.IBL mybl = BL.FactoryBL.GetInstance;

            Dictionary <DayOfWeek, KeyValuePair <int, int> > Need = new Dictionary <DayOfWeek, KeyValuePair <int, int> >();
            DateTime    d    = new DateTime(1994, 4, 21);
            DateTime    d2   = new DateTime(2016, 4, 21);
            BankAccount bank = new BankAccount {
                AccountNumber = 1, BankName = BankName.Discont, BranchNumber = 10, BankAdress = new Address {
                    Number = 12, Street = "Hadekel", City = "Eilat", Country = "Israel"
                }
            };
            Address A = new Address {
                Street = "beit hadfus", Number = 7, City = "JERUSALEM", Country = "ISRAEL"
            };
            Address B = new Address {
                Street = "beit hadfus", Number = 11, City = "JERUSALEM", Country = "ISRAEL"
            };
            Address C = new Address {
                Street = "beit hadfus", Number = 21, City = "JERUSALEM", Country = "ISRAEL"
            };

            List <string> s = new List <string>();
            Mother        m = new Mother {
                ID = "333", PersonAddress = A, FirstName = "asa", Lastname = "faf", GoalAddress = B, HoursNeed = Need, MotherAccount = bank, Tel = "30484", TelHome = "39853"
            };
            Mother m1 = new Mother {
                ID = "888", PersonAddress = B, FirstName = "asa", Lastname = "faf", GoalAddress = B, HoursNeed = Need, MotherAccount = bank, Tel = "30484", TelHome = "39853"
            };
            Mother m2 = new Mother {
                ID = "777", PersonAddress = C, FirstName = "asa", Lastname = "faf", GoalAddress = B, HoursNeed = Need, MotherAccount = bank, Tel = "30484", TelHome = "39853"
            };

            mybl.AddMother(m);
            mybl.AddMother(m1);
            mybl.AddMother(m2);

            Nanny n = new Nanny {
                ID = "355", PersonAddress = C, VacationDays = true, Birthday = d, Elevator = false, Experience = 4, FirstName = "nana", Floor = 2, SalaryForMonth = 300, Lastname = "poly", MaxChildrens = 12, MaxChildrensAge = 12, MinChildrensAge = 2, MyBankAccount = bank, MyRecommendations = "very good", range = "2-12", RateForHour = 34, Tel = "24769786", WorkHours = Need
            };
            Nanny n2 = new Nanny {
                ID = "385", PersonAddress = A, VacationDays = true, Birthday = d, Elevator = false, Experience = 5, FirstName = "nana", Floor = 2, SalaryForMonth = 300, Lastname = "poly", MaxChildrens = 12, MaxChildrensAge = 12, MinChildrensAge = 2, MyBankAccount = bank, MyRecommendations = "very good", range = "2-12", RateForHour = 34, Tel = "24769786", WorkHours = Need
            };
            Nanny n3 = new Nanny {
                ID = "395", PersonAddress = B, VacationDays = true, Birthday = d, Elevator = false, Experience = 3, FirstName = "nana", Floor = 2, SalaryForMonth = 300, Lastname = "poly", MaxChildrens = 12, MaxChildrensAge = 18, MinChildrensAge = 5, MyBankAccount = bank, MyRecommendations = "very good", range = "5-18", RateForHour = 34, Tel = "24769786", WorkHours = Need
            };

            mybl.AddNanny(n);
            mybl.AddNanny(n2);
            mybl.AddNanny(n3);

            Child CH = new Child {
                ID = "555", Allergy = false, Birthday = d2, SpecialNeeds = false, MyMotherID = "333", FirstName = "BABY", Needs = "s", MyAllergy = "nuts", MyNutrition = "materna"
            };
            Child CH1 = new Child {
                ID = "790", Allergy = false, Birthday = d2, SpecialNeeds = false, MyMotherID = "333", FirstName = "BABY", Needs = "s"
            };
            Child CH2 = new Child {
                ID = "476", Allergy = false, Birthday = d2, SpecialNeeds = false, MyMotherID = "333", FirstName = "BABY", Needs = "s"
            };

            mybl.AddChild(CH);
            mybl.AddChild(CH1);
            mybl.AddChild(CH2);

            Contract C1 = new Contract {
                NannyID = "355", ChildID = "555", MotherID = "333", EmploymentHours = Need, Payment = true
            };
            Contract C2 = new Contract {
                NannyID = "385", ChildID = "790", MotherID = "888", EmploymentHours = Need, Payment = true
            };
            Contract C3 = new Contract {
                NannyID = "395", ChildID = "476", MotherID = "777", EmploymentHours = Need, Payment = true
            };

            mybl.AddContract(C1);
            mybl.AddContract(C2);
            mybl.AddContract(C3);

            List <Nanny> nannys = mybl.SelectedNannys(22, Need, 400, 4, 14, 5);
            // List<Contract> list = mybl.SelectedContracts(c => c.ChildID == "555");
            // int num = mybl.NumOfSelectedContracts(c => c.ChildID == "555");
            //IEnumerable<IGrouping<string, Nanny>> range = mybl.GroupNannyByChildAge(false);
            //IEnumerable<IGrouping<int, Contract>> cont = mybl.GroupContractByDistanceBetweenNannyAndChild(true);
            //mybl.SelectedNanniesByAddress(A,10,false,19, Need,400,30,2,12,10);
            //bool dis=mybl.Distance(A, B,10) ;
        }
Exemple #5
0
        static void Main(string[] args)
        {
            BL.IBL bl = BL.FactoryBL.GetBL();

            bl.Init();

            #region Nanny Functions

            Nanny myNanny = new Nanny
            {
                Id                   = 1237,
                FirstName            = "Shir",
                LastName             = "Tevet",
                BirthDate            = DateTime.Parse("12.12.1997"),
                PhoneNumber          = "0541234567",
                Address              = "Yaffo,Jerusalem,Israel",
                IsElevator           = true,
                Floor                = 3,
                MaxNumOfChildren     = 10,
                MinAge               = 3,
                MaxAge               = 7,
                EnanblePayForHour    = true,
                HourlyRate           = 10,
                MonthlyRate          = 2000,
                IsVacationAsTMT      = true,
                Recommendations      = "Recommendations",
                SpecialActivities    = "SpecialActivities",
                IsKosherFood         = true,
                IsReligiousEducation = true,
                Comments             = "Comments",
                //BankAccount = new Bank(),
            };
            myNanny.NannySchedule[0].IsWorkDay  = true;
            myNanny.NannySchedule[1].IsWorkDay  = true;
            myNanny.NannySchedule[2].IsWorkDay  = true;
            myNanny.NannySchedule[0].StartHour += new TimeSpan(10, 0, 0);
            myNanny.NannySchedule[0].EndHour   += new TimeSpan(16, 0, 0);
            myNanny.NannySchedule[1].StartHour += new TimeSpan(9, 0, 0);
            myNanny.NannySchedule[1].EndHour   += new TimeSpan(14, 0, 0);
            myNanny.NannySchedule[2].StartHour += new TimeSpan(8, 0, 0);
            myNanny.NannySchedule[2].EndHour   += new TimeSpan(14, 0, 0);

            try
            {
                Console.WriteLine("-----add nanny-----");
                bl.AddNanny(myNanny);
                foreach (Nanny n in bl.GetNannyList())
                {
                    Console.WriteLine(n);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("-----remove nanny-----");
                //bl.RemoveNanny(1236);
                foreach (Nanny n in bl.GetNannyList())
                {
                    Console.WriteLine(n);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("-----update nanny-----");
                Nanny nannyToUpdate = new Nanny
                {
                    Id                   = 1237,
                    FirstName            = "Shir",
                    LastName             = "Tevet",
                    BirthDate            = DateTime.Parse("12.12.1997"),
                    PhoneNumber          = "0541234567",
                    Address              = "Yaffo,Jerusalem,Israel",
                    IsElevator           = true,
                    Floor                = 3,
                    MaxNumOfChildren     = 10,
                    MinAge               = 3,
                    MaxAge               = 7,
                    EnanblePayForHour    = true,
                    HourlyRate           = 10,
                    MonthlyRate          = 2000,
                    IsVacationAsTMT      = true,
                    Recommendations      = "Recommendations",
                    SpecialActivities    = "SpecialActivities",
                    IsKosherFood         = true,
                    IsReligiousEducation = true,
                    Comments             = "Comments",
                    //BankAccount = new Bank(),
                };
                nannyToUpdate.NannySchedule[0].IsWorkDay  = true;
                nannyToUpdate.NannySchedule[1].IsWorkDay  = true;
                nannyToUpdate.NannySchedule[2].IsWorkDay  = true;
                nannyToUpdate.NannySchedule[0].StartHour += new TimeSpan(10, 0, 0);
                nannyToUpdate.NannySchedule[0].EndHour   += new TimeSpan(16, 0, 0);
                nannyToUpdate.NannySchedule[1].StartHour += new TimeSpan(9, 0, 0);
                nannyToUpdate.NannySchedule[1].EndHour   += new TimeSpan(17, 0, 0);
                nannyToUpdate.NannySchedule[2].StartHour += new TimeSpan(7, 0, 0);
                nannyToUpdate.NannySchedule[2].EndHour   += new TimeSpan(17, 0, 0);

                bl.UpdateNannyDetails(nannyToUpdate);
                foreach (Nanny n in bl.GetNannyList())
                {
                    Console.WriteLine(n);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("-----get nanny-----");
                Console.WriteLine(bl.GetNanny(1237));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            #endregion

            #region Mother Functions

            Mother myMother = new Mother
            {
                Id             = 3237,
                LastName       = "Ben-David",
                FirstName      = "Tal",
                PhoneNumber    = "054444444",
                HomeAddress    = "Ben-Tzion,Jerusalem,Israel",
                Comments       = "Comments",
                Status         = MotherStatus.HouseWife,
                IsSingleMother = true,
            };
            for (int i = 0; i < 3; i++)
            {
                myMother.WantedNannySchedule[i].IsWorkDay = true;
            }
            myMother.WantedNannySchedule[0].StartHour += new TimeSpan(8, 30, 0);
            myMother.WantedNannySchedule[0].EndHour   += new TimeSpan(16, 0, 0);
            myMother.WantedNannySchedule[1].StartHour += new TimeSpan(9, 0, 0);
            myMother.WantedNannySchedule[1].EndHour   += new TimeSpan(14, 0, 0);
            myMother.WantedNannySchedule[2].StartHour += new TimeSpan(8, 0, 0);
            myMother.WantedNannySchedule[2].EndHour   += new TimeSpan(14, 0, 0);
            try
            {
                Console.WriteLine("-----add mother-----");
                bl.AddMother(myMother);
                foreach (Mother m in bl.GetMotherList())
                {
                    Console.WriteLine(m);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("-----remove mother-----");
                // bl.RemoveMother(3236);
                foreach (Mother m in bl.GetMotherList())
                {
                    Console.WriteLine(m);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            try
            {
                Console.WriteLine("-----update mother-----");
                Mother motherToUpdate = new Mother
                {
                    Id             = 3237,
                    LastName       = "Ben-David",
                    FirstName      = "Tal",
                    PhoneNumber    = "054444444",
                    HomeAddress    = "Ben-Tzion,Jerusalem,Israel",
                    Comments       = "Comments",
                    Status         = MotherStatus.Worker,
                    IsSingleMother = false,
                };
                for (int i = 0; i < 3; i++)
                {
                    motherToUpdate.WantedNannySchedule[i].IsWorkDay = true;
                }
                motherToUpdate.WantedNannySchedule[0].StartHour += new TimeSpan(8, 30, 0);
                motherToUpdate.WantedNannySchedule[0].EndHour   += new TimeSpan(16, 0, 0);
                motherToUpdate.WantedNannySchedule[1].StartHour += new TimeSpan(9, 0, 0);
                motherToUpdate.WantedNannySchedule[1].EndHour   += new TimeSpan(17, 0, 0);
                motherToUpdate.WantedNannySchedule[2].StartHour += new TimeSpan(8, 0, 0);
                motherToUpdate.WantedNannySchedule[2].EndHour   += new TimeSpan(20, 0, 0);

                bl.UpdateMotherDetails(motherToUpdate);
                foreach (Mother m in bl.GetMotherList())
                {
                    Console.WriteLine(m);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("-----get mother-----");
                Console.WriteLine(bl.GetMother(2237));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            #endregion

            #region Child Functions

            Child myChild = new Child
            {
                Id                  = 2237,
                MotherId            = 3237,
                FirstName           = "Chen",
                BirthDate           = DateTime.Parse("3.4.2017"),
                IsSpecialNeedsChild = true,
                SpecialNeeds        = "SpecialNeeds",
                IsFoodAllergy       = true,
                FoodAllergy         = "FoodAllergy",
                IsMedicinesAllergy  = true,
                MedicinesAllergy    = "IsMedicinesAllergy",
                IsBreastMilk        = true,
                Comments            = "Comments"
            };

            try
            {
                Console.WriteLine("-----add child-----");
                bl.AddChild(myChild);
                foreach (Child c in bl.GetChildList())
                {
                    Console.WriteLine(c);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("-----remove child-----");
                //bl.RemoveChild(2234);
                foreach (Child c in bl.GetChildList())
                {
                    Console.WriteLine(c);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("-----update child-----");
                Child childToUpdate = new Child
                {
                    Id                  = 2237,
                    MotherId            = 3237,
                    FirstName           = "Chen",
                    BirthDate           = DateTime.Parse("3.7.2017"),
                    IsSpecialNeedsChild = false,
                    SpecialNeeds        = "",
                    IsFoodAllergy       = true,
                    FoodAllergy         = "FoodAllergy",
                    IsMedicinesAllergy  = true,
                    MedicinesAllergy    = "IsMedicinesAllergy",
                    IsBreastMilk        = true,
                    Comments            = "Comments"
                };

                bl.UpdateChildDetails(childToUpdate);
                foreach (Child c in bl.GetChildList())
                {
                    Console.WriteLine(c);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("-----get child-----");
                Console.WriteLine(bl.GetChild(2237));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            #endregion

            #region Contract Functions

            Contract myContract = new Contract
            {
                NannyId = 1237,
                ChildId = 2237,
                IsIntroductoryMeeting = false,
                IsSignedContract      = false,
                PayPerHourOrMonth     = PaymentPer.Hour,
                StartContractDate     = new DateTime(2017, 9, 1),
                EndContractDate       = new DateTime(2018, 9, 1),
                PaidBy = WayOfPayment.BankTransfer
            };

            try
            {
                Console.WriteLine("-----add contract-----");
                bl.AddContract(myContract);
                foreach (Contract c in bl.GetContractList())
                {
                    Console.WriteLine(c);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("-----remove contract-----");
                //bl.RemoveContract(10000003);
                foreach (Contract c in bl.GetContractList())
                {
                    Console.WriteLine(c);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("-----update contract-----");
                Contract contractToUpdate = new Contract
                {
                    NannyId = 1234,
                    ChildId = 2236,
                    IsIntroductoryMeeting = false,
                    IsSignedContract      = false,
                    PayPerHourOrMonth     = PaymentPer.Month,
                    StartContractDate     = new DateTime(2017, 9, 1),
                    EndContractDate       = new DateTime(2018, 9, 1),
                    PaidBy = WayOfPayment.BankTransfer
                };
                bl.UpdateContractDetails(contractToUpdate);

                foreach (Contract c in bl.GetContractList())
                {
                    Console.WriteLine(c);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("-----get contract-----");
                Console.WriteLine(bl.GetContract(10000004));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            #endregion

            try
            {
                Console.WriteLine("\n----GetAllNannyByDistance----");
                var nanniesByDistance = bl.GetAllNannyByDistance(3234, 40);
                foreach (var n in nanniesByDistance)
                {
                    Console.WriteLine("nannyId: {0}", n.Id);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                var matchNannies = bl.GetAllMatchHoursNanny(3234);
                Console.WriteLine("\n----NannyHours----");
                string result;
                foreach (Nanny n in bl.GetNannyList())
                {
                    result = "\n";
                    for (int i = 0; i < n.NannySchedule.Length; i++)
                    {
                        if (n.NannySchedule[i].IsWorkDay)
                        {
                            result += n.NannySchedule[i].Day + ": ";                                                                  //print the days that nanny works
                            result += n.NannySchedule[i].StartHour.ToString() + " - " + n.NannySchedule[i].EndHour.ToString() + "\n"; //print the hours per a day that nanny works
                        }
                    }
                    Console.WriteLine(result);
                }
                Console.WriteLine("\n----MotherHours----");
                result = "\n";
                for (int i = 0; i < bl.GetMother(3234).WantedNannySchedule.Length; i++)
                {
                    if (bl.GetMother(3234).WantedNannySchedule[i].IsWorkDay)
                    {
                        result += bl.GetMother(3234).WantedNannySchedule[i].Day + ": ";                                                                                         //print the days that nanny works
                        result += bl.GetMother(3234).WantedNannySchedule[i].StartHour.ToString() + " - " + bl.GetMother(3234).WantedNannySchedule[i].EndHour.ToString() + "\n"; //print the hours per a day that nanny works
                    }
                }
                Console.WriteLine(result);
                Console.WriteLine("\n----GetAllMatchHoursNanny----");
                foreach (Nanny n in matchNannies)
                {
                    Console.WriteLine(n);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                var noNannyChildren = bl.GetNoNannyChildrenList();
                Console.WriteLine("\n----AllContractsList----");
                foreach (Contract c in bl.GetContractList())
                {
                    Console.WriteLine(c);
                }
                Console.WriteLine("\n----GetNoNannyChildrenList----");
                foreach (Child c in noNannyChildren)
                {
                    Console.WriteLine(c);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("\n----AllNannyList----");
                foreach (Nanny n in bl.GetNannyList())
                {
                    Console.WriteLine("nannyId: {0}, isTMT: {1}", n.Id, n.IsVacationAsTMT);
                }
                Console.WriteLine("\n----GetNannyWithTMTList----");
                var TMTNannyList = bl.GetNannyWithTMTList();
                foreach (Nanny n in TMTNannyList)
                {
                    Console.WriteLine("nannyId: {0}, isTMT: {1}", n.Id, n.IsVacationAsTMT);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("\n----AllNannyList----");
                foreach (Nanny n in bl.GetNannyList())
                {
                    Console.WriteLine("nannyId: {0}, minAge: {1}, maxAge: {2}", n.Id, n.MinAge, n.MaxAge);
                }
                Console.WriteLine("\n----GroupNannyByChildAge----");
                var maxAgeNannyGroups = bl.GroupNannyByChildAge(true, true);
                var minAgeNannyGroups = bl.GroupNannyByChildAge(true, false);
                foreach (var g in maxAgeNannyGroups)
                {
                    //switch(g.Key)
                    //{
                    //    case 1:
                    //        Console.WriteLine("maxAge: 3-5:");
                    //        break;
                    //    case 2:
                    //        Console.WriteLine("maxAge: 6-8:");
                    //        break;
                    //    case 3:
                    //        Console.WriteLine("maxAge: 9-11:");
                    //        break;
                    //    default:
                    //        Console.WriteLine("maxAge: 1 year+: ");
                    //        break;

                    //}

                    foreach (var n in g)
                    {
                        Console.WriteLine("nannyId: {0}", n.Id);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                var minAgeNannyGroups = bl.GroupNannyByChildAge(true, false);
                foreach (var g in minAgeNannyGroups)
                {
                    //switch (g.Key)
                    //{
                    //    case 1:
                    //        Console.WriteLine("minAge: 3-5:");
                    //        break;
                    //    case 2:
                    //        Console.WriteLine("minAge: 6-8:");
                    //        break;
                    //    case 3:
                    //        Console.WriteLine("minAge: 9-11:");
                    //        break;
                    //    default:
                    //        Console.WriteLine("minAge: 1 year+: ");
                    //        break;

                    //}

                    foreach (var n in g)
                    {
                        Console.WriteLine("nannyId: {0}", n.Id);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("\n----GroupContractByDistance----");
                var distanceGroups      = bl.GroupContractByDistance(false);
                var orderDistanceGroups = bl.GroupContractByDistance(true);
                foreach (var g in orderDistanceGroups)
                {
                    //switch ((int)g.Key)
                    //{
                    //    case 0:
                    //        Console.WriteLine("Distance: 0-1:");
                    //        break;
                    //    case 1:
                    //        Console.WriteLine("Distance: 2-3:");
                    //        break;
                    //    case 2:
                    //        Console.WriteLine("Distance: 4-5:");
                    //        break;
                    //    case 3:
                    //        Console.WriteLine("Distance: 5-6:");
                    //        break;
                    //    case 4:
                    //        Console.WriteLine("Distance: 7-8:");
                    //        break;
                    //    case 5:
                    //        Console.WriteLine("Distance: 9-10:");
                    //        break;
                    //    default:
                    //        break;
                    //}

                    foreach (var c in g)
                    {
                        Console.WriteLine("contractId: {0}", c.ContractId);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("\n----AllContractsList----");
                foreach (Contract c in bl.GetContractList())
                {
                    Console.WriteLine(c);
                }
                Console.WriteLine("\n----GroupContractByRate----");
                var rateGroups = bl.GroupContractByRate(true);
                foreach (var g in rateGroups)
                {
                    //switch ((int)g.Key)
                    //{
                    //    case 0:
                    //        Console.WriteLine("up to 1000:");
                    //        break;
                    //    case 1:
                    //        Console.WriteLine("1000-2000:");
                    //        break;
                    //case 2:
                    //    Console.WriteLine("2000-3000:");
                    //    break;
                    //default:
                    //        Console.WriteLine("3000+:");
                    //        break;
                    //}

                    foreach (var c in g)
                    {
                        Console.WriteLine("contractId: {0}, NetoRate: {1}", c.ContractId, bl.CalculateContractRate(c));
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("\n----AllChildInNannyList----");
                foreach (Contract c in bl.GetContractList(c => c.NannyId == 1237))
                {
                    Console.WriteLine("childId: {0}, BreastMilk: {1}", c.ChildId, bl.GetChild(c.ChildId).IsBreastMilk);
                }
                Console.WriteLine("\n----GroupChildrenByBreastMilk----");
                var milkGroups = bl.GroupChildrenByBreastMilk(1237);
                foreach (var g in milkGroups)
                {
                    //switch (g.Key)
                    //{
                    //    case true:
                    //        Console.WriteLine("BreastMilk:");
                    //        break;
                    //    case false:
                    //        Console.WriteLine("NoBreastMilk:");
                    //        break;
                    //    //    default:
                    //    //        break;
                    //}

                    //    foreach (var c in g)
                    //    {
                    //        Console.WriteLine("childId: {0}", c.Id, c.IsBreastMilk);
                    //    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("\n----AllMothersStatus----");
                foreach (Mother m in bl.GetMotherList())
                {
                    Console.WriteLine("motherId: {0}, status: {1}", m.Id, m.Status);
                }
                Console.WriteLine("\n----GroupMotherByStatus----");
                var statusGroups = bl.GroupMotherByStatus();
                foreach (var g in statusGroups)
                {
                    switch (g.Key)
                    {
                    case MotherStatus.HouseWife:
                        Console.WriteLine("HouseWife:");
                        break;

                    case MotherStatus.MaternityLeave:
                        Console.WriteLine("MaternityLeave:");
                        break;

                    case MotherStatus.Student:
                        Console.WriteLine("Student:");
                        break;

                    case MotherStatus.Worker:
                        Console.WriteLine("Worker:");
                        break;

                    default:
                        break;
                    }

                    foreach (var m in g)
                    {
                        Console.WriteLine("motherId: {0}", m.Id);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("\n----GetChildAge----");
                foreach (Child c in bl.GetChildList())
                {
                    Console.WriteLine("childId: {0}, birthDate: {1}, Age: {2}", c.Id, c.BirthDate.ToShortDateString(), bl.GetChildAge(c.Id));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("\n----AllContractsList----");
                foreach (Contract c in bl.GetContractList())
                {
                    Console.WriteLine("contractId: {0}, nannyId: {1} , childId: {2}", c.ContractId, c.NannyId, c.ChildId);
                }
                Console.WriteLine("\n----SearchContract----");
                Console.WriteLine(bl.SearchContract(1239, 2237));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            try
            {
                Console.WriteLine("\n----AllChildList----");
                foreach (Child c in bl.GetChildList())
                {
                    Console.WriteLine("childId: {0}, IsFoodAllergy: {1}, IsMedicinesAllergy: {2}", c.Id, c.IsFoodAllergy, c.IsMedicinesAllergy);
                }
                Console.WriteLine("\n----GetAllergyChildren----");
                foreach (Nanny n in bl.GetNannyList())
                {
                    Console.WriteLine("nannyId: {0}", n.Id);
                    foreach (Child c in bl.GetAllergyChildren(n.Id))
                    {
                        Console.WriteLine("childId: {0}, IsFoodAllergy: {1}, IsMedicinesAllergy: {2}", c.Id, c.IsFoodAllergy, c.IsMedicinesAllergy);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
Exemple #6
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            // if((chsun.IsChecked==true && (IsTimes(sunS.Text) || IsTimes(sunE.Text))==false)||(chmon.IsChecked==true&&(IsTimes(monS.Text)||IsTimes(monE.Text))==false)||(chtue.IsChecked==true&&(IsTimes(tueS.Text)||IsTimes(sueE.Text))==false)||(chwed.IsChecked==true&&(IsTimes(wedS.Text)|| IsTimes(wedE.Text))==false)||(chtue.IsChecked==true&& (IsTimes(thuE.Text)|| IsTimes(thuS.Text))==false)||(thfri.IsChecked==true&& (IsTimes(friS.Text) || IsTimes(friE.Text))==false))

            if (IsTimes(sunS.Text) == false || IsTimes(sunE.Text) == false || IsTimes(monS.Text) == false || IsTimes(monE.Text) == false || IsTimes(tueS.Text) == false || IsTimes(sueE.Text) == false || IsTimes(wedS.Text) == false || IsTimes(wedE.Text) == false || IsTimes(thuE.Text) == false || IsTimes(thuS.Text) == false || IsTimes(friS.Text) == false || IsTimes(friE.Text) == false)
            {
                MessageBox.Show("cannot add this nanny");
            }
            else
            {
                if ((chsun.IsChecked == true && (sunS.Text == "" || sunE.Text == "")) || (chmon.IsChecked == true && (monS.Text == "" || monE.Text == "")) || (chtue.IsChecked == true && (tueS.Text == "" || sueE.Text == "")) || (chwed.IsChecked == true && (wedS.Text == "" || wedE.Text == "")) || (chtue.IsChecked == true && (thuE.Text == "" || thuS.Text == "")) || (thfri.IsChecked == true && (friS.Text == "" || friE.Text == "")))
                {
                    MessageBox.Show("fill the empty fildes");
                }
                else
                {
                    //   corentMother.Times = new string[6][];
                    corentMother.Days = new bool[6];
                    for (int i = 0; i < 6; i++)
                    {
                        corentMother.Times[i] = new string[2];
                    }
                    if (chsun.IsChecked == true)
                    {
                        corentMother.Days[0]     = true;
                        corentMother.Times[0][0] = sunS.Text;
                        corentMother.Times[0][1] = sunE.Text;
                    }
                    else
                    {
                        corentMother.Days[0]     = false;
                        corentMother.Times[0][0] = "00:00";
                        corentMother.Times[0][1] = "00:00";
                    }
                    if (chmon.IsChecked == true)
                    {
                        corentMother.Days[1]     = true;
                        corentMother.Times[1][0] = monS.Text;
                        corentMother.Times[1][1] = monE.Text;
                    }
                    else
                    {
                        corentMother.Days[1]     = false;
                        corentMother.Times[1][0] = "00:00";
                        corentMother.Times[1][1] = "00:00";
                    }
                    if (chthu.IsChecked == true)
                    {
                        corentMother.Days[2]     = true;
                        corentMother.Times[2][0] = tueS.Text;
                        corentMother.Times[2][1] = sueE.Text;
                    }
                    else
                    {
                        corentMother.Days[2]     = false;
                        corentMother.Times[2][0] = "00:00";
                        corentMother.Times[2][1] = "00:00";
                    }
                    if (chwed.IsChecked == true)
                    {
                        corentMother.Days[3]     = true;
                        corentMother.Times[3][0] = wedS.Text;
                        corentMother.Times[3][1] = wedE.Text;
                    }
                    else
                    {
                        corentMother.Days[3]     = false;
                        corentMother.Times[3][0] = "00:00";
                        corentMother.Times[3][1] = "00:00";
                    }
                    if (chthu.IsChecked == true)
                    {
                        corentMother.Days[4]     = true;
                        corentMother.Times[4][0] = thuS.Text;
                        corentMother.Times[4][1] = thuE.Text;
                    }
                    else
                    {
                        corentMother.Days[4]     = false;
                        corentMother.Times[4][0] = "00:00";
                        corentMother.Times[4][1] = "00:00";
                    }
                    if (thfri.IsChecked == true)
                    {
                        corentMother.Days[5]     = true;
                        corentMother.Times[5][0] = friS.Text;
                        corentMother.Times[5][1] = friE.Text;
                    }
                    else
                    {
                        corentMother.Days[5]     = false;
                        corentMother.Times[5][0] = "00:00";
                        corentMother.Times[5][1] = "00:00";
                    }

                    try
                    {
                        myBL.AddMother(corentMother);
                        corentMother     = new BE.Mother();
                        this.DataContext = corentMother;
                        MessageBox.Show("succeed!!");
                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Exemple #7
0
 private void Button_Click(object sender, RoutedEventArgs e)
 //What happens in the program when you click the button (as is said when you start the Click event)
 {
     try
     {
         if (M.MotherId > 999999999)
         {
             throw new Exception("your id is not valid");
         }
         if (M.MotherId == 0)
         {
             throw new Exception("your id is not valid");
         }
         bool[] motherNeedsNannyhelp = new bool[6]; //define an array of days when the mother needs a nanny
         for (int i = 0; i < 6; i++)                //initialize the array in false
         {
             motherNeedsNannyhelp[i] = false;
         }
         double[,] motherTimeNeedsNannyhelp = new double[6, 2];                   //define an array of hours during which the mother needs nanny
         if (this.day1.IsChecked == true)                                         //If the mother indicated she needed a nanny on this day
         {
             motherNeedsNannyhelp[0]        = true;                               //We set the first array on this day, to be true
             motherTimeNeedsNannyhelp[0, 0] = switctTimeToDouble(daystart1.Text); //take the user's start time from the screen and insert it into the array of hours
             motherTimeNeedsNannyhelp[0, 1] = switctTimeToDouble(dayend1.Text);   //take the user's end time from the screen and insert it into the array of hours
         }
         if (this.day2.IsChecked == true)
         {
             motherNeedsNannyhelp[1]        = true;
             motherTimeNeedsNannyhelp[1, 0] = switctTimeToDouble(daystart2.Text);
             motherTimeNeedsNannyhelp[1, 1] = switctTimeToDouble(dayend2.Text);
         }
         if (this.day3.IsChecked == true)
         {
             motherNeedsNannyhelp[2]        = true;
             motherTimeNeedsNannyhelp[2, 0] = switctTimeToDouble(daystart3.Text);
             motherTimeNeedsNannyhelp[2, 1] = switctTimeToDouble(dayend3.Text);
         }
         if (this.day4.IsChecked == true)
         {
             motherNeedsNannyhelp[3]        = true;
             motherTimeNeedsNannyhelp[3, 0] = switctTimeToDouble(daystart4.Text);
             motherTimeNeedsNannyhelp[3, 1] = switctTimeToDouble(dayend4.Text);
         }
         if (this.day5.IsChecked == true)
         {
             motherNeedsNannyhelp[4]        = true;
             motherTimeNeedsNannyhelp[4, 0] = switctTimeToDouble(daystart5.Text);
             motherTimeNeedsNannyhelp[4, 1] = switctTimeToDouble(dayend5.Text);
         }
         if (this.day6.IsChecked == true)
         {
             motherNeedsNannyhelp[5]        = true;
             motherTimeNeedsNannyhelp[5, 0] = switctTimeToDouble(daystart6.Text);
             motherTimeNeedsNannyhelp[5, 1] = switctTimeToDouble(dayend6.Text);
         }
         M.MotherTimeNeedsNanny = motherTimeNeedsNannyhelp; //send the array of days we have built as the array of days of the object "mother"
         M.MotherNeedsNanny     = motherNeedsNannyhelp;     //send the array of hours we have built as the array of hours of the object "mother"
         bl.AddMother(M);                                   //Add the M object to the "mother" list in the BL database
         M = new BE.Mother();                               //initialize M as an empty object of the mother type
         this.DataContext = M;                              //Set the fields of the screen to M
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }