示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.access_token model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update access_token set ");
            strSql.Append("access_token_str=@access_token_str,");
            strSql.Append("time=@time");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@access_token_str", SqlDbType.NChar,     50),
                new SqlParameter("@time",             SqlDbType.DateTime),
                new SqlParameter("@id",               SqlDbType.Int, 4)
            };
            parameters[0].Value = model.access_token_str;
            parameters[1].Value = model.time;
            parameters[2].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Maticsoft.Model.access_token model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into access_token(");
            strSql.Append("access_token_str,time)");
            strSql.Append(" values (");
            strSql.Append("@access_token_str,@time)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@access_token_str", SqlDbType.NChar, 50),
                new SqlParameter("@time",             SqlDbType.DateTime)
            };
            parameters[0].Value = model.access_token_str;
            parameters[1].Value = model.time;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.access_token DataRowToModel(DataRow row)
 {
     Maticsoft.Model.access_token model = new Maticsoft.Model.access_token();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["access_token_str"] != null)
         {
             model.access_token_str = row["access_token_str"].ToString();
         }
         if (row["time"] != null && row["time"].ToString() != "")
         {
             model.time = DateTime.Parse(row["time"].ToString());
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.access_token GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,access_token_str,time from [bds238528155_db].[dbo].[access_token] ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Maticsoft.Model.access_token model = new Maticsoft.Model.access_token();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }