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 lstSyncInstrument = new List(); public InstumentCodeHanlder InstrumentDelegate; public string strOldCode = ""; public InstrumentType type = InstrumentType.None; public frmInstrumentCode(List lstSyncInstrument) { InitializeComponent(); this.lstSyncInstrument = lstSyncInstrument; this.DialogResult = DialogResult.None; } public frmInstrumentCode(List lstSyncInstrument,string strOldCode=null) { InitializeComponent(); this.lstSyncInstrument = lstSyncInstrument; this.strOldCode=this.txtCode.Text=strOldCode; var lstInstrument = lstSyncInstrument.Where(s => s.Code == strOldCode).ToList(); 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(); } } }