533 lines
		
	
	
		
			24 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			533 lines
		
	
	
		
			24 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using AIMSBLL;
 | ||
| using AIMSModel;
 | ||
| using DCSoft.Writer;
 | ||
| using DCSoft.Writer.Data;
 | ||
| using DCSoft.Writer.Dom;
 | ||
| using DocumentManagement;
 | ||
| using DrawGraph;
 | ||
| using System;
 | ||
| using System.Collections.Generic;
 | ||
| using System.Data;
 | ||
| using System.Drawing;
 | ||
| using System.Globalization;
 | ||
| using System.Linq;
 | ||
| using System.Reflection;
 | ||
| using System.Runtime.InteropServices;
 | ||
| using System.Text.RegularExpressions;
 | ||
| using System.Windows.Forms;
 | ||
| using System.Xml;
 | ||
| using System.Xml.Linq;
 | ||
| 
 | ||
| namespace AIMS.OperationAanesthesia
 | ||
| {
 | ||
|     public partial class frmPrescriptionDocument : Form
 | ||
|     {
 | ||
|         public int PatientId;
 | ||
|         public FeesRecord fee;
 | ||
|         public List<int> RecordIds;
 | ||
|         //模板Model
 | ||
|         private PrintTemplate TModel = new PrintTemplate();
 | ||
|         //文档Model
 | ||
|         private PrintDocument DModel = new PrintDocument();
 | ||
|         //患者Id
 | ||
|         public PatientRecord Patient = new PatientRecord();
 | ||
|         //容器tab
 | ||
|         //public TabItem Tb;
 | ||
|         //文档事件
 | ||
|         //private EventCodeCompilerBill codeCompiler;
 | ||
|         //private string strClick, strContentChanged;
 | ||
| 
 | ||
| 
 | ||
|         public frmPrescriptionDocument()
 | ||
|         {
 | ||
|             InitializeComponent();
 | ||
|         }
 | ||
| 
 | ||
|         private void frmPrescriptionDocument_Load(object sender, EventArgs e)
 | ||
|         {
 | ||
|             //myEditControl初始化
 | ||
|             myEditControl.MoveFocusHotKey = MoveFocusHotKeys.Tab;
 | ||
|             myEditControl.HeaderFooterReadonly = true;
 | ||
|             myEditControl.CommandControler = this.writerCommandControler1;
 | ||
|             writerCommandControler1.Start();
 | ||
|             //表单视图模式
 | ||
|             myEditControl.FormView = DCSoft.Writer.Controls.FormViewMode.Strict;
 | ||
|             //加载知识库
 | ||
|             //DocumentDAL.LoadKBLibaray();
 | ||
|             myEditControl.ExecuteCommand("LoadKBLibrary", false, DocumentDAL.Lib);
 | ||
|             // 注册自定义的输入域下拉列表提供者
 | ||
|             myEditControl.AppHost.Services.AddService(
 | ||
|                 typeof(IListItemsProvider),
 | ||
|                 new MyListItemsProvider());
 | ||
|             //// 设置文档处于调试模式
 | ||
|             //myEditControl.DocumentOptions.BehaviorOptions.DebugMode = true;
 | ||
|             //myEditControl.DocumentOptions.BehaviorOptions.InsertCommentBindingUserTrack = true;
 | ||
|             //启用逻辑删除、权限控制
 | ||
|             myEditControl.Document.Options.SecurityOptions.EnablePermission = true;
 | ||
|             myEditControl.Document.Options.SecurityOptions.EnableLogicDelete = true;
 | ||
|             myEditControl.Document.Options.SecurityOptions.ShowLogicDeletedContent = true;
 | ||
|             myEditControl.Document.Options.SecurityOptions.ShowPermissionMark = true;
 | ||
|             myEditControl.Document.Options.SecurityOptions.ShowPermissionTip = true;
 | ||
| 
 | ||
| 
 | ||
|             if (fee != null)
 | ||
|             {
 | ||
|                 panelDrug.Visible = false;
 | ||
|                 toolStrip1.Visible = true;
 | ||
|                 Patient = PatientRecord.GetPatientRecord(PatientId);
 | ||
|                 if (fee.FeeTypeId == "精神II类")
 | ||
|                 {
 | ||
|                     DModel = DocumentDAL.GetDocumentbyName("第二类精神药品处方笺", Patient.PatientId, fee.Id.Value);
 | ||
|                     LoadDocument();
 | ||
|                 }
 | ||
|                 else if (fee.FeeTypeId == "精神I类")
 | ||
|                 {
 | ||
|                     DModel = DocumentDAL.GetDocumentbyName("第一类精神药品处方笺", Patient.PatientId, fee.Id.Value);
 | ||
|                     LoadDocument();
 | ||
|                 }
 | ||
|                 else if (fee.FeeTypeId == "麻醉药")
 | ||
|                 {
 | ||
|                     DModel = DocumentDAL.GetDocumentbyName("麻醉药品处方笺", Patient.PatientId, fee.Id.Value);
 | ||
|                     LoadDocument();
 | ||
|                 }
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 panelDrug.Visible = true;
 | ||
|                 toolStrip1.Visible = false;
 | ||
| 
 | ||
|                 string applianceId = string.Join(",", RecordIds.ToArray());
 | ||
|                 feesRecords = BFeesRecord.Select(" Extend4<>'' and OperationRecordId in(" + applianceId + ") ", null);
 | ||
|                 foreach (var item in feesRecords)
 | ||
|                 {
 | ||
|                     if (!chargName.Contains(item.ChargName))
 | ||
|                     {
 | ||
|                         chargName.Add(item.ChargName);
 | ||
|                     }
 | ||
|                 }
 | ||
|                 if (chargName.Count > 0)
 | ||
|                 {
 | ||
|                     FullPanel(panelDrug, chargName);
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         /// <summary>
 | ||
|         /// 加载相应的不良质控控件(同时赋值)
 | ||
|         /// </summary>
 | ||
|         /// <param name="panel"></param>
 | ||
|         /// <param name="list"></param>
 | ||
|         /// <param name="rList"></param>
 | ||
|         private void FullPanel(Panel panel, List<string> list)
 | ||
|         {
 | ||
|             //panel.Controls.Clear();
 | ||
|             int rows = 0;
 | ||
|             int cols = 0;
 | ||
|             int x = 0;
 | ||
|             //循环加载CheckBox控件
 | ||
|             foreach (string ade in list)
 | ||
|             {
 | ||
|                 x = cols * 150 + 20;
 | ||
|                 CheckBox chkYes = new CheckBox();
 | ||
|                 chkYes.AutoSize = true;
 | ||
|                 chkYes.Text = ade.Length > 14 ? ade.Substring(0, 13) : ade;
 | ||
|                 chkYes.UseVisualStyleBackColor = true;
 | ||
|                 chkYes.Tag = ade;
 | ||
|                 chkYes.CheckedChanged += new EventHandler(cb_CheckedChanged);
 | ||
|                 chkYes.Location = new Point(x, rows * (chkYes.Height + 2) + 4);
 | ||
|                 panel.Controls.Add(chkYes);
 | ||
|                 rows++;
 | ||
|                 if (rows == 3)
 | ||
|                 {
 | ||
|                     rows = 0;
 | ||
|                     cols++;
 | ||
|                     if (cols == 2)
 | ||
|                     {
 | ||
|                         return;
 | ||
|                     }
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         void cb_CheckedChanged(object sender, EventArgs e)
 | ||
|         {
 | ||
|             CheckBox ck = sender as CheckBox;
 | ||
|             //判断CheckBox被选中时
 | ||
|             if (ck.Checked)
 | ||
|             {
 | ||
|                 if (!SelChargName.Contains(ck.Tag.ToString()))
 | ||
|                 {
 | ||
|                     SelChargName.Add(ck.Tag.ToString());
 | ||
|                 }
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 if (SelChargName.Contains(ck.Tag.ToString()))
 | ||
|                 {
 | ||
|                     SelChargName.Remove(ck.Tag.ToString());
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
|         public List<string> chargName = new List<string>();
 | ||
|         public List<string> SelChargName = new List<string>();
 | ||
|         public List<FeesRecord> feesRecords;
 | ||
| 
 | ||
|         private void buttonX1_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             foreach (var item in feesRecords)
 | ||
|             {
 | ||
|                 if (!SelChargName.Contains(item.ChargName)) continue;
 | ||
|                 fee = item;
 | ||
|                 Patient = PatientRecord.GetPatientRecord(item.PatientId.Value);
 | ||
|                 if (item.FeeTypeId == "精神II类")
 | ||
|                 {
 | ||
|                     DModel = DocumentDAL.GetDocumentbyName("第二类精神药品处方笺", Patient.PatientId, item.Id.Value);
 | ||
|                     LoadDocument();
 | ||
|                     myEditControl.ExecuteCommand("FilePrint", false, null);
 | ||
|                     ControlExtension.UPDocument(Patient.PatientId, Patient.ApplyId, DModel.Id, 3, DModel.TemplateId.ToString(), DModel.XmlFileName);
 | ||
|                 }
 | ||
|                 else if (item.FeeTypeId == "精神I类")
 | ||
|                 {
 | ||
|                     DModel = DocumentDAL.GetDocumentbyName("第一类精神药品处方笺", Patient.PatientId, item.Id.Value);
 | ||
|                     LoadDocument();
 | ||
|                     myEditControl.ExecuteCommand("FilePrint", false, null);
 | ||
|                     ControlExtension.UPDocument(Patient.PatientId, Patient.ApplyId, DModel.Id, 3, DModel.TemplateId.ToString(), DModel.XmlFileName);
 | ||
|                 }
 | ||
|                 else if (item.FeeTypeId == "麻醉药")
 | ||
|                 {
 | ||
|                     DModel = DocumentDAL.GetDocumentbyName("麻醉药品处方笺", Patient.PatientId, item.Id.Value);
 | ||
|                     LoadDocument();
 | ||
|                     myEditControl.ExecuteCommand("FilePrint", false, null);
 | ||
|                     ControlExtension.UPDocument(Patient.PatientId, Patient.ApplyId, DModel.Id, 3, DModel.TemplateId.ToString(), DModel.XmlFileName);
 | ||
|                 }
 | ||
|             }
 | ||
|         }
 | ||
| 
 | ||
|         #region 文书控件事件
 | ||
|         private void LoadDocument()
 | ||
|         {
 | ||
|             if (DModel.Id > 0)
 | ||
|             {
 | ||
|                 //加载文档
 | ||
|                 DModel = DocumentDAL.GetDocumentbyId(DModel.Id);
 | ||
|                 myEditControl.LoadDocumentFromString(DModel.XmlFile, "xml");
 | ||
| 
 | ||
|                 //患者基本信息二次赋值
 | ||
|                 var query = from XTextElement in myEditControl.Document.Fields.ToArray()
 | ||
|                             where XTextElement is XTextInputFieldElement
 | ||
|                             && (XTextElement as XTextInputFieldElement).FieldSettings != null
 | ||
|                             && (XTextElement as XTextInputFieldElement).FieldSettings.EditStyle != InputFieldEditStyle.Date
 | ||
|                             && (XTextElement as XTextInputFieldElement).FieldSettings.ListSource != null
 | ||
|                             select XTextElement as XTextInputFieldElement;
 | ||
|                 DataRow[] dr = DocumentDAL.GetReflectionList("V_OperationRecordALL").Select("KB_SEQ <> '' and Reload=1");
 | ||
|                 var p = typeof(PatientRecord).GetProperties();
 | ||
|                 for (int i = 0; i < dr.Count(); i++)
 | ||
|                 {
 | ||
|                     var name = dr[i].ItemArray[0].ToString();
 | ||
|                     var value = dr[i].ItemArray[1].ToString();
 | ||
|                     XTextInputFieldElement element = query.Where(x => x.FieldSettings.ListSource.SourceName == value).FirstOrDefault();
 | ||
|                     PropertyInfo info = p.Where(px => px.Name == name).FirstOrDefault();
 | ||
|                     if (element != null && info != null)
 | ||
|                     {
 | ||
|                         element.Text = info.GetValue(Patient, null).ToString();
 | ||
|                     }
 | ||
|                 }
 | ||
|                 if (fee != null)
 | ||
|                 {
 | ||
|                     var Text8 = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                         && (x as XTextInputFieldElement).Name == "批号").FirstOrDefault();
 | ||
|                     if (Text8 != null)
 | ||
|                         Text8.Text = fee.InsureNO; 
 | ||
|                 }
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 fee.Extend4 = BFeesRecord.GetOrderNum(fee.FeeTypeId).ToString();
 | ||
|                 //无文档则加载模板
 | ||
|                 TModel = DocumentDAL.GetTemplatebyId(DModel.TemplateId);
 | ||
|                 if (TModel.XmlFile == null || TModel.XmlFile.Trim().Equals(string.Empty))
 | ||
|                 {
 | ||
|                     myEditControl.ExecuteCommand("FileNew", true, null);
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
|                     myEditControl.LoadDocumentFromString(TModel.XmlFile, "xml");
 | ||
|                 }
 | ||
|                 DModel.XmlFileName = TModel.XmlFileName;
 | ||
|                 DModel.TemplateId = TModel.Id;
 | ||
|                 DModel.OrderNo = fee.Extend4;
 | ||
|                 //患者基本信息赋值
 | ||
|                 var query = from XTextElement in myEditControl.Document.Fields.ToArray()
 | ||
|                             where XTextElement is XTextInputFieldElement
 | ||
|                             && (XTextElement as XTextInputFieldElement).FieldSettings != null
 | ||
|                             && (XTextElement as XTextInputFieldElement).FieldSettings.EditStyle != InputFieldEditStyle.Date
 | ||
|                             && (XTextElement as XTextInputFieldElement).FieldSettings.ListSource != null
 | ||
|                             select XTextElement as XTextInputFieldElement;
 | ||
|                 DataRow[] dr = DocumentDAL.GetReflectionList("V_OperationRecordALL").Select("KB_SEQ <> ''");
 | ||
|                 var p = typeof(PatientRecord).GetProperties();
 | ||
|                 for (int i = 0; i < dr.Count(); i++)
 | ||
|                 {
 | ||
|                     var name = dr[i].ItemArray[0].ToString();
 | ||
|                     var value = dr[i].ItemArray[1].ToString();
 | ||
|                     XTextInputFieldElement element = query.Where(x => x.FieldSettings.ListSource.SourceName == value).FirstOrDefault();
 | ||
|                     PropertyInfo info = p.Where(px => px.Name == name).FirstOrDefault();
 | ||
|                     if (element != null && info != null)
 | ||
|                     {
 | ||
|                         element.Text = info.GetValue(Patient, null).ToString();
 | ||
|                     }
 | ||
|                 }
 | ||
| 
 | ||
|                 var Text = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                     && (x as XTextInputFieldElement).Name == "开方日期").FirstOrDefault();
 | ||
|                 if (Text != null && fee.ExecTime != null)
 | ||
|                     Text.Text = " " + fee.ExecTime.Value.ToString("yyyy年MM月dd日");
 | ||
|                 var Text1 = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                     && (x as XTextInputFieldElement).Name == "药品名称").FirstOrDefault();
 | ||
|                 if (Text1 != null)
 | ||
|                     Text1.Text = fee.ChargName;
 | ||
|                 var Text2 = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                     && (x as XTextInputFieldElement).Name == "规格").FirstOrDefault();
 | ||
|                 if (Text2 != null)
 | ||
|                     Text2.Text = GetChina(fee.ChargSpec) + "*" + NumToChinese(fee.FeeNum) + GetChina(fee.Unit);
 | ||
|                 var Text3 = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                     && (x as XTextInputFieldElement).Name == "剂量").FirstOrDefault();
 | ||
|                 if (Text3 != null)
 | ||
|                     Text3.Text = fee.Extend2;
 | ||
|                 var Text4 = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                     && (x as XTextInputFieldElement).Name == "单位").FirstOrDefault();
 | ||
|                 if (Text4 != null)
 | ||
|                     Text4.Text = GetChina(fee.Extend1);
 | ||
|                 //var Text5 = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                 //    && (x as XTextInputFieldElement).Name == "途径").FirstOrDefault();
 | ||
|                 //if (Text5 != null)
 | ||
|                 //    Text5.Text = fee.Extend3;
 | ||
|                 var Text6 = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                     && (x as XTextInputFieldElement).Name == "药价").FirstOrDefault();
 | ||
|                 if (Text6 != null)
 | ||
|                     Text6.Text = " " + fee.ChargePrice;
 | ||
|                 var Text7 = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                     && (x as XTextInputFieldElement).Name == "医师").FirstOrDefault();
 | ||
|                 if (Text7 != null)
 | ||
|                     Text7.Text = fee.ExecWork;
 | ||
|                 var Text8 = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                     && (x as XTextInputFieldElement).Name == "处方单号").FirstOrDefault();
 | ||
|                 if (Text8 != null)
 | ||
|                     Text8.Text = "00" + fee.Extend4;
 | ||
|                 var Text9 = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                     && (x as XTextInputFieldElement).ID == "field18").FirstOrDefault();
 | ||
|                 if (Text9 != null && fee.ChargName.Contains("瑞芬"))
 | ||
|                     Text9.Text = "术中静脉泵入";
 | ||
|                 DocumentExtension.SetDocumentDefaultValue(TModel.XmlFileName, myEditControl.Document, Patient);
 | ||
|             }
 | ||
|             string xmlStatic = DocumentDAL.GetEventXml(DModel.TemplateId);
 | ||
|             if (xmlStatic != string.Empty)
 | ||
|             {
 | ||
|                 XmlDocument doc = new XmlDocument();
 | ||
|                 doc.LoadXml(xmlStatic);
 | ||
|                 //strClick = doc.GetElementsByTagName("ClickEvent")[0].InnerText;
 | ||
|                 //strContentChanged = doc.GetElementsByTagName("ContentChangedEnvent")[0].InnerText;
 | ||
|             }
 | ||
|             //codeCompiler = new EventCodeCompilerBill(ref this.myEditControl, strClick, strContentChanged, QXList);
 | ||
| 
 | ||
|             //文档用户信息
 | ||
|             myEditControl.UserLoginByParameter(
 | ||
|                        AIMSExtension.PublicMethod.OperatorNo,
 | ||
|                        AIMSExtension.PublicMethod.OperatorName,
 | ||
|                        AIMSExtension.PublicMethod.PermissionLevel);
 | ||
|             //隐藏痕迹先
 | ||
|             myEditControl.ExecuteCommand(StandardCommandNames.CleanViewMode, false, true);
 | ||
| 
 | ||
|         }
 | ||
