public JsonResult Create(MachineType obj) { try { if (obj.StartDate < Convert.ToDateTime("2000-01-01")) { obj.StartDate = Convert.ToDateTime("2000-01-01"); } if (obj.EndDate < Convert.ToDateTime("2000-01-01")) { obj.EndDate = Convert.ToDateTime("2000-01-01"); } if (obj.BuyDate < Convert.ToDateTime("2000-01-01")) { obj.BuyDate = Convert.ToDateTime("2000-01-01"); } if (IsCreateOk(obj.Code)) return Json(new { errorMsg = "编号已经存在" }); NSession.Save(obj); NSession.Flush(); } catch (Exception ee) { return Json(new { IsSuccess = false, ErrorMsg = "出错了" }); } return Json(new { IsSuccess = true }); }
public ActionResult Edit(MachineType obj) { try { if (IsOk(obj.Id, obj.Code)) return Json(new { errorMsg = "编号已经存在" }); NSession.Update(obj); NSession.Flush(); } catch (Exception ee) { return Json(new { IsSuccess = false, ErrorMsg = "出错了" }); } return Json(new { IsSuccess = true }); }