Beispiel #1
0
        public ProductItemInfo GetModel(object Id)
        {
            ProductItemInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 Id,ProductId,Named,PictureId,Sort,EnableStartTime,EnableEndTime,IsEnable,IsDisable 
			            from ProductItem
						where Id = @Id "                        );
            SqlParameter parm = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model                 = new ProductItemInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ProductId       = reader.GetGuid(1);
                        model.Named           = reader.GetString(2);
                        model.PictureId       = reader.GetGuid(3);
                        model.Sort            = reader.GetInt32(4);
                        model.EnableStartTime = reader.GetDateTime(5);
                        model.EnableEndTime   = reader.GetDateTime(6);
                        model.IsEnable        = reader.GetBoolean(7);
                        model.IsDisable       = reader.GetBoolean(8);
                    }
                }
            }

            return(model);
        }
Beispiel #2
0
        public IList <ProductItemInfo> GetList()
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,ProductId,Named,PictureId,Sort,EnableStartTime,EnableEndTime,IsEnable,IsDisable 
			            from ProductItem
					    order by LastUpdatedDate desc "                    );

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ProductItemInfo model = new ProductItemInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ProductId       = reader.GetGuid(1);
                        model.Named           = reader.GetString(2);
                        model.PictureId       = reader.GetGuid(3);
                        model.Sort            = reader.GetInt32(4);
                        model.EnableStartTime = reader.GetDateTime(5);
                        model.EnableEndTime   = reader.GetDateTime(6);
                        model.IsEnable        = reader.GetBoolean(7);
                        model.IsDisable       = reader.GetBoolean(8);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
        public void CreateGiftRules(ProductItemInfo productItem, BatchCreateGiftRuleInfo ruleInfo)
        {
            DataCommand dataCommand = DataCommandManager.GetDataCommand("SaleGift_CreateGiftRules");

            dataCommand.SetParameterValue("@PromotionSysNo", ruleInfo.PromotionSysNo);
            dataCommand.SetParameterValue("@ProductSysNo", productItem.ProductSysNo);
            dataCommand.SetParameterValue("@Count", productItem.HandselQty);
            dataCommand.SetParameterValue("@Priority", productItem.Priority);
            dataCommand.ExecuteNonQuery();
        }
Beispiel #4
0
        public IList <ProductItemInfo> GetList(int pageIndex, int pageSize, out int totalRecords, string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select count(*) from ProductItem ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            totalRecords = (int)SqlHelper.ExecuteScalar(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), cmdParms);

            if (totalRecords == 0)
            {
                return(new List <ProductItemInfo>());
            }

            sb.Clear();
            int startIndex = (pageIndex - 1) * pageSize + 1;
            int endIndex   = pageIndex * pageSize;

            sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber,
			          Id,ProductId,Named,PictureId,Sort,EnableStartTime,EnableEndTime,IsEnable,IsDisable
					  from ProductItem "                    );
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ProductItemInfo model = new ProductItemInfo();
                        model.Id              = reader.GetGuid(1);
                        model.ProductId       = reader.GetGuid(2);
                        model.Named           = reader.GetString(3);
                        model.PictureId       = reader.GetGuid(4);
                        model.Sort            = reader.GetInt32(5);
                        model.EnableStartTime = reader.GetDateTime(6);
                        model.EnableEndTime   = reader.GetDateTime(7);
                        model.IsEnable        = reader.GetBoolean(8);
                        model.IsDisable       = reader.GetBoolean(9);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Beispiel #5
