PCPeiZhi.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 WWPipeLine.MapBasic;
  13. using SuperMap.Data;
  14. using SuperMap.Mapping;
  15. using Sunny.UI;
  16. namespace WWPipeLine.MapTools.Conditions.ShuJuChuLi
  17. {
  18. public partial class PCPeiZhi : ConditionPanel
  19. {
  20. Recordset rd = null;
  21. DataTable dtCopy;
  22. public PCPeiZhi()
  23. {
  24. this.ConditionPanelName = "普查数据检查配置";
  25. InitializeComponent();
  26. this.SetSize(800, 500);
  27. this.IsShowResultWindow = false;
  28. }
  29. protected override void OnLoad(EventArgs e)
  30. {
  31. ComsStatic.setUIDataGridView(uidgv);
  32. uidgv.ReadOnly = false;
  33. //rd = ComsStatic.dvConfig.Query(" pzlx='普查数据检查配置' and gxlx='管点表' ", CursorType.Dynamic);
  34. rd = ComsStatic.QueryRecordsetDynamic(ComsStatic.dvConfig, " pzlx='普查数据检查配置' and gxlx='管点表' ", new string[] { "gxlx", "gxcz", "pzkey", "pzvalue", "gxspjj", "gxczjj" });
  35. DataTable dt = ComsStatic.RecordsetToDataTable(rd, false);
  36. dtCopy = dt.Copy();
  37. uidgv.DataSource = dt;
  38. for (int i = 0; i < uidgv.Columns.Count; i++)
  39. {
  40. uidgv.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
  41. switch (uidgv.Columns[i].Name.ToLower())
  42. {
  43. case "gxlx": uidgv.Columns[i].HeaderText = "普查表类型"; uidgv.Columns[i].ReadOnly = true; break;
  44. case "gxcz": uidgv.Columns[i].HeaderText = "字段类型"; uidgv.Columns[i].ReadOnly = true; break;
  45. case "pzkey": uidgv.Columns[i].HeaderText = "字段标识"; uidgv.Columns[i].ReadOnly = true; break;
  46. case "pzvalue": uidgv.Columns[i].HeaderText = "普查标准"; uidgv.Columns[i].ReadOnly = true; break;
  47. case "gxspjj": uidgv.Columns[i].HeaderText = "数值字段最小值"; uidgv.Columns[i].ReadOnly = false; break;
  48. case "gxczjj": uidgv.Columns[i].HeaderText = "数值字段最大值"; uidgv.Columns[i].ReadOnly = false; break;
  49. default: uidgv.Columns[i].Visible = false; break;
  50. }
  51. }
  52. }
  53. public override object Do(DockPanel dockPanel = null)
  54. {
  55. try
  56. {
  57. int smid = 0;
  58. for (int i = 0; i < uidgv.Rows.Count; i++)
  59. {
  60. smid = ComsStatic.StringToInt(dtCopy.Rows[i]["smid"]);
  61. if (smid == 0) continue;
  62. if (uidgv.Rows[i].Cells["gxspjj"].Value?.ToString() != dtCopy.Rows[i]["gxspjj"]?.ToString() || uidgv.Rows[i].Cells["gxczjj"].Value?.ToString() != dtCopy.Rows[i]["gxczjj"]?.ToString())
  63. {
  64. rd.SeekID(smid);
  65. rd.Edit();
  66. rd.SetFieldValue("gxspjj", ComsStatic.StringToDouble(uidgv.Rows[i].Cells["gxspjj"].Value));
  67. rd.SetFieldValue("gxczjj", ComsStatic.StringToDouble(uidgv.Rows[i].Cells["gxczjj"].Value));
  68. rd.Update();
  69. }
  70. }
  71. ComsStatic.ShowOKLog("配置更改成功"); return true;
  72. }
  73. catch (Exception e)
  74. {
  75. ComsStatic.ShowErrorLog("配置更改失败", e.Message); return false;
  76. }
  77. }
  78. public override void AfterClose()
  79. {
  80. ComsStatic.RecordsetDispose(rd);
  81. base.AfterClose();
  82. }
  83. }
  84. }