Ejemplo n.º 1
0
        public static ObservableCollection <PhotoDAO> selectPhotos()
        {
            ObservableCollection <PhotoDAO> l = new ObservableCollection <PhotoDAO>();
            string          query             = "SELECT * FROM photo;";
            MySqlCommand    cmd    = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataReader reader = null;

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

                while (reader.Read())
                {
                    PhotoDAO p = new PhotoDAO(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3));
                    l.Add(p);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Il y a un problème dans la table Photo : {0}", e.StackTrace);
            }
            reader.Close();
            return(l);
        }
Ejemplo n.º 2
0
        public static void updatePhoto(PhotoDAO p)
        {
            string           query       = "UPDATE photo set nomPhoto=\"" + p.nomPhotoDAO + "\", lienPhoto=\"" + p.lienPhotoDAO + "\", idProduit=\"" + p.idProduitDAO + "\" where idPhoto=" + p.idPhotoDAO + ";";
            MySqlCommand     cmd         = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd);

            cmd.ExecuteNonQuery();
        }
Ejemplo n.º 3
0
        public static void insertPhoto(PhotoDAO p)
        {
            int id = getMaxIdPhoto() + 1;

            string           query       = "INSERT INTO photo VALUES (\"" + id + "\",\"" + p.nomPhotoDAO + "\",\"" + p.lienPhotoDAO + "\",\"" + p.idProduitDAO + "\");";
            MySqlCommand     cmd2        = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2);

            cmd2.ExecuteNonQuery();
        }
Ejemplo n.º 4
0
        public static PhotoViewModel getPhoto(int idPhoto)
        {
            PhotoDAO phDAO = PhotoDAO.getPhoto(idPhoto);

            int idProduit        = phDAO.idProduitDAO;
            ProduitViewModel pro = ProduitORM.getProduit(idProduit);

            PhotoViewModel ph = new PhotoViewModel(phDAO.idPhotoDAO, phDAO.nomPhotoDAO, phDAO.lienPhotoDAO, pro);

            return(ph);
        }
Ejemplo n.º 5
0
        public static PhotoDAO getPhoto(int idPhoto)
        {
            string       query = "SELECT * FROM photo WHERE id=" + idPhoto + ";";
            MySqlCommand cmd   = new MySqlCommand(query, DALConnection.OpenConnection());

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

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

            reader.Close();
            return(pers);
        }
Ejemplo n.º 6
0
        public static ObservableCollection <PhotoViewModel> listePhotos()
        {
            ObservableCollection <PhotoDAO>       lDAO = PhotoDAO.listePhotos();
            ObservableCollection <PhotoViewModel> l    = new ObservableCollection <PhotoViewModel>();

            foreach (PhotoDAO element in lDAO)
            {
                int idProduit        = element.idProduitDAO;
                ProduitViewModel pro = ProduitORM.getProduit(idProduit);

                PhotoViewModel ph =
                    new PhotoViewModel(element.idPhotoDAO, element.nomPhotoDAO, element.lienPhotoDAO, pro);
                l.Add(ph);
            }

            return(l);
        }
Ejemplo n.º 7
0
 public static void insertPhoto(PhotoViewModel ph)
 {
     PhotoDAO.insertPhoto(new PhotoDAO(ph.idPhotoProperty, ph.nomPhotoProperty, ph.lienPhotoProperty,
                                       ph.idProduitProperty.idProduitProperty));
 }
Ejemplo n.º 8
0
 public static void supprimerPhoto(int id)
 {
     PhotoDAO.supprimerPhoto(id);
 }
Ejemplo n.º 9
0
 public static void insertPhoto(PhotoDAO p)
 {
     PhotoDAL.insertPhoto(p);
 }
Ejemplo n.º 10
0
 public static void updatePhoto(PhotoDAO p)
 {
     PhotoDAL.updatePhoto(p);
 }
Ejemplo n.º 11
0
        public static PhotoDAO getPhoto(int idPhoto)
        {
            PhotoDAO p = PhotoDAL.getPhoto(idPhoto);

            return(p);
        }