495 lines
21 KiB
C#
495 lines
21 KiB
C#
using AIMSExtension;
|
||
using DevComponents.Editors.DateTimeAdv;
|
||
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Windows.Forms;
|
||
|
||
namespace DrawGraph
|
||
{
|
||
/// <summary>
|
||
/// 麻醉前访视单
|
||
/// </summary>
|
||
public class TempDataManage : AreaManageBase
|
||
{
|
||
|
||
private OperationRecord myOpeRecord = null;
|
||
private bool valChang = false; //值不变
|
||
|
||
AbleEditPackObj ableEdit2;
|
||
AbleEditPackObj ableEdit3;
|
||
public TempDataManage() { }
|
||
public TempDataManage(object _operationRecor, DrawGraph.ZedGraphControl _zedControl, TemplateManage _template, string _name) : base(_operationRecor, _zedControl, _template, _name)
|
||
{ }
|
||
|
||
public void init()
|
||
{
|
||
//自己要用的手术对象
|
||
myOpeRecord = OpeRecord as OperationRecord;
|
||
ableEdit2 = template.GetPackObjectOTag<AbleEditPackObj>("TempDataManage_AbleEditPackObj_357_OperationRecord_InstrumentList_TagPicturePanel");
|
||
ableEdit3 = template.GetPackObjectOTag<AbleEditPackObj>("TempDataManage_AbleEditPackObj_397_OperationRecord_InstrumentList_PackPanel");
|
||
}
|
||
#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)
|
||
{
|
||
//传过来的数据是不是可编辑的
|
||
AbleEditPackObj editPack = sender as AbleEditPackObj;
|
||
if (editPack == null) return;
|
||
//找到这个组件
|
||
AbleEditPackObj aEdit1 = PackManage.ListPob.FirstOrDefault<PackObjBase>(s => s is AbleEditPackObj && s.PackTag == editPack.PackTag) as AbleEditPackObj;
|
||
if (aEdit1 == null) return;
|
||
|
||
txt_DoubleClick(aEdit1.CControl, null);
|
||
}
|
||
|
||
public override void Bind()
|
||
{
|
||
base.Bind();
|
||
init();
|
||
if (ableEdit2 != null)
|
||
{
|
||
GraphObj gos = ZedControl.MasterPane.GraphObjList[TextPrefix.IM + "InstrumentListTagPicturePanel2"];
|
||
if (gos == null)
|
||
{
|
||
ZUtil.DrawImage("bjtp", ableEdit2.RealEndX, ableEdit2.RealY, (ableEdit2.RealEndX - ableEdit2.RealX), (ableEdit2.RealEndY - ableEdit2.RealY) / 2, ZedControl, TextPrefix.IM + "InstrumentListTagPicturePanel2");
|
||
}
|
||
}
|
||
if (ableEdit3 != null)
|
||
{
|
||
for (int i = 593; i < 617; i++)
|
||
{
|
||
TextPackObj packObj = template.GetPackObjectOTag<TextPackObj>("TempDataManage_TextPackObj_" + i);
|
||
if (packObj != null)
|
||
{
|
||
packObj.PackText = "";
|
||
packObj.PackValue = "";
|
||
packObj.Draw();
|
||
}
|
||
}
|
||
}
|
||
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;
|
||
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)
|
||
{
|
||
ableEdit.CControl.DoubleClick -= new EventHandler(txt_DoubleClick);
|
||
ableEdit.CControl.DoubleClick += new EventHandler(txt_DoubleClick);
|
||
ableEdit.CControl.TextChanged -= new EventHandler(txt_Leave);
|
||
ableEdit.CControl.TextChanged += new EventHandler(txt_Leave);
|
||
}
|
||
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);
|
||
//chBox.Click -= new EventHandler(radio_click);
|
||
//chBox.Click += new EventHandler(radio_click);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
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);
|
||
}
|
||
ableEdit.CControl.Leave -= new EventHandler(txt_Leave);
|
||
ableEdit.CControl.Leave += new EventHandler(txt_Leave);
|
||
}
|
||
SetAbleEditView(ableEdit);
|
||
}
|
||
}
|
||
}
|
||
|
||
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)
|
||
{
|
||
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()
|
||
{
|
||
if (myOpeRecord != null && myOpeRecord.Id != null)
|
||
{
|
||
if (ableEdit2 != null)
|
||
{
|
||
GraphObj gos = ZedControl.MasterPane.GraphObjList[TextPrefix.IM + "InstrumentListTagPicturePanel"];
|
||
if (gos != null)
|
||
{
|
||
ZedControl.MasterPane.GraphObjList.Remove(gos);
|
||
}
|
||
if (myOpeRecord.InstrumentList != null && myOpeRecord.InstrumentList.TagPicture != null && myOpeRecord.InstrumentList.TagPicture != "")
|
||
{
|
||
MemoryStream ms = new MemoryStream(Convert.FromBase64String(myOpeRecord.InstrumentList.TagPicture));
|
||
System.Drawing.Image image = System.Drawing.Image.FromStream(ms);
|
||
ZUtil.DrawImage(image, ableEdit2.RealX, ableEdit2.RealY, (ableEdit2.RealEndX - ableEdit2.RealX), (ableEdit2.RealEndY - ableEdit2.RealY), ZedControl, TextPrefix.IM + "InstrumentListTagPicturePanel");
|
||
}
|
||
}
|
||
if (ableEdit3 != null && myOpeRecord.InstrumentList != null && myOpeRecord.InstrumentList.JsonTextData != null && myOpeRecord.InstrumentList.JsonTextData != "")
|
||
{
|
||
//593-616
|
||
List<JsonTextForDoc> list = JsonConvert.DeserializeObject<List<JsonTextForDoc>>(myOpeRecord.InstrumentList.JsonTextData);
|
||
foreach (JsonTextForDoc m in list)
|
||
{
|
||
if (m.Id.Trim() == "")
|
||
continue;
|
||
TextPackObj packObj = template.GetPackObjectOTag<TextPackObj>(m.Tag);
|
||
packObj.PackText = m.Value;
|
||
packObj.PackValue = m.Value;
|
||
packObj.Draw();
|
||
}
|
||
}
|
||
}
|
||
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 exp)
|
||
{
|
||
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)
|
||
{
|
||
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:
|
||
if (ableEdit.ControlTitleText.Contains("模板"))
|
||
{
|
||
text = ableEdit.CControl.Text;
|
||
value = ableEdit.CControl.Text;
|
||
}
|
||
else
|
||
{
|
||
value = ableEdit.PackValue;
|
||
string typeName = ableEdit.ControlTitleText;
|
||
//如果是“人员,2”这种需要把人员取出来
|
||
if (ableEdit.ControlTitleText.Contains(",") || ableEdit.ControlTitleText.Contains(","))
|
||
{
|
||
string[] strs = ableEdit.ControlTitleText.Replace(",", ",").Split(',');
|
||
typeName = strs[0];
|
||
}
|
||
text = DocumentEntityMethod.GetDictionaryValuesById(ableEdit.PackValue, typeName);
|
||
}
|
||
break;
|
||
default:
|
||
text = ableEdit.CControl.Text;
|
||
value = ableEdit.CControl.Text;
|
||
break;
|
||
}
|
||
|
||
//设置属性的值
|
||
template.SetObjValue(OpeRecord, ableEdit.ClassDataSourceName, text, value);
|
||
//如果有逻辑区域,则区域进行更新。
|
||
template.NotificationAreaBindingUpdate(template.ProjectName + "逻辑");
|
||
}
|
||
}
|
||
|
||
private void setDefaultDateTime(object sender)
|
||
{
|
||
Control control = (Control)sender;
|
||
if (control == null) return;
|
||
AbleEditPackObj ableEdit = control.Tag as AbleEditPackObj;
|
||
if (ableEdit == null) return;
|
||
string DataSourceName = ableEdit.ClassDataSourceName;
|
||
if (ableEdit.ControlTitleText != "")
|
||
{
|
||
((DateTimePicker)control).Format = DateTimePickerFormat.Custom;
|
||
((DateTimePicker)control).CustomFormat = ableEdit.ControlTitleText;
|
||
}
|
||
if (ableEdit.PackText == "")
|
||
{
|
||
//control.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");//ToShortDateString
|
||
}
|
||
}
|
||
|
||
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;
|
||
default:
|
||
text = ableEdit.CControl.Text;
|
||
value = ableEdit.CControl.Text;
|
||
break;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
}
|
||
finally
|
||
{
|
||
template.ZedControl.Refresh();
|
||
}
|
||
}
|
||
|
||
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;
|
||
//拿到数据源(格式:OperationRecord.PatientRef.Bed)
|
||
bool updateOk = true;
|
||
try
|
||
{
|
||
SetAbleEditView(ableEdit);
|
||
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);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
//写日志
|
||
updateOk = false;
|
||
}
|
||
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;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|