Exemple #1
0
        public static int Add(ProductInfo entity)
        {
            entity.Id = dal.Add(entity);

            UploadBLL.UpdateUpload(TableID, 0, entity.Id, Cookies.Admin.GetRandomNumber(false));

            int[] classIds = Array.ConvertAll <string, int>(entity.ClassId.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k));
            ProductClassBLL.ChangeProductCount(classIds, ChangeAction.Plus);
            CacheHelper.Remove("ProductClass");

            return(entity.Id);
        }
Exemple #2
0
        /// <summary>
        /// 彻底删除
        /// </summary>
        /// <param name="id"></param>
        public static void Delete(int id)
        {
            bool canDel = true;

            if (OrderDetailBLL.ReadListByProductId(id).Count > 0)
            {
                foreach (OrderDetailInfo myOD in OrderDetailBLL.ReadListByProductId(id))
                {
                    OrderInfo tempOrder = OrderBLL.Read(myOD.OrderId, 0);
                    if (tempOrder.IsDelete == 0)
                    {
                        canDel = false;
                        break;
                    }
                }
                if (!canDel)
                {
                    ScriptHelper.Alert("该产品存在相关订单,不能删除。");
                }
                else
                {
                    var product = Read(id);

                    if (product.Id > 0)
                    {
                        UploadBLL.DeleteUploadByRecordID(TableID, id.ToString());
                        dal.Delete(id);
                        ProductPhotoBLL.DeleteList(id, 0);

                        int[] classIds = Array.ConvertAll <string, int>(product.ClassId.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k));
                        ProductClassBLL.ChangeProductCount(classIds, ChangeAction.Minus);
                        CacheHelper.Remove("ProductClass");
                    }
                }
            }
            else
            {
                var product = Read(id);

                if (product.Id > 0)
                {
                    UploadBLL.DeleteUploadByRecordID(TableID, id.ToString());
                    dal.Delete(id);
                    ProductPhotoBLL.DeleteList(id, 0);

                    int[] classIds = Array.ConvertAll <string, int>(product.ClassId.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k));
                    ProductClassBLL.ChangeProductCount(classIds, ChangeAction.Minus);
                    CacheHelper.Remove("ProductClass");
                }
            }
        }
        /// <summary>
        /// 读取编排好的产品分类---后台展示
        /// </summary>
        /// <param name="idList"></param>
        public static string ProductClassNameListAdmin(string idList)
        {
            string content = string.Empty;

            if (!string.IsNullOrEmpty(idList))
            {
                idList = idList.Substring(1, idList.Length - 2);
            }
            idList = idList.Replace("||", "#");
            if (idList.Length > 0)
            {
                foreach (string temp in idList.Split('#'))
                {
                    string tempProductClassName = string.Empty;
                    foreach (string id in temp.Split('|'))
                    {
                        ProductClassInfo proClass = ProductClassBLL.Read(Convert.ToInt32(id));
                        if (string.IsNullOrEmpty(tempProductClassName))
                        {
                            //tempProductClassName = "<a href=\"/List.html?cat=" + ReadFullParentId(proClass.Id) + "\" target=\"_blank\" title=\"" + proClass.Name + "\">" + StringHelper.Substring(proClass.Name, 10) + "</a>";
                            tempProductClassName = StringHelper.Substring(proClass.Name, 10);
                        }
                        else
                        {
                            //tempProductClassName += " > <a href=\"/List.html?cat=" + ReadFullParentId(proClass.Id) + "\"  target=\"_blank\" title=\"" + proClass.Name + "\">" + StringHelper.Substring(proClass.Name, 10) + "</a>";
                            tempProductClassName += " > " + StringHelper.Substring(proClass.Name, 10);
                        }
                    }
                    if (!string.IsNullOrEmpty(tempProductClassName))
                    {
                        if (string.IsNullOrEmpty(content))
                        {
                            content = tempProductClassName;
                        }
                        else
                        {
                            content += "," + tempProductClassName;
                        }
                    }
                }
            }
            return(content);
        }