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.

137 lines
4.8KB

  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. using System.Xml.Serialization;
  12. namespace CNAS_DBSync
  13. {
  14. public partial class frmSystemSetting : Form
  15. {
  16. private SystemFormatConfig systemConfig;
  17. public List<SyncInstrumentItemInfo> lstSyncInstrument = new List<SyncInstrumentItemInfo>();
  18. public string strOldCode = "";
  19. public InstumentCodeHanlder InstrumentDelegate;
  20. public InstrumentType type = InstrumentType.None;
  21. public frmSystemSetting(List<SyncInstrumentItemInfo> lstSyncInstrument)
  22. {
  23. InitializeComponent();
  24. this.lstSyncInstrument = lstSyncInstrument;
  25. this.DialogResult = DialogResult.None;
  26. }
  27. public frmSystemSetting(List<SyncInstrumentItemInfo> lstSyncInstrument, string strOldCode = null)
  28. {
  29. InitializeComponent();
  30. this.lstSyncInstrument = lstSyncInstrument;
  31. this.strOldCode = this.txtCode.Text = strOldCode;
  32. var lstInstrument = lstSyncInstrument.Where(s => s.Code == strOldCode).ToList<SyncInstrumentItemInfo>();
  33. if (lstInstrument.Count == 1)
  34. {
  35. type = lstInstrument[0].InstruType;
  36. //this.cbxInstruType.Text =GlobalCommonOperation.GetTitleByInstruType(type);
  37. }
  38. }
  39. private void frmSystemSetting_Load(object sender, EventArgs e)
  40. {
  41. //加载配置信息
  42. systemConfig= FileOperation.GetSystemFormatConfigData(strOldCode);
  43. if (systemConfig.TableInfoMode == "1")
  44. {
  45. this.cbxManual.Checked = true;
  46. this.cbxAutomatic.Checked = false;
  47. }
  48. else
  49. {
  50. this.cbxManual.Checked = false;
  51. this.cbxAutomatic.Checked = true;
  52. }
  53. int days = 0;
  54. if (Int32.TryParse(systemConfig.ShowDelayDays, out days))
  55. {
  56. this.numpShowDataDays.Value = -days;
  57. }
  58. if (Int32.TryParse(systemConfig.ShowLogDays, out days))
  59. {
  60. this.numpLogDataDays.Value = -days;
  61. }
  62. }
  63. private void btnOK_Click(object sender, EventArgs e)
  64. {
  65. //判断合法性,存储配置信息
  66. systemConfig.TableInfoMode = this.cbxManual.Checked ? "1" : "0";
  67. systemConfig.ShowDelayDays = (-numpShowDataDays.Value).ToString();
  68. systemConfig.ShowLogDays = (-numpLogDataDays.Value).ToString();
  69. systemConfig.YQName = this.txtCode.Text.Trim();
  70. bool bSave = FileOperation.SaveSystemFormatConfigData(systemConfig, systemConfig.YQName);
  71. if (this.txtCode.Text.Trim() == strOldCode) //此时没有修改任何内容,直接关闭界面
  72. {
  73. //return;
  74. this.Close();
  75. return;
  76. }
  77. if (this.txtCode.Text.Trim() != strOldCode)
  78. {
  79. int iMessage = new InstrumentCodeOperation().CheckInstrumentCode(this.txtCode.Text.Trim(), lstSyncInstrument);
  80. if (iMessage <= 0)
  81. {
  82. switch (iMessage)
  83. {
  84. case 0:
  85. MessageBox.Show("输入不允许为空!请重新输入!");
  86. break;
  87. case -1:
  88. MessageBox.Show("输入含有特殊字符!请重新输入!");
  89. break;
  90. case -2:
  91. MessageBox.Show("仪器编码不允许重复!请重新输入!");
  92. break;
  93. }
  94. this.txtCode.Text = "";
  95. return;
  96. }
  97. }
  98. //传输输入到父界面
  99. SyncInstrumentItemInfo syncinstrument = new SyncInstrumentItemInfo
  100. {
  101. GUID = Guid.NewGuid().ToString(),
  102. Code = this.txtCode.Text.Trim(),
  103. //InstruType = GlobalCommonOperation.GetInstruTypeBySelectedItem(this.cbxInstruType.Text)
  104. InstruType = InstrumentType.None
  105. };
  106. this.InstrumentDelegate(syncinstrument);
  107. this.DialogResult = DialogResult.OK;
  108. //关闭界面
  109. this.Close();
  110. }
  111. private void cbxManual_CheckedChanged(object sender, EventArgs e)
  112. {
  113. cbxAutomatic.Checked = !cbxManual.Checked;
  114. }
  115. private void cbxAutomatic_CheckedChanged(object sender, EventArgs e)
  116. {
  117. cbxManual.Checked = !cbxAutomatic.Checked;
  118. }
  119. }
  120. }