Пример #1
0
        public static ObservableCollection <CategorieDAO> selectCategories()
        {
            ObservableCollection <CategorieDAO> l = new ObservableCollection <CategorieDAO>();
            string          query  = "SELECT * FROM categorie;";
            MySqlCommand    cmd    = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataReader reader = null;

            try
            {
                cmd.ExecuteNonQuery();
                reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    CategorieDAO p = new CategorieDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2));
                    l.Add(p);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Il y a un problème dans la table Categorie : {0}", e.StackTrace);
            }
            reader.Close();
            return(l);
        }
Пример #2
0
        public static void updateCategorie(CategorieDAO p)
        {
            string           query       = "UPDATE categorie set nomCategorie=\"" + p.nomCategorieDAO + "\", descriptionCategorie=\"" + p.descriptionCategorieDAO + "\" where idCategorie=" + p.idCategorieDAO + ";";
            MySqlCommand     cmd         = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd);

            cmd.ExecuteNonQuery();
        }
Пример #3
0
        public static void insertCategorie(CategorieDAO p)
        {
            int              id          = getMaxIdCategorie() + 1;
            string           query       = "INSERT INTO categorie VALUES (\"" + id + "\",\"" + p.nomCategorieDAO + "\",\"" + p.descriptionCategorieDAO + "\");";
            MySqlCommand     cmd2        = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2);

            cmd2.ExecuteNonQuery();
        }
Пример #4
0
        public static CategorieViewModel getCategorie(int idCategorie)
        {
            CategorieDAO cDAO = CategorieDAO.getCategorie(idCategorie);

            //int idProduit = cDAO.idProduitCategorie;
            //ProduitViewModel pro = ProduitORM.getProduit(idProduit);

            CategorieViewModel c = new CategorieViewModel(cDAO.idCategorieDAO, cDAO.nomCategorieDAO,
                                                          cDAO.descriptionCategorieDAO);

            return(c);
        }
Пример #5
0
        public static CategorieDAO getCategorie(int idCategorie)
        {
            string       query = "SELECT * FROM Categorie WHERE id=" + idCategorie + ";";
            MySqlCommand cmd   = new MySqlCommand(query, DALConnection.OpenConnection());

            cmd.ExecuteNonQuery();
            MySqlDataReader reader = cmd.ExecuteReader();

            reader.Read();
            CategorieDAO pers = new CategorieDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2));

            reader.Close();
            return(pers);
        }
Пример #6
0
        public static ObservableCollection <CategorieViewModel> listeCategories()
        {
            ObservableCollection <CategorieDAO>       lDAO = CategorieDAO.listeCategories();
            ObservableCollection <CategorieViewModel> l    = new ObservableCollection <CategorieViewModel>();

            foreach (CategorieDAO element in lDAO)
            {
                //int idProduit = element.idProduitCategorieDAO;
                //ProduitViewModel pro = ProduitORM.getProduit(idProduit);

                CategorieViewModel c = new CategorieViewModel(element.idCategorieDAO, element.nomCategorieDAO,
                                                              element.descriptionCategorieDAO);
                l.Add(c);
            }

            return(l);
        }
Пример #7
0
 public static void insertCategorie(CategorieDAO p)
 {
     CategorieDAL.insertCategorie(p);
 }
Пример #8
0
 public static void updateCategorie(CategorieDAO p)
 {
     CategorieDAL.updateCategorie(p);
 }
Пример #9
0
        public static CategorieDAO getCategorie(int idCategorie)
        {
            CategorieDAO p = CategorieDAL.getCategorie(idCategorie);

            return(p);
        }
Пример #10
0
 public static void insertCategorie(CategorieViewModel c)
 {
     CategorieDAO.insertCategorie(new CategorieDAO(c.idCategorieProperty, c.nomCategorieProperty,
                                                   c.descriptionCategorieProperty));
 }
Пример #11
0
 public static void supprimerCategorie(int id)
 {
     CategorieDAO.supprimerCategorie(id);
 }