ATMLCommonLibrary.forms.ATMLErrorListBox.Show C# (CSharp) Method

Show() public static method

public static Show ( ICollection messages ) : void
messages ICollection
return void
        public static void Show(ICollection<String> messages)
        {
            int i = 1;
            //-------------------------------------------//
            //--- First lets remove any existing rows ---//
            //-------------------------------------------//
            form.InitGrid();
            foreach (String error in messages)
            {
                int rowId = form.dbGrid.Rows.Add(new object[] {"" + i++, error});
            }
            form.ShowDialog();
        }

Usage Example

Exemplo n.º 1
0
        private void ATMLForm_Closing(object sender, CancelEventArgs e)
        {
            if (e.Cancel)
            {
                e.Cancel = false;
                FormManager.RemoveActiveForm(this);
            }
            else
            {
                if (DialogResult.Cancel == DialogResult || DialogResult.Abort == DialogResult)
                {
                    OnCanceled();
                }
                else if (DialogResult.OK == DialogResult)
                {
                    try
                    {
                        bool thisValidated     = Validate();
                        bool childrenValidated = ValidateChildren(ValidationConstraints.Enabled);
                        if (!thisValidated || !childrenValidated)
                        {
                            childrenValidated = ValidateChildren(ValidationConstraints.Enabled);
                            //Hack: need to check children again
                            if (!thisValidated || !childrenValidated)
                            {
                                e.Cancel = true;
                                UpdateAll();
                                ICollection <string> errorsList = ErrorManager.GatherErrorMessages(this);
                                if (errorsList.Count > 0)
                                {
                                    ATMLErrorListBox.Show(errorsList);
                                }

                                LogManager.Debug("Form \"{0}\" Validated: {1}, Children Validated: {2}",
                                                 Text,
                                                 thisValidated,
                                                 childrenValidated);
                            }
                            else
                            {
                                OnSaved();
                            }
                        }
                        else
                        {
                            OnSaved();
                        }
                    }
                    catch (Exception err)
                    {
                        LogManager.Error(err, "An error occurred saving the form.");
                        e.Cancel = true;
                    }

                    e.Cancel = e.Cancel |= !_closeOnSave;
                }

                if (!e.Cancel)
                {
                    if (OwnedForms.Length > 0)
                    {
                        foreach (Form ownedForm in OwnedForms)
                        {
                            LogManager.Warn(string.Format("Child Form Forced Closed: {0}", ownedForm.GetType().Name));
                            try
                            {
                                ownedForm.Close();
                            }
                            catch (Exception err)
                            {
                                LogManager.Debug(err);
                            }
                        }
                    }
                    else
                    {
                        FormManager.RemoveActiveForm(this);
                    }
                }

                //------------------------------------------------------------------------//
                //--- If the user presses the command box X on the form when the form  ---//
                //--- has been opened modeless and the user has already saved the data ---//
                //--- with the OK button we must set the DialogResult to something     ---//
                //--- other than OK so the form will close. This is because the X does ---//
                //--- not set the DialogResult to a Cancel State or change it at all   ---//
                //--- for that matter as far as I know.                                ---//
                //--- TODO: Need to look into setting cancel state on command X        ---//
                //------------------------------------------------------------------------//
                if (!Modal && !_closeOnSave)
                {
                    DialogResult = DialogResult.None;
                }
            }

            //---------------------------------------------//
            //--- Close the ATML View Form if it exists ---//
            //---------------------------------------------//
            if (!e.Cancel && _atmlContentform != null)
            {
                _atmlContentform.HideOnClose = false;
                _atmlContentform.Close();
            }

            if (e.Cancel)
            {
                UpdateAll();
            }
        }