コード例 #1
0
        public static ObservableCollection <Ordre_AchatDAO> selectOrdre_Achats()
        {
            ObservableCollection <Ordre_AchatDAO> l = new ObservableCollection <Ordre_AchatDAO>();
            string          query  = "SELECT * FROM ordre_achat ORDER BY id_ordre_achat ASC;";
            MySqlCommand    cmd    = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataReader reader = null;

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

                while (reader.Read())
                {
                    Ordre_AchatDAO p = new Ordre_AchatDAO(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetFloat(3), reader.GetString(4));
                    l.Add(p);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Il y a un problème dans la table Ordre_Achat : {0}", e.StackTrace);
            }
            reader.Close();
            return(l);
        }
コード例 #2
0
        public static Ordre_AchatViewModel getOrdre_Achat(int idOrdre_Achat)
        {
            Ordre_AchatDAO       pDAO = Ordre_AchatDAO.getOrdre_Achat(idOrdre_Achat);
            Ordre_AchatViewModel p    = new Ordre_AchatViewModel(pDAO.id_ordre_achat, pDAO.id_produit, pDAO.id_acheteur, pDAO.montant, pDAO.date_achat);

            return(p);
        }
コード例 #3
0
        public static void updateOrdre_Achat(Ordre_AchatDAO p)
        {
            string           query       = "UPDATE ordre_achat set id_produit=\"" + p.id_produit + "\", id_acheteur=\"" + p.id_acheteur + "\", montant=\"" + p.montant + "\", date_achat=\"" + p.date_achat + "\" where id_ordre_achat=" + p.id_ordre_achat + ";";
            MySqlCommand     cmd         = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd);

            cmd.ExecuteNonQuery();
        }
コード例 #4
0
        public static void insertOrdre_Achat(Ordre_AchatDAO p)
        {
            int              id          = getMaxIdOrdre_Achat() + 1;
            string           query       = "INSERT INTO ordre_achat VALUES (\"" + id + "\",\"" + p.id_produit + "\",\"" + p.id_acheteur + "\",\"" + p.montant + "\",\"" + p.date_achat + "\");";
            MySqlCommand     cmd2        = new MySqlCommand(query, DALConnection.OpenConnection());
            MySqlDataAdapter sqlDataAdap = new MySqlDataAdapter(cmd2);

            cmd2.ExecuteNonQuery();
        }
コード例 #5
0
        public static ObservableCollection <Ordre_AchatViewModel> listeOrdre_Achats()
        {
            ObservableCollection <Ordre_AchatDAO>       lDAO = Ordre_AchatDAO.listeOrdre_Achats();
            ObservableCollection <Ordre_AchatViewModel> l    = new ObservableCollection <Ordre_AchatViewModel>();

            foreach (Ordre_AchatDAO element in lDAO)
            {
                Ordre_AchatViewModel p = new Ordre_AchatViewModel(element.id_ordre_achat, element.id_produit, element.id_acheteur, element.montant, element.date_achat);
                l.Add(p);
            }
            return(l);
        }
コード例 #6
0
        public static Ordre_AchatDAO getOrdre_Achat(int idOrdre_Achat)
        {
            string       query = "SELECT * FROM ordre_achat WHERE id_ordre_achat=" + idOrdre_Achat + "\";";
            MySqlCommand cmd   = new MySqlCommand(query, DALConnection.OpenConnection());

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

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

            reader.Close();
            return(pers);
        }
コード例 #7
0
 public static void insertOrdre_Achat(Ordre_AchatViewModel p)
 {
     Ordre_AchatDAO.insertOrdre_Achat(new Ordre_AchatDAO(p.id, p.id_produit, p.id_acheteur, p.montant, p.date_achat));
 }
コード例 #8
0
 public static void supprimerOrdre_Achat(int id)
 {
     Ordre_AchatDAO.supprimerOrdre_Achat(id);
 }