Beispiel #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnEditFormula_Click(object sender, EventArgs e)
 {
     if (this.lvFormula.SelectedItems.Count > 0)
     {
         ListViewItem lvi = this.lvFormula.SelectedItems[0];
         Formula formula = this.lvFormula.SelectedItems[0].Tag as Formula;
         if (formula != null)
         {
             frmFormula f = new frmFormula();
             f.SetEditInfo(this.Device.ID, formula);
             DialogResult dr = f.ShowDialog();
             if (dr == DialogResult.OK)
             {
                 if (!f.IsAdd())
                 {
                     DB.FormulaDB.UpdateFormula(formula.ID, formula.Begin, formula.End, formula.FormulaExpress);
                     lvi.SubItems[0].Text = formula.BeginString;
                     lvi.SubItems[1].Text = formula.EndString;
                     lvi.SubItems[2].Text = formula.FormulaExpress;
                 }
             }
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddFormula_Click(object sender, EventArgs e)
        {
            frmFormula f = new frmFormula();
            f.SetAddInfo(this.Device.ID);
            DialogResult dr = f.ShowDialog();
            if (dr == DialogResult.OK)
            {
                if (f.IsAdd())
                {
                    int id = DB.FormulaDB.InsertFormula(this.Device.ID,
                        f.Begin, f.End, f.Formula);
                    Formula formula = new Formula(id, f.Begin, f.End, f.Formula);

                    YeHeCommuniServerApp.Default.DevieFormaulCollectionMapCollection.AddFormula(
                        this.Device.ID, formula);

                    AddFormulaListViewItem(formula);
                }
            }
        }