Exemple #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddFormula_Click(object sender, EventArgs e)
        {
            DeviceFormulaCollectionMap sel = SelectedDeviceFormulaCollectionMap;
            if (sel != null)
            {
                frmFormula f = new frmFormula();
                f.SetAddInfo(sel.DeviceID);
                DialogResult dr = f.ShowDialog();
                if (dr == DialogResult.OK)
                {
                    Formula formula = f.FormulaClass;
                    //YeHeCommuniServerApp.Default.DevieFormaulCollectionMapCollection.AddFormula(
                    //    this.Device.ID, formula);
                    int formulaID = App.Default.ToDBI.InsertFormula(sel.DeviceID,
                        formula.Begin,
                        formula.End,
                        formula.FormulaExpress);

                    formula.ID = formulaID;

                    FormulaCollection formulaCollection = App.Default.DevieFormaulCollectionMapCollection.GetFormulaCollection(sel.DeviceID);
                    formulaCollection.Add(formula);

                    AddFormulaListViewItem(formula);
                }
            }
        }
Exemple #2
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.SelectedDeviceFormulaCollectionMap.DeviceID, formula);
             DialogResult dr = f.ShowDialog();
             if (dr == DialogResult.OK)
             {
                 App.Default.ToDBI.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;
             }
         }
     }
 }