CNAS取数仪器端升级
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 line
4.5KB

  1. using CnasSynchronusClient;
  2. using CnasSynchrousModel;
  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.Windows.Forms;
  11. namespace CNAS_DBSync
  12. {
  13. public partial class frmConditionParam : Form
  14. {
  15. private SyncInstrumentItemInfo syncInstrument = new SyncInstrumentItemInfo();
  16. public CnasConditionMapValue conditionvalue = new CnasConditionMapValue();
  17. public frmConditionParam(SyncInstrumentItemInfo syncInstrument, CnasConditionMapValue conditionvalue)
  18. {
  19. InitializeComponent();
  20. this.syncInstrument = syncInstrument;
  21. this.conditionvalue = conditionvalue;
  22. }
  23. private void frmConditionParam_Load(object sender, EventArgs e)
  24. {
  25. if (conditionvalue == null) return;
  26. string strCondition = conditionvalue.Condition.ToString();
  27. this.groupBox1.Text = $"条件<{strCondition}>参数配置";
  28. string strValue = "";
  29. if(conditionvalue.Value!=null)
  30. strValue = conditionvalue.Value.ToString();
  31. if (strValue != "")
  32. {
  33. string[] strValues = strValue.Split(new string[] { "+" }, StringSplitOptions.RemoveEmptyEntries);
  34. if (strValues.Length >= 1 && strValues.Length <= 3)
  35. {
  36. switch (strValues.Length)
  37. {
  38. case 1:
  39. this.txtPrama1.Text = strValues[0];
  40. break;
  41. case 2:
  42. this.txtPrama1.Text = strValues[0];
  43. this.txtPrama2.Text = strValues[1];
  44. break;
  45. case 3:
  46. this.txtPrama1.Text = strValues[0];
  47. this.txtPrama2.Text = strValues[1];
  48. this.txtPrama3.Text = strValues[2];
  49. break;
  50. }
  51. }
  52. else
  53. {
  54. conditionvalue.Condition = new MapCondition();
  55. conditionvalue.Value = "";
  56. }
  57. }
  58. }
  59. private void btnOK_Click(object sender, EventArgs e)
  60. {
  61. if (this.txtPrama1.Text.Trim() == "" && this.txtPrama2.Text.Trim() == "" && this.txtPrama3.Text.Trim() == "")
  62. return;
  63. conditionvalue.Value = this.txtPrama1.Text;
  64. if (this.txtPrama2.Text != "")
  65. conditionvalue.Value += "+" + this.txtPrama2.Text;
  66. if(this.txtPrama3.Text != "")
  67. conditionvalue.Value += "+" + this.txtPrama3.Text;
  68. this.DialogResult = DialogResult.OK;
  69. this.Close();
  70. }
  71. private void txtPrama2_TextChanged(object sender, EventArgs e)
  72. {
  73. if (this.txtPrama1.Text == "")
  74. {
  75. MessageBox.Show("请按照顺序添加参数");
  76. this.txtPrama2.Text = "";
  77. }
  78. }
  79. private void txtPrama3_TextChanged(object sender, EventArgs e)
  80. {
  81. if (this.txtPrama1.Text == ""||this.txtPrama2.Text == "")
  82. {
  83. MessageBox.Show("请按照顺序添加参数");
  84. this.txtPrama3.Text = "";
  85. }
  86. }
  87. private void btnSelect1_Click(object sender, EventArgs e)
  88. {
  89. frmSelectInstruItem frm = new frmSelectInstruItem(syncInstrument);
  90. if (frm.ShowDialog() == DialogResult.OK)
  91. {
  92. if (frm.strSelectedColumn != "")
  93. txtPrama1.Text = "{" + frm.strSelectedColumn+"} ";
  94. }
  95. }
  96. private void btnSelect2_Click(object sender, EventArgs e)
  97. {
  98. frmSelectInstruItem frm = new frmSelectInstruItem(syncInstrument);
  99. if (frm.ShowDialog() == DialogResult.OK)
  100. {
  101. if (frm.strSelectedColumn != "")
  102. txtPrama2.Text = "{" + frm.strSelectedColumn + "} ";
  103. }
  104. }
  105. private void btnSelect3_Click(object sender, EventArgs e)
  106. {
  107. frmSelectInstruItem frm = new frmSelectInstruItem(syncInstrument);
  108. if (frm.ShowDialog() == DialogResult.OK)
  109. {
  110. if (frm.strSelectedColumn != "")
  111. txtPrama3.Text = "{" + frm.strSelectedColumn + "} ";
  112. }
  113. }
  114. }
  115. }