0
        public ProductInfo GetProductDetails(string productId)
        {
            ProductInfo     info = new ProductInfo();
            ProductItemInfo itemInfo;

            SqlParameter[] sqlParam = new SqlParameter[] { new SqlParameter("@product_id", SqlDbType.NVarChar, 30) };
            sqlParam[0].Value = productId;
            using (SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.CONNECTION_STRING,
                                                                  CommandType.StoredProcedure, SQLHelper.GetSQLStatement("Product", "SP_GET_SINGLEPRODUCTDETAILS"), sqlParam))
            {
                if (reader.HasRows)
                {
                    reader.Read();
                    info.ProductId  = (string)reader["product_id"];
                    info.TotalPrice = Math.Round((decimal)reader["price"], 2);
                    if (reader["short_desc"] != DBNull.Value)
                    {
                        info.BriefDesc = (string)reader["short_desc"];
                    }
                    info.BriefDescWithQuantity = info.BriefDesc + "<br><br><I> Contains </I>";
                    info.ExtDesc       = (string)reader["long_desc"];
                    info.ProductStatus = (ProductStatus)(Convert.ToInt32(reader["status"]));
                    info.TotalPrice    = Math.Round(Convert.ToDecimal(reader["price"]), 2);
                    List <ProductItemInfo> productItems = new List <ProductItemInfo>();
                    do
                    {
                        itemInfo = new ProductItemInfo();
                        if (reader["agent_user_id"] != DBNull.Value)
                        {
                            itemInfo.AgentUserId  = (int)reader["agent_user_id"];
                            itemInfo.IsCustomSize = true;
                            info.ProductCatalog   = ProductCatalogType.Custom;
                        }
                        itemInfo.ProductTypeId = (int)reader["category_code"];
                        itemInfo.ProductType   = (string)reader["category_name"];
                        itemInfo.Quantity      = (int)reader["quantity"];
                        itemInfo.Size          = new List <string>();
                        if (reader["size"] != DBNull.Value)
                        {
                            itemInfo.Size.Add((string)reader["size"]);
                        }
                        AddToDesc(info, reader);
                        productItems.Add(itemInfo);
                    } while (reader.Read());
                    info.ProductItems = productItems;
                }
                else
                {
                    info = null;
                }
            }
            return(info);
        }
        public void CreateSaleRules(BatchCreateSaleGiftSaleRuleInfo info, ProductItemInfo entity)
        {
            DataCommand dataCommand = DataCommandManager.GetDataCommand("SaleGift_CreateSaleRules");

            dataCommand.SetParameterValue("@PromotionSysNo", info.PromotionSysNo);
            dataCommand.SetParameterValue("@Type", "I");
            dataCommand.SetParameterValue("@ComboType", "A");
            dataCommand.SetParameterValue("@ProductSysNo", entity.ProductSysNo);
            dataCommand.SetParameterValue("@C3SysNo", entity.C3SysNo);
            dataCommand.SetParameterValue("@BrandSysNo", entity.BrandSysNo);
            dataCommand.SetParameterValue("@BuyCount", entity.HandselQty == 0 ? null : entity.HandselQty);
            dataCommand.ExecuteNonQuery();
        }
Beispiel #7
0
        public IList <ProductItemInfo> GetListByProduct(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select pi.Id,pi.ProductId,pi.Named,pi.PictureId,pi.EnableStartTime,pi.EnableEndTime,pi.IsDisable,
                        ppi.FileExtension,ppi.FileDirectory,ppi.RandomFolder
                        from ProductItem pi
                        left join Picture_Product ppi on ppi.Id = pi.PictureId
                        ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ProductItemInfo model = new ProductItemInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ProductId       = reader.GetGuid(1);
                        model.Named           = reader.GetString(2);
                        model.PictureId       = reader.GetGuid(3);
                        model.EnableStartTime = reader.GetDateTime(4);
                        model.EnableEndTime   = reader.GetDateTime(5);
                        model.IsDisable       = reader.GetBoolean(6);

                        model.FileExtension = reader.IsDBNull(7) ? "" : reader.GetString(7);
                        model.FileDirectory = reader.IsDBNull(8) ? "" : reader.GetString(8);
                        model.RandomFolder  = reader.IsDBNull(9) ? "" : reader.GetString(9);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Beispiel #8
0
        public ProductItemInfo GetModelByJoin(object Id)
        {
            ProductItemInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 pi.Id,pi.ProductId,pi.Named,pi.PictureId,pi.EnableStartTime,pi.EnableEndTime,pi.IsDisable, 
                        pp.OriginalPicture,pp.BPicture,pp.MPicture,pp.SPicture
			            from ProductItem pi
                        left join ProductPicture pp on pp.Id = pi.PictureId
						where pi.Id = @Id 
                      ");
            SqlParameter parm = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model                 = new ProductItemInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ProductId       = reader.GetGuid(1);
                        model.Named           = reader.GetString(2);
                        model.PictureId       = reader.GetGuid(3);
                        model.EnableStartTime = reader.GetDateTime(4);
                        model.EnableEndTime   = reader.GetDateTime(5);
                        model.IsDisable       = reader.GetBoolean(6);

                        model.OriginalPicture = reader.IsDBNull(7) ? "" : reader.GetString(7);
                        model.BPicture        = reader.IsDBNull(8) ? "" : reader.GetString(8);
                        model.MPicture        = reader.IsDBNull(9) ? "" : reader.GetString(9);
                        model.SPicture        = reader.IsDBNull(10) ? "" : reader.GetString(10);
                    }
                }
            }

            return(model);
        }
