AIMS/DrawGraph/AreaManage/TokenEditorManage.cs

220 lines
8.8 KiB
C#

using AIMSExtension;
using DevComponents.DotNetBar.Controls;
using HelperDB;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
namespace DrawGraph
{
public static class TokenEditorManage
{
public static void SelectDictList(OperationRecord OpeRecord, TextBox txt, bool IsSearch = true)
{
//检索字典数据
DevComponents.DotNetBar.Controls.TokenEditor tokenEditor = txt.Parent as DevComponents.DotNetBar.Controls.TokenEditor;
AbleEditPackObj aEdit = tokenEditor.Tag as AbleEditPackObj;
string PersonType = "";
switch (aEdit.ClassDataSourceName)
{
case "OperationRecord.AnesthesiaDoctor": //麻醉医生
PersonType = "2";
tokenEditor.DropDownHeight = 120;
break;
case "OperationRecord.OperationDoctor":
tokenEditor.DropDownHeight = 200;
PersonType = "0";
break;
case "OperationRecord.InstrumentNurse":
tokenEditor.DropDownHeight = 250;
PersonType = "3";
break;
case "OperationRecord.Assistant1":
tokenEditor.DropDownHeight = 200;
PersonType = "0";
break;
case "OperationRecord.TourNurse":
tokenEditor.DropDownHeight = 250;
PersonType = "3";
break;
case "OperationRecord.OrtherDoctorId":
tokenEditor.DropDownHeight = 120;
PersonType = "4";
break;
case "OperationRecord.Applydiagnose": //手术诊断
tokenEditor.DropDownHeight = 340;
break;
case "OperationRecord.Applyoperation": //手术诊断
tokenEditor.DropDownHeight = 340;
break;
case "OperationRecord.Operation": //手术诊断
tokenEditor.DropDownHeight = 340;
break;
default:
tokenEditor.DropDownHeight = 200;
break;
}
DataTable dt = DBManage.GetDictDataTable(OpeRecord, txt.Text, aEdit.ControlTitleText, PersonType, (IsSearch == true ? aEdit.PackValue : ""));
tokenEditor.Tokens.Clear();
foreach (DataRow item in dt.Rows)
{
DevComponents.DotNetBar.Controls.EditToken edit = new DevComponents.DotNetBar.Controls.EditToken(item["Id"].ToString(), item["Name"].ToString());
tokenEditor.Tokens.Add(edit);
}
if (tokenEditor.IsPopupOpen == false)
tokenEditor.IsPopupOpen = true;
}
public static string GetOperationItemId(string name, AbleEditPackObj aEdit)
{
string Id = "";
if (aEdit.ControlTitleText == "手术")
{
string sql = string.Format("select Id from Operation where Name = '{0}'", name);
object dt = DBHelper.ExecuteScalar(sql);
if (dt != null) { Id = dt.ToString(); }
if (Id == null || Id == "")
{
string sql2 = string.Format("insert into Operation values('{0}','{1}','{2}',0,1,'admin','系統管理員',getdate(),'{3}');select @@identity ", "", name, PublicMethod.GetFirstLetter(name), "");
Id = DBHelper.ExecuteScalar(sql2).ToString();
}
}
else if (aEdit.ControlTitleText == "诊断")
{
string sql = string.Format("select Id from Disease where Name = '{0}'", name);
object dt = DBHelper.ExecuteScalar(sql);
if (dt != null) { Id = dt.ToString(); }
if (Id == null || Id == "")
{
string sql2 = string.Format("insert into Disease values('{0}','{1}','{2}',0,1,'admin','系統管理員',getdate());select @@identity ", "", name, PublicMethod.GetFirstLetter(name));
Id = DBHelper.ExecuteScalar(sql2).ToString();
}
}
return Id;
}
public static string GetWorkerTags(string text, string value)
{
string result = "";
string sql = string.Format("select Name from Person where Id = '{0}'", value);
object dt = DBHelper.ExecuteScalar(sql);
if (dt != null)
{
string name = dt.ToString();
result = text.Replace(name, "");
}
return result;
}
public static void SaveDictItem(TemplateManage _template, OperationRecord OpeRecord, TokenEditor tokenEditor, AbleEditPackObj aEdit, bool IsVisible = false)
{
string SplitChar = ",";
if (aEdit.ClassDataSourceName == "OperationRecord.AnaesthesiaMethodName")
{
SplitChar = "+";
}
string Value = "";
string Key = "";
List<string> namevalue = new List<string>();
List<string> idvalue = new List<string>();
foreach (var item in tokenEditor.SelectedTokens)
{
namevalue.Add(item.Text);
idvalue.Add(item.Value);
}
if (idvalue.Count > 0)
{
Value = string.Join(SplitChar, namevalue);
Key = string.Join(SplitChar, idvalue);
}
else
{
Value = "";
Key = "";
}
if (IsVisible == true)
aEdit.IsVisible = !aEdit.IsVisible;
if (aEdit.PackValue != Value)
//设置属性的值
_template.SetObjValue(OpeRecord, aEdit.ClassDataSourceName, Value, Key, true);
}
public static void SaveDictItemText(TemplateManage _template, OperationRecord OpeRecord, TokenEditor tokenEditor, AbleEditPackObj aEdit, bool IsVisible = false)
{
string SplitChar = ",";
if (aEdit.ClassDataSourceName == "OperationRecord.AnaesthesiaMethodName")
{
SplitChar = "+";
}
string Value = "";
List<string> namevalue = new List<string>();
foreach (var item in tokenEditor.SelectedTokens)
{
namevalue.Add(item.Text);
}
if (namevalue.Count > 0)
{
Value = string.Join(SplitChar, namevalue);
}
else
{
Value = "";
}
if (IsVisible == true)
aEdit.IsVisible = !aEdit.IsVisible;
if (aEdit.PackValue != Value)
//设置属性的值
_template.SetObjValue(OpeRecord, aEdit.ClassDataSourceName, Value, Value, true);
}
public static void SaveDictItem2(TemplateManage _template, OperationRecord OpeRecord, TokenEditor tokenEditor, AbleEditPackObj aEdit, bool IsVisible = false)
{
string SplitChar = ",";
if (aEdit.ClassDataSourceName == "OperationRecord.AnaesthesiaMethodName")
{
SplitChar = "+";
}
string Value = "";
string Key = "";
string Tag = "";
List<string> namevalue = new List<string>();
List<string> idvalue = new List<string>();
List<string> tagvalue = new List<string>();
foreach (var item in tokenEditor.SelectedTokens)
{
namevalue.Add(item.Text);
idvalue.Add(item.Value);
tagvalue.Add(GetWorkerTags(item.Text,item.Value));
}
if (idvalue.Count > 0)
{
Value = string.Join(SplitChar, namevalue);
Key = string.Join(SplitChar, idvalue);
Tag = string.Join("|", tagvalue);
}
else
{
Value = "";
Key = "";
Tag = "";
}
if (IsVisible == true)
aEdit.IsVisible = !aEdit.IsVisible;
if (aEdit.PackValue != Value)
//设置属性的值
_template.SetObjValue(OpeRecord, aEdit.ClassDataSourceName, Value, Key, true);
if (aEdit.ClassDataSourceName == "OperationRecord.OperationDoctor")
{
_template.SetObjValue(OpeRecord, "OperationRecord.OpeRecordInfo.Extend4", Tag, Tag, true);
}
else if (aEdit.ClassDataSourceName == "OperationRecord.AnesthesiaDoctor")
{
_template.SetObjValue(OpeRecord, "OperationRecord.OpeRecordInfo.Extend5", Tag, Tag, true);
}
}
}
}