public UpdateNanny() { InitializeComponent(); nanny = new Nanny(); this.DataContext = nanny; BL = new BL_imp(); foreach (Nanny nany in BL.GetAllNannys()) { ComboBoxItem item = new ComboBoxItem { Content = nany.FirstName }; this.firstNameComboBox.Items.Add(item); } }
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; } } } }
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(); }
private void IDchanged() { Nanny n = MainWindow.bl.FindNannyByID(iDTextBox.Text); if (n == null) { tempNanny = new Nanny(iDTextBox.Text); //NannyGrid.DataContext = tempNanny; UpdateBTN.IsEnabled = false; RemoveBTN.IsEnabled = false; AddBTN.IsEnabled = true; birthDateDatePicker.IsEnabled = true; h.Reset(); recs.Clear(); } else { tempNanny = new Nanny(n); //tempNanny.ID = n.ID; //tempNanny.Floor = n.Floor; //tempNanny.Address = n.Address; //tempNanny.BirthDate = n.BirthDate; //tempNanny.Elevator = n.Elevator; //tempNanny.Expertise = n.Expertise; //tempNanny.FirstName = n.FirstName; //tempNanny.HourSalary = n.HourSalary; //tempNanny.IsCostByHour = n.IsCostByHour; //tempNanny.LastName = n.LastName; //tempNanny.MaxAge = n.MaxAge; //tempNanny.MaxChildren = n.MaxChildren; //tempNanny.MinAge = n.MinAge; //tempNanny.MonthSalary = n.MonthSalary; //tempNanny.Phone = n.Phone; //tempNanny.VacationByMinisterOfEducation = n.VacationByMinisterOfEducation; //for (int i = 0; i < 6; i++) //{ // tempNanny.WorkDays[i] = n.WorkDays[i]; // tempNanny.WorkHours[0, i] = n.WorkHours[0, i]; // tempNanny.WorkHours[1, i] = n.WorkHours[1, i]; //} //tempNanny.WorkDays[6] = n.WorkDays[6]; //foreach (string str in n.Recommendations) // tempNanny.Recommendations.Add(str); UpdateBTN.IsEnabled = true; RemoveBTN.IsEnabled = true; AddBTN.IsEnabled = false; birthDateDatePicker.IsEnabled = false; h.Reset(); h.ManualSetting(tempNanny.WorkDays, tempNanny.WorkHours); recs.Clear(); foreach (string str in n.Recommendations) { recs.AddString(str); } } NannyGrid.DataContext = tempNanny; // from here on ensuring that the user knows in advance if his the ID is taken if (MainWindow.bl.FindChildByID(iDTextBox.Text) != null || MainWindow.bl.FindMotherByID(iDTextBox.Text) != null) { AddBTN.Content = "ID already exists!!"; AddBTN.FontSize = 13; AddBTN.IsEnabled = false; } else { AddBTN.Content = "Add"; AddBTN.FontSize = 20; //AddBTN.IsEnabled = true; } //tempNanny.ID = "2222222222"; //tempNanny.Phone = "error message"; //NannyGrid.DataContext = tempNanny; }
private void iDTextBox_MouseEnter(object sender, MouseEventArgs e) { // this makes the tooltip show the nanny's "to string" details Nanny n = MainWindow.bl.FindNannyByID(iDTextBox.Text); iDTextBox.ToolTip = (n == null ? "new nanny" : n.ToString()); }
private void Button_Click(object sender, RoutedEventArgs e) { try { newNanny.NannyId = int.Parse(ID_TextBox.Text); newNanny.NannyPrivateName = FirstName_TextBox.Text; newNanny.NannyFamilyName = LastName_TextBox.Text; newNanny.NannyPhoneNum = int.Parse(PhoneNumber_TextBox.Text); newNanny.NannyAdress = Street_TextBox.Text + ", " + City_TextBox.Text + ", israel"; newNanny.NannyFloor = int.Parse(Floor_TextBox.Text); newNanny.NannyIsElevator = (bool)Elevator_CheckBox.IsChecked; newNanny.NannyYearsOfExperience = int.Parse(Experience_TextBox.Text); newNanny.NannyMaxInfants = int.Parse(MaxChildrens_TextBox.Text); newNanny.NannyMinInfantAge = int.Parse(MinAge_TextBox.Text); newNanny.NannyMaxInfantAge = int.Parse(MaxAge_TextBox.Text); newNanny.NannyMonthlySalary = int.Parse(MonthlySalary_TextBox.Text); newNanny.NannyIsHourlySalary = (bool)HourlySalary_CheckBox.IsChecked; if (newNanny.NannyIsHourlySalary) { newNanny.NannyHourlySalary = int.Parse(HourlySalary_TextBox.Text); } newNanny.NannyDateOfBirth = new DateTime(birth_DatePicker.SelectedDate.Value.Year, birth_DatePicker.SelectedDate.Value.Month, birth_DatePicker.SelectedDate.Value.Day); newNanny.NannyIsMOE = (Vacation_ComboBox.SelectedItem == MOE_ComboBoxItem) ? true : false; newNanny.NannyRecommendations = Recommendations_TextBox.Text; #region Time input newNanny.NannyWorkingDays[0] = (bool)Schedule.SundayCheckBox.IsChecked; newNanny.NannyWorkingDays[1] = (bool)Schedule.MondayCheckBox.IsChecked; newNanny.NannyWorkingDays[2] = (bool)Schedule.TuesdayCheckBox.IsChecked; newNanny.NannyWorkingDays[3] = (bool)Schedule.WednesdayCheckBox.IsChecked; newNanny.NannyWorkingDays[4] = (bool)Schedule.ThursdayCheckBox.IsChecked; newNanny.NannyWorkingDays[5] = (bool)Schedule.FridayCheckBox.IsChecked; List <WeeklyWorkSchedule> hoursArray = new List <WeeklyWorkSchedule>(6); for (int i = 0; i < 6; i++) { hoursArray.Insert(i, new WeeklyWorkSchedule()); } hoursArray[0].StartTime = new TimeSpan((int)Schedule.SundayStartTime.HoursValue, (int)Schedule.SundayStartTime.MinutesValue, 0); hoursArray[0].EndTime = new TimeSpan((int)Schedule.SundayEndTime.HoursValue, (int)Schedule.SundayEndTime.MinutesValue, 0); hoursArray[1].StartTime = new TimeSpan((int)Schedule.MondayStartTime.HoursValue, (int)Schedule.MondayStartTime.MinutesValue, 0); hoursArray[1].EndTime = new TimeSpan((int)Schedule.MondayEndTime.HoursValue, (int)Schedule.MondayEndTime.MinutesValue, 0); hoursArray[2].StartTime = new TimeSpan((int)Schedule.TuesdayStartTime.HoursValue, (int)Schedule.TuesdayStartTime.MinutesValue, 0); hoursArray[2].EndTime = new TimeSpan((int)Schedule.TuesdayEndTime.HoursValue, (int)Schedule.TuesdayEndTime.MinutesValue, 0); hoursArray[3].StartTime = new TimeSpan((int)Schedule.WednesdayStartTime.HoursValue, (int)Schedule.WednesdayStartTime.MinutesValue, 0); hoursArray[3].EndTime = new TimeSpan((int)Schedule.WednesdayEndTime.HoursValue, (int)Schedule.WednesdayEndTime.MinutesValue, 0); hoursArray[4].StartTime = new TimeSpan((int)Schedule.ThursdayStartTime.HoursValue, (int)Schedule.ThursdayStartTime.MinutesValue, 0); hoursArray[4].EndTime = new TimeSpan((int)Schedule.ThursdayEndTime.HoursValue, (int)Schedule.ThursdayEndTime.MinutesValue, 0); hoursArray[5].StartTime = new TimeSpan((int)Schedule.FridayStartTime.HoursValue, (int)Schedule.FridayStartTime.MinutesValue, 0); hoursArray[5].EndTime = new TimeSpan((int)Schedule.FridayEndTime.HoursValue, (int)Schedule.FridayEndTime.MinutesValue, 0); newNanny.NannyWorkingHours = hoursArray; #endregion bl.AddNanny(newNanny); dataGridToRefresh.ItemsSource = null; dataGridToRefresh.ItemsSource = bl.GetAllNannies(); MessageBox.Show("addition successful"); this.IsEnabled = false; newNanny = new Nanny(); } catch (Exception c) { MessageBox.Show(c.Message); } }
private void comboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { nanny = new BE.Nanny(comboBox.SelectedItem as BE.Nanny); label.Content = nanny.ToString(); RemoveButton.IsEnabled = true; }
private void Button_Click(object sender, RoutedEventArgs e) { try { nanny.DaysOfWork[0] = CB1.IsChecked.Value; nanny.DaysOfWork[1] = CB2.IsChecked.Value; nanny.DaysOfWork[2] = CB3.IsChecked.Value; nanny.DaysOfWork[3] = CB4.IsChecked.Value; nanny.DaysOfWork[4] = CB5.IsChecked.Value; nanny.DaysOfWork[5] = CB6.IsChecked.Value; nanny.DaysOfWork[6] = CB7.IsChecked.Value; if (CB1.IsChecked.Value) { nanny.WorkingHours[0].BeginingTime = (DateTime)sundayBegT.Value; } if (CB2.IsChecked.Value) { nanny.WorkingHours[1].BeginingTime = (DateTime)mondayBegT.Value; } if (CB3.IsChecked.Value) { nanny.WorkingHours[2].BeginingTime = (DateTime)tuesdayBegT.Value; } if (CB4.IsChecked.Value) { nanny.WorkingHours[3].BeginingTime = (DateTime)wednesdayBegT.Value; } if (CB5.IsChecked.Value) { nanny.WorkingHours[4].BeginingTime = (DateTime)thursdayBegT.Value; } if (CB6.IsChecked.Value) { nanny.WorkingHours[5].BeginingTime = (DateTime)fridayBegT.Value; } if (CB7.IsChecked.Value) { nanny.WorkingHours[6].BeginingTime = (DateTime)saturdayBegT.Value; } if (CB1.IsChecked.Value) { nanny.WorkingHours[0].EndTime = (DateTime)sundayEndT.Value; } if (CB2.IsChecked.Value) { nanny.WorkingHours[1].EndTime = (DateTime)mondayEndT.Value; } if (CB3.IsChecked.Value) { nanny.WorkingHours[2].EndTime = (DateTime)tuesdayEndT.Value; } if (CB4.IsChecked.Value) { nanny.WorkingHours[3].EndTime = (DateTime)wednesdayEndT.Value; } if (CB5.IsChecked.Value) { nanny.WorkingHours[4].EndTime = (DateTime)thursdayEndT.Value; } if (CB6.IsChecked.Value) { nanny.WorkingHours[5].EndTime = (DateTime)fridayEndT.Value; } if (CB7.IsChecked.Value) { nanny.WorkingHours[6].EndTime = (DateTime)saturdayEndT.Value; } BL.UpdateNanny(nanny); nanny = new Nanny(); this.DataContext = nanny; this.Close(); } catch (Exception E) { MessageBox.Show(E.Message); } }
public NannyEditWindow(Nanny nannyToUpdate, DataGrid dataGridInput) { InitializeComponent(); bl = BL.FactoryBL.GetBL(); dataGridToRefresh = dataGridInput; ID_TextBox.Text = nannyToUpdate.NannyId.ToString(); ID_TextBox.IsEnabled = false; FirstName_TextBox.Text = nannyToUpdate.NannyPrivateName; LastName_TextBox.Text = nannyToUpdate.NannyFamilyName; birth_DatePicker.Text = nannyToUpdate.NannyDateOfBirth.Day + "/" + nannyToUpdate.NannyDateOfBirth.Month + "/" + nannyToUpdate.NannyDateOfBirth.Year; PhoneNumber_TextBox.Text = "0" + nannyToUpdate.NannyPhoneNum.ToString(); int IndexOfStreet = nannyToUpdate.NannyAdress.IndexOf(','); int IndexOfCity = nannyToUpdate.NannyAdress.LastIndexOf(','); Street_TextBox.Text = nannyToUpdate.NannyAdress.Substring(0, IndexOfStreet); City_TextBox.Text = nannyToUpdate.NannyAdress.Substring(IndexOfStreet + 2, IndexOfCity - IndexOfStreet - 2); Floor_TextBox.Text = nannyToUpdate.NannyFloor.ToString(); Elevator_CheckBox.IsChecked = nannyToUpdate.NannyIsElevator; Experience_TextBox.Text = nannyToUpdate.NannyYearsOfExperience.ToString(); MaxChildrens_TextBox.Text = nannyToUpdate.NannyMaxInfants.ToString(); MinAge_TextBox.Text = nannyToUpdate.NannyMinInfantAge.ToString(); MaxAge_TextBox.Text = nannyToUpdate.NannyMaxInfantAge.ToString(); if (nannyToUpdate.NannyIsMOE) { Vacation_ComboBox.SelectedIndex = 0; } else { Vacation_ComboBox.SelectedIndex = 1; } MonthlySalary_TextBox.Text = nannyToUpdate.NannyMonthlySalary.ToString(); HourlySalary_CheckBox.IsChecked = nannyToUpdate.NannyIsHourlySalary; if (nannyToUpdate.NannyIsHourlySalary) { HourlySalary_TextBox.Visibility = Visibility.Visible; HourlySalary_TextBox.Text = nannyToUpdate.NannyHourlySalary.ToString(); } Recommendations_TextBox.Text = nannyToUpdate.NannyRecommendations; for (int i = 0; i < 6; i++) { if (nannyToUpdate.NannyWorkingDays[i]) { switch (i) { case 0: Schedule.SundayCheckBox.IsChecked = true; Schedule.SundayStartTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Hours; Schedule.SundayStartTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Minutes; Schedule.SundayEndTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Hours; Schedule.SundayEndTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Minutes; break; case 1: Schedule.MondayCheckBox.IsChecked = true; Schedule.MondayStartTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Hours; Schedule.MondayStartTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Minutes; Schedule.MondayEndTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Hours; Schedule.MondayEndTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Minutes; break; case 2: Schedule.TuesdayCheckBox.IsChecked = true; Schedule.TuesdayStartTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Hours; Schedule.TuesdayStartTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Minutes; Schedule.TuesdayEndTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Hours; Schedule.TuesdayEndTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Minutes; break; case 3: Schedule.WednesdayCheckBox.IsChecked = true; Schedule.WednesdayStartTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Hours; Schedule.WednesdayStartTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Minutes; Schedule.WednesdayEndTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Hours; Schedule.WednesdayEndTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Minutes; break; case 4: Schedule.ThursdayCheckBox.IsChecked = true; Schedule.ThursdayStartTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Hours; Schedule.ThursdayStartTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Minutes; Schedule.ThursdayEndTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Hours; Schedule.ThursdayEndTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Minutes; break; case 5: Schedule.FridayCheckBox.IsChecked = true; Schedule.FridayStartTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Hours; Schedule.FridayStartTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].StartTime.Minutes; Schedule.FridayEndTime.HoursValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Hours; Schedule.FridayEndTime.MinutesValue = nannyToUpdate.NannyWorkingHours[i].EndTime.Minutes; break; default: break; } } } nannyToUpdate = new Nanny(); }
public NannyCard(Nanny NannyToShow, DataGrid dataGridInput) { InitializeComponent(); dataGridToRefresh = dataGridInput; bl = FactoryBL.GetBL(); nannyOfCard = NannyToShow.GetCopy(); ID_TextBox.Text = NannyToShow.NannyId.ToString(); FirstName_TextBox.Text = NannyToShow.NannyPrivateName; LastName_TextBox.Text = NannyToShow.NannyFamilyName; PhoneNumber_TextBox.Text = "0" + NannyToShow.NannyPhoneNum.ToString(); birth_TextBox.Text = NannyToShow.NannyDateOfBirth.Day + "/" + NannyToShow.NannyDateOfBirth.Month + "/" + NannyToShow.NannyDateOfBirth.Year; Adress_TextBox.Text = NannyToShow.NannyAdress; Floor_TextBox.Text = NannyToShow.NannyFloor.ToString(); Elevator_CheckBox.IsChecked = NannyToShow.NannyIsElevator; Experience_TextBox.Text = NannyToShow.NannyYearsOfExperience.ToString(); Maxchildrens_TextBox.Text = NannyToShow.NannyMaxInfants.ToString(); AgeRange_TextBox.Text = NannyToShow.NannyMinInfantAge.ToString() + "-" + NannyToShow.NannyMaxInfantAge.ToString(); Vacation_TextBox.Text = NannyToShow.NannyIsElevator ? "Ministry of Education" : "Ministry of Industry and Trade"; MonthlySalary_TextBox.Text = NannyToShow.NannyMonthlySalary.ToString() + " NIS"; HourlySalary_TextBox.Text = NannyToShow.NannyIsHourlySalary ? NannyToShow.NannyHourlySalary.ToString() + " NIS" : "Does not allow hourly salary"; Recommendations_TextBox.Text = NannyToShow.NannyRecommendations; for (int i = 0; i < 6; i++) { if (NannyToShow.NannyWorkingDays[i]) { switch (i) { case 0: Sunday_Day_TextBlock.Visibility = Visibility.Visible; Sunday_Time_TextBlock.Visibility = Visibility.Visible; Sunday_Day_TextBlock.Text = UiTools.NumToDay(i); Sunday_Time_TextBlock.Text = NannyToShow.NannyWorkingHours[i].ToString(); break; case 1: Monday_Day_TextBlock.Visibility = Visibility.Visible; Monday_Time_TextBlock.Visibility = Visibility.Visible; Monday_Day_TextBlock.Text = UiTools.NumToDay(i); Monday_Time_TextBlock.Text = NannyToShow.NannyWorkingHours[i].ToString(); break; case 2: Tuesday_Day_TextBlock.Visibility = Visibility.Visible; Tuesday_Time_TextBlock.Visibility = Visibility.Visible; Tuesday_Day_TextBlock.Text = UiTools.NumToDay(i); Tuesday_Time_TextBlock.Text = NannyToShow.NannyWorkingHours[i].ToString(); break; case 3: Wednesday_Day_TextBlock.Visibility = Visibility.Visible; Wednesday_Time_TextBlock.Visibility = Visibility.Visible; Wednesday_Day_TextBlock.Text = UiTools.NumToDay(i); Wednesday_Time_TextBlock.Text = NannyToShow.NannyWorkingHours[i].ToString(); break; case 4: Thursday_Day_TextBlock.Visibility = Visibility.Visible; Thursday_Time_TextBlock.Visibility = Visibility.Visible; Thursday_Day_TextBlock.Text = UiTools.NumToDay(i); Thursday_Time_TextBlock.Text = NannyToShow.NannyWorkingHours[i].ToString(); break; case 5: Friday_Day_TextBlock.Visibility = Visibility.Visible; Friday_Time_TextBlock.Visibility = Visibility.Visible; Friday_Day_TextBlock.Text = UiTools.NumToDay(i); Friday_Time_TextBlock.Text = NannyToShow.NannyWorkingHours[i].ToString(); break; default: break; } } } NannyToShow = new Nanny(); }
private void NannyOption(object sender, RoutedEventArgs e) { Window nannyOption = new Nanny(); nannyOption.ShowDialog(); }