Beispiel #9
0
    protected void ProductListDataList_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        ProductItemInfo itemInfo = (ProductItemInfo)e.Item.DataItem;

        if (itemInfo != null)
        {
            HyperLink productLink  = (HyperLink)e.Item.FindControl("ProductHyperLink");
            Literal   productText  = (Literal)e.Item.FindControl("ProductTypeLiteral");
            Image     productImage = (Image)e.Item.FindControl("ProductImage");
            productText.Text        = itemInfo.ProductType;
            productLink.NavigateUrl = "ProductList.aspx?type=" + itemInfo.ProductTypeId.ToString() + "&typeName=" + itemInfo.ProductType;
            switch (itemInfo.ProductType.ToLower())
            {
            case "powerkard":
                productImage.ImageUrl = "../Images/Powerkard_small.jpg";
                break;

            case "brochure":
                productImage.ImageUrl = "../Images/Brochure_small.jpg";
                break;

            case "generic product":
                productImage.ImageUrl = "../Images/kit_small.jpg";
                break;

            case "envelope":
                productImage.ImageUrl = "../Images/Envelope_small.jpg";
                break;

            case "house fliers":
                productImage.ImageUrl = "../Images/Housefliers_small.jpg";
                break;

            default:
                break;
            }
        }
    }
Beispiel #10
0
        public IList <ProductItemInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,ProductId,Named,PictureId,Sort,EnableStartTime,EnableEndTime,IsEnable,IsDisable
                        from ProductItem ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }

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

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ProductItemInfo model = new ProductItemInfo();
                        model.Id              = reader.GetGuid(0);
                        model.ProductId       = reader.GetGuid(1);
                        model.Named           = reader.GetString(2);
                        model.PictureId       = reader.GetGuid(3);
                        model.Sort            = reader.GetInt32(4);
                        model.EnableStartTime = reader.GetDateTime(5);
                        model.EnableEndTime   = reader.GetDateTime(6);
                        model.IsEnable        = reader.GetBoolean(7);
                        model.IsDisable       = reader.GetBoolean(8);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
Beispiel #11
0
        public int Update(ProductItemInfo model)
        {
            if (IsExist(model.ProductId, model.Named, model.Id))
            {
                return(110);
            }

            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"update ProductItem set ProductId = @ProductId,Named = @Named,PictureId = @PictureId,Sort = @Sort,EnableStartTime = @EnableStartTime,EnableEndTime = @EnableEndTime,IsEnable = @IsEnable,IsDisable = @IsDisable 
			            where Id = @Id
					    "                    );

            SqlParameter[] parms =
            {
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@ProductId",       SqlDbType.UniqueIdentifier),
                new SqlParameter("@Named",           SqlDbType.NVarChar,50),
                new SqlParameter("@PictureId",       SqlDbType.UniqueIdentifier),
                new SqlParameter("@Sort",            SqlDbType.Int),
                new SqlParameter("@EnableStartTime", SqlDbType.DateTime),
                new SqlParameter("@EnableEndTime",   SqlDbType.DateTime),
                new SqlParameter("@IsEnable",        SqlDbType.Bit),
                new SqlParameter("@IsDisable",       SqlDbType.Bit)
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.ProductId;
            parms[2].Value = model.Named;
            parms[3].Value = model.PictureId;
            parms[4].Value = model.Sort;
            parms[5].Value = model.EnableStartTime;
            parms[6].Value = model.EnableEndTime;
            parms[7].Value = model.IsEnable;
            parms[8].Value = model.IsDisable;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.HnztcShopDbConnString, CommandType.Text, sb.ToString(), parms));
        }