|         #endregion
 | ||
|         //dizuoxin
 | ||
|         //曲马多  
 | ||
|         public string NumToChinese(string x)
 | ||
|         {
 | ||
|             //数字转换为中文后的数组 //转载请注明来自 http://www.shang11.com  
 | ||
|             string[] P_array_num = new string[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
 | ||
|             //为数字位数建立一个位数组  
 | ||
|             string[] P_array_digit = new string[] { "", "拾", "佰", "仟" };
 | ||
|             //为数字单位建立一个单位数组  
 | ||
|             string[] P_array_units = new string[] { "", "万", "亿", "万亿" };
 | ||
|             string P_str_returnValue = ""; //返回值  
 | ||
|             int finger = 0; //字符位置指针  
 | ||
|             int P_int_m = x.Length % 4; //取模  
 | ||
|             int P_int_k = 0;
 | ||
|             if (P_int_m > 0)
 | ||
|                 P_int_k = x.Length / 4 + 1;
 | ||
|             else
 | ||
|                 P_int_k = x.Length / 4;
 | ||
|             //外层循环,四位一组,每组最后加上单位: ",万亿,",",亿,",",万,"  
 | ||
|             for (int i = P_int_k; i > 0; i--)
 | ||
|             {
 | ||
|                 int P_int_L = 4;
 | ||
|                 if (i == P_int_k && P_int_m != 0)
 | ||
|                     P_int_L = P_int_m;
 | ||
|                 //得到一组四位数  
 | ||
|                 string four = x.Substring(finger, P_int_L);
 | ||
|                 int P_int_l = four.Length;
 | ||
|                 //内层循环在该组中的每一位数上循环  
 | ||
|                 for (int j = 0; j < P_int_l; j++)
 | ||
|                 {
 | ||
|                     //处理组中的每一位数加上所在的位  
 | ||
|                     int n = Convert.ToInt32(four.Substring(j, 1));
 | ||
|                     if (n == 0)
 | ||
|                     {
 | ||
|                         if (j < P_int_l - 1 && Convert.ToInt32(four.Substring(j + 1, 1)) > 0 && !P_str_returnValue.EndsWith(P_array_num[n]))
 | ||
|                             P_str_returnValue += P_array_num[n];
 | ||
|                     }
 | ||
|                     else
 | ||
|                     {
 | ||
|                         if (!(n == 1 && (P_str_returnValue.EndsWith(P_array_num[0]) | P_str_returnValue.Length == 0) && j == P_int_l - 2))
 | ||
|                             P_str_returnValue += P_array_num[n];
 | ||
|                         P_str_returnValue += P_array_digit[P_int_l - j - 1];
 | ||
|                     }
 | ||
|                 }
 | ||
|                 finger += P_int_L;
 | ||
|                 //每组最后加上一个单位:",万,",",亿," 等  
 | ||
|                 if (i < P_int_k) //如果不是最高位的一组  
 | ||
|                 {
 | ||
|                     if (Convert.ToInt32(four) != 0)
 | ||
|                         //如果所有4位不全是0则加上单位",万,",",亿,"等  
 | ||
|                         P_str_returnValue += P_array_units[i - 1];
 | ||
|                 }
 | ||
|                 else
 | ||
|                 {
 | ||
|                     //处理最高位的一组,最后必须加上单位  
 | ||
|                     P_str_returnValue += P_array_units[i - 1];
 | ||
|                 }
 | ||
|             }
 | ||
|             return P_str_returnValue;
 | ||
|         }
 | ||
|         public string GetChina(string str)
 | ||
|         {
 | ||
|             string value = str;
 | ||
|             if (value.Contains(":"))
 | ||
|             {
 | ||
|                 List<string> strs = value.Split(':').ToList();
 | ||
|                 if (strs.Count == 2)
 | ||
|                     value = strs[1];
 | ||
|             }
 | ||
|             else if (value.Contains(":"))
 | ||
|             {
 | ||
|                 List<string> strs = value.Split(':').ToList();
 | ||
|                 if (strs.Count == 2)
 | ||
|                     value = strs[1];
 | ||
|             }
 | ||
|             else if (value.Contains(":"))
 | ||
|             {
 | ||
|                 List<string> strs = value.Split(':').ToList();
 | ||
|                 if (strs.Count == 2)
 | ||
|                     value = strs[1];
 | ||
|             }
 | ||
|             if (value.Contains("mg"))
 | ||
|             {
 | ||
|                 value = value.Replace("mg", "毫克");
 | ||
|             }
 | ||
|             else if (value.Contains("ug"))
 | ||
|             {
 | ||
|                 value = value.Replace("ug", "微克");
 | ||
|             }
 | ||
|             else if (value.Contains("ml"))
 | ||
|             {
 | ||
|                 value = value.Replace("ml", "毫升");
 | ||
|             }
 | ||
|             else if (value.Contains("g"))
 | ||
|             {
 | ||
|                 value = value.Replace("g", "克");
 | ||
|             }
 | ||
|             else if (value.Contains("l"))
 | ||
|             {
 | ||
|                 value = value.Replace("l", "毫升");
 | ||
|             }
 | ||
|             return value;
 | ||
|         }
 | ||
| 
 | ||
|         private void tsbAdd_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             tsbSava_Click(null, null);
 | ||
|             myEditControl.ExecuteCommand("FilePrint", true, null);
 | ||
|             ControlExtension.UPDocument(Patient.PatientId, Patient.ApplyId, DModel.Id, 3, DModel.TemplateId.ToString(), DModel.XmlFileName);
 | ||
|         }
 | ||
