BiaoZhuGuanWang.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 Sunny.UI;
  13. using SuperMap.Mapping;
  14. using WWPipeLine.MapBasic;
  15. using SuperMap.Data;
  16. namespace WWPipeLine.MapTools.Conditions.XiTongGuanLi
  17. {
  18. public partial class BiaoZhuGuanWang : ConditionPanel
  19. {
  20. Recordset rd = null;
  21. private int _rdsmid = 0;
  22. public BiaoZhuGuanWang()
  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. private void uicbxLayer_SelectedIndexChanged(object sender, EventArgs e)
  33. {
  34. DoListItem item = (DoListItem)uicbxLayer.SelectedItem;
  35. DatasetVector dv = ComsStatic.Datasource.Datasets[item.Key] as DatasetVector;
  36. QueryParameter queryParameter = new QueryParameter
  37. {
  38. AttributeFilter = string.Format(" pzlx='标注字段配置' AND gxlx='{0}' ", dv.Name),
  39. ResultFields = new string[] { "smid", "gxlx", "pzlx", "pzKey", "pzValue", "valueBefore", "valueAfter", "valueSort", "valueEnable" },
  40. OrderBy = new string[] { " valueSort asc " },
  41. CursorType = CursorType.Dynamic
  42. };
  43. rd = ComsStatic.dvConfig.Query(queryParameter);
  44. if (rd.RecordCount == 0)
  45. {
  46. FieldInfos infos = dv.GetRecordset(true, CursorType.Static).GetFieldInfos();
  47. string allTag = ",x,y,fsw,xh,gg,cz,kj,gj,yl,ms,cd,name,address,".ToLower();
  48. foreach (FieldInfo info in infos)
  49. {
  50. if (!allTag.Contains("," + info.Name.ToLower() + ",") || info.IsSystemField) continue;
  51. rd.AddNew(new GeoPoint(0, 0));
  52. rd.SetFieldValue("pzlx", "标注字段配置");
  53. rd.SetFieldValue("gxlx", dv.Name);
  54. rd.SetFieldValue("pzKey", info.Name);
  55. rd.SetFieldValue("pzValue", info.Caption);
  56. rd.SetFieldValue("valueEnable", 0);
  57. rd.Update();
  58. }
  59. rd = ComsStatic.dvConfig.Query(queryParameter);
  60. }
  61. ComsStatic.setUIDataGridView(uidgvPeiZhi, ComsStatic.RecordsetToDataTable(rd, false), null, ",pzlx,gxlx,pzKey,smid,");
  62. uidgvPeiZhi.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  63. }
  64. public override object Do(DockPanel dockPanel = null)
  65. {
  66. if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要操作的信息!"); return null; }
  67. if (rd.SeekID(_rdsmid))
  68. {
  69. rd.Edit();
  70. rd.SetFieldValue("valueBefore", uitbBefore.Text);
  71. rd.SetFieldValue("valueAfter", uitbAfter.Text);
  72. rd.SetFieldValue("valueSort", ComsStatic.StringToInt(uitbSort.Text));
  73. rd.SetFieldValue("valueEnable", uicbBiaoZhu.Checked ? 1 : 0);
  74. ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "标注字段配置更改");
  75. }
  76. else
  77. {
  78. Sunny.UI.UIMessageTip.ShowError("信息在编辑选择时失败!");
  79. }
  80. uicbBiaoZhu.Checked = false; uitbSort.Text = ""; uitbAfter.Text = ""; uitbBefore.Text = ""; uitbZiduan.Text = "";
  81. QueryParameter queryParameter = new QueryParameter
  82. {
  83. AttributeFilter = string.Format(" pzlx='标注字段配置' AND gxlx='{0}' ", (uicbxLayer.SelectedItem as DoListItem).Key),
  84. ResultFields = new string[] { "smid", "gxlx", "pzlx", "pzKey", "pzValue", "valueBefore", "valueAfter", "valueSort", "valueEnable" },
  85. OrderBy = new string[] { " valueSort desc " },
  86. CursorType = CursorType.Dynamic
  87. };
  88. rd = ComsStatic.dvConfig.Query(queryParameter);
  89. uidgvPeiZhi.DataSource = ComsStatic.RecordsetToDataTable(rd, false);
  90. return null;
  91. }
  92. private void uidgvPeiZhi_SelectIndexChange(object sender, int index)
  93. {
  94. if (uidgvPeiZhi.SelectedRows == null || uidgvPeiZhi.SelectedRows.Count != 1) return;
  95. _rdsmid = ComsStatic.StringToInt(uidgvPeiZhi.SelectedRows[0].Cells["SmID"].Value);
  96. if (_rdsmid != 0 && rd.SeekID(_rdsmid))
  97. {
  98. uitbZiduan.Text = rd.GetFieldValue("pzValue")?.ToString();
  99. uitbBefore.Text = rd.GetFieldValue("valueBefore")?.ToString();
  100. uitbAfter.Text = rd.GetFieldValue("valueAfter")?.ToString();
  101. uitbSort.Text = rd.GetFieldValue("valueSort")?.ToString();
  102. uicbBiaoZhu.Checked = ComsStatic.StringToInt(rd.GetFieldValue("valueEnable")) == 0 ? false : true;
  103. }
  104. else
  105. { Sunny.UI.UIMessageTip.ShowError("信息错误!"); }
  106. }
  107. private void uidgvPeiZhi_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
  108. {
  109. for (int i = 0; i < uidgvPeiZhi.Rows.Count; i++)
  110. {
  111. if (uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value.ToString() == "0")
  112. uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value = "";
  113. if (uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value.ToString() == "1")
  114. uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value = "标注";
  115. }
  116. }
  117. }
  118. }