Beispiel #12
0
        public List <ProductItemInfo> GetProductItems()
        {
            List <ProductItemInfo> products = new List <ProductItemInfo>();
            ProductItemInfo        itemInfo;

            using (SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.CONNECTION_STRING,
                                                                  CommandType.StoredProcedure, SQLHelper.GetSQLStatement("Product", "SP_GET_PRODUCTCATEGORIES"), null))
            {
                while (reader.Read())
                {
                    itemInfo = new ProductItemInfo();
                    string avlSize = string.Empty;
                    if (reader["avl_size"] != DBNull.Value)
                    {
                        avlSize = (string)reader["avl_size"];
                    }
                    List <string> size = new List <string>();
                    if (avlSize != string.Empty)
                    {
                        char[] delim = new char[] { '|' };
                        if (avlSize != DBNull.Value.ToString() && avlSize != string.Empty)
                        {
                            foreach (string splitSize in avlSize.Split(delim))
                            {
                                size.Add(splitSize.Trim());
                            }
                        }
                    }
                    itemInfo.Size          = size;
                    itemInfo.ProductType   = (string)reader["category_name"];
                    itemInfo.ProductTypeId = (int)reader["category_code"];
                    products.Add(itemInfo);
                }
            }
            return(products);
        }
Beispiel #13
0
        public List <ProductItemInfo> GetInventoryTotalCount(int agentUserId)
        {
            List <ProductItemInfo> products = new List <ProductItemInfo>();
            ProductItemInfo        itemInfo;

            SqlParameter[] sqlParam = new SqlParameter[] { new SqlParameter("@agent_userid", SqlDbType.Int) };
            if (agentUserId != 0)
            {
                sqlParam[0].Value = agentUserId;
            }
            using (SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.CONNECTION_STRING,
                                                                  CommandType.StoredProcedure, SQLHelper.GetSQLStatement("Product", "SP_GET_INVENTORYCOUNT"), sqlParam))
            {
                while (reader.Read())
                {
                    itemInfo               = new ProductItemInfo();
                    itemInfo.ProductType   = (string)reader["category_name"];
                    itemInfo.ProductTypeId = (int)reader["category_code"];
                    itemInfo.Quantity      = (int)reader["Quantity"];
                    products.Add(itemInfo);
                }
            }
            return(products);
        }
Beispiel #14
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(ProductItemInfo model)
 {
     return(dal.Insert(model));
 }