|         private void tsbExit_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             this.Close();
 | ||
|         }
 | ||
| 
 | ||
|         private void tsbSava_Click(object sender, EventArgs e)
 | ||
|         {
 | ||
|             if (DModel.Id == 0)
 | ||
|             {
 | ||
|                 int orderno = BFeesRecord.GetOrderNum(fee.FeeTypeId);
 | ||
|                 if (int.Parse(fee.Extend4) < orderno)
 | ||
|                 {
 | ||
|                     fee.Extend4 = orderno.ToString();
 | ||
|                     var Text8 = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
 | ||
|                    && (x as XTextInputFieldElement).Name == "处方单号").FirstOrDefault();
 | ||
|                     if (Text8 != null)
 | ||
|                         Text8.Text = "00" + fee.Extend4;
 | ||
|                 }
 | ||
|             }
 | ||
|             BFeesRecord.Update(fee);
 | ||
|             ValueValidateResultList listR = myEditControl.Document.ValueValidate();
 | ||
|             string vMsg = "";
 | ||
|             foreach (var item in listR)
 | ||
|             {
 | ||
|                 vMsg += item.Message + System.Environment.NewLine;
 | ||
|             }
 | ||
|             if (vMsg.Length > 0)
 | ||
|             {
 | ||
|                 throw new Exception(vMsg);
 | ||
|             }
 | ||
