示例#1
0
 public void Init()
 {
     db = new DataBase.DataBaseManagement("VetoPTArentir");
     // suppression de tout les objets du panel
     modifyUserPanel.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 = "Modifier un utilisateur";
     modifyUserPanel.Controls.Add(title);
     int y = 100;   // ordonnee labels
     //String details = db.displayAnimalDetails(user_id);
     // nom 
     TextBox name = new TextBox();
     name.Size = new Size(100, 30);
     name.Location = new Point(230, y);
     name.Text = "Nom";
     modifyUserPanel.Controls.Add(name);
     y += 30;
     // prenom 
     TextBox first_name = new TextBox();
     first_name.Size = new Size(100, 30);
     first_name.Location = new Point(230, y);
     first_name.Text = "Prénom";
     modifyUserPanel.Controls.Add(first_name);
     y += 30;
     // mail
     TextBox mail = new TextBox();
     mail.Size = new Size(100, 30);
     mail.Location = new Point(230, y);
     mail.Text = "Mail";
     modifyUserPanel.Controls.Add(mail);
     y += 30;
     // rang
     rank = new ComboBox();
     rank.Size = new Size(100, 30);
     rank.Location = new Point(230, y);
     rank.SelectedText = "Rang";
     rank_id = db.findSpecyIdByName(rank.SelectedText);
     ranks = new List<String>();
     ranks.Add("Administrateur"); ranks.Add("Vétérinaire"); ranks.Add("Assistant(e)"); 
     foreach (string r in ranks) {
         rank.Items.Add(r);
     }
     //rank.SelectedIndexChanged += new EventHandler(rankChange);
     modifyUserPanel.Controls.Add(rank);
     y += 30;
     // identifiant
     TextBox login = new TextBox();
     login.Size = new Size(100, 30);
     login.Location = new Point(230, y);
     login.Text = "Login";
     modifyUserPanel.Controls.Add(login);
     y += 30;
     // mot de passe
     TextBox password = new TextBox();
     password.Size = new Size(100, 30);
     password.Location = new Point(230, y);
     password.Text = "Mot de passe";
     modifyUserPanel.Controls.Add(password);
     y += 30;
     // nouveau mot de passe
     TextBox new_password = new TextBox();
     new_password.Size = new Size(100, 30);
     new_password.Location = new Point(230, y);
     new_password.Text = "Nouveau mot de passe";
     modifyUserPanel.Controls.Add(new_password);
     y += 30;
     // confirmation nouveau mot de passe
     TextBox new_password_confirm = new TextBox();
     new_password_confirm.Size = new Size(100, 30);
     new_password_confirm.Location = new Point(230, y);
     new_password_confirm.Text = "Confirmation nouveau mot de passe";
     modifyUserPanel.Controls.Add(new_password_confirm);
     // bouton modifier
     Button confirmButton = new Button();
     confirmButton.Size = new Size(100, 30);
     confirmButton.Location = new Point(150, 360);
     confirmButton.Text = "Modifier";
     confirmButton.Click += (sender, eventArgs) => {db.updateUser(rank.Text, login.Text, new_password.Text , user_id);};
     confirmButton.Click += new EventHandler(displayUsers);
     modifyUserPanel.Controls.Add(confirmButton);
     // bouton Annuler
     Button backButton = new Button();
     backButton.Size = new Size(100, 30);
     backButton.Location = new Point(310, 360);
     backButton.Text = "Annuler";
     backButton.Click += new EventHandler(displayUsers);
     modifyUserPanel.Controls.Add(backButton);
 }
示例#2
0
        public void Init()
        {
            db = new DataBase.DataBaseManagement("VetoPTArentir");
            // suppression de tout les objets du panel
            modifyAnimalPanel.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 = "Modifier un animal";
            modifyAnimalPanel.Controls.Add(title);
            int y = 100;   // ordonnee labels
            String details = db.displayAnimalDetails(code_animal);

            // nom 
            TextBox name = new TextBox();
            name.Size = new Size(100, 30);
            name.Location = new Point(230, y);
            name.Text = details.Split(':')[0];
            modifyAnimalPanel.Controls.Add(name);
            y += 30;
            // poids 
            TextBox weight = new TextBox();
            weight.Size = new Size(100, 30);
            weight.Location = new Point(230, y);
            weight.Text = details.Split(':')[1].Remove(details.Split(':')[1].Length - 3);      // pour éviter qu'il y ait plusieurs "kg" 
            modifyAnimalPanel.Controls.Add(weight);
            y += 30;
            // proprietaire
            owner = new ComboBox();
            owner.Size = new Size(100, 30);
            owner.Location = new Point(230, y);
            owner.SelectedText = details.Split(':')[3] + " " + details.Split(':')[4];
            person_id = db.findPersonIdByName(details.Split(':')[3], details.Split(':')[4]);
            people = db.getPeople();
            foreach (string p in people)
            {
                owner.Items.Add(p.Split(':')[1] + " " + p.Split(':')[2]);
            }
            owner.SelectedIndexChanged += new EventHandler(ownerChange);
            modifyAnimalPanel.Controls.Add(owner);
            y += 30;
            // date de naissance
            DateTimePicker date = new DateTimePicker();
            date.Format = DateTimePickerFormat.Short;
            date.Size = new Size(100, 30);
            date.Location = new Point(230, y);
            date.Text = details.Split(':')[2];
            modifyAnimalPanel.Controls.Add(date);
            y += 30;
            // espece
            specy = new ComboBox();
            specy.Size = new Size(100, 30);
            specy.Location = new Point(230, y);
            specy.SelectedText = details.Split(':')[5];
            specy_id = db.findSpecyIdByName(specy.SelectedText);
            species = db.getSpecies();
            foreach (string s in species)
            {
                specy.Items.Add(s.Split(':')[1]);
            }
            specy.SelectedIndexChanged += new EventHandler(specyChange);
            modifyAnimalPanel.Controls.Add(specy);
            y += 30;
            // race
            breed = new ComboBox();
            breed.Size = new Size(100, 30);
            breed.Location = new Point(230, y);
            breed.SelectedText = details.Split(':')[6];
            breed_id = db.findBreedIdByName(details.Split(':')[6]);
            breed.SelectedIndexChanged += new EventHandler(breedChange);
            modifyAnimalPanel.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.UpdateAnimal(name.Text, weight.Text + " kg",
                 date.Text, person_id, breed_id, this.code_animal);
            };
            confirmButton.Click += new EventHandler(displayAnimals);
            modifyAnimalPanel.Controls.Add(confirmButton);

            // bouton retour
            Button backButton = new Button();
            backButton.Size = new Size(100, 30);
            backButton.Location = new Point(310, 310);
            backButton.Text = "Retour";
            backButton.Click += new EventHandler(displayAnimals);
            modifyAnimalPanel.Controls.Add(backButton);
            /*
            // bouton proprietaire
            Button ownerButton = new Button();
            ownerButton.Size = new Size(100, 30);
            ownerButton.Location = new Point(470, 310);
            ownerButton.Text = "Propriétaire";
            modifyAnimalPanel.Controls.Add(ownerButton);
            // bouton soins
            Button careButton = new Button();
            careButton.Size = new Size(100, 30);
            careButton.Location = new Point(580, 310);
            careButton.Text = "Soins";
            modifyAnimalPanel.Controls.Add(careButton);
            */
        }