Esempio n. 1
0
 /// <summary>
 /// 通过对象删除记录
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public bool Del( TbSqlQuery item)
 {
     bool res = false;
     using (var connection = DataBase.GetOpenConnection())
     {
         res = connection.Delete< TbSqlQuery>(item);
     }
     return res;
 }
Esempio n. 2
0
 /// <summary>
 /// 通过ID删除记录
 /// </summary>
 /// <param name="id">需要删除的对象的ID</param>
 /// <returns></returns>
 public bool Del(int id)
 {
     bool res = false;
     TbSqlQuery item = new TbSqlQuery();
     using (var connection = DataBase.GetOpenConnection())
     {
         item = GetByID(id);
         res = connection.Delete<TbSqlQuery>(item);
     }
     return res;
 }
Esempio n. 3
0
 /// <summary>
 /// 插入一个对象
 /// </summary>
 /// <param name="item">需要插入的对象</param>
 /// <returns></returns>
 public int Insert(TbSqlQuery item)
 {
     int id = 0;
     using (var connection = DataBase.GetOpenConnection())
     {
         id = (int)connection.Insert<TbSqlQuery>(item);
     }
     return id;
 }
        /// <summary>
        /// 获取所有的SQL语句
        /// </summary>
        /// <returns></returns>
        public JsonResult GetSQLName()
        {
            List<TbSqlQuery> SQLList = new List<TbSqlQuery>();
            // TbSqlQuery tempQuery = new TbSqlQuery(); //定义一个表对象
            try
            {
                Database db = DBHelper.CreateDataBase("PlatformData");

                DbCommand cmd = db.GetSqlStringCommand("select ID, SSqlName  from tb_SqlQuery");

                using (DataSet myDs = db.ExecuteDataSet(cmd))
                {
                    DataTable tmpDT = myDs.Tables[0];
                    for (int i = 0; i < tmpDT.Rows.Count; i++)
                    {
                        TbSqlQuery tempQuery = new TbSqlQuery(); //定义一个表对象
                        string tempID = tmpDT.Rows[i][0].ToString();  //获取SQL语句的id
                        int id = int.Parse(tempID);
                        string tempSQLName = tmpDT.Rows[i][1].ToString(); //获取SQL语句的名字
                        tempQuery.Id = id;
                        tempQuery.SSqlName = tempSQLName;
                        SQLList.Add(tempQuery);

                    }

                }
                return Json(SQLList, JsonRequestBehavior.AllowGet);
            }
            catch (Exception e2)
            {

                return null;

            }
        }
Esempio n. 5
0
        /// <summary>
        /// PUT api/SqlQuery/Put/5,更新数据
        /// </summary>
        public int Put(int id, TbSqlQuery item)
        {
            if (id != item.Id)
            {
                //数据无效
                return -1;
            }

            try
            {

                item.DCreate = DateTime.Now;//更新时间
                item.ICreateID = SysUserInfo.GetUserID();

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

            //更新成功
            return 1;
        }
Esempio n. 6
0
        /// <summary>
        /// POST api/SqlQuery/Post
        ///新增item数据,
        /// </summary>
        /// <param name="item">item,新增数据</param>
        public int Post(TbSqlQuery item)
        {
            item.DCreate = DateTime.Now;
            item.ICreateID = SysUserInfo.GetUserID();

            SqlQueryDAO.Insert(item);

            return item.Id;//新增数据成功
        }