private string GetProductListJson(int ScenceID, int CategoryID, int FatherCategoryID, int BrandID, string ProductName, int OrderType)
        {
            bool      HasSubCateogry;
            DataTable dt = new CategoryConditionBll().GetCategoryProductList(ScenceID, CategoryID, FatherCategoryID, BrandID, ProductName, OrderType, out HasSubCateogry);

            StringBuilder result = new StringBuilder();
            StringWriter  sw     = new StringWriter(result);
            JsonWriter    writer = new JsonWriter(sw);

            writer.Formatting = Formatting.Indented;

            writer.WriteStartArray();

            foreach (DataRow row in dt.Rows)
            {
                writer.WriteStartObject();
                WriteJsonKeyValue(writer, "productid", row["productid"].ToString());
                WriteJsonKeyValue(writer, "productname", row["productname"].ToString());
                WriteJsonKeyValue(writer, "url", String.Format("/product-{0}.html", row["productid"]));
                WriteJsonKeyValue(writer, "image", ProductMainImageRule.GetMainImageUrl(row["smallimage"].ToString()));
                WriteJsonKeyValue(writer, "price", row["merchantprice"].ToString());
                WriteJsonKeyValue(writer, "categoryid", HasSubCateogry ? row["cateid"].ToString() : "0");
                writer.WriteEndObject();
            }

            writer.WriteEndArray();
            writer.Close();

            return(result.ToString());
        }
예제 #2
0
 private void ShowInfo(int productId)
 {
     if (productId != 0)
     {
         NoName.NetShop.Product.Model.GiftModel model = gbll.GetModel(productId);
         this.litProductId.Text   = model.ProductId.ToString();
         this.txtProductName.Text = model.ProductName;
         this.txtStock.Text       = model.Stock.ToString();
         this.txtKeywords.Text    = model.Keywords;
         this.txtBrief.Text       = model.Brief;
         this.litInsertTime.Text  = model.InsertTime.ToString("yyyy-MM-dd HH:mm:ss");
         this.litChangeTime.Text  = model.ChangeTime.ToString("yyyy-MM-dd HH:mm:ss");
         this.rblStatus.Items.FindByValue(model.Status.ToString()).Selected = true;
         this.txtScore.Text      = model.Score.ToString();
         this.txtDecription.Text = model.Decription;
         if (!String.IsNullOrEmpty(model.SmallImage))
         {
             this.imgProduct.Visible  = true;
             this.imgProduct.ImageUrl = ProductMainImageRule.GetMainImageUrl(model.SmallImage);
         }
         else
         {
             this.imgProduct.Visible = false;
         }
     }
 }
 private void ShowProductInfo(int productId)
 {
     NetShop.Product.BLL.ProductModelBll pbll   = new NoName.NetShop.Product.BLL.ProductModelBll();
     NetShop.Product.Model.ProductModel  pmodel = pbll.GetModel(productId);
     this.litProductName.Text    = pmodel.ProductName;
     this.litTopProductName.Text = pmodel.ProductName;
     this.litMerchantPrice.Text  = pmodel.MerchantPrice.ToString("F2");
     this.litTradePrice.Text     = pmodel.TradePrice.ToString("F2");
     this.litProductId.Text      = pmodel.ProductId.ToString();
     this.litStock.Text          = pmodel.Stock > 0 ? "库存充足" : "暂时缺货";
     this.imgProductL.ImageUrl   = ProductMainImageRule.GetMainImageUrl(pmodel.MediumImage);
     this.imgProductM.ImageUrl   = ProductMainImageRule.GetMainImageUrl(pmodel.LargeImage);
 }
