Ejemplo n.º 1
0
        public void Add_Contract(BE.Contract contract)
        {
            var found_child = (from Child in ChildXml.Elements()
                               where Convert.ToUInt32(Child.Element("Id").Value) == contract.Child_ID
                               select new BE.Child
            {
                ID = Convert.ToInt32(Child.Element("Id").Value),
                Id_Mom = Convert.ToInt32(Child.Element("IdMom").Value),
                gender = (BE.Gender)Enum.Parse(typeof(BE.Gender), Child.Element("Gender").Value),
                s = (BE.With_Special_Needs)Enum.Parse(typeof(BE.With_Special_Needs), Child.Element("S").Value),
                Special_Needs = Child.Element("SpecialNeeds").Value,
                First_Name = Child.Element("FirstName").Value,
                Date = DateTime.Parse(Child.Element("Date").Value)
            }).FirstOrDefault();



            var found_mom   = DS.DataSource.mother_list.Find(who => who.ID == found_child.Id_Mom);
            var fount_nanny = DS.DataSource.nanny_list.Find(who => who.ID == contract.Nanny_ID);

            if (found_mom == null || fount_nanny == null)
            {
                throw new Exception("Mother or Nanny not exsit");
            }

            Coded_Contracts(contract);

            configXml.Element("Coded").Value = coded.ToString();
            configXml.Save(ConfigPath);

            DS.DataSource.contract_list.Add(contract.clone());
            List_To_Xml(DS.DataSource.contract_list, ContractPath);
        }
Ejemplo n.º 2
0
        public void Remove_chaild(int ID)
        {
            var found = from Child in ChildXml.Elements()
                        where Convert.ToUInt32(Child.Element("Id").Value) == ID
                        select Child;

            if (found == null)
            {
                throw new Exception("Child whit this ID not exist");
            }



            try
            {
                (from Child in ChildXml.Elements()
                 where Convert.ToUInt32(Child.Element("Id").Value) == ID
                 select Child).FirstOrDefault().Remove();
                ChildXml.Save(ChildPath);
            }
            catch
            {
                throw new Exception("Error in deleting Child");
            }
        }
Ejemplo n.º 3
0
 public List <BE.Child> Get_Child_List()
 {
     return((from Child in ChildXml.Elements()
             select new BE.Child
     {
         ID = Convert.ToInt32(Child.Element("Id").Value),
         Id_Mom = Convert.ToInt32(Child.Element("IdMom").Value),
         gender = (BE.Gender)Enum.Parse(typeof(BE.Gender), Child.Element("Gender").Value),
         s = (BE.With_Special_Needs)Enum.Parse(typeof(BE.With_Special_Needs), Child.Element("S").Value),
         Special_Needs = Child.Element("SpecialNeeds").Value,
         First_Name = Child.Element("FirstName").Value,
         Date = DateTime.Parse(Child.Element("Date").Value)
     }).ToList());
 }
Ejemplo n.º 4
0
 public List <Child> ChildList()
 {
     return((from Child in ChildXml.Elements()
             select new Child
     {
         id_child = Convert.ToInt32(Child.Element("id_child").Value),
         id_mother = Convert.ToInt32(Child.Element("id_mother").Value),
         Special_needs = Child.Element("Special_needs").Value,
         name = Child.Element("name").Value,
         date_of_birth = DateTime.Parse(Child.Element("date_of_birth").Value),
         Has_Nanny = Convert.ToBoolean(Child.Element("Has_Nanny").Value),
         special_needs = Convert.ToBoolean(Child.Element("special_needs").Value),
     }).ToList());
 }
