/// <summary>
        /// 根据属性ID获取属性信息
        /// </summary>
        public string GetPropInfoById()
        {
            var      service = new PropService(CurrentUserInfo);
            PropInfo obj     = new PropInfo();
            string   content = string.Empty;

            string key = string.Empty;

            if (Request("PropID") != null && Request("PropID") != string.Empty)
            {
                key = Request("PropID").ToString().Trim();
            }

            obj = service.GetPropInfoById(key);
            var SKUDomain = "SKU";

            if (obj != null)
            {
                obj.Children = service.GetPropListByParentId(SKUDomain, obj.Prop_Id);
            }

            var jsonData = new JsonData();

            jsonData.totalCount = obj == null ? "0" : "1";
            jsonData.data       = obj;

            content = jsonData.ToJSON();
            return(content);
        }
        /// <summary>
        /// 删除
        /// </summary>
        public string PropDeleteData()
        {
            string content        = string.Empty;
            string error          = "";
            var    responseData   = new ResponseData();
            var    service        = new PropService(this.CurrentUserInfo);
            var    brandDetailBLL = new BrandDetailBLL(this.CurrentUserInfo);
            var    skuPropServer  = new SkuPropServer(this.CurrentUserInfo);

            string key = string.Empty;

            if (FormatParamValue(Request("ids")) != null && FormatParamValue(Request("ids")) != string.Empty)
            {
                key = FormatParamValue(Request("ids")).ToString().Trim();
            }

            if (key == null || key.Trim().Length == 0)
            {
                responseData.success = false;
                responseData.msg     = "ID不能为空";
                return(responseData.ToJSON());
            }



            string[] ids = key.Split(',');

            if (ids.Length > 0)
            {
                foreach (var id in ids)
                {
                    if (skuPropServer.ISCheckSkuProp(id))
                    {
                        responseData.success = false;
                        responseData.msg     = "属性已被引用";
                        return(responseData.ToJSON());
                    }
                    if (skuPropServer.ISCheckSkuProp2(id))
                    {
                        responseData.success = false;
                        responseData.msg     = "规格已被引用";
                        return(responseData.ToJSON());
                    }
                }
            }
            if (ids.Length > 0)
            {
                foreach (var id in ids)
                {
                    var propObj = new PropInfo();
                    propObj.Prop_Id = id;

                    var      tmpPropObj = service.GetPropInfoById(id);
                    PropInfo parentObj  = null;
                    if (tmpPropObj.Parent_Prop_id != null && tmpPropObj.Parent_Prop_id.Trim().Length > 0)
                    {
                        parentObj = service.GetPropInfoById(tmpPropObj.Parent_Prop_id);
                    }
                    if (parentObj != null && (parentObj.Prop_Code == "品牌" || parentObj.Prop_Id == "F8823C2EBACF4965BA134D3B10BD0B9F"))
                    {
                        brandDetailBLL.SetBrandAndPropSyn(propObj.Prop_Id, propObj.Prop_Name, 2, 1, out error);
                    }



                    service.DeleteProp(propObj);

                    SkuPropInfo skuPropInfo = new SkuPropInfo();
                    skuPropInfo.prop_id = propObj.Prop_Id;
                    skuPropServer.DeleteSkuProp(skuPropInfo);
                }
            }

            responseData.success = true;
            responseData.msg     = error;

            content = responseData.ToJSON();
            return(content);
        }
        /// <summary>
        /// 保存属性
        /// </summary>
        public string SavePropData()
        {
            var      service        = new PropService(CurrentUserInfo);
            var      brandDetailBLL = new BrandDetailBLL(CurrentUserInfo);
            var      skuPropServer  = new SkuPropServer(this.CurrentUserInfo);
            PropInfo item           = new PropInfo();
            string   content        = string.Empty;
            var      responseData   = new ResponseData();

            string key     = string.Empty;
            string item_id = string.Empty;

            if (Request("item") != null && Request("item") != string.Empty)
            {
                key = Request("item").ToString().Trim();
            }
            if (Request("PropId") != null && Request("PropId") != string.Empty)
            {
                item_id = Request("PropId").ToString().Trim();
            }

            item = key.DeserializeJSONTo <PropInfo>();

            PropInfo parentObj = new PropInfo();

            parentObj.Prop_Level = 1;
            if (item.Parent_Prop_id != null && item.Parent_Prop_id.Trim().Length > 0)
            {
                parentObj = service.GetPropInfoById(item.Parent_Prop_id);
                if (parentObj != null)
                {
                    item.Prop_Level = parentObj.Prop_Level + 1;
                }
            }
            else
            {
                item.Parent_Prop_id = "-99";
                item.Prop_Status    = 1;
            }

            if (item.Prop_Domain == "SKU" && item.Prop_Level == 2)
            {
                if (service.CheckSkuLast(item.Parent_Prop_id))
                {
                    responseData.success = false;
                    responseData.msg     = "SKU组最多有5个子节点";
                    return(responseData.ToJSON());
                }
            }

            if (item.Prop_Name == null || item.Prop_Name.Trim().Length == 0)
            {
                responseData.success = false;
                responseData.msg     = "名称不能为空";
                return(responseData.ToJSON());
            }
            if (item.Prop_Code == null || item.Prop_Code.Trim().Length == 0)
            {
                responseData.success = false;
                responseData.msg     = "代码不能为空";
                return(responseData.ToJSON());
            }


            #region 商品sku 属性时判断  Display_Index只能在1-5,且不能在
            if (item.Prop_Type == "2" && item.Prop_Domain == "SKU")
            {
                string skuMsg = string.Empty;
                if (item.Display_Index < 1 || item.Display_Index > 5)
                {
                    skuMsg = "序号必须在1~5范围内";
                }

                //是否存在sku

                if (skuPropServer.CheckSkuPropByDisplayindex(this.CurrentUserInfo.CurrentLoggingManager.Customer_Id, item.Display_Index))
                {
                    skuMsg = "序号被占用,请重新选择1~5的序号。";
                }
                if (!string.IsNullOrWhiteSpace(skuMsg))
                {
                    responseData.msg = skuMsg;
                    return(responseData.ToJSON());
                }
            }
            #endregion


            bool   status  = true;
            string message = "保存成功";
            //------------------------------------------------
            //if (item.Prop_Domain.Equals("SKU") && item.Prop_Level.Equals("3"))
            //{
            //    item.Prop_Domain = "ITEM";
            //}
            //-----------------------------------------------------------------
            item.Prop_Status = 1;
            if (item.Prop_Id.Trim().Length == 0)
            {
                item.Prop_Id = Utils.NewGuid();
                service.SaveProp(item, ref message);
            }
            else
            {
                service.SaveProp(item, ref message);
            }

            if (message != "属性代码已存在")
            {
                if (item.Prop_Type == "2" && item.Prop_Domain == "SKU")
                {
                    string skuMsg = string.Empty;
                    if (item.Display_Index < 1 && item.Display_Index > 5)
                    {
                        skuMsg = "序号必须在1~5范围内";
                    }

                    //是否存在sku

                    if (skuPropServer.CheckSkuPropByDisplayindex(this.CurrentUserInfo.CurrentLoggingManager.Customer_Id, item.Display_Index))
                    {
                        skuMsg = "序号被占用,请重新选择1~5的序号。";
                    }
                    if (!string.IsNullOrWhiteSpace(skuMsg))
                    {
                        responseData.msg = skuMsg;
                        return(responseData.ToJSON());
                    }

                    //如果不存在属性关系
                    if (!skuPropServer.CheckSkuProp(item.Prop_Id))
                    {
                        SkuPropInfo skuPropInfo = new SkuPropInfo();
                        skuPropInfo.sku_prop_id   = Utils.NewGuid();
                        skuPropInfo.prop_id       = item.Prop_Id;
                        skuPropInfo.CustomerId    = this.CurrentUserInfo.CurrentLoggingManager.Customer_Id;
                        skuPropInfo.status        = item.Prop_Status.ToString();
                        skuPropInfo.display_index = item.Display_Index;
                        skuPropServer.AddSkuProp(skuPropInfo);
                    }
                }
                else
                {
                    SkuPropInfo skuPropInfo = new SkuPropInfo();
                    skuPropInfo.prop_id = item.Prop_Id;
                    skuPropServer.DeleteSkuProp(skuPropInfo);
                }
            }
            else
            {
                status = false;
            }



            if (parentObj != null && (parentObj.Prop_Code == "品牌" || parentObj.Prop_Id == "F8823C2EBACF4965BA134D3B10BD0B9F"))
            {
                brandDetailBLL.SetBrandAndPropSyn(item.Prop_Id, item.Prop_Name, 2, 0, out message);
            }

            responseData.success = status;
            responseData.msg     = message;

            content = responseData.ToJSON();
            return(content);
        }
