989 lines
42 KiB
C#
989 lines
42 KiB
C#
using AIMSExtension;
|
||
using DevComponents.DotNetBar.Controls;
|
||
using DevComponents.Editors.DateTimeAdv;
|
||
using Newtonsoft.Json;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Windows.Forms;
|
||
using static System.Net.Mime.MediaTypeNames;
|
||
|
||
namespace DrawGraph
|
||
{
|
||
/// <summary>
|
||
/// 麻醉前访视单
|
||
/// </summary>
|
||
public class AnalgesiaDataBottonManage : AreaManageBase
|
||
{
|
||
|
||
private OperationRecord myOpeRecord = null;
|
||
public AnalgesiaDataBottonManage() { }
|
||
public AnalgesiaDataBottonManage(object _operationRecor, DrawGraph.ZedGraphControl _zedControl, TemplateManage _template, string _name) : base(_operationRecor, _zedControl, _template, _name)
|
||
{ }
|
||
|
||
public void init()
|
||
{
|
||
//自己要用的手术对象
|
||
myOpeRecord = OpeRecord as OperationRecord;
|
||
}
|
||
#region 重写的事件
|
||
/// <summary>
|
||
/// 鼠标点击画板
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
public override void MouseDown(ZedGraphControl sender, MouseEventArgs e)
|
||
{
|
||
}
|
||
public override void MouseMove(ZedGraphControl sender, MouseEventArgs e)
|
||
{
|
||
}
|
||
public override void MouseUp(ZedGraphControl sender, MouseEventArgs e)
|
||
{
|
||
}
|
||
public override void MouseDoubleClick(ZedGraphControl sender, MouseEventArgs e)
|
||
{
|
||
}
|
||
public override void KeyUp(ZedGraphControl sender, KeyEventArgs e)
|
||
{
|
||
}
|
||
|
||
public override void editAr_Click(object sender, EventArgs e)
|
||
{
|
||
SelectDictText.Hidden();
|
||
////传过来的数据是不是可编辑的
|
||
//AbleEditPackObj aEdit1S = sender as AbleEditPackObj;
|
||
//if (aEdit1S == null) return;
|
||
////找到这个组件
|
||
//AbleEditPackObj aEdit1 = PackManage.ListPob.FirstOrDefault<PackObjBase>(s => s is AbleEditPackObj && s.PackTag == aEdit1S.PackTag) as AbleEditPackObj;
|
||
//if (aEdit1 == null) return;
|
||
|
||
//if (aEdit1.ControlTitleText == "手术" || aEdit1.ControlTitleText == "诊断" || aEdit1.ControlTitleText == "人员")
|
||
//{
|
||
// Control conl = aEdit1.CControl;
|
||
// aEdit1.IsVisible = !aEdit1.IsVisible;
|
||
// conl.Leave -= new EventHandler(txt_Leave);
|
||
// aEdit1S.CControl.MouseDown -= new MouseEventHandler(CControl_MouseDown);
|
||
// aEdit1S.CControl.KeyUp -= new KeyEventHandler(CControl_KeyUp2);
|
||
// aEdit1S.CControl.TextChanged -= new EventHandler(CControl_TextChanged);
|
||
// aEdit1S.CControl.KeyPress -= new KeyPressEventHandler(CControl_KeyPress); ;
|
||
// //根据数据源名称进行不同的事件处理
|
||
// switch (aEdit1.ClassDataSourceName)
|
||
// {
|
||
// case "OperationRecord.Applydiagnose": //手术诊断
|
||
// opeDisease_Click(aEdit1, e);
|
||
// break;
|
||
// case "OperationRecord.Applyoperation": //手术诊断
|
||
// ope_Click(aEdit1, e);
|
||
// break;
|
||
// }
|
||
//}
|
||
////txt_DoubleClick(aEdit1.CControl, null);
|
||
}
|
||
|
||
//得到当前页数
|
||
private void GetcurrentPage()
|
||
{
|
||
DateTime EndTime = OperationRecord.getOpeMaxTime(myOpeRecord);
|
||
EndTime = DateTime.Parse(EndTime.ToString("yyyy-MM-dd HH:mm"));
|
||
TimeSpan tsp = (TimeSpan)(EndTime - myOpeRecord.sharpBegin);
|
||
double db = tsp.TotalHours / 4;
|
||
if (db == ((int)tsp.TotalHours / 4))
|
||
myOpeRecord.currentPage = (int)db;
|
||
else
|
||
myOpeRecord.currentPage = (int)db + 1;
|
||
if (myOpeRecord.currentPage == 0) myOpeRecord.currentPage = 1;
|
||
}
|
||
#region 初始化时间轴
|
||
/// <summary>
|
||
/// 设置页面的开始时间和结束时间
|
||
/// </summary>
|
||
/// <param name="_operationRecord">手术信息对象</param>
|
||
private void setPageTime(DateTime begin)
|
||
{
|
||
if (myOpeRecord.pageCount == 0)
|
||
{
|
||
myOpeRecord.pageCount = 1;
|
||
myOpeRecord.sharpBegin = getSharpTime(begin);
|
||
myOpeRecord.PageBegin = getPageBegin(begin, collectInterval, 120);
|
||
myOpeRecord.lastPageBegin = myOpeRecord.PageBegin.AddHours(120 / 60);
|
||
|
||
if (myOpeRecord.phListPack != null)
|
||
{
|
||
Panel pan3 = myOpeRecord.phListPack.CControl as Panel;
|
||
if (pan3 != null)
|
||
{
|
||
pan3.Controls.Clear();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 根据采集间隔,确定页面时间跨度和页面开始时间
|
||
/// </summary>
|
||
/// <param name="curTime">给定时间(文本)</param>
|
||
/// <param name="collectInterval">采集间隔(分钟)</param>
|
||
/// <param name="timeSpan">页面时间跨度</param>
|
||
/// <returns>页面显示的开始时间</returns>
|
||
private DateTime getPageBegin(DateTime dt, double collectInterval, double timeSpan)
|
||
{
|
||
try
|
||
{
|
||
DateTime pageBegin = dt.Date.AddHours(dt.Hour);
|
||
int ci = (int)(collectInterval * 60);
|
||
if (ci <= 30)
|
||
{
|
||
if (dt.Minute >= 30)
|
||
{
|
||
pageBegin = pageBegin.AddMinutes(30);
|
||
}
|
||
timeSpan = 30;
|
||
}
|
||
else if (ci <= 60)
|
||
{
|
||
timeSpan = 60;
|
||
}
|
||
else
|
||
{
|
||
timeSpan = 120;
|
||
TimeSpan ts = pageBegin - myOpeRecord.sharpBegin;
|
||
int h = ts.Hours;
|
||
h /= 2;
|
||
pageBegin = myOpeRecord.sharpBegin.AddHours(h * 2);
|
||
}
|
||
return pageBegin;
|
||
}
|
||
catch (Exception exp)
|
||
{
|
||
throw exp;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 获取系统的整点时刻
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
private DateTime getSharpTime(DateTime dt)
|
||
{
|
||
int ci = (int)dt.Minute;
|
||
|
||
if (ci >= 50)
|
||
{
|
||
dt = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:50:00"));
|
||
}
|
||
else if (ci >= 40)
|
||
{
|
||
dt = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:40:00"));
|
||
}
|
||
else if (ci >= 30)
|
||
{
|
||
dt = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:30:00"));
|
||
}
|
||
else if (ci >= 20)
|
||
{
|
||
dt = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:20:00"));
|
||
}
|
||
else if (ci >= 10)
|
||
{
|
||
dt = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:10:00"));
|
||
}
|
||
else if (ci < 10)
|
||
{
|
||
dt = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:00:00"));
|
||
}
|
||
//if (ci >= 30)
|
||
//{
|
||
// dt = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:30:00"));
|
||
//}
|
||
//else if (ci < 30)
|
||
//{
|
||
// dt = DateTime.Parse(dt.ToString("yyyy-MM-dd HH:00:00"));
|
||
//}
|
||
return dt;
|
||
}
|
||
private void setXAxisTime(GraphPane myPane, DateTime begin, double pageSpan)
|
||
{
|
||
myPane.XAxis.Scale.Min = new XDate(begin);
|
||
myPane.X2Axis.Scale.Min = myPane.XAxis.Scale.Min;
|
||
myPane.XAxis.Scale.Max = new XDate(begin.AddMinutes(pageSpan));
|
||
myPane.X2Axis.Scale.Max = myPane.XAxis.Scale.Max;
|
||
}
|
||
#endregion
|
||
|
||
public SelectDictText aSyncSelectDict = null;
|
||
public override void Bind()
|
||
{
|
||
base.Bind();
|
||
init();
|
||
aSyncSelectDict = SelectDictText.CreateInstance();
|
||
myOpeRecord.clearAddObj(ZedControl);
|
||
setPageTime(myOpeRecord.InRoomTime.Value);
|
||
setXAxisTime(ZedControl.GraphPane, myOpeRecord.PageBegin, 120);
|
||
GetcurrentPage();
|
||
//SelectDictText.SetValue += ASyncSelectDict_SetValue;
|
||
|
||
List<PackObjBase> ables = PackManage.ListPob.Where<PackObjBase>(s => s is AbleEditPackObj).ToList<PackObjBase>();
|
||
foreach (PackObjBase pack in ables)
|
||
{
|
||
AbleEditPackObj ableEdit = pack as AbleEditPackObj;
|
||
|
||
if (ableEdit != null)
|
||
{
|
||
ableEdit.IsVisible = true;
|
||
ableEdit.CControl.Click -= new EventHandler(txt_Click);
|
||
ableEdit.CControl.Click += new EventHandler(txt_Click);
|
||
if (ableEdit.ControlType == EControlType.DateTimePicker)
|
||
{
|
||
ableEdit.CControl.Leave -= new EventHandler(txt_Leave);
|
||
ableEdit.CControl.Leave += new EventHandler(txt_Leave);
|
||
}
|
||
else if (ableEdit.ControlType == EControlType.Directory)
|
||
{
|
||
|
||
if (ableEdit.ControlTitleText == "手术" || ableEdit.ControlTitleText == "诊断" || ableEdit.ControlTitleText == "人员")
|
||
{
|
||
ableEdit.CControl.DoubleClick -= new EventHandler(txt_DoubleClick1);
|
||
ableEdit.CControl.DoubleClick += new EventHandler(txt_DoubleClick1);
|
||
ableEdit.CControl.MouseDown -= new MouseEventHandler(CControl_MouseDown);
|
||
ableEdit.CControl.MouseDown += new MouseEventHandler(CControl_MouseDown);
|
||
ableEdit.CControl.KeyUp -= new KeyEventHandler(CControl_KeyUp2);
|
||
ableEdit.CControl.KeyUp += new KeyEventHandler(CControl_KeyUp2);
|
||
ableEdit.CControl.KeyPress -= new KeyPressEventHandler(CControl_KeyPress);
|
||
ableEdit.CControl.KeyPress += new KeyPressEventHandler(CControl_KeyPress);
|
||
}
|
||
else
|
||
{
|
||
ableEdit.CControl.DoubleClick -= new EventHandler(txt_DoubleClick);
|
||
ableEdit.CControl.DoubleClick += new EventHandler(txt_DoubleClick);
|
||
ableEdit.CControl.Leave -= new EventHandler(txt_Leave);
|
||
ableEdit.CControl.Leave += new EventHandler(txt_Leave);
|
||
}
|
||
}
|
||
else if (ableEdit.ControlType == EControlType.Directorys)
|
||
{
|
||
DevComponents.DotNetBar.Controls.TokenEditor tokenEditor = ableEdit.CControl as DevComponents.DotNetBar.Controls.TokenEditor;
|
||
tokenEditor.EditTextBox.DoubleClick -= EditTextBox_DoubleClick;
|
||
tokenEditor.EditTextBox.DoubleClick += EditTextBox_DoubleClick;
|
||
tokenEditor.EditTextBox.TextChanged -= EditTextBox_TextChanged;
|
||
tokenEditor.EditTextBox.TextChanged += EditTextBox_TextChanged;
|
||
tokenEditor.Leave -= TokenEditor_Leave;
|
||
tokenEditor.Leave += TokenEditor_Leave;
|
||
|
||
if (ableEdit.ControlTitleText == "手术" || ableEdit.ControlTitleText == "诊断")
|
||
{
|
||
tokenEditor.ValidateToken -= new DevComponents.DotNetBar.Controls.ValidateTokenEventHandler(this.tokenEditor_ValidateToken);
|
||
tokenEditor.ValidateToken += new DevComponents.DotNetBar.Controls.ValidateTokenEventHandler(this.tokenEditor_ValidateToken);
|
||
}
|
||
}
|
||
else if (ableEdit.ControlType == EControlType.CheckBox)
|
||
{
|
||
Panel pan = ableEdit.CControl as Panel;
|
||
if (pan != null)
|
||
{
|
||
foreach (Control conl in pan.Controls)
|
||
{
|
||
CheckBox chBox = conl as CheckBox;
|
||
if (chBox != null)
|
||
{
|
||
chBox.CheckedChanged -= new EventHandler(txt_Leave);
|
||
chBox.CheckedChanged += new EventHandler(txt_Leave);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (ableEdit.ControlType == EControlType.RadioButtonList)
|
||
{
|
||
Panel pan = ableEdit.CControl as Panel;
|
||
if (pan != null)
|
||
{
|
||
foreach (Control conl in pan.Controls)
|
||
{
|
||
CheckBox chBox = conl as CheckBox;
|
||
if (chBox != null)
|
||
{
|
||
chBox.CheckedChanged -= new EventHandler(txt_Leave);
|
||
chBox.CheckedChanged += new EventHandler(txt_Leave);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (ableEdit.ControlType == EControlType.TextBox)
|
||
{
|
||
ableEdit.CControl.KeyDown -= new KeyEventHandler(text_keyDown);
|
||
ableEdit.CControl.KeyDown += new KeyEventHandler(text_keyDown);
|
||
ableEdit.CControl.GotFocus -= new EventHandler(txt_Focus);
|
||
ableEdit.CControl.GotFocus += new EventHandler(txt_Focus);
|
||
((TextBox)ableEdit.CControl).BorderStyle = BorderStyle.Fixed3D;
|
||
|
||
ableEdit.CControl.MouseWheel += new MouseEventHandler(numericUpDown1_MouseWheel);
|
||
ableEdit.CControl.Leave -= new EventHandler(txt_Leave);
|
||
ableEdit.CControl.Leave += new EventHandler(txt_Leave);
|
||
}
|
||
else
|
||
{
|
||
|
||
ableEdit.CControl.Leave -= new EventHandler(txt_Leave);
|
||
ableEdit.CControl.Leave += new EventHandler(txt_Leave);
|
||
}
|
||
SetAbleEditView(ableEdit);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
////取消滚轮事件
|
||
//void numericUpDown1_MouseWheel(object sender, MouseEventArgs e)
|
||
//{
|
||
// base.MouseWheelParam();
|
||
//}
|
||
|
||
private void txt_Focus(object sender, EventArgs e)
|
||
{
|
||
TextBox control = (TextBox)sender;
|
||
if (control == null) return;
|
||
AbleEditPackObj ableEdit = control.Tag as AbleEditPackObj;
|
||
if (ableEdit == null) return;
|
||
if (control.Focused == true && (ableEdit.PackValue == ableEdit.DefaultValue || ableEdit.PackValue == ""))
|
||
control.Clear();
|
||
}
|
||
private void text_keyDown(object sender, KeyEventArgs e)
|
||
{
|
||
((TextBox)sender).Enabled = true;
|
||
if (e.Modifiers.CompareTo(Keys.Control) == 0 && e.KeyCode == Keys.V)
|
||
{
|
||
string val = Clipboard.GetText();
|
||
val = val.Replace("\r", "").Replace("\n", "");
|
||
Clipboard.SetText(val);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 在画完表单后,显示多选单选的默认项
|
||
/// </summary>
|
||
public override void FollowUpMethod()
|
||
{
|
||
base.FollowUpMethod();
|
||
List<PackObjBase> ables = PackManage.ListPob.Where<PackObjBase>(s => s is AbleEditPackObj).ToList<PackObjBase>();
|
||
foreach (PackObjBase pack in ables)
|
||
{
|
||
AbleEditPackObj ableEdit = pack as AbleEditPackObj;
|
||
SetAbleEditView(ableEdit);
|
||
}
|
||
}
|
||
|
||
public override void BindTempData()
|
||
{
|
||
List<PackObjBase> ables = PackManage.ListPob.Where<PackObjBase>(s => s is AbleEditPackObj).ToList<PackObjBase>();
|
||
foreach (PackObjBase pack in ables)
|
||
{
|
||
pack.Draw();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 公共验证方法
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
public override bool Verification()
|
||
{
|
||
List<PackObjBase> editPack = PackManage.ListPob.Where<PackObjBase>(s => s is AbleEditPackObj).ToList<PackObjBase>();
|
||
foreach (PackObjBase pack in editPack)
|
||
{
|
||
AbleEditPackObj ablePack = pack as AbleEditPackObj;
|
||
if (ablePack != null)
|
||
{
|
||
if (ablePack.ValidType == EValidType.IsRequired)
|
||
{
|
||
if (ablePack.PackValue.Trim() == "")
|
||
{
|
||
MessageBox.Show(pack.Descript + "不能为空");
|
||
return false;
|
||
}
|
||
};
|
||
if (ablePack.PackValue != "" && ablePack.ValidType == EValidType.IsNumber)
|
||
{
|
||
try
|
||
{
|
||
int.Parse(ablePack.PackValue);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
MessageBox.Show(pack.Descript + "不能为空且必须是数值型");
|
||
return false;
|
||
}
|
||
};
|
||
if (ablePack.TextLength != 0)
|
||
{
|
||
if (ablePack.PackValue.Length >= ablePack.TextLength)
|
||
{
|
||
MessageBox.Show(ablePack.Descript + "长度不能超过" + ablePack.TextLength + "字");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
#endregion 重写的事件结束
|
||
|
||
/// <summary>
|
||
/// 设置可编辑组件的显示样式
|
||
/// </summary>
|
||
/// <param name="ableEdit"></param>
|
||
private void SetAbleEditView(AbleEditPackObj ableEdit, bool isUpdate = false)
|
||
{
|
||
string span = "";
|
||
double spanSum = Math.Round((float)(ableEdit.OneUnitCount / 18));
|
||
for (int i = 0; i < spanSum; i++)
|
||
{
|
||
if (ableEdit.IsHorizontal == ELineType.Horizontal)
|
||
{
|
||
span += " ";
|
||
}
|
||
else
|
||
{
|
||
|
||
span += "\n";
|
||
}
|
||
}
|
||
string text = "", value = "";
|
||
if (ableEdit != null && ableEdit.CControl != null)
|
||
{
|
||
switch (ableEdit.ControlType)
|
||
{
|
||
case EControlType.RadioButtonList:
|
||
foreach (Control conl in ableEdit.CControl.Controls)
|
||
{
|
||
string spanT = span.Clone().ToString();
|
||
if (ableEdit.DfArrangement == EIsBool.True)
|
||
{
|
||
if (spanT.Length - conl.Text.Length >= conl.Text.Length)
|
||
{
|
||
spanT = spanT.Remove(spanT.Length - conl.Text.Length, conl.Text.Length);
|
||
}
|
||
}
|
||
CheckBox radio = conl as CheckBox;
|
||
if (radio.Checked)
|
||
{
|
||
text += "☑" + conl.Text + spanT;
|
||
value = conl.Text;
|
||
}
|
||
else
|
||
{
|
||
text += "□" + conl.Text + spanT;
|
||
}
|
||
}
|
||
break;
|
||
case EControlType.CheckBox:
|
||
foreach (Control conl in ableEdit.CControl.Controls)
|
||
{
|
||
string spanT = span.Clone().ToString();
|
||
if (ableEdit.DfArrangement == EIsBool.True)
|
||
{
|
||
if (spanT.Length - conl.Text.Length >= conl.Text.Length)
|
||
{
|
||
spanT = spanT.Remove(spanT.Length - conl.Text.Length, conl.Text.Length);
|
||
}
|
||
}
|
||
CheckBox radio = conl as CheckBox;
|
||
if (radio.Checked)
|
||
{
|
||
text += "☑" + conl.Text + spanT;
|
||
value += conl.Text + ",";
|
||
}
|
||
else
|
||
{
|
||
text += "□" + conl.Text + spanT;
|
||
}
|
||
}
|
||
value = value.TrimEnd(',');
|
||
break;
|
||
case EControlType.Directory:
|
||
value = ableEdit.PackValue;
|
||
if (ableEdit.ControlTitleText == "手术" || ableEdit.ControlTitleText == "诊断" || ableEdit.ControlTitleText == "人员")
|
||
{
|
||
text = DBManage.GetDictionaryValuesById(ableEdit.PackValue, ableEdit.ControlTitleText);
|
||
}
|
||
else
|
||
{
|
||
text = ableEdit.PackValue;
|
||
}
|
||
//设置属性的值
|
||
template.SetObjValue(OpeRecord, ableEdit.ClassDataSourceName, text, value);
|
||
break;
|
||
case EControlType.Directorys:
|
||
value = ableEdit.PackValue;
|
||
if (ableEdit.ControlTitleText == "手术" || ableEdit.ControlTitleText == "诊断" || ableEdit.ControlTitleText == "人员")
|
||
{
|
||
text = DBManage.GetDictionaryValuesById(ableEdit.PackValue, ableEdit.ControlTitleText);
|
||
}
|
||
else
|
||
{
|
||
text = ableEdit.PackValue;
|
||
}
|
||
//设置属性的值
|
||
template.SetObjValue(OpeRecord, ableEdit.ClassDataSourceName, text, value);
|
||
break;
|
||
default:
|
||
text = ableEdit.CControl.Text;
|
||
value = ableEdit.CControl.Text;
|
||
break;
|
||
}
|
||
|
||
//设置属性的值
|
||
template.SetObjValue(OpeRecord, ableEdit.ClassDataSourceName, text, value, isUpdate);
|
||
//如果有逻辑区域,则区域进行更新。
|
||
template.NotificationAreaBindingUpdate(template.ProjectName + "逻辑");
|
||
}
|
||
}
|
||
|
||
private void txt_DoubleClick(object sender, EventArgs e)
|
||
{
|
||
Control control = (Control)sender;
|
||
if (control == null) return;
|
||
AbleEditPackObj ableEdit = control.Tag as AbleEditPackObj;
|
||
if (ableEdit == null) return;
|
||
string DataSourceName = ableEdit.ClassDataSourceName;
|
||
try
|
||
{
|
||
string text = "", value = "";
|
||
switch (ableEdit.ControlType)
|
||
{
|
||
case EControlType.DateTimePicker:
|
||
text = DateTime.Now.ToString();
|
||
value = DateTime.Now.ToString();
|
||
control.Text = text;
|
||
break;
|
||
case EControlType.Directory:
|
||
TYZD_Click(ableEdit, e, true);
|
||
break;
|
||
default:
|
||
text = ableEdit.CControl.Text;
|
||
value = ableEdit.CControl.Text;
|
||
break;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
PublicMethod.WriteLog(ex);
|
||
}
|
||
finally
|
||
{
|
||
template.ZedControl.Refresh();
|
||
}
|
||
}
|
||
|
||
private void txt_DoubleClick1(object sender, EventArgs e)
|
||
{
|
||
Control control = (Control)sender;
|
||
if (control == null) return;
|
||
AbleEditPackObj aEdit1S = control.Tag as AbleEditPackObj;
|
||
if (aEdit1S == null) return;
|
||
//这句话很重要,只操作自己管理器里的组件
|
||
AbleEditPackObj aEdit1 = PackManage.ListPob.FirstOrDefault<PackObjBase>(s => s.PackTag == aEdit1S.PackTag) as AbleEditPackObj;
|
||
//指定的组件显示
|
||
if (aEdit1 != null)
|
||
{
|
||
Control conl = aEdit1.CControl;
|
||
conl.Leave -= new EventHandler(txt_Leave);
|
||
aEdit1S.CControl.MouseDown -= new MouseEventHandler(CControl_MouseDown);
|
||
aEdit1S.CControl.KeyUp -= new KeyEventHandler(CControl_KeyUp2);
|
||
aEdit1S.CControl.TextChanged -= new EventHandler(CControl_TextChanged);
|
||
aEdit1S.CControl.KeyPress -= new KeyPressEventHandler(CControl_KeyPress); ;
|
||
//根据数据源名称进行不同的事件处理
|
||
switch (aEdit1.ClassDataSourceName)
|
||
{
|
||
case "OperationRecord.AnesthesiaDoctor": //麻醉医生
|
||
Worker_Click(aEdit1, e, 2);
|
||
break;
|
||
case "OperationRecord.OperationDoctor":
|
||
Worker_Click(aEdit1, e, 0);
|
||
break;
|
||
case "OperationRecord.InstrumentNurse":
|
||
Worker_Click(aEdit1, e, 3);
|
||
break;
|
||
case "OperationRecord.Assistant1":
|
||
Worker_Click(aEdit1, e, 0);
|
||
break;
|
||
case "OperationRecord.TourNurse":
|
||
Worker_Click(aEdit1, e, 3);
|
||
break;
|
||
case "OperationRecord.Operation": //手术名称
|
||
ope_Click(aEdit1, e);
|
||
break;
|
||
case "OperationRecord.OrtherDoctorId":
|
||
Worker_Click(aEdit1, e, 4);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
private void Worker_Click(AbleEditPackObj sender, EventArgs e, int _workersType)
|
||
{
|
||
AbleEditPackObj ableEdit = sender;
|
||
if (ableEdit == null) return;
|
||
|
||
ableEdit.CControl.MouseDown -= new MouseEventHandler(CControl_MouseDown);
|
||
ableEdit.CControl.MouseDown += new MouseEventHandler(CControl_MouseDown);
|
||
ableEdit.CControl.KeyUp -= new KeyEventHandler(CControl_KeyUp);
|
||
ableEdit.CControl.KeyUp += new KeyEventHandler(CControl_KeyUp);
|
||
ableEdit.CControl.KeyPress -= new KeyPressEventHandler(CControl_KeyPress);
|
||
ableEdit.CControl.KeyPress += new KeyPressEventHandler(CControl_KeyPress);
|
||
SelectWorkerValue.ChageText = "";
|
||
if (myOpeRecord != null)
|
||
{
|
||
Control conl = sender.CControl;
|
||
if (conl is TextBox)
|
||
{
|
||
((TextBox)conl).BorderStyle = BorderStyle.Fixed3D;
|
||
((TextBox)conl).Focus();
|
||
if (sender.PackValue != null && sender.PackValue.Trim() != "")
|
||
{
|
||
if (((TextBox)conl).Text.LastIndexOf(',') != sender.PackText.Length && ((TextBox)conl).Text != "")
|
||
((TextBox)conl).Text = ((TextBox)conl).Text + ",";
|
||
((TextBox)conl).Select(((TextBox)conl).Text.Length, 1);
|
||
}
|
||
}
|
||
ableEdit.CControl.TextChanged -= new EventHandler(CControl_TextChanged);
|
||
ableEdit.CControl.TextChanged += new EventHandler(CControl_TextChanged);
|
||
|
||
aSyncSelectDict.Show(template, OpeRecord, sender, _workersType.ToString(), false);
|
||
}
|
||
}
|
||
|
||
private void CControl_MouseDown(object sender, MouseEventArgs e)
|
||
{
|
||
if (myOpeRecord != null)
|
||
{
|
||
TextBox conl = sender as TextBox;
|
||
string leftStr = conl.Text.Substring(0, conl.SelectionStart);
|
||
string rightStr = conl.Text.Substring(conl.SelectionStart, conl.Text.Length - conl.SelectionStart);
|
||
int startIndex = 0;
|
||
int endLength = conl.Text.Length;
|
||
|
||
if (leftStr.Contains(","))
|
||
{
|
||
int beginindex = leftStr.LastIndexOf(',');
|
||
startIndex = beginindex + 1;
|
||
if (rightStr.Contains(","))
|
||
{
|
||
endLength = rightStr.IndexOf(",") + (leftStr.Length - beginindex);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (rightStr.Contains(","))
|
||
{
|
||
endLength = rightStr.IndexOf(",") + leftStr.Length + 1;
|
||
}
|
||
}
|
||
conl.Select(startIndex, endLength);
|
||
|
||
}
|
||
}
|
||
|
||
private void ope_Click(AbleEditPackObj sender, EventArgs e)
|
||
{
|
||
AbleEditPackObj ableEdit = sender;
|
||
if (ableEdit == null) return;
|
||
try
|
||
{
|
||
if (myOpeRecord != null)
|
||
{
|
||
SelDict2(sender, e, ableEdit.ControlTitleText);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
AIMSExtension.PublicMethod.WriteLog(ex);
|
||
}
|
||
}
|
||
private void opeDisease_Click(AbleEditPackObj sender, EventArgs e)
|
||
{
|
||
AbleEditPackObj ableEdit = sender;
|
||
if (ableEdit == null) return;
|
||
try
|
||
{
|
||
if (myOpeRecord != null)
|
||
{
|
||
SelDict2(sender, e, ableEdit.ControlTitleText);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
AIMSExtension.PublicMethod.WriteLog(ex);
|
||
}
|
||
}
|
||
private void txt_Click(object sender, EventArgs e)
|
||
{
|
||
Control control = (Control)sender;
|
||
if (control == null) return;
|
||
AbleEditPackObj ableEdit = control.Tag as AbleEditPackObj;
|
||
if (ableEdit == null) return;
|
||
string DataSourceName = ableEdit.ClassDataSourceName;
|
||
if (SelectDictText.dgvZd.Visible == true)
|
||
{
|
||
SelectDictText.Hidden();
|
||
}
|
||
}
|
||
private void txt_Leave(object sender, EventArgs e)
|
||
{
|
||
Control control = (Control)sender;
|
||
if (control == null) return;
|
||
AbleEditPackObj ableEdit = control.Tag as AbleEditPackObj;
|
||
if (ableEdit == null) return;
|
||
try
|
||
{
|
||
if (ableEdit.ControlType == EControlType.RadioButtonList)
|
||
{
|
||
if ((sender as CheckBox).Checked == true)
|
||
{
|
||
foreach (CheckBox chk in (sender as CheckBox).Parent.Controls)
|
||
{
|
||
chk.CheckedChanged -= new EventHandler(txt_Leave);
|
||
if (chk != sender)
|
||
{
|
||
chk.Checked = false;
|
||
}
|
||
chk.CheckedChanged += new EventHandler(txt_Leave);
|
||
}
|
||
}
|
||
}
|
||
SetAbleEditView(ableEdit, true);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//写日志
|
||
PublicMethod.WriteLog(ex);
|
||
}
|
||
finally
|
||
{
|
||
}
|
||
}
|
||
|
||
//设置打印模式,组件不显示
|
||
public override void setPrint(bool isVisible)
|
||
{
|
||
//预览状态时所可编辑组件的组件隐藏
|
||
List<PackObjBase> ables = PackManage.ListPob.Where<PackObjBase>(s => s is AbleEditPackObj).ToList<PackObjBase>();
|
||
foreach (PackObjBase pack1 in ables)
|
||
{
|
||
AbleEditPackObj ableEdit = pack1 as AbleEditPackObj;
|
||
|
||
if (ableEdit != null)
|
||
{
|
||
ableEdit.IsVisible = isVisible;
|
||
if (isVisible == true)
|
||
ableEdit.IsViewBoard = EIsBool.True;
|
||
else
|
||
ableEdit.IsViewBoard = EIsBool.False;
|
||
}
|
||
}
|
||
}
|
||
//通用字典分组窗体打开
|
||
private void TYZD_Click(AbleEditPackObj sender, EventArgs e, bool isRadio = false)
|
||
{
|
||
AbleEditPackObj ableEdit = sender;
|
||
if (ableEdit == null) return;
|
||
try
|
||
{
|
||
if (myOpeRecord != null)
|
||
{
|
||
SelDict(sender, e, ableEdit.ControlTitleText, isRadio);
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
AIMSExtension.PublicMethod.WriteLog(ex);
|
||
}
|
||
}
|
||
private void SelDict(AbleEditPackObj sender, EventArgs e, string _DictType, bool isRadio = false)
|
||
{
|
||
AbleEditPackObj ableEdit = sender;
|
||
if (ableEdit == null) return;
|
||
|
||
ableEdit.CControl.Leave -= new EventHandler(txt_Leave);
|
||
ableEdit.CControl.KeyUp -= new KeyEventHandler(CControl_KeyUp);
|
||
ableEdit.CControl.KeyUp += new KeyEventHandler(CControl_KeyUp);
|
||
ableEdit.CControl.KeyPress -= new KeyPressEventHandler(CControl_KeyPress);
|
||
ableEdit.CControl.KeyPress += new KeyPressEventHandler(CControl_KeyPress);
|
||
|
||
if (myOpeRecord != null)
|
||
{
|
||
Control conl = sender.CControl;
|
||
if (conl is TextBox)
|
||
{
|
||
((TextBox)conl).BorderStyle = BorderStyle.Fixed3D;
|
||
((TextBox)conl).Focus();
|
||
if (sender.PackValue != null && sender.PackValue.Trim() != "" && isRadio == false)
|
||
{
|
||
if (((TextBox)conl).Text.LastIndexOf(',') != sender.PackText.Length)
|
||
((TextBox)conl).Text = ((TextBox)conl).Text + ",";
|
||
}
|
||
((TextBox)conl).Select(((TextBox)conl).Text.Length, 1);
|
||
}
|
||
|
||
aSyncSelectDict.Show(template, OpeRecord, sender, _DictType, isRadio);
|
||
ableEdit.CControl.Leave += new EventHandler(txt_Leave);
|
||
}
|
||
}
|
||
//private void ASyncSelectDict_SetValue(string Text, string Key, AbleEditPackObj aEdit)
|
||
//{
|
||
// if (aEdit.ControlTitleText == "手术" || aEdit.ControlTitleText == "诊断" || aEdit.ControlTitleText == "人员")
|
||
// {
|
||
// aEdit.PackValue = Key;
|
||
// aEdit.PackText = Text;
|
||
// template.SetObjValue(OpeRecord, aEdit.ClassDataSourceName, Text, Key, true);
|
||
// }
|
||
// else
|
||
// {
|
||
// aEdit.PackValue = Text;
|
||
// aEdit.PackText = Text;
|
||
// template.SetObjValue(OpeRecord, aEdit.ClassDataSourceName, Text, Text, true);
|
||
// }
|
||
// aEdit.CControl.Leave -= new EventHandler(txt_Leave);
|
||
// aEdit.CControl.Leave += new EventHandler(txt_Leave);
|
||
//}
|
||
private void CControl_KeyUp(object sender, KeyEventArgs e)
|
||
{
|
||
if (myOpeRecord != null)
|
||
{
|
||
Control conl = sender as Control;
|
||
if (e.KeyCode == Keys.Down)
|
||
{
|
||
if (SelectDictText.dgvZd.CurrentRow.Index + 1 != SelectDictText.dgvZd.Rows.Count - 1)
|
||
{
|
||
SelectDictText.dgvZd.CurrentCell = SelectDictText.dgvZd.Rows[SelectDictText.dgvZd.CurrentRow.Index + 1].Cells[1];
|
||
}
|
||
}
|
||
else if (e.KeyCode == Keys.Up)
|
||
{
|
||
if (SelectDictText.dgvZd.CurrentRow.Index != 0)
|
||
{
|
||
SelectDictText.dgvZd.CurrentCell = SelectDictText.dgvZd.Rows[SelectDictText.dgvZd.CurrentRow.Index - 1].Cells[1];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
private void CControl_KeyPress(object sender, KeyPressEventArgs e)
|
||
{
|
||
if (e.KeyChar.ToString() == "\r")
|
||
{
|
||
if (SelectDictText.dgvZd.SelectedRows.Count > 0)
|
||
{
|
||
SelectDictText.SetContent(SelectDictText.dgvZd.SelectedRows[0].Index);
|
||
}
|
||
}
|
||
}
|
||
private void CControl_TextChanged(object sender, EventArgs e)
|
||
{
|
||
if (myOpeRecord != null)
|
||
{
|
||
Control conl = sender as Control;
|
||
AbleEditPackObj aEdit1S = conl.Tag as AbleEditPackObj;
|
||
if (aEdit1S == null) return;
|
||
aSyncSelectDict.ShowSel(template, conl, OpeRecord, aEdit1S);
|
||
//conl.KeyUp -= new KeyEventHandler(CControl_KeyUp2);
|
||
}
|
||
}
|
||
private void CControl_KeyUp2(object sender, KeyEventArgs e)
|
||
{
|
||
if (myOpeRecord != null)
|
||
{
|
||
Control conl = sender as Control;
|
||
if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back)
|
||
{
|
||
if (conl.Text != SelectDictText.Value && SelectDictText.ChageText == "")
|
||
{
|
||
AbleEditPackObj aEdit1S = conl.Tag as AbleEditPackObj;
|
||
if (aEdit1S == null) return;
|
||
aSyncSelectDict.DelSel(template, conl, OpeRecord, aEdit1S);
|
||
SelectDictText.ChageText = "";
|
||
}
|
||
}
|
||
else if (e.KeyCode == Keys.Down)
|
||
{
|
||
if (SelectDictText.dgvZd.CurrentRow.Index + 1 != SelectDictText.dgvZd.Rows.Count - 1)
|
||
{
|
||
SelectDictText.dgvZd.CurrentCell = SelectDictText.dgvZd.Rows[SelectDictText.dgvZd.CurrentRow.Index + 1].Cells[1];
|
||
}
|
||
}
|
||
else if (e.KeyCode == Keys.Up)
|
||
{
|
||
if (SelectDictText.dgvZd.CurrentRow.Index != 0)
|
||
{
|
||
SelectDictText.dgvZd.CurrentCell = SelectDictText.dgvZd.Rows[SelectDictText.dgvZd.CurrentRow.Index - 1].Cells[1];
|
||
}
|
||
}
|
||
}
|
||
}
|
||
private void SelDict2(AbleEditPackObj sender, EventArgs e, string _DictType, bool isRadio = false)
|
||
{
|
||
AbleEditPackObj ableEdit = sender;
|
||
if (ableEdit == null) return;
|
||
|
||
ableEdit.CControl.MouseDown -= new MouseEventHandler(CControl_MouseDown);
|
||
ableEdit.CControl.MouseDown += new MouseEventHandler(CControl_MouseDown);
|
||
ableEdit.CControl.KeyUp -= new KeyEventHandler(CControl_KeyUp2);
|
||
ableEdit.CControl.KeyUp += new KeyEventHandler(CControl_KeyUp2);
|
||
ableEdit.CControl.KeyPress -= new KeyPressEventHandler(CControl_KeyPress);
|
||
ableEdit.CControl.KeyPress += new KeyPressEventHandler(CControl_KeyPress);
|
||
SelectDictText.ChageText = "";
|
||
if (myOpeRecord != null)
|
||
{
|
||
Control conl = sender.CControl;
|
||
if (conl is TextBox)
|
||
{
|
||
((TextBox)conl).BorderStyle = BorderStyle.Fixed3D;
|
||
((TextBox)conl).Focus();
|
||
if (sender.PackValue != null && sender.PackValue.Trim() != "" && isRadio == false)
|
||
{
|
||
if (((TextBox)conl).Text.LastIndexOf(',') != sender.PackText.Length && ((TextBox)conl).Text != "")
|
||
((TextBox)conl).Text = ((TextBox)conl).Text + ",";
|
||
}
|
||
((TextBox)conl).Select(((TextBox)conl).Text.Length, 1);
|
||
}
|
||
ableEdit.CControl.TextChanged -= new EventHandler(CControl_TextChanged);
|
||
ableEdit.CControl.TextChanged += new EventHandler(CControl_TextChanged);
|
||
aSyncSelectDict.Show(template, OpeRecord, sender, _DictType, isRadio);
|
||
}
|
||
}
|
||
|
||
|
||
private void EditTextBox_DoubleClick(object sender, EventArgs e)
|
||
{
|
||
TextBox txt = sender as TextBox;
|
||
TokenEditorManage.SelectDictList(OpeRecord as OperationRecord, txt);
|
||
}
|
||
private void EditTextBox_TextChanged(object sender, EventArgs e)
|
||
{
|
||
TextBox txt = sender as TextBox;
|
||
TokenEditorManage.SelectDictList(OpeRecord as OperationRecord, txt);
|
||
}
|
||
|
||
private void tokenEditor_ValidateToken(object sender, DevComponents.DotNetBar.Controls.ValidateTokenEventArgs ea)
|
||
{
|
||
DevComponents.DotNetBar.Controls.TokenEditor tokenEditor = sender as DevComponents.DotNetBar.Controls.TokenEditor;
|
||
AbleEditPackObj aEdit = tokenEditor.Tag as AbleEditPackObj;
|
||
if (ea.IsNewToken)
|
||
{
|
||
tokenEditor.EditTextBox.TextChanged -= EditTextBox_TextChanged;
|
||
string id = TokenEditorManage.GetOperationItemId(ea.Token.Value, aEdit);
|
||
tokenEditor.SelectedTokens.Add(new EditToken(id, ea.Token.Value));
|
||
ea.Token = null;
|
||
tokenEditor.EditTextBox.Text = "";
|
||
tokenEditor.IsPopupOpen = false;
|
||
tokenEditor.EditTextBox.TextChanged += EditTextBox_TextChanged;
|
||
}
|
||
}
|
||
|
||
private void TokenEditor_Leave(object sender, EventArgs e)
|
||
{
|
||
DevComponents.DotNetBar.Controls.TokenEditor tokenEditor = sender as DevComponents.DotNetBar.Controls.TokenEditor;
|
||
AbleEditPackObj aEdit = tokenEditor.Tag as AbleEditPackObj;
|
||
TokenEditorManage.SaveDictItem(template, OpeRecord as OperationRecord, tokenEditor, aEdit);
|
||
}
|
||
|
||
}
|
||
}
|