Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Cms.Model.C_exchange_cart model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update C_exchange_cart set ");
            strSql.Append("user_id=@user_id,");
            strSql.Append("article_id=@article_id,");
            strSql.Append("title=@title,");
            strSql.Append("price=@price,");
            strSql.Append("quantity=@quantity,");
            strSql.Append("integral=@integral,");
            strSql.Append("property_value=@property_value,");
            strSql.Append("note=@note,");
            strSql.Append("is_checked=@is_checked,");
            strSql.Append("updateTime=@updateTime");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",        SqlDbType.Int,         4),
                new SqlParameter("@article_id",     SqlDbType.Int,         4),
                new SqlParameter("@title",          SqlDbType.VarChar,   350),
                new SqlParameter("@price",          SqlDbType.Money,       8),
                new SqlParameter("@quantity",       SqlDbType.Int,         4),
                new SqlParameter("@integral",       SqlDbType.Int,         4),
                new SqlParameter("@property_value", SqlDbType.VarChar,   550),
                new SqlParameter("@note",           SqlDbType.VarChar,   350),
                new SqlParameter("@is_checked",     SqlDbType.Int,         4),
                new SqlParameter("@updateTime",     SqlDbType.DateTime),
                new SqlParameter("@id",             SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.user_id;
            parameters[1].Value  = model.article_id;
            parameters[2].Value  = model.title;
            parameters[3].Value  = model.price;
            parameters[4].Value  = model.quantity;
            parameters[5].Value  = model.integral;
            parameters[6].Value  = model.property_value;
            parameters[7].Value  = model.note;
            parameters[8].Value  = model.is_checked;
            parameters[9].Value  = model.updateTime;
            parameters[10].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Cms.Model.C_exchange_cart DataRowToModel(DataRow row)
 {
     Cms.Model.C_exchange_cart model = new Cms.Model.C_exchange_cart();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["user_id"] != null && row["user_id"].ToString() != "")
         {
             model.user_id = int.Parse(row["user_id"].ToString());
         }
         if (row["article_id"] != null && row["article_id"].ToString() != "")
         {
             model.article_id = int.Parse(row["article_id"].ToString());
         }
         if (row["title"] != null)
         {
             model.title = row["title"].ToString();
         }
         if (row["price"] != null && row["price"].ToString() != "")
         {
             model.price = decimal.Parse(row["price"].ToString());
         }
         if (row["quantity"] != null && row["quantity"].ToString() != "")
         {
             model.quantity = int.Parse(row["quantity"].ToString());
         }
         if (row["integral"] != null && row["integral"].ToString() != "")
         {
             model.integral = int.Parse(row["integral"].ToString());
         }
         if (row["property_value"] != null)
         {
             model.property_value = row["property_value"].ToString();
         }
         if (row["note"] != null)
         {
             model.note = row["note"].ToString();
         }
         if (row["is_checked"] != null && row["is_checked"].ToString() != "")
         {
             model.is_checked = int.Parse(row["is_checked"].ToString());
         }
         if (row["updateTime"] != null && row["updateTime"].ToString() != "")
         {
             model.updateTime = DateTime.Parse(row["updateTime"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Cms.Model.C_exchange_cart model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into C_exchange_cart(");
            strSql.Append("user_id,article_id,title,price,quantity,integral,property_value,note,is_checked,updateTime)");
            strSql.Append(" values (");
            strSql.Append("@user_id,@article_id,@title,@price,@quantity,@integral,@property_value,@note,@is_checked,@updateTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@user_id",        SqlDbType.Int,       4),
                new SqlParameter("@article_id",     SqlDbType.Int,       4),
                new SqlParameter("@title",          SqlDbType.VarChar, 350),
                new SqlParameter("@price",          SqlDbType.Money,     8),
                new SqlParameter("@quantity",       SqlDbType.Int,       4),
                new SqlParameter("@integral",       SqlDbType.Int,       4),
                new SqlParameter("@property_value", SqlDbType.VarChar, 550),
                new SqlParameter("@note",           SqlDbType.VarChar, 350),
                new SqlParameter("@is_checked",     SqlDbType.Int,       4),
                new SqlParameter("@updateTime",     SqlDbType.DateTime)
            };
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.article_id;
            parameters[2].Value = model.title;
            parameters[3].Value = model.price;
            parameters[4].Value = model.quantity;
            parameters[5].Value = model.integral;
            parameters[6].Value = model.property_value;
            parameters[7].Value = model.note;
            parameters[8].Value = model.is_checked;
            parameters[9].Value = model.updateTime;

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

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

            strSql.Append("select  top 1 id,user_id,article_id,title,price,quantity,integral,property_value,note,is_checked,updateTime from C_exchange_cart ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

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