ShuJuZiDian.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.SetSize(600, 585);
  27. this.IsShowResultWindow = false;
  28. }
  29. protected override void OnLoad(EventArgs e)
  30. {
  31. foreach (Layer lyr in ComsStatic.MapLayersUsed)
  32. {
  33. uilbLayers.Items.Add(new DoListItem(lyr.Dataset.Name, lyr.Caption));
  34. }
  35. uilbLayers.SelectedIndex = 0;
  36. }
  37. public override object Do(DockPanel dockPanel = null)
  38. {
  39. if (rdsmid == 0 || string.IsNullOrEmpty(uitb.Text)) { UIMessageTip.ShowError("请先选择需要操作的信息!"); return null; }
  40. if (rd.SeekID(rdsmid))
  41. {
  42. rd.Edit();
  43. rd.SetFieldValue("infos", uitb.Text);
  44. ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "数据字典配置更改");
  45. }
  46. else
  47. {
  48. Sunny.UI.UIMessageTip.ShowError("信息在编辑选择时失败");
  49. }
  50. uilbLayers.SelectedIndex = 0;
  51. return null;
  52. }
  53. private void uilbLayers_SelectedIndexChanged(object sender, EventArgs e)
  54. {
  55. string itemKey = (uilbLayers.SelectedItem as DoListItem).Key;
  56. string itemValue = (uilbLayers.SelectedItem as DoListItem).Value;
  57. QueryParameter queryParameter = new QueryParameter
  58. {
  59. AttributeFilter = string.Format(" pzlx='数据字典' AND gxlx='{0}' ", itemKey),
  60. ResultFields = new string[] { "smid", "pzlx", "gxlx", "pzKey", "pzValue", "infos" },
  61. OrderBy = new string[] { " smid asc " },
  62. CursorType = CursorType.Dynamic
  63. };
  64. rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
  65. if (rd.RecordCount == 0)
  66. {
  67. DatasetVector dv = ComsStatic.Datasource.Datasets[itemKey] as DatasetVector;
  68. FieldInfos infos = dv.GetRecordset(true, CursorType.Static).GetFieldInfos();
  69. foreach (FieldInfo info in infos)
  70. {
  71. if (ComsStatic.HideEnableTag.Contains("," + info.Name.ToLower() + ",") || info.IsSystemField) continue;
  72. rd.AddNew(new GeoPoint(0, 0));
  73. rd.SetFieldValue("pzlx", "数据字典");
  74. rd.SetFieldValue("gxlx", dv.Name);
  75. rd.SetFieldValue("pzKey", itemValue);
  76. rd.SetFieldValue("pzValue", info.Caption);
  77. rd.Update();
  78. }
  79. rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
  80. }
  81. ComsStatic.setUIDataGridView(uidgv, ComsStatic.RecordsetToDataTable(rd), null, "pzlx,gxlx");
  82. }
  83. private void uidgv_SelectIndexChange(object sender, int index)
  84. {
  85. if (uidgv.SelectedRows == null || uidgv.SelectedRows.Count != 1) return;
  86. rdsmid = ComsStatic.StringToInt(uidgv.SelectedRows[0].Cells["SmID"].Value);
  87. uitb.Text = uidgv.SelectedRows[0].Cells["infos"].Value?.ToString();
  88. }
  89. public override void AfterClose()
  90. {
  91. ComsStatic.RecordsetDispose(rd);
  92. base.AfterClose();
  93. }
  94. }
  95. }