// static public bool condition(Contract c) // { // return c.Singning && c.Meeting; // } static void Main(string[] args) { BE.Nanny nanny; BL.IBL bl; nanny = new BE.Nanny(); bl = BL.FactoryBL.GetBL(); // bl.IsHaveFriend(new BE.Child); //Time a = new Time(); //a.StartOcloc = TimeSpan.Parse("08:30"); //Nanny nanny = new Nanny(1, "", "", "5.4.1998"); //nanny.eduction = Eduction.EducationOffice; //nanny.Address = "Kineret,Haifa,Israel"; //nanny.Experience = 2; //nanny.Family = "winter"; //nanny.Floor = 3; //nanny.Hour = 25; //bool[] workDays = new bool[6] { true, false, true, false, true, true }; //nanny.IsWork = workDays; //int[,] workHours = new int[2, 6] //{ { 0800, 0900, 0000, 1100, 0000, 0000 }, // { 1400,1600,0000,1700,0000,0000}}; //nanny.NumWorkHours = new Time[6]; //nanny.IfHour = true; //nanny.IsLift = true; //nanny.MaxAgeMounth = 6; //nanny.MaxChild = 3; //nanny.Name = "hana"; //nanny.Phone = 07653456; //nanny.IfPrepareFood = true; }
private void comboBoxNannyUpdate_SelectionChanged(object sender, SelectionChangedEventArgs e) { buttonUpdateNanny.IsEnabled = true; nanny = (BE.Nanny)comboBoxNannyUpdate.SelectedItem; addressNannyTextBoxUpdate.Text = nanny.addressNanny; updateNannyTab.DataContext = nanny; }
private void relevantNannies_list_SelectionChanged(object sender, SelectionChangedEventArgs e) { DataGrid helpDataGrid = sender as DataGrid; if (helpDataGrid.SelectedIndex > -1) // grid in not empty { nanny = helpDataGrid.SelectedItem as BE.Nanny; addCont._isByHour = nanny._acceptByHour; addCont._nannyID = nanny._nannyID; addCont._ratePerHour = nanny._rateByHour; addCont._ratePerMonth = nanny._rateByMonth; addCont._monthHours = bl.getMotherHours(addMom); if (nanny._acceptByHour) { addCont._finalPerHour = bl.getUpdatedRate(addCont._childID, nanny._nannyID, true); } else { addCont._finalPerMonth = bl.getUpdatedRate(addCont._childID, nanny._nannyID, false); } _nannyIDTextBox1.Text = Convert.ToString(nanny._nannyID); _childIDTextBox.Text = Convert.ToString(addCont._childID); } addCont._momID = addMom._momID; thisGrid.DataContext = addCont; }
private void UpdateNannyButton_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 { if (nanny != null) { bl.updateNanny(nanny); } this.DataContext = nanny = null; //updates the combo list after the update refreshData(); this.Close(); // this.updateNannyComboBox.ItemsSource = bl.getNanniesList(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { Nanny N = updateNannyComboBox.SelectedItem as Nanny; if (N != null) { nanny = N.getNannyCopy(); // this.grid1.DataContext = nanny; this.DataContext = nanny; this.SundayBeginningTimeComboBox.SelectedValue = N.WorkHourPerDay[0, 0]; this.MondayBeginningTimeComboBox.SelectedValue = N.WorkHourPerDay[0, 1]; this.TuesdayBeginningTimeComboBox.SelectedValue = N.WorkHourPerDay[0, 2]; this.WednesdayBeginningTimeComboBox.SelectedValue = N.WorkHourPerDay[0, 3]; this.ThursdayBeginningTimeComboBox.SelectedValue = N.WorkHourPerDay[0, 4]; this.FridayBeginningTimeComboBox.SelectedValue = N.WorkHourPerDay[0, 5]; this.SundayEndTimeComboBox.SelectedValue = N.WorkHourPerDay[1, 0]; this.MondayEndTimeComboBox.SelectedValue = N.WorkHourPerDay[1, 1]; this.TuesdayEndTimeComboBox.SelectedValue = N.WorkHourPerDay[1, 2]; this.WednesdayEndTimeComboBox.SelectedValue = N.WorkHourPerDay[1, 3]; this.ThursdayEndTimeComboBox.SelectedValue = N.WorkHourPerDay[1, 4]; this.FridayEndTimeComboBox.SelectedValue = N.WorkHourPerDay[1, 5]; } }
/// <summary> /// Calculates the salary for child care /// /// Exception: /// if the nother asks to calculate according to hour, and the nanny does not allow /// </summary> /// <param name="nan">object of nanny</param> /// <param name="isDalyRate">bool variable if the mother wants order to hourly rate or not</param> /// <param name="someBrothers">int variable if there more children by the same nanny</param> /// <returns></returns> double SalaryPerMonth(BE.Nanny nan, bool isDalyRate, int someBrothers) { double salary = 0; if (!isDalyRate) { salary = nan.SallaryPerMonths; } else { //if the nanny opposes hourly payment if (!nan.IsHourlyRate) { throw new Exception(); } //Calculation of monthly work hours double timeWeekWork = 0; for (int i = 0; i < 6; ++i) { if (nan.workDay[i]) { timeWeekWork += (nan.timeOfWork[1, i] - nan.timeOfWork[0, i]).TotalHours; } } //calculation of the full monthly salary salary = (timeWeekWork * 4) * nan.SallaryPerHour; //calculation of discount double PercentDiscount = (salary * (someBrothers) * 2) / 100; salary -= PercentDiscount; } return(salary); }
private void AddNannyButton_Click(object sender, RoutedEventArgs e) { BL.FactoryBL.getBL().AddNanny(nanny); MessageBox.Show(nanny.ToString()); nanny = new BE.Nanny(); DataContext = nanny; this.Close(); }
private void addNannyTab_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { nanny = new BE.Nanny(); nanny.startHour = new DateTime[6]; nanny.endHour = new DateTime[6]; nanny.daysWorkNanny = new bool[6]; nanny.dateNanny = new DateTime(1990, 1, 1); addNannyTab.DataContext = nanny; }
public deleteNanny() { InitializeComponent(); DelNan = new BE.Nanny(); this.DataContext = DelNan; bl = BL.FactoryBL.GetBL(); textBox.ItemsSource = bl.getAllNanny(); textBox.DisplayMemberPath = "_fullName"; }
public IEnumerable <BE.Child> getChildOfNanni(BE.Nanny Nanny) { IEnumerable <BE.Child> temp = getAllChild(); var child = from ch in temp where ch.IdOfNanny == Nanny.Id select ch; return(child); }
public void removeNanny(BE.Nanny nanny) { foreach (var item in getChildOfNanni(nanny)) { removeContract(getContractOfChild(item)); item.IdOfNanny = "0"; updateChild(item); } dal.removeNanny(nanny); }
public void updateNanny(BE.Nanny nanny) { foreach (BE.Nanny item in ds.nannies) { if (item == nanny) { ds.nannies.Remove(item); ds.nannies.Add(nanny); } } }
private void IdNanny_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (sender is ComboBox && ((ComboBox)sender).SelectedIndex > -1) { try { addA_Nanny = (Nanny)IdNanny.SelectedItem; thisGrid.DataContext = addA_Nanny; if (addA_Nanny._workDays[0] == true) { SunCheck.IsChecked = true; SunStart.Value = addA_Nanny._startHour[0].ToUniversalTime(); SunEnd.Value = addA_Nanny._endHour[0].ToUniversalTime(); } if (addA_Nanny._workDays[1] == true) { MonCheck.IsChecked = true; MonStart.Value = addA_Nanny._startHour[1].ToUniversalTime(); MonEnd.Value = addA_Nanny._endHour[1].ToUniversalTime(); } if (addA_Nanny._workDays[2] == true) { TueCheck.IsChecked = true; TueStart.Value = addA_Nanny._startHour[2].ToUniversalTime(); TueEnd.Value = addA_Nanny._endHour[2].ToUniversalTime(); } if (addA_Nanny._workDays[3] == true) { WedCheck.IsChecked = true; WedStart.Value = addA_Nanny._startHour[3].ToUniversalTime(); WedEnd.Value = addA_Nanny._endHour[3].ToUniversalTime(); } if (addA_Nanny._workDays[4] == true) { ThuCheck.IsChecked = true; ThuStart.Value = addA_Nanny._startHour[4].ToUniversalTime(); ThuEnd.Value = addA_Nanny._endHour[4].ToUniversalTime(); } if (addA_Nanny._workDays[5] == true) { FriCheck.IsChecked = true; FriStart.Value = addA_Nanny._startHour[5].ToUniversalTime(); FriEnd.Value = addA_Nanny._endHour[5].ToUniversalTime(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public AddingNanny() { InitializeComponent(); bl = BL.FactoryBL.GetBL(); nanny = new Nanny(); this.DataContext = nanny; nanny.born = DateTime.Parse("07/09/97"); BornDatePicker.DisplayDateEnd = DateTime.Now; this.UpdateButton.IsEnabled = false; this.FloorComboBox.ItemsSource = Enum.GetValues(typeof(BE.FLOORS)); }
public updateNanny() { InitializeComponent(); _nannyBirthDatePicker2.SelectedDate = DateTime.Today; addA_Nanny = new BE.Nanny(); addA_Nanny._startHour = new DateTime[6]; addA_Nanny._endHour = new DateTime[6]; addA_Nanny._workDays = new bool[6]; this.DataContext = addA_Nanny; bl = BL.FactoryBL.GetBL(); IdNanny.ItemsSource = bl.getAllNanny(); IdNanny.DisplayMemberPath = "_fullName"; }
private void textBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (sender is ComboBox && ((ComboBox)sender).SelectedIndex > -1) { try { DelNan = (Nanny)textBox.SelectedItem; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void datalist_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (datalist.SelectedItem != null) { BE.Nanny nanny = new BE.Nanny(datalist.SelectedItem as BE.Nanny); nanny_IDTextBlock.Text = nanny.ID.ToString(); is_PayPer_HourCheckBox.IsChecked = (bool)nanny.Salary_Per_Hour; pay_For_HourTextBox.Text = nanny.Pay_For_Hour.ToString(); pay_for_MonthTextBox.Text = nanny.Pay_For_Mount.ToString(); DataContextNanny(nanny); AddButton.IsEnabled = true; } }
//public BL_imp() //{ // init(); //} public void addNanny(BE.Nanny nanny) { nanny.Age(); if (nanny.AgeYear < 18) { throw (new Exception("nanny need to be at least 18 years old")); } if (searchNanny(nanny.Id) != null) { throw (new Exception("the nanny is already exist in the nanny list")); } dal.addNanny(nanny); }
//constractor public NannyWindow() { InitializeComponent(); bl = BL.FactoryBl.getBl(); option.SelectionChanged += Option_SelectionChanged; nanny = new BE.Nanny(); nanny.bDay = DateTime.Now.AddYears(-40); this.NannyGrid.DataContext = nanny; this.idComboBox.ItemsSource = null; this.idComboBox.ItemsSource = bl.getNannies(); idComboBox.DisplayMemberPath = "idAndName"; idComboBox.SelectedValuePath = "id"; this.daysOffPropComboBox.ItemsSource = Enum.GetValues(typeof(BE.DaysOff)); errorMessages = new List <string>(); }
private void button_Click_buttonAddNanny(object sender, RoutedEventArgs e) { try { nanny.addressNanny = addressNannyTextBox.Text; bl.addNanny(nanny); nanny = new BE.Nanny(); addNannyTab.DataContext = nanny; MessageBox.Show("המטפלת הוספה בהצלחה"); } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
private void _nannyIDTextBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (sender is ComboBox && ((ComboBox)sender).SelectedIndex > -1) { try { nanny = (Nanny)_nannyIDTextBox.SelectedItem; addCont._momID = addMom._momID; //_nannyIDTextBox1.Text = nanny._nannyID; } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
private void buttonUpdateNanny_Click(object sender, RoutedEventArgs e) { try { nanny.addressNanny = addressNannyTextBoxUpdate.Text; bl.updateNanny(nanny); MessageBox.Show("פרטי המטפלת עודכנו"); comboBoxNannyUpdate.SelectedIndex = -1; nanny = new Nanny(); updateNannyTab.DataContext = nanny; } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
public void removeNanny(BE.Nanny nanny) { XElement nannyElement; try { nannyElement = (from na in nannyRoot.Elements() where int.Parse(na.Element("id").Value) == nanny.id select na).FirstOrDefault(); nannyElement.Remove(); } catch { throw new Exception("can not delete nanny"); } }
public DeleteNannyWindow() { try { InitializeComponent(); nanny = new BE.Nanny(); bl = BL.FactoryBL.GetBL(); refreshData(); this.DeleteNannyComboBox.DisplayMemberPath = "Id"; this.DeleteNannyComboBox.SelectedValuePath = "Id"; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void removeContract(BE.Contract contract) { if (contract != null) { BE.Nanny nannyTemp = searchNanny(contract.IdOfNanny); BE.Child childTemp = searchChild(contract.IdOfChild); childTemp.IdOfNanny = "0"; childTemp.ContractNum = 0; dal.updateChild(childTemp); nannyTemp.CountChildren--; updateNanny(nannyTemp); dal.removeContract(contract); } }
private void search_Click(object sender, RoutedEventArgs e) { try { child_list = bl.getKidsByMom(a => a._momID == addMom._momID); _childIDTextBox.ItemsSource = child_list; child = (Child)_childIDTextBox.SelectedItem; // thisGrid.DataContext = child; _childIDTextBox.DisplayMemberPath = "_fullName"; } catch (Exception ex) { MessageBox.Show(ex.Message); } try { nanny_list = bl.allCompatibleNannies(addMom); _nannyIDTextBox.ItemsSource = nanny_list; nanny = (Nanny)_nannyIDTextBox.SelectedItem; // this.DataContext = nanny; _nannyIDTextBox.DisplayMemberPath = "_fullName"; } catch (Exception ex) { MessageBox.Show(ex.Message); } try { child_list = bl.getKidsByMom(a => a._momID == addMom._momID); // refine children list to thisMoms kids thisMomsKids_list.ItemsSource = child_list; // update UI window nanny_list = bl.allCompatibleNannies(addMom); // refine to relevant nanneis (suitble schedule or 5 nearest) relevantNannies_list.ItemsSource = nanny_list; // update UI window } catch (FormatException) { MessageBox.Show("Check your input and try again"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void dataGridNannyList_SelectionChanged(object sender, SelectionChangedEventArgs e) { DataGrid dg = sender as DataGrid; if (dg.SelectedIndex > -1) { nanny = dg.SelectedItem as BE.Nanny; idNannyTextBox.Text = Convert.ToString(nanny.nannyId); isHourCheckBox.IsChecked = nanny.isByHourNanny; if (nanny.isByHourNanny) { salaryPerHourTextBox.Text = Convert.ToString(bl.getSalary(child.idChild, nanny.nannyId, true, false)); contract.salaryPerHour = bl.getSalary(child.idChild, nanny.nannyId, true, false); } salaryPerMonthTextBox.Text = Convert.ToString(bl.getSalary(child.idChild, nanny.nannyId, false, false)); contract.salaryPerMonth = bl.getSalary(child.idChild, nanny.nannyId, false, false); contract.idNanny = nanny.nannyId; } }
public void addNanny(BE.Nanny nanny) { if (nanniesList().FindAll(x => x.id == nanny.id).Count != 0) { throw new Exception("cand add nanny there is nanny with such id"); } XElement isWorkingToday = new XElement("workingDays"); XElement workingHours = new XElement("workingHours"); for (int i = 0; i < 6; i++) { isWorkingToday.Add(new XElement("day" + i.ToString().ToUpper(), ToXMLstring(nanny.isWorkingToday[i]))); if (nanny.isWorkingToday[i]) { workingHours.Add(new XElement("start" + i.ToString().ToUpper(), nanny.workingHours[i, 0].ToString(@"hh\:mm\:ss"))); workingHours.Add(new XElement("end" + i.ToString().ToUpper(), nanny.workingHours[i, 1].ToString(@"hh\:mm\:ss"))); } } XElement id = new XElement("id", nanny.id); XElement lastName = new XElement("lastName", nanny.lastName); XElement firstName = new XElement("firstName", nanny.firstName); XElement dateOfBirth = new XElement("dateOfBirth", nanny.dateOfBirth.ToString(@"MM\/dd\/yyyy")); XElement phoneNumber = new XElement("phoneNumber", nanny.phoneNumber); XElement address = new XElement("address", nanny.address); XElement isElevator = new XElement("elevator", ToXMLstring(nanny.isElevator)); XElement floor = new XElement("floor", nanny.floor); XElement experienceYears = new XElement("experienceYears", nanny.experienceYears); XElement maxChildren = new XElement("maxChildren", nanny.maxChildren); XElement minAgeChildren = new XElement("minimumAgeChildren", nanny.minAgeChildren); XElement maxAgeChildren = new XElement("maximumAgeChildren", nanny.maxAgeChildren); XElement hourlyRateAccepting = new XElement("hourlyRateAccepting", ToXMLstring(nanny.hourlyRateAccepting)); XElement hourlyRate = new XElement("hourlyRate", nanny.hourlyRate); XElement monthlyRate = new XElement("monthlyRate", nanny.monthlyRate); XElement tamatHolidays = new XElement("tamatHolidays", ToXMLstring(nanny.tamatHolidays)); XElement reviews = new XElement("reviews", nanny.reviews); nannyRoot.Add(new XElement("nanny", firstName, lastName, id, address, phoneNumber, isElevator, dateOfBirth, floor, experienceYears, maxChildren, maxAgeChildren, minAgeChildren, hourlyRateAccepting, hourlyRate, monthlyRate, tamatHolidays, reviews, isWorkingToday, workingHours)); nannyRoot.Save(nannyPath); }
//בחירת מטפלתת ועידכון הפרטים בתצוגה private void idComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.idComboBox.SelectedItem is Nanny) { this.nanny = ((Nanny)this.idComboBox.SelectedItem).getCopyNanny(); this.NannyGrid.DataContext = nanny; this.sundayStart.Text = nanny.hoursOfWork[0, 0].ToString(); this.sundayEnd.Text = nanny.hoursOfWork[1, 0].ToString(); this.mondayStart.Text = nanny.hoursOfWork[0, 1].ToString(); this.mondayEnd.Text = nanny.hoursOfWork[1, 1].ToString(); this.tuesdayStart.Text = nanny.hoursOfWork[0, 2].ToString(); this.tuesdayEnd.Text = nanny.hoursOfWork[1, 2].ToString(); this.wednesdayStart.Text = nanny.hoursOfWork[0, 3].ToString(); this.wednesdayEnd.Text = nanny.hoursOfWork[1, 3].ToString(); this.thursdayStart.Text = nanny.hoursOfWork[0, 4].ToString(); this.thursdayEnd.Text = nanny.hoursOfWork[1, 4].ToString(); this.fridayStart.Text = nanny.hoursOfWork[0, 5].ToString(); this.fridayEnd.Text = nanny.hoursOfWork[1, 5].ToString(); } }
//Return the number of times in week that there is compatibility between nanny and mom public int compareMomNannies(BE.Nanny nanny, BE.Mother mom) { DateTime[,] nannyMatrix = convert(nanny.workHoursTimestring); DateTime[,] momMatrix = convert(nanny.workHoursTimestring); int count = 0; for (int i = 0; i < 6; i++) { if (nanny.dayOfWork[i] && mom.dayOfWork[i]) { if (nannyMatrix[i, 0] <= momMatrix[i, 0] && nannyMatrix[i, 1] >= momMatrix[i, 1]) { count++; } } } return(count); }