public ActionResult AjaxSave() { ProductAttachmentStatus status = new ProductAttachmentStatus(); string qtyText = Request.Form["Quantity"]; int qty = 0; int.TryParse(qtyText, out qty); if (qty > 0) { ProductAttachmentInfo entity = new ProductAttachmentInfo(); entity.AttachmentID = Request.Form["AttachmentID"]; entity.ProductID = Request.Form["ProductID"]; entity.Quantity = qty; entity.InUser = UserAuthHelper.GetCurrentUser().UserID; entity.InUserName = UserAuthHelper.GetCurrentUser().UserID; entity.InUserSysNo = UserAuthHelper.GetCurrentUser().UserSysNo; status = ProductAttachmentService.CreateProductAttachment(entity); } return(Json(status)); }
/// <summary> /// Checks the product status for edit. /// </summary> /// <param name="productSysNo">The product system no.</param> /// <returns></returns> /// <exception cref="ECommerce.Utility.BusinessException"> /// 商品不存在 /// or /// 商品不能是上架状态 /// </exception> public static ProductAttachmentStatus CheckTheProductStatusForEdit(int productSysNo) { ProductAttachmentStatus status = ProductAttachmentDA.GetTheProductAttachmentStatusByProductSysNo(productSysNo); if (!status.ProductSysNo.HasValue || status.ProductSysNo <= 0) { throw new BusinessException("商品不存在"); } return(status); }
/// <summary> /// Checks the is exist product for edit. /// </summary> /// <param name="productSysNo">The product system no.</param> /// <exception cref="ECommerce.Utility.BusinessException"> /// 商品编号不能为空 /// or /// 商品不存在 /// </exception> private static void CheckIsExistProductForEdit(int productSysNo) { if (productSysNo <= 0) { throw new BusinessException("商品编号不能为空"); } ProductAttachmentStatus status = ProductAttachmentDA.GetTheProductAttachmentStatusByProductSysNo(productSysNo); if (!status.ProductSysNo.HasValue || status.ProductSysNo <= 0) { throw new BusinessException("商品不存在"); } }
/// <summary> /// Checks the attachment status. /// </summary> /// <param name="productSysNo">The product system no.</param> /// <exception cref="ECommerce.Utility.BusinessException"> /// 附件不存在 /// or /// 附件不能是上架状态 /// </exception> private static ProductAttachmentStatus CheckTheAttachmentStatus(int productSysNo) { ProductAttachmentStatus status = ProductAttachmentDA.GetTheProductAttachmentStatusByProductSysNo(productSysNo); if (!status.ProductSysNo.HasValue || status.ProductSysNo <= 0) { throw new BusinessException("附件不存在"); } if (status.ProductStatus.HasValue && status.ProductStatus == 1) { throw new BusinessException("附件不能是上架状态"); } return(status); }
public ActionResult Maintain() { string productSysNoText = Request["ProductSysNo"]; if (!string.IsNullOrEmpty(productSysNoText)) { int productSysNo = 0; int.TryParse(productSysNoText, out productSysNo); ProductAttachmentStatus status = ProductAttachmentService.CheckTheProductStatusForEdit(productSysNo); ViewBag.ProductSysNo = status.ProductSysNo; ViewBag.ProductID = status.ProductID; } return(View()); }
/// <summary> /// Checks the product status. /// </summary> /// <param name="productID">The product identifier.</param> /// <exception cref="ECommerce.Utility.BusinessException">商品不存在 /// or /// 商品不能是上架状态 /// or /// 商品附件不能超过3个</exception> private static ProductAttachmentStatus CheckTheProductStatus(string productID) { ProductAttachmentStatus status = ProductAttachmentDA.GetTheProductAttachmentStatusByProductID(productID); if (!status.ProductSysNo.HasValue || status.ProductSysNo <= 0) { throw new BusinessException("商品不存在"); } if (status.ProductStatus.HasValue && status.ProductStatus == 1) { throw new BusinessException("商品不能是上架状态"); } if (status.AttachmentCount.HasValue && status.AttachmentCount >= 3) { throw new BusinessException("商品附件不能超过3个"); } return(status); }
/// <summary> /// Creates the product attachment. /// </summary> /// <param name="entity">The entity.</param> public static ProductAttachmentStatus CreateProductAttachment(ProductAttachmentInfo entity) { //CheckTheProductStatus(entity.ProductSysNo); ProductAttachmentStatus productStatus = CheckTheProductStatus(entity.ProductID); entity.ProductSysNo = productStatus.ProductSysNo.Value; //CheckTheAttachmentStatus(entity.AttachmentSysNo); ProductAttachmentStatus attachmentStatus = CheckTheAttachmentStatus(entity.AttachmentID); entity.AttachmentSysNo = attachmentStatus.ProductSysNo.Value; if (ProductAttachmentDA.IsExistProductAttachment(entity.ProductSysNo, entity.AttachmentSysNo)) { throw new BusinessException("该商品的相同附件已存在,不能重复添加"); } ProductAttachmentDA.InsertAttachment(entity); ProductAttachmentStatus status = ProductAttachmentDA.GetTheProductAttachmentStatusByProductSysNo(entity.ProductSysNo); return(status); }