381 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			381 lines
		
	
	
		
			15 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Newtonsoft.Json;
 | ||
| using AIMSExtension;
 | ||
| using System;
 | ||
| using System.Collections.Generic;
 | ||
| using System.Linq;
 | ||
| using System.Windows.Forms;
 | ||
| 
 | ||
| 
 | ||
| namespace DrawGraph
 | ||
| {
 | ||
|     [Serializable, JsonObject(MemberSerialization.OptOut)]
 | ||
|     public class BaseInfoBottomManage : AreaManageBase
 | ||
|     {
 | ||
|         private OperationRecord myOpeRecord = null;
 | ||
|         public BaseInfoBottomManage() { }
 | ||
|         public BaseInfoBottomManage(object _operationRecor, ZedGraphControl _zedControl, TemplateManage _template, string _name) : base(_operationRecor, _zedControl, _template, _name)
 | ||
|         {
 | ||
|             init();
 | ||
|         }
 | ||
|         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)
 | ||
|         {
 | ||
|             //if (e.Button == System.Windows.Forms.MouseButtons.Left)
 | ||
|             //{
 | ||
|             //    MessageBox.Show(this.GetType().Name + "is Click Left Button");
 | ||
|             //}
 | ||
|         }
 | ||
|         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 SelectWorkerValue aSyncSelectDict = null;
 | ||
|         public override void Bind()
 | ||
|         {
 | ||
|             init();
 | ||
|             aSyncSelectDict = SelectWorkerValue.CreateInstance();
 | ||
|             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);
 | ||
|             }
 | ||
|         }
 | ||
|         /// <summary>
 | ||
|         /// 设置可编辑组件的显示样式
 | ||
|         /// </summary>
 | ||
|         /// <param name="ableEdit"></param>
 | ||
|         private void SetAbleEditView(AbleEditPackObj ableEdit)
 | ||
