//新增救治记录 public bool InsertPRRescue(M_PatientRecordRescue info, List<M_PatientRecordMeasure> measureSCO , List<M_PatientRecordDrug> drugSCO, List<M_PatientRecordSanitation> sanitationSCO , List<M_PatientRecordLossDrug> lossDrugSCO, List<M_PatientRecordLossSanitation> lossSanitationSCO) { using (var tran = db.Database.BeginTransaction()) { try { string RescueRecordCode = ""; M_PatientRecordRescue q = (from pr in db.M_PatientRecordRescue orderby pr.RescueRecordCode descending where pr.TaskCode == info.TaskCode && pr.PatientOrder == info.PatientOrder select pr).FirstOrDefault(); if (q != null) RescueRecordCode = info.TaskCode + (Convert.ToInt32(q.RescueRecordCode.Replace(info.TaskCode, "")) + 1).ToString(); //RescueRecordCode = info.TaskCode + (query.Count() + 1); else RescueRecordCode = info.TaskCode + "1"; info.RescueRecordCode = RescueRecordCode;//救治记录编码 db.M_PatientRecordRescue.Add(info);//插入救治记录 if (info != null) { if (measureSCO != null) { List<M_PatientRecordMeasure> measure = new List<M_PatientRecordMeasure>(); for (int k = 0; k < measureSCO.Count; k++) { M_PatientRecordMeasure SInfo = measureSCO[k]; //M_PatientRecordMeasure MeasureInfo = measureSCO[k]; I_Material c = (from m in db.I_Material where m.ID == SInfo.RescueMeasureCode select m).FirstOrDefault(); SInfo.TaskCode = SInfo.TaskCode; SInfo.PatientOrder = SInfo.PatientOrder; SInfo.RescueRecordCode = RescueRecordCode;//救治记录编码 SInfo.DisposeOrder = SInfo.DisposeOrder;//处理序号 SInfo.RescueMeasureCode = c.ID;//救治措施编码 SInfo.RescueMeasureName = c.Name;//救治措施 SInfo.OtherTypeID = c.OtherTypeID;// SInfo.NumberOfTimes = SInfo.NumberOfTimes;//次数 SInfo.Price = c.RealPrice;//单价 int FeeScale = c.FeeScale == null ? 1 : Convert.ToInt32(c.FeeScale); int Dosage = 1; if (FeeScale == -1) { Dosage = 1; } else if (FeeScale == 1) { Dosage = Convert.ToInt32(SInfo.NumberOfTimes); } else { if (FeeScale < 0 && (-FeeScale <= Convert.ToInt32(SInfo.NumberOfTimes))) { Dosage = -FeeScale; } else { Dosage = Convert.ToInt32(SInfo.NumberOfTimes); } } SInfo.TotalPrice = c.RealPrice * Dosage;//合计金额 SInfo.ChargeWay = Decimal.Round(decimal.Parse(c.RealPrice.ToString()), 2, MidpointRounding.AwayFromZero) + "元/" + c.TDictionary2.Name;//收费方式 SInfo.Remark = SInfo.Remark; SInfo.SelectOrder = k + 1; measure.Add(SInfo); //measureSCO.Add(SInfo); //db.M_PatientRecordMeasure.Add(SInfo);//插入救治措施子表 } db.M_PatientRecordMeasure.AddRange(measure);//插入救治措施子表 } if (drugSCO != null) { List<M_PatientRecordDrug> drug = new List<M_PatientRecordDrug>(); for (int l = 0; l < drugSCO.Count; l++) { M_PatientRecordDrug DInfo = drugSCO[l]; I_Material c = (from m in db.I_Material where m.ID == DInfo.DrugCode select m).FirstOrDefault(); DInfo.TaskCode = DInfo.TaskCode; DInfo.PatientOrder = DInfo.PatientOrder; DInfo.RescueRecordCode = RescueRecordCode; DInfo.DisposeOrder = DInfo.DisposeOrder;//处理序号 DInfo.DrugCode = c.ID; DInfo.DrugName = c.Name; DInfo.GiveMedicineWay = DInfo.GiveMedicineWay; string ChargeWay = ""; string RealPrice = Decimal.Round(decimal.Parse(c.RealPrice.ToString()), 2, MidpointRounding.AwayFromZero).ToString(); if (c.FeeScale > 1) { ChargeWay = RealPrice + "元/" + "1-" + c.FeeScale + c.TDictionary2.Name; } else { ChargeWay = RealPrice + "元/" + c.TDictionary2.Name; } DInfo.ChargeWay = ChargeWay;//收费方式 DInfo.Specifications = c.Specification;//规格 DInfo.Unit = c.TDictionary2.Name;//单位 DInfo.Dosage = DInfo.Dosage;//用量 DInfo.Price = c.RealPrice;//单价 int FeeScale = c.FeeScale == null ? 1 : Convert.ToInt32(c.FeeScale); int Dosage = 1; if (Convert.ToInt32(DInfo.Dosage) % FeeScale > 0) { Dosage = Convert.ToInt32(Math.Round(Convert.ToDouble(DInfo.Dosage / FeeScale), 0)) + 1; } else { Dosage = Convert.ToInt32(Math.Round(Convert.ToDouble(DInfo.Dosage / FeeScale), 0)); } DInfo.TotalPrice = c.RealPrice * Dosage;//合计金额 DInfo.TotalDose = DInfo.TotalDose;//合计用量 DInfo.Remark = DInfo.Remark;//备注 DInfo.SelectOrder = l + 1;//选择序号 DInfo.FeeScale = c.FeeScale; drug.Add(DInfo); //db.M_PatientRecordDrug.Add(DInfo);//插入药品子表 } db.M_PatientRecordDrug.AddRange(drug);//插入药品子表 } if (sanitationSCO != null) { List<M_PatientRecordSanitation> sanitation = new List<M_PatientRecordSanitation>(); for (int k = 0; k < sanitationSCO.Count; k++) { M_PatientRecordSanitation SInfo = sanitationSCO[k]; //M_PatientRecordSanitation SInfo = null; I_Material c = (from m in db.I_Material where m.ID == SInfo.SanitationCode select m).FirstOrDefault(); SInfo.TaskCode = SInfo.TaskCode; SInfo.PatientOrder = SInfo.PatientOrder; SInfo.RescueRecordCode = RescueRecordCode; SInfo.DisposeOrder = SInfo.DisposeOrder;//处理序号 SInfo.SanitationCode = c.ID; SInfo.SanitationName = c.Name; SInfo.NumberOfTimes = SInfo.NumberOfTimes;//次数 SInfo.Price = c.RealPrice; SInfo.TotalPrice = c.RealPrice * SInfo.NumberOfTimes;//合计金额 SInfo.ChargeWay = Decimal.Round(decimal.Parse(c.RealPrice.ToString()), 2, MidpointRounding.AwayFromZero) + "元/" + c.TDictionary2.Name;//收费方式 SInfo.SelectOrder = k + 1; sanitation.Add(SInfo); } db.M_PatientRecordSanitation.AddRange(sanitation);//插入耗材子表 } if (lossDrugSCO != null) { List<M_PatientRecordLossDrug> lossDrug = new List<M_PatientRecordLossDrug>(); for (int k = 0; k < lossDrugSCO.Count; k++) { M_PatientRecordLossDrug SInfo = lossDrugSCO[k]; I_Material c = (from m in db.I_Material where m.ID == SInfo.DrugCode select m).FirstOrDefault(); SInfo.TaskCode = SInfo.TaskCode; SInfo.PatientOrder = SInfo.PatientOrder; SInfo.RescueRecordCode = RescueRecordCode; SInfo.DisposeOrder = SInfo.DisposeOrder; SInfo.DrugCode = c.ID; SInfo.DrugName = c.Name;//药品名称 SInfo.GiveMedicineWay = SInfo.GiveMedicineWay;//应该是空 string ChargeWay = ""; string RealPrice = Decimal.Round(decimal.Parse(c.RealPrice.ToString()), 2, MidpointRounding.AwayFromZero).ToString(); if (c.FeeScale > 1) { ChargeWay = RealPrice + "元/" + "1-" + c.FeeScale + c.TDictionary2.Name; } else { ChargeWay = RealPrice + "元/" + c.TDictionary2.Name; } SInfo.ChargeWay = ChargeWay;//收费方式 SInfo.Specifications = c.Specification;//规格 SInfo.Unit = c.TDictionary2.Name;//单位 SInfo.Dosage = SInfo.Dosage;//用量 SInfo.Price = c.RealPrice;//单价 SInfo.TotalPrice = c.RealPrice * SInfo.Dosage;//合计金额 SInfo.TotalDose = SInfo.TotalDose;//合计用量 SInfo.Remark = SInfo.Remark;//备注 SInfo.SelectOrder = k + 1; lossDrug.Add(SInfo); } db.M_PatientRecordLossDrug.AddRange(lossDrug);//插入损耗药品子表 } if (lossSanitationSCO != null) { List<M_PatientRecordLossSanitation> lossSanitation = new List<M_PatientRecordLossSanitation>(); for (int k = 0; k < lossSanitationSCO.Count; k++) { M_PatientRecordLossSanitation SInfo = lossSanitationSCO[k]; I_Material c = (from m in db.I_Material where m.ID == SInfo.SanitationCode select m).FirstOrDefault(); SInfo.TaskCode = SInfo.TaskCode; SInfo.PatientOrder = SInfo.PatientOrder; SInfo.RescueRecordCode = RescueRecordCode;//救治记录编码 SInfo.DisposeOrder = SInfo.DisposeOrder;//处理序号 SInfo.SanitationCode = c.ID; SInfo.SanitationName = c.Name; SInfo.NumberOfTimes = SInfo.NumberOfTimes;//次数 SInfo.Price = c.RealPrice; SInfo.ChargeWay = Decimal.Round(decimal.Parse(c.RealPrice.ToString()), 2, MidpointRounding.AwayFromZero) + "元/" + c.TDictionary2.Name;//收费方式 SInfo.TotalPrice = c.RealPrice * SInfo.NumberOfTimes;//合计金额 SInfo.Remark = SInfo.Remark; SInfo.SelectOrder = k + 1; lossSanitation.Add(SInfo); } db.M_PatientRecordLossSanitation.AddRange(lossSanitation);//插入损耗卫生材料子表 } } db.SaveChanges();//将在此上下文中所做的所有更改保存到基础数据库 tran.Commit(); //提交事务 //transaction.Complete();//这一句如果注释后,则上面的保存不会被提交到DB中 return true; } catch (Exception ex) { LogUtility.Error("M_PatientRecordDAL/InsertPRRescue()", ex.ToString()); if (tran != null) tran.Rollback(); //回滚事务 return false; } } }
public void GetPRRescueInfo(string taskCode, int patientOrder, string rescueRecordCode, int disposeOrder , out M_PatientRecordRescue prrInfo) { prrInfo = (from pi in db.M_PatientRecordRescue where pi.TaskCode == taskCode && pi.PatientOrder == patientOrder && pi.RescueRecordCode == rescueRecordCode && pi.DisposeOrder == disposeOrder select pi).FirstOrDefault();//救治记录主表 }
public string GetRescueRecordMaxCode(string taskCode, int patientOrder) { M_PatientRecordRescue pInfo = new M_PatientRecordRescue(); string RescueRecordCode = ""; var query = from pr in db.M_PatientRecordRescue where pr.TaskCode == taskCode && pr.PatientOrder == patientOrder select pr.RescueRecordCode; if (query.Count() > 0) RescueRecordCode = taskCode + (query.Count() + 1); else RescueRecordCode = taskCode + "1"; return RescueRecordCode; }
public bool UpdatePRRescue(M_PatientRecordRescue prrInfo, List<M_PatientRecordMeasure> measureSCO , List<M_PatientRecordDrug> drugSCO, List<M_PatientRecordSanitation> sanitationSCO , List<M_PatientRecordLossDrug> lossDrugSCO, List<M_PatientRecordLossSanitation> lossSanitationSCO) { using (var tran = db.Database.BeginTransaction()) { try { List<M_PatientRecordTrace> crackList = new List<M_PatientRecordTrace>();//病历修改记录 int j = 0;//病历修改记录主键 DateTime modifyTime = DateTime.Now;//修改时间 string modifyPerson = prrInfo.LastUpdatePerson;//修改人 M_PatientRecord PRoriginInfo = dalContext.IM_PatientRecordDAL.GetModelWithOutTrace(a => a.PatientOrder == prrInfo.PatientOrder && a.TaskCode == prrInfo.TaskCode); string RescueRecordCode = ""; var entry = db.Entry(prrInfo); bool origin = false; if (entry.State == EntityState.Detached) { M_PatientRecordRescue originInfo = dalContext.IM_PatientRecordRescueDAL.GetModelWithOutTrace(a => a.PatientOrder == prrInfo.PatientOrder && a.TaskCode == prrInfo.TaskCode && a.RescueRecordCode == prrInfo.RescueRecordCode); //如果已经被上下文追踪 if (originInfo != null) { origin = true; RescueRecordCode = originInfo.RescueRecordCode; prrInfo.RescueXFFSMouldChoose = originInfo.RescueXFFSMouldChoose;//心肺复苏模板选择 db.M_PatientRecordRescue.Attach(prrInfo);//将给定实体附加到集的基础上下文中,将实体以“未更改”的状态放置到上下文; db.Entry(prrInfo).State = EntityState.Modified; #region 提交病历后修改病历痕迹 int flag = 0;//病历状态:0.普通保存(还没有提交);1.提交;2.提交后的保存 //提交后保存的 if (PRoriginInfo != null) { if (PRoriginInfo.MedicalStateCode == 1) { flag = 2;//提交后的保存 #region 插入病历救治记录痕迹 //获得所有property的信息 PropertyInfo[] proOrigin = originInfo.GetType().GetProperties(); PropertyInfo[] proNew = prrInfo.GetType().GetProperties(); for (int i = 0; i < proOrigin.Length; i++) { object obj1 = proOrigin[i].GetValue(originInfo, null); object obj2 = proOrigin[i].GetValue(prrInfo, null); obj1 = obj1 == null ? "" : obj1; obj2 = obj2 == null ? "" : obj2; if (!obj1.Equals(obj2) && proOrigin[i].Name != "MeasureCodes" && proOrigin[i].Name != "DrugCodes" && proOrigin[i].Name != "SanitationCodes" && proOrigin[i].Name != "LossDrugCodes" && proOrigin[i].Name != "LossSanitationCodes") { j = j + 1; M_PatientRecordTrace crackInfo = new M_PatientRecordTrace(); var query = from a in db.M_PatientRecordTrace select a.ID; if (query.Count() > 0 && j == 1) { crackInfo.ID = query.Max() + 1; j = crackInfo.ID; } else if (j > 1) { crackInfo.ID = j; } else { crackInfo.ID = 1; } crackInfo.ModifyTime = modifyTime;//修改时间 crackInfo.ModifyPerson = modifyPerson;//修改人 crackInfo.TaskCode = prrInfo.TaskCode;//任务编码 crackInfo.PatientOrder = prrInfo.PatientOrder;//序号 crackInfo.ModifyItem = GetDescriptionByTableName("M_PatientRecordRescue", proOrigin[i].Name);//修改项 crackInfo.OriginalValue = obj1.ToString();//原值 crackInfo.NewValue = obj2.ToString();//新值 crackInfo.OwnershipType = 5; crackList.Add(crackInfo); } } #endregion } } #endregion } } if (prrInfo != null && origin == true) { #region 修改救治措施子表 var dqry0 = from infos in db.M_PatientRecordMeasure where infos.TaskCode == prrInfo.TaskCode && infos.PatientOrder == prrInfo.PatientOrder && infos.RescueRecordCode == prrInfo.RescueRecordCode select infos; foreach (var inf in dqry0) db.M_PatientRecordMeasure.Remove(inf);//删除救治措施子表 if (measureSCO != null) { List<M_PatientRecordMeasure> measure = new List<M_PatientRecordMeasure>(); for (int k = 0; k < measureSCO.Count; k++) { M_PatientRecordMeasure SInfo = measureSCO[k]; //M_PatientRecordMeasure MeasureInfo = measureSCO[k]; I_Material c = (from m in db.I_Material where m.ID == SInfo.RescueMeasureCode select m).FirstOrDefault(); SInfo.TaskCode = SInfo.TaskCode; SInfo.PatientOrder = SInfo.PatientOrder; SInfo.RescueRecordCode = RescueRecordCode;//救治记录编码 SInfo.DisposeOrder = SInfo.DisposeOrder;//处理序号 SInfo.RescueMeasureCode = c.ID;//救治措施编码 SInfo.RescueMeasureName = c.Name;//救治措施 SInfo.OtherTypeID = c.OtherTypeID;// SInfo.NumberOfTimes = SInfo.NumberOfTimes;//次数 SInfo.Price = c.RealPrice;//单价 int FeeScale = c.FeeScale == null ? 1 : Convert.ToInt32(c.FeeScale); int Dosage = 1; if (FeeScale == -1) { Dosage = 1; } else if (FeeScale == 1) { Dosage = Convert.ToInt32(SInfo.NumberOfTimes); } else { if (FeeScale < 0 && (-FeeScale <= Convert.ToInt32(SInfo.NumberOfTimes))) { Dosage = -FeeScale; } else { Dosage = Convert.ToInt32(SInfo.NumberOfTimes); } } SInfo.TotalPrice = c.RealPrice * Dosage;//合计金额 SInfo.ChargeWay = Decimal.Round(decimal.Parse(c.RealPrice.ToString()), 2, MidpointRounding.AwayFromZero) + "元/" + c.TDictionary2.Name;//收费方式 SInfo.Remark = SInfo.Remark; SInfo.SelectOrder = k + 1; measure.Add(SInfo); //measureSCO.Add(SInfo); //db.M_PatientRecordMeasure.Add(SInfo);//插入救治措施子表 } db.M_PatientRecordMeasure.AddRange(measure);//插入救治措施子表 } #endregion #region 修改药品子表 var dqry1 = from infos in db.M_PatientRecordDrug where infos.TaskCode == prrInfo.TaskCode && infos.PatientOrder == prrInfo.PatientOrder && infos.RescueRecordCode == prrInfo.RescueRecordCode select infos; foreach (var inf in dqry1) db.M_PatientRecordDrug.Remove(inf);//删除药品子表 if (drugSCO != null) { List<M_PatientRecordDrug> drug = new List<M_PatientRecordDrug>(); for (int l = 0; l < drugSCO.Count; l++) { M_PatientRecordDrug DInfo = drugSCO[l]; I_Material c = (from m in db.I_Material where m.ID == DInfo.DrugCode select m).FirstOrDefault(); DInfo.TaskCode = DInfo.TaskCode; DInfo.PatientOrder = DInfo.PatientOrder; DInfo.RescueRecordCode = RescueRecordCode; DInfo.DisposeOrder = DInfo.DisposeOrder;//处理序号 DInfo.DrugCode = c.ID; DInfo.DrugName = c.Name; DInfo.GiveMedicineWay = DInfo.GiveMedicineWay; string ChargeWay = ""; string RealPrice = Decimal.Round(decimal.Parse(c.RealPrice.ToString()), 2, MidpointRounding.AwayFromZero).ToString(); if (c.FeeScale > 1) { ChargeWay = RealPrice + "元/" + "1-" + c.FeeScale + c.TDictionary2.Name; } else { ChargeWay = RealPrice + "元/" + c.TDictionary2.Name; } DInfo.ChargeWay = ChargeWay;//收费方式 DInfo.Specifications = c.Specification;//规格 DInfo.Unit = c.TDictionary2.Name;//单位 DInfo.Dosage = DInfo.Dosage;//用量 DInfo.Price = c.RealPrice;//单价 int FeeScale = c.FeeScale == null ? 1 : Convert.ToInt32(c.FeeScale); int Dosage = 1; if (Convert.ToInt32(DInfo.Dosage) % FeeScale > 0) { Dosage = Convert.ToInt32(Math.Round(Convert.ToDouble(DInfo.Dosage / FeeScale), 0)) + 1; } else { Dosage = Convert.ToInt32(Math.Round(Convert.ToDouble(DInfo.Dosage / FeeScale), 0)); } DInfo.TotalPrice = c.RealPrice * Dosage;//合计金额 DInfo.TotalDose = DInfo.TotalDose;//合计用量 DInfo.Remark = DInfo.Remark;//备注 DInfo.SelectOrder = l + 1;//选择序号 DInfo.FeeScale = c.FeeScale; drug.Add(DInfo); //db.M_PatientRecordDrug.Add(DInfo);//插入药品子表 } db.M_PatientRecordDrug.AddRange(drug);//插入药品子表 } #endregion #region 修改耗材子表 var dqry2 = from infos in db.M_PatientRecordSanitation where infos.TaskCode == prrInfo.TaskCode && infos.PatientOrder == prrInfo.PatientOrder && infos.RescueRecordCode == prrInfo.RescueRecordCode select infos; foreach (var inf in dqry2) db.M_PatientRecordSanitation.Remove(inf);//删除耗材子表 if (sanitationSCO != null) { List<M_PatientRecordSanitation> sanitation = new List<M_PatientRecordSanitation>(); for (int k = 0; k < sanitationSCO.Count; k++) { M_PatientRecordSanitation SInfo = sanitationSCO[k]; //M_PatientRecordSanitation SInfo = null; I_Material c = (from m in db.I_Material where m.ID == SInfo.SanitationCode select m).FirstOrDefault(); SInfo.TaskCode = SInfo.TaskCode; SInfo.PatientOrder = SInfo.PatientOrder; SInfo.RescueRecordCode = RescueRecordCode; SInfo.DisposeOrder = SInfo.DisposeOrder;//处理序号 SInfo.SanitationCode = c.ID; SInfo.SanitationName = c.Name; SInfo.NumberOfTimes = SInfo.NumberOfTimes;//次数 SInfo.Price = c.RealPrice; SInfo.TotalPrice = c.RealPrice * SInfo.NumberOfTimes;//合计金额 SInfo.ChargeWay = Decimal.Round(decimal.Parse(c.RealPrice.ToString()), 2, MidpointRounding.AwayFromZero) + "元/" + c.TDictionary2.Name;//收费方式 SInfo.SelectOrder = k + 1; sanitation.Add(SInfo); } db.M_PatientRecordSanitation.AddRange(sanitation);//插入耗材子表 } #endregion #region 修改损耗药品子表 var dqry3 = from infos in db.M_PatientRecordLossDrug where infos.TaskCode == prrInfo.TaskCode && infos.PatientOrder == prrInfo.PatientOrder && infos.RescueRecordCode == prrInfo.RescueRecordCode select infos; foreach (var inf in dqry3) db.M_PatientRecordLossDrug.Remove(inf);//删除损耗药品子表 if (lossDrugSCO != null) { List<M_PatientRecordLossDrug> lossDrug = new List<M_PatientRecordLossDrug>(); for (int k = 0; k < lossDrugSCO.Count; k++) { M_PatientRecordLossDrug SInfo = lossDrugSCO[k]; I_Material c = (from m in db.I_Material where m.ID == SInfo.DrugCode select m).FirstOrDefault(); SInfo.TaskCode = SInfo.TaskCode; SInfo.PatientOrder = SInfo.PatientOrder; SInfo.RescueRecordCode = RescueRecordCode; SInfo.DisposeOrder = SInfo.DisposeOrder; SInfo.DrugCode = c.ID; SInfo.DrugName = c.Name;//药品名称 SInfo.GiveMedicineWay = SInfo.GiveMedicineWay;//应该是空 string ChargeWay = ""; string RealPrice = Decimal.Round(decimal.Parse(c.RealPrice.ToString()), 2, MidpointRounding.AwayFromZero).ToString(); if (c.FeeScale > 1) { ChargeWay = RealPrice + "元/" + "1-" + c.FeeScale + c.TDictionary2.Name; } else { ChargeWay = RealPrice + "元/" + c.TDictionary2.Name; } SInfo.ChargeWay = ChargeWay;//收费方式 SInfo.Specifications = c.Specification;//规格 SInfo.Unit = c.TDictionary2.Name;//单位 SInfo.Dosage = SInfo.Dosage;//用量 SInfo.Price = c.RealPrice;//单价 SInfo.TotalPrice = c.RealPrice * SInfo.Dosage;//合计金额 SInfo.TotalDose = SInfo.TotalDose;//合计用量 SInfo.Remark = SInfo.Remark;//备注 SInfo.SelectOrder = k + 1; lossDrug.Add(SInfo); } db.M_PatientRecordLossDrug.AddRange(lossDrug);//插入损耗药品子表 } #endregion #region 修改损耗药品子表 var dqry4 = from infos in db.M_PatientRecordLossSanitation where infos.TaskCode == prrInfo.TaskCode && infos.PatientOrder == prrInfo.PatientOrder && infos.RescueRecordCode == prrInfo.RescueRecordCode select infos; foreach (var inf in dqry4) db.M_PatientRecordLossSanitation.Remove(inf);//删除损耗药品子表 if (lossSanitationSCO != null) { List<M_PatientRecordLossSanitation> lossSanitation = new List<M_PatientRecordLossSanitation>(); for (int k = 0; k < lossSanitationSCO.Count; k++) { M_PatientRecordLossSanitation SInfo = lossSanitationSCO[k]; I_Material c = (from m in db.I_Material where m.ID == SInfo.SanitationCode select m).FirstOrDefault(); SInfo.TaskCode = SInfo.TaskCode; SInfo.PatientOrder = SInfo.PatientOrder; SInfo.RescueRecordCode = RescueRecordCode;//救治记录编码 SInfo.DisposeOrder = SInfo.DisposeOrder;//处理序号 SInfo.SanitationCode = c.ID; SInfo.SanitationName = c.Name; SInfo.NumberOfTimes = SInfo.NumberOfTimes;//次数 SInfo.Price = c.RealPrice; SInfo.ChargeWay = Decimal.Round(decimal.Parse(c.RealPrice.ToString()), 2, MidpointRounding.AwayFromZero) + "元/" + c.TDictionary2.Name;//收费方式 SInfo.TotalPrice = c.RealPrice * SInfo.NumberOfTimes;//合计金额 SInfo.Remark = SInfo.Remark; SInfo.SelectOrder = k + 1; lossSanitation.Add(SInfo); } db.M_PatientRecordLossSanitation.AddRange(lossSanitation);//插入损耗卫生材料子表 } #endregion } db.SaveChanges();//将在此上下文中所做的所有更改保存到基础数据库 tran.Commit(); //提交事务 return true; } catch (Exception ex) { LogUtility.Error("M_PatientRecordDAL/UpdatePRRescue()", ex.ToString()); if (tran != null) tran.Rollback(); //回滚事务 return false; } } }