Beispiel #15
0
        private void SaveProduct(HttpContext context)
        {
            string  Id             = context.Request.Form["ctl00$cphMain$hId"].Trim();
            string  sProductName   = context.Request.Form["ctl00$cphMain$txtProductName"].Trim();
            string  sSubTitle      = context.Request.Form["ctl00$cphMain$txtSubTitle"].Trim();
            decimal dOriginalPrice = 0;
            decimal dProductPrice  = 0;
            float   discount       = 0;

            decimal.TryParse(context.Request.Form["ctl00$cphMain$txtOriginalPrice"].Trim(), out dOriginalPrice);
            decimal.TryParse(context.Request.Form["ctl00$cphMain$txtProductPrice"].Trim(), out dProductPrice);
            float.TryParse(context.Request.Form["ctl00$cphMain$txtDiscount"].Trim(), out discount);
            string sDiscountDescri = context.Request.Form["ctl00$cphMain$txtDiscountDescri"].Trim();
            int    stockNum        = 0;

            int.TryParse(context.Request.Form["ctl00$cphMain$txtStockNum"].Trim(), out stockNum);
            string sProductPictureId = context.Request.Form["productPictureId"].Trim();
            Guid   productPictureId  = Guid.Empty;

            Guid.TryParse(sProductPictureId, out productPictureId);
            string sCategoryId = context.Request.Form["categoryId"].Trim();
            Guid   categoryId  = Guid.Empty;

            Guid.TryParse(sCategoryId, out categoryId);
            string sBrandId = context.Request.Form["brandId"].Trim();
            Guid   brandId  = Guid.Empty;

            Guid.TryParse(sBrandId, out brandId);
            Guid customMenuId = Guid.Empty;

            Guid.TryParse(context.Request.Form["customMenuId"].Trim(), out customMenuId);
            string sOtherPicture = context.Request.Form["otherPic"].Trim();
            string sSizeItem     = context.Request.Form["sizeItem"].Trim();
            string sSizePicture  = context.Request.Form["sizePicture"].Trim();
            string sPayOption    = "";

            string content = context.Request.Form["txtContent"].Trim();

            content = HttpUtility.HtmlDecode(content);
            Guid gId = Guid.Empty;

            if (Id != "")
            {
                Guid.TryParse(Id, out gId);
            }

            ProductInfo model = new ProductInfo();

            model.Id               = gId;
            model.UserId           = WebCommon.GetUserId();
            model.LastUpdatedDate  = DateTime.Now;
            model.ProductName      = sProductName;
            model.SubTitle         = sSubTitle;
            model.OriginalPrice    = dOriginalPrice;
            model.ProductPrice     = dProductPrice;
            model.Discount         = discount;
            model.DiscountDescri   = sDiscountDescri;
            model.ProductPictureId = productPictureId;
            model.StockNum         = stockNum;
            model.CustomMenuId     = customMenuId;

            Product         bll   = new Product();
            ProductItem     piBll = new ProductItem();
            CategoryProduct cpBll = new CategoryProduct();
            BrandProduct    bpBll = new BrandProduct();

            ProductItemInfo piModel = new ProductItemInfo();

            piModel.OtherPicture = sOtherPicture;
            piModel.SizeItem     = sSizeItem;
            piModel.SizePicture  = sSizePicture;
            piModel.PayOption    = sPayOption;
            piModel.CustomAttr   = string.Empty;
            piModel.Descr        = content;
            piModel.ProductId    = gId;

            int effect = -1;

            if (!gId.Equals(Guid.Empty))
            {
                bll.Update(model);
                piBll.Update(piModel);

                CategoryProductInfo cpModel = cpBll.GetModel(gId);
                BrandProductInfo    bpModel = bpBll.GetModel(gId);

                #region 所属分类

                if (!categoryId.Equals(Guid.Empty))
                {
                    if (cpModel == null)
                    {
                        cpModel            = new CategoryProductInfo();
                        cpModel.ProductId  = gId;
                        cpModel.CategoryId = categoryId;
                        cpBll.Insert(cpModel);
                    }
                    else
                    {
                        if (!cpModel.CategoryId.Equals(categoryId))
                        {
                            cpModel.CategoryId = categoryId;
                            cpBll.Update(cpModel);
                        }
                    }
                }
                else
                {
                    if (cpModel != null)
                    {
                        cpBll.Delete(gId, cpModel.CategoryId);
                    }
                }

                #endregion
                #region 所属品牌

                if (!brandId.Equals(Guid.Empty))
                {
                    if (bpModel == null)
                    {
                        bpModel           = new BrandProductInfo();
                        bpModel.ProductId = gId;
                        bpModel.BrandId   = brandId;
                        bpBll.Insert(bpModel);
                    }
                    else
                    {
                        if (!bpModel.BrandId.Equals(brandId))
                        {
                            bpModel.BrandId = brandId;
                            bpBll.Update(bpModel);
                        }
                    }
                }
                else
                {
                    if (bpModel != null)
                    {
                        bpBll.Delete(gId, bpModel.BrandId);
                    }
                }

                #endregion

                effect = 1;
            }
            else
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    Guid productId = bll.Insert(model);
                    piModel.ProductId = productId;
                    piBll.Insert(piModel);
                    if (!categoryId.Equals(Guid.Empty))
                    {
                        CategoryProductInfo cpModel = new CategoryProductInfo();
                        cpModel.CategoryId = categoryId;
                        cpModel.ProductId  = productId;
                        cpBll.Insert(cpModel);
                    }
                    if (!brandId.Equals(Guid.Empty))
                    {
                        BrandProductInfo bpModel = new BrandProductInfo();
                        bpModel.BrandId   = brandId;
                        bpModel.ProductId = productId;
                        bpBll.Insert(bpModel);
                    }

                    effect = 1;

                    scope.Complete();
                }
            }

            if (effect != 1)
            {
                context.Response.Write("{\"success\": false,\"message\": \"操作失败,请正确输入\"}");
                return;
            }

            context.Response.Write("{\"success\": true,\"message\": \"操作成功\"}");
        }
