Exemplo n.º 1
0
 public static void save(Attribuer attribuer)
 {
     if (attribuer.Id == 0)
     {
         OdbcCommand cmd = new OdbcCommand("insert into attribuer (Numero, DateDebut,DateFin,id_bus,id_chauffeur) values(?,?,?,?,?)", AccesBd.getConnection());
         cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value     = attribuer.Numero;
         cmd.Parameters.Add("@DateDebut", OdbcType.DateTime).Value = attribuer.DateDebut;
         cmd.Parameters.Add("@DateFin", OdbcType.DateTime).Value   = attribuer.DateFin;
         cmd.Parameters.Add("@idbus", OdbcType.VarChar).Value      = attribuer.bus.Numero;
         cmd.Parameters.Add("@idchau", OdbcType.VarChar).Value     = attribuer.chauffeur.Numero;
         cmd.ExecuteNonQuery();
         cmd.Dispose();
     }
     else
     {
         OdbcCommand cmd = new OdbcCommand("update attribuer set Numero=?,DateDebut=?,DateFin=?,id_bus=?,id_chauffeur=? where Id=?", AccesBd.getConnection());
         cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value     = attribuer.Numero;
         cmd.Parameters.Add("@DateDebut", OdbcType.DateTime).Value = attribuer.DateDebut;
         cmd.Parameters.Add("@DateFin", OdbcType.DateTime).Value   = attribuer.DateFin;
         cmd.Parameters.Add("@idbus", OdbcType.VarChar).Value      = attribuer.bus.Numero;
         cmd.Parameters.Add("@idchau", OdbcType.VarChar).Value     = attribuer.chauffeur.Numero;
         cmd.Parameters.Add("@id", OdbcType.Int).Value             = attribuer.Id;
         cmd.ExecuteNonQuery();
         cmd.Dispose();
     }
 }
Exemplo n.º 2
0
        public static List <Attribuer> findAll()
        {
            List <Attribuer> attribuers = new List <Attribuer>();
            OdbcCommand      cmd        = new OdbcCommand("select Id from attribuer", AccesBd.getConnection());
            OdbcDataReader   dr         = cmd.ExecuteReader();

            while (dr.Read())
            {
                Attribuer attribuer = find(dr.GetInt32(0));
                attribuers.Add(attribuer);
            }
            cmd.Dispose();
            return(attribuers);
        }
Exemplo n.º 3
0
        public static Attribuer findByNumero(string numero)
        {
            Attribuer   attribuer = null;
            OdbcCommand cmd       = new OdbcCommand("select * from attribuer where Numero=?", AccesBd.getConnection());

            cmd.Parameters.Add("@numero", OdbcType.VarChar).Value = numero;
            OdbcDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                attribuer = new Attribuer {
                    Id = dr.GetInt32(0), Numero = dr.GetString(1), DateDebut = dr.GetDateTime(2), DateFin = dr.GetDateTime(3), bus = BusDao.find(dr.GetInt32(4)), chauffeur = ChauffeurDao.find(dr.GetInt32(5))
                };
            }
            cmd.Dispose();
            return(attribuer);
        }