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

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

            DimAreaDAO.Insert(tmpNode);

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

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

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

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

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