|         {
 | ||
|             string span = "";
 | ||
|             double spanSum = Math.Round((float)(ableEdit.OneUnitCount / 12));
 | ||
|             for (int i = 0; i < spanSum; i++)
 | ||
|             {
 | ||
|                 span += " ";
 | ||
|             }
 | ||
|             string text = "", value = "";
 | ||
|             if (ableEdit != null)
 | ||
|             {
 | ||
|                 switch (ableEdit.ControlType)
 | ||
|                 {
 | ||
|                     case EControlType.Directory:
 | ||
|                         value = ableEdit.PackValue;
 | ||
|                         text = DBManage.GetDictionaryValuesById(ableEdit.PackValue, ableEdit.ControlTitleText);
 | ||
|                         //设置属性的值
 | ||
|                         template.SetObjValue(OpeRecord, ableEdit.ClassDataSourceName, text, value);
 | ||
|                         break;
 | ||
|                     default:
 | ||
|                         break;
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
|         #endregion 重写的事件结束
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 响应可编辑区域的点击事件
 | ||
|         /// </summary>
 | ||
|         /// <param name="sender"></param>
 | ||
|         /// <param name="e"></param>
 | ||
|         public override void editAr_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             try
 | ||
|             {
 | ||
|                 //传过来的数据是不是可编辑的
 | ||
|                 AbleEditPackObj aEdit1S = sender as AbleEditPackObj;
 | ||
|                 if (aEdit1S == null) return;
 | ||
| 
 | ||
|                 //先把所有WINFORM组件隐藏
 | ||
|                 foreach (PackObjBase pack in PackManage.ListPob)
 | ||
|                 {
 | ||
|                     AbleEditPackObj aEdit = pack as AbleEditPackObj;
 | ||
|                     if (aEdit != null)
 | ||
|                     {
 | ||
|                         aEdit.IsVisible = false;
 | ||
|                     }
 | ||
|                 }
 | ||
|                 SelectWorkerValue.Hidden();
 | ||
|                 //这句话很重要,只操作自己管理器里的组件
 | ||
|                 AbleEditPackObj aEdit1 = PackManage.ListPob.FirstOrDefault<PackObjBase>(s => s.PackTag == aEdit1S.PackTag) as AbleEditPackObj;
 | ||
|                 //指定的组件显示
 | ||
|                 if (aEdit1 != null)
 | ||
|                 {
 | ||
|                     aEdit1.IsVisible = !aEdit1.IsVisible;
 | ||
|                     aEdit1S.CControl.MouseDown -= new MouseEventHandler(CControl_MouseDown);
 | ||
|                     aEdit1S.CControl.KeyUp -= new KeyEventHandler(CControl_KeyUp);
 | ||
|                     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.AnaesthesiaMethodName":
 | ||
|                             Anaes_Click(aEdit1, e);
 | ||
|                             break;
 | ||
|                         case "OperationRecord.OperationSiteId": //手术体位
 | ||
|                             TYZD_Click(aEdit1, e);
 | ||
|                             break;
 | ||
|                         case "OperationRecord.OperationPositionId": //手术体位
 | ||
|                             TYZD_Click(aEdit1, e);
 | ||
|                             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;
 | ||
|                             //default:
 | ||
|                             //    //在此处写日志
 | ||
|                             //    aEdit1.IsVisible = !aEdit1.IsVisible;
 | ||
|                             //    MessageBox.Show("没找到-" + aEdit1.ClassDataSourceName + "-属性的事件");
 | ||
|                             //    break;
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|             catch (Exception exp)
 | ||
|             {
 | ||
|                 MessageBox.Show(exp.Message);
 | ||
|             }
 | ||
|             finally
 | ||
|             {
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         #region 可编辑区域响应事件
 | ||
| 
 | ||
| 
 | ||
|         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).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());
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void CControl_TextChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (myOpeRecord != null)
 | ||
|             {
 | ||
|                 Control conl = sender as Control;
 | ||
| 
 | ||
|                 aSyncSelectDict.ShowSel(conl, OpeRecord);
 | ||
|             }
 | ||
|         }
 | ||
|         private void CControl_KeyUp(object sender, KeyEventArgs e)
 | ||
|         {
 | ||
|             if (myOpeRecord != null)
 | ||
|             {
 | ||
|                 Control conl = sender as Control;
 | ||
|                 if (e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back)
 | ||
|                 {
 | ||
|                     if (conl.Text != SelectWorkerValue.Value && SelectWorkerValue.ChageText == "")
 | ||
|                     {
 | ||
|                         aSyncSelectDict.DelSel(conl, OpeRecord);
 | ||
|                         SelectDictValue.ChageText = "";
 | ||
|                     }
 | ||
|                 }
 | ||
|                 else if (e.KeyCode == Keys.Down)
 | ||
|                 {
 | ||
|                     if (SelectWorkerValue.dgvZd.CurrentRow.Index + 1 != SelectWorkerValue.dgvZd.Rows.Count - 1)
 | ||
|                     {
 | ||
|                         SelectWorkerValue.dgvZd.CurrentCell = SelectWorkerValue.dgvZd.Rows[SelectWorkerValue.dgvZd.CurrentRow.Index + 1].Cells[1];
 | ||
|                     }
 | ||
|                 }
 | ||
|                 else if (e.KeyCode == Keys.Up)
 | ||
|                 {
 | ||
|                     if (SelectWorkerValue.dgvZd.CurrentRow.Index != 0)
 | ||
|                     {
 | ||
|                         SelectWorkerValue.dgvZd.CurrentCell = SelectWorkerValue.dgvZd.Rows[SelectWorkerValue.dgvZd.CurrentRow.Index - 1].Cells[1];
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
|         private void CControl_KeyPress(object sender, KeyPressEventArgs e)
 | ||
|         {
 | ||
|             if (e.KeyChar.ToString() == "\r")
 | ||
|             {
 | ||
|                 if (SelectWorkerValue.dgvZd.SelectedRows.Count > 0)
 | ||
|                 {
 | ||
|                     SelectWorkerValue.SetContent(SelectWorkerValue.dgvZd.SelectedRows[0].Index);
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
|         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
 | ||
|                     //{
 | ||
|                     //    endLength = conl.Text.Length - startIndex;
 | ||
|                     //}
 | ||
|                 }
 | ||
|                 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)
 | ||
|                 {
 | ||
|                     SelDict(sender, e, ableEdit.ControlTitleText);
 | ||
|                 }
 | ||
|             }
 | ||
|             catch (Exception ex)
 | ||
|             {
 | ||
|                 AIMSExtension.PublicMethod.WriteLog(ex);
 | ||
|             }
 | ||
|         }
 | ||
|         private void Anaes_Click(AbleEditPackObj sender, EventArgs e)
 | ||
|         {
 | ||
|             AbleEditPackObj ableEdit = sender;
 | ||
|             if (ableEdit == null) return;
 | ||
|             try
 | ||
|             {
 | ||
|                 if (myOpeRecord != null)
 | ||
|                 {
 | ||
|                     SelDict(sender, e, ableEdit.ControlTitleText);
 | ||
|                 }
 | ||
|             }
 | ||
|             catch (Exception ex)
 | ||
|             {
 | ||
|                 AIMSExtension.PublicMethod.WriteLog(ex);
 | ||
|             }
 | ||
|         }
 | ||
|         //通用字典分组窗体打开
 | ||
|         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);
 | ||
|                 }
 | ||
|             }
 | ||
|             catch (Exception ex)
 | ||
|             {
 | ||
|                 AIMSExtension.PublicMethod.WriteLog(ex);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         private void SelDict(AbleEditPackObj sender, EventArgs e, string _DictType)
 | ||
|         {
 | ||
|             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);
 | ||
| 
 | ||
|             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).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);
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         #endregion 
 | ||
|     }
 | ||
| }
 |