|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- 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<SyncInstrumentItemInfo> lstSyncInstrument = new List<SyncInstrumentItemInfo>();
- public string strOldCode = "";
- public InstumentCodeHanlder InstrumentDelegate;
- public InstrumentType type = InstrumentType.None;
- public frmSystemSetting(List<SyncInstrumentItemInfo> lstSyncInstrument)
- {
- InitializeComponent();
- this.lstSyncInstrument = lstSyncInstrument;
- this.DialogResult = DialogResult.None;
- }
-
- public frmSystemSetting(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 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;
- }
- }
- }
|