GDshuliangQY.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using SuperMap.Data;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using WeifenLuo.WinFormsUI.Docking;
  6. using WWPipeLine.MapBasic.Conditions;
  7. using WWPipeLine.MapBasic;
  8. using SuperMap.Mapping;
  9. using SuperMap.UI;
  10. using System.Drawing;
  11. namespace WWPipeLine.MapTools.Conditions.Statistics
  12. {
  13. public partial class GDshuliangQY : ConditionPanel
  14. {
  15. private LayerWithDataListPanel LayerPanel;
  16. GeoRegion m_geo = null;
  17. public GDshuliangQY() : base()
  18. {
  19. this.ConditionPanelName = "区域管点数量统计";
  20. InitializeComponent();
  21. }
  22. protected override void OnLoad(EventArgs e)
  23. {
  24. LayerPanel = new LayerWithDataListPanel();
  25. LayerPanel.LoadToVector(true, false);
  26. this.Controls.Add(LayerPanel);
  27. int index = MapControl.Map.TrackingLayer.IndexOf("ControlToolAddGeoRegion");
  28. if (index == -1)
  29. {
  30. Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域");
  31. this.FindForm().Close(); return;
  32. }
  33. m_geo = MapControl.Map.TrackingLayer.Get(index) as GeoRegion;
  34. if (m_geo is null || m_geo.PartCount != 1)
  35. {
  36. ComsStatic.ShowErrorLog("绘制区域PartCount参数发生错误");
  37. this.FindForm().Close(); return;
  38. }
  39. }
  40. public override object Do(DockPanel dockPanel = null)
  41. {
  42. if (m_geo is null)
  43. {
  44. Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域"); return false;
  45. }
  46. if (LayerPanel.SelectLayers.Count == 0)
  47. {
  48. Sunny.UI.UIMessageTip.ShowError("请先选择需要查询的图层"); return false;
  49. }
  50. DataTable dt = new DataTable() { TableName = "管点数量统计结果" };
  51. DataRow dr;
  52. dt.Columns.Add("统计图层");
  53. foreach (Layer lyr in LayerPanel.SelectLayers)
  54. {
  55. dt.Columns.Add(lyr.Caption);
  56. }
  57. dr = dt.NewRow(); dr["统计图层"] = "管点数量";
  58. DatasetVector dv;
  59. Recordset rd = null;
  60. foreach (Layer lyr in LayerPanel.SelectLayers)
  61. {
  62. dv = lyr.Dataset as DatasetVector;
  63. rd = dv.Query(m_geo, 1, "1=1", CursorType.Static);
  64. dr[lyr.Caption] = rd.RecordCount;
  65. }
  66. dt.Rows.Add(dr);
  67. ComsStatic.RecordsetDispose(rd);
  68. return dt;
  69. }
  70. }
  71. }