private void Save() { AjaxResult result = new AjaxResult(); result.IsSuccess = false; result.Msg = "保存失败!"; int?id = null; if (!string.IsNullOrEmpty(Request.Form["id"])) { id = Convert.ToInt32(Request.Form["id"]); } Pilot model = null; if (!id.HasValue)//新增 { model = new Pilot(); model.GetEntitySearchPars <Pilot>(this.Context); model.LicenseImg = Request.Params["LicenseImgsInfo"]; model.CreateTime = DateTime.Now; if (bll.Add(model) > 0) { result.IsSuccess = true; result.Msg = "增加成功!"; } } else//编辑 { model = bll.Get(id.Value); if (model != null) { model.GetEntitySearchPars <Pilot>(this.Context); model.LicenseImg = Request.Params["LicenseImgsInfo"]; if (bll.Update(model) > 0) { result.IsSuccess = true; result.Msg = "更新成功!"; } } } Response.Clear(); Response.Write(result.ToJsonString()); Response.ContentType = "application/json"; Response.End(); }