1. 设置表格的表头
C1FlexGrid flgView = new C1FlexGrid();
/// <summary>
/// 表头设置
/// </summary>
private void SetTable()
{
flgView.Cols.Count = 38;
flgView.Rows.Count = 2;
// 设置固定行
flgView.Rows.Fixed = 2;
// 格式不清除,翻页后表格显示格式将异常
flgView.MergedRanges.Clear();
}
2. 呈现数据
/// <summary>
/// 显示交接班报告区
/// </summary>
internal void Handovers_ShowDate()
{
SetTable();
try
{
// 查询交班记录中当天所有记录
// 查询不重复的病人号
// 整合整个表格的显示,同一病人的多行数据,其中第一列进行合并
string sql1 = string.Format(@"select t.*,p.patient_name,p.gender_code,p.age,p.age_unit,b.bed_no,p.in_time from t_handovers_records_icu t
inner join t_in_patient p on t.patient_id=p.id inner join t_sickbedinfo b on p.sick_bed_id = b.bed_id where t.measure_time
like '%{0}%' and Sickarea_name='{1}' order by t.patient_id,t.measure_time", dtpDate.Value.ToString("yyyy-MM-dd"),
App.UserAccount.CurrentSelectRole.Sickarea_name);
DataSet dsHandoversRecord = App.GetDataSet(sql1);
if (dsHandoversRecord == null || dsHandoversRecord.Tables[0].Rows.Count == 0)
{
goto Cell;
}
string sql2 = string.Format(@"select distinct(t.patient_id) from t_handovers_records_icu t
where t.measure_time like '%{0}%' and Sickarea_name='{1}'", dtpDate.Value.ToString("yyyy-MM-dd"),
App.UserAccount.CurrentSelectRole.Sickarea_name);
DataSet dsPids = App.GetDataSet(sql2);
DataTable dtRecord = dsHandoversRecord.Tables[0];
DataTable dtPid = dsPids.Tables[0];
foreach (DataRow drPid in dtPid.Rows)
{
int min = 0;
int max = 0;
DataRow[] rows = dtRecord.Select("patient_id=" + drPid["patient_id"]);
for (int i = 0; i < rows.Length; i++)
{
Row c1Row = flgView.Rows.Add();
if (i == 0)
{
min = c1Row.Index; // 新增行的小行号
}
if (i == rows.Length - 1)
{
max = c1Row.Index; // 新增行的大行号
}
c1Row[1] = rows[i]["CLASS_COUNT"]; // 班次
c1Row[2] = rows[i]["IN_TIME"]; // 入院时间
c1Row[3] = rows[i]["WARM_BOX"]; // 暖箱
c1Row[4] = rows[i]["TEMPERATURE"]; // 体温
c1Row[5] = rows[i]["PULSE"]; // 脉搏
c1Row[6] = rows[i]["BREATH"]; // 呼吸
c1Row[7] = rows[i]["BLOOD_PRESSURE"]; // 血压
c1Row[8] = rows[i]["SPO2"]; // SPO2
c1Row[9] = rows[i]["OXYGEN_WAY"]; // 吸氧方式
c1Row[10] = rows[i]["OXYGEN_FLOW"]; // 氧流量
c1Row[11] = rows[i]["MIND"]; // 神志
c1Row[12] = rows[i]["SPIRIT_REACTION"]; // 精神反应
c1Row[13] = rows[i]["PUPIL"]; // 瞳孔
c1Row[14] = rows[i]["COMPLEXION"]; // 面色
c1Row[15] = rows[i]["COUGH"]; // 咳喘
c1Row[16] = rows[i]["VOMIT"]; // 呕吐
c1Row[17] = rows[i]["TWITCH"]; // 抽搐
c1Row[18] = rows[i]["SKIN"]; // 皮肤
c1Row[19] = rows[i]["ABDOMINAL"]; // 腹部
c1Row[20] = rows[i]["UMBILICAL"]; // 脐部
c1Row[21] = rows[i]["HIP"]; // 臀部
c1Row[22] = rows[i]["DIET"]; // 饮食
c1Row[23] = rows[i]["SHIT"]; // 大便
c1Row[24] = rows[i]["URINATE"]; // 小便
c1Row[25] = rows[i]["FUKE"]; // 敷科
// 导管护理 (胃管26,尿管27,引流管28,其他29)
string sTemp = rows[i]["NURSING_CATHETERS"].ToString();
if (sTemp.Length != 0)
{
string[] strs = sTemp.Split(';');
foreach (string s in strs)
{
string str = "";
if (s.Contains("胃管"))
{
str = s.Substring(s.IndexOf("胃管") + 3);
c1Row[26] = str;
}
else if (s.Contains("尿管"))
{
str = s.Substring(s.IndexOf("尿管") + 3);
c1Row[27] = str;
}
else if (s.Contains("引流"))
{
str = s.Substring(s.IndexOf("引流") + 3);
c1Row[28] = str;
}
else
{
c1Row[29] = s;
}
}
}
else
{
c1Row[26] = "";
c1Row[27] = "";
c1Row[28] = "";
c1Row[29] = "";
}
c1Row[30] = rows[i]["OXYGEN_CONCENTRATION"]; // 氧浓度
c1Row[31] = rows[i]["BREATH_FREQUENCY"]; // 呼吸频率
c1Row[32] = rows[i]["BREATHE_TIME"]; // 吸气时间
c1Row[33] = rows[i]["CPAP"]; // CPAP
c1Row[34] = rows[i]["PEEP"]; // PEEP
c1Row[35] = rows[i]["PIP"]; // PIP
c1Row[36] = rows[i]["STATUS_MEASURE"]; // 病情及处理
c1Row[37] = rows[i]["ID"]; // 主表ID列
}
// 合并表格的第一列数据(床号,姓名,性别,年龄,诊断)
string sBedNo = rows[0]["bed_no"].ToString();
string sName = rows[0]["patient_name"].ToString();
string sSex = rows[0]["gender_code"].ToString().Equals("0") ? "男" : "女";
string sAge = rows[0]["age"].ToString() + rows[0]["age_unit"].ToString();
string sqlDiagnose = string.Format(@"select t.diagnose_name from t_diagnose_item t where t.patient_id ={0} and t.diagnose_type=403 order by t.create_time", drPid["patient_id"].ToString());
string sDiagnose = App.ReadSqlVal(sqlDiagnose, 0, "diagnose_name");
C1.Win.C1FlexGrid.CellRange cr = flgView.GetCellRange(min, 0, max, 0);
cr.Data = string.Format("{0}\n{1}\n{2}", sBedNo + " " + sName, sSex + " " + sAge, sDiagnose);
cr.StyleNew.TextAlign = TextAlignEnum.LeftCenter;
flgView.MergedRanges.Add(cr);
}
}
catch (Exception ex)
{
MessageBox.Show("出错了,原因是:" + ex.Message);
}
Cell:
CellUnit();
}
3. 单元格合并,设置字体居中模式
/// <summary>
/// 交接班报告区单元格合并和设置
/// </summary>
private void CellUnit()
{
flgView.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Custom;
flgView.Cols.Fixed = 0;
#region 设置表头单元格合并及文字
C1.Win.C1FlexGrid.CellRange cr;
cr = flgView.GetCellRange(0, 0, 1, 0);
cr.Data = "床号\n姓名\n性别\n年龄\n诊断";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 1, 1, 1);
cr.Data = "班" + "\r\n" + "次";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 2, 1, 2);
cr.Data = "入" + "\r\n" + "院" + "\r\n" + "时" + "\r\n" + "间";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 3, 1, 3);
cr.Data = "暖\n箱";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 4, 0, 7);
cr.Data = "生命体征";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(1, 4, 1, 4);
cr.Data = "T\n℃";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(1, 5, 1, 5);
cr.Data = "P" + "\r\n" + "次" + "\r\n" + "/" + "\r\n" + "分";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(1, 6, 1, 6);
cr.Data = "R" + "\r\n" + "次" + "\r\n" + "/" + "\r\n" + "分";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(1, 7, 1, 7);
cr.Data = "BP" + "\r\n" + "mm" + "\r\n" + "Hg";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 8, 1, 8);
cr.Data = "SPO\n2%";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 9, 1, 9);
cr.Data = "吸\n氧\n方\n式"; ;
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 10, 1, 10);
cr.Data = "氧\n流\n量\nml/\n分";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 11, 1, 11);
cr.Data = "神\n志";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 12, 1, 12);
cr.Data = "精\n神\n反\n应";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 13, 1, 13);
cr.Data = "瞳\n孔";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 14, 1, 14);
cr.Data = "面\n色";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 15, 1, 15);
cr.Data = "咳\n嗽";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 16, 1, 16);
cr.Data = "呕\n吐";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 17, 1, 17);
cr.Data = "抽\n搐";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 18, 1, 18);
cr.Data = "皮\n肤";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 19, 1, 19);
cr.Data = "腹\n部";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 20, 1, 20);
cr.Data = "脐\n部";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 21, 1, 21);
cr.Data = "臀\n部";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 22, 1, 22);
cr.Data = "饮\n食";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 23, 1, 23);
cr.Data = "大\n便";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 24, 1, 24);
cr.Data = "小\n便";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 25, 1, 25);
cr.Data = "敷\n科";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 26, 0, 29);
cr.Data = "导管护理";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(1, 26, 1, 26);
cr.Data = "胃\n管";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(1, 27, 1, 27);
cr.Data = "尿\n管";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(1, 28, 1, 28);
cr.Data = "引\n流\n管";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(1, 29, 1, 29);
cr.Data = "其\n他";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 30, 1, 30);
cr.Data = "氧\n浓\n度\n%";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 31, 1, 31);
cr.Data = "呼\n吸\n频\n率\n次\n/\n分";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 32, 1, 32);
cr.Data = "吸\n气\n时\n间\n/\n秒";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 33, 1, 33);
cr.Data = "CPAP\ncmH2O";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 34, 1, 34);
cr.Data = "PEEP\ncmH2O";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 35, 1, 35);
cr.Data = "PIP\ncmH2O";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 36, 1, 36);
cr.Data = "病情及处理";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
cr = flgView.GetCellRange(0, 37, 1, 37);
cr.Data = "报告表ID";
cr.StyleNew.TextAlign = C1.Win.C1FlexGrid.TextAlignEnum.CenterCenter;
flgView.MergedRanges.Add(cr);
#endregion
flgView.AutoSizeCols();
flgView.AutoSizeRows();
flgView.Cols[36].Width = 300;
flgView.Cols[37].Visible = false;
flgView.AllowEditing = false;
}