Exemplo n.º 1
0
        public Bouteilles Lister(Pays p)
        {
            Bouteilles liste = new Bouteilles();

            con.Open();
            try
            {
                IDbCommand com = con.CreateCommand();
                com.CommandText = "SELECT * FROM Bouteille WHERE IdCasier=" + p.Id.ToString();
                IDataReader reader = com.ExecuteReader();
                while (reader.Read())
                {
                    Bouteille b = reader2Bouteille(reader);
                    liste.Ajouter(b);
                }
            }
            finally
            {
                con.Close();
            }
            return(liste);
        }
Exemplo n.º 2
0
        public Bouteilles Chercher(Bouteille b)
        {
            Bouteilles liste  = new Bouteilles();
            String     IdType = null;

            if (b.IdType != 0)
            {
                IdType = b.IdType.ToString();
            }
            String IdRegion = null;

            if (b.IdRegion != 0)
            {
                IdRegion = b.IdRegion.ToString();
            }
            String IdDomaine = null;

            if (b.IdDomaine != 0)
            {
                IdDomaine = b.IdDomaine.ToString();
            }
            String IdContenance = null;

            if (b.IdContenance != 0)
            {
                IdContenance = b.IdContenance.ToString();
            }
            String IdCru = null;

            if (b.IdCru != 0)
            {
                IdCru = b.IdCru.ToString();
            }
            String IdMillesime = null;

            if (b.IdMillesime != 0)
            {
                IdMillesime = b.IdMillesime.ToString();
            }
            String IdType_vinification = null;

            if (b.IdType_vinification != 0)
            {
                IdType_vinification = b.IdType_vinification.ToString();
            }
            String IdAppelation = null;

            if (b.IdAppelation != 0)
            {
                IdAppelation = b.IdAppelation.ToString();
            }
            String IdPays = null;

            if (b.IdPays != 0)
            {
                IdPays = b.IdPays.ToString();
            }

            con.Open();
            try
            {
                IDbCommand com = con.CreateCommand();
                com.CommandText = "SELECT * FROM Bouteille LEFT JOIN Casier ON(Bouteille.IdCasier = Casier.idCasier) LEFT JOIN Type ON(Bouteille.IdType = Type.idType) LEFT JOIN Region ON(Bouteille.IdRegion = Region.IdRegion) LEFT JOIN Pays ON(Bouteille.IdPays = Pays.idPays) LEFT JOIN Domaine ON(Bouteille.IdPays = Pays.idPays) LEFT JOIN Contenance ON(Bouteille.IdContenance = Contenance.idContenance) LEFT JOIN Cru ON(Bouteille.IdCru = Cru.idCru) LEFT JOIN Millesime ON(Bouteille.IdMillesime = Millesime.idMillesime) LEFT JOIN Type_vinification ON(Bouteille.IdVinif = Type_vinification.IdVinif) LEFT JOIN Appelation ON(Bouteille.IdAppelation = Appelation.idAppelation)  Where ";
                if (b.IdType != 0)
                {
                    com.CommandText += " Bouteille.`IdType` = " + IdType + " AND ";
                }
                if (b.IdRegion != 0)
                {
                    com.CommandText += " Bouteille.`IdRegion` = '" + IdRegion + "' AND ";
                }
                if (b.IdDomaine != 0)
                {
                    com.CommandText += " Bouteille.`IdDomaine`= '" + IdDomaine + "' AND ";
                }
                if (b.IdContenance != 0)
                {
                    com.CommandText += " Bouteille.`IdContenance` = '" + IdContenance + "' AND ";
                }
                if (b.IdCru != 0)
                {
                    com.CommandText += " Bouteille.`IdCru` = '" + IdCru + "' AND ";
                }
                if (b.IdMillesime != 0)
                {
                    com.CommandText += " Bouteille.`IdMillesime` = '" + IdMillesime + "' AND ";
                }
                if (b.IdType_vinification != 0)
                {
                    com.CommandText += " Bouteille.`IdVinif` = '" + IdType + "' AND ";
                }
                if (b.IdAppelation != 0)
                {
                    com.CommandText += " Bouteille.`IdAppelation` = '" + IdType_vinification + "' AND ";
                }
                if (b.IdPays != 0)
                {
                    com.CommandText += " Bouteille.`IdPays` = '" + IdPays + "' AND ";
                }
                com.CommandText += "1 = 1;";
                IDataReader reader = com.ExecuteReader();
                while (reader.Read())
                {
                    Bouteille bo = reader2BouteilleRecherche(reader);
                    liste.Ajouter(bo);
                }
            }
            finally
            {
                con.Close();
            }
            return(liste);
        }