Beispiel #1
0
        public void Init()
        {
            db = new DataBase.DataBaseManagement("VetoPTArentir");
            // suppression de tout les objets du panel
            addAnimalPanel.Controls.Clear();
            // titre
            Label title = new Label();
            title.Size = new Size(500, 30);
            title.Font = new Font("Arial", 20);
            title.Location = new Point(170, 20);
            title.Text = "Ajouter un animal";
            addAnimalPanel.Controls.Add(title);
            // nom 
            TextBox name = new TextBox();
            name.Size = new Size(100, 30);
            name.Location = new Point(230, 100);
            name.Text = "Nom";
            addAnimalPanel.Controls.Add(name);
            // poids 
            TextBox weight = new TextBox();
            weight.Size = new Size(100, 30);
            weight.Location = new Point(230, 130);
            weight.Text = "Poids (en kg)";
            addAnimalPanel.Controls.Add(weight);
            // proprietaire
            owner = new ComboBox();
            owner.Size = new Size(100, 30);
            owner.Location = new Point(230, 160);
            owner.Text = "Propriétaire  ";
            people = db.getPeople();
            foreach (string p in people)
            {
                owner.Items.Add(p.Split(':')[1] + " " + p.Split(':')[2]);
            }
            owner.SelectedIndexChanged += new EventHandler(ownerChange);
            addAnimalPanel.Controls.Add(owner);
            // date de naissance
            DateTimePicker date = new DateTimePicker();
            date.Format = DateTimePickerFormat.Short;
            date.Size = new Size(100, 30);
            date.Location = new Point(230, 190);
            addAnimalPanel.Controls.Add(date);
            // espece
            specy = new ComboBox();
            specy.Size = new Size(100, 30);
            specy.Location = new Point(230, 220);
            specy.Text = "Espece";
            species = db.getSpecies();
            foreach (string s in species)
            {
                specy.Items.Add(s.Split(':')[1]);
            }
            specy.SelectedIndexChanged += new EventHandler(specyChange);
            addAnimalPanel.Controls.Add(specy);
            // race
            breed = new ComboBox();
            breed.Size = new Size(100, 30);
            breed.Location = new Point(230, 250);
            breed.Text = "Race";
            breed.SelectedIndexChanged += new EventHandler(breedChange);
            addAnimalPanel.Controls.Add(breed);
            // bouton confirmer
            Button confirmButton = new Button();
            confirmButton.Size = new Size(100, 30);
            confirmButton.Location = new Point(150, 310);
            confirmButton.Text = "Confirmer";
            confirmButton.Click += (sender, eventArgs) => { db.InsertAnimal(name.Text, weight.Text + " kg", date.Text, person_id, breed_id); };
            confirmButton.Click += new EventHandler(displayAnimals);
            addAnimalPanel.Controls.Add(confirmButton);
            // bouton annuler
            Button cancelButton = new Button();
            cancelButton.Size = new Size(100, 30);
            cancelButton.Location = new Point(310, 310);
            cancelButton.Text = "Annuler";
            cancelButton.Click += new EventHandler(homePage);
            addAnimalPanel.Controls.Add(cancelButton);


        }