예제 #4
0
        private static void AddProductMainImage(int ProductID, string CatePath, string ImageRelativeURL)
        {
            string   ImageFullURL = UrlPrefix + ImageRelativeURL;
            FileInfo ImageFile    = DownloadImage(ImageFullURL);

            if (!ImageFile.Directory.Exists)
            {
                Directory.CreateDirectory(ImageFile.Directory.FullName);
            }
            string[] MainImages;
            ProductMainImageRule.SaveProductMainImage(ProductID, CatePath, ImageFile, out MainImages);

            pbll.UpdateProductMainImage(ProductID, MainImages);
        }
        public XmlNode GetHotSaleProductList()
        {
            XmlNode HotSaleProductsNode = xdoc.CreateElement("hotsaleproduct");

            DataTable dt = dal.GetHotSaleProduct(new CategoryModelBll().GetCategoryPath(Parameter.CategoryID));

            foreach (DataRow row in dt.Rows)
            {
                XmlNode ProductNode = XmlUtility.AddNewNode(HotSaleProductsNode, "product", null);

                XmlUtility.AddNewNode(ProductNode, "productid", Convert.ToString(row["productid"]));
                XmlUtility.AddNewNode(ProductNode, "productname", Convert.ToString(row["productname"]));
                XmlUtility.AddNewNode(ProductNode, "productimage", ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["smallimage"])));
                XmlUtility.AddNewNode(ProductNode, "price", Convert.ToDecimal(Convert.ToDecimal(row["MerchantPrice"]) - Convert.ToDecimal(row["reduceprice"])).ToString("00"));
            }

            return(HotSaleProductsNode);
        }
        public XmlNode GetSalesProductList()
        {
            XmlNode SalesProductListNode = xdoc.CreateElement("salesproducts");

            DataTable dt = dal.GetBrandHotSaleProductList(Parameter.BrandID);

            foreach (DataRow row in dt.Rows)
            {
                XmlNode ProductNode = XmlUtility.AddNewNode(SalesProductListNode, "product", null);

                XmlUtility.AddNewNode(ProductNode, "productid", Convert.ToString(row["productid"]));
                XmlUtility.AddNewNode(ProductNode, "productname", Convert.ToString(row["productname"]));
                XmlUtility.AddNewNode(ProductNode, "productimage", ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["smallimage"])));
                XmlUtility.AddNewNode(ProductNode, "price", Convert.ToDecimal(Convert.ToDecimal(row["MerchantPrice"]) - Convert.ToDecimal(row["reduceprice"])).ToString("00"));
            }

            return(SalesProductListNode);
        }
        private void BindProductData()
        {
            ProductModel model = productBll.GetModel(ProductID);

            Literal_ProductID.Text = model.ProductId.ToString();

            Literal_ProductName1.Text = model.ProductName;
            Literal_ProductName2.Text = model.ProductName;

            Literal_MerchantPrice.Text = model.MerchantPrice.ToString("0.00");
            Literal_TradePrice.Text    = model.TradePrice.ToString("0.00");

            Image_LargeImage.ImageUrl = ProductMainImageRule.GetMainImageUrl(model.LargeImage);
            Image_SmallImage.ImageUrl = ProductMainImageRule.GetMainImageUrl(model.MediumImage);

            HyperLink_Buy.NavigateUrl      = "/sp/addtocart.aspx?pid=" + model.ProductId;
            HyperLink_Favorite.NavigateUrl = "";
        }
예제 #8
0
        private void BindSalesData()
        {
            DataSet ds = new SalesProductModelBll().GetListForShoppingProcedure();

            foreach (DataTable dt in ds.Tables)
            {
                foreach (DataRow row in dt.Rows)
                {
                    row["mediumimage"] = ProductMainImageRule.GetMainImageUrl(row["mediumimage"].ToString());
                }
            }

            Repeater_Reduce.DataSource = ds.Tables[0];
            Repeater_Reduce.DataBind();
            Repeater_Recommend.DataSource = ds.Tables[1];
            Repeater_Recommend.DataBind();
            Repeater_HotSale.DataSource = ds.Tables[2];
            Repeater_HotSale.DataBind();
        }
