BJroad.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. Recordset rd = null;
  21. private int _rdsmid = 0;
  22. public BJroad()
  23. {
  24. this.ConditionPanelName = "交通道路信息管理";
  25. InitializeComponent();
  26. this.IsShowPanelFooter = false;
  27. }
  28. protected override void OnLoad(EventArgs e)
  29. {
  30. DatasetVector dv = ComsStatic.Datasource.Datasets["pyroad"] as DatasetVector;
  31. if (dv == null)
  32. {
  33. Sunny.UI.UIMessageTip.ShowError("当前数据源中不包含相应的矢量数据集"); return;
  34. }
  35. rd = dv.Query("1=1", CursorType.Dynamic);
  36. ComsStatic.setUIDataGridView(uidgvTable, ComsStatic.RecordsetToDataTable(rd, false), null, ",smid,");
  37. }
  38. private void uiButtonAdd_Click(object sender, EventArgs e)
  39. {
  40. int index = MapControl.Map.TrackingLayer.IndexOf(ComsStatic.ControlToolsTrackingName);
  41. if (index == -1)
  42. {
  43. Sunny.UI.UIMessageTip.ShowError("请先绘制区域"); return;
  44. }
  45. GeoRegion geo = MapControl.Map.TrackingLayer.Get(index) as GeoRegion;
  46. if (geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制交通道路区域"); return; }
  47. if (string.IsNullOrEmpty(uitbName.Text)) { Sunny.UI.UIMessageTip.ShowError("请先输入交通道路名称"); return; }
  48. rd.AddNew(geo);
  49. rd.SetFieldValue("name", uitbName.Text);
  50. rd.SetFieldValue("shape_length", ComsStatic.StringToDouble(geo.Perimeter));
  51. rd.SetFieldValue("shape_area", ComsStatic.StringToDouble(geo.Area));
  52. ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "交通道路新增");
  53. uitbName.Text = ""; MapControl.Map.TrackingLayer.Clear(); MapControl.Map.Refresh();
  54. OnLoad(e);
  55. }
  56. private void uiButtonUpdate_Click(object sender, EventArgs e)
  57. {
  58. if (string.IsNullOrEmpty(uitbName.Text)) { Sunny.UI.UIMessageTip.ShowError("请先输入行政区域名称"); return; }
  59. if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要编辑的信息!"); return; }
  60. if (rd.SeekID(_rdsmid))
  61. {
  62. rd.Edit();
  63. rd.SetFieldValue("name", uitbName.Text);
  64. ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "交通道路编辑");
  65. uitbName.Text = "";
  66. OnLoad(e);
  67. }
  68. else
  69. { Sunny.UI.UIMessageTip.ShowError("信息在编辑选择时失败!"); }
  70. }
  71. private void uiButtonDel_Click(object sender, EventArgs e)
  72. {
  73. if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要删除的信息!"); return; }
  74. if (rd.SeekID(_rdsmid))
  75. {
  76. ComsStatic.ShowUIMessageTipOKorError(rd.Delete(), "交通道路删除");
  77. uitbName.Text = "";
  78. OnLoad(e);
  79. }
  80. else
  81. { Sunny.UI.UIMessageTip.ShowError("信息在删除选择时失败!"); }
  82. }
  83. private void uiDataGridViewtb_SelectIndexChange(object sender, int index)
  84. {
  85. DataGridViewRow dr = uidgvTable.Rows[index];
  86. _rdsmid = ComsStatic.StringToInt(dr.Cells["SmID"].Value.ToString());
  87. uitbName.Text = dr.Cells["name"].Value?.ToString();
  88. }
  89. public override void AfterClose()
  90. {
  91. ComsStatic.RecordsetDispose(rd);
  92. base.AfterClose();
  93. }
  94. }
  95. }