コード例 #1
0
        private void formEmploye_Load(object sender, EventArgs e)
        {
            cbCateg.DisplayMember = "Infos";
            cbCateg.ValueMember   = "Id";
            cbCateg.DataSource    = CategorieDAO.findAll();

            cbAEnfants.DisplayMember = "Infos";
            cbAEnfants.ValueMember   = "Id";
            cbAEnfants.DataSource    = EnfantDAO.findByEmploye(id);

            List <Cadeau> lesCadeaux = new List <Cadeau>();

            try { lesCadeaux = CadeauDAO.findEnfants(id); }
            catch { MessageBox.Show("Problème avec la fonction pour trouver les jouets."); }

            try
            {
                Int32 i = 0;
                foreach (Cadeau leCadeau in lesCadeaux)
                {
                    dataGridView1.Rows.Insert(i, leCadeau.getEnfant().getPrenom(), leCadeau.getJouet().getLibelle(), leCadeau.getDate());
                    i++;
                }
            }
            catch
            {
                MessageBox.Show("Impossible d'afficher les jouets des enfants");
            }
        }
コード例 #2
0
        //Delete
        public override bool delete(Utilisateur unUtilisateur)
        {
            List <Enfant> sesEnfants = EnfantDAO.findByEmploye(unUtilisateur.getId());

            if (sesEnfants.Count() != 0)
            {
                try
                {
                    EnfantDAO unDAO = new EnfantDAO();
                    foreach (Enfant e in sesEnfants)
                    {
                        unDAO.delete(e);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Oups: " + ex);
                }
            }
            Boolean retour = false;

            try
            {
                String     requete    = "DELETE FROM Utilisateur WHERE id=" + unUtilisateur.getId();
                SqlCommand maCommande = new SqlCommand(requete, seConnecter());
                Int32      resultat   = maCommande.ExecuteNonQuery();
                retour = true;
            }
            catch (Exception ex)
            {
                throw new Exception("Oups: " + ex);
            }
            return(retour);
        }
コード例 #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            int id = DAO <Enfant> .NumMax("Enfant", "id");

            int idEmploye = (Int32)cbEmployes.SelectedValue;

            if (txtBxAge.Text != "" && txtBxPrenom.Text != "")
            {
                string prenom = txtBxPrenom.Text;
                Int32  age    = 0;
                if (Int32.TryParse(txtBxAge.Text, out age))
                {
                    UtilisateurDAO unUtilisateurDAO = new UtilisateurDAO();
                    Enfant         unEnfant         = new Enfant(id, age, prenom, unUtilisateurDAO.find(idEmploye));
                    EnfantDAO      enfantDao        = new EnfantDAO();
                    Boolean        check            = enfantDao.create(unEnfant);
                    if (check == true)
                    {
                        MessageBox.Show("Enfant ajouté.");
                    }
                    else
                    {
                        MessageBox.Show("Incident dans l'ajout de l'enfant.");
                    }
                }
            }
            else
            {
                MessageBox.Show("Veuillez remplir tous les champs.");
            }
            cbEnfants.DataSource    = EnfantDAO.findByEmploye((Int32)cbEmployes.SelectedValue);
            cbEnfants.DisplayMember = "Infos";
            cbEnfants.ValueMember   = "Id";
        }
コード例 #4
0
        private void btnSupprEnfant_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("Vous êtes sûr de vouloir supprimer cet enfant?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                int            idEnfant         = (Int32)cbEnfants.SelectedValue;
                UtilisateurDAO unUtilisateurDAO = new UtilisateurDAO();
                EnfantDAO      enfantDao        = new EnfantDAO();
                Enfant         unEnfant         = enfantDao.find(idEnfant);
                Boolean        check            = enfantDao.delete(unEnfant);
                if (check == true)
                {
                    MessageBox.Show("Enfant supprimé.");
                }
                else
                {
                    MessageBox.Show("Incident dans la suppression de l'enfant.");
                }
            }
            else
            {
                MessageBox.Show("Suppression annulée");
            }
            cbEnfants.DataSource    = EnfantDAO.findByEmploye((Int32)cbEmployes.SelectedValue);
            cbEnfants.DisplayMember = "Infos";
            cbEnfants.ValueMember   = "Id";
        }
コード例 #5
0
        public override string ToString()
        {
            string retour = "";

            if (TypeU == 2)
            {
                List <Enfant> lesEnfants = new List <Enfant>(EnfantDAO.findByEmploye(id));
                foreach (Enfant unEnfant in lesEnfants)
                {
                    retour += unEnfant.getPrenom() + "\t" + unEnfant.getAge() + "ans \n";
                }
            }
            else if (TypeU == 1)
            {
                retour = "id = " + id + "  mdp = " + mdp + "  type = " + TypeU;
            }
            return(retour);
        }
