예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(XCWeiXin.Model.wx_book_cart model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_book_cart set ");
            strSql.Append("openid=@openid,");
            strSql.Append("wid=@wid,");
            strSql.Append("productId=@productId,");
            strSql.Append("skuId=@skuId,");
            strSql.Append("skuInfo=@skuInfo,");
            strSql.Append("totPrice=@totPrice,");
            strSql.Append("productNum=@productNum,");
            strSql.Append("createDate=@createDate");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@openid",     SqlDbType.VarChar,   100),
                new SqlParameter("@wid",        SqlDbType.Int,         4),
                new SqlParameter("@productId",  SqlDbType.Int,         4),
                new SqlParameter("@skuId",      SqlDbType.Int,         4),
                new SqlParameter("@skuInfo",    SqlDbType.VarChar,   500),
                new SqlParameter("@totPrice",   SqlDbType.Float,       8),
                new SqlParameter("@productNum", SqlDbType.Int,         4),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.openid;
            parameters[1].Value = model.wid;
            parameters[2].Value = model.productId;
            parameters[3].Value = model.skuId;
            parameters[4].Value = model.skuInfo;
            parameters[5].Value = model.totPrice;
            parameters[6].Value = model.productNum;
            parameters[7].Value = model.createDate;
            parameters[8].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public XCWeiXin.Model.wx_book_cart DataRowToModel(DataRow row)
 {
     XCWeiXin.Model.wx_book_cart model = new XCWeiXin.Model.wx_book_cart();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["openid"] != null)
         {
             model.openid = row["openid"].ToString();
         }
         if (row["wid"] != null && row["wid"].ToString() != "")
         {
             model.wid = int.Parse(row["wid"].ToString());
         }
         if (row["productId"] != null && row["productId"].ToString() != "")
         {
             model.productId = int.Parse(row["productId"].ToString());
         }
         if (row["skuId"] != null && row["skuId"].ToString() != "")
         {
             model.skuId = int.Parse(row["skuId"].ToString());
         }
         if (row["skuInfo"] != null)
         {
             model.skuInfo = row["skuInfo"].ToString();
         }
         if (row["totPrice"] != null && row["totPrice"].ToString() != "")
         {
             model.totPrice = decimal.Parse(row["totPrice"].ToString());
         }
         if (row["productNum"] != null && row["productNum"].ToString() != "")
         {
             model.productNum = int.Parse(row["productNum"].ToString());
         }
         if (row["createDate"] != null && row["createDate"].ToString() != "")
         {
             model.createDate = DateTime.Parse(row["createDate"].ToString());
         }
     }
     return(model);
 }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(XCWeiXin.Model.wx_book_cart model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_book_cart(");
            strSql.Append("openid,wid,productId,skuId,skuInfo,totPrice,productNum,createDate)");
            strSql.Append(" values (");
            strSql.Append("@openid,@wid,@productId,@skuId,@skuInfo,@totPrice,@productNum,@createDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@openid",     SqlDbType.VarChar, 100),
                new SqlParameter("@wid",        SqlDbType.Int,       4),
                new SqlParameter("@productId",  SqlDbType.Int,       4),
                new SqlParameter("@skuId",      SqlDbType.Int,       4),
                new SqlParameter("@skuInfo",    SqlDbType.VarChar, 500),
                new SqlParameter("@totPrice",   SqlDbType.Float,     8),
                new SqlParameter("@productNum", SqlDbType.Int,       4),
                new SqlParameter("@createDate", SqlDbType.DateTime)
            };
            parameters[0].Value = model.openid;
            parameters[1].Value = model.wid;
            parameters[2].Value = model.productId;
            parameters[3].Value = model.skuId;
            parameters[4].Value = model.skuInfo;
            parameters[5].Value = model.totPrice;
            parameters[6].Value = model.productNum;
            parameters[7].Value = model.createDate;

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

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

            strSql.Append("select  top 1 id,openid,wid,productId,skuId,skuInfo,totPrice,productNum,createDate from wx_book_cart ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            XCWeiXin.Model.wx_book_cart model = new XCWeiXin.Model.wx_book_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);
            }
        }