398 lines
17 KiB
C#
398 lines
17 KiB
C#
using AIMS.PublicUI.UI;
|
|
using DCSoft.Writer;
|
|
using DCSoft.Writer.Data;
|
|
using DCSoft.Writer.Dom;
|
|
using DocumentManagement;
|
|
using DrawGraph;
|
|
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Windows.Forms;
|
|
using System.Xml;
|
|
|
|
namespace AIMS.OremrUserControl
|
|
{
|
|
public partial class ucDocumentGoodsBill : UserControl
|
|
{
|
|
//模板Model
|
|
private PrintTemplate TModel = new PrintTemplate();
|
|
//文档Model
|
|
private PrintDocument DModel = new PrintDocument();
|
|
//患者Id
|
|
public PatientRecord Patient = new PatientRecord();
|
|
//刷新文档目录
|
|
public delegate void RefreshUcClassify(int patientId);
|
|
public RefreshUcClassify RefreshUc;
|
|
//文档标题
|
|
public delegate void ModifyTitle();
|
|
public ModifyTitle ModifyT;
|
|
public delegate void ClearTitle();
|
|
public ClearTitle ClearT;
|
|
//关闭
|
|
public delegate void CloseParent();
|
|
public CloseParent CloseP;
|
|
//容器tab
|
|
//public TabItem Tb;
|
|
//文档事件
|
|
private EventCodeCompiler codeCompiler;
|
|
private string strClick, strContentChanged;
|
|
|
|
public ucDocumentGoodsBill(int tempId, int docId, PatientRecord patient)
|
|
{
|
|
InitializeComponent();
|
|
|
|
Patient = patient;
|
|
TModel.Id = tempId;
|
|
DModel.Id = docId;
|
|
DModel.TemplateId = tempId;
|
|
}
|
|
|
|
public ucDocumentGoodsBill(PrintDocument model, PatientRecord patient)
|
|
{
|
|
InitializeComponent();
|
|
|
|
Patient = patient;
|
|
DModel = model;
|
|
}
|
|
|
|
private void ucDocumentGoodsBill_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;
|
|
//文档事件
|
|
myEditControl.DocumentContentChanged += new WriterEventHandler(myEditControl_DocumentContentChanged);
|
|
myEditControl.AfterExecuteCommand += new DCSoft.Writer.Commands.WriterCommandEventHandler(myEditControl_AfterExecuteCommand);
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//无文档则加载模板
|
|
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;
|
|
//患者基本信息赋值
|
|
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();
|
|
}
|
|
}
|
|
|
|
if (Patient.LisResult != null && Patient.LisResult.PATIENT_ID != null)
|
|
{
|
|
DataRow[] drr = DocumentDAL.GetReflectionList("V_LisResult").Select("KB_SEQ <> ''");
|
|
var lis = typeof(PatientLisResult).GetProperties();
|
|
for (int i = 0; i < drr.Count(); i++)
|
|
{
|
|
var name = drr[i].ItemArray[0].ToString();
|
|
var value = drr[i].ItemArray[1].ToString();
|
|
XTextInputFieldElement element = query.Where(x => x.FieldSettings.ListSource.SourceName == value).FirstOrDefault();
|
|
PropertyInfo info = lis.Where(px => px.Name == name).FirstOrDefault();
|
|
if (element != null && info != null)
|
|
{
|
|
element.Text = info.GetValue(Patient.LisResult, null).ToString();
|
|
}
|
|
}
|
|
}
|
|
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 EventCodeCompiler(ref this.myEditControl, strClick, strContentChanged);
|
|
|
|
//文档用户信息
|
|
myEditControl.UserLoginByParameter(
|
|
AIMSExtension.PublicMethod.OperatorNo,
|
|
AIMSExtension.PublicMethod.OperatorName,
|
|
AIMSExtension.PublicMethod.PermissionLevel);
|
|
//隐藏痕迹先
|
|
myEditControl.ExecuteCommand(StandardCommandNames.CleanViewMode, false, true);
|
|
|
|
if (Patient.MedicalRecord != null && Patient.MedicalRecord != "")
|
|
{
|
|
tsbSave.Visible = false;
|
|
tsbSaveAndPrint.Text = "打印";
|
|
}
|
|
|
|
}
|
|
|
|
void myEditControl_AfterExecuteCommand(object eventSender, DCSoft.Writer.Commands.WriterCommandEventArgs args)
|
|
{
|
|
if (args.Name == "Undo" && !myEditControl.Document.Modified && ClearT != null)
|
|
{
|
|
ClearT();
|
|
}
|
|
}
|
|
|
|
void myEditControl_DocumentContentChanged(object eventSender, WriterEventArgs args)
|
|
{
|
|
if (myEditControl.Document.Modified && ModifyT != null)
|
|
{
|
|
ModifyT();
|
|
}
|
|
}
|
|
|
|
private void tsbSave_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SaveDocument();
|
|
}
|
|
catch (Exception exp)
|
|
{
|
|
MessageBox.Show(exp.Message, "提示");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关闭文档
|
|
/// </summary>
|
|
/// <param name="text">文档标题</param>
|
|
/// <param name="isCancel">是否取消关闭</param>
|
|
public void CloseMsg(string text, ref bool isCancel)
|
|
{
|
|
if (text.EndsWith("*"))
|
|
{
|
|
DialogResult result = MessageBox.Show("文档【"
|
|
+ DModel.XmlFileName +
|
|
"】已经修改,尚未保存,是否保存文件?", "系统提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question,
|
|
MessageBoxDefaultButton.Button1);
|
|
switch (result)
|
|
{
|
|
case DialogResult.Yes:
|
|
try
|
|
{
|
|
SaveDocument();
|
|
}
|
|
catch (Exception exp)
|
|
{
|
|
MessageBox.Show(exp.Message, "提示");
|
|
isCancel = true;
|
|
}
|
|
break;
|
|
case DialogResult.No:
|
|
break;
|
|
case DialogResult.Cancel:
|
|
isCancel = true;
|
|
return;
|
|
//break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存文档
|
|
/// </summary>
|
|
public void SaveDocument()
|
|
{
|
|
try
|
|
{
|
|
//输入域校验
|
|
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;
|
|
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.UpdatePrintDocument(this.DModel);
|
|
//MessageBox.Show("修改成功!");
|
|
}
|
|
else
|
|
{
|
|
DocumentDAL.InsertPrintDocument(this.DModel);
|
|
//new frmMessageBox().Show();
|
|
}
|
|
if (RefreshUc != null)
|
|
{
|
|
RefreshUc(this.Patient.PatientId);
|
|
}
|
|
if (ClearT != null)
|
|
{
|
|
ClearT();
|
|
}
|
|
myEditControl.Document.Modified = false;
|
|
////更新ASA分级与心功能分级
|
|
//if (DModel.XmlFileName == "麻醉术前访视单")
|
|
//{
|
|
// var asa = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
|
|
// && (x as XTextInputFieldElement).ToolTip == "ASA分级").FirstOrDefault();
|
|
// string strASA = asa == null ? "" : asa.Text;
|
|
// var hf = myEditControl.Document.Fields.ToArray().Where(x => x is XTextInputFieldElement
|
|
// && (x as XTextInputFieldElement).ToolTip == "心功能分级").FirstOrDefault();
|
|
// string strH = hf == null ? "" : hf.Text;
|
|
// BOperationApply.UpdateASA(Patient.ApplyId, strASA, strH);
|
|
//}
|
|
|
|
new frmMessageBox().Show();
|
|
}
|
|
catch
|
|
{
|
|
//MessageBox.Show(ex.Message, "错误");
|
|
throw;
|
|
}
|
|
}
|
|
|
|
public void tsbSaveAndPrint_Click(object sender, EventArgs e)
|
|
{
|
|
if (tsbCheckout.Text == " 隐藏痕迹")
|
|
{
|
|
tsbCheckout_Click(null, null);
|
|
}
|
|
if (tsbSaveAndPrint.Text == "打印")
|
|
{
|
|
myEditControl.ExecuteCommand("FilePrint", true, null);
|
|
}
|
|
else
|
|
{
|
|
tsbSave_Click(null, null);
|
|
myEditControl.ExecuteCommand("FilePrint", true, null);
|
|
}
|
|
}
|
|
|
|
private void tsbPreview_Click(object sender, EventArgs e)
|
|
{
|
|
if (tsbCheckout.Text == " 隐藏痕迹")
|
|
{
|
|
tsbCheckout_Click(null, null);
|
|
}
|
|
myEditControl.ExecuteCommand("FilePrintPreview", true, null);
|
|
}
|
|
|
|
private void tsbExit_Click(object sender, EventArgs e)
|
|
{
|
|
CloseP();
|
|
}
|
|
|
|
private void tsbCheckout_Click(object sender, EventArgs e)
|
|
{
|
|
if (tsbCheckout.Text == " 查看痕迹")
|
|
{
|
|
myEditControl.ExecuteCommand(StandardCommandNames.ComplexViewMode, false, true);
|
|
myEditControl.RefreshDocument();
|
|
tsbCheckout.Text = " 隐藏痕迹";
|
|
}
|
|
else
|
|
{
|
|
myEditControl.ExecuteCommand(StandardCommandNames.CleanViewMode, false, true);
|
|
myEditControl.RefreshDocument();
|
|
tsbCheckout.Text = " 查看痕迹";
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|