private void child_IDComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            if (child_IDComboBox.SelectedItem != null)
            {
                try
                {
                    var Child = new BE.Child(child_IDComboBox.SelectedItem as BE.Child);
                    var Mom   = bl.Get_M_list().Find(who => who.ID == Child.Id_Mom);
                    contract.Child_ID = Child.ID;

                    //find top nannys
                    new Thread(() =>
                    {
                        var groping_list = bl.Find_Closes_Nannys(Mom, Child).ToList();

                        Dispatcher.Invoke(new Action(() =>
                        {
                            datalist.ItemsSource = groping_list;
                        }));
                    }).Start();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public UpdateChildWindow()
        {
            try
            {
                InitializeComponent();
                child         = null;
                errorMessages = new List <string>();

                bl = BL.FactoryBL.GetBL();
                refreshData();

                this.updateChildComboBox.DisplayMemberPath = "ChildiID";
                this.updateChildComboBox.SelectedValuePath = "ChildiID";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            this.momIdComboBox.ItemsSource = null;
            this.momIdComboBox.ItemsSource = bl.getMothersList();

            this.momIdComboBox.DisplayMemberPath = "Id";
            this.momIdComboBox.SelectedValuePath = "Id";
        }
Ejemplo n.º 3
0
 private void addButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string errorMassage = "";
         if (this.nameTextBox.Text == "")
         {
             errorMassage += "You must enter name.\n";
         }
         if (this.idTextBox.Text == "0")
         {
             errorMassage += "You must enter identity number.\n";
         }
         if (this.birthDatePicker.Text == "01/01/0001")
         {
             errorMassage += "You must enter a date of birthday.\n";
         }
         if (this.motherIdTextBox.Text == "0")
         {
             errorMassage += "You must enter identity number of mother.\n";
         }
         if (errorMassage != "")
         {
             throw new Exception(errorMassage);
         }
         bl.addChild(child);
         child            = new BE.Child();
         this.DataContext = child;
         MessageBox.Show("The child successfully added ", "Informaion", MessageBoxButton.OK, MessageBoxImage.Information);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "missing!!", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
 }
Ejemplo n.º 4
0
        private void UpdateChild_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 (child != null)
                    {
                        bl.updateChild(child);
                    }
                    this.DataContext = child = null;
                    //updates the combo list after the update
                    refreshData();
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void AddChild_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.addChild(child);
                //resets child to insert the next child

                child            = null;
                this.DataContext = child;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 6
0
 public newChild(int motherId, Child ch)
 {
     InitializeComponent();
     child            = ch;
     bl               = BL.FactoryBL.GetBL();
     this.DataContext = child;
 }
 private void DeleteChildButton_Click(object sender, RoutedEventArgs e)
 {
     BL.FactoryBL.getBL().DeleteChild(child);
     MessageBox.Show("the Child is deleted");
     child       = new BE.Child();
     DataContext = child.ChildID;
     this.Close();
 }
Ejemplo n.º 8
0
 public newChild()
 {
     InitializeComponent();
     child             = new BE.Child();
     child.dateOfBirth = DateTime.Now;
     bl = BL.FactoryBL.GetBL();
     this.DataContext = child;
 }
Ejemplo n.º 9
0
 //בחירת ילד ועדכון הפרטים שלו בתצוגה
 private void idComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.idComboBox.SelectedItem is Child)
     {
         this.child = ((Child)this.idComboBox.SelectedItem).GetCopy();
         this.gridChild.DataContext = child;
         idMomComboBox.SelectedItem = bl.getMothers(x => x.id == child.idMom).First();
     }
 }
 public DeleteChildWindow()
 {
     InitializeComponent();
     child = new Child();
     bl    = FactoryBL.getBL();
     this.grid1.DataContext           = child;
     this.childIDComboBox.ItemsSource = from z in bl.GetChilds()
                                        select z.ChildID;
 }
Ejemplo n.º 11
0
 public deleteChild()
 {
     InitializeComponent();
     DelChild         = new BE.Child();
     this.DataContext = DelChild;
     bl = BL.FactoryBL.GetBL();
     textBox.ItemsSource       = bl.getAllChildren();
     textBox.DisplayMemberPath = "_fullName";
 }
Ejemplo n.º 12
0
        public void removeChild(BE.Child child)
        {
            if (child.ContractNum != 0)
            {
                removeContract(getContractOfChild(child));
            }

            dal.removeChild(child);
        }
Ejemplo n.º 13
0
 public newChild(int motherId)
 {
     InitializeComponent();
     child             = new BE.Child();
     child.dateOfBirth = DateTime.Now;
     child.motherId    = motherId;
     bl          = BL.FactoryBL.GetBL();
     DataContext = child;
 }
Ejemplo n.º 14
0
        public AddChild()
        {
            InitializeComponent();
            child            = new BE.Child();
            this.DataContext = child;

            bl = BL.FactoryBL.GetBL();

            this.childGenderComboBox.ItemsSource = Enum.GetValues(typeof(BE.Gender));
        }
Ejemplo n.º 15
0
        //function convert child to XElement
        XElement ConvertChild(BE.Child child)
        {
            XElement childElement = new XElement("child");

            foreach (PropertyInfo item in typeof(BE.Child).GetProperties())
            {
                childElement.Add(new XElement(item.Name, item.GetValue(child, null)));
            }
            return(childElement);
        }