Ejemplo n.º 5
0
        /// <summary>
        /// update a child
        /// </summary>
        /// <param name="child">childto update</param>
        public void update_detail_Child(Child child)
        {
            XElement updateChild = (from Child in ChildXml.Elements()
                                    where Convert.ToInt32(Child.Element("id_child").Value) == child.id_child
                                    select Child).FirstOrDefault();

            if (updateChild == null)
            {
                throw new Exception("...הילד אינו קיים במערכת");
            }

            updateChild.Element("id_child").Value      = child.id_child.ToString();
            updateChild.Element("id_mother").Value     = child.id_mother.ToString();
            updateChild.Element("Has_Nanny").Value     = child.Has_Nanny.ToString();
            updateChild.Element("special_needs").Value = child.special_needs.ToString();
            updateChild.Element("Special_needs").Value = child.Special_needs;
            updateChild.Element("name").Value          = child.name;
            updateChild.Element("date_of_birth").Value = child.date_of_birth.ToString();
            ChildXml.Save(ChildPath);
        }
Ejemplo n.º 6
0
        public void Update_Cdetails(BE.Child tmp)
        {
            XElement updateChild = (from Child in ChildXml.Elements()
                                    where Convert.ToUInt32(Child.Element("Id").Value) == tmp.ID
                                    select Child).FirstOrDefault();

            if (updateChild == null)
            {
                throw new Exception("Child not exsit in the List");
            }

            updateChild.Element("Id").Value           = tmp.ID.ToString();
            updateChild.Element("IdMom").Value        = tmp.Id_Mom.ToString();
            updateChild.Element("Gender").Value       = tmp.gender.ToString();
            updateChild.Element("S").Value            = tmp.s.ToString();
            updateChild.Element("SpecialNeeds").Value = tmp.Special_Needs;
            updateChild.Element("FirstName").Value    = tmp.First_Name;
            updateChild.Element("Date").Value         = tmp.Date.ToString();

            ChildXml.Save(ChildPath);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// add child
        /// </summary>
        /// <param name="child">child to add</param>
        public void addChild(Child child)
        {
            var found_child = (from Child in ChildXml.Elements()
                               where Convert.ToInt32(Child.Element("id_child").Value) == child.id_child
                               select Child).ToList();

            if (found_child.Count != 0)
            {
                throw new Exception("...הילד כבר קיים במערכת");
            }

            var clone = new XElement("Child", new XElement("id_child", child.id_child),
                                     new XElement("id_mother", child.id_mother),
                                     new XElement("name", child.name),
                                     new XElement("special_needs", child.special_needs),
                                     new XElement("Special_needs", child.Special_needs),
                                     new XElement("Has_Nanny", child.Has_Nanny),
                                     new XElement("date_of_birth", child.date_of_birth));

            ChildXml.Add(clone);
            ChildXml.Save(ChildPath);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// remove a child
        /// </summary>
        /// <param name="_id">remove by id</param>
        public void removeChild(int?_id)
        {
            var found = from Child in ChildXml.Elements()
                        where Convert.ToInt32(Child.Element("id_child").Value) == _id
                        select Child;

            if (found == null)
            {
                throw new Exception("...הילד אינו קיים במערכת");
            }

            try
            {
                (from Child in ChildXml.Elements()
                 where Convert.ToInt32(Child.Element("id_child").Value) == _id
                 select Child).FirstOrDefault().Remove();
                ChildXml.Save(ChildPath);
            }
            catch
            {
                throw new Exception("Error in deleting Child");
            }
        }
Ejemplo n.º 9
0
        public void Add_Chaild(BE.Child child)
        {
            var found_child = (from Child in ChildXml.Elements()
                               where Convert.ToUInt32(Child.Element("Id").Value) == child.ID
                               select Child).ToList();

            if (found_child.Count != 0)
            {
                throw new Exception("Child already exist with same id");
            }



            var clone = new XElement("Child", new XElement("Id", child.ID),
                                     new XElement("IdMom", child.Id_Mom),
                                     new XElement("Gender", child.gender),
                                     new XElement("S", child.s),
                                     new XElement("SpecialNeeds", child.Special_Needs),
                                     new XElement("FirstName", child.First_Name),
                                     new XElement("Date", child.Date));

            ChildXml.Add(clone);
            ChildXml.Save(ChildPath);
        }