Inheritance: System.Windows.Forms.Form
Ejemplo n.º 1
0
        private void CreateNewAutoCat()
        {
            string       name = string.Empty;
            AutoCatType  t    = AutoCatType.None;
            bool         good = true;
            DialogResult result;

            do
            {
                using (DlgAutoCatCreate dialog = new DlgAutoCatCreate())
                {
                    result = dialog.ShowDialog();
                    if (result != DialogResult.OK)
                    {
                        continue;
                    }

                    good = true;
                    name = dialog.SelectedName;
                    t    = dialog.SelectedType;
                }

                if (string.IsNullOrEmpty(name))
                {
                    MessageBox.Show(GlobalStrings.DlgAutoCat_MustHaveName);
                    good = false;
                }
                else if (NameExists(name))
                {
                    MessageBox.Show(GlobalStrings.DlgAutoCat_NameInUse);
                    good = false;
                }
                else if (t == AutoCatType.None)
                {
                    MessageBox.Show(GlobalStrings.DlgAutoCat_SelectValidType);
                    good = false;
                }
            } while (result == DialogResult.OK && !good);

            AutoCat newAutoCat = null;

            if (result == DialogResult.OK)
            {
                newAutoCat = AutoCat.Create(t, name);
                if (newAutoCat != null)
                {
                    AutoCatList.Add(newAutoCat);
                }
            }

            AutoCatList.Sort();
            FillAutocatList();
            if (newAutoCat != null)
            {
                lstAutoCats.SelectedItem = newAutoCat;
            }
        }
Ejemplo n.º 2
0
        private void CreateNewAutoCat()
        {
            string       name = string.Empty;
            AutoCatType  t    = AutoCatType.None;
            bool         good = true;
            DialogResult res;

            do
            {
                DlgAutoCatCreate dlg = new DlgAutoCatCreate();
                res = dlg.ShowDialog();
                if (res == System.Windows.Forms.DialogResult.OK)
                {
                    good = true;
                    name = dlg.SelectedName;
                    t    = dlg.SelectedType;
                    if (string.IsNullOrEmpty(name))
                    {
                        MessageBox.Show(GlobalStrings.DlgAutoCat_MustHaveName);
                        good = false;
                    }
                    else if (NameExists(name))
                    {
                        MessageBox.Show(GlobalStrings.DlgAutoCat_NameInUse);
                        good = false;
                    }
                    else if (t == AutoCatType.None)
                    {
                        MessageBox.Show(GlobalStrings.DlgAutoCat_SelectValidType);
                        good = false;
                    }
                }
            } while(res == DialogResult.OK && !good);
            if (res == DialogResult.OK)
            {
                AutoCat newAutoCat = AutoCat.Create(t, name);
                if (newAutoCat != null)
                {
                    AutoCatList.Add(newAutoCat);
                }
            }
            AutoCatList.Sort();
            FillAutocatList();
        }
Ejemplo n.º 3
0
 private void CreateNewAutoCat() {
     string name = string.Empty;
     AutoCatType t = AutoCatType.None;
     bool good = true;
     DialogResult res;
     do {
         DlgAutoCatCreate dlg = new DlgAutoCatCreate();
         res = dlg.ShowDialog();
         if( res == System.Windows.Forms.DialogResult.OK ) {
             good = true;
             name = dlg.SelectedName;
             t = dlg.SelectedType;
             if( string.IsNullOrEmpty( name ) ) {
                 MessageBox.Show( GlobalStrings.DlgAutoCat_MustHaveName );
                 good = false;
             } else if( NameExists( name ) ) {
                 MessageBox.Show( GlobalStrings.DlgAutoCat_NameInUse );
                 good = false;
             } else if( t == AutoCatType.None ) {
                 MessageBox.Show( GlobalStrings.DlgAutoCat_SelectValidType );
                 good = false;
             }
         }
     } while( res == DialogResult.OK && !good );
     AutoCat newAutoCat = null;
     if ( res == DialogResult.OK ) {
         newAutoCat = AutoCat.Create( t, name );
         if( newAutoCat != null ) {
             AutoCatList.Add( newAutoCat );
         }
     }
     AutoCatList.Sort();
     FillAutocatList();
     if (newAutoCat != null) lstAutoCats.SelectedItem = newAutoCat;
 }