BiaoZhuGuanWang.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. private UIRadioButton rBtn;
  23. public BiaoZhuGuanWang()
  24. {
  25. this.ConditionPanelName = "管网标注字段配置";
  26. InitializeComponent();
  27. this.SetSize(800, 485);
  28. this.IsShowResultWindow = false;
  29. }
  30. protected override void OnLoad(EventArgs e)
  31. {
  32. foreach (Layer lyr in ComsStatic.MapLayersUsed)
  33. {
  34. UIRadioButton rBtn = new UIRadioButton()
  35. {
  36. Name = lyr.Name,
  37. Text = lyr.Caption,
  38. Tag = lyr.Dataset,
  39. Location = new Point(10, 35 + uigbLayer.Controls.Count * 28),
  40. Width = 120
  41. };
  42. rBtn.CheckedChanged += RBtn_CheckedChanged;
  43. uigbLayer.Controls.Add(rBtn);
  44. }
  45. }
  46. private void RBtn_CheckedChanged(object sender, EventArgs e)
  47. {
  48. rBtn = sender as UIRadioButton;
  49. if (!rBtn.Checked) return;
  50. DatasetVector dv = rBtn.Tag as DatasetVector;
  51. QueryParameter queryParameter = new QueryParameter
  52. {
  53. AttributeFilter = string.Format(" pzlx='标注字段配置' AND gxlx='{0}' ", dv.Name),
  54. ResultFields = new string[] { "smid", "gxlx", "pzlx", "pzKey", "pzValue", "valueBefore", "valueAfter", "valueSort", "valueEnable" },
  55. OrderBy = new string[] { " valueSort asc " },
  56. CursorType = CursorType.Dynamic
  57. };
  58. rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
  59. if (rd.RecordCount == 0)
  60. {
  61. FieldInfos infos = dv.GetRecordset(true, CursorType.Static).GetFieldInfos();
  62. string allTag = ",x,y,fsw,xh,gg,cz,kj,gj,yl,ms,cd,name,address,".ToLower();
  63. foreach (FieldInfo info in infos)
  64. {
  65. if (!allTag.Contains("," + info.Name.ToLower() + ",") || info.IsSystemField) continue;
  66. rd.AddNew(new GeoPoint(0, 0));
  67. rd.SetFieldValue("pzlx", "标注字段配置");
  68. rd.SetFieldValue("gxlx", dv.Name);
  69. rd.SetFieldValue("pzKey", info.Name);
  70. rd.SetFieldValue("pzValue", info.Caption);
  71. rd.SetFieldValue("valueEnable", 0);
  72. rd.Update();
  73. }
  74. rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
  75. }
  76. ComsStatic.setUIDataGridView(uidgvPeiZhi, ComsStatic.RecordsetToDataTable(rd), null, "pzlx,gxlx,pzKey");
  77. uidgvPeiZhi.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  78. }
  79. public override object Do(DockPanel dockPanel = null)
  80. {
  81. if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要操作的信息!"); return null; }
  82. if (rd.SeekID(_rdsmid))
  83. {
  84. rd.Edit();
  85. rd.SetFieldValue("valueBefore", uitbBefore.Text);
  86. rd.SetFieldValue("valueAfter", uitbAfter.Text);
  87. rd.SetFieldValue("valueSort", ComsStatic.StringToInt(uitbSort.Text));
  88. rd.SetFieldValue("valueEnable", uicbBiaoZhu.Checked ? 1 : 0);
  89. ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "标注字段配置更改");
  90. }
  91. else
  92. {
  93. Sunny.UI.UIMessageTip.ShowError("信息在编辑选择时失败!");
  94. }
  95. rBtn.Checked = true; uicbBiaoZhu.Checked = false; uitbSort.Text = ""; uitbAfter.Text = ""; uitbBefore.Text = ""; uitbZiduan.Text = "";
  96. return null;
  97. }
  98. private void uidgvPeiZhi_SelectIndexChange(object sender, int index)
  99. {
  100. //var selectRows = (sender as UIDataGridView).SelectedRows;
  101. if (uidgvPeiZhi.SelectedRows == null || uidgvPeiZhi.SelectedRows.Count != 1) return;
  102. _rdsmid = ComsStatic.StringToInt(uidgvPeiZhi.SelectedRows[0].Cells["SmID"].Value);
  103. if (_rdsmid != 0 && rd.SeekID(_rdsmid))
  104. {
  105. uitbZiduan.Text = rd.GetFieldValue("pzValue")?.ToString();
  106. uitbBefore.Text = rd.GetFieldValue("valueBefore")?.ToString();
  107. uitbAfter.Text = rd.GetFieldValue("valueAfter")?.ToString();
  108. uitbSort.Text = rd.GetFieldValue("valueSort")?.ToString();
  109. uicbBiaoZhu.Checked = ComsStatic.StringToInt(rd.GetFieldValue("valueEnable")) == 0 ? false : true;
  110. }
  111. else
  112. { Sunny.UI.UIMessageTip.ShowError("信息错误!"); }
  113. }
  114. private void uidgvPeiZhi_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
  115. {
  116. for (int i = 0; i < uidgvPeiZhi.Rows.Count; i++)
  117. {
  118. if (uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value.ToString() == "0")
  119. uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value = "";
  120. if (uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value.ToString() == "1")
  121. uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value = "标注";
  122. }
  123. }
  124. private void uitbSort_KeyPress(object sender, KeyPressEventArgs e)
  125. {
  126. if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar < 96 || e.KeyChar > 105) && (e.KeyChar != 8))
  127. e.Handled = true;
  128. }
  129. }
  130. }