326 lines
		
	
	
		
			17 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			326 lines
		
	
	
		
			17 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| using System.CodeDom.Compiler;
 | |
| using Microsoft.CSharp;
 | |
| using System.Reflection;
 | |
| using DCSoft.Writer.Controls;
 | |
| using DCSoft.Writer;
 | |
| using DCSoft.Writer.Dom;
 | |
| using System.Windows.Forms;
 | |
| using AIMSBLL;
 | |
| using DataDictionary.UI;
 | |
| using DrawGraph;
 | |
| using System.Xml;
 | |
| using System.Drawing;
 | |
| using DCSoftDotfuscate;
 | |
| using System.Collections;
 | |
| using DocumentManagement;
 | |
| using AIMSModel;
 | |
| using AIMS.Infrastructure.CA;
 | |
| using System.Data;
 | |
| using HelperDB;
 | |
| 
 | |
| namespace AIMS
 | |
| {
 | |
|     public class EventCodeCompilerBill
 | |
|     {
 | |
|         public CompilerResults cr;
 | |
| 
 | |
|         public Type type;
 | |
| 
 | |
|         private ElementEventTemplate eet;
 | |
| 
 | |
|         private XTextInputFieldElement SelElement;
 | |
|         private string SelElementName;
 | |
|         private string SelElementValue;
 | |
|         List<string> QXList;
 | |
|         public bool IsLoad = false;
 | |
| 
 | |
|         public EventCodeCompilerBill(ref WriterControl myEditControl, string strMouseClickEvent, string strContentChangedEvent, List<string> _QXList)
 | |
|         {
 | |
|             eet = new ElementEventTemplate();
 | |
|             eet.MouseClick += new ElementMouseEventHandler(eetChk_MouseClick);
 | |
|             eet.MouseDblClick += Eet_MouseDblClick;
 | |
|             eet.ContentChanged += new ContentChangedEventHandler(eet_ContentChanged);
 | |
|             myEditControl.GlobalEventTemplate_Element = eet;
 | |
|             QXList = _QXList;
 | |
| 
 | |
|         }
 | |
| 
 | |
|         private void Eet_MouseDblClick(object eventSender, ElementMouseEventArgs args)
 | |
|         {
 | |
|             if (args.Button == System.Windows.Forms.MouseButtons.Left && args.Clicks == 2)
 | |
|             {
 | |
|                 if (args.Element.Parent is XTextInputFieldElement && IsLoad == true)
 | |
|                 {
 | |
|                     var element = args.Element.Parent as XTextInputFieldElement;
 | |
|                     if (element != null && element.ClientID == "KB20180604142607822")
 | |
|                     {
 | |
|                         SelElement = element;
 | |
|                         PublicUI.UI.frmSelectOperation frmOperation = new PublicUI.UI.frmSelectOperation();
 | |
|                         frmOperation.FormClosed += new FormClosedEventHandler(frmOperation_FormClosed);
 | |
|                         frmOperation.SelectRightData = new List<int>();
 | |
|                         frmOperation.ShowDialog();
 | |
| 
 | |
|                     }
 | |
|                     else if (element != null && element.ClientID == "KB20180604142254986")
 | |
|                     {
 | |
|                         SelElement = element;
 | |
|                         PublicUI.UI.frmSelectDisease frmOperation = new PublicUI.UI.frmSelectDisease();
 | |
|                         frmOperation.FormClosed += new FormClosedEventHandler(frmSelectDisease_FormClosed);
 | |
|                         frmOperation.SelectRightData = new List<int>();
 | |
|                         frmOperation.ShowDialog();
 | |
| 
 | |
|                     }
 | |
|                 }
 | |
|                 //else if (eventSender is XTextImageElement && IsLoad == true)
 | |
|                 //{
 | |
|                 //    OpenFileDialog openFileDialogEmpImage = new OpenFileDialog();
 | |
|                 //    openFileDialogEmpImage.Filter = "*.png|*.png|*.jpg|*.jpg|*.bmp|*.bmp|*.tiff|*.tiff";//图片格式  
 | |
|                 //    if (openFileDialogEmpImage.ShowDialog() == DialogResult.OK)
 | |
|                 //    {
 | |
|                 //        try
 | |
|                 //        {
 | |
|                 //            string empUpLoadPictureRealPos = openFileDialogEmpImage.FileName;//实际的文件路径+文件名  
 | |
|                 //            String[] empImageData = empUpLoadPictureRealPos.Split('.');
 | |
|                 //            //empImageData[1]:是上传的图片的后缀名  
 | |
|                 //            string empUpLoadPictureFormat = empImageData[1];
 | |
|                 //            //赋值图片
 | |
|                 //            (eventSender as XTextImageElement).Image = new DCSoft.Drawing.XImageValue(Image.FromFile(empUpLoadPictureRealPos));
 | |
|                 //            (eventSender as XTextImageElement).Alt = "已签名";
 | |
|                 //            (eventSender as XTextImageElement).Title = "8080";
 | |
|                 //            (eventSender as XTextImageElement).EditorRefreshView();
 | |
| 
 | |
|                 //            //清空图片
 | |
|                 //            //(eventSender as XTextImageElement).Image = null;
 | |
|                 //            //(eventSender as XTextImageElement).Alt = "签名";
 | |
|                 //            //(eventSender as XTextImageElement).Title = "";
 | |
|                 //            //(eventSender as XTextImageElement).EditorRefreshView();
 | |
| 
 | |
|                 //            //属性赋值判断
 | |
|                 //            // (eventSender as XTextImageElement).Image.Value==null 判断是否有图片 是否签名
 | |
|                 //            // (eventSender as XTextImageElement).Alt =="签名"      改为已签名或签名ID
 | |
|                 //            // (eventSender as XTextImageElement).Title =="标题"    存储对应ca人员介质
 | |
|                 //            // (eventSender as XTextImageElement).ID =="image3"     标识Id用于定位赋值图片
 | |
| 
 | |
|                 //        }
 | |
|                 //        catch
 | |
|                 //        {
 | |
|                 //            MessageBox.Show("您选择的图片不能被读取或文件类型不对!", "错误信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
 | |
|                 //        }
 | |
|                 //    }
 | |
|                 //}
 | |
|                 else if (eventSender is XTextImageElement && IsLoad == true)
 | |
|                 {
 | |
|                     frmSelectPersonDoc personDoc = new frmSelectPersonDoc();
 | |
|                     personDoc.PersonType = (eventSender as XTextImageElement).Alt == null ? "麻醉医生" : (eventSender as XTextImageElement).Alt;
 | |
|                     DialogResult dialogResult = personDoc.ShowDialog();
 | |
|                     if (dialogResult == DialogResult.OK)
 | |
|                         if (personDoc.SelectPersonData > 0)
 | |
|                         {
 | |
|                             int PersonId = personDoc.SelectPersonData;
 | |
|                             DataTable Person = GetPerson(PersonId);
 | |
|                             if (Person != null && Person.Rows.Count > 0)
 | |
|                             {
 | |
|                                 string Id = Person.Rows[0][3].ToString();
 | |
|                                 string Name = Person.Rows[0][0].ToString();
 | |
|                                 string Contact = Person.Rows[0][1].ToString();
 | |
|                                 string SignatureStr = Person.Rows[0][2].ToString();
 | |
| 
 | |
| 
 | |
|                                 if (SignatureStr == null || SignatureStr == "")
 | |
|                                     SignatureStr = new SignManage().GetSignStr(args.WriterControl.SaveDocumentToString("txt"), args.WriterControl.Document.FileName, Id, Name, Contact);
 | |
| 
 | |
|                                 if (SignatureStr != null && SignatureStr != "")
 | |
|                                 {
 | |
|                                     DCSoft.Drawing.XImageValue img = new DCSoft.Drawing.XImageValue();
 | |
|                                     img.ImageDataBase64String = SignatureStr;
 | |
|                                     (eventSender as XTextImageElement).Image = img;
 | |
|                                     //(eventSender as XTextImageElement).Alt = "麻醉医生";
 | |
|                                     (eventSender as XTextImageElement).Title = PersonId.ToString();
 | |
|                                     (eventSender as XTextImageElement).EditorRefreshView();
 | |
|                                 }
 | |
|                             }
 | |
|                             else
 | |
|                             {
 | |
|                                 //清空图片
 | |
|                                 (eventSender as XTextImageElement).Image = null;
 | |
|                                 (eventSender as XTextImageElement).Alt = "麻醉医生";
 | |
|                                 (eventSender as XTextImageElement).Title = "";
 | |
|                                 (eventSender as XTextImageElement).EditorRefreshView();
 | |
|                             }
 | |
|                         }
 | |
|                         else
 | |
|                         {
 | |
|                             //清空图片
 | |
|                             (eventSender as XTextImageElement).Image = null;
 | |
|                             (eventSender as XTextImageElement).Alt = "麻醉医生";
 | |
|                             (eventSender as XTextImageElement).Title = "";
 | |
|                             (eventSender as XTextImageElement).EditorRefreshView();
 | |
|                         }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         public CompilerErrorCollection Errors { get { return cr.Errors; } }
 | |
| 
 | |
|         void eet_ContentChanged(object eventSender, ContentChangedEventArgs args)
 | |
|         {
 | |
|             if (args.Element is XTextInputFieldElement && IsLoad == true)
 | |
|             {
 | |
|                 var element = args.Element as XTextInputFieldElement;
 | |
|                 if (SelElementName != null && SelElementName == element.Name && SelElementValue == element.Text)
 | |
|                     return;
 | |
|                 for (int i = 0; i < QXList.Count; i++)
 | |
|                 {
 | |
|                     if (element.Name == QXList[i] + "A")
 | |
|                     {
 | |
|                         try
 | |
|                         {
 | |
|                             SelElement = element;
 | |
|                             SelElementName = element.Name;
 | |
|                             SelElementValue = element.Text;
 | |
|                             var hf1 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                 && (x as XTextInputFieldElement).Name == QXList[i] + "B").FirstOrDefault();
 | |
|                             if (SelElementValue != "" && hf1.Text != "")
 | |
|                             {
 | |
|                                 double value = 0, font = 0, doing = 0;
 | |
|                                 if (double.TryParse(SelElementValue, out font) == true && double.TryParse(hf1.Text, out doing) == true)
 | |
|                                 {
 | |
|                                     value = font + doing;
 | |
|                                     var hf3 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                         && (x as XTextInputFieldElement).Name == QXList[i] + "C").FirstOrDefault();
 | |
|                                     if (hf3 != null) hf3.Text = value.ToString();
 | |
|                                     var hf2 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                         && (x as XTextInputFieldElement).Name == QXList[i] + "D").FirstOrDefault();
 | |
|                                     if (hf2 != null) hf2.Text = value.ToString();
 | |
|                                 }
 | |
|                                 else
 | |
|                                 {
 | |
|                                     var hf3 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                         && (x as XTextInputFieldElement).Name == QXList[i] + "C").FirstOrDefault();
 | |
|                                     if (hf3 != null) hf3.Text = SelElementValue;
 | |
|                                     var hf2 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                         && (x as XTextInputFieldElement).Name == QXList[i] + "D").FirstOrDefault();
 | |
|                                     if (hf2 != null) hf2.Text = SelElementValue;
 | |
|                                 }
 | |
|                             }
 | |
|                             else if (SelElementValue != "")
 | |
|                             {
 | |
|                                 var hf3 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                     && (x as XTextInputFieldElement).Name == QXList[i] + "C").FirstOrDefault();
 | |
|                                 if (hf3 != null) hf3.Text = SelElementValue;
 | |
|                                 var hf2 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                     && (x as XTextInputFieldElement).Name == QXList[i] + "D").FirstOrDefault();
 | |
|                                 if (hf2 != null) hf2.Text = SelElementValue;
 | |
|                             }
 | |
|                         }
 | |
|                         catch (Exception)
 | |
|                         {
 | |
|                             var hf = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                 && (x as XTextInputFieldElement).Name == QXList[i] + "C").FirstOrDefault();
 | |
|                             if (hf != null) hf.Text = SelElementValue;
 | |
|                             var hf2 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                 && (x as XTextInputFieldElement).Name == QXList[i] + "D").FirstOrDefault();
 | |
|                             if (hf2 != null) hf2.Text = SelElementValue;
 | |
|                         }
 | |
