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; using System.Xml.Serialization; namespace CNAS_DBSync { public partial class frmSystemSetting : Form { private SystemFormatConfig systemConfig; public List lstSyncInstrument = new List(); public string strOldCode = ""; public InstumentCodeHanlder InstrumentDelegate; public InstrumentType type = InstrumentType.None; public frmSystemSetting(List lstSyncInstrument) { InitializeComponent(); this.lstSyncInstrument = lstSyncInstrument; this.DialogResult = DialogResult.None; } public frmSystemSetting(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 frmSystemSetting_Load(object sender, EventArgs e) { //加载配置信息 systemConfig = FileOperation.GetSystemFormatConfigData(strOldCode); if (systemConfig.TableInfoMode == "1") { this.cbxManual.Checked = true; this.cbxAutomatic.Checked = false; } else { this.cbxManual.Checked = false; this.cbxAutomatic.Checked = true; } int days = 0; if (Int32.TryParse(systemConfig.ShowDelayDays, out days)) { this.numpShowDataDays.Value = -days; } if (Int32.TryParse(systemConfig.ShowLogDays, out days)) { this.numpLogDataDays.Value = -days; } } private void btnOK_Click(object sender, EventArgs e) { //判断合法性,存储配置信息 systemConfig.TableInfoMode = this.cbxManual.Checked ? "1" : "0"; systemConfig.ShowDelayDays = (-numpShowDataDays.Value).ToString(); systemConfig.ShowLogDays = (-numpLogDataDays.Value).ToString(); systemConfig.YQName = this.txtCode.Text.Trim(); bool bSave = FileOperation.SaveSystemFormatConfigData(systemConfig, systemConfig.YQName); 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; } } //传输输入到父界面 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(); } private void cbxManual_CheckedChanged(object sender, EventArgs e) { cbxAutomatic.Checked = !cbxManual.Checked; } private void cbxAutomatic_CheckedChanged(object sender, EventArgs e) { cbxManual.Checked = !cbxAutomatic.Checked; } } }