예제 #1
0
        //Delete
        public override bool delete(Categorie uneCategorie)
        {
            List <Jouet> sesJouets = JouetDAO.findByCateg(uneCategorie);

            if (sesJouets.Count() != 0)
            {
                try
                {
                    JouetDAO unDAO = new JouetDAO();
                    foreach (Jouet j in sesJouets)
                    {
                        unDAO.delete(j);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Oups: " + ex);
                }
            }
            Boolean retour = false;

            try
            {
                String     requete    = "DELETE FROM Categorie WHERE id =" + uneCategorie.getId();
                SqlCommand maCommande = new SqlCommand(requete, seConnecter());
                Int32      resultat   = maCommande.ExecuteNonQuery();
                retour = true;
            }
            catch (Exception ex)
            {
                throw new Exception("Oups: " + ex);
            }
            return(retour);
        }
예제 #2
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");
            }
        }
예제 #3
0
        private void cbCategJouet_SelectedIndexChanged(object sender, EventArgs e)
        {
            dGVJouets.Rows.Clear();
            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");
            }
        }