Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Cms.Model.C_article_product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update C_article_product set ");
            strSql.Append("article_id=@article_id,");
            strSql.Append("price=@price,");
            strSql.Append("marketPrice=@marketPrice,");
            strSql.Append("integral=@integral,");
            strSql.Append("stock=@stock,");
            strSql.Append("is_integral=@is_integral,");
            strSql.Append("group_id=@group_id,");
            strSql.Append("s_version=@s_version");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@article_id",  SqlDbType.Int,   4),
                new SqlParameter("@price",       SqlDbType.Money, 8),
                new SqlParameter("@marketPrice", SqlDbType.Money, 8),
                new SqlParameter("@integral",    SqlDbType.Int,   4),
                new SqlParameter("@stock",       SqlDbType.Int,   4),
                new SqlParameter("@is_integral", SqlDbType.Int,   4),
                new SqlParameter("@group_id",    SqlDbType.Int,   4),
                new SqlParameter("@s_version",   SqlDbType.Int,   4),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.article_id;
            parameters[1].Value = model.price;
            parameters[2].Value = model.marketPrice;
            parameters[3].Value = model.integral;
            parameters[4].Value = model.stock;
            parameters[5].Value = model.is_integral;
            parameters[6].Value = model.group_id;
            parameters[7].Value = model.s_version;
            parameters[8].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Cms.Model.C_article_product DataRowToModel(DataRow row)
 {
     Cms.Model.C_article_product model = new Cms.Model.C_article_product();
     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["price"] != null && row["price"].ToString() != "")
         {
             model.price = decimal.Parse(row["price"].ToString());
         }
         if (row["marketPrice"] != null && row["marketPrice"].ToString() != "")
         {
             model.marketPrice = decimal.Parse(row["marketPrice"].ToString());
         }
         if (row["integral"] != null && row["integral"].ToString() != "")
         {
             model.integral = int.Parse(row["integral"].ToString());
         }
         if (row["stock"] != null && row["stock"].ToString() != "")
         {
             model.stock = int.Parse(row["stock"].ToString());
         }
         if (row["is_integral"] != null && row["is_integral"].ToString() != "")
         {
             model.is_integral = int.Parse(row["is_integral"].ToString());
         }
         if (row["group_id"] != null && row["group_id"].ToString() != "")
         {
             model.group_id = int.Parse(row["group_id"].ToString());
         }
         if (row["s_version"] != null && row["s_version"].ToString() != "")
         {
             model.s_version = int.Parse(row["s_version"].ToString());
         }
     }
     return(model);
 }
Example #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Cms.Model.C_article_product model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into C_article_product(");
            strSql.Append("article_id,price,marketPrice,integral,stock,is_integral,group_id,s_version)");
            strSql.Append(" values (");
            strSql.Append("@article_id,@price,@marketPrice,@integral,@stock,@is_integral,@group_id,@s_version)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@article_id",  SqlDbType.Int,   4),
                new SqlParameter("@price",       SqlDbType.Money, 8),
                new SqlParameter("@marketPrice", SqlDbType.Money, 8),
                new SqlParameter("@integral",    SqlDbType.Int,   4),
                new SqlParameter("@stock",       SqlDbType.Int,   4),
                new SqlParameter("@is_integral", SqlDbType.Int,   4),
                new SqlParameter("@group_id",    SqlDbType.Int,   4),
                new SqlParameter("@s_version",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.article_id;
            parameters[1].Value = model.price;
            parameters[2].Value = model.marketPrice;
            parameters[3].Value = model.integral;
            parameters[4].Value = model.stock;
            parameters[5].Value = model.is_integral;
            parameters[6].Value = model.group_id;
            parameters[7].Value = model.s_version;

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

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

            strSql.Append("select  top 1 id,article_id,price,marketPrice,integral,stock,is_integral,group_id,s_version from C_article_product ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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