|                         break;
 | |
|                     }
 | |
|                     else if (element.Name == QXList[i] + "B")
 | |
|                     {
 | |
|                         try
 | |
|                         {
 | |
|                             SelElement = element;
 | |
|                             SelElementName = element.Name;
 | |
|                             SelElementValue = element.Text;
 | |
|                             var hf1 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                 && (x as XTextInputFieldElement).Name == QXList[i] + "A").FirstOrDefault();
 | |
|                             if (SelElementValue != "" && hf1.Text != null)
 | |
|                             {
 | |
|                                 double value = 0, font = 0, doing = 0;
 | |
|                                 if (double.TryParse(SelElementValue, out font) == true && double.TryParse(hf1.Text, out doing) == true)
 | |
|                                 {
 | |
|                                     value = font + doing;
 | |
|                                     var hf3 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                         && (x as XTextInputFieldElement).Name == QXList[i] + "C").FirstOrDefault();
 | |
|                                     if (hf3 != null) hf3.Text = value.ToString();
 | |
|                                     var hf2 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                         && (x as XTextInputFieldElement).Name == QXList[i] + "D").FirstOrDefault();
 | |
|                                     if (hf2 != null) hf2.Text = value.ToString();
 | |
|                                 }
 | |
|                             }
 | |
|                         }
 | |
