public async Task <ActionResult> UpdateGoodsProfit(GoodsProfit model) { try { if (model != null) { if (!string.IsNullOrEmpty(model.GoodsMarketingID.ToString())) { GoodsMarketing gm = await GoodsMarketingRepository.FindAsync(g => g.GoodsMarketingID == model.GoodsMarketingID); GoodsPurchase gp = await GoodsPurchaseRepository.FindAsync(p => p.GoodsPurchaseID == gm.GoodsPurchaseID); model.SigningTime = gm.SigningTime; model.MarketingName = gm.CustomerName; model.MarketingUnitPrice = gm.UnitPrice; model.ContractNum = gm.ContractNum; model.PurchaseName = gp.CustomerName; model.ContractType = gp.ContractType; model.ContractObject = gp.ContractObject; model.PurchaseUnitPrice = gp.UnitPrice; model.TotalPrice = gp.UnitPrice * gm.ContractNum; model.RealityPrice = gp.UnitPrice * model.RealityPickdingNum; model.RealityPayment = gm.UnitPrice * model.RealityPickdingNum; model.Spread = gm.UnitPrice - gp.UnitPrice; model.Profit = (gm.UnitPrice - gp.UnitPrice) * model.RealityPickdingNum; model.ProfitPercentage = (model.Profit / model.RealityPrice) / 100; } model.Noter = Session["LoginedUser"].ToString(); model.RecordTime = DateTime.Now; if (GoodsProfitRepository.Update(model)) { return(Json(new { Success = true })); } } return(Json(new { Success = false, Message = "参数有误。" })); } catch (Exception ex) { LogRepository.Add(new EventLog() { Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "更新利润核算表失败" + ex.Message }); return(Json(new { Success = false, Message = ex.Message })); } }
public async Task <ActionResult> GetGoodsProfitDetails(string ID) { try { if (!string.IsNullOrEmpty(ID)) { Guid gid = new Guid(ID); GoodsProfit findgp = await GoodsProfitRepository.FindAsync(p => p.GoodsProfitID == gid); GoodsMarketing findgm = await GoodsMarketingRepository.FindAsync(m => m.GoodsMarketingID == findgp.GoodsMarketingID); if (findgp != null && findgm != null) { return(Json(new { Success = true, GoodsMarketingID = findgp.GoodsMarketingID, ContractNo = findgm.ContractNo, RealityPickdingNum = findgp.RealityPickdingNum, ReflowTime = findgp.ReflowTime, Status = findgp.Status, Remark = findgp.Remark }, JsonRequestBehavior.AllowGet)); } } return(Json(new { Success = false, Message = "参数有误。" }, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { LogRepository.Add(new EventLog() { Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "绑定利润核算表明细失败" + ex.Message }); return(Json(new { Success = false, Message = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> DeleteGoodsProfit(string ID) { try { if (!string.IsNullOrEmpty(ID)) { Guid gid = new Guid(ID); GoodsProfit findgp = await GoodsProfitRepository.FindAsync(p => p.GoodsProfitID == gid); if (findgp != null) { if (GoodsProfitRepository.Delete(findgp)) { return(Json(new { Success = true })); } } } return(Json(new { Success = false, Message = "参数有误。" })); } catch (Exception ex) { LogRepository.Add(new EventLog() { Name = Session["LoginedUser"].ToString(), Date = DateTime.Now.ToLocalTime(), Event = "删除利润核算表失败" + ex.Message }); return(Json(new { Success = false, Message = ex.Message })); } }