123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using WWPipeLine.MapBasic.Conditions;
- using SuperMap.Data;
- using Sunny.UI;
- using WWPipeLine.MapBasic;
- using WeifenLuo.WinFormsUI.Docking;
- using SuperMap.UI;
- namespace WWPipeLine.MapTools.Conditions.FuZhuGongJu
- {
- public partial class BJroad : ConditionPanel
- {
- Recordset rd = null;
- private int _rdsmid = 0;
- public BJroad()
- {
- this.ConditionPanelName = "交通道路信息管理";
- InitializeComponent();
- this.IsShowPanelFooter = false;
- }
- protected override void OnLoad(EventArgs e)
- {
- DatasetVector dv = ComsStatic.Datasource.Datasets["pyroad"] as DatasetVector;
- if (dv == null)
- {
- Sunny.UI.UIMessageTip.ShowError("当前数据源中不包含相应的矢量数据集"); return;
- }
- rd = dv.Query("1=1", CursorType.Dynamic);
- ComsStatic.setUIDataGridView(uidgvTable, ComsStatic.RecordsetToDataTable(rd, false), null, ",smid,");
- }
- private void uiButtonAdd_Click(object sender, EventArgs e)
- {
- int index = MapControl.Map.TrackingLayer.IndexOf(ComsStatic.ControlToolsTrackingName);
- if (index == -1)
- {
- Sunny.UI.UIMessageTip.ShowError("请先绘制区域"); return;
- }
- GeoRegion geo = MapControl.Map.TrackingLayer.Get(index) as GeoRegion;
- if (geo is null) { Sunny.UI.UIMessageTip.ShowError("请先绘制交通道路区域"); return; }
- if (string.IsNullOrEmpty(uitbName.Text)) { Sunny.UI.UIMessageTip.ShowError("请先输入交通道路名称"); return; }
- rd.AddNew(geo);
- rd.SetFieldValue("name", uitbName.Text);
- rd.SetFieldValue("shape_length", ComsStatic.StringToDouble(geo.Perimeter));
- rd.SetFieldValue("shape_area", ComsStatic.StringToDouble(geo.Area));
- ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "交通道路新增");
- uitbName.Text = ""; MapControl.Map.TrackingLayer.Clear(); MapControl.Map.Refresh();
- OnLoad(e);
- }
- private void uiButtonUpdate_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(uitbName.Text)) { Sunny.UI.UIMessageTip.ShowError("请先输入行政区域名称"); return; }
- if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要编辑的信息!"); return; }
- if (rd.SeekID(_rdsmid))
- {
- rd.Edit();
- rd.SetFieldValue("name", uitbName.Text);
- ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "交通道路编辑");
- uitbName.Text = "";
- OnLoad(e);
- }
- else
- { Sunny.UI.UIMessageTip.ShowError("信息在编辑选择时失败!"); }
- }
- private void uiButtonDel_Click(object sender, EventArgs e)
- {
- if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要删除的信息!"); return; }
- if (rd.SeekID(_rdsmid))
- {
- ComsStatic.ShowUIMessageTipOKorError(rd.Delete(), "交通道路删除");
- uitbName.Text = "";
- OnLoad(e);
- }
- else
- { Sunny.UI.UIMessageTip.ShowError("信息在删除选择时失败!"); }
- }
- private void uiDataGridViewtb_SelectIndexChange(object sender, int index)
- {
- DataGridViewRow dr = uidgvTable.Rows[index];
- _rdsmid = ComsStatic.StringToInt(dr.Cells["SmID"].Value.ToString());
- uitbName.Text = dr.Cells["name"].Value?.ToString();
- }
- public override void AfterClose()
- {
- ComsStatic.RecordsetDispose(rd);
- base.AfterClose();
- }
- }
- }
|