|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- using CnasSynchronusClient;
- using CnasSynchrousModel;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
-
- namespace CNAS_DBSync
- {
- public delegate void InstumentCodeHanlder(SyncInstrumentItemInfo Instrumentitem);
-
- public partial class frmInstrumentCode : Form
- {
- public List<SyncInstrumentItemInfo> lstSyncInstrument = new List<SyncInstrumentItemInfo>();
- public InstumentCodeHanlder InstrumentDelegate;
- public string strOldCode = "";
- public InstrumentType type = InstrumentType.None;
-
- public frmInstrumentCode(List<SyncInstrumentItemInfo> lstSyncInstrument)
- {
- InitializeComponent();
-
- this.lstSyncInstrument = lstSyncInstrument;
- this.DialogResult = DialogResult.None;
- }
-
- public frmInstrumentCode(List<SyncInstrumentItemInfo> lstSyncInstrument,string strOldCode=null)
- {
- InitializeComponent();
-
- this.lstSyncInstrument = lstSyncInstrument;
- this.strOldCode=this.txtCode.Text=strOldCode;
-
- var lstInstrument = lstSyncInstrument.Where(s => s.Code == strOldCode).ToList<SyncInstrumentItemInfo>();
- if (lstInstrument.Count == 1)
- {
- type = lstInstrument[0].InstruType;
- //this.cbxInstruType.Text =GlobalCommonOperation.GetTitleByInstruType(type);
- }
- }
-
- private void btnOK_Click(object sender, EventArgs e)
- {
- //if (this.txtCode.Text.Trim() == strOldCode&& GlobalCommonOperation.GetInstruTypeBySelectedItem(this.cbxInstruType.Text)==type) //此时没有修改任何内容
- if (this.txtCode.Text.Trim() == strOldCode) //此时没有修改任何内容,直接关闭界面
- {
- //return;
- this.Close();
- return;
- }
-
- if (this.txtCode.Text.Trim() != strOldCode)
- {
- int iMessage = new InstrumentCodeOperation().CheckInstrumentCode(this.txtCode.Text.Trim(), lstSyncInstrument);
- if (iMessage <= 0)
- {
- switch (iMessage)
- {
- case 0:
- MessageBox.Show("输入不允许为空!请重新输入!");
- break;
- case -1:
- MessageBox.Show("输入含有特殊字符!请重新输入!");
- break;
- case -2:
- MessageBox.Show("仪器编码不允许重复!请重新输入!");
- break;
-
- }
- this.txtCode.Text = "";
- return;
- }
- }
-
- //if (this.cbxInstruType.Text == "")
- //{
- // MessageBox.Show("类型不允许为空!请重新选择!");
- // return;
- //}
-
-
- //传输输入到父界面
- SyncInstrumentItemInfo syncinstrument = new SyncInstrumentItemInfo
- {
- GUID = Guid.NewGuid().ToString(),
- Code = this.txtCode.Text.Trim(),
- //InstruType = GlobalCommonOperation.GetInstruTypeBySelectedItem(this.cbxInstruType.Text)
- InstruType = InstrumentType.None
- };
-
- this.InstrumentDelegate(syncinstrument);
-
- this.DialogResult = DialogResult.OK;
-
- //关闭界面
- this.Close();
- }
- }
-
-
- }
|