using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
namespace XjxMobilenursing
{
public partial class frmNurseList : UserControl
{
#region 全局变量
private frmNurse myparentform = null; //父窗体
private string strtemplate = ""; //Web Service 返回的XML数据
private bool bolLook = true; //是否锁定
private ComboBox mySingleVeto;
private DataGridView mypopudatagridview = null;
private int iRowIndex = ;
private string strrq1 = "";
private int yzlx = ;
private Nurseinfo fNurseinfo = null;
// private Dictionary<string, DataTable> conDataitems = new Dictionary<string, DataTable>();
#endregion
public frmNurseList()
{
InitializeComponent();
}
#region 类成员GET和SET方法
public frmNurse OwnerParentForm
{
get
{ return myparentform; }
set
{ this.myparentform = value; }
}
public bool bLook
{
get
{
return this.bolLook;
}
set
{
this.bolLook = value;
}
}
public string RQ1
{
get
{
if (!StringCommon.IsDate(this.strrq1))
{
this.strrq1 = DateTime.Now.ToString("yyyy-MM-dd");
}
return strrq1;
}
set
{
this.strrq1 = value;
}
}
//public Dictionary<string, DataTable> conData
//{
// get
// {
// return conDataitems;
// }
// set { conDataitems = value; }
//}
#endregion
#region 重置dataGridView数据
public void ReflashTable()
{
try
{
if (this.NurseGridList == null) return;
DataTable dt = (DataTable)NurseGridList.DataSource;
if (dt != null)
{
dt.Rows.Clear();
NurseGridList.DataSource = dt;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Source + ":" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
#region get护理单记录信息XML
public bool getNurseListInfo(string rq1, string rq2)
{
try
{
if (this.OwnerParentForm == null)
return false;
if (!StringCommon.IsDate(rq1))
{
rq1 = DateTime.Parse(this.OwnerParentForm.OwnerParentForm.CurrentPatientInfo.rysj).ToString("yyyy-MM-dd");
}
if (!StringCommon.IsDate(rq2))
{
rq2 = DateTime.Now.ToString("yyyy-MM-dd");
}
string strresult;
this.strtemplate = "";
strresult = this.OwnerParentForm.OwnerParentForm.Xjxinfoweb.GetNurseTableinfo(Properties.Settings.Default.strapplication_account,
this.OwnerParentForm.OwnerParentForm.CurrentPatientInfo.lsh, rq1, rq2);
if (strresult.IndexOf("error") > -)
{
return false;
}
else if (strresult == "")
{
return false;
}
this.strtemplate = strresult;
return true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Source + ":" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
}
#endregion
#region Set护理单信息XML到DataTable
private DataTable FromXML2DataTable(string XMLStr)
{
XmlDocument myDoc = new XmlDocument();
myDoc.LoadXml(XMLStr);
if (string.IsNullOrEmpty(XMLStr) || !myDoc.HasChildNodes) return null;
DataTable dt = new DataTable();
DataRow row = null;
DataColumn col = null;
//填充数据
foreach (XmlElement el in myDoc.SelectNodes("Nurseinfos/row"))
{
row = dt.NewRow();
foreach (XmlNode node in el.ChildNodes)
{
if (!dt.Columns.Contains(node.Name))
{
col = new DataColumn();
col.ColumnName = node.Name;
dt.Columns.Add(col);
}
row[node.Name] = node.InnerText;
}
dt.Rows.Add(row);
}
return dt;
}
#endregion
#region Set护理单信息DataTable到GridView
public void ShowNurseTable()
{
DataTable ds = FromXML2DataTable(this.strtemplate);
if (ds != null && ds.Rows.Count > )
{
NurseGridList.AutoGenerateColumns = false;
NurseGridList.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
NurseGridList.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
NurseGridList.DataSource = ds;
NurseGridList.ClearSelection();
}
}
#endregion
#region Set护理单GridView可编辑
public void SetEditNurseTable()
{
try
{
this.bLook = false;
this.NurseGridList.ReadOnly = this.bolLook;
this.NurseGridList.AllowUserToAddRows = !this.bolLook;
if (this.NurseGridList.RowCount <= ) return;
this.NurseGridList.FirstDisplayedScrollingRowIndex = this.NurseGridList.Rows.Count - ;
this.NurseGridList.Rows[this.NurseGridList.Rows.Count - ].Selected = true;
this.NurseGridList.CurrentCell = this.NurseGridList.Rows[this.NurseGridList.Rows.Count - ].Cells["rqsj"];
this.NurseGridList.Focus();
this.NurseGridList.BeginEdit(false);
}
catch (Exception ex)
{
MessageBox.Show("对象:" + this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "异常信息:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
#region Set护理单GridView删除
public void SetdelNurseTable()
{
try
{
fNurseinfo = FillNurseinfo();
this.yzlx = ;
string requestParam = this.PkgCtrlParams(yzlx, fNurseinfo);
string rtn = OwnerParentForm.OwnerParentForm.Xjxinfoweb.SetNurseRequest(requestParam);
MessageBox.Show(rtn);
}
catch (Exception ex)
{
MessageBox.Show("对象:" + this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "异常信息:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
#region 窗体初始化
private void frmNurseList_Load(object sender, EventArgs e)
{
try
{
this.mySingleVeto = new ComboBox();
this.mySingleVeto.FormattingEnabled = true;
this.mySingleVeto.Items.AddRange(new object[] {
"",
"True",
"False"});
this.mySingleVeto.BringToFront();
this.mySingleVeto.SelectedIndexChanged += new System.EventHandler(this.mySingleVeto_SelectedIndexChanged);
//this.mySingleVeto.Click += new System.EventHandler(this.mySingleVeto_Click);
this.mySingleVeto.KeyUp += new System.Windows.Forms.KeyEventHandler(this.mySingleVeto_KeyUp);
this.mySingleVeto.Visible = false;
InitDataGridView(this.NurseGridList, "ZY_tHLDTJLD");
this.NurseGridList.Controls.Add(this.mySingleVeto);
mypopudatagridview = new DataGridView();
mypopudatagridview.Width = ;
mypopudatagridview.Height = ;
mypopudatagridview.AllowUserToAddRows = false;
mypopudatagridview.AllowUserToDeleteRows = false;
mypopudatagridview.AllowUserToResizeRows = false;
mypopudatagridview.BackgroundColor = System.Drawing.Color.White;
mypopudatagridview.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
mypopudatagridview.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.mypopudatagridview_CellClick);
mypopudatagridview.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
mypopudatagridview.MultiSelect = false;
mypopudatagridview.Name = "mypopudatagridview";
mypopudatagridview.ReadOnly = true;
mypopudatagridview.RowTemplate.Height = ;
mypopudatagridview.Cursor = Cursors.Hand;
mypopudatagridview.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
mypopudatagridview.AllowUserToOrderColumns = false;
mypopudatagridview.RowHeadersVisible = false;
mypopudatagridview.Visible = false;
this.NurseGridList.Controls.Add(mypopudatagridview);
InitPopDataGridView(mypopudatagridview, "XT_TCSSZ");
}
catch (Exception ex)
{
MessageBox.Show("对象:" + this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "异常信息:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
#region 主GridView初始化
private void InitDataGridView(DataGridView sender, string strName)
{
try
{
DataTable dt = new DataTable(strName);
dt.Columns.Add("jlid");
dt.Columns.Add("lsh");
dt.Columns.Add("JLR");
dt.Columns.Add("rqsj");
dt.Columns.Add("sz");
dt.Columns.Add("xybhd");
dt.Columns.Add("tk_y");
dt.Columns.Add("tk_z");
dt.Columns.Add("dgfs_y");
dt.Columns.Add("dgfs_z");
dt.Columns.Add("rl_mc");
dt.Columns.Add("rllx");
dt.Columns.Add("rl_l");
dt.Columns.Add("cl_mc");
dt.Columns.Add("cllx");
dt.Columns.Add("cl_l");
dt.Columns.Add("bbreathingmachine");
dt.Columns.Add("hx");
dt.Columns.Add("s");
dt.Columns.Add("f");
dt.Columns.Add("qm");
sender.DataSource = dt;
sender.AllowUserToOrderColumns = false;
sender.RowHeadersVisible = false;
sender.ReadOnly = this.bolLook;
sender.AllowUserToAddRows = !this.bolLook;
sender.Columns["jlid"].HeaderText = "jlid";
sender.Columns["jlid"].Visible = false;
sender.Columns["lsh"].HeaderText = "lsh";
sender.Columns["lsh"].Visible = false;
sender.Columns["JLR"].HeaderText = "JLR";
sender.Columns["JLR"].Visible = false;
sender.Columns["rqsj"].HeaderText = "日期";
sender.Columns["rqsj"].Width = ;
// sender.Columns["rqsj"].ReadOnly = this.bolLook;
sender.Columns["rqsj"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["sz"].HeaderText = "神志";
sender.Columns["sz"].Width = ;
// sender.Columns["sz"].ReadOnly = this.bolLook;
sender.Columns["sz"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["xybhd"].HeaderText = "血氧饱和度%";
sender.Columns["xybhd"].Width = ;
// sender.Columns["xybhd"].ReadOnly = this.bolLook;
sender.Columns["xybhd"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["tk_y"].HeaderText = "对光反应右";
sender.Columns["tk_y"].Width = ;
// sender.Columns["tk_y"].ReadOnly = this.bolLook;
sender.Columns["tk_y"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["tk_z"].HeaderText = "对光反应左";
sender.Columns["tk_z"].Width = ;
// sender.Columns["tk_z"].ReadOnly = this.bolLook;
sender.Columns["tk_z"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["dgfs_y"].HeaderText = "瞳孔(右)";
sender.Columns["dgfs_y"].Width = ;
// sender.Columns["dgfs_y"].ReadOnly = this.bolLook;
sender.Columns["dgfs_y"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["dgfs_z"].HeaderText = "瞳孔(左)";
sender.Columns["dgfs_z"].Width = ;
// sender.Columns["dgfs_z"].ReadOnly = this.bolLook;
sender.Columns["dgfs_z"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["rl_mc"].HeaderText = "入量名称";
sender.Columns["rl_mc"].Width = ;
// sender.Columns["rl_mc"].ReadOnly = this.bolLook;
sender.Columns["rl_mc"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["rllx"].HeaderText = "入量(单位)";
sender.Columns["rllx"].Width = ;
//sender.Columns["rllx"].ReadOnly = this.bolLook;
sender.Columns["rllx"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["rl_l"].HeaderText = "入量(量)";
sender.Columns["rl_l"].Width = ;
// sender.Columns["rl_l"].ReadOnly = this.bolLook;
sender.Columns["rl_l"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["cl_mc"].HeaderText = " 出量名称";
sender.Columns["cl_mc"].Width = ;
// sender.Columns["cl_mc"].ReadOnly = this.bolLook;
sender.Columns["cl_mc"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["cllx"].HeaderText = "出量(单位)";
sender.Columns["cllx"].Width = ;
// sender.Columns["cllx"].ReadOnly = this.bolLook;
sender.Columns["cllx"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["cl_l"].HeaderText = "出量(量)";
sender.Columns["cl_l"].Width = ;
// sender.Columns["cl_l"].ReadOnly = this.bolLook;
sender.Columns["cl_l"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["bbreathingmachine"].HeaderText = "呼吸机";
sender.Columns["bbreathingmachine"].Width = ;
//sender.Columns["bbreathingmachine"].ReadOnly = this.bolLook;
sender.Columns["bbreathingmachine"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["hx"].HeaderText = "呼吸";
sender.Columns["hx"].Width = ;
// sender.Columns["hx"].ReadOnly = this.bolLook;
sender.Columns["hx"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["s"].HeaderText = "时";
sender.Columns["s"].Width = ;
// sender.Columns["s"].ReadOnly = this.bolLook;
sender.Columns["s"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["f"].HeaderText = "分";
sender.Columns["f"].Width = ;
// sender.Columns["f"].ReadOnly = this.bolLook;
sender.Columns["f"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["qm"].HeaderText = "记录人";
sender.Columns["qm"].Width = ;
//sender.Columns["qm"].ReadOnly = this.bolLook;
sender.Columns["qm"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Tag = strName;
}
catch (Exception ex)
{
MessageBox.Show("对象:" + this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "异常信息:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
#region 辅GridView初始化
private void InitPopDataGridView(DataGridView sender, string strName)
{
try
{
DataTable dt = new DataTable(strName);
dt.Columns.Add("id");
dt.Columns.Add("mc");
sender.DataSource = dt;
sender.Columns["id"].HeaderText = "序号";
sender.Columns["id"].Width = ;
sender.Columns["id"].ReadOnly = false;
sender.Columns["id"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
sender.Columns["mc"].HeaderText = "名称";
sender.Columns["mc"].Width = ;
sender.Columns["mc"].ReadOnly = false;
sender.Columns["mc"].CellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleLeft;
}
catch (Exception ex)
{
MessageBox.Show("对象:" + this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "异常信息:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
#region 主GridView触发事件
private void NurseGridList_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (this.bLook) return;
if (e.RowIndex < )
{
return;
}
if (this.NurseGridList.Columns[e.ColumnIndex].Name.ToString().ToUpper() == "rl_l".ToUpper()
|| this.NurseGridList.Columns[e.ColumnIndex].Name.ToString().ToUpper() == "cl_l".ToUpper())
{
string str = e.FormattedValue.ToString();
this.NurseGridList.Rows[e.RowIndex].ErrorText = "";
if (XjxWordE.xjxformat.StringCommon.IsNumeric(str))
{
if (double.Parse(str) < )
{
if (this.NurseGridList.Columns[e.ColumnIndex].Name.ToString().ToUpper() == "cl_l".ToUpper())
{
this.NurseGridList.Rows[e.RowIndex].ErrorText = "分值输入的必须是大于或等于0的数字,请重输";
}
else
{
this.NurseGridList.Rows[e.RowIndex].ErrorText = "数量输入的必须是大于或等于0的数字,请重输";
}
MessageBox.Show(this.NurseGridList.Rows[e.RowIndex].ErrorText, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
e.Cancel = true;
}
}
else
{
if (this.NurseGridList.Columns[e.ColumnIndex].Name.ToString().ToUpper() == "cl_l".ToUpper())
{
this.NurseGridList.Rows[e.RowIndex].ErrorText = "分值输入的必须是数字类型,请重输";
}
else
{
this.NurseGridList.Rows[e.RowIndex].ErrorText = "数量输入的必须是数字类型,请重输";
}
MessageBox.Show(this.NurseGridList.Rows[e.RowIndex].ErrorText, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
e.Cancel = true;
}
}
}
private void NurseGridList_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (this.bLook) return;
string kind = this.NurseGridList.Columns[this.NurseGridList.CurrentCell.ColumnIndex].Name.ToString().ToLower();
switch (kind)
{
case "sz":
case "tk_y":
case "tk_z":
case "dgfs_y":
case "dgfs_z":
case "rl_mc":
case "rllx":
case "cl_mc":
case "cllx":
TextBox mytextbox;
mytextbox = e.Control as TextBox;
mytextbox.Name = this.NurseGridList.Columns[this.NurseGridList.CurrentCell.ColumnIndex].Name.ToString().ToLower();
mytextbox.Tag = this.NurseGridList.CurrentCell;
if (mytextbox == null) return;
mytextbox.Click += new System.EventHandler(this.mytextbox_Click);
//mytextbox.KeyUp += new System.Windows.Forms.KeyEventHandler(this.mytextbox_KeyUp);
break;
default:
this.mypopudatagridview.Visible = false;
break;
}
}
private void NurseGridList_CellEnter(object sender, DataGridViewCellEventArgs e)
{
if (this.bLook) return;
if (this.NurseGridList.Columns[this.NurseGridList.CurrentCell.ColumnIndex].Name.ToString().ToUpper() == "bbreathingmachine".ToUpper())
{
Rectangle rect = this.NurseGridList.GetCellDisplayRectangle(this.NurseGridList.CurrentCell.ColumnIndex, this.NurseGridList.CurrentCell.RowIndex, false);
this.mySingleVeto.Text = this.NurseGridList.CurrentCell.Value.ToString();
this.mySingleVeto.Left = rect.Left;
this.mySingleVeto.Top = rect.Top;
this.mySingleVeto.Width = rect.Width;
this.mySingleVeto.Height = rect.Height;
this.mySingleVeto.Tag = this.NurseGridList.CurrentCell;
this.mySingleVeto.Visible = true;
this.mySingleVeto.BringToFront();
this.mySingleVeto.Focus();
this.mypopudatagridview.Visible = false;
}
else
{
this.mySingleVeto.Visible = false;
}
}
private void NurseGridList_CurrentCellChanged(object sender, EventArgs e)
{
if (this.bLook) return;
string kind = this.NurseGridList.Columns[this.NurseGridList.CurrentCell.ColumnIndex].Name.ToString().ToLower();
switch (kind)
{
case "sz":
case "tk_y":
case "tk_z":
case "dgfs_y":
case "dgfs_z":
case "rl_mc":
case "rllx":
case "cl_mc":
case "cllx":
if (this.mySingleVeto != null && this.mySingleVeto.Visible)
{
DataGridViewCell mycell = this.mySingleVeto.Tag as DataGridViewCell;
if (mycell == null) return;
mycell.Value = this.mySingleVeto.Text;
this.mySingleVeto.Visible = false;
this.mySingleVeto.Tag = null;
this.NurseGridList.BeginEdit(false);
}
if (this.mypopudatagridview != null)
{
DataGridViewCell mydatagridviewcell = this.mypopudatagridview.Tag as DataGridViewCell;
if ((mydatagridviewcell != null) && (this.NurseGridList.Columns[mydatagridviewcell.ColumnIndex].Name != kind))
{
this.mypopudatagridview.Visible = false;
iRowIndex = ;
this.mypopudatagridview.Tag = null;
this.NurseGridList.BeginEdit(false);
}
}
break;
case "bbreathingmachine":
if (this.mypopudatagridview != null)
{
this.mypopudatagridview.Visible = false;
iRowIndex = ;
this.mypopudatagridview.Tag = null;
this.NurseGridList.BeginEdit(false);
}
break;
default:
if (this.mySingleVeto != null && this.mySingleVeto.Visible)
{
DataGridViewCell mycell = this.mySingleVeto.Tag as DataGridViewCell;
if (mycell == null) return;
mycell.Value = this.mySingleVeto.Text;
this.mySingleVeto.Visible = false;
this.mySingleVeto.Tag = null;
this.NurseGridList.BeginEdit(false);
}
if (this.mypopudatagridview != null)
{
DataGridViewCell mydatagridviewcell = this.mypopudatagridview.Tag as DataGridViewCell;
this.mypopudatagridview.Visible = false;
iRowIndex = ;
this.mypopudatagridview.Tag = null;
this.NurseGridList.BeginEdit(false);
}
break;
}
}
private void NurseGridList_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (this.bLook) return;
if (this.NurseGridList.Columns[this.NurseGridList.CurrentCell.ColumnIndex].Name.ToString().ToUpper() == "rqsj".ToUpper())
{
SelectDatetime();
}
}
private void NurseGridList_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
{
if (this.bLook) return;
if (this.mySingleVeto == null) return;
this.mySingleVeto.Visible = false;
}
private void NurseGridList_Scroll(object sender, ScrollEventArgs e)
{
if (this.bLook) return;
if (this.mySingleVeto == null) return;
this.mySingleVeto.Visible = false;
}
private void NurseGridList_RowLeave(object sender, DataGridViewCellEventArgs e)
{
fNurseinfo = FillNurseinfo();
string requestParam = this.PkgCtrlParams(yzlx, fNurseinfo);
string rtn = OwnerParentForm.OwnerParentForm.Xjxinfoweb.SetNurseRequest(requestParam);
// MessageBox.Show(rtn);
}
#endregion
#region 日期选择事件
public void SelectDatetime()
{
using (frmSelectsingleDate myfrm = new frmSelectsingleDate())
{
myfrm.RQ1 = this.RQ1;
if (myfrm.ShowDialog() == DialogResult.OK)
{
this.NurseGridList.Rows[this.NurseGridList.CurrentCell.RowIndex].Cells[this.NurseGridList.CurrentCell.ColumnIndex].Value = myfrm.RQ1;
this.NurseGridList.Rows[this.NurseGridList.CurrentCell.RowIndex].Cells["s"].Value = DateTime.Now.Hour.ToString();
this.NurseGridList.Rows[this.NurseGridList.CurrentCell.RowIndex].Cells["f"].Value = DateTime.Now.Minute.ToString();
this.NurseGridList.CurrentCell = this.NurseGridList.Rows[this.NurseGridList.CurrentCell.RowIndex].Cells[this.NurseGridList.CurrentCell.ColumnIndex + ];
this.NurseGridList.Focus();
this.NurseGridList.BeginEdit(false);
}
}
}
#endregion
#region 获取控件数据小窗口grid
private void mytextbox_KeyUp(object sender, KeyEventArgs e)
{
string kind = this.NurseGridList.Columns[this.NurseGridList.CurrentCell.ColumnIndex].Name.ToString().ToLower();
if ((kind != "sz") && (kind != "tk_y") && (kind != "tk_z") && (kind != "dgfs_y") && (kind != "dgfs_z") && (kind != "rl_mc") && (kind != "rllx") && (kind != "cl_mc") && (kind != "cllx"))
{
e.Handled = true;
return;
}
switch (e.KeyCode)
{
case Keys.Down:
if (this.mypopudatagridview.Rows.Count < ) return;
iRowIndex++;
if (iRowIndex >= this.mypopudatagridview.Rows.Count) iRowIndex = this.mypopudatagridview.Rows.Count - ;
setSelectRowValue(iRowIndex);
e.Handled = true;
break;
case Keys.Up:
if (this.mypopudatagridview.Rows.Count < ) return;
iRowIndex--;
if (iRowIndex < ) iRowIndex = ;
setSelectRowValue(iRowIndex);
e.Handled = true;
break;
case Keys.Enter:
if (this.mypopudatagridview.Visible && this.mypopudatagridview.Rows.Count > )
{
setSelectRowValue(iRowIndex);
}
System.Windows.Forms.SendKeys.Send("{TAB}");
e.Handled = true;
break;
}
if (e.KeyCode == Keys.Down || e.KeyCode == Keys.Up) return;
if (!this.mypopudatagridview.Visible)
{
Rectangle rect = this.NurseGridList.GetCellDisplayRectangle(this.NurseGridList.CurrentCell.ColumnIndex, this.NurseGridList.CurrentCell.RowIndex, false);
this.mypopudatagridview.Visible = true;
this.mypopudatagridview.Left = rect.Left;
if (rect.Top + this.mypopudatagridview.Height > this.NurseGridList.Height)
{
this.mypopudatagridview.Top = rect.Top - this.mypopudatagridview.Height;
}
else
{
this.mypopudatagridview.Top = rect.Top + rect.Height;
}
this.mypopudatagridview.Tag = this.NurseGridList.CurrentCell;
this.mypopudatagridview.Visible = true;
}
if (this.mypopudatagridview.Visible)
{
TextBox mytextbox = sender as TextBox;
string tbName = mytextbox.Name;
if (mytextbox == null) return;
if (this.NurseGridList.Columns[Name].Tag != null && this.NurseGridList.Columns[Name].Tag is DataTable)
{
this.mypopudatagridview.DataSource = this.NurseGridList.Columns[Name].Tag;
}
else
{
this.writePopDataGridView(tbName);
}
}
}
private void mytextbox_Click(object sender, EventArgs e)
{
string kind = this.NurseGridList.Columns[this.NurseGridList.CurrentCell.ColumnIndex].Name.ToString().ToLower();
if ((kind != "sz") && (kind != "tk_y") && (kind != "tk_z") && (kind != "dgfs_y") && (kind != "dgfs_z") && (kind != "rl_mc") && (kind != "rllx") && (kind != "cl_mc") && (kind != "cllx"))
{
return;
}
if (!this.mypopudatagridview.Visible)
{
Rectangle rect = this.NurseGridList.GetCellDisplayRectangle(this.NurseGridList.CurrentCell.ColumnIndex, this.NurseGridList.CurrentCell.RowIndex, false);
this.mypopudatagridview.Visible = true;
this.mypopudatagridview.Left = rect.Left;
if (rect.Top + this.mypopudatagridview.Height > this.NurseGridList.Height)
{
this.mypopudatagridview.Top = rect.Top - this.mypopudatagridview.Height;
}
else
{
this.mypopudatagridview.Top = rect.Top + rect.Height;
}
this.mypopudatagridview.Tag = this.NurseGridList.CurrentCell;
this.mypopudatagridview.Visible = true;
}
if (this.mypopudatagridview.Visible)
{
TextBox mytextbox = sender as TextBox;
string tbName = mytextbox.Name;
if (mytextbox == null) return;
//if (this.conDataitems != null && this.conDataitems.Count > 0 && this.conDataitems.ContainsKey(tbName))
//{
// DataTable dt = this.conDataitems[tbName] as DataTable;
// this.mypopudatagridview.DataSource = dt;
//}
//else
//{
// this.writePopDataGridView(tbName);
//}
if (this.NurseGridList.Columns[kind].Tag != null && this.NurseGridList.Columns[kind].Tag is DataTable)
{
this.mypopudatagridview.DataSource = this.NurseGridList.Columns[kind].Tag;
}
else
{
this.writePopDataGridView(kind);
}
}
}
private void mypopudatagridview_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < ) return;
iRowIndex = e.RowIndex;
setSelectRowValue(iRowIndex);
DataGridViewCell mydatagridviewcell = this.mypopudatagridview.Tag as DataGridViewCell;
DataGridViewCell mycell = this.mypopudatagridview.Tag as DataGridViewCell;
if (mydatagridviewcell != null)
{
this.NurseGridList.FirstDisplayedScrollingRowIndex = this.NurseGridList.Rows.Count - ;
this.NurseGridList.Rows[this.NurseGridList.Rows.Count - ].Selected = true;
this.NurseGridList.CurrentCell = this.NurseGridList.Rows[mycell.RowIndex].Cells[mycell.ColumnIndex + ];
this.NurseGridList.Focus();
this.NurseGridList.BeginEdit(false);
}
this.mypopudatagridview.Visible = false;
this.mypopudatagridview.Tag = null;
iRowIndex = ;
}
public void writePopDataGridView(string Name)
{
//if (this.mypopudatagridview.RowCount > 0) ((DataTable)this.mypopudatagridview.DataSource).Clear();
XmlDocument myDoc = new XmlDocument();
string respStr = string.Empty;
respStr = this.OwnerParentForm.OwnerParentForm.Xjxinfoweb.GetNurseTabinfo(Name, string.Empty);
if (string.IsNullOrEmpty(respStr) || respStr.IndexOf("error") > -)
{
MessageBox.Show(respStr, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
myDoc.LoadXml(respStr);
DataTable dt = new DataTable();
DataRow row = null;
DataColumn col = null;
foreach (XmlElement el in myDoc.SelectNodes("patientinfos/patientinfo"))
{
row = dt.NewRow();
foreach (XmlNode node in el.ChildNodes)
{
if (!dt.Columns.Contains(node.Name))
{
col = new DataColumn();
col.ColumnName = node.Name;
dt.Columns.Add(col);
}
row[node.Name] = node.InnerText;
}
dt.Rows.Add(row);
}
this.mypopudatagridview.DataSource = dt;
//if (!this.conDataitems.ContainsKey(Name.ToString()))
//{
// this.conDataitems.Add(Name, dt);
//}
this.NurseGridList.Columns[Name].Tag = dt;
}
private void setSelectRowValue(int rowindex)
{
if (this.mypopudatagridview.Rows.Count < ) return;
if (rowindex < || rowindex > this.mypopudatagridview.Rows.Count) return;
this.mypopudatagridview.FirstDisplayedScrollingRowIndex = rowindex;
this.mypopudatagridview.Rows[rowindex].Selected = true;
this.NurseGridList.Rows[this.NurseGridList.CurrentCell.RowIndex].Cells[this.NurseGridList.CurrentCell.ColumnIndex].Value = this.mypopudatagridview.Rows[rowindex].Cells["mc"].Value.ToString();
}
#endregion
#region 获取Combox
private void mySingleVeto_SelectedIndexChanged(object sender, EventArgs e)
{
return;
}
private void mySingleVeto_KeyUp(object sender, KeyEventArgs e)
{
int index = mySingleVeto.SelectedIndex;
switch (e.KeyCode)
{
case Keys.Up:
index--;
if (index < ) index = ;
mySingleVeto.SelectedIndex = index;
e.Handled = true;
break;
case Keys.Down:
index++;
if (index >= this.mySingleVeto.Items.Count) index = this.mySingleVeto.Items.Count - ;
this.mySingleVeto.SelectedIndex = index;
e.Handled = true;
break;
case Keys.Enter:
DataGridViewCell mycell = this.Tag as DataGridViewCell;
if (mycell == null) return;
mycell.Value = this.mySingleVeto.Text;
this.NurseGridList.FirstDisplayedScrollingRowIndex = mycell.RowIndex;
this.NurseGridList.Rows[mycell.RowIndex].Selected = true;
this.NurseGridList.CurrentCell = this.NurseGridList.Rows[mycell.RowIndex].Cells[mycell.ColumnIndex + ];
this.NurseGridList.Focus();
this.NurseGridList.BeginEdit(false);
e.Handled = true;
break;
}
}
#endregion
#region 获取记录
private Nurseinfo FillNurseinfo()
{
DataGridViewRow selectedRow = NurseGridList.CurrentRow;
if (selectedRow == null)
{
MessageBox.Show("请选中记录", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return null;
}
Nurseinfo myNurseinfo = new Nurseinfo();
if (selectedRow.Cells["jlid"].Value + "" == "")
{
this.yzlx = ;
myNurseinfo.jlid = "";
}
else
{
this.yzlx = ;
myNurseinfo.jlid = selectedRow.Cells["jlid"].Value + "";
}
myNurseinfo.lsh = selectedRow.Cells["lsh"].Value + "";
myNurseinfo.jlr = selectedRow.Cells["jlr"].Value + "";
myNurseinfo.rqsj = selectedRow.Cells["rqsj"].Value + "";
myNurseinfo.s = selectedRow.Cells["s"].Value + "";
myNurseinfo.f = selectedRow.Cells["f"].Value + "";
myNurseinfo.bbreathingmachine = selectedRow.Cells["bbreathingmachine"].Value + "";
myNurseinfo.hx = selectedRow.Cells["hx"].Value + "";
myNurseinfo.sz = selectedRow.Cells["sz"].Value + "";
myNurseinfo.s = selectedRow.Cells["s"].Value + "";
myNurseinfo.xybhd = selectedRow.Cells["xybhd"].Value + "";
myNurseinfo.dgfs_z = selectedRow.Cells["dgfs_y"].Value + "";
myNurseinfo.tk_z = selectedRow.Cells["tk_z"].Value + "";
myNurseinfo.tk_y = selectedRow.Cells["tk_y"].Value + "";
myNurseinfo.rl_mc = selectedRow.Cells["rl_mc"].Value + "";
myNurseinfo.rllx = selectedRow.Cells["rllx"].Value + "";
myNurseinfo.rl_l = selectedRow.Cells["rl_l"].Value + "";
myNurseinfo.cl_mc = selectedRow.Cells["cl_mc"].Value + "";
myNurseinfo.cllx = selectedRow.Cells["cl_l"].Value + "";
return myNurseinfo;
}
#endregion
#region 界面数据打包XML
private string PkgCtrlParams(int opKind, Nurseinfo oNurseinfo)
{
Patientinfo myCurrentPatientinfo = OwnerParentForm.OwnerParentForm.CurrentPatientInfo;
if (myCurrentPatientinfo == null || (opKind != && opKind != && opKind != )) return string.Empty;
XmlDocument myDoc = new XmlDocument();
XmlElement root = myDoc.CreateElement("params");
myDoc.AppendChild(root);
try
{
AppendToXml(root, "jlid", oNurseinfo.jlid);//*主键
AppendToXml(root, "lsh", myCurrentPatientinfo.lsh == ? "" : myCurrentPatientinfo.lsh.ToString());//*患者ID
AppendToXml(root, "czzt", opKind.ToString());//*执行保存操作;1:增,2:改,3:删
AppendToXml(root, "jlr", Properties.Settings.Default.iapplication_yhid.ToString());//*操作员ID
}
catch (Exception e)
{
MessageBox.Show(this, e.Message, "出错提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return string.Empty;
}
if ((opKind == ) || (opKind == ))
{
AppendToXml(root, "rqsj", oNurseinfo.rqsj); //*护理时间
AppendToXml(root, "s", oNurseinfo.s); //护理时
AppendToXml(root, "f", oNurseinfo.f); //护理分
AppendToXml(root, "bbreathingmachine", true? "" : "");//*呼吸机
AppendToXml(root, "hx", oNurseinfo.hx); //*呼吸机速率
AppendToXml(root, "sz", oNurseinfo.sz); //神志
AppendToXml(root, "xybhd", oNurseinfo.xybhd); //血氧饱和度
AppendToXml(root, "dgfs_z", oNurseinfo.dgfs_z); //对光反应左
AppendToXml(root, "dgfs_y", oNurseinfo.dgfs_y); //对光反应右
AppendToXml(root, "tk_z", oNurseinfo.tk_z); //瞳孔(左)
AppendToXml(root, "tk_y", oNurseinfo.tk_y); //瞳孔(右)
AppendToXml(root, "rl_mc ", oNurseinfo.rl_mc); //入量名称
AppendToXml(root, "rllx", oNurseinfo.rllx); //入量(单位)
AppendToXml(root, "rl_l", oNurseinfo.rl_l); //入量(量)
AppendToXml(root, "cl_mc", oNurseinfo.cl_mc); //出量名称
AppendToXml(root, "cllx", oNurseinfo.cllx); //出量(单位)
AppendToXml(root, "cl_l", oNurseinfo.cl_l); //出量(量)
AppendToXml(root, "jlsj", oNurseinfo.rqsj); //*记录护理时间
}
return myDoc.OuterXml;
}
private void AppendToXml(XmlElement root, string name, string text)
{
if (string.IsNullOrEmpty(text)) return;
XMLCommon.CreateChildElement(root, name, true, text);
}
#endregion
}
}