예제 #9
0
        private void BindData()
        {
            SuiteModel suite = new SuiteBll().GetModel(SuiteID);
            DataTable  dt    = bll.GetList(SuiteID);

            decimal sumPrice = 0, sumMarketPrice = 0;

            foreach (DataRow row in dt.Rows)
            {
                row["mediumimage"] = ProductMainImageRule.GetMainImageUrl(row["mediumimage"].ToString());
                sumPrice          += Convert.ToDecimal(row["price"]);
                sumMarketPrice    += Convert.ToDecimal(row["tradeprice"]);
            }

            Repeater_Products.DataSource = dt;
            Repeater_Products.DataBind();

            Literal_SuiteSum.Text  = suite.Price.ToString("0.00");
            Literal_SaveValue.Text = (sumMarketPrice - suite.Price).ToString("0.00");
        }
        private void BindData(int PageIndex)
        {
            int       RecordCount = 0;
            DataTable dt          = bll.GetProductList(AspNetPager.PageSize, PageIndex, SalesType, out RecordCount);

            dt.Columns.Add("price");

            foreach (DataRow row in dt.Rows)
            {
                row["smallimage"]  = ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["smallimage"]));
                row["mediumimage"] = ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["mediumimage"]));
                row["largeimage"]  = ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["largeimage"]));
                row["price"]       = Convert.ToString(Convert.ToDecimal(row["MerchantPrice"]) - Convert.ToDecimal(row["reduceprice"]));
            }

            Repeater_Product.DataSource = dt;
            Repeater_Product.DataBind();

            Literal_SalesName1.Text = SalesType.ToString();
            Literal_SalesName2.Text = SalesType.ToString();

            switch (SalesType)
            {
            case SalesProductType.热销商品:
                HyperLink1.CssClass = "button_blue2";
                break;

            case SalesProductType.直降特卖:
                HyperLink2.CssClass = "button_blue2";
                break;

            case SalesProductType.鼎鼎推荐:
                HyperLink3.CssClass = "button_blue2";
                break;

            default:
                HyperLink1.CssClass = "button_blue2";
                break;
            }
        }
        protected void btnSave_Click(object sender, EventArgs e)
        {
            SuiteBll sbll    = new SuiteBll();
            int      suiteId = String.IsNullOrEmpty(lblSuiteId.Text) ? 0 : int.Parse(lblSuiteId.Text);

            SuiteModel smodel = sbll.GetModel(suiteId);

            if (smodel == null)
            {
                smodel          = new SuiteModel();
                smodel.Price    = 0m;
                smodel.Score    = 0;
                smodel.SuiteId  = NoName.NetShop.Common.CommDataHelper.GetNewSerialNum(AppType.Product);
                smodel.ScenceId = ScenceId;
            }
            decimal price;

            if (!decimal.TryParse(lblPrice.Text, out price))
            {
                price = 0m;
            }
            smodel.ProductFee = price;
            smodel.DerateFee  = decimal.Parse(txtDerate.Text);
            smodel.Price      = smodel.ProductFee - smodel.DerateFee;
            smodel.Remark     = txtRemark.Text.Trim();
            smodel.SuiteName  = txtSuiteName.Text.Trim();
            if (!String.IsNullOrEmpty(fulImage.FileName))
            {
                string[] MainImages;
                if (ProductMainImageRule.SaveProductMainImage(smodel.SuiteId, "suite/", fulImage.PostedFile, out MainImages))
                {
                    smodel.SmallImage  = MainImages[0];
                    smodel.MediumImage = MainImages[1];
                    smodel.LargeImage  = MainImages[2];
                }
            }
            sbll.Save(smodel);
            this.ShowInfo(smodel.SuiteId);
        }
        public XmlNode GetProductList()
        {
            XmlNode ProductListNode = xdoc.CreateElement("productlist");

            int RecordCount = 0, PageCount = 0;

            DataTable dt;

            if (Parameter.Properities == null)
            {
                dt = dal.GetProductList(Parameter.CategoryID, Parameter.PageIndex, Parameter.BrandID, Parameter.PriceRange, Parameter.OrderValue, out RecordCount, out PageCount);
            }
            else
            {
                dt = dal.GetProductList(Parameter.CategoryID, Parameter.PageIndex, Parameter.BrandID, Parameter.PriceRange, Parameter.OrderValue, Parameter.Properities, out RecordCount, out PageCount);
            }

            //商品列表节点
            XmlNode ProductsNode = XmlUtility.AddNewNode(ProductListNode, "products", null);


            foreach (DataRow row in dt.Rows)
            {
                XmlNode ProductNode = XmlUtility.AddNewNode(ProductsNode, "product", null);

                XmlUtility.AddNewNode(ProductNode, "productid", Convert.ToString(row["productid"]));
                XmlUtility.AddNewNode(ProductNode, "productname", Convert.ToString(row["productname"]));
                XmlUtility.AddNewNode(ProductNode, "smallimage", ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["smallimage"])));
                XmlUtility.AddNewNode(ProductNode, "mediumimage", ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["mediumimage"])));
                XmlUtility.AddNewNode(ProductNode, "tradeprice", Convert.ToString(row["tradeprice"]));
                XmlUtility.AddNewNode(ProductNode, "merchantprice", Convert.ToString(row["merchantprice"]));
                XmlUtility.AddNewNode(ProductNode, "categoryid", Convert.ToString(row["cateid"]));
            }

            //分页信息节点
            XmlNode PageInfoNode = XmlUtility.AddNewNode(ProductListNode, "pageinfo", null);

            XmlUtility.SetAtrributeValue(PageInfoNode, "recordcount", RecordCount.ToString());
            XmlUtility.SetAtrributeValue(PageInfoNode, "pagecount", PageCount.ToString());
            XmlUtility.SetAtrributeValue(PageInfoNode, "currentpage", Parameter.PageIndex.ToString());


            if (PageCount <= 11) //小于最大显示数目,全部显示即可
            {
                for (int i = 1; i <= PageCount; i++)
                {
                    XmlNode PageNode = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                    XmlUtility.SetAtrributeValue(PageNode, "pageindex", i.ToString());
                    if (i == Parameter.PageIndex)
                    {
                        XmlUtility.SetAtrributeValue(PageNode, "isselected", "true");
                    }
                }
            }
            else                //大于最大显示数据,需要根据pageindex决定显示页码
            {
                XmlNode PageNodeS = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                XmlUtility.SetAtrributeValue(PageNodeS, "pageindex", 1.ToString());
                if (Parameter.PageIndex == 1)
                {
                    XmlUtility.SetAtrributeValue(PageNodeS, "isselected", "true");
                }

                if (Parameter.PageIndex < 10)
                {
                    for (int i = 2; i <= 10; i++)
                    {
                        XmlNode PageNode = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                        XmlUtility.SetAtrributeValue(PageNode, "pageindex", i.ToString());
                        if (i == Parameter.PageIndex)
                        {
                            XmlUtility.SetAtrributeValue(PageNode, "isselected", "true");
                        }
                    }
                    XmlNode PageNodeME = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                    XmlUtility.SetAtrributeValue(PageNodeME, "pageindex", "...");
                }
                else
                {
                    if (Parameter.PageIndex >= 10 && Parameter.PageIndex <= PageCount - 10)
                    {
                        XmlNode PageNodeMS = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                        XmlUtility.SetAtrributeValue(PageNodeMS, "pageindex", "...");

                        for (int i = Parameter.PageIndex - 5; i < Parameter.PageIndex + 5; i++)
                        {
                            XmlNode PageNode = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                            XmlUtility.SetAtrributeValue(PageNode, "pageindex", i.ToString());
                            if (i == Parameter.PageIndex)
                            {
                                XmlUtility.SetAtrributeValue(PageNode, "isselected", "true");
                            }
                        }

                        XmlNode PageNodeME = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                        XmlUtility.SetAtrributeValue(PageNodeME, "pageindex", "...");
                    }
                    else
                    {
                        if (Parameter.PageIndex > PageCount - 10)
                        {
                            XmlNode PageNodeMS = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                            XmlUtility.SetAtrributeValue(PageNodeMS, "pageindex", "...");

                            for (int i = PageCount - 10; i <= PageCount - 1; i++)
                            {
                                XmlNode PageNode = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                                XmlUtility.SetAtrributeValue(PageNode, "pageindex", i.ToString());
                                if (i == Parameter.PageIndex)
                                {
                                    XmlUtility.SetAtrributeValue(PageNode, "isselected", "true");
                                }
                            }
                        }
                    }
                }

                XmlNode PageNodeE = XmlUtility.AddNewNode(PageInfoNode, "page", "");
                XmlUtility.SetAtrributeValue(PageNodeE, "pageindex", PageCount.ToString());
                if (Parameter.PageIndex == PageCount)
                {
                    XmlUtility.SetAtrributeValue(PageNodeE, "isselected", "true");
                }
            }

            return(ProductListNode);
        }
