예제 #1
0
 /// <summary>
 /// 通过对象删除记录
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Del(TbDimLib item)
 {
     bool res = false;
     using (var connection = DataBase.GetOpenConnection())
     {
         res = connection.Delete<TbDimLib>(item);
     }
     return res;
 }
예제 #2
0
 /// <summary>
 /// 通过ID删除记录
 /// </summary>
 /// <param name="id">需要删除的对象的ID</param>
 /// <returns></returns>
 public bool Del(int id)
 {
     bool res = false;
     TbDimLib item = new TbDimLib();
     using (var connection = DataBase.GetOpenConnection())
     {
         item = GetByID(id);
         res = connection.Delete<TbDimLib>(item);
     }
     return res;
 }
예제 #3
0
 /// <summary>
 /// 插入一个对象
 /// </summary>
 /// <param name="item">需要插入的对象</param>
 /// <returns></returns>
 public int Insert(TbDimLib item)
 {
     int id = 0;
     using (var connection = DataBase.GetOpenConnection())
     {
         id = (int)connection.Insert<TbDimLib>(item);
     }
     return id;
 }
예제 #4
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="id"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public int Update(int id, TbDimLib item)
        {
            if (id != item.Id)
            {
                //数据无效
                return -1;
            }

            try
            {
                //获取更新前的表名

                string tableName = DimLibDAO.GetByID(id).STableName;
                //如果两次的表名不相同
                if (tableName != item.STableName) {

                    DimLibDAO.UpdateTableName(tableName, item.STableName);

                }

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

            //更新成功
            return 1;
        }
예제 #5
0
        /// <summary>
        /// PUT api/DimLib/Put/5,更新数据
        /// </summary>
        public int Put(int id, TbDimLib item)
        {
            if (id != item.Id)
            {
                //数据无效
                return -1;
            }

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

            //更新成功
            return 1;
        }
예제 #6
0
        /// <summary>
        /// POST api/DimLib/Post
        ///新增item数据,
        /// </summary>
        /// <param name="item">item,新增数据</param>
        public int Post(TbDimLib item)
        {
            DimLibDAO.Insert(item);

            return item.Id;//新增数据成功
        }
예제 #7
0
        /// <summary>
        /// 添加数据
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public int Insert(TbDimLib item)
        {
            DimLibDAO.Insert(item);

            string tableName = item.STableName;
            //创建表
            DimLibDAO.CreateTable(tableName);
            return item.Id;//新增数据成功
        }