2023-08-16 22:32:16 +08:00

1081 lines
50 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using AIMSBLL;
using AIMSExtension;
using AIMSModel;
using DevComponents.DotNetBar;
using DevComponents.DotNetBar.Controls;
using DrawGraph;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
namespace AIMS.PublicUI.UI
{
public partial class frmFactEventsNew : Form
{
/// <summary>
/// 手术记录
/// </summary>
public DrawGraph.OperationRecord _record;
public int EventTypeId;
/// <summary>
/// 选择项编号
/// </summary>
public int _itemId;
/// <summary>
/// 图表控件
/// </summary>
public ZedGraphControl zgcAnaesRecord;
/// <summary>
/// 是否是回顾
/// </summary>
public bool IsReview = false;
SuperTabControl stc = new SuperTabControl();
/// <summary>
/// 修改委托
/// </summary>
public delegate void EventParamHandler();
/// <summary>
/// 修改事件
/// </summary>
public event EventParamHandler EventParam;
public bool IsDeleteConcet = false;
public frmFactEventsNew()
{
InitializeComponent();
}
private void frmFactEventsNew_Load(object sender, EventArgs e)
{
if (PublicMethod.OperatorNo == "admin" || PublicMethod.RoleName.Contains("常用事件"))
{
btnTypeManager.Visible = true;
}
for (int i = 0; i < dgvEvents.Columns.Count; i++)
{
dgvEvents.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
}
dgvEvents.CellValueChanged -= new DataGridViewCellEventHandler(dgvEvents_CellValueChanged);
Initial();
dgvEvents.ClearSelection();
dgvEvents.ShowCellToolTips = true;
dgvEvents.CellValueChanged += new DataGridViewCellEventHandler(dgvEvents_CellValueChanged);
dgvEvents.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCellsExceptHeaders;
}
private void Initial()
{
BindAnaesthesiaEvents();
DataTable dt = BEvents.GetCommonlyEvents();
FullCommonlyEvents(superTabControlPanel1, dt);
if (_record.FactEventsList.Count > 0)
{
FullDGV(_record.FactEventsList);
}
}
int page = 0;
int currpage = 0;
DataTable drugdt;
Panel panelleftsel;
private void FullCommonlyEvents(Panel panelleft, DataTable dt)
{
if (panelleft.Controls != null) panelleft.Controls.Clear();
page = (dt.Rows.Count / 16) + 1;
currpage = 1;
drugdt = dt;
int y = -28;
if (page > 1)
{
Panel paneltab = new Panel();
paneltab.AutoScroll = true;
paneltab.BackColor = Color.White;
paneltab.Dock = DockStyle.Top;
paneltab.Height = 36;
panelleft.Controls.Add(paneltab);
int x = -28;
y = 8;
for (int i = 1; i <= page; i++)
{
ButtonX lb = new ButtonX();
lb.Text = i.ToString().Trim();
lb.Size = new System.Drawing.Size(30, 30);
lb.Font = new System.Drawing.Font("微软雅黑", 11f, FontStyle.Bold);
lb.Parent = paneltab;
if (i == 1)
lb.TextColor = System.Drawing.Color.Black;
x += 34;
lb.Location = new Point(x, 3);
lb.Click += Lb1_Click;
paneltab.Controls.Add(lb);
}
}
Panel panel = new Panel();
panel.AutoScroll = true;
panel.BackColor = Color.White;
panel.Dock = DockStyle.Fill;
panelleft.Controls.Add(panel);
panelleftsel = panel;
LoadDrugsMethod(y);
}
private void Lb1_Click(object sender, EventArgs e)
{
ButtonX button = (ButtonX)sender;
currpage = int.Parse(button.Text);
foreach (Control item in button.Parent.Controls)
{
if (item is ButtonX)
{
if (((ButtonX)item).Text == currpage.ToString())
((ButtonX)item).TextColor = System.Drawing.Color.Black;
else
((ButtonX)item).TextColor = System.Drawing.Color.White;
}
}
panelleftsel.Controls.Clear();
int y = 8;
LoadDrugsMethod(y);
}
private void LoadDrugsMethod(int y)
{
int row = (currpage - 1) * 18;
for (int i = 0; i < 18; i++)
{
if (row + i >= drugdt.Rows.Count) break;
ButtonX lb = new ButtonX();
lb.Text = drugdt.Rows[row + i]["Name"].ToString().Trim();
if (lb.Text.Length > 16)
{
lb.Text = lb.Text.Substring(0, 17) + "...";
}
lb.Tag = drugdt.Rows[row + i]["Id"].ToString();
//设定位置
lb.Size = new System.Drawing.Size(panelleftsel.Width - 26, 30);
lb.Font = new System.Drawing.Font("微软雅黑", 10.9f, FontStyle.Bold);
lb.Cursor = Cursors.Hand;
lb.ColorTable = eButtonColor.Flat;
lb.BackColor = Color.SkyBlue;
lb.TextAlignment = eButtonTextAlignment.Left;
lb.Parent = panelleftsel;
lb.TextColor = System.Drawing.Color.Black;
y += 32;
lb.Location = new Point(4, y);
lb.Click += new EventHandler(lb_Click);
panelleftsel.Controls.Add(lb);
}
}
void lb_Click(object sender, EventArgs e)
{
ButtonX button = sender as ButtonX;
Events selevent = BEvents.SelectSingle(int.Parse(button.Tag.ToString()), RecursiveType.None, 0);
foreach (FactEvents drd in _record.FactEventsList)
{
if (drd.Id == selevent.Id)
{
DialogResult drr = MessageBox.Show(selevent.Name + "已于" + drd.EventBeginTime + "添加过了,是否继续添加?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if (drr == DialogResult.Yes)
break;
else
return;
}
}
DataGridViewRow dr = new DataGridViewRow();
dr.CreateCells(dgvEvents);
dr.Cells[0].Value = selevent.Id.Value;
dr.Cells[1].Tag = selevent.Id.Value;
dr.Cells[1].Value = selevent.Name;
dr.Cells[2].Value = DateTime.Now;
//dr.Cells[5].Value = selevent.Value;
if (selevent.Remark != null)
{
DataGridViewComboEditTipBoxCell col = (DataGridViewComboEditTipBoxCell)dr.Cells[6];
col.Items.Add("");
string remark = selevent.Remark;
if (remark.Contains('|'))
{
string[] s = remark.Split('|');
for (int i = 0; i < s.Length; i++)
{
if (s[i] != "")
col.Items.Add(s[i]);
}
dr.Cells[6].Value = s[0];//备注名称
}
else
{
if (remark != null && remark.Trim() != "" && !col.Items.Contains(remark))
{
col.Items.Add(remark);
}
dr.Cells[6].Value = remark;//备注名称
}
}
dgvEvents.Rows.Add(dr);
}
private void FullDGV(List<FactEvents> list)
{
dgvEvents.AutoGenerateColumns = false;
dgvEvents.Rows.Clear();
foreach (FactEvents item in _record.FactEventsList)
{
int index = this.dgvEvents.Rows.Add();
this.dgvEvents.Rows[index].Tag = item.Id;
this.dgvEvents.Rows[index].Cells["TypeName"].Value = "事件";
DataGridViewComboEditTipBoxCell col = (DataGridViewComboEditTipBoxCell)dgvEvents.Rows[index].Cells[6];
col.Items.Add("");
if (item.EventRemark != null && item.EventRemark != "")
{
string remark = item.EventRemark.ToString();
string[] s = remark.Split('|');
for (int i = 0; i < s.Length; i++)
{
if (s[i] != "")
col.Items.Add(s[i]);
}
}
if (item.Remark != null && item.Remark.Trim() != "" && !col.Items.Contains(item.Remark))
{
col.Items.Add(item.Remark);
}
this.dgvEvents.Rows[index].Cells["Remark"].Value = item.Remark;
this.dgvEvents.Rows[index].Cells["EventName"].Value = item.EventName;
this.dgvEvents.Rows[index].Cells["EventName"].Tag = item.EventId;
if (item.EventId < 10)
{
this.dgvEvents.Rows[index].Cells["EventName"].ReadOnly = true;
}
if (Convert.ToDateTime(item.EventBeginTime).ToString().Length > 0)
{
this.dgvEvents.Rows[index].Cells["BeginTime"].Value = item.EventBeginTime;
}
if (item.IsContinue > 0)
{
this.dgvEvents.Rows[index].Cells["Continue"].Value = "-->";
}
if (Convert.ToDateTime(item.EventEndTime).ToString().Length > 0)
{
if (item.EventEndTime != item.EventBeginTime)
{
this.dgvEvents.Rows[index].Cells["Continue"].Value = "-->";
this.dgvEvents.Rows[index].Cells["EndTime"].Value = item.EventEndTime;
}
}
this.dgvEvents.Rows[index].Cells["EventValue"].Value = item.EventValue;
}
for (int i = 0; i < dgvEvents.Columns.Count; i++)
{
dgvEvents.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
}
}
private void dgvEvents_CellValueChanged(object sender, DataGridViewCellEventArgs e)
{
//判断如果事件名称列内容发生变化时(输入关键字),设置显示查询结果的控件的位置及内容
if (dgvEvents.CurrentCell != null && dgvEvents.CurrentCell.Tag != null && dgvEvents.CurrentCell.ColumnIndex == 1)
{
//if ("5660,61,154,10,11".Contains(dgvEvents.CurrentCell.Tag.ToString())) return;
if (dgvEvents.CurrentCell.Tag != null && BEvents.SelectSingle(int.Parse(dgvEvents.CurrentCell.Tag.ToString())).Name != dgvEvents.CurrentCell.Value.ToString())
{
dgvEvents.CurrentCell.Tag = null;
}
}
if (dgvEvents.CurrentCell.ColumnIndex == 1)
{
if (dgvEvents.Rows[e.RowIndex].Cells["BeginTime"].EditedFormattedValue.ToString() == "")
{
dgvEvents.Rows[e.RowIndex].Cells["BeginTime"].Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm");//默认当前时间‘
TimeSpan tsp = DateTime.Now - _record.InRoomTime.Value;
if (tsp.TotalHours > 12)
{
DateTime begindate = new DateTime(_record.InRoomTime.Value.Year, _record.InRoomTime.Value.Month, _record.InRoomTime.Value.Day, DateTime.Now.Hour, DateTime.Now.Minute, 0);
if (begindate > _record.InRoomTime.Value)
{
begindate = DateTime.Now;
}
dgvEvents.Rows[e.RowIndex].Cells["BeginTime"].Value = begindate;
}
}
}
//if (dgvEvents.CurrentCell != null && dgvEvents.CurrentCell.ColumnIndex == 2 )
//{
// DataGridViewCell s = dgvEvents.CurrentCell as DataGridViewCell;
// if (s.Tag != null && (DateTime.Parse(s.Tag.ToString()).Minute != DateTime.Parse(s.Value.ToString()).Minute))
// SendKeys.Send("{left}");
// s.Tag = s.Value.ToString();
//}
}
private void dgvEvents_CellClick(object sender, DataGridViewCellEventArgs e)
{
//点击开始时间时显示时间
if (dgvEvents.CurrentCell.ColumnIndex == 2 && dgvEvents.CurrentCell.EditedFormattedValue.ToString() == "")
{
dgvEvents.CurrentCell.Value = DateTime.Now;
SendKeys.Send("{Tab}");
}
//点击Sign列时显示持续事件标记
if (dgvEvents.CurrentCell.ColumnIndex == 3)
{
if (dgvEvents.CurrentCell.EditedFormattedValue.ToString() == "" && dgvEvents.CurrentRow.Cells["BeginTime"].EditedFormattedValue.ToString() != "")
{
dgvEvents.CurrentCell.Value = "-->";
btnSave.Focus();
//SendKeys.Send("{Tab}");
}
else
{
dgvEvents.CurrentCell.Value = "";
dgvEvents.CurrentRow.Cells["EndTime"].Value = "";
btnSave.Focus();
//SendKeys.Send("{Tab}");
}
}
//点击结束时间时判断是否持续事件,并显示时间
if (dgvEvents.CurrentCell.ColumnIndex == 4)
{
if (dgvEvents.CurrentRow.Cells[3].EditedFormattedValue.ToString() != "" && dgvEvents.CurrentCell.EditedFormattedValue.ToString() == "")
{
dgvEvents.CurrentRow.Cells["EndTime"].Value = DateTime.Now;
btnSave.Focus();
//SendKeys.Send("{Tab}");
}
}
}
private void btnDelete_Click(object sender, EventArgs e)
{
if (dgvEvents.CurrentRow != null && dgvEvents.CurrentRow.Tag != null)
{
string objectName = dgvEvents.CurrentRow.Cells["EventName"].EditedFormattedValue.ToString();
int objectId = int.Parse(dgvEvents.CurrentRow.Cells["EventName"].Tag.ToString());
bool b = false;
if (objectId == 7)
{
b = true;
}
if (_record.StateName == "手术结束" || _record.StateName == "麻醉复苏结束")
{
if (objectId < 10)
{
b = true;
}
if (objectName == "插管" || objectName == "拔管" || objectName == "喉罩" || objectName == "拔喉罩")
{
b = false;
}
}
if (b == true)
{
MessageBox.Show("删除失败!\n\r" + "选择的事件不可删除 只可修改!");
return;
}
//string messang = string.Format("确定要删除:{0}吗?", objectName);
//DialogResult dr = MessageBox.Show(messang, "删除提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
//if (dr == System.Windows.Forms.DialogResult.OK)
//{
if (dgvEvents.CurrentRow.Tag != null)
{
int id = Convert.ToInt32(dgvEvents.CurrentRow.Tag);
FactEvents er = _record.FactEventsList.Where(p => p.Id == id).ToList()[0];
if (er != null)
{
if (zgcAnaesRecord != null)
er.clearAddObj(zgcAnaesRecord);
BFactEvents.Delete(er);
DelEventTime(er);
IsDeleteConcet = true;
_record.FactEventsList.Remove(er);
dgvEvents.Rows.Remove(dgvEvents.CurrentRow);
}
}
else
{
if (dgvEvents.CurrentRow.Cells["EventName"].Value != null)
{
dgvEvents.Rows.Remove(dgvEvents.CurrentRow);
}
}
//}
}
else
{
if (dgvEvents.CurrentRow.Cells["EventName"].Value != null)
{
dgvEvents.Rows.Remove(dgvEvents.CurrentRow);
}
}
}
private void btnSave_Click(object sender, EventArgs e)
{
#region
foreach (DataGridViewRow dr in dgvEvents.Rows)
{
if (dr.Cells[1].Value != null)
{
if (dr.Cells["BeginTime"].EditedFormattedValue.ToString() == "")
{
MessageBox.Show("保存失败!\n\r" + "请输入:" + dr.Cells[0].EditedFormattedValue.ToString() + ":" + dr.Cells["EventName"].EditedFormattedValue.ToString() + "的开始时间!");
dgvEvents.CurrentCell = dr.Cells["BeginTime"];
dgvEvents.BeginEdit(true);
return;
}
else
{
DateTime Begin = Convert.ToDateTime(dr.Cells["BeginTime"].Value.ToString());
if (Begin > DateTime.Now.AddHours(5))
{
MessageBox.Show("保存失败!\n\r 事件开始时间不能大于当前时间5个小时 请检查!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);//药品名称
dgvEvents.CurrentCell = dr.Cells["BeginTime"];
dgvEvents.BeginEdit(true);
return;
}
}
}
if (dr.Cells["EndTime"].Value != null)
{
if (dr.Cells["EndTime"].EditedFormattedValue.ToString() != "")
{
DateTime Begin = Convert.ToDateTime(dr.Cells["EndTime"].Value.ToString());
if (Begin > DateTime.Now.AddHours(5))
{
MessageBox.Show("保存失败!\n\r 事件结束时间不能大于当前时间5个小时 请检查!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);//药品名称
dgvEvents.CurrentCell = dr.Cells["BeginTime"];
dgvEvents.BeginEdit(true);
return;
}
}
}
}
//foreach (DataGridViewRow dr in dgvEvents.Rows)
//{
// if (dr.Cells["EventName"].Value != null && _record.StateName != 2)
// {
// string messing = "";
// bool timeistrue = BOperationRecord.IfTimeisTrue(_record.ParentId == 0 ? true : false, _record, dr.Cells["EventName"].Value.ToString(), Convert.ToDateTime(dr.Cells["BeginTime"].Value.ToString()), ref messing);
// if (messing != "") MessageBox.Show("保存失败!\n\r" + messing);
// if (timeistrue == false) return;
// }
//}
#endregion
bool IsChage = false;
int second = 0;
foreach (DataGridViewRow dr in dgvEvents.Rows)
{
if (dr.Cells["EventName"].Value == null || dr.Cells["EventName"].Value.ToString().Trim() == "") continue;
//实例化FactEvents对象
FactEvents _event = new FactEvents();
_event.EventTypeId = EventTypeId;
_event.PatientId = _record.PatientId;
GetEvent(dr, _event);
if (_event.EventName == null) continue;
if (dr.Cells["BeginTime"].EditedFormattedValue.ToString() != "")
{
string begindate = Convert.ToDateTime(dr.Cells["BeginTime"].Value.ToString()).ToString("yyyy-MM-dd HH:mm:00");
_event.EventBeginTime = Convert.ToDateTime(begindate);//开始时间
if (dr.Cells["EventName"].Value.ToString() != "入室")
{
second++;
_event.EventBeginTime = _event.EventBeginTime.Value.AddSeconds(second);
if (second > 5) second = 0;
}
}
_event.EventEndTime = dr.Cells["EndTime"].EditedFormattedValue.ToString() != "" ? Convert.ToDateTime(dr.Cells["EndTime"].Value.ToString()) : _event.EventBeginTime;
if (dr.Cells["Remark"].EditedFormattedValue.ToString() != "")
{
_event.Remark = dr.Cells["Remark"].EditedFormattedValue.ToString();
}
else
{
_event.Remark = "";
}
if (dr.Cells["EventValue"].EditedFormattedValue.ToString() != "")
{
_event.EventValue = dr.Cells["EventValue"].Value.ToString();
}
_event.IsContinue = dr.Cells["Continue"].EditedFormattedValue.ToString() != "" ? 1 : 0;
if (dr.Tag == null)
{
_event.OperatorNo = PublicMethod.OperatorNo;
_event.OperatorName = PublicMethod.OperatorName;
_event.OperateDate = DateTime.Now;
//if (_event.EventName == "出室") continue;
//将事件对象保存到集合
int _eventId = BFactEvents.Insert(_event);
_event.Id = _eventId;
_record.FactEventsList.Add(_event);
//将新增的事件Id保存到Row
dr.Tag = _eventId;
//if (dr.Tag != null && _eventId > 0)
// SetEventTime(_event, ref IsChage);
}
else
{
_event.Id = Convert.ToInt32(dr.Tag);
//将修改的事件保存到集合
foreach (FactEvents FactEvents in _record.FactEventsList)
{
if (FactEvents.Id == _event.Id)
{
_event.OperatorNo = PublicMethod.OperatorNo;
_event.OperatorName = PublicMethod.OperatorName;
_event.OperateDate = DateTime.Now;
if (zgcAnaesRecord != null)
FactEvents.clearAddObj(zgcAnaesRecord);
_record.FactEventsList.Remove(FactEvents);
_record.FactEventsList.Add(_event);
//修改时间对象
if (BFactEvents.Update(_event) > 0)
{
SetEventTime(_event, ref IsChage);
}
break;
}
}
}
//增加事件的使用频次
Events events = BEvents.SelectSingle(_event.EventId, RecursiveType.None, 0);
events.UseRate += 1;
BEvents.Update(events);
}
new frmMessageBox().Show();
EventParam();
//this.Close();
}
private void SetEventTime(FactEvents _event, ref bool IsChage)
{
if (_event != null && _event.EventName == "机控呼吸")
{
if (_event.EventValue != null)
{
DateTime EventEndTime = _event.EventEndTime.Value;
if (_event.IsContinue == 1 && _event.EventEndTime.Value == _event.EventBeginTime.Value)
{
EventEndTime = OperationRecord.getOpeMaxTime(_record);
}
if (EventEndTime > DateTime.Now) EventEndTime = DateTime.Now;
DateTime insTime = GetRecordTime(_event.EventBeginTime.Value);
TimeSpan tsp = EventEndTime - insTime;
List<PhysioData> PhysioDatas = new List<PhysioData>();
foreach (var addPP in _record.PhysioConfigList)
{
if (addPP.Id != 12) continue;
for (int i = 0; i < (tsp.TotalMinutes / 5); i++)
{
PhysioData pdTemp = PhysioDataConfig.newPhysioData(addPP, _record.Id.Value, insTime.AddMinutes(i * 5), Convert.ToInt32(_event.EventValue));
PhysioDatas.Add(pdTemp);
}
}
if (PhysioDatas.Count > 0)
{
PhysioDataService.AddPhysioDatas(PhysioDatas);
UpdatePhysioDataResp();
}
}
}
if (_event != null && _event.EventName == "入室" && _record.InRoomTime != _event.EventBeginTime)
{
_record.InRoomTime = _event.EventBeginTime; IsChage = true;
BOperationRecord.Update("InRoomTime=@InRoom where Id=@id ", new AIMSModel.ParameterList("@InRoom", _record.InRoomTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
}
if (_event != null && _event.EventName == "手术开始" && _record.OperationBeginTime != _event.EventBeginTime)
{
_record.OperationBeginTime = _event.EventBeginTime; IsChage = true;
BOperationRecord.Update("OperationBeginTime=@OperationBegin where Id=@id ", new AIMSModel.ParameterList("@OperationBegin", _record.OperationBeginTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
}
if (_event != null && _event.EventName == "麻醉开始" && _record.AnesthesiaBeginTime != _event.EventBeginTime)
{
_record.AnesthesiaBeginTime = _event.EventBeginTime; IsChage = true;
BOperationRecord.Update("AnesthesiaBeginTime=@AnesthesiaBeginTime where Id=@id ", new AIMSModel.ParameterList("@AnesthesiaBeginTime", _record.AnesthesiaBeginTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
}
if (_event != null && _event.EventName == "麻醉完成" && _record.AnesthesiaEndTime != _event.EventBeginTime)
{
_record.AnesthesiaEndTime = _event.EventBeginTime; IsChage = true;
BOperationRecord.Update("AnesthesiaEndTime=@AnesthesiaEndTime where Id=@id ", new AIMSModel.ParameterList("@AnesthesiaEndTime", _record.AnesthesiaEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
}
if (_event != null && _event.EventName == "插管" && _record.SpileInTime != _event.EventBeginTime)
{
_record.SpileInTime = _event.EventBeginTime; IsChage = true;
BOperationRecord.Update(" SpileInTime=@SpileIn where Id=@id ", new AIMSModel.ParameterList("@SpileIn", _record.SpileInTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
UpdatePhysioDataResp();
}
if (_event != null && _event.EventName == "喉罩" && _record.SpileInTime != _event.EventBeginTime)
{
_record.SpileInTime = _event.EventBeginTime; IsChage = true;
BOperationRecord.Update(" SpileInTime=@SpileIn where Id=@id ", new AIMSModel.ParameterList("@SpileIn", _record.SpileInTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
UpdatePhysioDataResp();
}
if (_event != null && _event.EventName == "拔管" && _record.SpileOutTime != _event.EventBeginTime)
{
_record.SpileOutTime = _event.EventBeginTime; IsChage = true;
BOperationRecord.Update(" SpileOutTime=@SpileOut where Id=@id ", new AIMSModel.ParameterList("@SpileOut", _record.SpileOutTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
UpdatePhysioDataResp();
}
if (_event != null && _event.EventName == "拔喉罩" && _record.SpileOutTime != _event.EventBeginTime)
{
_record.SpileOutTime = _event.EventBeginTime; IsChage = true;
BOperationRecord.Update(" SpileOutTime=@SpileOut where Id=@id ", new AIMSModel.ParameterList("@SpileOut", _record.SpileOutTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
UpdatePhysioDataResp();
}
if (_event != null && _event.EventName == "手术结束" && _record.OperationEndTime != _event.EventBeginTime)
{
_record.OperationEndTime = _event.EventBeginTime; IsChage = true;
BOperationRecord.Update("OperationEndTime=@OperationEnd where Id=@id ", new AIMSModel.ParameterList("@OperationEnd", _record.OperationEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
}
if (_event != null && _event.EventName == "出室" && _record.OutRoomTime != _event.EventBeginTime)
{
_record.OutRoomTime = _event.EventBeginTime; IsChage = true;
BOperationRecord.Update("OutRoomTime=@OutRoom where Id=@id ", new AIMSModel.ParameterList("@OutRoom", _record.OutRoomTime.Value.ToString("yyyy-MM-dd HH:mm:ss"), "@id", _record.Id));
}
}
public DateTime GetRecordTime(DateTime pdTemp, int collectInterval = 5)
{
DateTime result = Convert.ToDateTime(pdTemp.ToString("yyyy-MM-dd HH:mm:00.000"));
//小于入室时间默认不画
for (int i = 0; i < (480 / 5); i++)
{//InRoomTime.Value
DateTime tempTime = _record.PageBegin.AddMinutes(i * 5);
if (tempTime >= result && result < tempTime.AddMinutes(5))
{
result = tempTime;
break;
}
}
return result;
}
private void DelEventTime(FactEvents _event)
{
if (_event != null && _event.EventName == "机控呼吸")
{
UpdatePhysioDataResp();
}
//if (_event != null && _event.EventName == "入室" ) { _record.InRoomTime = null; }
if (_event != null && _event.EventName == "手术开始")
{
_record.OperationBeginTime = null;
BOperationRecord.Update(" OperationBeginTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
}
if (_event != null && _event.EventName == "手术结束")
{
_record.OperationEndTime = null;
BOperationRecord.Update(" OperationEndTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
}
if (_event != null && _event.EventName == "麻醉开始")
{
_record.AnesthesiaBeginTime = null;
BOperationRecord.Update("AnesthesiaBeginTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
}
if (_event != null && _event.EventName == "麻醉完成")
{
_record.AnesthesiaEndTime = null;
BOperationRecord.Update(" AnesthesiaEndTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
}
if (_event != null && _event.EventName == "插管")
{
_record.SpileInTime = null;
BOperationRecord.Update(" SpileInTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
UpdatePhysioDataResp();
}
if (_event != null && _event.EventName == "喉罩")
{
_record.SpileInTime = null;
BOperationRecord.Update(" SpileInTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
UpdatePhysioDataResp();
}
if (_event != null && _event.EventName == "拔管")
{
_record.SpileOutTime = null;
BOperationRecord.Update(" SpileOutTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
UpdatePhysioDataResp();
}
if (_event != null && _event.EventName == "拔喉罩")
{
_record.SpileOutTime = null;
BOperationRecord.Update(" SpileOutTime=null where Id=@id ", new AIMSModel.ParameterList("@id", _record.Id));
UpdatePhysioDataResp();
}
//AIMSModel.ParameterList keyValuePairs = new AIMSModel.ParameterList();
// keyValuePairs.Add("@InRoomTime", _record.InRoomTime.HasValue ? (object)_record.InRoomTime.Value : (object)DBNull.Value);
// keyValuePairs.Add("@OutRoomTime", _record.OutRoomTime.HasValue ? (object)_record.OutRoomTime.Value : (object)DBNull.Value);
// keyValuePairs.Add("@OperationBeginTime", _record.OperationBeginTime.HasValue ? (object)_record.OperationBeginTime.Value : (object)DBNull.Value);
// keyValuePairs.Add("@OperationEndTime", _record.OperationEndTime.HasValue ? (object)_record.OperationEndTime.Value : (object)DBNull.Value);
// keyValuePairs.Add("@AnesthesiaBeginTime", _record.AnesthesiaBeginTime.HasValue ? (object)_record.AnesthesiaBeginTime.Value : (object)DBNull.Value);
// keyValuePairs.Add("@AnesthesiaEndTime", _record.AnesthesiaEndTime.HasValue ? (object)_record.AnesthesiaEndTime.Value : (object)DBNull.Value);
// keyValuePairs.Add("@SpileInTime", _record.SpileInTime.HasValue ? (object)_record.SpileInTime.Value : (object)DBNull.Value);
// keyValuePairs.Add("@SpileOutTime", _record.SpileOutTime.HasValue ? (object)_record.SpileOutTime.Value : (object)DBNull.Value);
// keyValuePairs.Add("@Id", _record.Id);
// BOperationRecord.Update("update OperationRecord set InRoomTime=@InRoomTime,OutRoomTime=@OutRoomTime,OperationBeginTime=@OperationBeginTime,OperationEndTime=@OperationEndTime,AnesthesiaBeginTime=@AnesthesiaBeginTime,AnesthesiaEndTime=@AnesthesiaEndTime,SpileInTime=@SpileInTime,SpileOutTime=@SpileOutTime where Id=@Id", keyValuePairs);
}
private static void GetEvent(DataGridViewRow dr, FactEvents _event)
{
try
{
if (dr.Cells["EventName"].Tag == null)
{
string name = dr.Cells["EventName"].EditedFormattedValue.ToString();
Events events = BEvents.SelectSingle(" Name='" + name + "'", null);
if (events == null)
{
events = new Events();
events.Name = name;
events.HelpCode = PublicMethod.GetFirstLetter(name);
events.UseRate = 1;
events.IsValid = 1;
events.OperatorNo = PublicMethod.OperatorNo;
events.OperatorName = PublicMethod.OperatorName;
events.OperateDate = DateTime.Now;
events.Id = BEvents.Insert(events);
}
_event.EventId = events.Id;
_event.EventName = events.Name;
}
else
{
_event.EventId = Convert.ToInt32(dr.Cells["EventName"].Tag);
_event.EventName = BEvents.SelectSingle(_event.EventId).Name;
}
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
private void btnAdd_Click(object sender, EventArgs e)
{
if (dgvEvents.CurrentCell.ColumnIndex != 1) return;
string name = dgvEvents.CurrentCell.EditedFormattedValue.ToString();
Events et = BEvents.SelectSingle(" Name='" + name + "'", null);
if (et != null)
{
MessageBox.Show("保存失败!\n\r" + name + "已存在!");
return;
}
DialogResult dr = MessageBox.Show("确定要将:" + name + " 增加到事件字典中吗?", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (dr == DialogResult.OK)
{
Events events = new Events();
events.Name = name;
events.HelpCode = PublicMethod.GetFirstLetter(name);
events.UseRate = 1;
events.IsValid = 1;
events.OperatorNo = PublicMethod.OperatorNo;
events.OperatorName = PublicMethod.OperatorName;
events.OperateDate = DateTime.Now;
events.Id = BEvents.Insert(events);
dgvEvents.CurrentCell.Tag = events.Id;
btnSave.Enabled = true;
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void textBoxX1_TextChanged(object sender, EventArgs e)
{
this.TabSelEvents.SelectedTabChanged -= new System.EventHandler<DevComponents.DotNetBar.SuperTabStripSelectedTabChangedEventArgs>(this.TabSelEvents_SelectedTabChanged_1);
TabSelEvents.SelectedTab = tab1; ;
TextBoxX tb1 = sender as TextBoxX;
if (tb1.Text.Trim() != "")
{
DataTable table = BEvents.SelectIdNameCode(tb1.Text);
FullCommonlyEvents(superTabControlPanel1, table);
}
else
{
DataTable dt = BEvents.GetCommonlyEvents();
FullCommonlyEvents(superTabControlPanel1, dt);
}
this.TabSelEvents.SelectedTabChanged += new System.EventHandler<DevComponents.DotNetBar.SuperTabStripSelectedTabChangedEventArgs>(this.TabSelEvents_SelectedTabChanged_1);
}
private void dgvEvents_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (e.Control.GetType().Equals(typeof(DevComponents.DotNetBar.Controls.DataGridViewDateTimeInputEditingControl)))
((DevComponents.DotNetBar.Controls.DataGridViewDateTimeInputEditingControl)e.Control).DateTimeSelectorVisibility = DevComponents.Editors.DateTimeAdv.eDateTimeSelectorVisibility.DateSelector;
}
private void frmFactEventsNew_FormClosing(object sender, FormClosingEventArgs e)
{
//List<FactEvents> UpdateRecordList = GetEventsList();
//if (UpdateRecordList.Count > 0)
//{
// DialogResult dialogResult = MessageBox.Show("记录尚未保存,是否保存当前记录?", "系统提示", MessageBoxButtons.YesNo);
// if (dialogResult == DialogResult.Yes)
// {
// btnSave_Click(null, null);
// }
//}
//this.Hide();
//e.Cancel = true;
if (IsDeleteConcet == true)
{
EventParam();
}
}
public bool equelEvents(FactEvents oldDrug, FactEvents newDrug)
{
bool b = true;
if (oldDrug.Remark != newDrug.Remark) b = false;
//if (oldDrug.Value != newDrug.Value) b = false;
if (oldDrug.EventBeginTime != null && newDrug.EventBeginTime != null && oldDrug.EventBeginTime.Value.ToString("yyyy-MM-dd HH:mm") != newDrug.EventBeginTime.Value.ToString("yyyy-MM-dd HH:mm")) b = false;
if (oldDrug.EventEndTime != newDrug.EventEndTime && oldDrug.EventEndTime.Value.ToString("HH:mm") != newDrug.EventEndTime.Value.ToString("HH:mm")) b = false;
return b;
}
private void btnTypeManager_Click(object sender, EventArgs e)
{
frmAnaesthesiaEvents fae = new frmAnaesthesiaEvents();
fae.Type = 2;
fae.ShowDialog();
BindAnaesthesiaEvents();
TabSelEvents.SelectedTab = tab1;
}
private void TabSelEvents_SelectedTabChanged_1(object sender, SuperTabStripSelectedTabChangedEventArgs e)
{
SuperTabItem item = TabSelEvents.SelectedTab;
if (item.Tag == null || item.Tag.ToString() == "")
{
DataTable dt = BEvents.GetCommonlyEvents();
FullCommonlyEvents((SuperTabControlPanel)tab1.AttachedControl, dt);
}
else
{
DataTable dt = BEvents.GetEventsByIds(item.Tag.ToString());
FullCommonlyEvents((SuperTabControlPanel)item.AttachedControl, dt);
}
}
private void BindAnaesthesiaEvents()
{
try
{
for (int i = TabSelEvents.Tabs.Count; i > 1; i--)
{
TabSelEvents.Tabs.RemoveAt(i - 1);
}
List<AnaesthesiaEvents> AnaesthesiaList = BAnaesthesiaEvents.Select(" IsAutomatic=2 and IsValid=1 ", null, RecursiveType.None, 0);
foreach (AnaesthesiaEvents item in AnaesthesiaList)
{
string Name = "";
char[] separatedCharacters = item.Name.ToCharArray();
for (int i = 0; i < separatedCharacters.Length; i++)
{
Name += separatedCharacters[i] + "\n";
}
SuperTabItem spt = stc.CreateTab(Name);
spt.Tag = item.TheEventsId;
spt.SymbolColor = Color.White;
SuperTabControlPanel superTabControlPanel = new SuperTabControlPanel();
superTabControlPanel.Dock = System.Windows.Forms.DockStyle.Fill;
superTabControlPanel.CanvasColor = Color.White;
TabSelEvents.Controls.Add(superTabControlPanel);
TabSelEvents.Tabs.Add(spt);
superTabControlPanel.TabItem = spt;
spt.AttachedControl = superTabControlPanel;
TabSelEvents.FixedTabSize = new Size(30, 100);
};
}
catch (Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
private void dgvEvents_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
if (e.Exception.Message == "DataGridViewComboBoxCell 值无效。")
{
try
{
object value = dgvEvents.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
if (value == null || value.ToString().Trim() == "")
{
e.ThrowException = false;
}
else
{
if (!((DataGridViewComboBoxCell)dgvEvents.Rows[e.RowIndex].Cells[e.ColumnIndex]).Items.Contains(value))
{
((DataGridViewComboBoxCell)dgvEvents.Rows[e.RowIndex].Cells[e.ColumnIndex]).Items.Add(value);
e.ThrowException = false;
}
}
}
catch (Exception ex)
{
e.ThrowException = false;
PublicMethod.WriteLog(ex);
}
}
}
private void dgvEvents_CurrentCellDirtyStateChanged(object sender, EventArgs e)
{
if (dgvEvents.IsCurrentCellDirty)
{
dgvEvents.CommitEdit(DataGridViewDataErrorContexts.Commit);
}
}
private void txtQuery_Click(object sender, EventArgs e)
{
TextBoxX box = sender as TextBoxX;
box.Text = "";
}
public void UpdatePhysioDataResp()
{
BOperationRecord.UpdatePhysioDataRespByTime(_record);
string PhysioDataConfigIds = "3,12";
DataTable dtPhysioData = BOperationRecord.getByOpeIDIsPhysioData(_record.Id.Value, PhysioDataConfigIds);
List<string> Ids = PhysioDataConfigIds.Split(',').ToList();
if (dtPhysioData != null && dtPhysioData.Rows.Count > 0)
{
foreach (PhysioDataConfig addPP in _record.PhysioConfigList)
{
if (!Ids.Contains(addPP.Id.ToString())) continue;
if (zgcAnaesRecord != null)
addPP.clearAddObj(zgcAnaesRecord);
if (addPP.IsDefalultShow == false) continue;
for (int i = 0; i < dtPhysioData.Rows.Count; i++)
{
if (dtPhysioData.Rows[i]["Name"].ToString().Equals(addPP.Name.ToString()))
{
PhysioData pdTemp = PhysioDataConfig.newPhysioData(addPP, _record.Id.Value, DateTime.Parse(dtPhysioData.Rows[i]["RecordTime"].ToString()), dtPhysioData.Rows[i]["Value"].ToString());
addPP.AddPointItem(pdTemp, false);
}
}
}
}
}
private void dgvEvents_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
{
//if (dgvEvents.Rows[e.RowIndex].Cells["BeginTime"].EditedFormattedValue.ToString() == "")
//{
// dgvEvents.Rows[e.RowIndex].Cells["BeginTime"].Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm");//默认当前时间‘
// TimeSpan tsp = DateTime.Now - _record.InRoomTime.Value;
// if (tsp.TotalHours > 12)
// {
// DateTime begindate = new DateTime(_record.InRoomTime.Value.Year, _record.InRoomTime.Value.Month, _record.InRoomTime.Value.Day, DateTime.Now.Hour, DateTime.Now.Minute, 0);
// if (begindate > _record.InRoomTime.Value)
// {
// begindate = DateTime.Now;
// }
// dgvEvents.Rows[e.RowIndex].Cells["BeginTime"].Value = begindate;
// }
//}
}
}
public class DataGridViewComboEditTipBoxColumn : DataGridViewComboBoxColumn
{
public DataGridViewComboEditTipBoxColumn()
{
DataGridViewComboEditTipBoxCell obj = new DataGridViewComboEditTipBoxCell();
this.CellTemplate = obj;
}
}
//要加入的类
public class DataGridViewComboEditTipBoxCell : DataGridViewComboBoxCell
{
private System.Windows.Forms.ToolTip toolTip1;
public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
{
base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
try
{
ComboBox comboBox = (ComboBox)base.DataGridView.EditingControl;
toolTip1 = new System.Windows.Forms.ToolTip();
if (comboBox != null)
{
comboBox.DropDownStyle = ComboBoxStyle.DropDown;
comboBox.AutoCompleteMode = AutoCompleteMode.Suggest;
comboBox.Validating += new CancelEventHandler(comboBox_Validating);
comboBox.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
//下拉表单重绘事件
comboBox.DrawItem += new System.Windows.Forms.DrawItemEventHandler(ComboBox_DrawItem);
comboBox.DropDownClosed += new System.EventHandler(ComboBox_DropDownClosed);
}
}
catch (Exception)
{
}
}
//[主程序中的代码]
private void ComboBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
{
try
{
// 绘制背景
e.DrawBackground();
//绘制列表项目
e.Graphics.DrawString((sender as ComboBox).Items[e.Index].ToString(), e.Font, System.Drawing.Brushes.Black, e.Bounds);
//将高亮的列表项目的文字传递到toolTip1(之前建立ToolTip的一个实例)
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
toolTip1.Show((sender as ComboBox).Items[e.Index].ToString(), (sender as ComboBox), e.Bounds.X + e.Bounds.Width, e.Bounds.Y + e.Bounds.Height);
e.DrawFocusRectangle();
}
catch (Exception)
{
toolTip1.Hide((sender as ComboBox));
}
}
//关闭列表时同时关闭toolTip1的显示
private void ComboBox_DropDownClosed(object sender, System.EventArgs e)
{
try
{
if (toolTip1 != null) toolTip1.Hide((sender as ComboBox));
}
catch (Exception)
{
}
}
void comboBox_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
DataGridViewComboBoxEditingControl cbo = sender as DataGridViewComboBoxEditingControl;
if (cbo == null || cbo.Text.Trim() == string.Empty) return;
DataGridView grid = cbo.EditingControlDataGridView;
//if ((grid.Name == "dgvOutput" && grid.CurrentCell.ColumnIndex == 1) || (grid.Name == "dgvEvents" && grid.CurrentCell.ColumnIndex == 6) || grid.CurrentCell.ColumnIndex == 12)
if (grid.CurrentCell.ColumnIndex != 1 && grid.CurrentCell.ColumnIndex != 4 && grid.CurrentCell.ColumnIndex != 6 && grid.CurrentCell.ColumnIndex != 12) return;
object value = cbo.Text;
// Add value to list if not there
if (cbo.Items.IndexOf(value) == -1)
{
DataGridViewComboBoxCell cboCol = (DataGridViewComboBoxCell)grid.CurrentCell;
// Must add to both the current combobox as well as the template, to avoid duplicate entries
cbo.Items.Add(value);
cboCol.Items.Add(value);
grid.CurrentCell.Value = value;
}
}
}
}