Ejemplo n.º 16
0
 //מאפס את הנתונים בתצוגה
 private void refreshData()
 {
     child      = new Child();
     child.bDay = DateTime.Now.AddYears(-1);
     this.gridChild.DataContext  = child;
     idComboBox.ItemsSource      = null;
     idComboBox.ItemsSource      = bl.getChildren();
     idComboBox.SelectedIndex    = -1;
     idMomComboBox.SelectedIndex = -1;
 }
Ejemplo n.º 17
0
        private void dataGridChildList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid dg = sender as DataGrid;

            if (dg.SelectedIndex > -1)
            {
                child = dg.SelectedItem as BE.Child;
                idChildTextBox.Text = Convert.ToString(child.idChild);
                contract.idChild    = child.idChild;
            }
        }
Ejemplo n.º 18
0
        XElement ConvertChild(BE.Child child)
        {
            XElement ChildiID       = new XElement("ChildiID", child.ChildiID);
            XElement MomId          = new XElement("MomId", child.MomId);
            XElement Name           = new XElement("Name", child.Name);
            XElement Birthday       = new XElement("Birthday", child.Birthday);
            XElement IsSpecialNeeds = new XElement("IsSpecialNeeds", child.IsSpecialNeeds);
            XElement SpecialNeeds   = new XElement("SpecialNeeds", child.SpecialNeeds);
            XElement childElement   = new XElement("child", ChildiID, MomId, Name, Birthday, IsSpecialNeeds, SpecialNeeds);

            return(childElement);
        }
Ejemplo n.º 19
0
        private void thisMomsKids_list_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid helpDataGrid = sender as DataGrid;

            if (helpDataGrid.SelectedIndex > -1) // grid in not empty
            {
                child = helpDataGrid.SelectedItem as BE.Child;

                addCont._childID     = child._childID;
                _childIDTextBox.Text = Convert.ToString(child._childID);
            }
        }
Ejemplo n.º 20
0
        private void updateChildComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Child C = updateChildComboBox.SelectedItem as Child;

            if (C != null)
            {
                child            = C.getChildCopy();
                this.DataContext = child;
                //makes the combo show current momId,befor changes
                momIdComboBox.SelectedValue = C.MomId;
            }
        }
Ejemplo n.º 21
0
 private void textBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (sender is ComboBox && ((ComboBox)sender).SelectedIndex > -1)
     {
         try
         {
             DelChild = (Child)textBox.SelectedItem;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
        private void search_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                childToUpdate = bl.getChild(Convert.ToInt64(idChildTextBox.Text));

                UpdateChild.DataContext = childToUpdate;
            }
            catch (Exception exception)
            {
                MessageBox.Show("Please check your input");
                throw;
            }
        }
Ejemplo n.º 23
0
        public void addChild(BE.Child child)
        {
            if (searchMother(child.IdOfMom) == null)
            {
                throw (new Exception("You can not add a child Without a mother"));
            }

            if (searchChild(child.Id) != null)
            {
                throw (new Exception("You can not add a child who is alredy xsist on the child list"));
            }

            child.Age();
            dal.addChild(child);
        }
 private void update_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         childToUpdate = UpdateChild.DataContext as Child;
         bl.updateChild(childToUpdate);
         MessageBox.Show("פרטי ילד עודכנו בהצלחה");
         Close();
     }
     catch (Exception exception)
     {
         MessageBox.Show("Please check your input");
         throw;
     }
 }
Ejemplo n.º 25
0
        private void IdChild_SelectionChanged(object tempo, RoutedEventArgs e)
        {
            if (tempo is ComboBox && ((ComboBox)tempo).SelectedIndex > -1)
            {
                try
                {
                    updateKid        = (Child)IdChild.SelectedItem;
                    this.DataContext = updateKid;
                    MessageBox.Show("Child is found, you can continue updating...");
                }

                catch (FormatException)
                {
                    MessageBox.Show("Check your input and try again");
                }
            }
Ejemplo n.º 26
0
        public void removeChild(BE.Child child)
        {
            XElement childElement;

            try
            {
                childElement = (from ch in childRoot.Elements()
                                where int.Parse(ch.Element("id").Value) == child.Id
                                select ch).FirstOrDefault();
                childElement.Remove();
            }
            catch
            {
                throw new Exception("can not delete child");
            }
        }
 public void idCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         string id = childIDComboBox.SelectedValue.ToString();
         child = this.bl.GetChildByID(id);
         MessageBox.Show(child.ToString());
     }
     catch (FormatException)
     {
         MessageBox.Show("Incorrect input");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Ejemplo n.º 28
0
 //constractor
 public ChildWindow()
 {
     InitializeComponent();
     bl = BL.FactoryBl.getBl();
     option.SelectionChanged += Option_SelectionChanged;
     child = new BE.Child();
     this.gridChild.DataContext      = child;
     idComboBox.ItemsSource          = null;
     this.idComboBox.ItemsSource     = bl.getChildren();
     idComboBox.DisplayMemberPath    = "idAndName";
     idComboBox.SelectedValuePath    = "id";
     this.idMomComboBox.ItemsSource  = bl.getMothers();
     idMomComboBox.DisplayMemberPath = "idAndName";
     idMomComboBox.SelectedValuePath = "id";
     child.bDay    = DateTime.Now.AddYears(-1);
     errorMessages = new List <string>();
 }
Ejemplo n.º 29
0
        public DeleteChildWindow()
        {
            try
            {
                InitializeComponent();
                child = new BE.Child();

                bl = BL.FactoryBL.GetBL();
                refreshData();

                this.DeleteChildComboBox.DisplayMemberPath = "ChildiID";
                this.DeleteChildComboBox.SelectedValuePath = "ChildiID";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 30
0
        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);
            }
        }