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) { //检索字典数据 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"; break; case "OperationRecord.OperationDoctor": PersonType = "0"; 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; } 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); } 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 = ""; 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 namevalue = new List(); List idvalue = new List(); 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); 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 namevalue = new List(); 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 namevalue = new List(); List idvalue = new List(); List tagvalue = new List(); 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); } } } }