public void Query() { dataLayoutControl1.Validate(); T_JCXX_DAL dal = new T_JCXX_DAL(); List <T_YH> yhList = null; var dataEntities = new List <DataEntity>(); var sqlFilter = sqlFilterBindingSource.Current as SqlFilter; SplashScreenManager.ShowDefaultWaitForm($"正在查询"); try { string sqlCg = " select f_bgys bgys,f_fzys fzys from [dbo].[T_JCXX] t where F_BZ like '疑难病例' "; string sqlBc = "select f_bc_bgys bgys,F_BC_FZYS fzys from [dbo].[T_BCBG] bc inner join t_jcxx t on t.f_blh=bc.f_blh where F_BC_BZ like '疑难病例' and F_BC_BGXH='1' "; string sqlWhereBc = ""; string sqlWhereCg = ""; if (sqlFilter.Blk != null && (sqlFilter.Blk != "全部" && sqlFilter.Blk != "")) { sqlWhereCg += $" and t.f_blk='{sqlFilter.Blk}' "; sqlWhereBc += $" and t.f_blk='{sqlFilter.Blk}' "; } if (sqlFilter.Sdrq1.HasValue) { //收到日期 sqlWhereBc += $" and CONVERT(datetime,t.f_sdrq) >= CONVERT(datetime,'{sqlFilter.Sdrq1.Value.Date}') "; sqlWhereCg += $" and CONVERT(datetime,t.f_sdrq) >= CONVERT(datetime,'{sqlFilter.Sdrq1.Value.Date}') "; } if (sqlFilter.Sdrq2.HasValue) { sqlWhereBc += $" and CONVERT(datetime,t.f_sdrq) <=CONVERT(datetime,'{sqlFilter.Sdrq2.Value.Date.AddDays(1)}') "; sqlWhereCg += $" and CONVERT(datetime,t.f_sdrq) <=CONVERT(datetime,'{sqlFilter.Sdrq2.Value.Date.AddDays(1)}') "; } //如果输入医生姓名,取单一的医生姓名,否则取用户列表 if (!string.IsNullOrEmpty(sqlFilter.医生姓名)) { yhList = new List <T_YH>(); yhList.Add(new T_YH() { F_YHMC = sqlFilter.医生姓名 }); } else { yhList = T_YH_DAL.GetList(""); } var dtCg = CommonDAL.GetTableBySql(sqlCg + sqlWhereCg); var dtBc = CommonDAL.GetTableBySql(sqlBc + sqlWhereBc); var dtCgEnumerable = dtCg.Rows.Cast <DataRow>().ToList(); var dtBcEnumerable = dtBc.Rows.Cast <DataRow>().ToList(); foreach (T_YH yh in yhList) { DataEntity entity = new DataEntity(); entity.医生姓名 = yh.F_YHMC; entity.常规初诊 = dtCgEnumerable.Count(dr => dr["bgys"].ToString().Contains(yh.F_YHMC)); entity.常规复诊 = dtCgEnumerable.Count(dr => dr["fzys"].ToString().Contains(yh.F_YHMC) && dr["bgys"].ToString().Contains(yh.F_YHMC) == false); entity.补充初诊 = dtBcEnumerable.Count(dr => dr["bgys"].ToString().Contains(yh.F_YHMC)); entity.补充复诊 = dtBcEnumerable.Count(dr => dr["fzys"].ToString().Contains(yh.F_YHMC) && dr["bgys"].ToString().Contains(yh.F_YHMC) == false); if (entity.常规初诊 + entity.常规复诊 + entity.补充初诊 + entity.补充复诊 > 0) { dataEntities.Add(entity); } } } catch (Exception exception) { MessageBox.Show(exception.ToString()); return; } finally { try { SplashScreenManager.CloseDefaultWaitForm(); } catch { } } if (dataEntities.Any() == false) { XtraMessageBox.Show("没有找到任何结果!"); } tJCXXBindingSource.DataSource = dataEntities; gridView1.RefreshData(); gridView1.ExpandAllGroups(); gridView1.BestFitColumns(); }
public void Query() { dataLayoutControl1.Validate(); T_JCXX_DAL dal = new T_JCXX_DAL(); List <T_YH> yhList = null; var dataEntities = new List <DataEntity>(); var sqlFilter = sqlFilterBindingSource.Current as SqlFilter; SplashScreenManager.ShowDefaultWaitForm($"正在查询"); try { string sqlCg = " select f_bgys bgys,f_fzys fzys from [dbo].[T_JCXX] t where F_BZ like '疑难病例' "; string sqlWhereCg = ""; string sqlQC = "select t.F_QCYS qcys,count(distinct t.f_blh) lishu,count(*) heshu from t_jcxx t left join T_QCMX q on t.F_BLH=q.F_BLH "; string sqlWhereQc = " where 1=1 "; string sqlGroupQc = " group by t.F_QCYS "; if (sqlFilter.Blk != null && (sqlFilter.Blk != "全部" && sqlFilter.Blk != "")) { sqlWhereCg += $" and t.f_blk='{sqlFilter.Blk}' "; sqlWhereQc += $" and t.f_blk='{sqlFilter.Blk}' "; } if (sqlFilter.Sdrq1.HasValue) { //收到日期 sqlWhereCg += $" and CONVERT(datetime,t.f_sdrq) >= CONVERT(datetime,'{sqlFilter.Sdrq1.Value.Date}') "; sqlWhereQc += $" and CONVERT(datetime,t.f_sdrq) >= CONVERT(datetime,'{sqlFilter.Sdrq1.Value.Date}') "; } if (sqlFilter.Sdrq2.HasValue) { sqlWhereCg += $" and CONVERT(datetime,t.f_sdrq) <=CONVERT(datetime,'{sqlFilter.Sdrq2.Value.Date.AddDays(1)}') "; sqlWhereQc += $" and CONVERT(datetime,t.f_sdrq) <=CONVERT(datetime,'{sqlFilter.Sdrq2.Value.Date.AddDays(1)}') "; } //如果输入医生姓名,取单一的医生姓名,否则取用户列表 if (!string.IsNullOrEmpty(sqlFilter.医生姓名)) { yhList = new List <T_YH>(); yhList.Add(new T_YH() { F_YHMC = sqlFilter.医生姓名 }); } else { yhList = T_YH_DAL.GetList(""); } var dtCg = CommonDAL.GetTableBySql(sqlCg + sqlWhereCg); var dtQc = CommonDAL.GetTableBySql(sqlQC + sqlWhereQc + sqlGroupQc); var dtCgEnumerable = dtCg.Rows.Cast <DataRow>().ToList(); var dtQcEnumerable = dtQc.Rows.Cast <DataRow>().ToList(); foreach (T_YH yh in yhList) { DataEntity entity = new DataEntity(); entity.医生姓名 = yh.F_YHMC; entity.常规初诊 = dtCgEnumerable.Count(dr => dr["bgys"].ToString().Contains(yh.F_YHMC)); entity.常规复诊 = dtCgEnumerable.Count(dr => dr["fzys"].ToString().Contains(yh.F_YHMC) && dr["bgys"].ToString().Contains(yh.F_YHMC) == false); object lishu = dtQcEnumerable.SingleOrDefault(dr => dr["qcys"].ToString() == yh.F_YHMC)?["lishu"]; if (lishu != null) { entity.取材_例 = (int)lishu; } object heshu = dtQcEnumerable.SingleOrDefault(dr => dr["qcys"].ToString() == yh.F_YHMC)?["heshu"]; if (heshu != null) { entity.取材_盒 = (int)heshu; } if (entity.常规初诊 + entity.常规复诊 + entity.取材_例 + entity.取材_盒 > 0) { dataEntities.Add(entity); } } } catch (Exception exception) { MessageBox.Show(exception.ToString()); return; } finally { try { SplashScreenManager.CloseDefaultWaitForm(); } catch { } } if (dataEntities.Any() == false) { XtraMessageBox.Show("没有找到任何结果!"); } tJCXXBindingSource.DataSource = dataEntities; gridView1.RefreshData(); gridView1.ExpandAllGroups(); gridView1.BestFitColumns(); }