예제 #13
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtProductName.Text == "")
            {
                strErr += "ProductName不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtStock.Text))
            {
                strErr += "Stock不是数字!\\n";
            }
            if (this.txtKeywords.Text == "")
            {
                strErr += "Keywords不能为空!\\n";
            }
            if (this.txtBrief.Text == "")
            {
                strErr += "Brief不能为空!\\n";
            }

            if (!PageValidate.IsNumber(txtScore.Text))
            {
                strErr += "Score不是数字!\\n";
            }
            if (this.txtDecription.Text == "")
            {
                strErr += "Decription不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int ProductId;

            if (!int.TryParse(this.litProductId.Text, out ProductId))
            {
                ProductId = 0;
            }
            string ProductName = this.txtProductName.Text;
            int    Stock       = int.Parse(this.txtStock.Text);
            string Keywords    = this.txtKeywords.Text;
            string Brief       = this.txtBrief.Text;
            int    Status      = int.Parse(this.rblStatus.SelectedValue);
            int    Score       = int.Parse(this.txtScore.Text);
            string Decription  = this.txtDecription.Text;

            NoName.NetShop.Product.Model.GiftModel model = new NoName.NetShop.Product.Model.GiftModel();
            model.ProductId = ProductId;
            if (ProductId == 0)
            {
                model.ProductId = NoName.NetShop.Common.CommDataHelper.GetNewSerialNum(AppType.Product);
            }
            model.ProductName = ProductName;
            model.Stock       = Stock;

            if (fulImage.HasFile)
            {
                string[] MainImages;
                if (ProductMainImageRule.SaveProductMainImage(model.ProductId, "gift/", fulImage.PostedFile, out MainImages))
                {
                    model.SmallImage  = MainImages[0];
                    model.MediumImage = MainImages[1];
                    model.LargeImage  = MainImages[2];
                }
            }
            model.Keywords   = Keywords;
            model.Brief      = Brief;
            model.Status     = Status;
            model.SortValue  = 0;
            model.Score      = Score;
            model.Decription = Decription;

            gbll.Save(model);
            Response.Redirect("GiftProductList.aspx");
        }
예제 #14
0
        private void BindData()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("code");
            dt.Columns.Add("status");

            foreach (int code in Enum.GetValues(typeof(ProductStatus)))
            {
                DataRow row = dt.NewRow();
                row["code"]   = code;
                row["status"] = Enum.GetName(typeof(ProductStatus), code);
                dt.Rows.Add(row);
            }

            ProductModel product = ProductMainImageRule.GetMainImageUrl(bll.GetModel(ProductID));

            drpStatus.DataSource     = dt;
            drpStatus.DataTextField  = "status";
            drpStatus.DataValueField = "code";
            drpStatus.DataBind();

            DropDown_Brand.DataSource     = new BrandCategoryRelationBll().GetCategoryBrandList(CategoryID == -1 ? product.CateId : CategoryID);
            DropDown_Brand.DataTextField  = "brandname";
            DropDown_Brand.DataValueField = "brandid";
            DropDown_Brand.DataBind();

            DropDown_Specification.DataSource     = AddSelectRow(new ProductSpecificationBll().GetList(SpecificationType.规格参数));
            DropDown_Specification.DataTextField  = "title";
            DropDown_Specification.DataValueField = "content";
            DropDown_Specification.DataBind();

            DropDown_Packing.DataSource     = AddSelectRow(new ProductSpecificationBll().GetList(SpecificationType.包装清单));
            DropDown_Packing.DataTextField  = "title";
            DropDown_Packing.DataValueField = "content";
            DropDown_Packing.DataBind();

            DropDown_Service.DataSource     = AddSelectRow(new ProductSpecificationBll().GetList(SpecificationType.售后服务));
            DropDown_Service.DataTextField  = "title";
            DropDown_Service.DataValueField = "content";
            DropDown_Service.DataBind();

            DropDown_OfferSet.DataSource     = AddSelectRow(new ProductSpecificationBll().GetList(SpecificationType.优惠套装));
            DropDown_OfferSet.DataTextField  = "title";
            DropDown_OfferSet.DataValueField = "content";
            DropDown_OfferSet.DataBind();

            if (product != null)
            {
                txtProductName.Text   = product.ProductName;
                txtProductCode.Text   = product.ProductCode;
                txtTradePrice.Text    = product.TradePrice.ToString();
                txtScore.Text         = product.Score.ToString();
                txtMerchantPrice.Text = product.MerchantPrice.ToString();
                txtReducePrice.Text   = product.ReducePrice.ToString();

                drpStatus.SelectedValue = product.Status.ToString();
                txtKeywords.Text        = product.Keywords;
                TextBox_Brief.Text      = product.Brief;
                imgProduct.ImageUrl     = product.SmallImage;

                TextBox_Specification.Text = product.Specifications;
                TextBox_Packing.Text       = product.PackingList;
                TextBox_Service.Text       = product.AfterSaleService;
                TextBox_OfferSet.Text      = product.OfferSet;

                txtWeight.Text = product.Weight.ToString("0.00");

                SetStockTip(product.StockTip);
                txtRelateProduct.Text = product.RelateProducts;

                ProductNewsModel newsModel = new ProductNewsBll().GetModel(product.ProductId);
                txtNewsID.Text = newsModel == null?"":newsModel.NewsID.ToString();

                if (CategoryID != -1)
                {
                    Label_CategoryNamePath.Text = new CategoryModelBll().GetCategoryNamePath(CategoryID);
                    txtCategoryID.Value         = CategoryID.ToString();
                }
                else
                {
                    txtCategoryID.Value         = product.CateId.ToString();
                    Label_CategoryNamePath.Text = new CategoryModelBll().GetCategoryNamePath(product.CateId);
                }
                DropDown_Brand.SelectedValue = product.BrandID.ToString();

                BindParameterData(product.CateId);
                BindSpecificationData(product.CateId);

                ReselectCategory.HRef = String.Format("CategorySelect.aspx?cid={0}&pid={1}", product.CateId, product.ProductId);
            }
        }
