PeiZhiYuJing.cs 16 KB

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