/// <summary> /// 初始化数据 --- 病种列表 /// </summary> /// <auth>Yanqiao.Cai</auth> /// <date>2012-12-28</date> private void InitData() { try { //获取所有病种列表 DataTable dt = DS_SqlService.GetDiagnosis(); dt.Columns.Add(new DataColumn("FLAG", typeof(bool))); DataRow[] listArry = dt.Select(" 1=1 "); if (allSource.Rows.Count == 0) { allSource = listArry.Length == 0 ? new DataTable() : listArry.CopyToDataTable(); } string searchStr = this.txt_search.Text.ToUpper(); if (groupID == -1) {//新增 foreach (DataRow dr in listArry) { dr["FLAG"] = false; } notCheckedList = listArry.ToList(); } else {//编辑 DataTable thisGroupDt = DS_SqlService.GetDiseaseGroupByID(groupID); if (null == thisGroupDt || thisGroupDt.Rows.Count == 0) { return; } this.txt_groupName.Text = null == thisGroupDt.Rows[0]["NAME"] ? "" : thisGroupDt.Rows[0]["NAME"].ToString(); this.txt_memo.Text = null == thisGroupDt.Rows[0]["MEMO"] ? "" : thisGroupDt.Rows[0]["MEMO"].ToString(); List <string> idList = thisGroupDt.Rows[0]["diseaseids"].ToString().Split('$').ToList(); checkedList.Clear(); notCheckedList.Clear(); //已勾选项 不过滤 var checkedEnu = listArry.Where(p => null != p["ICD"] && idList.Contains(p["ICD"].ToString())).OrderBy(q => q["NAME"]); foreach (DataRow dr in checkedEnu) { dr["FLAG"] = true; checkedList.Add(dr); } //对未勾选项进行过滤 var notCheckedEnu = listArry.Where(p => null != p["ICD"] && !idList.Contains(p["ICD"].ToString()) && (p["ICD"].ToString().Contains(searchStr) || p["NAME"].ToString().Contains(searchStr) || p["PY"].ToString().Contains(searchStr) || p["WB"].ToString().Contains(searchStr))).OrderBy(q => q["NAME"]); foreach (DataRow dr in notCheckedEnu) { dr["FLAG"] = false; notCheckedList.Add(dr); } RefreshDiseaseTextArea(); } DataTable endDt = checkedList.Union(notCheckedList).CopyToDataTable(); defaultSource = endDt.Copy(); this.gridControl_disease.DataSource = endDt; } catch (Exception ex) { throw new Exception(ex.Message); } }