示例#1
0
        public bool Update(Entity.LookUp editObj)
        {
            bool isok = false;

            try
            {
                using (var db = new TransEntities())
                {
                    Entity.LookUp update = db.LookUps.FirstOrDefault(f => f.LookupId == editObj.LookupId);
                    if (update != null)
                    {
                        update.ItemName  = editObj.ItemName;
                        update.ItemId    = editObj.ItemId;
                        update.GroupName = editObj.GroupName;
                        db.SaveChanges();
                    }
                    isok = true;
                }
            }
            catch (System.Exception)
            {
                throw;
            }
            return(isok);
        }
示例#2
0
        bool ICRUD <User> .Update(User editObj)
        {
            bool isok = false;

            try
            {
                using (var db = new TransEntities())
                {
                    User updateUser = db.Users.FirstOrDefault(f => f.UserId == editObj.UserId);
                    if (updateUser != null)
                    {
                        updateUser.FirstName = editObj.FirstName;
                        updateUser.LastName  = editObj.LastName;
                        updateUser.Email     = editObj.Email;
                        updateUser.IsEnable  = editObj.IsEnable;
                        db.SaveChanges();
                    }
                    isok = true;
                }
            }
            catch (System.Exception)
            {
                throw;
            }
            return(isok);
        }
示例#3
0
        public int Create(LookUp newObj)
        {
            int id = -1;

            try
            {
                using (var db = new TransEntities())
                {
                    db.LookUps.Add(newObj);
                    db.SaveChanges();
                    id = newObj.LookupId;
                }
            }
            catch (System.Exception)
            {
                throw;
            }
            return(id);
        }
示例#4
0
        int ICRUD <User> .Create(User newObj)
        {
            int userid = -1;

            try
            {
                using (var db = new TransEntities())
                {
                    db.Users.Add(newObj);
                    db.SaveChanges();
                    userid = newObj.UserId;
                }
            }
            catch (System.Exception)
            {
                throw;
            }
            return(userid);
        }
示例#5
0
        public bool Delete(int id)
        {
            bool isok = false;

            try
            {
                using (var db = new TransEntities())
                {
                    LookUp removeObj = db.LookUps.FirstOrDefault(f => f.LookupId == id);
                    if (removeObj != null)
                    {
                        removeObj.IsEnable = true;
                        db.SaveChanges();
                    }
                    isok = true;
                }
            }
            catch (System.Exception)
            {
                throw;
            }
            return(isok);
        }
示例#6
0
        bool ICRUD <User> .Delete(int id)
        {
            bool isok = false;

            try
            {
                using (var db = new TransEntities())
                {
                    User removeUesr = db.Users.FirstOrDefault(f => f.UserId == id);
                    if (removeUesr != null)
                    {
                        db.Users.Remove(removeUesr);
                        db.SaveChanges();
                    }
                    isok = true;
                }
            }
            catch (System.Exception)
            {
                throw;
            }
            return(isok);
        }