public newNanny() { InitializeComponent(); bl = BL.FactoryBL.getBL(); nny = new BE.Nanny(); this.mainGrid.DataContext = nny; }
/// <summary> /// button for update nanny /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void update_nanny_Click(object sender, RoutedEventArgs e) { if (errorMwsagges.Any()) { string err = "Exaption:"; foreach (var item in errorMwsagges) { err += "\n" + item; } MessageBox.Show(err); return; } try { bl.update_details_Nanny(nanny); nanny = new BE.Nanny(); this.DataContext = nanny; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public int MinutesEnd(int i, BE.Nanny mothertemp)//מחזירה דקות סיום { int x = (int)((mothertemp.Times[1][i])[4]); int y = (int)((mothertemp.Times[1][i])[3]); return(y * 10 + x); }
private void comboBoxContractByNanny_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (comboBoxContractByNanny.SelectedIndex != -1) { nanny = (BE.Nanny)comboBoxContractByNanny.SelectedItem; } }
public void updateNanny(BE.Nanny nanny) { string str = ""; double distance = 0; Thread thread = new Thread(() => distance = GoogleApiFunc.CalcDistance(nanny.address, nanniesList().First(x => x.id == nanny.id).address, TravelType.Walking)); thread.Start(); thread.Join(); if (distance > 1000) { str += "update succseed but you have to update all the mother about your new address"; } try { dal.updateNanny(nanny); if (str != "") { throw new Exception(str); } } catch (Exception ex) { throw new Exception(ex.Message); } }
private void delete_Click(object sender, RoutedEventArgs e) { try { string myId = Id_comboBox.Text; if (myId == null || myId == "") throw new Exception("You need choose id!"); BE.Nanny myNanny = bl.FindNannyAcordId(int.Parse(myId)); var result = MessageBox.Show("Are you sure you want to delete this nanny?", "", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { bl.delNanny(myNanny); } Id_comboBox.Text = ""; Name_textBox.Text = ""; MessageBox.Show("The nanny successfully removed ", "Informaion", MessageBoxButton.OK, MessageBoxImage.Information); this.Id_comboBox.BeginInit(); this.Id_comboBox.ItemsSource = bl.GetAllNannies(); this.Id_comboBox.DisplayMemberPath = "Id"; this.Id_comboBox.SelectedValuePath = "Name"; this.Id_comboBox.EndInit(); } catch (Exception ex) { MessageBox.Show(ex.Message, "ERROR!", MessageBoxButton.OK, MessageBoxImage.Error); } }
public updateNanny() { InitializeComponent(); bl = BL.FactoryBL.GetBL(); nanny = this.DataContext as BE.Nanny; if (nanny.isWorkingToday[0]) { Sun.IsEnabled = true; } if (nanny.isWorkingToday[1]) { Mon.IsEnabled = true; } if (nanny.isWorkingToday[2]) { Tue.IsEnabled = true; } if (nanny.isWorkingToday[3]) { Wed.IsEnabled = true; } if (nanny.isWorkingToday[4]) { Thu.IsEnabled = true; } if (nanny.isWorkingToday[5]) { Fri.IsEnabled = true; } }
public int HourEnd(int i, BE.Nanny mothertemp)//מחזירה שעות סיום { int x = (int)((mothertemp.Times[1][i])[0]); int y = (int)((mothertemp.Times[1][i])[1]); return(x * 10 + y); }
public double Payment(BE.Contract C) { //calculates and returns how much mother owes the nanny in contract int amount = doesHeHaveBrotherInNanny(C.NannyId, C.ChildId); //finds how many brothers are also by this nanny BE.Nanny N = dal.findNanny(C.NannyId); //find of nanny double payThisMonth; double HoursPreWeek = 0; if (C.IsPymentPerHour == true) //checks if payment is by hour { for (int i = 0; i < 6; i++) //adds up time nanny works every week { HoursPreWeek += C.TimeNannyWorkingWeek[i]; } payThisMonth = C.PaymentPerHour * 4 * HoursPreWeek; } else//if payment is by month { payThisMonth = C.PaymentPermonth; } for (int j = amount; j > 0; j--)//reduces 2% of payment for each brother child has at nnany { payThisMonth = payThisMonth - (payThisMonth * 0.02); } return(payThisMonth); }
public existNanny(BE.Nanny nanny1) { nanny = nanny1; InitializeComponent(); bl = BL.FactoryBL.getBL(); mainGrid.DataContext = nanny; }
private void AddNanny_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; } bl.addNanny(nanny); nanny = new BE.Nanny(); this.DataContext = nanny; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void AddContract(BE.Contract C) { //add contract to list->the contract is basic there for the program must fill in the rest of the details BE.Nanny N = dal.findNanny(C.NannyId); //finds nanny from contract BE.Mother M = dal.findMother(C.MotherId); isNannyFilled(C); C.PaymentPerHour = N.NannyPaymentPerHour;//puts nannys payment demands into contract payments C.PaymentPermonth = N.NannyPaymentPermonth; double start, end; for (int i = 0; i < 6; i++) { if (M.MotherTimeNeedsNanny[i, 0] < N.NannyTimeIsWorkingOnDay[i, 0])//find when nanny starts working { start = N.NannyTimeIsWorkingOnDay[i, 0]; } else { start = M.MotherTimeNeedsNanny[i, 0]; } if (M.MotherTimeNeedsNanny[i, 1] < N.NannyTimeIsWorkingOnDay[i, 1])//finds when nanny stops working { end = N.NannyTimeIsWorkingOnDay[i, 1]; } else { end = M.MotherTimeNeedsNanny[i, 1]; } C.TimeNannyWorkingWeek[i] = end - start; } dal.AddContract(C); }
public void AddNanny(BE.Nanny nanny) { XElement xElement = (from item in NannyRoot.Elements() where (Convert.ToString(item.Element("NannyId").Value)) == nanny.NannyId select item).FirstOrDefault(); if (xElement != null) { ApdateNanny(nanny); } else { XElement id = new XElement("NannyId", nanny.NannyId); XElement firstName = new XElement("NannyFirstName", nanny.NannyFirstName); XElement lastName = new XElement("NannyLastName", nanny.NannyLastName); XElement phone = new XElement("NannyPhone", nanny.NannyPhone); XElement adrress = new XElement("NannyAddress", nanny.NannyAddress); XElement elevators = new XElement("IsElevators", nanny.IsElevators); XElement birth = new XElement("NannyBirth", nanny.NannyBirth); XElement flat = new XElement("Nannyflat", nanny.Nannyflat); XElement experience = new XElement("NannyExperience", nanny.NannyExperience); XElement maxChild = new XElement("MaxChild", nanny.MaxChild); XElement minAge = new XElement("MinAge", nanny.MinAge); XElement maxAge = new XElement("MaxAge", nanny.MaxAge); XElement isHours = new XElement("IsHours", nanny.IsHours); XElement moneyForHour = new XElement("MoneyForHour", nanny.MoneyForHour); XElement moneyForMonth = new XElement("MoneyForMonth", nanny.MoneyForMonth); XElement sun = new XElement("sun", nanny.Days[0]); XElement mon = new XElement("mon", nanny.Days[1]); XElement tue = new XElement("tue", nanny.Days[2]); XElement wed = new XElement("wed", nanny.Days[3]); XElement thu = new XElement("thu", nanny.Days[4]); XElement fri = new XElement("fri", nanny.Days[5]); XElement aa = new XElement("t00", nanny.Times[0][0]); XElement ab = new XElement("t01", nanny.Times[1][0]); XElement ac = new XElement("t02", nanny.Times[2][0]); XElement ad = new XElement("t03", nanny.Times[3][0]); XElement ae = new XElement("t04", nanny.Times[4][0]); XElement af = new XElement("t05", nanny.Times[5][0]); XElement ba = new XElement("t10", nanny.Times[0][1]); XElement bb = new XElement("t11", nanny.Times[1][1]); XElement bc = new XElement("t12", nanny.Times[2][1]); XElement bd = new XElement("t13", nanny.Times[3][1]); XElement be = new XElement("t14", nanny.Times[4][1]); XElement bf = new XElement("t15", nanny.Times[5][1]); XElement tttt = new XElement("Times", aa, ab, ac, ad, ae, af, ba, bb, bc, bd, be, bf); XElement isTMTVocation = new XElement("IsTMTVocation", nanny.IsTMTVocation); XElement days = new XElement("Days", sun, mon, tue, wed, thu, fri); XElement recommendation = new XElement("Recommendation", nanny.Recommendation); XElement isspecial = new XElement("Isspecial", nanny.Isspecial); NannyRoot.Add(new XElement("nanny", days, tttt, firstName, lastName, phone, adrress, elevators, birth, flat, experience, maxAge, maxChild, minAge, isHours, moneyForHour, moneyForMonth, id, isTMTVocation, isspecial, recommendation)); NannyRoot.Save(nannyPath); } }
public BE.Nanny[] bestNannysForMother(BE.Mother M) {//returns the array of nannys that are best for the mother double missedT; if (GetListOfNannys().Capacity <= 5)//if there are less then 5 nannies in nanny list then return all of them { BE.Nanny[] BestNanny2 = GetListOfNannys().ToArray(); return(BestNanny2); } BE.Nanny[] BestNanny = new BE.Nanny[5]; double[] NannyMissedTime = new double[5]; //saves the amount of hours each nanny is bad for mother int switchplace = returnMaxPlace(NannyMissedTime); //saves the place of the worst nanny for mother for (int i = 0; i < 5; i++) //places the 5 first nannies into array { BestNanny[i] = GetListOfNannys()[i]; NannyMissedTime[i] = WorksForMotherAndNannyTime(M, GetListOfNannys()[i]); } for (int j = 6; j < GetListOfNannys().Capacity; j++) {//goes through the rest of the nanny list and if its better then the worst nanny in array it switches them missedT = WorksForMotherAndNannyTime(M, GetListOfNannys()[j]); if (missedT < NannyMissedTime[switchplace]) { NannyMissedTime[switchplace] = missedT; BestNanny[switchplace] = GetListOfNannys()[j]; switchplace = returnMaxPlace(NannyMissedTime); } } return(BestNanny); }
public double WorksForMotherAndNannyTime(BE.Mother M, BE.Nanny N) {//returns the amount of time the mother needs nanny but nanny does not work int i = 0; double sum = 0; while (i < 6) { if (M.MotherNeedsNanny[i] == true) //mother needs nanny on day i { if (N.NannyIsWorkingOnDay[i] == true) //nanny works on day i { if (M.MotherTimeNeedsNanny[i, 0] < N.NannyTimeIsWorkingOnDay[i, 0]) //if nanny starts later then mother needs { sum = sum + N.NannyTimeIsWorkingOnDay[i, 0] - M.MotherTimeNeedsNanny[i, 0]; } if (M.MotherTimeNeedsNanny[i, 1] > N.NannyTimeIsWorkingOnDay[i, 1])//if nanny end earlier then mother needs { sum = sum + M.MotherTimeNeedsNanny[i, 1] - N.NannyTimeIsWorkingOnDay[i, 1]; } } else//if nanny does not work on day i { sum = sum + M.MotherTimeNeedsNanny[i, 1] - M.MotherTimeNeedsNanny[i, 0]; } } i++; } return(sum); }
public int MinutesStart(int i, BE.Nanny mothertemp)//מחזירה דקות התחלה { int x = (int)((mothertemp.Times[0][i])[4]); int y = (int)((mothertemp.Times[0][i])[3]); return(y * 10 + x); }
public int HoursStart(int i, BE.Nanny mothertemp)//מחזירה שעת התחלה { int x = (int)((mothertemp.Times[0][i])[0]); int y = (int)((mothertemp.Times[0][i])[1]); return(x * 10 + y); }
public AddNanny() { InitializeComponent(); N = new BE.Nanny(); this.DataContext = N; bl = BL.FactoryBL.GetBL(); }
private void enterToSystem_Click(object sender, RoutedEventArgs e) { try { BE.Nanny temp = null; temp = bl.searchNanny(this.idBox.Text); if (temp == null) { throw (new Exception("no exist")); } if (temp.Password != this.passwordBox.Password) { throw (new Exception("Incorrect password")); } existNanny exstNanny = new existNanny(temp); exstNanny.Show(); this.idBox.Clear(); this.passwordBox.Clear(); } catch (Exception p) { MessageBox.Show(p.Message); } }
private void dataGrid_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (dataGrid.SelectedItem != null) { nanny = new BE.Nanny(dataGrid.SelectedItem as BE.Nanny); DataContext = nanny; } }
public void AddNanny(BE.Nanny N) {//adds nanny to list after checking that he does not exist already if (checkNanny(N) == true) { throw new Exception("nanny already exists"); } listOfNannys.Add(N); }
private void Button_Click(object sender, RoutedEventArgs e) { contractNanny = myBL.SearchNany(x => x.NannyId == idnannytxt.Text).FirstOrDefault(); List <BE.Nanny> list = new List <BE.Nanny>(); list.Add(contractNanny); litstBox.ItemsSource = list; }
/// <summary> /// reload the page data, to get clean fields /// </summary> private void refreshData() { nanny = new BE.Nanny(); this.DataContext = nanny; this.CommentsExpander.IsExpanded = false; this.RecommendationsExpander.IsExpanded = false; this.SpecialActivitiesExpander.IsExpanded = false; }
public NewNanny() { InitializeComponent(); nanny = new BE.Nanny(); nanny.dateOfBirth = DateTime.Now.AddYears(-18); bl = BL.FactoryBL.GetBL(); this.DataContext = nanny; }
public AddNannyWindow() { InitializeComponent(); nanny = new BE.Nanny(); this.DataContext = nanny; // bl = BL.blfactory.getbl(); }
public ShowNannyWindow() { bl = BL.FactorySingletonBL.GetBL(); InitializeComponent(); dataGrid.ItemsSource = bl.Get_N_list(); nanny = new BE.Nanny(); DataContext = nanny; collection = new ListCollectionView(bl.Get_N_list()); }
public AnotherFunNan_Window() { InitializeComponent(); nanny = new BE.Nanny(); bl = BL.FactoryBL.GetBL(); this.IdNanny_comboBox.ItemsSource = bl.GetAllNannies(); this.IdNanny_comboBox.DisplayMemberPath = "Id"; this.IdNanny_comboBox.SelectedValuePath = "Id"; }
private void datalist_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (datalist.SelectedItem != null) { nanny = new BE.Nanny(datalist.SelectedItem as BE.Nanny); DataContext = nanny; AddButton.IsEnabled = true; } }
private void DeleteNannyButton_Click(object sender, RoutedEventArgs e) { nanny = BL.FactoryBL.getBL().GetNannyByID(nanny.ID); BL.FactoryBL.getBL().DeleteNanny(nanny); MessageBox.Show("the nanny is deleted"); nanny = new BE.Nanny(); DataContext = nanny.ID; this.Close(); }
public List <BE.Child> childrenByNanny(BE.Nanny nanny) { int nannyId = nanny.id; List <BE.Contract> contracts = contractsList().Where(x => x.nannyId == nannyId).ToList(); IEnumerable <BE.Child> children = from child in contracts select childrenList().First(x => x.Id == child.childId); return(children.ToList()); }