frmMatMsgInfo.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using com.hnshituo.core.webapp.vo;
  2. using Common;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12. namespace CarMeterSystem
  13. {
  14. public partial class frmMatMsgInfo : Form
  15. {
  16. public frmMatMsgInfo()
  17. {
  18. InitializeComponent();
  19. }
  20. //是否选对了
  21. public bool _isSuccess { get; set; }
  22. string _matName = "", _chkMatName = "";
  23. public frmMatMsgInfo(string matName)
  24. {
  25. InitializeComponent();
  26. _matName = matName;
  27. }
  28. private void btnCancel_Click(object sender, EventArgs e)
  29. {
  30. this.DialogResult = DialogResult.Cancel;
  31. }
  32. private void btnSave_Click(object sender, EventArgs e)
  33. {
  34. _isSuccess = (_matName == _chkMatName);
  35. this.DialogResult = DialogResult.OK;
  36. btnSave.Enabled = false;
  37. btnCancel.Enabled = false;
  38. }
  39. /// <summary>
  40. /// 定时关闭(15000ms)
  41. /// </summary>
  42. /// <param name="sender"></param>
  43. /// <param name="e"></param>
  44. private void timer1_Tick(object sender, EventArgs e)
  45. {
  46. this.DialogResult = DialogResult.Cancel;
  47. }
  48. private void lbMat1_Click(object sender, EventArgs e)
  49. {
  50. _chkMatName = lbMat1.Text;
  51. lbMat1.BackColor = Color.PaleTurquoise;
  52. lbMat2.BackColor = Color.LightBlue;
  53. }
  54. private void lbMat2_Click(object sender, EventArgs e)
  55. {
  56. _chkMatName = lbMat2.Text;
  57. lbMat2.BackColor = Color.PaleTurquoise;
  58. lbMat1.BackColor = Color.LightBlue;
  59. }
  60. private void frmMatMsgInfo_Load(object sender, EventArgs e)
  61. {
  62. Random rd = new Random();
  63. string strMat = "";
  64. PbModelDbService<List<PbModelDb>> pbRelation = new PbModelDbService<List<PbModelDb>>();
  65. string sql = $"select t.text, t.rn from (select matter_name text, rownum rn from meter_base_matter_info where IS_SECOND_RESOURCES = '1') t " +
  66. $"where t.rn = (select trunc(dbms_random.value(1, (select count(1) + 1 from meter_base_matter_info where IS_SECOND_RESOURCES = '1'))) as rn from dual)";
  67. RESTfulResult<List<PbModelDb>> rmRelation = pbRelation.executeSqlDataWf(sql);
  68. if (rmRelation.Succeed && rmRelation.Data != null && rmRelation.Data.Count > 0)
  69. {
  70. strMat = rmRelation.Data[0].text;
  71. }
  72. else
  73. {
  74. strMat = _matName;
  75. }
  76. int i = rd.Next(1, 2);
  77. if (i == 1)
  78. {
  79. lbMat1.Text = _matName;
  80. lbMat2.Text = strMat;
  81. }
  82. if (i == 2)
  83. {
  84. lbMat2.Text = _matName;
  85. lbMat1.Text = strMat;
  86. }
  87. }
  88. }
  89. }