public CategoryModel GetSelectedRegionInfo()
        {
            string regionPath = String.Empty;
            string country    = Request.Form["category0"];
            string province   = Request.Form["category1"];
            string city       = Request.Form["category2"];
            string county     = Request.Form["category3"];

            int curRegionId = 0;

            if (curRegionId == 0 && !String.IsNullOrEmpty(county))
            {
                int.TryParse(county, out curRegionId);
            }
            if (curRegionId == 0 && !String.IsNullOrEmpty(city))
            {
                int.TryParse(city, out curRegionId);
            }
            if (curRegionId == 0 && !String.IsNullOrEmpty(province))
            {
                int.TryParse(province, out curRegionId);
            }
            if (curRegionId == 0 && !String.IsNullOrEmpty(country))
            {
                int.TryParse(country, out curRegionId);
            }

            CategoryModel result = null;

            if (curRegionId > 0)
            {
                result = new CategoryModelBll().GetModel(curRegionId);
            }
            return(result);
        }
        private void DeleteRelation(int CateID, int BrandID)
        {
            bll.Delete(BrandID, CateID);

            DataTable sonCates = new CategoryModelBll().GetList(" parentid=" + CateID).Tables[0];

            if (sonCates.Rows.Count > 0)
            {
                foreach (DataRow row in sonCates.Rows)
                {
                    DeleteRelation(Convert.ToInt32(row["cateid"]), BrandID);
                }
            }
        }
        //大类>>小类,商品点击量|购买量    批量操作上下架
        private void BindData(int PageIndex)
        {
            if (SearchCondition != ConstructSearchCondition())
            {
                SearchCondition = ConstructSearchCondition();
            }

            //Response.Write(SearchCondition);
            int       RecordCount = 0;
            DataTable dt          = bll.GetList(PageIndex, AspNetPager.PageSize, SearchCondition, out RecordCount).Tables[0];

            //Response.Write("<br/>recordcount:"+RecordCount);

            dt.Columns.Add("producturl");
            dt.Columns.Add("secondarycategoryid");
            dt.Columns.Add("secondarycategoryname");
            dt.Columns.Add("endcategoryid");
            dt.Columns.Add("endcategoryname");
            dt.Columns.Add("ishotsale");
            dt.Columns.Add("isreduce");
            dt.Columns.Add("isrecommend");

            foreach (DataRow row in dt.Rows)
            {
                string CategoryNamePath = new CategoryModelBll().GetCategoryNamePath(Convert.ToInt32(row["cateid"]));
                string CategoryIDPath   = new CategoryModelBll().GetCategoryPath(Convert.ToInt32(row["cateid"]));
                row["producturl"] = GetProductUrl(Convert.ToInt32(row["productid"]));

                row["secondarycategoryid"] = CategoryIDPath.Split('/')[1];
                row["endcategoryid"]       = CategoryIDPath.Split('/')[CategoryIDPath.Split('/').Length - 2];

                row["secondarycategoryname"] = CategoryNamePath.Split('/')[1];
                row["endcategoryname"]       = CategoryNamePath.Split('/')[CategoryNamePath.Split('/').Length - 2];

                SalesProductModelBll salesBll = new SalesProductModelBll();
                row["ishotsale"]   = salesBll.Exists(Convert.ToInt32(row["productid"]), SalesProductType.热销商品);
                row["isreduce"]    = salesBll.Exists(Convert.ToInt32(row["productid"]), SalesProductType.直降特卖);
                row["isrecommend"] = salesBll.Exists(Convert.ToInt32(row["productid"]), SalesProductType.鼎鼎推荐);
            }

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

            AspNetPager.RecordCount      = RecordCount;
            AspNetPager.CurrentPageIndex = PageIndex;

            //InitializeSerchCondition();
        }
        public XmlNode GetCategoryList()
        {
            XmlNode CategoryListNode = xdoc.CreateElement("categorylist");

            int AncestorID = new CategoryModelBll().GetAncestorID(Parameter.CategoryID);

            XmlNode       AncestorInfoNode = XmlUtility.AddNewNode(CategoryListNode, "ancestorinfo", null);
            CategoryModel AncestorCategory = new CategoryModelBll().GetModel(AncestorID);

            XmlUtility.AddNewNode(AncestorInfoNode, "categoryid", Convert.ToString(AncestorID));
            XmlUtility.AddNewNode(AncestorInfoNode, "categoryname", AncestorCategory.CateName);

            XmlNode CategoriesNode = XmlUtility.AddNewNode(CategoryListNode, "categories", null);

            DataTable RootCategories = dal.GetCategorySonList(AncestorID);

            foreach (DataRow row in RootCategories.Rows)
            {
                XmlNode FatherNode = XmlUtility.AddNewNode(CategoriesNode, "fathercategory", null);

                XmlUtility.SetAtrributeValue(FatherNode, "categoryid", Convert.ToString(row["cateid"]));
                XmlUtility.SetAtrributeValue(FatherNode, "categoryname", Convert.ToString(row["catename"]));

                int CategoryID = Convert.ToInt32(row["cateid"]);

                DataTable SonCategories = dal.GetCategorySonList(CategoryID);

                if (SonCategories.Rows.Count > 0)
                {
                    foreach (DataRow srow in SonCategories.Rows)
                    {
                        XmlNode SonNode = XmlUtility.AddNewNode(FatherNode, "soncategory", null);

                        XmlUtility.SetAtrributeValue(SonNode, "categoryid", Convert.ToString(srow["cateid"]));
                        XmlUtility.SetAtrributeValue(SonNode, "categoryname", Convert.ToString(srow["catename"]));
                    }
                }
            }

            return(CategoryListNode);
        }
