Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.ProductPK model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProductPK set ");
            strSql.Append("productId=@productId,");
            strSql.Append("quantiyCount=@quantiyCount,");
            strSql.Append("brandCount=@brandCount,");
            strSql.Append("priceCount=@priceCount,");
            strSql.Append("configCount=@configCount,");
            strSql.Append("appearanceCount=@appearanceCount,");
            strSql.Append("otherCount=@otherCount");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@productId",       SqlDbType.Int, 4),
                new SqlParameter("@quantiyCount",    SqlDbType.Int, 4),
                new SqlParameter("@brandCount",      SqlDbType.Int, 4),
                new SqlParameter("@priceCount",      SqlDbType.Int, 4),
                new SqlParameter("@configCount",     SqlDbType.Int, 4),
                new SqlParameter("@appearanceCount", SqlDbType.Int, 4),
                new SqlParameter("@otherCount",      SqlDbType.Int, 4),
                new SqlParameter("@id",              SqlDbType.Int, 4)
            };
            parameters[0].Value = model.productId;
            parameters[1].Value = model.quantiyCount;
            parameters[2].Value = model.brandCount;
            parameters[3].Value = model.priceCount;
            parameters[4].Value = model.configCount;
            parameters[5].Value = model.appearanceCount;
            parameters[6].Value = model.otherCount;
            parameters[7].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.ProductPK DataRowToModel(DataRow row)
 {
     Model.ProductPK model = new Model.ProductPK();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["productId"] != null && row["productId"].ToString() != "")
         {
             model.productId = int.Parse(row["productId"].ToString());
         }
         if (row["quantiyCount"] != null && row["quantiyCount"].ToString() != "")
         {
             model.quantiyCount = int.Parse(row["quantiyCount"].ToString());
         }
         if (row["brandCount"] != null && row["brandCount"].ToString() != "")
         {
             model.brandCount = int.Parse(row["brandCount"].ToString());
         }
         if (row["priceCount"] != null && row["priceCount"].ToString() != "")
         {
             model.priceCount = int.Parse(row["priceCount"].ToString());
         }
         if (row["configCount"] != null && row["configCount"].ToString() != "")
         {
             model.configCount = int.Parse(row["configCount"].ToString());
         }
         if (row["appearanceCount"] != null && row["appearanceCount"].ToString() != "")
         {
             model.appearanceCount = int.Parse(row["appearanceCount"].ToString());
         }
         if (row["otherCount"] != null && row["otherCount"].ToString() != "")
         {
             model.otherCount = int.Parse(row["otherCount"].ToString());
         }
     }
     return(model);
 }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.ProductPK model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProductPK(");
            strSql.Append("productId,quantiyCount,brandCount,priceCount,configCount,appearanceCount,otherCount)");
            strSql.Append(" values (");
            strSql.Append("@productId,@quantiyCount,@brandCount,@priceCount,@configCount,@appearanceCount,@otherCount)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@productId",       SqlDbType.Int, 4),
                new SqlParameter("@quantiyCount",    SqlDbType.Int, 4),
                new SqlParameter("@brandCount",      SqlDbType.Int, 4),
                new SqlParameter("@priceCount",      SqlDbType.Int, 4),
                new SqlParameter("@configCount",     SqlDbType.Int, 4),
                new SqlParameter("@appearanceCount", SqlDbType.Int, 4),
                new SqlParameter("@otherCount",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.productId;
            parameters[1].Value = model.quantiyCount;
            parameters[2].Value = model.brandCount;
            parameters[3].Value = model.priceCount;
            parameters[4].Value = model.configCount;
            parameters[5].Value = model.appearanceCount;
            parameters[6].Value = model.otherCount;

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

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

            strSql.Append("select  top 1 id,productId,quantiyCount,brandCount,priceCount,configCount,appearanceCount,otherCount from ProductPK ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.ProductPK model = new Model.ProductPK();
            DataSet         ds    = DBHelperSQL.Query(strSql.ToString(), parameters);

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