public void removeMother(BE.Mother mother) { List <BE.Child> children = childrenList().Where(x => x.motherId == mother.id).ToList(); foreach (var child in children)//deleting her children { try { removeChild(child); } catch (Exception ex) { throw new Exception(ex.Message); } } try { dal.removeMother(mother); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void comboBoxChildByMom_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (comboBoxChildByMom.SelectedIndex != -1) { mom = (BE.Mother)comboBoxChildByMom.SelectedItem; } }
BL.IBL bl; //Builds an IBL type object public AddMother() { InitializeComponent(); //Startup (initializes component) M = new BE.Mother(); this.DataContext = M; //Displays on the screen the fields of the object being built bl = BL.FactoryBL.GetBL(); //Links the panel to the BL database }
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.Mother myMother = bl.FindMotherAcordId(int.Parse(myId)); var result = MessageBox.Show("Are you sure you want to delete this child?", "", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { bl.delMother(myMother); } Id_comboBox.Text = ""; Name_textBox.Text = ""; MessageBox.Show("The mother successfully removed ", "Informaion", MessageBoxButton.OK, MessageBoxImage.Information); this.Id_comboBox.BeginInit(); this.Id_comboBox.ItemsSource = bl.GetAllMothers(); 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); } }
private void buttonUpdateContract_Click(object sender, RoutedEventArgs e) { try { if (contract.isHour) { contract.salaryAgreed = contract.salaryPerHour; } else { contract.salaryAgreed = contract.salaryPerMonth; } bl.updateContract(contract); MessageBox.Show("חוזה עודכן בהצלחה"); comboBoxChooseChildUpdate.SelectedIndex = -1; comboBoxchooseMomUPdate.SelectedIndex = -1; contract = new BE.Contract(); gridDetalisContract.DataContext = contract; mom = new BE.Mother(); gridHourMom.DataContext = mom; } catch (Exception Ex) { MessageBox.Show(Ex.Message); } }
public NewMother() { InitializeComponent(); mother = new BE.Mother(); bl = BL.FactoryBL.GetBL(); DataContext = mother; }
/// <summary> /// add the data that was handed over by the user /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_Click(object sender, RoutedEventArgs e) { bool[] NeedsNanny = { (bool)Sunday.IsChecked, (bool)Monday.IsChecked, (bool)Tuesday.IsChecked, (bool)Wednesday.IsChecked, (bool)Thursday.IsChecked, (bool)Friday.IsChecked }; TimeSpan[,] workHours = { { TimeSpan.FromHours(Convert.ToDouble(SunHour.Text) + (Convert.ToDouble(SunMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(SunHour2.Text) + (Convert.ToDouble(SunMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(MonHour.Text) + (Convert.ToDouble(MonMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(MonHour2.Text) + (Convert.ToDouble(MonMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(TuesHour.Text) + (Convert.ToDouble(TuesMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(TuesHour2.Text) + (Convert.ToDouble(TuesMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(WedHour.Text) + (Convert.ToDouble(WedMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(WedHour2.Text) + (Convert.ToDouble(WedMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(ThuHour.Text) + (Convert.ToDouble(ThuMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(ThuHour2.Text) + (Convert.ToDouble(ThuMin2.Text) / 60)) }, { TimeSpan.FromHours(Convert.ToDouble(FriHour.Text) + (Convert.ToDouble(FriMin.Text) / 60)), TimeSpan.FromHours(Convert.ToDouble(FriHour2.Text) + (Convert.ToDouble(FriMin2.Text) / 60)) } }; try { BE.Mother mother; if (SearchArea.Text == "") { mother = new BE.Mother(ID.Text, First.Text, Last.Text, Phone.Text, Address.Text, Address.Text, NeedsNanny, workHours, Comments.Text); } else { mother = new BE.Mother(ID.Text, First.Text, Last.Text, Phone.Text, Address.Text, SearchArea.Text, NeedsNanny, workHours, Comments.Text); } GetBL.bl.AddMother(mother); PotentialNannyWin potentialNannyWin = new PotentialNannyWin(); potentialNannyWin.Show(); Thread.Sleep(500); Close(); } catch (Exception str) { MessageBox.Show(str.Message, str.Message, MessageBoxButton.OK, MessageBoxImage.Error); } }
public int HourEnd(int i, BE.Mother mothertemp)//מחזירה שעות סיום { int x = (int)((mothertemp.Times[1][i])[0]); int y = (int)((mothertemp.Times[1][i])[1]); return(x * 10 + y); }
public int MinutesStart(int i, BE.Mother 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.Mother mothertemp)//מחזירה שעת התחלה { int x = (int)((mothertemp.Times[0][i])[0]); int y = (int)((mothertemp.Times[0][i])[1]); return(x * 10 + y); }
private void Button_Click(object sender, RoutedEventArgs e) { try { mymother.Address = new BE.Address() { City = this.cityTextBox.Text, Country = this.countryTextBox.Text, Number = Int32.Parse(this.numberTextBox.Text), Street = this.streetTextBox.Text, ZipCode = this.zipCodeTextBox.Text }; mymother.BankDetails.BankAdress = new BE.Address() { City = this.cityTextBox.Text, Country = this.countryTextBox.Text, Number = Int32.Parse(this.numberTextBox.Text), Street = this.streetTextBox.Text, ZipCode = this.zipCodeTextBox.Text }; BL.FactoryBl.getBL().AddMother(mymother); MessageBox.Show(mymother.ToString()); mymother = new BE.Mother(); DataContext = mymother; DialogResult = true; } catch (Exception ex) { MessageBox.Show(ex.Message); //this.DialogResult = false; } }
public int MinutesEnd(int i, BE.Mother mothertemp)//מחזירה דקות סיום { int x = (int)((mothertemp.Times[1][i])[4]); int y = (int)((mothertemp.Times[1][i])[3]); return(y * 10 + x); }
private void AddMother_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.addMother(mother); //resets mother to insert the next mother mother = new BE.Mother(); this.DataContext = mother; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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 existMother(BE.Mother mom) { mother1 = mom; InitializeComponent(); bl = BL.FactoryBL.getBL(); mainGrid.DataContext = mother1; }
public List <BE.Nanny> workRightTimeforMother(BE.Mother M) {//finds all the nannys that work in the time the mother needs List <BE.Nanny> l = new List <BE.Nanny>(); bool flage; int i; foreach (BE.Nanny item in GetListOfNannys()) {//goes through list of nannys flage = true; i = 0; while ((i < 6) && (flage == true))//for each nanny check that every day she start earlly then the mother needs and ends later then the mother needs { if ((M.MotherNeedsNanny[i] == true) && (item.NannyIsWorkingOnDay[i] == true)) { if (!((M.MotherTimeNeedsNanny[i, 0] >= item.NannyTimeIsWorkingOnDay[i, 0]) && (M.MotherTimeNeedsNanny[i, 1] <= item.NannyTimeIsWorkingOnDay[i, 1]))) { flage = false; } } i++; } if (flage == true)//if the nanny every day start earlly then the mother needs and ends later then the mother needs adds to list { l.Add(item); } } return(l); }
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 List <BE.Child> childrenByMother(BE.Mother mother) { List <BE.Child> temp = new List <BE.Child>(); temp = DS.DataSource.childrenList.FindAll(x => x.motherId == mother.id); return(temp); }
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 RemoveMother(BE.Mother M) {//removes mother from program XElement root = BasicXML.LoadData(); XElement help = null; help = (from item in root.Elements() where item.Name == "Mother" where int.Parse(item.Element("id").Value) == M.MotherId select item).FirstOrDefault(); help.Remove(); BasicXML.Save(root); foreach (BE.Contract item in GetListOfContracts()) //deletes all contracts that mother is in { if (M.MotherId == item.MotherId) { RemoveContract(item); } } foreach (BE.Child item in GetListOfChildS()) //deletes all childs that M is there mother { if (M.MotherId == item.ChildMotherId) { RemoveChild(item); } } }
private void enterToSystem_Click(object sender, RoutedEventArgs e) { try { BE.Mother temp = null; temp = bl.searchMother(this.idBox.Text); if (temp == null) { throw(new Exception("no exist")); } if (temp.Password != this.passwordBox.Password) { throw (new Exception("Incorrect password")); } existMother exstMom = new existMother(temp); exstMom.Show(); this.idBox.Clear(); this.passwordBox.Clear(); } catch (Exception p) { MessageBox.Show(p.Message); } }
public AddMother_Window() { InitializeComponent(); mother = new BE.Mother(); MotherDetailsGrid.DataContext = mother; bl = BL.FactoryBL.GetBL(); }
/// <summary> /// constructor of AddMotherWin /// </summary> public AddMotherWin() { InitializeComponent(); mother = new BE.Mother(); this.DataContext = mother; bl = BL.FactoryBL.GetBL(); }
public newMom() { InitializeComponent(); bl = BL.FactoryBL.getBL(); mom = new BE.Mother(); this.mainGrid.DataContext = mom; }
private void AddMotherButton_Click(object sender, RoutedEventArgs e) { BL.FactoryBL.getBL().AddMother(mother); MessageBox.Show(mother.ToString()); mother = new BE.Mother(); DataContext = mother; this.Close(); }
public AddMotherWindow() { InitializeComponent(); bl = BL.FactorySingletonBL.GetBL(); mother = new BE.Mother(); this.DataContext = mother; ItemSourceForComboBox(); }
private void dataGrid_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (dataGrid.SelectedItem != null) { mother = new BE.Mother(dataGrid.SelectedItem as BE.Mother); DataContext = mother; } }
private void Button_Click(object sender, RoutedEventArgs e) { corentMother = myBL.SearchMother(x => x.MomId == momidtxt.Text).FirstOrDefault(); List <BE.Mother> list = new List <BE.Mother>(); list.Add(corentMother); listBox.ItemsSource = list; }
public ShowMotherWindow() { bl = BL.FactorySingletonBL.GetBL(); InitializeComponent(); dataGrid.ItemsSource = bl.Get_M_list(); mother = new BE.Mother(); DataContext = mother; }
private void comboBoxMom_SelectionChanged(object sender, SelectionChangedEventArgs e) { mom = (BE.Mother)comboBoxMom.SelectedItem; if (mom != null) { _momIDTextBox.Text = Convert.ToString(mom._momID); } }