Beispiel #5
0
        private void ShowInfo(int scenceId, int cateId)
        {
            SolutionCategoryBll   scbll   = new SolutionCategoryBll();
            SolutionCategoryModel scmodel = scbll.GetModel(scenceId, cateId);
            CategoryModelBll      cbll    = new CategoryModelBll();
            CategoryModel         cmodel  = cbll.GetModel(cateId);

            if (cmodel == null)
            {
                throw new NoName.NetShop.Common.ShopException("分类不存在", true);
            }

            InitConditionItems(cateId);

            if (scmodel != null)
            {
                lblCateId.Text    = scmodel.CateId.ToString();
                lblSenceId.Text   = scmodel.SenceId.ToString();
                chkIsShow.Checked = scmodel.IsShow;
                txtRemark.Text    = scmodel.Remark;
                txtPosition.Text  = scmodel.Position;

                if (!String.IsNullOrEmpty(scmodel.CateImage))
                {
                    this.imgCate.Visible  = true;
                    this.imgCate.ImageUrl = Common.CommonImageUpload.GetCommonImageFullUrl(scmodel.CateImage);
                }
                else
                {
                    this.imgCate.Visible = false;
                }
                PresetConditionItems(scenceId, cateId);
            }
            else
            {
                lblCateId.Text  = cmodel.CateId.ToString();
                lblSenceId.Text = scenceId.ToString();
                txtRemark.Text  = cmodel.CateName;
            }
        }
