void advBandedGridView1_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e) { if (e.RowHandle != advBandedGridView1.FocusedRowHandle && e.Column.FieldName == "tipwarninfo") { int tip = (int)advBandedGridView1.GetRowCellValue(e.RowHandle, advBandedGridView1.Columns["tipstatus"]); RuleRecordState recState = (RuleRecordState)tip; switch (recState) { case RuleRecordState.None: case RuleRecordState.DoIntime: case RuleRecordState.UndoIntime: e.Appearance.ForeColor = Color.Teal; break; case RuleRecordState.DoOuttime: case RuleRecordState.UndoOuttime: e.Appearance.ForeColor = Color.Red; break; default: break; } } }
/// <summary> /// 获取最终的数据集 /// Edit by xlb 新的病历时限信息条件时间来判断 即REALCONDITIONTIME /// 2013-02-26 /// </summary> /// <param name="infos"></param> /// <param name="dtTimeLimit"></param> public DataTable GetGridViewData(DataTable infos, DataTable dtTimeLimit) { //if (null == dtTimeLimit) //{ // return infos; //} try { for (int i = 0; i < dtTimeLimit.Rows.Count; i++) { DataRow row = dtTimeLimit.Rows[i]; RuleRecordState recordstate = (RuleRecordState)int.Parse(row["FoulState"].ToString()); DateTime conditionTime = DateTime.Parse(row["ConditionTime"].ToString()); if (recordstate == RuleRecordState.None || recordstate == RuleRecordState.DoIntime || conditionTime > DateTime.Now) { continue; } DataRow newRow = infos.NewRow(); newRow["UserName"] = row["UserName"].ToString().Trim(); //+ "(" + row["UserID"].ToString().Trim() + ")"; newRow["PatName"] = row["PatName"].ToString().Trim(); // + "(" + row["Patid"].ToString().Trim() + ")"; newRow["DeptName"] = row["DeptName"]; newRow["Age"] = null == row["Age"] ? "" : (row["Age"].ToString() + "岁"); newRow["SexID"] = row["SexID"]; newRow["Sex"] = row["Sex"]; newRow["Outbed"] = row["Outbed"]; newRow["InTime"] = row["InTime"]; //条件成功时间 即触发时间加延迟时间 DateTime dateConditionTime = DateTime.Parse(row["REALCONDITIONTIME"].ToString()); //现在时间 DateTime dateNow = DateTime.Now; //时间限制 以秒为单位 double timeLimit = double.Parse(row["TIMELIMIT"].ToString()); TimeSpan tsLimit = (TimeSpan)(dateNow - dateConditionTime); //违规状态 string foulState = row["FOULSTATE"].ToString().Trim(); //时间限制转换为指定格式 TimeSpan lTimeLimit = new TimeSpan(0, 0, 0, Convert.ToInt32(timeLimit)); switch (foulState) { case "1": //1表示违规 newRow["TimeLimit"] = "超过" + DS_Common.TimeSpanToLocal(tsLimit - lTimeLimit); newRow["TipWarnInfo"] = row["FOULMESSAGE"]; infos.Rows.Add(newRow); break; case "0": if (tsLimit > lTimeLimit) { newRow["TipWarnInfo"] = row["FOULMESSAGE"].ToString(); newRow["TimeLimit"] = "超出" + DS_Common.TimeSpanToLocal(tsLimit - lTimeLimit); infos.Rows.Add(newRow); } else { newRow["TipWarnInfo"] = row["REMINDER"].ToString(); newRow["TimeLimit"] = "还剩" + DS_Common.TimeSpanToLocal(lTimeLimit - tsLimit); infos.Rows.Add(newRow); } break; default: break; } #region 已注销 by xlb 2013-02-26 //预算与今日的差距 //DateTime dtResultTime = DateTime.Parse(row["ResultTime"].ToString()); //DateTime dtConditionTime = DateTime.Parse(row["ConditionTime"].ToString()); //TimeSpan tsTimeLimit = (TimeSpan)(dtResultTime - dtConditionTime); //double dblTimeLimit = double.Parse(row["TimeLimit"].ToString()); //TimeSpan tsDefTimeLimit = new TimeSpan(0, 0, 0, Convert.ToInt32(dblTimeLimit)); //switch (recordstate) //{ //case RuleRecordState.UndoIntime: //tsTimeLimit = DateTime.Now - dtConditionTime; //if (tsTimeLimit > tsDefTimeLimit) //{ // recordstate = RuleRecordState.UndoOuttime; //} //break; //case RuleRecordState.DoIntime: // break; //case RuleRecordState.UndoOuttime: //break; //case RuleRecordState.DoOuttime: //break; //default: //break; //} //newRow["TimeLimit"] = tsTimeLimit > tsDefTimeLimit ? (ConstRes.cstOverTime + TimeSpan2Chn(tsTimeLimit - tsDefTimeLimit)) : (ConstRes.cstOnTime + TimeSpan2Chn(tsDefTimeLimit - tsTimeLimit)); //if (recordstate == RuleRecordState.UndoIntime) //{ // newRow["TipWarnInfo"] = row["Reminder"]; //} //else if (recordstate == RuleRecordState.DoOuttime || recordstate == RuleRecordState.UndoOuttime) //{ // newRow["TipWarnInfo"] = row["FoulMessage"]; //} //infos.Rows.Add(newRow); #endregion } return(infos); } catch (Exception ex) { throw ex; } //return infos; }
void SetGridViewDisplay(DataSet infos, DataTable dtTimeLimit) { for (int i = 0; i < dtTimeLimit.Rows.Count; i++) { DataRow row = dtTimeLimit.Rows[i]; RuleRecordState recordstate = (RuleRecordState)int.Parse(row[ConstRes.cstFieldTipStatus2].ToString()); DateTime conditionTime = DateTime.Parse(row[ConstRes.cstFieldCondTime].ToString()); if (recordstate == RuleRecordState.None || recordstate == RuleRecordState.DoIntime || conditionTime > DateTime.Now) { continue; } DataRow inforow = infos.Tables[CstTimeLimitInfoDataTableName].NewRow(); inforow[ConstRes.cstFieldDoctorId] = row[ConstRes.cstFieldDoctorName].ToString().Trim() + "(" + row[ConstRes.cstFieldDoctorId2].ToString().Trim() + ")"; inforow[ConstRes.cstFieldFirstPage] = row[ConstRes.cstFieldFirstPage]; inforow[ConstRes.cstFieldPatNameHospNo] = row[ConstRes.cstFieldPatName].ToString().Trim();// + "(" + row[ConstRes.cstFieldPatHospNo].ToString().Trim() + ")"; //预算与今日的差距 DateTime dtResultTime = DateTime.Parse(row[ConstRes.cstFieldResultTime].ToString()); DateTime dtConditionTime = DateTime.Parse(row[ConstRes.cstFieldCondTime].ToString()); TimeSpan tsTimeLimit = (TimeSpan)(dtResultTime - dtConditionTime); double dblTimeLimit = double.Parse(row[ConstRes.cstFieldTimeLimit].ToString()); TimeSpan tsDefTimeLimit = new TimeSpan(0, 0, 0, Convert.ToInt32(dblTimeLimit)); switch (recordstate) { case RuleRecordState.UndoIntime: tsTimeLimit = DateTime.Now - dtConditionTime; if (tsTimeLimit > tsDefTimeLimit) { recordstate = RuleRecordState.UndoOuttime; } break; case RuleRecordState.DoIntime: break; case RuleRecordState.UndoOuttime: break; case RuleRecordState.DoOuttime: break; default: break; } if (tsTimeLimit > tsDefTimeLimit) { inforow[ConstRes.cstFieldTimeLimit] = ConstRes.cstOverTime + TimeSpan2Chn(tsTimeLimit - tsDefTimeLimit); } else { inforow[ConstRes.cstFieldTimeLimit] = ConstRes.cstOnTime + TimeSpan2Chn(tsDefTimeLimit - tsTimeLimit); } //edit by cyq 2012-11-08 去掉警告/提示信息中开头的“警告:”、"提示:"、"病人"字眼 if (recordstate == RuleRecordState.UndoIntime) { //inforow[ConstRes.cstFieldInfo] = row[ConstRes.cstFieldTipInfo]; string infoStr = null == row[ConstRes.cstFieldTipInfo] ? "" : row[ConstRes.cstFieldTipInfo].ToString(); if (infoStr.StartsWith("提示:病人")) { infoStr = infoStr.Substring(3, infoStr.Length - 5); } else if (infoStr.StartsWith("提示:")) { infoStr = infoStr.Substring(3, infoStr.Length - 3); } else if (infoStr.StartsWith("病人")) { infoStr = infoStr.Substring(3, infoStr.Length - 2); } inforow[ConstRes.cstFieldInfo] = infoStr; } if (recordstate == RuleRecordState.DoOuttime || recordstate == RuleRecordState.UndoOuttime) { //inforow[ConstRes.cstFieldInfo] = row[ConstRes.cstFieldWarnInfo]; string infoStr = null == row[ConstRes.cstFieldWarnInfo] ? "" : row[ConstRes.cstFieldWarnInfo].ToString(); if (infoStr.StartsWith("警告:病人")) { infoStr = infoStr.Substring(3, infoStr.Length - 5); } else if (infoStr.StartsWith("警告:")) { infoStr = infoStr.Substring(3, infoStr.Length - 3); } else if (infoStr.StartsWith("病人")) { infoStr = infoStr.Substring(3, infoStr.Length - 2); } inforow[ConstRes.cstFieldInfo] = infoStr; } inforow[ConstRes.cstFieldTipStatus] = (int)recordstate; infos.Tables[CstTimeLimitInfoDataTableName].Rows.Add(inforow); } gridControlTimeLimitInfo.DataSource = infos; gridControlTimeLimitInfo.DataMember = CstTimeLimitInfoDataTableName; }