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 frmAddSubtract : Form { public SyncInstrumentItemInfo syncInstrument { get; set; } public CnasConditionMapValue conditionvalue { get; set; } public frmAddSubtract(SyncInstrumentItemInfo syncInstrument, CnasConditionMapValue conditionvalue) { InitializeComponent(); this.syncInstrument = syncInstrument; this.conditionvalue = conditionvalue; } private void frmAddSubtract_Load(object sender, EventArgs e) { if (conditionvalue == null) return; string strValue = ""; if (conditionvalue.Value != null) strValue = conditionvalue.Value.ToString(); if (strValue != "") { string[] strValues = strValue.Split(new string[] { "{", "}" }, StringSplitOptions.RemoveEmptyEntries); if (strValues.Length == 3) { txtPrama1.Text = "{" + strValues[0] +"}"; cbxParams2.Text = strValues[1] == "Add" ?"数值相加": "数值相减"; txtPrama3.Text = "{" + strValues[2]+ "}"; } else { conditionvalue.Condition = new MapCondition(); conditionvalue.Value = ""; } } } 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 btnSelect3_Click(object sender, EventArgs e) { frmSelectInstruItem frm = new frmSelectInstruItem(syncInstrument); if (frm.ShowDialog() == DialogResult.OK) { if (frm.strSelectedColumn != "") txtPrama3.Text = "{[" + frm.strSelectedColumn + "]}"; } } private void btnOK_Click(object sender, EventArgs e) { if (this.txtPrama1.Text.Trim() == "" && this.cbxParams2.Text.Trim() == "" && this.txtPrama3.Text.Trim() == "") return; conditionvalue.Value = this.txtPrama1.Text; if (this.cbxParams2.Text != "") conditionvalue.Value += this.cbxParams2.Text=="数值相加"?"{Add}":"{Subtract}"; if (this.txtPrama3.Text != "") conditionvalue.Value += this.txtPrama3.Text; this.DialogResult = DialogResult.OK; this.Close(); } } }