Beispiel #6
0
        private void InitConditionItems(int cateId)
        {
            BrandCategoryRelationBll bcrbll = new BrandCategoryRelationBll();

            this.cblBrands.DataSource     = bcrbll.GetCategoryBrandList(cateId);
            this.cblBrands.DataTextField  = "BrandName";
            this.cblBrands.DataValueField = "BrandId";
            this.cblBrands.DataBind();

            NoName.NetShop.Product.BLL.CategoryModelBll cbll = new CategoryModelBll();
            this.cblSubCate.DataSource     = cbll.GetSubCategory(cateId);
            this.cblSubCate.DataTextField  = "CateName";
            this.cblSubCate.DataValueField = "CateId";
            this.cblSubCate.DataBind();


            CategoryParaModelBll     cpbll = new CategoryParaModelBll();
            List <CategoryParaModel> plist = cpbll.GetModelList("status=1 and paratype=1 and cateid=" + cateId);

            rpItems.DataSource = plist;
            rpItems.DataBind();
        }
        private DataTable GetSubCategory(int ParentID)
        {
            CategoryModelBll bll = new CategoryModelBll();

            return(bll.GetList("parentid = " + ParentID).Tables[0]);
        }
        private string ConstructSearchCondition()
        {
            string condition = String.Empty;

            //构建搜索条件
            if (CheckBox1.Checked || InitialCategoryID != -1)
            {
                #region s1
                bool   IsEnd;
                int    SelectedCategoryID = 0;
                string s1 = String.Empty;

                if (IsPostBack)
                {
                    SelectedCategoryID = CategorySelect1.GetSelectedRegionInfo().CateId;
                    if (SelectedCategoryID == -1)
                    {
                        MessageBox.Show(this, "请至少选择一个分类");
                        return(String.Empty);
                    }
                }
                else
                {
                    SelectedCategoryID = InitialCategoryID;
                }

                if (SelectedCategoryID != -1)
                {
                    string CategoryPath = new CategoryModelBll().GetModel(SelectedCategoryID).CatePath;
                    s1         = " and catepath like '" + CategoryPath + "%'";
                    condition += s1;
                    //SearchCondition.Add("s1",s1);

                    if (!CheckBox1.Checked)
                    {
                        CheckBox1.Checked = true;
                    }
                    CategoryPath = CategoryPath.Substring(0, CategoryPath.LastIndexOf("/"));
                    CategorySelect1.PresetRegionInfo(CategoryPath);
                }
                #endregion
            }

            if (CheckBox2.Checked)
            {
                #region s2
                string s2 = String.Empty;
                if (!String.IsNullOrEmpty(TextBox1.Text) && PageValidate.IsNumber(TextBox1.Text))
                {
                    s2         = " and productid=" + TextBox1.Text;
                    condition += s2;
                    //SearchCondition.Add("s2",s2);
                }
                else
                {
                    MessageBox.Show(this, "请输入正确的产品ID");
                    return(String.Empty);
                }
                #endregion
            }
            if (CheckBox3.Checked)
            {
                #region s3
                string s3     = String.Empty;
                int    Status = Convert.ToInt32(drpStatus.SelectedValue);
                s3         = " and status='" + Status + "'";
                condition += s3;
                #endregion
            }
            if (CheckBox4.Checked)
            {
                if (!String.IsNullOrEmpty(TextBox2.Text))
                {
                    condition += " and productname like '%" + TextBox2.Text + "%'";
                }
                else
                {
                    MessageBox.Show(this, "请输入产品名称");
                    return(String.Empty);
                }
            }
            if (CheckBox5.Checked)
            {
                if (!String.IsNullOrEmpty(TextBox3.Text) && !String.IsNullOrEmpty(TextBox4.Text) && PageValidate.IsDate(TextBox3.Text) && PageValidate.IsDate(TextBox4.Text))
                {
                    DateTime start = Convert.ToDateTime(TextBox3.Text);
                    DateTime end   = Convert.ToDateTime(TextBox4.Text);
                    condition += String.Format(" and InsertTime >= '{0}' and InsertTime <= '{1}'", start, end);
                }
                else
                {
                    MessageBox.Show(this, "请输入正确的日期");
                    return(String.Empty);
                }
            }
            if (CheckBox6.Checked)
            {
                if (!String.IsNullOrEmpty(TextBoxSearch_ScoreStart.Text) && !String.IsNullOrEmpty(TextBoxSearch_ScoreEnd.Text))
                {
                    condition += String.Format(" and score between {0} and {1}", TextBoxSearch_ScoreStart.Text, TextBoxSearch_ScoreEnd.Text);
                }
                else
                {
                    MessageBox.Show(this, "请输入正确的积分");
                    return(String.Empty);
                }
            }
            if (CheckBox7.Checked)
            {
                int StockStatus = Convert.ToInt32(DropDownList_Stock.SelectedValue);
                if (StockStatus == 0)
                {
                    condition += " and stock=0";
                }
                else
                {
                    condition += " and stock>0";
                }
            }
            if (CheckBox8.Checked)
            {
                if (!String.IsNullOrEmpty(TextBoxSearch_StartTime.Text) && !String.IsNullOrEmpty(TextBoxSearch_EndTime.Text) && PageValidate.IsDate(TextBoxSearch_StartTime.Text) && PageValidate.IsDate(TextBoxSearch_EndTime.Text))
                {
                    DateTime start = Convert.ToDateTime(TextBoxSearch_StartTime.Text);
                    DateTime end   = Convert.ToDateTime(TextBoxSearch_EndTime.Text);
                    condition += String.Format(" and changetime >= '{0}' and changetime <= '{1}'", start, end);
                }
                else
                {
                    MessageBox.Show(this, "请输入正确的日期");
                    return(String.Empty);
                }
            }
            if (CheckBox9.Checked)
            {
                BrandModel model;

                if (!String.IsNullOrEmpty(TextBoxSearch_Brand.Text.Trim()) && new BrandModelBll().RawExists(TextBoxSearch_Brand.Text.Trim(), out model))
                {
                    condition += String.Format(" and brandid = " + model.BrandId);
                }
                else
                {
                    MessageBox.Show(this, "未输入或未查找到您输入的品牌");
                    return(String.Empty);
                }
            }

            return(condition);
        }
        private int AddProduct()
        {
            int    rtnValue = 0;
            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.fulImage.FileName == "")
            {
                strErr += "产品图片不能为空!\\n";
            }
            if (this.txtKeywords.Text == "")
            {
                strErr += "关键词不能为空!\\n";
            }
            if (this.TextBox_Description.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输入有误!\\n";
            }

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

            if (bll.Exists(txtProductName.Text))
            {
                MessageBox.Show(this, "对不起,该商品名称已存在,无法添加同名商品");
                rtnValue = 1;
                return(rtnValue);
            }
            CategoryModel cate = new CategoryModelBll().GetModel(Convert.ToInt32(txtCategoryID.Value));

            string[] MainImages;

            if (ProductMainImageRule.SaveProductMainImage(ProductID, cate.CatePath, fulImage.PostedFile, out MainImages))
            {
                ProductModel product = new ProductModel();

                product.ProductId   = ProductID;
                product.ProductCode = String.IsNullOrEmpty(txtProductCode.Text) ? ProductID.ToString() : txtProductCode.Text;
                product.ProductName = txtProductName.Text;


                product.CateId     = cate.CateId;
                product.CatePath   = cate.CatePath;
                product.InsertTime = DateTime.Now;
                product.ChangeTime = DateTime.Now;
                product.Keywords   = txtKeywords.Text;
                product.Brief      = TextBox_Description.Text;
                product.BrandID    = Convert.ToInt32(DropDown_Brand.SelectedValue);


                product.SmallImage  = MainImages[0];
                product.MediumImage = MainImages[1];
                product.LargeImage  = MainImages[2];

                product.MerchantPrice = Convert.ToDecimal(txtMerchantPrice.Text);
                product.ReducePrice   = Convert.ToDecimal(txtReducePrice.Text);
                product.TradePrice    = Convert.ToDecimal(txtTradePrice.Text);
                product.PageView      = 0;
                product.Score         = 0;
                //product.SortValue = "";
                product.Status = Convert.ToInt32(drpStatus.SelectedValue);
                product.Stock  = int.MaxValue;

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

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

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

                new ProductNewsBll().Add(new ProductNewsModel()
                {
                    ProdutID = ProductID, NewsID = TempNewsID
                });

                bll.Add(product);

                //添加产品检索属性
                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.Add(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.Add(para);
                    }
                }
                //添加商品多图
                foreach (string s in Request.Files.AllKeys)
                {
                    if (s.StartsWith("multiImageUpload") && Request.Files[s].ContentLength > 0)
                    {
                        string[] FileNames;
                        ProductMultiImageRule.SaveProductMultiImage(ProductID, cate.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);
                        }
                    }
                }

                //创建索引
                try
                {
                    DataIndexerProduct SearchIndexer = new DataIndexerProduct(Config.Searches["product"]);
                    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 { }

                return(rtnValue);
            }
            else
            {
                MessageBox.Show(this, "图片上传失败,请检查!");
                rtnValue = 1;
                return(rtnValue);
            }
        }