CNAS取数仪器端升级
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

frmInstrumentCode.cs 3.6KB

4 달 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 delegate void InstumentCodeHanlder(SyncInstrumentItemInfo Instrumentitem);
  14. public partial class frmInstrumentCode : Form
  15. {
  16. public List<SyncInstrumentItemInfo> lstSyncInstrument = new List<SyncInstrumentItemInfo>();
  17. public InstumentCodeHanlder InstrumentDelegate;
  18. public string strOldCode = "";
  19. public InstrumentType type = InstrumentType.None;
  20. public frmInstrumentCode(List<SyncInstrumentItemInfo> lstSyncInstrument)
  21. {
  22. InitializeComponent();
  23. this.lstSyncInstrument = lstSyncInstrument;
  24. this.DialogResult = DialogResult.None;
  25. }
  26. public frmInstrumentCode(List<SyncInstrumentItemInfo> lstSyncInstrument,string strOldCode=null)
  27. {
  28. InitializeComponent();
  29. this.lstSyncInstrument = lstSyncInstrument;
  30. this.strOldCode=this.txtCode.Text=strOldCode;
  31. var lstInstrument = lstSyncInstrument.Where(s => s.Code == strOldCode).ToList<SyncInstrumentItemInfo>();
  32. if (lstInstrument.Count == 1)
  33. {
  34. type = lstInstrument[0].InstruType;
  35. //this.cbxInstruType.Text =GlobalCommonOperation.GetTitleByInstruType(type);
  36. }
  37. }
  38. private void btnOK_Click(object sender, EventArgs e)
  39. {
  40. //if (this.txtCode.Text.Trim() == strOldCode&& GlobalCommonOperation.GetInstruTypeBySelectedItem(this.cbxInstruType.Text)==type) //此时没有修改任何内容
  41. if (this.txtCode.Text.Trim() == strOldCode) //此时没有修改任何内容,直接关闭界面
  42. {
  43. //return;
  44. this.Close();
  45. return;
  46. }
  47. if (this.txtCode.Text.Trim() != strOldCode)
  48. {
  49. int iMessage = new InstrumentCodeOperation().CheckInstrumentCode(this.txtCode.Text.Trim(), lstSyncInstrument);
  50. if (iMessage <= 0)
  51. {
  52. switch (iMessage)
  53. {
  54. case 0:
  55. MessageBox.Show("输入不允许为空!请重新输入!");
  56. break;
  57. case -1:
  58. MessageBox.Show("输入含有特殊字符!请重新输入!");
  59. break;
  60. case -2:
  61. MessageBox.Show("仪器编码不允许重复!请重新输入!");
  62. break;
  63. }
  64. this.txtCode.Text = "";
  65. return;
  66. }
  67. }
  68. //if (this.cbxInstruType.Text == "")
  69. //{
  70. // MessageBox.Show("类型不允许为空!请重新选择!");
  71. // return;
  72. //}
  73. //传输输入到父界面
  74. SyncInstrumentItemInfo syncinstrument = new SyncInstrumentItemInfo
  75. {
  76. GUID = Guid.NewGuid().ToString(),
  77. Code = this.txtCode.Text.Trim(),
  78. //InstruType = GlobalCommonOperation.GetInstruTypeBySelectedItem(this.cbxInstruType.Text)
  79. InstruType = InstrumentType.None
  80. };
  81. this.InstrumentDelegate(syncinstrument);
  82. this.DialogResult = DialogResult.OK;
  83. //关闭界面
  84. this.Close();
  85. }
  86. }
  87. }