public int AddTreeNode(int id)
        {
            //api/DimIndCate/AddTreeNode/0

            TbDimIndCate tmpNode = new TbDimIndCate();
            tmpNode.IParentID = id;//此处的id为parentid
            tmpNode.SCateName = "新增结点";
            if (id != 0)
            {
                //非一级节点,先读取父结点
                TbDimIndCate parentNode = DimIndCateDAO.GetByID(id);
                if (parentNode != null)
                {
                    tmpNode.ILevel = parentNode.ILevel + 1;
                }
                else
                {
                    return -1;
                    //Request.CreateResponse(HttpStatusCode.BadRequest, "出错了,找不到新建 DimIndCate 的 父结点:"+id+"!!");
                }
            }
            else
            {
                //一级节点
                tmpNode.ILevel = 1;
            }

            DimIndCateDAO.Insert(tmpNode);

            int tempId = tmpNode.Id;//新增节点的ID

            return tempId;
        }
Example #2
0
 /// <summary>
 /// 通过对象删除记录
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Del(TbDimIndCate item)
 {
     bool res = false;
     using (var connection = DataBase.GetOpenConnection())
     {
         res = connection.Delete<TbDimIndCate>(item);
     }
     return res;
 }
Example #3
0
 /// <summary>
 /// 通过ID删除记录
 /// </summary>
 /// <param name="id">需要删除的对象的ID</param>
 /// <returns></returns>
 public bool Del(int id)
 {
     bool res = false;
     TbDimIndCate item = new TbDimIndCate();
     using (var connection = DataBase.GetOpenConnection())
     {
         item = GetByID(id);
         res = connection.Delete<TbDimIndCate>(item);
     }
     return res;
 }
        /// <summary>
        /// PUT api/DimIndCate/Put/5,更新数据
        /// </summary>
        public int Put(int id, TbDimIndCate item)
        {
            if (id != item.Id)
            {
                //数据无效
                return -1;
            }

            try
            {
                DimIndCateDAO.Update(item);
            }
            catch (Exception ex)
            {
                //更新数据失败
                return -2;
            }

            //更新成功
            return 1;
        }
        /// <summary>
        /// POST api/DimIndCate/Post
        ///新增item数据,
        /// </summary>
        /// <param name="item">item,新增数据</param>
        public int Post(TbDimIndCate item)
        {
            DimIndCateDAO.Insert(item);

                return item.Id;//新增数据成功
        }
Example #6
0
 /// <summary>
 /// 插入一个对象
 /// </summary>
 /// <param name="item">需要插入的对象</param>
 /// <returns></returns>
 public int Insert(TbDimIndCate item)
 {
     int id = 0;
     using (var connection = DataBase.GetOpenConnection())
     {
         id = (int)connection.Insert<TbDimIndCate>(item);
     }
     return id;
 }