ATMLCommonLibrary.forms.InstrumentForm.btnOk_Clicka C# (CSharp) Метод

btnOk_Clicka() защищенный Метод

protected btnOk_Clicka ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
Результат void
        protected void btnOk_Clicka( object sender, EventArgs e )
        {
            ValidateChildren();
            if (!ValidateChildren())
            {
                MessageBox.Show( @"Errors Exist. Please correct them to continue." );
            }
            else
            {
                InstrumentDescription instrumentDescription = instrumentControl.InstrumentDescription;

                if (instrumentDescription == null)
                    return;

                //------------------------------------------------------------------------------------------------//
                //--- Cleanup Objects - if Lists are empty then set list to null - may need to switch to array ---//
                //---                   if extension is not used then set it to null                           ---//
                //------------------------------------------------------------------------------------------------//
                if (instrumentDescription.Extension != null && instrumentDescription.Extension.Any != null &&
                    instrumentDescription.Extension.Any.Count == 0)
                    instrumentDescription.Extension = null;

                try
                {
                    InstrumentController.Instance.Save( instrumentDescription );
                    UpdateAtmlViewContent(instrumentDescription);
                    instrumentControl.Invalidate();
                    Update();
                }
                catch (Exception err)
                {
                    MessageBox.Show( string.Format( "An error has occurred saving the Instrument.\n{0}", err.Message ) );
                }
                //OnSaved(e);
                OnSaved();
            }
        }