示例#1
0
        //public static void updateChildren(CChildren cc)
        //{
        //    if (selectchildrenById(cc.Id) != null)
        //    {
        //        removeChildren(cc.Id);
        //    }
        //    addChildren(cc);
        //}
        public static void updateChildren(CChildren cc)
        {
            Children c = Mapper.convertToChildren(selectchildrenById(cc.Id));

            using (NDBEntities db = new NDBEntities())
            {
                db.Children.Find(cc.Id).Address = cc.Address;
                db.Children.Find(cc.Id).Phone   = cc.Phone;
                db.SaveChanges();
            }
        }
示例#2
0
        private void button4_Click(object sender, EventArgs e)
        {
            CChildren c = new CChildren(txtIdCH.Text, txtNameCH.Text, txtAddressCH.Text, txtPhoneCH.Text, txtCodeParentCH.Text, int.Parse(txtCodeKinderCH.Text));

            BChildrenManager.addChildren(c);
            txtIdCH.Text         = "";
            txtNameCH.Text       = "";
            txtAddressCH.Text    = "";
            txtPhoneCH.Text      = "";
            txtCodeParentCH.Text = "";
            txtCodeKinderCH.Text = "";
        }
示例#3
0
        public static CChildren convertToCChildren(Children c)
        {
            CChildren cc = new CChildren();

            cc.Id               = c.IdChild;
            cc.FirstName        = c.FirstName;
            cc.LastName         = c.LastName;
            cc.Address          = c.Address;
            cc.Phone            = c.Phone;
            cc.ParentCode       = c.ParentCode;
            cc.KinderGardenCode = c.KinderGardenCode;
            cc.Active           = c.Active;
            cc.picture          = c.Picture;
            return(cc);
        }
示例#4
0
        //public static int addChildren(CChildren cc)
        //{
        //    Children c = Mapper.convertToChildren(cc);
        //    using (NDBEntities db = new NDBEntities())
        //    {
        //        try
        //        {
        //            db.Children.Add(c);
        //            db.SaveChanges();
        //            return 1;
        //        }
        //        catch (Exception e)
        //        {

        //            throw;
        //        }
        //    }
        //}

        public static int addChildren(CChildParent cc)
        {
            CUsers    u  = new CUsers(cc.ParentId, cc.ParentFirstName, cc.ParentLastName, cc.Address, cc.Phone, 1, cc.mailAddress, cc.Active);
            Users     u1 = Mapper.convertToUsers(u);
            CChildren c  = new CChildren(cc.ChildId, cc.ChildFirstName, cc.ChildLastName, cc.Address, cc.Phone, cc.ParentCode, cc.KinderGardenCode, cc.Active, cc.picture);
            Children  c1 = Mapper.convertToChildren(c);

            using (NDBEntities db = new NDBEntities())
            {
                try
                {
                    var idParent = (from x in db.Users
                                    where u1.IdUser == x.IdUser
                                    select x.IdUser).FirstOrDefault();
                    if (idParent == null)
                    {
                        db.Users.Add(u1);
                    }
                    Children child = (from x in db.Children
                                      where x.IdChild.Equals(cc.ChildId) && x.Active == 0
                                      select x).FirstOrDefault();
                    if (child != null)
                    {
                        Children ch = db.Children.First(d => d.IdChild.Equals(child.IdChild));
                        ch.Active = 1;
                    }
                    else
                    {
                        db.Children.Add(c1);
                        db.SaveChanges();
                    }

                    return(1);
                }
                catch (Exception e)
                {
                    throw;
                }
            }
        }
示例#5
0
 public static void updateChildren(CChildren cc)
 {
     DChildrenManager.updateChildren(cc);
 }
示例#6
0
 public void UpdateChildren([FromBody] CChildren children)
 {
     BChildrenManager.updateChildren(children);
 }