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 WWPipeLine.MapBasic; using SuperMap.Data; using SuperMap.Mapping; using Sunny.UI; namespace WWPipeLine.MapTools.Conditions.XiTongGuanLi { public partial class ShuJuZiDian : ConditionPanel { Recordset rd = null; private int rdsmid = 0; public ShuJuZiDian() { this.ConditionPanelName = "数据字典维护"; InitializeComponent(); this.IsShowResultWindow = false; } protected override void OnLoad(EventArgs e) { ComsStatic.BindUICombox(uicbxLayer, true); } public override object Do(DockPanel dockPanel = null) { if (rdsmid == 0 || string.IsNullOrEmpty(uitb.Text)) { UIMessageTip.ShowError("请先选择需要操作的信息!"); return null; } if (rd.SeekID(rdsmid)) { rd.Edit(); rd.SetFieldValue("infos", uitb.Text); ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "数据字典配置更改"); QueryParameter queryParameter = new QueryParameter { AttributeFilter = string.Format(" pzlx='数据字典' AND gxlx='{0}' ", (uicbxLayer.SelectedItem as DoListItem).Key), ResultFields = new string[] { "smid", "pzlx", "gxlx", "pzKey", "pzValue", "valueBefore", "infos" }, OrderBy = new string[] { " smid asc " }, CursorType = CursorType.Dynamic }; rd = ComsStatic.dvConfig.Query(queryParameter); uidgv.DataSource = ComsStatic.RecordsetToDataTable(rd, false); } else { Sunny.UI.UIMessageTip.ShowError("信息在编辑选择时失败"); } return null; } private void uicbxLayer_SelectedIndexChanged(object sender, EventArgs e) { DoListItem item = (DoListItem)uicbxLayer.SelectedItem; DatasetVector dv = ComsStatic.Datasource.Datasets[item.Key] as DatasetVector; QueryParameter queryParameter = new QueryParameter { AttributeFilter = string.Format(" pzlx='数据字典' AND gxlx='{0}' ", dv.Name), ResultFields = new string[] { "smid", "pzlx", "gxlx", "pzKey", "pzValue", "valueBefore", "infos" }, OrderBy = new string[] { " smid asc " }, CursorType = CursorType.Dynamic }; rd = ComsStatic.dvConfig.Query(queryParameter); if (rd.RecordCount == 0) { FieldInfos infos = dv.GetRecordset(true, CursorType.Static).GetFieldInfos(); foreach (FieldInfo info in infos) { if (ComsStatic.HideEnableTag.Contains("," + info.Name.ToLower() + ",") || info.IsSystemField) continue; rd.AddNew(new GeoPoint(0, 0)); rd.SetFieldValue("pzlx", "数据字典"); rd.SetFieldValue("gxlx", dv.Name); rd.SetFieldValue("pzKey", item.Value); rd.SetFieldValue("valueBefore", info.Name); rd.SetFieldValue("pzValue", info.Caption); rd.Update(); } rd = ComsStatic.dvConfig.Query(queryParameter); } ComsStatic.setUIDataGridView(uidgv, ComsStatic.RecordsetToDataTable(rd, false), null, ",pzlx,gxlx,valueBefore,smid,"); } private void uidgv_SelectIndexChange(object sender, int index) { if (uidgv.SelectedRows == null || uidgv.SelectedRows.Count != 1) return; rdsmid = ComsStatic.StringToInt(uidgv.SelectedRows[0].Cells["SmID"].Value); uitb.Text = uidgv.SelectedRows[0].Cells["infos"].Value?.ToString(); } public override void AfterClose() { ComsStatic.RecordsetDispose(rd); base.AfterClose(); } } }