예제 #15
0
        private void SaveData()
        {
            string strErr = "";

            if (this.txtProductName.Text == "")
            {
                strErr += "产品名称不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtTradePrice.Text))
            {
                strErr += "市场价输入有误!\\n";
            }
            if (!PageValidate.IsDecimal(txtMerchantPrice.Text))
            {
                strErr += "销售价输入有误!\\n";
            }
            if (!PageValidate.IsDecimal(txtReducePrice.Text))
            {
                strErr += "直降价输入有误!\\n";
            }
            if (!PageValidate.IsNumber(txtScore.Text))
            {
                strErr += "商品积分输入有误!\\n";
            }
            if (!PageValidate.IsDecimal(txtWeight.Text))
            {
                strErr += "商品重量输入有误!\\n";
            }
            if (this.txtKeywords.Text == "")
            {
                strErr += "关键词不能为空!\\n";
            }
            if (this.TextBox_Brief.Text == "")
            {
                strErr += "商品简介不能为空!\\n";
            }
            if (!PageValidate.IsNumber(drpStatus.SelectedValue))
            {
                strErr += "商品状态选择有误!\\n";
            }
            int TempNewsID = 0;

            if (!String.IsNullOrEmpty(txtNewsID.Text) && !int.TryParse(txtNewsID.Text, out TempNewsID))
            {
                strErr += "关联资讯ID输入有误";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }

            ProductModel product = bll.GetModel(ProductID);

            product.ProductName   = txtProductName.Text;
            product.ProductCode   = txtProductCode.Text;
            product.CateId        = Convert.ToInt32(txtCategoryID.Value);
            product.TradePrice    = Convert.ToDecimal(txtTradePrice.Text);
            product.MerchantPrice = Convert.ToDecimal(txtMerchantPrice.Text);
            product.ReducePrice   = Convert.ToDecimal(txtReducePrice.Text);
            product.Status        = Convert.ToInt32(drpStatus.SelectedValue);
            product.Keywords      = txtKeywords.Text;
            product.Brief         = TextBox_Brief.Text;
            product.BrandID       = Convert.ToInt32(DropDown_Brand.SelectedValue);

            product.Specifications   = TextBox_Specification.Text;
            product.OfferSet         = TextBox_OfferSet.Text;
            product.PackingList      = TextBox_Packing.Text;
            product.AfterSaleService = TextBox_Service.Text;

            product.Weight = Convert.ToDecimal(txtWeight.Text);

            product.StockTip       = GetStockTip();
            product.RelateProducts = txtRelateProduct.Text.Replace(",", ",");

            product.ChangeTime = DateTime.Now;

            if (fulImage.FileName != String.Empty)
            {
                string[] MainImages;
                ProductMainImageRule.SaveProductMainImage(ProductID, product.CatePath, fulImage.PostedFile, out MainImages);
                product.SmallImage  = MainImages[0];
                product.MediumImage = MainImages[1];
                product.LargeImage  = MainImages[2];
            }

            //更新检索属性
            foreach (GridViewRow row in GridView_Parameter.Rows)
            {
                RadioButtonList ParameterValueList = ((RadioButtonList)row.Cells[0].FindControl("RadioList_ParameterValue"));
                if (!String.IsNullOrEmpty(ParameterValueList.SelectedValue))
                {
                    int              ParameterID    = Convert.ToInt32(((HiddenField)row.Cells[0].FindControl("Hidden_ParameterID")).Value);
                    string           ParameterValue = Convert.ToString(ParameterValueList.SelectedItem.Text);
                    ProductParaModel para           = new ProductParaModel();

                    para.ParaId    = ParameterID;
                    para.ProductId = product.ProductId;
                    para.ParaValue = ParameterValue;

                    pvBll.Save(para);
                }
            }
            //更新基本属性
            foreach (GridViewRow row in GridView_Specification.Rows)
            {
                RadioButtonList ParameterValueList = ((RadioButtonList)row.Cells[0].FindControl("RadioList_SpecificationValue"));
                if (!String.IsNullOrEmpty(ParameterValueList.SelectedValue))
                {
                    int              ParameterID    = Convert.ToInt32(((HiddenField)row.Cells[0].FindControl("Hidden_SpecificationID")).Value);
                    string           ParameterValue = Convert.ToString(ParameterValueList.SelectedItem.Text);
                    ProductParaModel para           = new ProductParaModel();

                    para.ParaId    = ParameterID;
                    para.ProductId = product.ProductId;
                    para.ParaValue = ParameterValue;

                    pvBll.Save(para);
                }
            }
            //添加商品多图
            foreach (string s in Request.Files.AllKeys)
            {
                if (s.StartsWith("multiImageUpload") && Request.Files[s].ContentLength > 0)
                {
                    string[] FileNames;
                    ProductMultiImageRule.SaveProductMultiImage(ProductID, product.CatePath, Request.Files[s], out FileNames);

                    if (FileNames != null)
                    {
                        ProductImageModel model = new ProductImageModel();
                        model.ImageId     = CommDataHelper.GetNewSerialNum("pd");
                        model.ProductId   = ProductID;
                        model.LargeImage  = FileNames[1];
                        model.OriginImage = FileNames[2];
                        model.SmallImage  = FileNames[0];
                        model.Title       = String.Empty;

                        new ProductImageModelBll().Add(model);
                    }
                }
            }

            //更新关联资讯ID
            new ProductNewsBll().Save(new ProductNewsModel()
            {
                ProdutID = product.ProductId, NewsID = TempNewsID
            });

            bll.Update(product);


            //重建索引
            try
            {
                DataIndexerProduct SearchIndexer = new DataIndexerProduct(Config.Searches["product"]);
                SearchIndexer.DeleteSingleIndex(product.ProductId);
                SearchIndexer.CreateSingleIndex(new Search.Entities.ProductModel()
                {
                    EntityIdentity = product.ProductId,
                    CategoryID     = product.CateId,
                    CategoryPath   = product.CatePath,
                    CreateTime     = product.InsertTime,
                    Description    = product.Brief,
                    Keywords       = product.Keywords,
                    Price          = product.MerchantPrice,
                    ProcessType    = NoName.NetShop.Search.Entities.EntityProcessType.insert,
                    ProductImage   = product.MediumImage,
                    ProductName    = product.ProductName,
                    UpdateTime     = product.ChangeTime
                });
            }
            catch { }
        }
예제 #16
0
        public XmlNode GetProductInfo()
        {
            XmlNode ProductInfoNode = xdoc.CreateElement("productinfo");

            //产品信息节点
            XmlNode ProductNode = XmlUtility.AddNewNode(ProductInfoNode, "product", null);

            DataTable dt = dal.GetProductInfo(Parameter.ProductID);

            if (dt == null || dt.Rows == null || dt.Rows.Count <= 0)
            {
                throw new PublishException("商品不存在");
            }
            if (Convert.ToInt32(dt.Rows[0]["status"]) != 1)
            {
                throw new PublishException("商品已下架");
            }

            DataRow row = dt.Rows[0];

            XmlUtility.AddNewNode(ProductNode, "productid", Convert.ToString(row["ProductId"]));
            XmlUtility.AddNewNode(ProductNode, "productname", Convert.ToString(row["ProductName"]));
            XmlUtility.AddNewNode(ProductNode, "productcode", Convert.ToString(row["ProductCode"]));
            XmlUtility.AddNewNode(ProductNode, "categorypath", Convert.ToString(row["CatePath"]));
            XmlUtility.AddNewNode(ProductNode, "categoryid", Convert.ToString(row["CateId"]));
            XmlUtility.AddNewNode(ProductNode, "tradeprice", Convert.ToString(row["TradePrice"]));
            XmlUtility.AddNewNode(ProductNode, "merchantprice", Convert.ToString(row["MerchantPrice"]));
            XmlUtility.AddNewNode(ProductNode, "actualprice", Convert.ToString(Convert.ToDecimal(row["MerchantPrice"]) - Convert.ToDecimal(row["reduceprice"])));
            XmlUtility.AddNewNode(ProductNode, "tradeprice", Convert.ToString(row["ReducePrice"]));
            XmlUtility.AddNewNode(ProductNode, "stock", Convert.ToString(row["Stock"]));
            XmlUtility.AddNewNode(ProductNode, "stocktip", Convert.ToString(row["stocktip"]));
            XmlUtility.AddNewNode(ProductNode, "smallimage", ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["SmallImage"])));
            XmlUtility.AddNewNode(ProductNode, "mediumimage", ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["MediumImage"])));
            XmlUtility.AddNewNode(ProductNode, "largeimage", ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["LargeImage"])));
            XmlUtility.AddNewNode(ProductNode, "keywords", Convert.ToString(row["Keywords"]));
            XmlUtility.AddCDataNode(ProductNode, "brief", Convert.ToString(row["Brief"]));
            XmlUtility.AddNewNode(ProductNode, "pageview", Convert.ToString(row["PageView"]));
            XmlUtility.AddNewNode(ProductNode, "inserttime", Convert.ToString(row["InsertTime"]));
            XmlUtility.AddNewNode(ProductNode, "changetime", Convert.ToString(row["ChangeTime"]));
            XmlUtility.AddNewNode(ProductNode, "score", Convert.ToString(row["Score"]));

            XmlUtility.AddCDataNode(ProductNode, "specifications", Convert.ToString(row["specifications"]));
            XmlUtility.AddCDataNode(ProductNode, "packinglist", Convert.ToString(row["packinglist"]));
            XmlUtility.AddCDataNode(ProductNode, "saleservice", Convert.ToString(row["aftersaleservice"]));
            XmlUtility.AddCDataNode(ProductNode, "offerset", Convert.ToString(row["offerset"]));

            XmlNode MultiImagesNode = XmlUtility.AddNewNode(ProductNode, "multiimages", null);
            XmlNode MainImageNode   = XmlUtility.AddNewNode(MultiImagesNode, "image", null);

            XmlUtility.AddNewNode(MainImageNode, "smallimage", ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["SmallImage"])));
            XmlUtility.AddNewNode(MainImageNode, "largeimage", ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["MediumImage"])));
            XmlUtility.AddNewNode(MainImageNode, "originimage", ProductMainImageRule.GetMainImageUrl(Convert.ToString(row["LargeImage"])));

            foreach (DataRow imageRow in dal.GetProductMultiImage(Parameter.ProductID).Rows)
            {
                XmlNode MultiImageNode = XmlUtility.AddNewNode(MultiImagesNode, "image", null);

                XmlUtility.AddNewNode(MultiImageNode, "smallimage", ProductMultiImageRule.GetMultiImageUrl(Convert.ToString(imageRow["smallimage"])));
                XmlUtility.AddNewNode(MultiImageNode, "largeimage", ProductMultiImageRule.GetMultiImageUrl(Convert.ToString(imageRow["largeimage"])));
                XmlUtility.AddNewNode(MultiImageNode, "originimage", ProductMultiImageRule.GetMultiImageUrl(Convert.ToString(imageRow["originimage"])));
            }


            //相关产品节点
            XmlNode   RelatedProductNode  = XmlUtility.AddNewNode(ProductInfoNode, "relatedproducts", null);
            DataTable RelatedProductTable = dal.GetRelatedProduct(dt.Rows[0]["relateproducts"].ToString());

            if (RelatedProductTable.Rows.Count > 0)
            {
                foreach (DataRow RelatedProductRow in RelatedProductTable.Rows)
                {
                    XmlNode RelatedProduct = XmlUtility.AddNewNode(RelatedProductNode, "product", null);

                    XmlUtility.AddNewNode(RelatedProduct, "productid", Convert.ToString(RelatedProductRow["productid"]));
                    XmlUtility.AddNewNode(RelatedProduct, "productimage", ProductMainImageRule.GetMainImageUrl(Convert.ToString(RelatedProductRow["smallimage"])));
                    XmlUtility.AddNewNode(RelatedProduct, "productname", Convert.ToString(RelatedProductRow["productname"]));
                    XmlUtility.AddNewNode(RelatedProduct, "productnameshort", Convert.ToString(RelatedProductRow["productname"]).Length > 10 ? Convert.ToString(RelatedProductRow["productname"]).Substring(0, 10) + ".." : Convert.ToString(RelatedProductRow["productname"]));
                    XmlUtility.AddNewNode(RelatedProduct, "price", Convert.ToDecimal(Convert.ToDecimal(RelatedProductRow["MerchantPrice"]) - Convert.ToDecimal(RelatedProductRow["reduceprice"])).ToString("00"));
                }
            }

            //关联资讯节点
            XmlNode   RelatedNewsNode  = XmlUtility.AddNewNode(ProductInfoNode, "relatednews", null);
            DataTable RelatedNewsTable = dal.GetRelatedNewsInfo(Parameter.ProductID);

            if (RelatedNewsTable != null && RelatedNewsTable.Rows.Count > 0)
            {
                XmlNode NewsNode = XmlUtility.AddNewNode(RelatedNewsNode, "news", null);

                XmlUtility.AddNewNode(NewsNode, "newsid", RelatedNewsTable.Rows[0]["newsid"].ToString());
                XmlUtility.AddNewNode(NewsNode, "newscontent", RelatedNewsTable.Rows[0]["newscontent"].ToString());
            }

            return(ProductInfoNode);
        }