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

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

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

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