BiaoZhuCheQi.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 WeifenLuo.WinFormsUI.Docking;
  12. using Sunny.UI;
  13. using SuperMap.Mapping;
  14. using WWPipeLine.MapBasic;
  15. using SuperMap.Data;
  16. namespace WWPipeLine.MapTools.Conditions.XiTongGuanLi
  17. {
  18. public partial class BiaoZhuCheQi : ConditionPanel
  19. {
  20. Recordset rd = null;
  21. private int _rdsmid = 0;
  22. QueryParameter queryParameter = new QueryParameter
  23. {
  24. AttributeFilter = string.Format(" pzlx='扯旗标注配置' AND gxlx='{0}' ", ComsStatic.dvJSLK.Name),
  25. ResultFields = new string[] { "smid", "gxlx", "pzlx", "pzKey", "pzValue", "valueBefore", "valueAfter", "valueSort", "valueEnable" },
  26. OrderBy = new string[] { " valueSort asc " },
  27. CursorType = CursorType.Dynamic
  28. };
  29. public BiaoZhuCheQi()
  30. {
  31. this.ConditionPanelName = "管线扯旗标注配置";
  32. InitializeComponent();
  33. this.IsShowResultWindow = false;
  34. }
  35. protected override void OnLoad(EventArgs e)
  36. {
  37. rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
  38. if (rd.RecordCount == 0)
  39. {
  40. FieldInfos infos = ComsStatic.dvJSLK.GetRecordset(true, CursorType.Static).GetFieldInfos();
  41. string allTag = ",gj,cz,cd,msfs,qsdw,dzms,".ToLower();
  42. foreach (FieldInfo info in infos)
  43. {
  44. if (!allTag.Contains("," + info.Name.ToLower() + ",") || info.IsSystemField) continue;
  45. rd.AddNew(new GeoPoint(0, 0));
  46. rd.SetFieldValue("pzlx", "扯旗标注配置");
  47. rd.SetFieldValue("gxlx", ComsStatic.dvJSLK.Name);
  48. rd.SetFieldValue("pzKey", info.Name);
  49. rd.SetFieldValue("pzValue", info.Caption);
  50. rd.SetFieldValue("valueEnable", 0);
  51. rd.Update();
  52. }
  53. rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
  54. }
  55. ComsStatic.setUIDataGridView(uidgvPeiZhi, ComsStatic.RecordsetToDataTable(rd), null, "pzlx,gxlx,pzKey");
  56. uidgvPeiZhi.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
  57. }
  58. public override object Do(DockPanel dockPanel = null)
  59. {
  60. if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要操作的信息!"); return null; }
  61. if (rd.SeekID(_rdsmid))
  62. {
  63. rd.Edit();
  64. rd.SetFieldValue("valueBefore", uitbBefore.Text);
  65. rd.SetFieldValue("valueAfter", uitbAfter.Text);
  66. rd.SetFieldValue("valueSort", ComsStatic.StringToInt(uitbSort.Text));
  67. rd.SetFieldValue("valueEnable", uicbBiaoZhu.Checked ? 1 : 0);
  68. ComsStatic.ShowUIMessageTipOKorError(rd.Update(), "扯旗标注配置更改");
  69. }
  70. else
  71. {
  72. Sunny.UI.UIMessageTip.ShowError("信息在编辑选择时失败!");
  73. }
  74. uicbBiaoZhu.Checked = false; uitbSort.Text = ""; uitbAfter.Text = ""; uitbBefore.Text = ""; uitbZiduan.Text = "";
  75. rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
  76. uidgvPeiZhi.DataSource = ComsStatic.RecordsetToDataTable(rd);
  77. return null;
  78. }
  79. private void uidgvPeiZhi_SelectIndexChange(object sender, int index)
  80. {
  81. var selectRows = (sender as UIDataGridView).SelectedRows;
  82. if (selectRows == null || selectRows.Count != 1) return;
  83. _rdsmid = ComsStatic.StringToInt(selectRows[0].Cells["SmID"].Value.ToString());
  84. if (_rdsmid != 0 && rd.SeekID(_rdsmid))
  85. {
  86. uitbZiduan.Text = rd.GetFieldValue("pzValue")?.ToString();
  87. uitbBefore.Text = rd.GetFieldValue("valueBefore")?.ToString();
  88. uitbAfter.Text = rd.GetFieldValue("valueAfter")?.ToString();
  89. uitbSort.Text = rd.GetFieldValue("valueSort")?.ToString();
  90. uicbBiaoZhu.Checked = ComsStatic.StringToInt(rd.GetFieldValue("valueEnable")) == 0 ? false : true;
  91. }
  92. else
  93. { Sunny.UI.UIMessageTip.ShowError("信息错误!"); }
  94. }
  95. private void uidgvPeiZhi_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
  96. {
  97. for (int i = 0; i < uidgvPeiZhi.Rows.Count; i++)
  98. {
  99. if (uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value.ToString() == "0")
  100. uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value = "";
  101. if (uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value.ToString() == "1")
  102. uidgvPeiZhi.Rows[i].Cells["valueEnable"].Value = "标注";
  103. }
  104. }
  105. private void uitbSort_KeyPress(object sender, KeyPressEventArgs e)
  106. {
  107. if ((e.KeyChar < 48 || e.KeyChar > 57) && (e.KeyChar < 96 || e.KeyChar > 105) && (e.KeyChar != 8))
  108. e.Handled = true;
  109. }
  110. }
  111. }