public md_dr_account CreateAccount(md_dr_account info, out string error) { error = string.Empty; try { db.md_dr_account.Add(info); db.SaveChanges(); return info; } catch (System.Data.Entity.Validation.DbEntityValidationException ex) { error = Share.BaseTool.FormatExceptionMessage(ex); return null; } }
/// <summary> /// 添加医生明细信息 /// </summary> /// <param name="info"></param> /// <param name="error"></param> /// <returns></returns> public md_dr_account CreateAccount(md_dr_account info, out string error) { error = string.Empty; try { md_account_DA da = new md_account_DA(); da.CreateAccount(info, out error); return info; } catch (Exception ex) { error += Share.BaseTool.FormatExceptionMessage(ex); return null; } }
public ActionResult UpdateCashdrawList(string idstr) { if (!string.IsNullOrEmpty(idstr)) { var str = idstr.TrimEnd(','); md_cashdraw_app_Bll cashdrawBll = new md_cashdraw_app_Bll(); md_docter_Bll doctorBll = new md_docter_Bll(); List<md_cashdraw_app> cashdrawlist = cashdrawBll.GetCashdrawByIds(str); string error = string.Empty; foreach (var item in cashdrawlist) { item.opstatus = (int)Model.ConfigClass.CashdrawStatus.已处理; ///批注By Andy:更新一次就调用一次数据库连接,对数据库性能有影响,建议传入需要更新的ids,用update语句一次执行 } cashdrawBll.UpdateChashdrawList(cashdrawlist, out error); var doctorids = cashdrawlist.Select(m => m.drid).Distinct().ToList(); var doctorlist = doctorBll.GetDoctorByIds(doctorids); List<md_docter> doctors = new List<md_docter>(); List<md_dr_account> dr_accountlist = new List<md_dr_account>(); foreach (var item in doctorlist) { var list = cashdrawlist.Where(m => m.drid == item.pkid.ToString()).ToList(); if (list.Any()) { var money = list.Select(m => m.drawmoney).Sum(); item.current_income -= money; doctors.Add(item); md_dr_account accountinfo = new md_dr_account(); accountinfo.Initial(); accountinfo.dr_id = item.pkid; accountinfo.income_type = 0; accountinfo.money = money; dr_accountlist.Add(accountinfo); } } if (doctors.Any()) { doctorBll.UpdateChashdrawList(doctors, out error); } if (dr_accountlist.Any()) { new md_account_Bll().CreateAccountList(dr_accountlist, out error); } } return View(); }