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.

frmInstrumentCode.cs 3.3KB

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