|             //model赋值
 | ||
|             DModel.XmlFile = myEditControl.Document.XMLText;
 | ||
|             DModel.PatientId = this.Patient.PatientId;
 | ||
|             DModel.OperatorNo = AIMSExtension.PublicMethod.OperatorNo;
 | ||
|             DModel.RecordId = fee.Id.Value.ToString();
 | ||
|             DModel.Remark = fee.ChargName;
 | ||
|             DModel.OrderNo = fee.Extend4;
 | ||
|             XmlDocument doc = new XmlDocument();
 | ||
|             XmlElement rootNode = doc.CreateElement("Root");
 | ||
|             doc.AppendChild(rootNode);
 | ||
|             var query = from XTextElement in myEditControl.Document.Fields.ToArray()
 | ||
|                         where (XTextElement is XTextInputFieldElement && (XTextElement as XTextInputFieldElement).ToolTip != "")
 | ||
|                         || XTextElement is XTextCheckBoxElement && ((XTextElement as XTextCheckBoxElement).ToolTip != "")
 | ||
|                         select XTextElement;
 | ||
|             foreach (var element in query)
 | ||
|             {
 | ||
|                 XmlElement itemNode = doc.CreateElement("Item");
 | ||
| 
 | ||
|                 if (element is XTextInputFieldElement)
 | ||
|                 {
 | ||
|                     itemNode.SetAttribute("Name", (element as XTextInputFieldElement).ToolTip);
 | ||
|                     itemNode.InnerText = element.Text;
 | ||
|                     rootNode.AppendChild(itemNode);
 | ||
|                 }
 | ||
|                 else if (element is XTextCheckBoxElement)
 | ||
|                 {
 | ||
|                     itemNode.SetAttribute("Name", (element as XTextCheckBoxElement).ToolTip);
 | ||
|                     itemNode.SetAttribute("Checked", ((XTextCheckBoxElement)element).Checked == true ? "1" : "0");
 | ||
|                     itemNode.InnerText = (element as XTextCheckBoxElement).Value;
 | ||
|                     rootNode.AppendChild(itemNode);
 | ||
|                 }
 | ||
|             }
 | ||
|             DModel.XmlStatic = doc.OuterXml;
 | ||
|             if (DModel.Id > 0)
 | ||
|             {
 | ||
|                 DocumentDAL.UpdatePrintDocument2(this.DModel);
 | ||
|                 //MessageBox.Show("修改成功!");
 | ||
|             }
 | ||
|             else
 | ||
|             {
 | ||
|                 DocumentDAL.InsertPrintDocument2(this.DModel);
 | ||
|                 //new frmMessageBox().Show();
 | ||
|             }
 | ||
|             myEditControl.Document.Modified = false;
 | ||
| 
 | ||
|             new frmMessageBox().Show();
 | ||
| 
 | ||
|         }
 | ||
| 
 | ||
|     }
 | ||
| }
 |