Beispiel #4
0
        /// <summary>
        /// 获取子节点数据
        /// </summary>
        /// <param name="pParentNodeID">父节点ID</param>
        /// <returns></returns>
        protected override TreeNodes GetNodes(string pParentNodeID)
        {
            TreeNodes nodes = new TreeNodes();

            var service              = new PropService(new SessionManager().CurrentUserLoginInfo);
            IList <PropInfo> data    = new List <PropInfo>();
            string           content = string.Empty;

            string key    = string.Empty;
            string domain = string.Empty;

            if (Request("node") != null && Request("node") != string.Empty)
            {
                key = Request("node").ToString().Trim();
            }
            if (key == "root" || key.Trim().Length == 0)
            {
                key = "-99";
            }
            if (Request("domain") != null && Request("domain") != string.Empty)
            {
                domain = Request("domain").ToString().Trim();
            }

            //if (key.Length == 2)
            //{
            //    data = service.GetCityListByProvince(key);
            //}
            //else if (key.Length == 4)
            //{
            //    data = service.GetAreaListByCity(key);
            //}
            //else if (key.Length == 0)
            //{
            //    data = service.GetProvinceList();
            //}

            var queryEntity = new PropInfo();

            queryEntity.Parent_Prop_id = key;
            queryEntity.Prop_Domain    = domain;


            if (queryEntity.Parent_Prop_id != "-99")
            {
                var      pr        = new PropService(CurrentUserInfo);
                PropInfo parentObj = pr.GetPropInfoById(key);
                if (parentObj.Prop_Type != "2")
                {
                    queryEntity.CustomerId = this.CurrentUserInfo.ClientID;
                }
            }
            data = service.GetWebProp(queryEntity, 0, 1000);

            var jsonData = new JsonData();

            jsonData.totalCount = data.Count.ToString();
            jsonData.data       = data;

            var parentCode = string.Empty;

            foreach (var item in data)
            {
                nodes.Add(item.Prop_Id, item.Prop_Name,
                          item.Parent_Prop_id,
                          false);
            }
            //
            //var root = new TreeNodes();
            //root.Add(new TreeNode() { ID = "1", IsLeaf = false, Text = "1" });
            //root.Add(new TreeNode() { ID = "1_1", ParentID = "1", IsLeaf = false, Text = "1_1" });
            //root.Add(new TreeNode() { ID = "1_1_1", ParentID = "1_1", IsLeaf = false, Text = "1_1_1`" });
            return(nodes);
        }