//实现方式略丑陋建议用联合查询方式, 我linq不太会用 public static List<CaseDetail> getListByPId(long patient_id) { List<CaseDetail> result = new List<CaseDetail>(); List<case_info> caselist = new CaseService().getCaseListByPId(patient_id); foreach (case_info ci in caselist) { result.Add(getInstanceByCaseId(ci.case_id)); } return result; }
public ActionResult test( ) { CaseService cs = new CaseService(); case_info ci = new case_info(); ci.patient_id =1; ci.dentist_id =1; ci.case_note ="aa"; ci.case_gen_time = DateTime.Now; cs.insert(ci); return null; }
public static CaseDetail getInstanceByCaseId(long case_id) { CaseDetail result = new CaseDetail(); case_info ci = new CaseService().getCaseByCaseId(case_id); if (ci==null) { return null; } result.case_id = ci.case_id; result.note = ci.case_note; result.case_gen_time = ci.case_gen_time; result.doctor = new PatientLogin().getUserById(ci.dentist_id); result.patient = new PatientLogin().getUserById(ci.patient_id); result.treatWithCountList = TreatWithCount.getListByCaseId(ci.case_id); return result; }
public void insert() { case_info ci = new case_info(); ci.case_id = this.case_id; ci.dentist_id = this.doctor.user_id; ci.patient_id = this.patient.user_id; ci.case_note = this.note; long case_id=new CaseService().insert(ci); foreach(TreatWithCount twc in this.treatWithCountList) { case_to_treat ct = new case_to_treat(); ct.case_id = case_id; ct.treat_id = twc.treat.treat_id; ct.treat_count = twc.count; new CaseToTreat().insert(ct); } }