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 partial class frmConditionParam : Form { private SyncInstrumentItemInfo syncInstrument = new SyncInstrumentItemInfo(); public CnasConditionMapValue conditionvalue = new CnasConditionMapValue(); public frmConditionParam(SyncInstrumentItemInfo syncInstrument, CnasConditionMapValue conditionvalue) { InitializeComponent(); this.syncInstrument = syncInstrument; this.conditionvalue = conditionvalue; } private void frmConditionParam_Load(object sender, EventArgs e) { if (conditionvalue == null) return; string strCondition = conditionvalue.Condition.ToString(); this.groupBox1.Text = $"条件<{strCondition}>参数配置"; string strValue = ""; if(conditionvalue.Value!=null) strValue = conditionvalue.Value.ToString(); if (strValue != "") { string[] strValues = strValue.Split(new string[] { "+" }, StringSplitOptions.RemoveEmptyEntries); if (strValues.Length >= 1 && strValues.Length <= 3) { switch (strValues.Length) { case 1: this.txtPrama1.Text = strValues[0]; break; case 2: this.txtPrama1.Text = strValues[0]; this.txtPrama2.Text = strValues[1]; break; case 3: this.txtPrama1.Text = strValues[0]; this.txtPrama2.Text = strValues[1]; this.txtPrama3.Text = strValues[2]; break; } } else { conditionvalue.Condition = new MapCondition(); conditionvalue.Value = ""; } } } private void btnOK_Click(object sender, EventArgs e) { if (this.txtPrama1.Text.Trim() == "" && this.txtPrama2.Text.Trim() == "" && this.txtPrama3.Text.Trim() == "") return; conditionvalue.Value = this.txtPrama1.Text; if (this.txtPrama2.Text != "") conditionvalue.Value += "+" + this.txtPrama2.Text; if(this.txtPrama3.Text != "") conditionvalue.Value += "+" + this.txtPrama3.Text; this.DialogResult = DialogResult.OK; this.Close(); } private void txtPrama2_TextChanged(object sender, EventArgs e) { if (this.txtPrama1.Text == "") { MessageBox.Show("请按照顺序添加参数"); this.txtPrama2.Text = ""; } } private void txtPrama3_TextChanged(object sender, EventArgs e) { if (this.txtPrama1.Text == ""||this.txtPrama2.Text == "") { MessageBox.Show("请按照顺序添加参数"); this.txtPrama3.Text = ""; } } private void btnSelect1_Click(object sender, EventArgs e) { frmSelectInstruItem frm = new frmSelectInstruItem(syncInstrument); if (frm.ShowDialog() == DialogResult.OK) { if (frm.strSelectedColumn != "") txtPrama1.Text = "{" + frm.strSelectedColumn+"} "; } } private void btnSelect2_Click(object sender, EventArgs e) { frmSelectInstruItem frm = new frmSelectInstruItem(syncInstrument); if (frm.ShowDialog() == DialogResult.OK) { if (frm.strSelectedColumn != "") txtPrama2.Text = "{" + frm.strSelectedColumn + "} "; } } private void btnSelect3_Click(object sender, EventArgs e) { frmSelectInstruItem frm = new frmSelectInstruItem(syncInstrument); if (frm.ShowDialog() == DialogResult.OK) { if (frm.strSelectedColumn != "") txtPrama3.Text = "{" + frm.strSelectedColumn + "} "; } } } }