/// <summary> /// 编辑 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Edit(int id = 0) { Order_Contract model = null; if (id == 0) { model = new Order_Contract(); } else { model = Bll.BllOrder_Contract.First(o => o.Id == id); if (model == null) { return(LayerAlertErrorAndClose("记录不存在!")); } } return(View(model)); }
public ActionResult Save(Order_Contract model) { string contractNo = RequestString("contractno"); if (string.IsNullOrEmpty(contractNo)) { return(LayerAlertErrorAndReturn("请填写合同号!")); } if (model.Id > 0) { model = Bll.BllOrder_Contract.First(o => o.Id == model.Id); if (model == null) { return(Response404()); } } else { model = new Order_Contract(); } if ((model.Id == 0 || model.ContractNo != contractNo) && Bll.BllOrder_Contract.CheckContractNo(contractNo)) { return(LayerAlertErrorAndReturn("合同号已存在!")); } model.ContractNo = contractNo; model.AddTime = DateTime.Now; model.AdminId = MyInfo.Id; if ((model.Id > 0 ? Bll.BllOrder_Contract.Update(model) : Bll.BllOrder_Contract.Insert(model)) > 0) { return(LayerAlertSuccessAndRefresh((model.Id > 0 ? "修改" : "添加") + "成功")); } else { return(LayerAlertErrorAndReturn((model.Id > 0 ? "修改" : "添加") + "失败")); } }