示例#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);
                }
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lstWaterDevice_SelectedIndexChanged(object sender, EventArgs e)
        {
            object selected = this.lstWaterDevice.SelectedItem;
            DeviceFormulaCollectionMap d = selected as DeviceFormulaCollectionMap;

            if (d != null)
            {
                this.lvFormula.Items.Clear();
                foreach (Formula f in d.FormulaCollection)
                {
                    AddFormulaListViewItem(f);
                }
            }
        }
示例#3
0
        static public DeviceFormulaCollectionMap CreateDeviceFormulaCollectionMap(int deviceID)
        {
            DeviceFormulaCollectionMap _deviceFormulaCollectionMap = new DeviceFormulaCollectionMap(deviceID);
            DataTable formulaDataTable = FormulaDBI.GetDataTable(deviceID);

            foreach (DataRow row in formulaDataTable.Rows)
            {
                DateTime begin   = Convert.ToDateTime(row["DTBegin"]);
                DateTime end     = Convert.ToDateTime(row["DTEnd"]);
                string   formula = row["formula"].ToString();

                if (formula.Length > 0)
                {
                    Xdgk.CF.Formula item = new Xdgk.CF.Formula(deviceID,
                                                               begin, end, formula);

                    _deviceFormulaCollectionMap.FormulaCollection.Add(item);
                }
            }
            return(_deviceFormulaCollectionMap);
        }