GDshuliangQYbak.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 GDshuliangQYbak : ConditionPanel
  14. {
  15. private LayerWithDataListPanel LayerPanel;
  16. GeoRegion m_geo = null;
  17. public GDshuliangQYbak() : base()
  18. {
  19. this.ConditionPanelName = "区域管点数量统计";
  20. this.SetSize(300, 400);
  21. InitializeComponent();
  22. }
  23. protected override void OnLoad(EventArgs e)
  24. {
  25. LayerPanel = new LayerWithDataListPanel();
  26. LayerPanel.LoadToVector(true, false);
  27. this.Controls.Add(LayerPanel);
  28. int index = MapControl.Map.TrackingLayer.IndexOf(ComsStatic.ControlToolsTrackingName);
  29. if (index == -1)
  30. {
  31. Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域");
  32. this.FindForm().Close(); return;
  33. }
  34. m_geo = MapControl.Map.TrackingLayer.Get(index) as GeoRegion;
  35. if (m_geo is null || m_geo.PartCount != 1)
  36. {
  37. ComsStatic.ShowErrorLog("绘制区域PartCount参数发生错误");
  38. this.FindForm().Close(); return;
  39. }
  40. }
  41. public override object Do(DockPanel dockPanel = null)
  42. {
  43. if (m_geo is null)
  44. {
  45. Sunny.UI.UIMessageTip.ShowError("请先绘制查询区域"); return false;
  46. }
  47. if (LayerPanel.SelectLayers.Count == 0)
  48. {
  49. Sunny.UI.UIMessageTip.ShowError("请先选择需要查询的图层"); return false;
  50. }
  51. DataTable dt = new DataTable() { TableName = "管点数量统计结果" };
  52. DataRow dr;
  53. dt.Columns.Add("统计图层");
  54. foreach (Layer lyr in LayerPanel.SelectLayers)
  55. {
  56. dt.Columns.Add(lyr.Caption);
  57. }
  58. dr = dt.NewRow(); dr["统计图层"] = "管点数量";
  59. DatasetVector dv;
  60. Recordset rd = null;
  61. foreach (Layer lyr in LayerPanel.SelectLayers)
  62. {
  63. dv = lyr.Dataset as DatasetVector;
  64. rd = dv.Query(m_geo, 1, "1=1", CursorType.Static);
  65. dr[lyr.Caption] = rd.RecordCount;
  66. }
  67. dt.Rows.Add(dr);
  68. ComsStatic.RecordsetDispose(rd);
  69. return dt;
  70. }
  71. }
  72. }