コード例 #6
0
        private void formResponsable_Load(object sender, EventArgs e)
        {
            cbEmployes.DataSource    = UtilisateurDAO.findAllEmployes();
            cbEmployes.DisplayMember = "Infos";
            cbEmployes.ValueMember   = "Id";

            cbEnfants.DataSource    = EnfantDAO.findByEmploye((Int32)cbEmployes.SelectedValue);
            cbEnfants.DisplayMember = "Infos";
            cbEnfants.ValueMember   = "Id";

            cbEmployeAff.DataSource    = UtilisateurDAO.findAllEmployes();
            cbEmployeAff.DisplayMember = "Infos";
            cbEmployeAff.ValueMember   = "Id";

            cbAffCateg.DataSource    = CategorieDAO.findAll();
            cbAffCateg.DisplayMember = "Infos";
            cbAffCateg.ValueMember   = "Id";

            cbCategJouet.DataSource    = CategorieDAO.findAll();
            cbCategJouet.DisplayMember = "Infos";
            cbCategJouet.ValueMember   = "Id";

            List <Jouet> lesJouets   = new List <Jouet>();
            CategorieDAO uneCategDAO = new CategorieDAO();
            Categorie    uneCateg    = uneCategDAO.find((int)cbCategJouet.SelectedValue);

            try { lesJouets = JouetDAO.findByCateg(uneCateg); }
            catch { MessageBox.Show("Problème avec la fonction pour trouver les jouets."); }
            try
            {
                Int32 i = 0;
                foreach (Jouet j in lesJouets)
                {
                    dGVJouets.Rows.Insert(i, j.getLibelle());
                    i++;
                }
            }
            catch
            {
                MessageBox.Show("Impossible d'afficher les jouets des enfants");
            }
        }
コード例 #7
0
 private void cbEmployes_SelectedIndexChanged(object sender, EventArgs e)
 {
     cbEnfants.DataSource    = EnfantDAO.findByEmploye((Int32)cbEmployes.SelectedValue);
     cbEnfants.DisplayMember = "Infos";
     cbEnfants.ValueMember   = "Id";
 }
コード例 #8
0
        private void button6_Click(object sender, EventArgs e)
        {
            int       id          = (Int32)cbEnfants.SelectedValue;
            int       idEmploye   = (Int32)cbEmployes.SelectedValue;
            EnfantDAO unEnfantDAO = new EnfantDAO();
            Enfant    unEnfant    = unEnfantDAO.find(id);

            if (tbModifAge.Text != "" && tbModifPrenom.Text != "")
            {
                string prenom = tbModifPrenom.Text;
                Int32  age    = 0;
                if (Int32.TryParse(tbModifAge.Text, out age))
                {
                    unEnfant.setAge(age);
                    unEnfant.setPrenom(prenom);
                    Boolean check = unEnfantDAO.update(unEnfant);
                    if (check == true)
                    {
                        MessageBox.Show("Enfant modifié.");
                    }
                    else
                    {
                        MessageBox.Show("Incident dans la modification de l'enfant.");
                    }
                }
            }
            else if (tbModifAge.Text != "")
            {
                Int32 age = 0;
                if (Int32.TryParse(tbModifAge.Text, out age))
                {
                    unEnfant.setAge(age);
                    Boolean check = unEnfantDAO.update(unEnfant);
                    if (check == true)
                    {
                        MessageBox.Show("Enfant modifié.");
                    }
                    else
                    {
                        MessageBox.Show("Incident dans la modification de l'enfant.");
                    }
                }
            }
            else if (tbModifPrenom.Text != "")
            {
                string prenom = tbModifPrenom.Text;
                unEnfant.setPrenom(prenom);
                Boolean check = unEnfantDAO.update(unEnfant);
                if (check == true)
                {
                    MessageBox.Show("Enfant modifié.");
                }
                else
                {
                    MessageBox.Show("Incident dans la modification de l'enfant.");
                }
            }
            else
            {
                MessageBox.Show("Veuillez remplir au moins un des champs ci-dessus.");
            }
            cbEnfants.DataSource    = EnfantDAO.findByEmploye((Int32)cbEmployes.SelectedValue);
            cbEnfants.DisplayMember = "Infos";
            cbEnfants.ValueMember   = "Id";
        }