コード例 #1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Cms.Model.C_integral_rec DataRowToModel(DataRow row)
 {
     Cms.Model.C_integral_rec model = new Cms.Model.C_integral_rec();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["article_id"] != null && row["article_id"].ToString() != "")
         {
             model.article_id = int.Parse(row["article_id"].ToString());
         }
         if (row["user_id"] != null && row["user_id"].ToString() != "")
         {
             model.user_id = int.Parse(row["user_id"].ToString());
         }
         if (row["usercard"] != null)
         {
             model.usercard = row["usercard"].ToString();
         }
         if (row["openid"] != null)
         {
             model.openid = row["openid"].ToString();
         }
         if (row["numberid"] != null)
         {
             model.numberid = row["numberid"].ToString();
         }
         if (row["scorename"] != null)
         {
             model.scorename = row["scorename"].ToString();
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["wescore"] != null && row["wescore"].ToString() != "")
         {
             model.wescore = long.Parse(row["wescore"].ToString());
         }
         if (row["quantity"] != null && row["quantity"].ToString() != "")
         {
             model.quantity = int.Parse(row["quantity"].ToString());
         }
         if (row["type"] != null && row["type"].ToString() != "")
         {
             model.type = int.Parse(row["type"].ToString());
         }
         if (row["updateTime"] != null && row["updateTime"].ToString() != "")
         {
             model.updateTime = DateTime.Parse(row["updateTime"].ToString());
         }
     }
     return(model);
 }
コード例 #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Cms.Model.C_integral_rec model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update C_integral_rec set ");
            strSql.Append("article_id=@article_id,");
            strSql.Append("user_id=@user_id,");
            strSql.Append("usercard=@usercard,");
            strSql.Append("openid=@openid,");
            strSql.Append("numberid=@numberid,");
            strSql.Append("scorename=@scorename,");
            strSql.Append("title=@title,");
            strSql.Append("wescore=@wescore,");
            strSql.Append("quantity=@quantity,");
            strSql.Append("type=@type,");
            strSql.Append("updateTime=@updateTime");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@article_id", SqlDbType.Int,         4),
                new SqlParameter("@user_id",    SqlDbType.Int,         4),
                new SqlParameter("@usercard",   SqlDbType.VarChar,   150),
                new SqlParameter("@openid",     SqlDbType.VarChar,   350),
                new SqlParameter("@numberid",   SqlDbType.VarChar,   150),
                new SqlParameter("@scorename",  SqlDbType.VarChar,   150),
                new SqlParameter("@title",      SqlDbType.VarChar,   150),
                new SqlParameter("@wescore",    SqlDbType.BigInt,      8),
                new SqlParameter("@quantity",   SqlDbType.Int,         4),
                new SqlParameter("@type",       SqlDbType.Int,         4),
                new SqlParameter("@updateTime", SqlDbType.DateTime),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.article_id;
            parameters[1].Value  = model.user_id;
            parameters[2].Value  = model.usercard;
            parameters[3].Value  = model.openid;
            parameters[4].Value  = model.numberid;
            parameters[5].Value  = model.scorename;
            parameters[6].Value  = model.title;
            parameters[7].Value  = model.wescore;
            parameters[8].Value  = model.quantity;
            parameters[9].Value  = model.type;
            parameters[10].Value = model.updateTime;
            parameters[11].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Cms.Model.C_integral_rec model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into C_integral_rec(");
            strSql.Append("article_id,user_id,usercard,openid,numberid,scorename,title,wescore,quantity,type,updateTime)");
            strSql.Append(" values (");
            strSql.Append("@article_id,@user_id,@usercard,@openid,@numberid,@scorename,@title,@wescore,@quantity,@type,@updateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@article_id", SqlDbType.Int,       4),
                new SqlParameter("@user_id",    SqlDbType.Int,       4),
                new SqlParameter("@usercard",   SqlDbType.VarChar, 150),
                new SqlParameter("@openid",     SqlDbType.VarChar, 350),
                new SqlParameter("@numberid",   SqlDbType.VarChar, 150),
                new SqlParameter("@scorename",  SqlDbType.VarChar, 150),
                new SqlParameter("@title",      SqlDbType.VarChar, 150),
                new SqlParameter("@wescore",    SqlDbType.BigInt,    8),
                new SqlParameter("@quantity",   SqlDbType.Int,       4),
                new SqlParameter("@type",       SqlDbType.Int,       4),
                new SqlParameter("@updateTime", SqlDbType.DateTime)
            };
            parameters[0].Value  = model.article_id;
            parameters[1].Value  = model.user_id;
            parameters[2].Value  = model.usercard;
            parameters[3].Value  = model.openid;
            parameters[4].Value  = model.numberid;
            parameters[5].Value  = model.scorename;
            parameters[6].Value  = model.title;
            parameters[7].Value  = model.wescore;
            parameters[8].Value  = model.quantity;
            parameters[9].Value  = model.type;
            parameters[10].Value = model.updateTime;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Cms.Model.C_integral_rec GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,article_id,user_id,usercard,openid,numberid,scorename,title,wescore,quantity,type,updateTime from C_integral_rec ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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