123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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 BJunit : ConditionPanel
- {
- private GeoPoint _geoPoint = null;
- Recordset rd;
- private int _rdsmid = 0;
- public BJunit()
- {
- this.ConditionPanelName = "用水单位信息管理";
- InitializeComponent();
- this.IsShowPanelFooter = false;
- }
- protected override void OnLoad(EventArgs e)
- {
- DatasetVector dv = ComsStatic.Datasource.Datasets["pyunit"] 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, ",fldm,smid,");
- MapControl.MouseDoubleClick += MapControl_MouseDoubleClick;
- }
- private void MapControl_MouseDoubleClick(object sender, MouseEventArgs e)
- {
- Point2D pClick = MapControl.Map.PixelToMap(new Point(e.X, e.Y));
- _geoPoint = new GeoPoint(pClick);
- _geoPoint.Style = ComsStatic.geoStyle_Red_Mark5mm;
- MapControl.Map.TrackingLayer.Clear();
- MapControl.Map.TrackingLayer.Add(_geoPoint, "jiedian");
- MapControl.Map.RefreshTrackingLayer();
- }
- private void uiButtonAdd_Click(object sender, EventArgs e)
- {
- if (_geoPoint is null) { Sunny.UI.UIMessageTip.ShowError("请先双击确定用水单位的坐标"); return; }
- if (string.IsNullOrEmpty(uitb_name.Text)) { Sunny.UI.UIMessageTip.ShowError("请先输入用水单位名称"); return; }
- rd.AddNew(_geoPoint);
- rd.SetFieldValue("fldm", "用水单位");
- rd.SetFieldValue("name", uitb_name.Text);
- rd.SetFieldValue("address", uitb_address.Text);
- ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "用水单位新增");
- uitb_name.Text = ""; uitb_address.Text = ""; MapControl.Map.TrackingLayer.Clear(); MapControl.Map.Refresh();
- OnLoad(e);
- }
- private void uiButtonUpdate_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(uitb_name.Text)) { Sunny.UI.UIMessageTip.ShowError("请先输入用水单位名称"); return; }
- if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要编辑的信息!"); return; }
- if (rd.SeekID(_rdsmid))
- {
- rd.Edit();
- rd.SetFieldValue("name", uitb_name.Text);
- rd.SetFieldValue("address", uitb_address.Text);
- ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "用水单位编辑");
- uitb_name.Text = ""; uitb_address.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(), "用水单位删除");
- uitb_name.Text = ""; uitb_address.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());
- uitb_name.Text = dr.Cells["name"].Value?.ToString();
- uitb_address.Text = dr.Cells["address"].Value?.ToString();
- }
- public override void AfterClose()
- {
- ComsStatic.RecordsetDispose(rd);
- MapControl.MouseDoubleClick -= MapControl_MouseDoubleClick;
- base.AfterClose();
- }
- }
- }
|