ShuJuZiDian.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using WWPipeLine.MapBasic.Conditions;
  11. using WeifenLuo.WinFormsUI.Docking;
  12. using WWPipeLine.MapBasic;
  13. using SuperMap.Data;
  14. using SuperMap.Mapping;
  15. using Sunny.UI;
  16. namespace WWPipeLine.MapTools.Conditions.XiTongGuanLi
  17. {
  18. public partial class ShuJuZiDian : ConditionPanel
  19. {
  20. Recordset rd = null;
  21. private int rdsmid = 0;
  22. public ShuJuZiDian()
  23. {
  24. this.ConditionPanelName = "数据字典维护";
  25. InitializeComponent();
  26. this.IsShowResultWindow = false;
  27. }
  28. protected override void OnLoad(EventArgs e)
  29. {
  30. ComsStatic.BindUICombox(uicbxLayer, true);
  31. }
  32. public override object Do(DockPanel dockPanel = null)
  33. {
  34. if (rdsmid == 0 || string.IsNullOrEmpty(uitb.Text)) { UIMessageTip.ShowError("请先选择需要操作的信息!"); return null; }
  35. if (rd.SeekID(rdsmid))
  36. {
  37. rd.Edit();
  38. rd.SetFieldValue("infos", uitb.Text);
  39. ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "数据字典配置更改");
  40. QueryParameter queryParameter = new QueryParameter
  41. {
  42. AttributeFilter = string.Format(" pzlx='数据字典' AND gxlx='{0}' ", (uicbxLayer.SelectedItem as DoListItem).Key),
  43. ResultFields = new string[] { "smid", "pzlx", "gxlx", "pzKey", "pzValue", "valueBefore", "infos" },
  44. OrderBy = new string[] { " smid asc " },
  45. CursorType = CursorType.Dynamic
  46. };
  47. rd = ComsStatic.dvConfig.Query(queryParameter);
  48. uidgv.DataSource = ComsStatic.RecordsetToDataTable(rd, false);
  49. }
  50. else
  51. {
  52. Sunny.UI.UIMessageTip.ShowError("信息在编辑选择时失败");
  53. }
  54. return null;
  55. }
  56. private void uicbxLayer_SelectedIndexChanged(object sender, EventArgs e)
  57. {
  58. DoListItem item = (DoListItem)uicbxLayer.SelectedItem;
  59. DatasetVector dv = ComsStatic.Datasource.Datasets[item.Key] as DatasetVector;
  60. QueryParameter queryParameter = new QueryParameter
  61. {
  62. AttributeFilter = string.Format(" pzlx='数据字典' AND gxlx='{0}' ", dv.Name),
  63. ResultFields = new string[] { "smid", "pzlx", "gxlx", "pzKey", "pzValue", "valueBefore", "infos" },
  64. OrderBy = new string[] { " smid asc " },
  65. CursorType = CursorType.Dynamic
  66. };
  67. rd = ComsStatic.dvConfig.Query(queryParameter);
  68. if (rd.RecordCount == 0)
  69. {
  70. FieldInfos infos = dv.GetRecordset(true, CursorType.Static).GetFieldInfos();
  71. foreach (FieldInfo info in infos)
  72. {
  73. if (ComsStatic.HideEnableTag.Contains("," + info.Name.ToLower() + ",") || info.IsSystemField) continue;
  74. rd.AddNew(new GeoPoint(0, 0));
  75. rd.SetFieldValue("pzlx", "数据字典");
  76. rd.SetFieldValue("gxlx", dv.Name);
  77. rd.SetFieldValue("pzKey", item.Value);
  78. rd.SetFieldValue("valueBefore", info.Name);
  79. rd.SetFieldValue("pzValue", info.Caption);
  80. rd.Update();
  81. }
  82. rd = ComsStatic.dvConfig.Query(queryParameter);
  83. }
  84. ComsStatic.setUIDataGridView(uidgv, ComsStatic.RecordsetToDataTable(rd, false), null, ",pzlx,gxlx,valueBefore,smid,");
  85. }
  86. private void uidgv_SelectIndexChange(object sender, int index)
  87. {
  88. if (uidgv.SelectedRows == null || uidgv.SelectedRows.Count != 1) return;
  89. rdsmid = ComsStatic.StringToInt(uidgv.SelectedRows[0].Cells["SmID"].Value);
  90. uitb.Text = uidgv.SelectedRows[0].Cells["infos"].Value?.ToString();
  91. }
  92. public override void AfterClose()
  93. {
  94. ComsStatic.RecordsetDispose(rd);
  95. base.AfterClose();
  96. }
  97. }
  98. }