Ejemplo n.º 1
0
        public IList <ProductSizeInfo> GetList()
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select ProductItemId,ProductId,SizeAppend 
			            from ProductSize
					    order by LastUpdatedDate desc "                    );

            IList <ProductSizeInfo> list = new List <ProductSizeInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ProductSizeInfo model = new ProductSizeInfo();
                        model.ProductItemId = reader.GetGuid(0);
                        model.ProductId     = reader.GetGuid(1);
                        model.SizeAppend    = reader.GetString(2);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Ejemplo n.º 2
0
        public IList <ProductSizeInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select ProductItemId,ProductId,SizeAppend
                        from ProductSize ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }

            IList <ProductSizeInfo> list = new List <ProductSizeInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ProductSizeInfo model = new ProductSizeInfo();
                        model.ProductItemId = reader.GetGuid(0);
                        model.ProductId     = reader.GetGuid(1);
                        model.SizeAppend    = reader.GetString(2);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Ejemplo n.º 3
0
        public IList <ProductSizeInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb         = new StringBuilder(250);
            int           startIndex = (pageIndex - 1) * pageSize + 1;
            int           endIndex   = pageIndex * pageSize;

            sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber,
			           ProductItemId,ProductId,SizeAppend
					   from ProductSize "                    );
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

            IList <ProductSizeInfo> list = new List <ProductSizeInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ProductSizeInfo model = new ProductSizeInfo();
                        model.ProductItemId = reader.GetGuid(1);
                        model.ProductId     = reader.GetGuid(2);
                        model.SizeAppend    = reader.GetString(3);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Ejemplo n.º 4
0
        public ProductSizeInfo GetModel(object ProductItemId)
        {
            ProductSizeInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 ProductItemId,ProductId,SizeAppend 
			            from ProductSize
						where ProductItemId = @ProductItemId "                        );
            SqlParameter parm = new SqlParameter("@ProductItemId", SqlDbType.UniqueIdentifier);

            parm.Value = Guid.Parse(ProductItemId.ToString());

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model = new ProductSizeInfo();
                        model.ProductItemId = reader.GetGuid(0);
                        model.ProductId     = reader.GetGuid(1);
                        model.SizeAppend    = reader.GetString(2);
                    }
                }
            }

            return(model);
        }
Ejemplo n.º 5
0
        public int Update(ProductSizeInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"update ProductSize set SizeAppend = @SizeAppend 
			            where ProductItemId = @ProductItemId
					    "                    );

            SqlParameter[] parms =
            {
                new SqlParameter("@ProductItemId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@SizeAppend",    SqlDbType.VarChar, 300)
            };
            parms[0].Value = model.ProductItemId;
            parms[1].Value = model.SizeAppend;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), parms));
        }
Ejemplo n.º 6
0
        public int Insert(ProductSizeInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"insert into ProductSize (ProductId,ProductItemId,SizeAppend)
			            values
						(@ProductId,@ProductItemId,@SizeAppend)
			            "            );

            SqlParameter[] parms =
            {
                new SqlParameter("@ProductId",     SqlDbType.UniqueIdentifier),
                new SqlParameter("@ProductItemId", SqlDbType.UniqueIdentifier),
                new SqlParameter("@SizeAppend",    SqlDbType.VarChar, 300)
            };
            parms[0].Value = model.ProductId;
            parms[1].Value = model.ProductItemId;
            parms[2].Value = model.SizeAppend;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), parms));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(ProductSizeInfo model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(ProductSizeInfo model)
 {
     return(dal.Insert(model));
 }