Beispiel #1
0
        public ModifyAnimalForm(Animal animal, AdministrationForm administrationForm)
        {
            if (animal == null)
            {
                throw new ArgumentNullException("animal");
            }

            if (administrationForm == null)
            {
                throw new ArgumentNullException("administrationForm");
            }

            InitializeComponent();

            this.animal             = animal;
            this.administrationForm = administrationForm;

            Cat cat = animal as Cat;

            if (cat != null)
            {
                ShowCatFields();
                if (cat.BadHabits != null)
                {
                    inputBadHabits.Text = cat.BadHabits;
                }

                animalType = AnimalType.Cat;
            }
            else
            {
                Dog dog = animal as Dog;
                if (dog == null)
                {
                    //We don't know what kind of animal this is, so we cannot modify it.
                    throw new InvalidOperationException();
                }
                ShowDogFields();
                if (dog.LastWalkDate != null)
                {
                    inputLastWalkDate.Value =
                        new DateTime(dog.LastWalkDate.Year, dog.LastWalkDate.Month, dog.LastWalkDate.Day);
                }

                animalType = AnimalType.Dog;
            }

            inputName.Text       = animal.Name;
            inputBirthDate.Value =
                new DateTime(animal.DateOfBirth.Year, animal.DateOfBirth.Month, animal.DateOfBirth.Day);
            checkbox_Reserved.Checked = animal.IsReserved;
        }
Beispiel #2
0
        public ModifyAnimalForm(Animal animal, AdministrationForm administrationForm)
        {
            if (animal == null)
            {
                throw new ArgumentNullException("animal");
            }

            if (administrationForm == null)
            {
                throw new ArgumentNullException("administrationForm");
            }

            InitializeComponent();

            this.animal = animal;
            this.administrationForm = administrationForm;

            Cat cat = animal as Cat;
            if(cat != null)
            {
                ShowCatFields();
                if (cat.BadHabits != null)
                {
                    inputBadHabits.Text = cat.BadHabits;
                }

                animalType = AnimalType.Cat;
            }
            else
            {
                Dog dog = animal as Dog;
                if(dog == null)
                {
                    //We don't know what kind of animal this is, so we cannot modify it.
                    throw new InvalidOperationException();
                }
                ShowDogFields();
                if (dog.LastWalkDate != null)
                {
                    inputLastWalkDate.Value =
                         new DateTime(dog.LastWalkDate.Year, dog.LastWalkDate.Month, dog.LastWalkDate.Day);
                }

                animalType = AnimalType.Dog;
            }

            inputName.Text = animal.Name;
            inputBirthDate.Value =
                new DateTime(animal.DateOfBirth.Year, animal.DateOfBirth.Month, animal.DateOfBirth.Day);
            checkbox_Reserved.Checked = animal.IsReserved;
        }
Beispiel #3
0
        public CreateAnimalForm(Administration administration, AdministrationForm administrationForm)
        {
            if (administration == null)
            {
                throw new ArgumentNullException("administration");
            }

            if (administrationForm == null)
            {
                throw new ArgumentNullException("administrationForm");
            }

            InitializeComponent();

            this.administration = administration;
            this.administrationForm = administrationForm;
        }
Beispiel #4
0
        public CreateAnimalForm(Administration administration, AdministrationForm administrationForm)
        {
            if (administration == null)
            {
                throw new ArgumentNullException("administration");
            }

            if (administrationForm == null)
            {
                throw new ArgumentNullException("administrationForm");
            }

            InitializeComponent();

            this.administration     = administration;
            this.administrationForm = administrationForm;
        }