ATMLCommonLibrary.controls.hardware.HardwareItemDescriptionControl.HardwareItemDescriptionControl_Validating C# (CSharp) Method

HardwareItemDescriptionControl_Validating() private method

private HardwareItemDescriptionControl_Validating ( object sender, CancelEventArgs e ) : void
sender object
e CancelEventArgs
return void
        private void HardwareItemDescriptionControl_Validating( object sender, CancelEventArgs e )
        {
            tabInterface.BackColor = Color.White;
            operationalRequirementsControl.HasErrors = false;
            interfaceListControl.HasErrors = false;
            legalDocumentListControl.HasErrors = false;
            errorProvider.SetError( interfaceListControl, "" );
            errorProvider.SetError( operationalRequirementsControl, "" );
            errorProvider.SetError( legalDocumentListControl, "" );

            foreach (TabPage tabPage in tabPanelControl.TabPages)
                tabPage.ToolTipText = "";

            //-------------------------------------------------------------------------------------------------------//
            //--- TODO: Would like to generically walk all the tab controls to validate and set the tooltip text. ---//
            //-------------------------------------------------------------------------------------------------------//
            string defError;
            if (factoryDefaultsListControl.FactoryDefaults != null &&
                !factoryDefaultsListControl.Validate( out defError ))
            {
                errorProvider.SetError(factoryDefaultsListControl, defError );
                tabDefaults.ToolTipText = defError;
                OnError(sender, errorProvider.GetError(this));
            }

            if (identificationControl.Identification == null
                || string.IsNullOrEmpty( identificationControl.Identification.ModelName ))
            {
                errorProvider.SetError(identificationControl, Resources.errmsg_An_Identification_Model_Name_is_required_);
                tabIdentification.ToolTipText = Resources.errmsg_An_Identification_Model_Name_is_required_;
                e.Cancel = true;
                OnError(sender, errorProvider.GetError(this));
            }

            if (operationalRequirementsControl.OperationalRequirements != null)
            {
                var errors = new SchemaValidationResult();
                if (!operationalRequirementsControl.OperationalRequirements.Validate( errors ))
                {
                    errorProvider.SetError( operationalRequirementsControl, errors.ErrorMessage );
                    tabRequirements.ToolTipText = errors.ErrorMessage;
                    tabOperational.ToolTipText = errors.ErrorMessage;
                    operationalRequirementsControl.HasErrors = true;
                    OnError( sender, errors.ErrorMessage );
                }
            }

            if (interfaceListControl.PhysicalInterface != null
                && ( interfaceListControl.PhysicalInterface.Items == null || (interfaceListControl.PhysicalInterface.Items != null
                && interfaceListControl.PhysicalInterface.Items.Count == 0 )) )
            {
                errorProvider.SetError( interfaceListControl, Resources.errmsg_at_least_one_interface_item );
                tabInterface.ToolTipText = Resources.errmsg_at_least_one_interface_item;
                interfaceListControl.HasErrors = true;
                OnError( sender, errorProvider.GetError( this ) );
            }

            if (legalDocumentListControl.LegalDocuments != null)
            {
                string error;
                if (!legalDocumentListControl.Validate( out error ))
                {
                    tabLegal.ToolTipText = error;
                    legalDocumentListControl.HasErrors = true;
                    errorProvider.SetError(legalDocumentListControl, error );
                    OnError(sender, errorProvider.GetError(this));
                }
            }
        }