/// <summary> /// 添加 /// </summary> /// <param name="userModel"></param> /// <param name="model"></param> /// <returns></returns> public virtual bool AddBuyOrderProduct(UserModel userModel, BuyOrderProduct model) { model.UserId = userModel.UserId; model.BuyOrderProductId = SeqGuid.NewGuid(); model.CreateDate = DateTime.Now; Da.Add <Guid, BuyOrderProduct>(model); return(true); }
/// <summary> /// 删除 /// </summary> /// <param name="userModel"></param> /// <param name="model"></param> /// <returns></returns> public virtual bool DeleteBuyOrderProduct(UserModel userModel, BuyOrderProduct model) { var m = Da.Get <BuyOrderProduct>(model.BuyOrderProductId); if (m == null || m.UserId != userModel.UserId) { return(false); } return(Da.Delete(model)); }
/// <summary> /// 添加订单产品 /// </summary> /// <returns></returns> public bool AddOrderProduct(BuyOrderProduct m) { Db((db, tran) => { var product = db.Get <Product>(m.ProductId, tran); product.InTransitQty += m.Qty; //添加产品 db.Update(product, tran); db.Insert <Guid, BuyOrderProduct>(m, tran); }); return(true); }
/// <summary> /// 更新 /// </summary> /// <param name="userModel"></param> /// <param name="model"></param> /// <returns></returns> public virtual bool UpdateBuyOrderProduct(UserModel userModel, BuyOrderProduct model) { var m = Da.Get <BuyOrderProduct>(model.BuyOrderProductId); if (m == null || m.UserId != userModel.UserId) { return(false); } m.BuyOrderId = model.BuyOrderId; m.ProductId = model.ProductId; m.Price = model.Price; m.Qty = model.Qty; m.Remark = model.Remark; return(Da.Update(m)); }
/// <summary> /// 添加订单产品 /// </summary> /// <param name="userModel"></param> /// <param name="request"></param> /// <param name="msg"></param> /// <returns></returns> public bool AddOrderProduct(UserModel userModel, BuyOrderProduct request, out string msg) { var order = Da.Get <BuyOrder>(request.BuyOrderId); var b1 = CheckAuthOrderByStatusStockIn(userModel, order, out msg); if (!b1) { return(false); } var product = Da.Get <Product>(request.ProductId); var b2 = CheckAuthProduct(userModel, product, out msg); if (!b2) { return(false); } var m = new BuyOrderProduct() { BuyOrderProductId = SeqGuid.NewGuid(), UserId = order.UserId, BuyOrderId = order.BuyOrderId, ProductId = product.ProductId, Price = 0, Qty = 0, InQty = request.InQty, Remark = null, CreateDate = DateTime.Now, IsStockIn = false, InStockRemark = request.InStockRemark, IsNewAdd = true, }; Da.Add <Guid, BuyOrderProduct>(m); msg = null; return(true); }
public IResponseResult AddOrderProduct(BuyOrderProduct request) { var result = Biz.AddOrderProduct(UserModel, request, out var msg); return(ReturnResult(result, msg)); }