|                         catch (Exception)
 | |
|                         {
 | |
|                             var hf = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                 && (x as XTextInputFieldElement).Name == QXList[i] + "C").FirstOrDefault();
 | |
|                             if (hf != null) hf.Text = SelElementValue;
 | |
|                             var hf2 = args.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | |
|                                 && (x as XTextInputFieldElement).Name == QXList[i] + "D").FirstOrDefault();
 | |
|                             if (hf2 != null) hf2.Text = SelElementValue;
 | |
|                         }
 | |
|                         break;
 | |
| 
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         void eetChk_MouseClick(object eventSender, ElementMouseEventArgs args)
 | |
|         {
 | |
|             if (args.Element is XTextInputFieldElement && IsLoad == true)
 | |
|             {
 | |
|                 var element = args.Element as XTextInputFieldElement;
 | |
|                 for (int i = 0; i < QXList.Count; i++)
 | |
|                 {
 | |
|                     if ((element.Name == QXList[i] + "A" || element.Name == QXList[i] + "B") && element.Text == "0")
 | |
|                     {
 | |
|                         element.Text = "";
 | |
|                         break;
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         void frmOperation_FormClosed(object sender, FormClosedEventArgs e)
 | |
|         {
 | |
|             PublicUI.UI.frmSelectOperation frmOperation = sender as PublicUI.UI.frmSelectOperation;
 | |
|             if (frmOperation.SelectRightData.Count > 0)
 | |
|             {
 | |
|                 string OpeStr = "";
 | |
|                 foreach (int RowId in frmOperation.SelectRightData)
 | |
|                 {
 | |
|                     OpeStr += BOperation.SelectSingle(RowId).Name + " ,";
 | |
|                 }
 | |
|                 int idxStart = OpeStr.LastIndexOf(" ,");
 | |
|                 OpeStr = OpeStr.Substring(0, idxStart);
 | |
|                 SelElement.Text = OpeStr;
 | |
|             }
 | |
|         }
 | |
|         void frmSelectDisease_FormClosed(object sender, FormClosedEventArgs e)
 | |
|         {
 | |
|             PublicUI.UI.frmSelectDisease frmOperation = sender as PublicUI.UI.frmSelectDisease;
 | |
|             if (frmOperation.SelectRightData.Count > 0)
 | |
|             {
 | |
|                 string OpeStr = "";
 | |
|                 foreach (int RowId in frmOperation.SelectRightData)
 | |
|                 {
 | |
|                     OpeStr += BDisease.SelectSingle(RowId).Name + " ,";
 | |
|                 }
 | |
|                 int idxStart = OpeStr.LastIndexOf(" ,");
 | |
|                 OpeStr = OpeStr.Substring(0, idxStart);
 | |
|                 SelElement.Text = OpeStr;
 | |
|             }
 | |
|         }
 | |
|         public DataTable GetPerson(int SelectPersonData)
 | |
|         {
 | |
|             DataTable Person = new DataTable();
 | |
|             string sql = "select  Name,SignatureIndex,SignatureStr,id from Person where id=" + SelectPersonData;
 | |
|             Person = DBHelper.GetDataTable(sql);
 | |
|             return Person;
 | |
|         }
 | |
|     }
 | |
| }
 |