Example #1
0
        private void ItemIdComboBox_Leave(object sender, EventArgs e)
        {
            // save new item id to DB only when user selects OK, save to in-memory list for transient use
            ItemId Cur = NC.App.DB.ItemIds.Get(d => String.Compare(d.item, ItemIdComboBox.Text, false) == 0);

            if (Cur == null)
            {
                // new items need the isotopics specified
                UpdateIsotopics(straight: false);
                //Add the item id if not found in DB. Use the current values on the dialog for the item id content
                ah.ItemIdComboBox_Leave(sender, e); // put the new id on the acq helper
                Cur              = ah.ap.ItemId;    // the dlg and acq parms are the same, use the ItemId helper to construct. Create a new object if there is no match.
                ah.ap.mass       = 0;
                Cur.declaredMass = 0;
                Cur.modified     = true;
                Cur.IsoApply(NC.App.DB.Isotopics.Get(ah.ap.isotopics_id)); // apply the iso dates to the item
                NC.App.DB.ItemIds.GetList().Add(Cur);                      // add only to in-memory, save to DB on user OK/exit

                FieldFillerOnItemId();                                     // refresh the dialog

                ItemIdComboBox.Items.Add(ItemIdComboBox.Text);             // rebuild combo box and select the new time
                ItemIdComboBox.Items.Clear();
                foreach (ItemId id in NC.App.DB.ItemIds.GetList())
                {
                    ItemIdComboBox.Items.Add(id.item);
                }
            }
        }