AIMS/DrawGraph/AreaManage/TokenEditorManage.cs
2023-06-05 11:17:09 +08:00

391 lines
15 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using AIMSExtension;
using DevComponents.DotNetBar.Controls;
using HelperDB;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
using static System.Net.Mime.MediaTypeNames;
namespace DrawGraph
{
public static class TokenEditorManage
{
public static void SelectDictList(OperationRecord OpeRecord, TextBox txt, bool IsSearch = true)
{
//检索字典数据
try
{
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";
IsSearch = false;
break;
case "OperationRecord.OperationDoctor":
PersonType = "0";
IsSearch = false;
break;
case "OperationRecord.InstrumentNurse":
PersonType = "3";
break;
case "OperationRecord.Assistant1":
PersonType = "0";
break;
case "OperationRecord.TourNurse":
PersonType = "3";
break;
case "OperationRecord.OrtherDoctorId":
PersonType = "4";
break;
case "OperationRecord.AnaesthesiaMethodName":
IsSearch = false;
break;
}
DataTable dt = DBManage.GetDictDataTable(OpeRecord, txt.Text, aEdit.ControlTitleText, PersonType, (IsSearch == true ? aEdit.PackValue : ""));
tokenEditor.Tokens.Clear();
//for (int i = tokenEditor.Tokens.Count - 1; i >= 0; i--)
//{
// tokenEditor.Tokens.Remove(tokenEditor.Tokens[i]);
//}
//DevComponents.DotNetBar.Controls.EditToken edit1 = new DevComponents.DotNetBar.Controls.EditToken("", "无");
//tokenEditor.Tokens.Add(edit1);
tokenEditor.IsPopupOpen = false; //弹出下拉框
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);
}
switch (aEdit.ClassDataSourceName)
{
case "OperationRecord.AnesthesiaDoctor": //麻醉医生
case "OperationRecord.OperationDoctor":
case "OperationRecord.InstrumentNurse":
case "OperationRecord.Assistant1":
case "OperationRecord.TourNurse":
case "OperationRecord.OrtherDoctorId":
tokenEditor.DropDownHeight = dt.Rows.Count * 23;
break;
case "OperationRecord.Applydiagnose": //手术诊断
case "OperationRecord.Applyoperation": //手术诊断
case "OperationRecord.Operation": //手术诊断
case "OperationRecord.Diagnose": //手术诊断
tokenEditor.DropDownHeight = 340;
break;
default:
tokenEditor.DropDownHeight = 250;
break;
}
//if (tokenEditor.IsPopupOpen == false)
tokenEditor.IsPopupOpen = true; //弹出下拉框
}
catch (System.Exception ex)
{
PublicMethod.WriteLog(ex);
}
}
public static string GetOperationItemId(string namestr, AbleEditPackObj aEdit)
{
string Id = "";
string Name = namestr.Replace("\n", "").Replace("\t", "");
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 = "";
try
{
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, "");//.Replace(",", "")
}
}
catch (System.Exception)
{
result = "";
}
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)
{
if (item.Text == "") break;
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;
TokenEditorManage.SetAutoSizeRowSpan(_template, aEdit, Value);
if (aEdit.PackValue != Value)
//设置属性的值
_template.SetObjValue(OpeRecord, aEdit.ClassDataSourceName, Value, Key, true);
if (aEdit.ClassDataSourceName == "OperationRecord.Applydiagnose")
{
_template.SetObjValue(OpeRecord, "OperationRecord.Diagnose", 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 (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);
}
if (IsVisible == true)
aEdit.IsVisible = !aEdit.IsVisible;
if (aEdit.PackValue != Value)
//设置属性的值
_template.SetObjValue(OpeRecord, aEdit.ClassDataSourceName, Value, Key, true);
}
public static void SetAutoSizeRowSpan(TemplateManage template, AbleEditPackObj ableEdit, string text)
{
if (template.ProjectName == "麻醉记录单" && PublicMethod.HospitalName.Contains("天福"))
{
if (ableEdit.ClassDataSourceName == "OperationRecord.Applydiagnose")
{
ableEdit.FontSize = 9f;
if (text.Length > 57)
{
ableEdit.FontSize = 8f;
ableEdit.Y = 0.055f;
}
if (text.Length > 64)
{
ableEdit.FontSize = 7f;
ableEdit.Y = 0.055f;
}
if (text.Length > 73)
{
ableEdit.FontSize = 7f;
ableEdit.Y = 0.051f;
ableEdit.RowSpan = 0.008f;
}
}
else if (ableEdit.ClassDataSourceName == "OperationRecord.Applyoperation")
{
ableEdit.FontSize = 9f;
if (text.Length > 57)
{
ableEdit.FontSize = 8f;
ableEdit.Y = 0.073f;
}
if (text.Length > 64)
{
ableEdit.FontSize = 7f;
ableEdit.Y = 0.073f;
}
if (text.Length > 73)
{
ableEdit.FontSize = 7f;
ableEdit.Y = 0.069f;
ableEdit.RowSpan = 0.008f;
}
}
else if (ableEdit.ClassDataSourceName == "OperationRecord.Diagnose")
{
ableEdit.FontSize = 9f;
if (text.Length > 57)
{
ableEdit.FontSize = 8f;
ableEdit.Y = -0.031f;
}
if (text.Length > 64)
{
ableEdit.FontSize = 7f;
ableEdit.Y = -0.031f;
}
if (text.Length > 73)
{
ableEdit.FontSize = 7f;
ableEdit.Y = -0.035f;
ableEdit.RowSpan = 0.008f;
}
}
else if (ableEdit.ClassDataSourceName == "OperationRecord.Operation")
{
ableEdit.FontSize = 9f;
if (text.Length > 43)
{
ableEdit.FontSize = 8f;
ableEdit.Y = -0.0109f;
}
if (text.Length > 48)
{
ableEdit.FontSize = 7f;
ableEdit.Y = -0.0109f;
}
if (text.Length > 63)
{
ableEdit.FontSize = 7f;
ableEdit.Y = -0.015f;
ableEdit.RowSpan = 0.008f;
}
}
}
else if (template.ProjectName == "恢复记录单" && PublicMethod.HospitalName.Contains("天福"))
{
if (ableEdit.ClassDataSourceName == "OperationRecord.Diagnose")
{
ableEdit.FontSize = 9f;
if (text.Length > 57)
{
ableEdit.FontSize = 8f;
ableEdit.Y = 0.041f;
}
if (text.Length > 64)
{
ableEdit.FontSize = 7f;
ableEdit.Y = 0.041f;
}
if (text.Length > 73)
{
ableEdit.FontSize = 7f;
ableEdit.Y = 0.037f;
ableEdit.RowSpan = 0.008f;
}
}
else if (ableEdit.ClassDataSourceName == "OperationRecord.Operation")
{
ableEdit.FontSize = 9f;
if (text.Length > 43)
{
ableEdit.FontSize = 8f;
ableEdit.Y = 0.062f;
}
if (text.Length > 48)
{
ableEdit.FontSize = 7f;
ableEdit.Y = 0.062f;
}
if (text.Length > 63)
{
ableEdit.FontSize = 7f;
ableEdit.Y = 0.058f;
ableEdit.RowSpan = 0.008f;
}
}
}
}
}
}