/// <summary> /// 添加采购退货单 /// </summary> /// <param name="purchase">采购单实体类对象</param> /// <returns></returns> public void AddPurchaseReturn(PrPurchaseReturn PurchaseReturn) { var sysNo = 0; PurchaseReturn.ReturnQuantity = PurchaseReturn.PurchaseReturnDetails.Sum(x => x.ReturnQuantity); PurchaseReturn.ReturnTotalMoney = PurchaseReturn.PurchaseReturnDetails.Sum(x => x.ReturnTotalMoney); if (PurchaseReturn.SysNo > 0) { IPrPurchaseReturnDao.Instance.UpdatePurchaseReturn(PurchaseReturn); sysNo = PurchaseReturn.SysNo; } else { sysNo = IPrPurchaseReturnDao.Instance.AddPurchaseReturn(PurchaseReturn); } if (sysNo > 0) { foreach (var item in PurchaseReturn.PurchaseReturnDetails) { item.PurchaseReturnSysNo = sysNo; if (item.SysNo <= 0) { IPrPurchaseReturnDetailsDao.Instance.AddPrPurchaseReturnDetails(item); } else { IPrPurchaseReturnDetailsDao.Instance.UpdatePrPurchaseReturnDetails(item); } } } }
/// <summary> /// 添加采购退货单 /// </summary> /// <param name="PurchaseReturn">采购退货单实体类对象</param> /// <returns></returns> public override int AddPurchaseReturn(PrPurchaseReturn PurchaseReturn) { PurchaseReturn.SysNo = Context.Insert("PrPurchaseReturn", PurchaseReturn) .AutoMap(o => o.SysNo, o => o.PurchaseReturnDetails) .ExecuteReturnLastId <int>("SysNo"); return(PurchaseReturn.SysNo); }
public JsonResult PurchaseReturnUpdate(PrPurchaseReturn model, List <int> delSysNos = null) { var result = new Result { Status = false, StatusCode = 0 }; try { if (model.SysNo <= 0) { model.CreatedBy = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo; model.CreatedDate = DateTime.Now; model.Status = (int)PurchaseStatus.采购退货单状态.待审核; } BLL.Purchase.PrPurchaseReturnBo.Instance.AddPurchaseReturn(model); if (delSysNos != null) { BLL.Purchase.PrPurchaseReturnDetailsBo.Instance.Delete(string.Join(",", delSysNos)); } } catch (Exception ex) { result.StatusCode = -1; result.Message = ex.Message; } return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 更新采购退货单 /// </summary> /// <param name="purchase">采购退货单实体类对象</param> /// <returns></returns> public override int UpdatePurchaseReturn(PrPurchaseReturn PurchaseReturn) { int rows = Context.Update("PrPurchaseReturn", PurchaseReturn) .AutoMap(o => o.SysNo, o => o.CreatedBy, o => o.CreatedDate, o => o.Status, o => o.PurchaseReturnDetails) .Where("SysNo", PurchaseReturn.SysNo) .Execute(); return(rows); }
public ActionResult PurchaseReturnUpdate(int id = 0, int page = 1) { var purchaseReturn = new PrPurchaseReturn(); if (id > 0) { purchaseReturn = BLL.Purchase.PrPurchaseReturnBo.Instance.GetPrPurchaseReturnInfo(id); ViewBag.WarehouseName = BLL.Warehouse.WhWarehouseBo.Instance.GetWarehouseName(purchaseReturn.WarehouseSysNo); ViewBag.PurchaseCode = BLL.Purchase.PrPurchaseBo.Instance.GetPurchaseCode(purchaseReturn.PurchaseSysNo); } return(View(purchaseReturn)); }
public JsonResult PurchaseReturnCreate(PrPurchaseReturn model) { var result = new Result { Status = false, StatusCode = 0 }; try { if (model.SysNo <= 0) { model.CreatedBy = BLL.Authentication.AdminAuthenticationBo.Instance.Current.Base.SysNo; model.CreatedDate = DateTime.Now; model.Status = (int)PurchaseStatus.采购退货单状态.待审核; } var detailList = model.PurchaseReturnDetails; IList <int> indxList = new List <int>(); foreach (var mod in detailList) { indxList.Add(mod.ProductSysNo); } var stockList = Hyt.BLL.Warehouse.PdProductStockBo.Instance.GetAllStockList(model.WarehouseSysNo, indxList); foreach (var mod in detailList) { PdProductStock stock = stockList.First(p => p.PdProductSysNo == mod.ProductSysNo); if (mod.ReturnQuantity > stock.StockQuantity) { result.StatusCode = -1; result.Message = "采购退货单的退货数量大于退货仓商品库存数,不能进行退货,请核实情况。"; return(Json(result, JsonRequestBehavior.AllowGet)); } } BLL.Purchase.PrPurchaseReturnBo.Instance.AddPurchaseReturn(model); } catch (Exception ex) { result.StatusCode = -1; result.Message = ex.Message; } return(Json(result, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 更新采购退货单 /// </summary> /// <param name="purchase">采购退货单实体类对象</param> /// <returns></returns> public abstract int UpdatePurchaseReturn(PrPurchaseReturn PurchaseReturn);
/// <summary> /// 添加采购退货单 /// </summary> /// <param name="PurchaseReturn">采购退货单实体类对象</param> /// <returns></returns> public abstract int AddPurchaseReturn(PrPurchaseReturn PurchaseReturn);