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

            strSql.Append("update T_User_ShopCar set ");
            strSql.Append("UID=@UID,");
            strSql.Append("ProductID=@ProductID,");
            strSql.Append("ProductExtID=@ProductExtID,");
            strSql.Append("Qty=@Qty");
            strSql.Append(" where ShopCarID=@ShopCarID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UID",          SqlDbType.Int, 4),
                new SqlParameter("@ProductID",    SqlDbType.Int, 4),
                new SqlParameter("@ProductExtID", SqlDbType.Int, 4),
                new SqlParameter("@Qty",          SqlDbType.Int, 4),
                new SqlParameter("@ShopCarID",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UID;
            parameters[1].Value = model.ProductID;
            parameters[2].Value = model.ProductExtID;
            parameters[3].Value = model.Qty;
            parameters[4].Value = model.ShopCarID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebApi_Model.T_User_ShopCar DataRowToModel(DataRow row)
 {
     WebApi_Model.T_User_ShopCar model = new WebApi_Model.T_User_ShopCar();
     if (row != null)
     {
         if (row["ShopCarID"] != null && row["ShopCarID"].ToString() != "")
         {
             model.ShopCarID = int.Parse(row["ShopCarID"].ToString());
         }
         if (row["UID"] != null && row["UID"].ToString() != "")
         {
             model.UID = int.Parse(row["UID"].ToString());
         }
         if (row["ProductID"] != null && row["ProductID"].ToString() != "")
         {
             model.ProductID = int.Parse(row["ProductID"].ToString());
         }
         if (row["ProductExtID"] != null && row["ProductExtID"].ToString() != "")
         {
             model.ProductExtID = int.Parse(row["ProductExtID"].ToString());
         }
         if (row["Qty"] != null && row["Qty"].ToString() != "")
         {
             model.Qty = int.Parse(row["Qty"].ToString());
         }
     }
     return(model);
 }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebApi_Model.T_User_ShopCar model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_User_ShopCar(");
            strSql.Append("UID,ProductID,ProductExtID,Qty)");
            strSql.Append(" values (");
            strSql.Append("@UID,@ProductID,@ProductExtID,@Qty)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UID",          SqlDbType.Int, 4),
                new SqlParameter("@ProductID",    SqlDbType.Int, 4),
                new SqlParameter("@ProductExtID", SqlDbType.Int, 4),
                new SqlParameter("@Qty",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.UID;
            parameters[1].Value = model.ProductID;
            parameters[2].Value = model.ProductExtID;
            parameters[3].Value = model.Qty;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebApi_Model.T_User_ShopCar GetModel(int ShopCarID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ShopCarID,UID,ProductID,ProductExtID,Qty from T_User_ShopCar ");
            strSql.Append(" where ShopCarID=@ShopCarID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ShopCarID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ShopCarID;

            WebApi_Model.T_User_ShopCar model = new WebApi_Model.T_User_ShopCar();
            DataSet ds = DBHelper.Query(strSql.ToString(), parameters);

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