PeiZhiFuTu.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. using SuperMap.Data;
  2. using System;
  3. using System.Collections.Generic;
  4. using WeifenLuo.WinFormsUI.Docking;
  5. using WWPipeLine.MapBasic.Conditions;
  6. using WWPipeLine.MapBasic;
  7. using Sunny.UI;
  8. using System.Windows.Forms;
  9. using System.Data;
  10. namespace WWPipeLine.MapTools.Conditions.XiTongGuanLi
  11. {
  12. public class PeiZhiFuTu : ConditionPanel
  13. {
  14. private Sunny.UI.UIDataGridView uiDGVjslkpz;
  15. private Sunny.UI.UIPanel uiPanel1;
  16. private Sunny.UI.UIButton uiButton3;
  17. private Sunny.UI.UIButton uiButton2;
  18. private Sunny.UI.UIButton uiButton1;
  19. private Sunny.UI.UILabel uiLabel1;
  20. private Sunny.UI.UILabel uiLabel2;
  21. private Sunny.UI.UITextBox uiTBms;
  22. private Sunny.UI.UIPanel uiPanel2;
  23. private Sunny.UI.UIComboBox uiCBcz;
  24. private Recordset _rd;
  25. private Sunny.UI.UILabel uiLBsmid;
  26. private int _rdsmid = 0;
  27. private DataTable m_dt;
  28. public PeiZhiFuTu() : base()
  29. {
  30. this.ConditionPanelName = "管线覆土预警配置";
  31. InitializeComponent();
  32. IsShowPanelFooter = false;
  33. }
  34. protected override void OnLoad(EventArgs e)
  35. {
  36. QueryParameter queryParameter = new QueryParameter
  37. {
  38. AttributeFilter = " pzlx='覆土配置' ",
  39. ResultFields = new string[] { "smid", "gxlx", "pzlx", "gxcz", "gxms" },
  40. OrderBy = new string[] { "smid" },
  41. CursorType = CursorType.Dynamic,
  42. HasGeometry = true
  43. };
  44. _rd = ComsStatic.dvJSLK_PZ.Query(queryParameter);
  45. m_dt = ComsStatic.RecordsetToDataTable(_rd);
  46. ComsStatic.setUIDataGridView(uiDGVjslkpz, m_dt);
  47. ComsStatic.BindDataTableOnComboBox(ComsStatic.dvJSLK, uiCBcz, "cz");
  48. }
  49. private void uiButton3_Click(object sender, EventArgs e)
  50. {
  51. if (_rdsmid == 0) { UIMessageTip.ShowError("请先选择需要删除的信息!"); return; }
  52. if (_rd.SeekID(_rdsmid))
  53. {
  54. ComsStatic.ShowUIMessageTipOKorError(_rd.Delete(), "管线覆土配置删除");
  55. OnLoad(e);
  56. }
  57. else
  58. { Sunny.UI.UIMessageTip.ShowError("信息在删除选择时失败!"); }
  59. }
  60. private void uiButton2_Click(object sender, EventArgs e)
  61. {
  62. string strCZ = uiCBcz.SelectedItem?.ToString();
  63. if (string.IsNullOrEmpty(uiTBms.Text) || uiTBms.Text == "0" || string.IsNullOrEmpty(strCZ))
  64. {
  65. UIMessageTip.ShowError("请输入正确的覆土数据!"); return;
  66. }
  67. if (_rd.SeekID(_rdsmid))
  68. {
  69. _rd.Edit();
  70. _rd.SetFieldValue("gxcz", uiCBcz.SelectedItem);
  71. _rd.SetFieldValue("gxms", ComsStatic.StringToDouble(uiTBms.Text));
  72. ComsStatic.ShowUIMessageTipOKorError(_rd.Update(), "管线覆土配置编辑");
  73. OnLoad(e);
  74. }
  75. else
  76. { Sunny.UI.UIMessageTip.ShowError("信息在编辑选择时失败!"); }
  77. }
  78. public override void AfterClose()
  79. {
  80. ComsStatic.RecordsetDispose(_rd);
  81. base.AfterClose();
  82. }
  83. private void uiButton1_Click(object sender, EventArgs e)
  84. {
  85. string strCZ = uiCBcz.SelectedItem?.ToString();
  86. if (string.IsNullOrEmpty(uiTBms.Text) || uiTBms.Text == "0" || string.IsNullOrEmpty(strCZ))
  87. {
  88. UIMessageTip.ShowError("请输入正确的覆土数据!"); return;
  89. }
  90. if (m_dt.Select(string.Format(" gxcz='{0}'", strCZ)).Length > 0)
  91. {
  92. UIMessageTip.ShowError("已经存在管线的覆土信息!"); return;
  93. }
  94. _rd.AddNew(new GeoPoint(0, 0));
  95. _rd.SetFieldValue("gxlx", "供水管线");
  96. _rd.SetFieldValue("pzlx", "覆土配置");
  97. _rd.SetFieldValue("gxcz", strCZ);
  98. _rd.SetFieldValue("gxms", ComsStatic.StringToDouble(uiTBms.Text));
  99. ComsStatic.ShowUIMessageTipOKorError(_rd.Update(), "管线覆土配置新增");
  100. OnLoad(e);
  101. }
  102. private void uiTextBox2_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
  103. {
  104. if ((e.KeyChar < 48 || e.KeyChar > 57) &&(e.KeyChar != 8))
  105. e.Handled = true;
  106. }
  107. private void uiDGVjslkpz_SelectIndexChange(object sender, int index)
  108. {
  109. var selectRows = (sender as UIDataGridView).SelectedRows;
  110. if (selectRows == null || selectRows.Count != 1) return;
  111. _rdsmid = ComsStatic.StringToInt(selectRows[0].Cells["SmID"].Value.ToString());
  112. if (_rdsmid != 0 && _rd.SeekID(_rdsmid))
  113. {
  114. uiLBsmid.Text = _rd.GetFieldValue("smid")?.ToString();
  115. uiCBcz.SelectedItem = _rd.GetFieldValue("gxcz")?.ToString();
  116. uiTBms.Text = _rd.GetFieldValue("gxms")?.ToString();
  117. }
  118. else
  119. { Sunny.UI.UIMessageTip.ShowError("信息错误!"); }
  120. }
  121. private void InitializeComponent()
  122. {
  123. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
  124. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle();
  125. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle();
  126. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle();
  127. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle();
  128. this.uiDGVjslkpz = new Sunny.UI.UIDataGridView();
  129. this.uiPanel1 = new Sunny.UI.UIPanel();
  130. this.uiPanel2 = new Sunny.UI.UIPanel();
  131. this.uiLBsmid = new Sunny.UI.UILabel();
  132. this.uiCBcz = new Sunny.UI.UIComboBox();
  133. this.uiTBms = new Sunny.UI.UITextBox();
  134. this.uiLabel2 = new Sunny.UI.UILabel();
  135. this.uiLabel1 = new Sunny.UI.UILabel();
  136. this.uiButton3 = new Sunny.UI.UIButton();
  137. this.uiButton2 = new Sunny.UI.UIButton();
  138. this.uiButton1 = new Sunny.UI.UIButton();
  139. ((System.ComponentModel.ISupportInitialize)(this.uiDGVjslkpz)).BeginInit();
  140. this.uiPanel1.SuspendLayout();
  141. this.uiPanel2.SuspendLayout();
  142. this.SuspendLayout();
  143. //
  144. // uiDGVjslkpz
  145. //
  146. dataGridViewCellStyle6.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
  147. this.uiDGVjslkpz.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle6;
  148. this.uiDGVjslkpz.BackgroundColor = System.Drawing.Color.White;
  149. this.uiDGVjslkpz.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
  150. dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  151. dataGridViewCellStyle7.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
  152. dataGridViewCellStyle7.Font = new System.Drawing.Font("微软雅黑", 12F);
  153. dataGridViewCellStyle7.ForeColor = System.Drawing.Color.White;
  154. dataGridViewCellStyle7.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
  155. dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  156. dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  157. this.uiDGVjslkpz.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle7;
  158. this.uiDGVjslkpz.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  159. dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  160. dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Window;
  161. dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 12F);
  162. dataGridViewCellStyle8.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
  163. dataGridViewCellStyle8.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(155)))), ((int)(((byte)(200)))), ((int)(((byte)(255)))));
  164. dataGridViewCellStyle8.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
  165. dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
  166. this.uiDGVjslkpz.DefaultCellStyle = dataGridViewCellStyle8;
  167. this.uiDGVjslkpz.Dock = System.Windows.Forms.DockStyle.Fill;
  168. this.uiDGVjslkpz.EnableHeadersVisualStyles = false;
  169. this.uiDGVjslkpz.Font = new System.Drawing.Font("微软雅黑", 12F);
  170. this.uiDGVjslkpz.GridColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
  171. this.uiDGVjslkpz.Location = new System.Drawing.Point(0, 0);
  172. this.uiDGVjslkpz.Name = "uiDGVjslkpz";
  173. dataGridViewCellStyle9.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
  174. dataGridViewCellStyle9.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
  175. dataGridViewCellStyle9.Font = new System.Drawing.Font("微软雅黑", 12F);
  176. dataGridViewCellStyle9.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(48)))), ((int)(((byte)(48)))), ((int)(((byte)(48)))));
  177. dataGridViewCellStyle9.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
  178. dataGridViewCellStyle9.SelectionForeColor = System.Drawing.Color.White;
  179. dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  180. this.uiDGVjslkpz.RowHeadersDefaultCellStyle = dataGridViewCellStyle9;
  181. dataGridViewCellStyle10.BackColor = System.Drawing.Color.White;
  182. this.uiDGVjslkpz.RowsDefaultCellStyle = dataGridViewCellStyle10;
  183. this.uiDGVjslkpz.RowTemplate.Height = 23;
  184. this.uiDGVjslkpz.SelectedIndex = -1;
  185. this.uiDGVjslkpz.ShowGridLine = true;
  186. this.uiDGVjslkpz.Size = new System.Drawing.Size(500, 350);
  187. this.uiDGVjslkpz.TabIndex = 0;
  188. this.uiDGVjslkpz.SelectIndexChange += new Sunny.UI.UIDataGridView.OnSelectIndexChange(this.uiDGVjslkpz_SelectIndexChange);
  189. //
  190. // uiPanel1
  191. //
  192. this.uiPanel1.Controls.Add(this.uiDGVjslkpz);
  193. this.uiPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
  194. this.uiPanel1.Font = new System.Drawing.Font("微软雅黑", 12F);
  195. this.uiPanel1.Location = new System.Drawing.Point(0, 0);
  196. this.uiPanel1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  197. this.uiPanel1.MinimumSize = new System.Drawing.Size(1, 1);
  198. this.uiPanel1.Name = "uiPanel1";
  199. this.uiPanel1.Size = new System.Drawing.Size(500, 350);
  200. this.uiPanel1.TabIndex = 1;
  201. this.uiPanel1.Text = "uiPanel1";
  202. this.uiPanel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
  203. //
  204. // uiPanel2
  205. //
  206. this.uiPanel2.Controls.Add(this.uiLBsmid);
  207. this.uiPanel2.Controls.Add(this.uiCBcz);
  208. this.uiPanel2.Controls.Add(this.uiTBms);
  209. this.uiPanel2.Controls.Add(this.uiLabel2);
  210. this.uiPanel2.Controls.Add(this.uiLabel1);
  211. this.uiPanel2.Controls.Add(this.uiButton3);
  212. this.uiPanel2.Controls.Add(this.uiButton2);
  213. this.uiPanel2.Controls.Add(this.uiButton1);
  214. this.uiPanel2.Dock = System.Windows.Forms.DockStyle.Bottom;
  215. this.uiPanel2.Font = new System.Drawing.Font("微软雅黑", 12F);
  216. this.uiPanel2.Location = new System.Drawing.Point(0, 254);
  217. this.uiPanel2.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  218. this.uiPanel2.MinimumSize = new System.Drawing.Size(1, 1);
  219. this.uiPanel2.Name = "uiPanel2";
  220. this.uiPanel2.Size = new System.Drawing.Size(500, 96);
  221. this.uiPanel2.TabIndex = 2;
  222. this.uiPanel2.Text = null;
  223. this.uiPanel2.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
  224. //
  225. // uiLBsmid
  226. //
  227. this.uiLBsmid.Font = new System.Drawing.Font("微软雅黑", 12F);
  228. this.uiLBsmid.Location = new System.Drawing.Point(3, 62);
  229. this.uiLBsmid.Name = "uiLBsmid";
  230. this.uiLBsmid.Size = new System.Drawing.Size(59, 23);
  231. this.uiLBsmid.TabIndex = 11;
  232. this.uiLBsmid.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  233. this.uiLBsmid.Visible = false;
  234. //
  235. // uiCBcz
  236. //
  237. this.uiCBcz.DataSource = null;
  238. this.uiCBcz.FillColor = System.Drawing.Color.White;
  239. this.uiCBcz.Font = new System.Drawing.Font("微软雅黑", 12F);
  240. this.uiCBcz.Location = new System.Drawing.Point(97, 7);
  241. this.uiCBcz.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  242. this.uiCBcz.MinimumSize = new System.Drawing.Size(63, 0);
  243. this.uiCBcz.Name = "uiCBcz";
  244. this.uiCBcz.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
  245. this.uiCBcz.Size = new System.Drawing.Size(85, 29);
  246. this.uiCBcz.TabIndex = 9;
  247. this.uiCBcz.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
  248. //
  249. // uiTBms
  250. //
  251. this.uiTBms.Cursor = System.Windows.Forms.Cursors.IBeam;
  252. this.uiTBms.FillColor = System.Drawing.Color.White;
  253. this.uiTBms.Font = new System.Drawing.Font("微软雅黑", 12F);
  254. this.uiTBms.Location = new System.Drawing.Point(301, 7);
  255. this.uiTBms.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
  256. this.uiTBms.Maximum = 2147483647D;
  257. this.uiTBms.MaxLength = 4;
  258. this.uiTBms.Minimum = -2147483648D;
  259. this.uiTBms.MinimumSize = new System.Drawing.Size(1, 1);
  260. this.uiTBms.Name = "uiTBms";
  261. this.uiTBms.Size = new System.Drawing.Size(85, 29);
  262. this.uiTBms.TabIndex = 7;
  263. this.uiTBms.Text = "0";
  264. this.uiTBms.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
  265. this.uiTBms.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.uiTextBox2_KeyPress);
  266. //
  267. // uiLabel2
  268. //
  269. this.uiLabel2.Font = new System.Drawing.Font("微软雅黑", 12F);
  270. this.uiLabel2.Location = new System.Drawing.Point(207, 7);
  271. this.uiLabel2.Name = "uiLabel2";
  272. this.uiLabel2.Size = new System.Drawing.Size(85, 29);
  273. this.uiLabel2.TabIndex = 4;
  274. this.uiLabel2.Text = "标准埋深";
  275. this.uiLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  276. //
  277. // uiLabel1
  278. //
  279. this.uiLabel1.Font = new System.Drawing.Font("微软雅黑", 12F);
  280. this.uiLabel1.Location = new System.Drawing.Point(3, 7);
  281. this.uiLabel1.Name = "uiLabel1";
  282. this.uiLabel1.Size = new System.Drawing.Size(85, 29);
  283. this.uiLabel1.TabIndex = 3;
  284. this.uiLabel1.Text = "管线材质";
  285. this.uiLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
  286. //
  287. // uiButton3
  288. //
  289. this.uiButton3.Cursor = System.Windows.Forms.Cursors.Hand;
  290. this.uiButton3.Font = new System.Drawing.Font("微软雅黑", 12F);
  291. this.uiButton3.Location = new System.Drawing.Point(375, 50);
  292. this.uiButton3.MinimumSize = new System.Drawing.Size(1, 1);
  293. this.uiButton3.Name = "uiButton3";
  294. this.uiButton3.Size = new System.Drawing.Size(100, 35);
  295. this.uiButton3.TabIndex = 2;
  296. this.uiButton3.Text = "删除";
  297. this.uiButton3.Click += new System.EventHandler(this.uiButton3_Click);
  298. //
  299. // uiButton2
  300. //
  301. this.uiButton2.Cursor = System.Windows.Forms.Cursors.Hand;
  302. this.uiButton2.Font = new System.Drawing.Font("微软雅黑", 12F);
  303. this.uiButton2.Location = new System.Drawing.Point(250, 50);
  304. this.uiButton2.MinimumSize = new System.Drawing.Size(1, 1);
  305. this.uiButton2.Name = "uiButton2";
  306. this.uiButton2.Size = new System.Drawing.Size(100, 35);
  307. this.uiButton2.TabIndex = 1;
  308. this.uiButton2.Text = "修改";
  309. this.uiButton2.Click += new System.EventHandler(this.uiButton2_Click);
  310. //
  311. // uiButton1
  312. //
  313. this.uiButton1.Cursor = System.Windows.Forms.Cursors.Hand;
  314. this.uiButton1.Font = new System.Drawing.Font("微软雅黑", 12F);
  315. this.uiButton1.Location = new System.Drawing.Point(125, 50);
  316. this.uiButton1.MinimumSize = new System.Drawing.Size(1, 1);
  317. this.uiButton1.Name = "uiButton1";
  318. this.uiButton1.Size = new System.Drawing.Size(100, 35);
  319. this.uiButton1.TabIndex = 0;
  320. this.uiButton1.Text = "新增";
  321. this.uiButton1.Click += new System.EventHandler(this.uiButton1_Click);
  322. //
  323. // PeiZhiFuTu
  324. //
  325. this.Controls.Add(this.uiPanel2);
  326. this.Controls.Add(this.uiPanel1);
  327. this.Name = "PeiZhiFuTu";
  328. this.Size = new System.Drawing.Size(500, 350);
  329. ((System.ComponentModel.ISupportInitialize)(this.uiDGVjslkpz)).EndInit();
  330. this.uiPanel1.ResumeLayout(false);
  331. this.uiPanel2.ResumeLayout(false);
  332. this.ResumeLayout(false);
  333. }
  334. }
  335. }