Nanook.QueenBee.GenericQbItemEditor.btnUpdateItems_Click C# (CSharp) Method

btnUpdateItems_Click() private method

private btnUpdateItems_Click ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        private void btnUpdateItems_Click(object sender, EventArgs e)
        {
            List<GenericQbItem> gis = new List<GenericQbItem>();
            GenericQbEditItem ei;
            GenericQbItem gi;

            //check that all the items are valid before saving

            try
            {
                //Check if QbKey is in the debug file, if not then add it to the user defined list
                base.AddQbKeyToUserDebugFile(base.QbItem.ItemQbKey);

                foreach (Control un in this.Controls)
                {
                    if ((ei = (un as GenericQbEditItem)) != null)
                    {
                        if (!ei.IsValid)
                        {
                            base.ShowError("Error", "QB cannot be updated while data is invalid.");
                            return;
                        }
                        gi = ei.GenericQbItem;

                        //if QbKey, check to see if it's in the debug file, if not then add it to the user defined list
                        if (gi.Type == typeof(QbKey))
                            AddQbKeyToUserDebugFile(gi.ToQbKey());

                        gis.Add(gi);
                    }
                }
            }
            catch (Exception ex)
            {
                base.ShowException("Failed to Get Item Values", ex);
                return;
            }

            try
            {
                QbFile.SetGenericItems(base.QbItem, gis);
            }
            catch (Exception ex)
            {
                base.ShowException("Edit Values Update Error", ex);
                return;
            }

            base.UpdateQbItem();
        }