Beispiel #16
0
        public List <ProductInfo> GetProducts(int productTypeId, int agentUserId)
        {
            List <ProductInfo> products = new List <ProductInfo>();
            ProductInfo        itemInfo;

            SqlParameter[] sqlParam = new SqlParameter[] { new SqlParameter("@product_type", SqlDbType.Int),
                                                           new SqlParameter("@agent_userid", SqlDbType.Int) };
            if (productTypeId != Int32.MinValue)
            {
                sqlParam[0].Value = productTypeId;
            }
            if (agentUserId != Int32.MinValue)
            {
                sqlParam[1].Value = agentUserId;
            }
            using (SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.CONNECTION_STRING,
                                                                  CommandType.StoredProcedure, SQLHelper.GetSQLStatement("Product", "SP_GET_PRODUCTS"), sqlParam))
            {
                itemInfo = new ProductInfo();
                while (reader.Read())
                {
                    bool productExists = false;
                    foreach (ProductInfo product in products)
                    {
                        if (product.ProductId == (string)reader["product_id"])
                        {
                            productExists = true;
                            itemInfo      = product;
                            break;
                        }
                    }
                    if (!productExists)
                    {
                        itemInfo = new ProductInfo();
                    }
                    itemInfo.ProductId     = (string)reader["product_id"];
                    itemInfo.TotalPrice    = Math.Round((decimal)reader["price"], 2);
                    itemInfo.ProductStatus = (ProductStatus)((int)reader["status"]);
                    if (reader["short_desc"] != DBNull.Value)
                    {
                        itemInfo.BriefDesc = (string)reader["short_desc"];
                    }
                    if (itemInfo.BriefDescWithQuantity == null || itemInfo.BriefDescWithQuantity == string.Empty)
                    {
                        itemInfo.BriefDescWithQuantity = itemInfo.BriefDesc + "<br><br><I> Contains </I>";
                    }
                    if (reader["agent_user_id"] != DBNull.Value)
                    {
                        itemInfo.ProductCatalog = ProductCatalogType.Custom;
                    }
                    List <ProductItemInfo> productItemInfo = new List <ProductItemInfo>();
                    ProductItemInfo        productItem     = new ProductItemInfo();
                    productItem.Quantity = (int)reader["quantity"];
                    List <string> size = new List <string>();
                    if (reader["size"] != DBNull.Value)
                    {
                        size.Add((string)reader["size"]);
                    }
                    productItem.Size = size;
                    productItemInfo.Add(productItem);
                    itemInfo.ProductItems = productItemInfo;
                    if (agentUserId == Int32.MinValue || (agentUserId != Int32.MinValue && productTypeId != Int32.MinValue))
                    {
                        if (productTypeId == (int)ProductCategory.Generic_Product && (int)reader["Product_Count"] > 1)
                        {
                            AddToGenericProduct(products, itemInfo, reader);
                        }
                        else if ((int)reader["Product_Count"] == 1 && productTypeId == (int)reader["category_code"])
                        {
                            AddToDesc(itemInfo, reader);
                            products.Add(itemInfo);
                            itemInfo = new ProductInfo();
                        }
                    }
                    if (productTypeId == Int32.MinValue)
                    {
                        if ((int)reader["Product_Count"] > 1)
                        {
                            AddToGenericProduct(products, itemInfo, reader);
                        }
                        else if ((int)reader["Product_Count"] == 1)
                        {
                            AddToDesc(itemInfo, reader);
                            products.Add(itemInfo);
                            itemInfo = new ProductInfo();
                        }
                    }
                }
            }
            return(products);
        }
