/// <summary> /// 逻辑删除 /// </summary> /// <param name="ids"></param> public static void DeleteLogically(string ids) { string[] delArr = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (delArr.Length > 0) { foreach (string did in delArr) { int id = 0; if (int.TryParse(did, out 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) { dal.DeleteLogically(id); CacheHelper.Remove("ProductClass"); } } } else { var product = Read(id); if (product.Id > 0) { dal.DeleteLogically(id); CacheHelper.Remove("ProductClass"); } } } } } }
/// <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> /// 逻辑删除--isdelete 置为1 /// </summary> /// <param name="id"></param> public static void DeleteLogically(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) { dal.DeleteLogically(id); CacheHelper.Remove("ProductClass"); } } } else { var product = Read(id); if (product.Id > 0) { dal.DeleteLogically(id); } } }