public ActionResult AddGoodsPurchase(GoodsPurchase purchase) { try { if (purchase != null) { purchase.TotalPrice = purchase.UnitPrice * purchase.ContractNum; purchase.AwaitPickdingNum = purchase.ContractNum - purchase.AlreadyPickingNum; purchase.TonCost = purchase.UnitPrice + purchase.LogisticsCost; purchase.AllCost = purchase.TonCost * purchase.ContractNum; purchase.GoodsPurchaseID = new GoodsPurchase().GoodsPurchaseID; purchase.Noter = Session["LoginedUser"].ToString(); purchase.RecordTime = DateTime.Now; if (GoodsPurchaseRepository.Add(purchase) != null) { 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> GetGoodsPurchaseDetails(string ID) { try { if (!string.IsNullOrEmpty(ID)) { Guid gid = new Guid(ID); GoodsPurchase findgp = await GoodsPurchaseRepository.FindAsync(p => p.GoodsPurchaseID == gid); if (findgp != null) { return(Json(new { Success = true, AllCost = findgp.AllCost, AlreadyPickingNum = findgp.AlreadyPickingNum, AwaitPickdingNum = findgp.AwaitPickdingNum, ContractNo = findgp.ContractNo, ContractNum = findgp.ContractNum, ContractObject = findgp.ContractObject, ContractType = findgp.ContractType, CustomerName = findgp.CustomerName, DeliveryTime = findgp.DeliveryTime.ToString("yyyy-MM-dd"), GoodsPurchaseID = findgp.GoodsPurchaseID, InvoiceStatus = findgp.InvoiceStatus, LogisticsCost = findgp.LogisticsCost, PaymentAmount = findgp.PaymentAmount, PaymentTime = findgp.PaymentTime.ToString("yyyy-MM-dd"), RealityPickdingNum = findgp.RealityPickdingNum, Remark = findgp.Remark, SigningTime = findgp.SigningTime.ToString("yyyy-MM-dd"), TonCost = findgp.TonCost, TotalPrice = findgp.TotalPrice, UnitPrice = findgp.UnitPrice }, 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> 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> AddGoodsFuture(GoodsFuture model) { try { if (model != null) { GoodsPurchase findgp = await GoodsPurchaseRepository.FindAsync(p => p.GoodsPurchaseID == model.GoodsPurchaseID); if (findgp != null) { model.ContractNo = findgp.ContractNo; } model.Noter = Session["LoginedUser"].ToString(); model.RecordTime = DateTime.Now; if (GoodsFutureRepository.Add(model) != null) { 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> DeleteGoodsPurchase(string ID) { try { if (!string.IsNullOrEmpty(ID)) { Guid gid = new Guid(ID); GoodsPurchase findgp = await GoodsPurchaseRepository.FindAsync(p => p.GoodsPurchaseID == gid); if (findgp != null) { if (GoodsPurchaseRepository.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 })); } }
public ActionResult UpdateGoodsPurchase(GoodsPurchase model) { try { if (model != null) { model.TotalPrice = model.UnitPrice * model.ContractNum; model.AwaitPickdingNum = model.ContractNum - model.AlreadyPickingNum; model.TonCost = model.UnitPrice + model.LogisticsCost; model.AllCost = model.TonCost * model.ContractNum; model.Noter = Session["LoginedUser"].ToString(); model.RecordTime = DateTime.Now; if (GoodsPurchaseRepository.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 })); } }