Beispiel #17
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(ProductItemInfo model)
 {
     return(dal.Update(model));
 }
Beispiel #18
0
        /// <summary>
        /// 获取楼层信息
        /// </summary>
        /// <param name="pageCode"></param>
        /// <returns></returns>
        public static List <FloorEntity> GetFloorInfo(PageCodeType pageType, int pageCode)
        {
            string cacheKey = CommonFacade.GenerateKey("GetFloorInfo", pageType.ToString(), pageCode.ToString());

            if (HttpRuntime.Cache[cacheKey] != null)
            {
                return((List <FloorEntity>)HttpRuntime.Cache[cacheKey]);
            }
            #region 获取信息

            //获取基本信息
            List <FloorEntity> floorEntitys = RecommendDA.GetFloorInfo(pageType, pageCode);

            //获取 Tab 信息
            foreach (FloorEntity entity in floorEntitys)
            {
                //获取 Tab 信息
                entity.FloorSections = RecommendDA.GetFloorSections(entity.FloorSysNo);
                List <FloorItemBase> originalItem = RecommendDA.GetFloorSectionItems(entity.FloorSysNo);

                entity.FloorSectionItems = new List <FloorItemBase>();
                //转换XML信息 to 实体
                foreach (FloorItemBase item in originalItem)
                {
                    FloorItemBase objItem = null;
                    switch (item.ItemType)
                    {
                    case FloorItemType.Product:

                        FloorItemProduct entityProduct = CreateObject <FloorItemProduct>(item.ItemValue);
                        ProductItemInfo  productInfo   = ProductFacade.GetProductShortInfoBySysNo(entityProduct.ProductSysNo);
                        if (productInfo != null && productInfo.Status == 1)
                        {
                            entityProduct.DefaultImage    = productInfo.DefaultImage;
                            entityProduct.RealPrice       = productInfo.RealPrice;
                            entityProduct.BasicPrice      = productInfo.MarketPrice;
                            entityProduct.ProductPrice    = productInfo.CurrentPrice;
                            entityProduct.PromotionTitle  = productInfo.PromotionTitle;
                            entityProduct.ProductSubTitle = productInfo.PromotionTitle;
                            entityProduct.CashRebate      = productInfo.CashRebate;
                            entityProduct.ProductTitle    = productInfo.ProductTitle;
                            objItem = entityProduct;
                        }
                        break;

                    case FloorItemType.Banner:
                        objItem = CreateObject <FloorItemBanner>(item.ItemValue);
                        break;

                    case FloorItemType.Brand:
                        objItem = CreateObject <FloorItemBrand>(item.ItemValue);
                        break;

                    case FloorItemType.TextLink:
                        objItem = CreateObject <FloorItemTextLink>(item.ItemValue);
                        break;
                    }

                    if (objItem != null)
                    {
                        objItem.CloneFloorItemBase(item);
                        entity.FloorSectionItems.Add(objItem);
                    }
                }
            }
            #endregion


            HttpRuntime.Cache.Insert(cacheKey, floorEntitys, null, DateTime.Now.AddSeconds(CacheTime.Long), Cache.NoSlidingExpiration);

            return(floorEntitys);
        }