BJroad.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 SuperMap.Data;
  12. using Sunny.UI;
  13. using WWPipeLine.MapBasic;
  14. using WeifenLuo.WinFormsUI.Docking;
  15. using SuperMap.UI;
  16. namespace WWPipeLine.MapTools.Conditions.FuZhuGongJu
  17. {
  18. public partial class BJroad : ConditionPanel
  19. {
  20. GeoRegion m_geo = null;
  21. Recordset rd;
  22. private int _rdsmid = 0;
  23. public BJroad()
  24. {
  25. this.ConditionPanelName = "交通道路信息管理";
  26. InitializeComponent();
  27. this.IsShowPanelFooter = false;
  28. }
  29. protected override void OnLoad(EventArgs e)
  30. {
  31. DatasetVector dv = ComsStatic.Datasource.Datasets["ROADPY"] as DatasetVector;
  32. if (dv == null)
  33. {
  34. Sunny.UI.UIMessageTip.ShowError("当前数据源中不包含相应的矢量数据集"); return;
  35. }
  36. rd = ComsStatic.QueryRecordsetDynamic(dv, "");
  37. ComsStatic.setUIDataGridView(uidgvTable, ComsStatic.RecordsetToDataTable(rd));
  38. MapControl.TrackMode = TrackMode.Track;
  39. MapControl.Action = SuperMap.UI.Action.CreatePolygon;
  40. MapControl.Tracked += new TrackedEventHandler(TrackedHandler);
  41. }
  42. private void uiButtonAdd_Click(object sender, EventArgs e)
  43. {
  44. if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制交通道路区域"); return; }
  45. if (string.IsNullOrEmpty(uitbName.Text)) { Sunny.UI.UIMessageTip.ShowError("请先输入交通道路名称"); return; }
  46. rd.AddNew(m_geo);
  47. rd.SetFieldValue("name", uitbName.Text);
  48. rd.SetFieldValue("shape_length", ComsStatic.StringToDouble(m_geo.Perimeter));
  49. rd.SetFieldValue("shape_area", ComsStatic.StringToDouble(m_geo.Area));
  50. ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "交通道路新增");
  51. uitbName.Text = ""; MapControl.Map.TrackingLayer.Clear(); MapControl.Map.Refresh();
  52. OnLoad(e);
  53. }
  54. private void uiButtonUpdate_Click(object sender, EventArgs e)
  55. {
  56. if (string.IsNullOrEmpty(uitbName.Text)) { Sunny.UI.UIMessageTip.ShowError("请先输入行政区域名称"); return; }
  57. if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要编辑的信息!"); return; }
  58. if (rd.SeekID(_rdsmid))
  59. {
  60. rd.Edit();
  61. rd.SetFieldValue("name", uitbName.Text);
  62. ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "交通道路编辑");
  63. uitbName.Text = "";
  64. OnLoad(e);
  65. }
  66. else
  67. { Sunny.UI.UIMessageTip.ShowError("信息在编辑选择时失败!"); }
  68. }
  69. private void uiButtonDel_Click(object sender, EventArgs e)
  70. {
  71. if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要删除的信息!"); return; }
  72. if (rd.SeekID(_rdsmid))
  73. {
  74. ComsStatic.ShowUIMessageTipOKorError(rd.Delete(), "交通道路删除");
  75. uitbName.Text = "";
  76. OnLoad(e);
  77. }
  78. else
  79. { Sunny.UI.UIMessageTip.ShowError("信息在删除选择时失败!"); }
  80. }
  81. private void TrackedHandler(object sender, TrackedEventArgs e)
  82. {
  83. if (e.Geometry is null) return;
  84. m_geo = e.Geometry.Clone() as GeoRegion;
  85. if (m_geo is null) { Sunny.UI.UIMessageTip.ShowError("区域绘制失败"); return; }
  86. m_geo.Style = ComsStatic.geoStyle_Red_1mm_OpaqueRate;
  87. MapControl.Map.TrackingLayer.Clear();
  88. MapControl.Map.TrackingLayer.Add(m_geo, "GeoRegion");
  89. MapControl.Map.Refresh();
  90. }
  91. private void uiDataGridViewtb_SelectIndexChange(object sender, int index)
  92. {
  93. DataGridViewRow dr = uidgvTable.Rows[index];
  94. _rdsmid = ComsStatic.StringToInt(dr.Cells["SmID"].Value.ToString());
  95. uitbName.Text = dr.Cells["name"].Value?.ToString();
  96. }
  97. public override void AfterClose()
  98. {
  99. ComsStatic.RecordsetDispose(rd);
  100. MapControl.Tracked -= new TrackedEventHandler(TrackedHandler);
  101. base.AfterClose();
  102. }
  103. }
  104. }