Пример #1
0
        private void BTArtiodactylCreate_Click(object sender, EventArgs e)
        {
            if (!SupportingMethods.IsStringEmpty(TBArtiodactylName.Text) &&
                !SupportingMethods.IsStringEmpty(TBArtiodactylWeight.Text) &&
                !SupportingMethods.IsStringEmpty(TBArtiodactylMaxAge.Text) &&
                !SupportingMethods.IsStringEmpty(TBArtiodactylIncubationPeriod.Text) &&
                !SupportingMethods.IsStringEmpty(TBArtiodactylHabitat.Text))
            {
                string name             = TBArtiodactylName.Text;
                int    weight           = Convert.ToInt32(TBArtiodactylWeight.Text);
                int    incubationPeriod = Convert.ToInt32(TBArtiodactylIncubationPeriod.Text);
                int    lifeExpectancy   = Convert.ToInt32(TBArtiodactylMaxAge.Text);
                bool   hasHorns         = CBHorns.Checked;
                string habitat          = TBArtiodactylHabitat.Text;

                Collections.AddToList(name, weight, incubationPeriod, lifeExpectancy, hasHorns, habitat);
            }
            else
            {
                SupportingMethods.ShowMistake();
            }

            TBArtiodactylHabitat.Clear();
            TBArtiodactylIncubationPeriod.Clear();
            TBArtiodactylMaxAge.Clear();
            TBArtiodactylName.Clear();
            TBArtiodactylWeight.Clear();
        }
Пример #2
0
 private void BTDelete_Click(object sender, EventArgs e)
 {
     if (!SupportingMethods.IsStringEmpty(TBKey.Text))
     {
         string key = TBKey.Text;
         Collections.DeleteByKey(key);
         MessageBox.Show("Объект удален");
     }
     else
     {
         SupportingMethods.ShowMistake();
     }
 }
Пример #3
0
        private void BTAnimalCreate_Click(object sender, EventArgs e)
        {
            if (!SupportingMethods.IsStringEmpty(TBAnimalName.Text) &&
                !SupportingMethods.IsStringEmpty(TBAnimalWeight.Text))
            {
                string name   = TBAnimalName.Text;
                int    weight = Convert.ToInt32(TBAnimalWeight.Text);

                Collections.AddToList(name, weight);
            }
            else
            {
                SupportingMethods.ShowMistake();
            }

            TBAnimalName.Clear();
            TBAnimalWeight.Clear();
        }
Пример #4
0
        private void BTBirdCreate_Click(object sender, EventArgs e)
        {
            if (!SupportingMethods.IsStringEmpty(TBBirdName.Text) &&
                !SupportingMethods.IsStringEmpty(TBBirdWeight.Text))
            {
                string name     = TBBirdName.Text;
                int    weight   = Convert.ToInt32(TBBirdWeight.Text);
                bool   flying   = CBFlying.Checked;
                bool   domestic = CBDomestic.Checked;

                Collections.AddToList(name, weight, flying, domestic);
            }
            else
            {
                SupportingMethods.ShowMistake();
            }

            TBBirdWeight.Clear();
            TBBirdName.Clear();
        }
Пример #5
0
        private void BTFind_Click(object sender, EventArgs e)
        {
            if (!SupportingMethods.IsStringEmpty(TBKey.Text))
            {
                string key             = TBKey.Text;
                object soughtForAnimal = Collections.FindByKey(key);

                if (soughtForAnimal != null)
                {
                    if (key.Contains("Животное"))
                    {
                        KingdomAnimal animal = soughtForAnimal as KingdomAnimal;
                        Output(animal);
                    }
                    if (key.Contains("Млекопитающее"))
                    {
                        ClassMammals mammal = soughtForAnimal as ClassMammals;
                        Output(mammal);
                    }
                    if (key.Contains("Птица"))
                    {
                        ClassBirds bird = soughtForAnimal as ClassBirds;
                        Output(bird);
                    }
                    if (key.Contains("Парнокопытное"))
                    {
                        OrderArtiodactyl artiodactyl = soughtForAnimal as OrderArtiodactyl;
                        Output(artiodactyl);
                    }
                }
            }
            else
            {
                SupportingMethods.ShowMistake();
            }
        }
Пример #6
0
        private void BTMammalCreate_Click(object sender, EventArgs e)
        {
            if (!SupportingMethods.IsStringEmpty(TBMammalName.Text) &&
                !SupportingMethods.IsStringEmpty(TBMammalWeight.Text) &&
                !SupportingMethods.IsStringEmpty(TBMammalMaxAge.Text) &&
                !SupportingMethods.IsStringEmpty(TBMammalIncubationPeriod.Text))
            {
                string name             = TBMammalName.Text;
                int    weight           = Convert.ToInt32(TBMammalWeight.Text);
                int    incubationPeriod = Convert.ToInt32(TBMammalIncubationPeriod.Text);
                int    lifeExpectancy   = Convert.ToInt32(TBMammalMaxAge.Text);

                Collections.AddToList(name, weight, incubationPeriod, lifeExpectancy);
            }
            else
            {
                SupportingMethods.ShowMistake();
            }

            TBMammalWeight.Clear();
            TBMammalName.Clear();
            TBMammalMaxAge.Clear();
            TBMammalIncubationPeriod.Clear();
        }