/// <summary> /// 保存伤病员信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public ActionResult AccidentPatientSave(TAccidentPatient entity) { BLL.MajorAccident.Accident accident = new BLL.MajorAccident.Accident(); string ambulance = Request.Form["ambulance"]; if (!string.IsNullOrEmpty(ambulance) && ambulance != "--请选择--") { entity.任务编码 = ambulance.Split('|')[0]; entity.车辆编码 = ambulance.Split('|')[1]; } bool save = false; try { save = accident.SavePatient(entity); } catch (Exception) { save = false; } if (save) { return(Json(new { IsSuccess = true, Message = "保存成功" }, "text/html", JsonRequestBehavior.AllowGet)); } else { return(Json(new { IsSuccess = false, Message = "保存失败" }, "text/html", JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 保存伤病员信息 /// </summary> /// <param name="entity"></param> /// <returns></returns> public static bool SavePatient(TAccidentPatient entity) { using (MainDataContext dbContext = new MainDataContext(AppConfig.ConnectionStringDispatch)) { if (entity.序号 == 0) { //新增的保存 var total = dbContext.TAccidentPatient.Where(t => t.事故编码 == entity.事故编码).Count(); if (total == 0) { entity.序号 = 1; } else { entity.序号 = total + 1; } dbContext.TAccidentPatient.InsertOnSubmit(entity); dbContext.SubmitChanges(); return(true); } else { //修改的保存 var model = dbContext.TAccidentPatient.FirstOrDefault(t => t.序号 == entity.序号 && t.事故编码 == entity.事故编码); model.任务编码 = entity.任务编码; model.姓名 = entity.姓名; model.性别 = entity.性别; model.年龄 = entity.年龄; model.年龄单位 = entity.年龄单位; model.单位 = entity.单位; model.收治医院 = entity.收治医院; model.病情编码 = entity.病情编码; model.车辆编码 = entity.车辆编码; model.初步诊断 = entity.初步诊断; model.职业 = entity.职业; model.治疗方式 = entity.治疗方式; model.住址 = entity.住址; model.转归 = entity.转归; dbContext.SubmitChanges(); return(true); } } }
public bool SavePatient(TAccidentPatient entity) { return(DAL.MajorAccident.Accident.SavePatient(entity)); }