Exemplo n.º 1
0
        public static ObservableCollection <ProduitDAO> selectProduits()
        {
            ObservableCollection <ProduitDAO> l = new ObservableCollection <ProduitDAO>();
            string          query  = "SELECT * FROM produit;";
            MySqlCommand    cmd    = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataReader reader = null;

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

                while (reader.Read())
                {
                    ProduitDAO p = new ProduitDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2),
                                                  reader.GetDouble(3), reader.GetDouble(4), reader.GetInt32(5),
                                                  reader.GetInt32(6), reader.GetDouble(7), reader.GetInt32(8),
                                                  reader.GetInt32(9), reader.GetInt32(10), reader.GetInt32(11));
                    l.Add(p);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Il y a un problème dans la table Produit : {0}", e.StackTrace);
            }
            reader.Close();
            return(l);
        }
Exemplo n.º 2
0
 public static void insertProduit(ProduitViewModel p)
 {
     ProduitDAO.insertProduit(new ProduitDAO(p.idProduitProperty, p.nomProduitProperty,
                                             p.descriptionProduitProperty,
                                             p.prixReserveProperty, p.prixDepartProperty, p.estVenduProperty, p.estVenduProperty,
                                             p.prixVenteProperty, p.nbInvenduProperty,
                                             p.utilisateurProduitProperty.idPersonneUtilisateurProperty,
                                             p.stockageProduitProperty.idStockageProperty, p.lotProduitProperty.idLotProperty));
 }
Exemplo n.º 3
0
        public static void insertProduit(ProduitDAO p)
        {
            int id = getMaxIdProduit() + 1;

            string           query       = "INSERT INTO produit VALUES (\"" + id + "\",\"" + p.nomProduitDAO + "\",\"" + p.descriptionProduitDAO + "\", \"" + p.prixReserveDAO + "\", \"" + p.prixDepartDAO + "\",\"" + p.estVenduDAO + "\",\"" + p.enStockDAO + "\",\"" + p.prixVenteDAO + "\",\"" + p.nbInvenduDAO + "\",\"" + p.idUtilisateurProduitDAO + "\",\"" + p.idLotProduitDAO + "\",\"" + p.idStockageProduitDAO + "\");";
            MySqlCommand     cmd2        = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2);

            cmd2.ExecuteNonQuery();
        }
Exemplo n.º 4
0
        public static void updateProduit(ProduitDAO p)
        {
            string query = "UPDATE produit set nomProduit=\"" + p.nomProduitDAO + "\", descriptionProduit=\"" + p.descriptionProduitDAO + "\", prixReserveDAO=\""
                           + p.prixReserveDAO + "\", prixDepartDAO=\"" + p.prixDepartDAO + "\", estVenduDAO=\"" + p.estVenduDAO + "\", enStockDAO=\""
                           + p.enStockDAO + "\", prixVenteDAO=\"" + p.prixVenteDAO + "\", nbInvenduDAO=\"" + p.nbInvenduDAO + "\", idUtilisateurProduitDAO=\""
                           + p.idUtilisateurProduitDAO + "\", idLotProduitDAO=\""
                           + p.idLotProduitDAO + "\", idStockageProduit=\"" + p.idStockageProduitDAO + "\" where idProduit=" + p.idProduitDAO + ";";

            MySqlCommand     cmd         = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd);

            cmd.ExecuteNonQuery();
        }
Exemplo n.º 5
0
        public static ProduitDAO getProduit(int idProduit)
        {
            string       query = "SELECT * FROM produit WHERE id=" + idProduit + ";";
            MySqlCommand cmd   = new MySqlCommand(query, DALConnection.OpenConnection());

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

            reader.Read();
            ProduitDAO pers = new ProduitDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2),
                                             reader.GetDouble(3), reader.GetDouble(4), reader.GetInt32(5),
                                             reader.GetInt32(6), reader.GetDouble(7), reader.GetInt32(8),
                                             reader.GetInt32(9), reader.GetInt32(10), reader.GetInt32(11));

            reader.Close();
            return(pers);
        }
Exemplo n.º 6
0
        public static ProduitViewModel getProduit(int idProduit)
        {
            ProduitDAO pDAO = ProduitDAO.getProduit(idProduit);

            int idUtilisateur      = pDAO.idUtilisateurProduitDAO;
            UtilisateurViewModel u = UtilisateurORM.getUtilisateur(idUtilisateur);

            int idStockage        = pDAO.idStockageProduitDAO;
            StockageViewModel sto = StockageORM.getStockage(idStockage);

            int          idLot = pDAO.idLotProduitDAO;
            LotViewModel l     = LotORM.getLot(idLot);

            ProduitViewModel p = new ProduitViewModel(pDAO.idProduitDAO, pDAO.nomProduitDAO, pDAO.descriptionProduitDAO,
                                                      pDAO.prixReserveDAO, pDAO.prixDepartDAO, pDAO.estVenduDAO, pDAO.enStockDAO,
                                                      pDAO.prixVenteDAO, pDAO.nbInvenduDAO, u, sto, l);

            return(p);
        }
Exemplo n.º 7
0
        public static ObservableCollection <ProduitViewModel> listeProduits()
        {
            ObservableCollection <ProduitDAO>       lDAO = ProduitDAO.listeProduits();
            ObservableCollection <ProduitViewModel> l    = new ObservableCollection <ProduitViewModel>();

            foreach (ProduitDAO element in lDAO)
            {
                int idUtilisateur = element.idUtilisateurProduitDAO;
                int idStockage    = element.idStockageProduitDAO;
                int idLot         = element.idLotProduitDAO;

                UtilisateurViewModel u   = UtilisateurORM.getUtilisateur(idUtilisateur); // Plus propre que d'aller chercher le métier dans la DAO.
                StockageViewModel    sto = StockageORM.getStockage(idStockage);
                LotViewModel         lo  = LotORM.getLot(idLot);

                ProduitViewModel p = new ProduitViewModel(element.idProduitDAO, element.nomProduitDAO,
                                                          element.descriptionProduitDAO, element.prixReserveDAO, element.prixDepartDAO, element.estVenduDAO,
                                                          element.enStockDAO, element.prixVenteDAO, element.nbInvenduDAO, u, sto, lo);
                l.Add(p);
            }

            return(l);
        }
Exemplo n.º 8
0
 public static void insertProduit(ProduitDAO p)
 {
     ProduitDAL.insertProduit(p);
 }
Exemplo n.º 9
0
 public static void updateProduit(ProduitDAO p)
 {
     ProduitDAL.updateProduit(p);
 }
Exemplo n.º 10
0
        public static ProduitDAO getProduit(int idProduit)
        {
            ProduitDAO p = ProduitDAL.getProduit(idProduit);

            return(p);
        }
Exemplo n.º 11
0
 public static void supprimerProduit(int id)
 {
     ProduitDAO.supprimerProduit(id);
 }