123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- 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 WeifenLuo.WinFormsUI.Docking;
- using Sunny.UI;
- using SuperMap.Mapping;
- using WWPipeLine.MapBasic;
- using SuperMap.Data;
- namespace WWPipeLine.MapTools.Conditions.XiTongGuanLi
- {
- public partial class BiaoZhuGuanWang : ConditionPanel
- {
- Recordset rd = null;
- private int _rdsmid = 0;
- private UIRadioButton rBtn;
- public BiaoZhuGuanWang()
- {
- this.ConditionPanelName = "管网标注字段配置";
- InitializeComponent();
- this.SetSize(800, 485);
- this.IsShowResultWindow = false;
- }
- protected override void OnLoad(EventArgs e)
- {
- foreach (Layer lyr in ComsStatic.MapLayersUsed)
- {
- UIRadioButton rBtn = new UIRadioButton()
- {
- Name = lyr.Name,
- Text = lyr.Caption,
- Tag = lyr.Dataset,
- Location = new Point(10, 35 + uigbLayer.Controls.Count * 28),
- Width = 120
- };
- rBtn.CheckedChanged += RBtn_CheckedChanged;
- uigbLayer.Controls.Add(rBtn);
- }
- }
- private void RBtn_CheckedChanged(object sender, EventArgs e)
- {
- rBtn = sender as UIRadioButton;
- if (!rBtn.Checked) return;
- DatasetVector dv = rBtn.Tag as DatasetVector;
- QueryParameter queryParameter = new QueryParameter
- {
- AttributeFilter = string.Format(" pzlx='标注字段配置' AND gxlx='{0}' ", dv.Name),
- ResultFields = new string[] { "smid", "gxlx", "pzlx", "pzKey", "pzValue", "valueBefore", "valueAfter", "valueSort", "valueEnable" },
- OrderBy = new string[] { " valueSort asc " },
- CursorType = CursorType.Dynamic
- };
- rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
- if (rd.RecordCount == 0)
- {
- FieldInfos infos = dv.GetRecordset(true, CursorType.Static).GetFieldInfos();
- string allTag = ",x,y,fsw,xh,gg,cz,kj,gj,yl,ms,cd,name,address,".ToLower();
- foreach (FieldInfo info in infos)
- {
- if (!allTag.Contains("," + info.Name.ToLower() + ",") || info.IsSystemField) continue;
- rd.AddNew(new GeoPoint(0, 0));
- rd.SetFieldValue("pzlx", "标注字段配置");
- rd.SetFieldValue("gxlx", dv.Name);
- rd.SetFieldValue("pzKey", info.Name);
- rd.SetFieldValue("pzValue", info.Caption);
- rd.SetFieldValue("valueEnable", 0);
- rd.Update();
- }
- rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
- }
- ComsStatic.setUIDataGridView(uidgvPeiZhi, ComsStatic.RecordsetToDataTable(rd), null, "pzlx,gxlx,pzKey");
- uidgvPeiZhi.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
- }
- public override object Do(DockPanel dockPanel = null)
- {
- if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要操作的信息!"); return null; }
- if (rd.SeekID(_rdsmid))
- {
- rd.Edit();
- rd.SetFieldValue("valueBefore", uitbBefore.Text);
- rd.SetFieldValue("valueAfter", uitbAfter.Text);
- rd.SetFieldValue("valueSort", ComsStatic.StringToInt(uitbSort.Text));
- rd.SetFieldValue("valueEnable", uicbBiaoZhu.Checked ? 1 : 0);
- ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "标注字段配置更改");
- }
- else
- {
- Sunny.UI.UIMessageTip.ShowError("信息在编辑选择时失败!");
- }
- rBtn.Checked = true; uicbBiaoZhu.Checked = false; uitbSort.Text = ""; uitbAfter.Text = ""; uitbBefore.Text = ""; uitbZiduan.Text = "";
- return null;
- }
- private void uidgvPeiZhi_SelectIndexChange(object sender, int index)
- {
- //var selectRows = (sender as UIDataGridView).SelectedRows;
- if (uidgvPeiZhi.SelectedRows == null || uidgvPeiZhi.SelectedRows.Count != 1) return;
- _rdsmid = ComsStatic.StringToInt(uidgvPeiZhi.SelectedRows[0].Cells["SmID"].Value);
- if (_rdsmid != 0 && rd.SeekID(_rdsmid))
- {
- uitbZiduan.Text = rd.GetFieldValue("pzValue")?.ToString();
- uitbBefore.Text = rd.GetFieldValue("valueBefore")?.ToString();
- uitbAfter.Text = rd.GetFieldValue("valueAfter")?.ToString();
- uitbSort.Text = rd.GetFieldValue("valueSort")?.ToString();
- uicbBiaoZhu.Checked = ComsStatic.StringToInt(rd.GetFieldValue("valueEnable")) == 0 ? false : true;
- }
- else
- { Sunny.UI.UIMessageTip.ShowError("信息错误!"); }
- }
- private void uidgvPeiZhi_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
- {
- for (int i = 0; i < uidgvPeiZhi.Rows.Count; i++)
- {
- if (uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value.ToString() == "0")
- uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value = "";
- if (uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value.ToString() == "1")
- uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value = "标注";
- }
- }
- private void uitbSort_KeyPress(object sender, KeyPressEventArgs e)
- {
- if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar < 96 || e.KeyChar > 105) && (e.KeyChar != 8))
- e.Handled = true;
- }
- }
- }
|