public static string generateKey() { int nbr = 0; string lastNumero = ""; OdbcCommand cmd = new OdbcCommand("select count(*) from bus", AccesBd.getConnection()); OdbcDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { nbr = dr.GetInt32(0); } cmd.Dispose(); if (nbr == 0) { lastNumero = "BU001"; } else { OdbcCommand cmd2 = new OdbcCommand("Select max(Numero) from bus", AccesBd.getConnection()); OdbcDataReader dr2 = cmd2.ExecuteReader(); if (dr2.Read()) { lastNumero = dr2.GetString(0); } cmd.Dispose(); lastNumero = lastNumero.Substring(2); int lastnbr = int.Parse(lastNumero); lastnbr++; lastNumero = "BU" + string.Format("{0:D3}", lastnbr); } return(lastNumero); }
public static void delete(int Id) { OdbcCommand cmd = new OdbcCommand("delete from paiement where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@id", OdbcType.Int).Value = Id; cmd.ExecuteNonQuery(); cmd.Dispose(); }
public static List <Carte> findAll() { List <Carte> cartes = new List <Carte>(); OdbcCommand cmd = new OdbcCommand("select Id from carte", AccesBd.getConnection()); OdbcDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Carte carte = find(dr.GetInt32(0)); cartes.Add(carte); } cmd.Dispose(); return(cartes); }
public static List <Paiement> findAll() { List <Paiement> paiements = new List <Paiement>(); OdbcCommand cmd = new OdbcCommand("select Id from paiement", AccesBd.getConnection()); OdbcDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Paiement paiement = find(dr.GetInt32(0)); paiements.Add(paiement); } cmd.Dispose(); return(paiements); }
public static List <Ligne> findAll() { List <Ligne> lignes = new List <Ligne>(); OdbcCommand cmd = new OdbcCommand("select Id from ligne", AccesBd.getConnection()); OdbcDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Ligne ligne = find(dr.GetInt32(0)); lignes.Add(ligne); } cmd.Dispose(); return(lignes); }
public static List <Bus> findAll() { List <Bus> buss = new List <Bus>(); OdbcCommand cmd = new OdbcCommand("select Id from bus", AccesBd.getConnection()); OdbcDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Bus bus = find(dr.GetInt32(0)); buss.Add(bus); } cmd.Dispose(); return(buss); }
public static List <Affecter> findAll() { List <Affecter> affecters = new List <Affecter>(); OdbcCommand cmd = new OdbcCommand("select Id from affecter", AccesBd.getConnection()); OdbcDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Affecter affecter = find(dr.GetInt32(0)); affecters.Add(affecter); } cmd.Dispose(); return(affecters); }
public static List <Droits> findAll() { List <Droits> droitss = new List <Droits>(); OdbcCommand cmd = new OdbcCommand("select Id from droits", AccesBd.getConnection()); OdbcDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Droits droits = find(dr.GetInt32(0)); droitss.Add(droits); } cmd.Dispose(); return(droitss); }
public static List <Points> findRecherche(string valu) { List <Points> points = new List <Points>(); OdbcCommand cmd = new OdbcCommand("select ? from point", AccesBd.getConnection()); cmd.Parameters.Add("@val", OdbcType.VarChar).Value = valu; OdbcDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { Points point = find(dr.GetInt32(0)); points.Add(point); } cmd.Dispose(); return(points); }
public static Ligne find(int Id) { Ligne ligne = null; OdbcCommand cmd = new OdbcCommand("select * from ligne where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@id", OdbcType.Int).Value = Id; OdbcDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { ligne = new Ligne { Id = dr.GetInt32(0), Numero = dr.GetString(1), Description = dr.GetString(2), Etat = dr.GetString(3), Distance = dr.GetString(4), PointD = dr.GetString(5), PointF = dr.GetString(6) }; } cmd.Dispose(); return(ligne); }
public static Bus findByNumero(string numero) { Bus bus = null; OdbcCommand cmd = new OdbcCommand("select * from bus where Numero=?", AccesBd.getConnection()); cmd.Parameters.Add("@id", OdbcType.VarChar).Value = numero; OdbcDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { bus = new Bus { Id = dr.GetInt32(0), Numero = dr.GetString(1), Type = dr.GetString(2), Marque = dr.GetString(3), Place = dr.GetString(4), Kilometrage = dr.GetString(5), Puissance = dr.GetString(6), Energie = dr.GetString(7), DateMise = dr.GetDateTime(9), CarteGrise = dr.GetString(10), Chassis = dr.GetString(11) }; } cmd.Dispose(); return(bus); }
public static Droits find(int Id) { Droits droits = null; OdbcCommand cmd = new OdbcCommand("select * from droits where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@id", OdbcType.Int).Value = Id; OdbcDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { droits = new Droits { Id = dr.GetInt32(0), admin = AdminDao.findByNumero(dr.GetString(1)), Table = dr.GetString(2), Consulter = dr.GetString(3), Ajouter = dr.GetString(4), Modifier = dr.GetString(5), Supprimer = dr.GetString(6) }; } cmd.Dispose(); return(droits); }
public static Points find(int Id) { Points point = null; OdbcCommand cmd = new OdbcCommand("select * from point where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@id", OdbcType.Int).Value = Id; OdbcDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { point = new Points { Id = dr.GetInt32(0), Numero = dr.GetString(1), Description = dr.GetString(2), coordonnee = dr.GetString(3), Etat = dr.GetString(4), ligne = LigneDao.findByNumero(dr.GetString(5)) }; } cmd.Dispose(); return(point); }
public static Carte find(int Id) { Carte carte = null; OdbcCommand cmd = new OdbcCommand("select * from carte where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@id", OdbcType.Int).Value = Id; OdbcDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { carte = new Carte { Id = dr.GetInt32(0), Numero = dr.GetString(1), DateCreation = dr.GetDate(2), DateExpiration = dr.GetDate(3), Type = dr.GetString(4), Code = dr.GetString(5), Porteur = dr.GetString(6), Solde = dr.GetInt32(7), SoldeMin = dr.GetInt32(8) }; } cmd.Dispose(); return(carte); }
public static Admin findUser(string user, string pass) { Admin administrateur = null; OdbcCommand cmd = new OdbcCommand("select * from administrateur where User=? and Password=? ", AccesBd.getConnection()); cmd.Parameters.Add("@numero", OdbcType.VarChar).Value = user; cmd.Parameters.Add("@pass", OdbcType.VarChar).Value = pass; OdbcDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { administrateur = new Admin { Id = dr.GetInt32(0), Numero = dr.GetString(1), Nom = dr.GetString(2), Prenom = dr.GetString(3), UserName = dr.GetString(4), Password = dr.GetString(5) }; } cmd.Dispose(); return(administrateur); }
public static void save(Admin administrateur) { if (administrateur.Id == 0) { OdbcCommand cmd = new OdbcCommand("insert into administrateur (Numero,Nom,Prenom,User, Password) values(?,?,?,?,?)", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = administrateur.Numero; cmd.Parameters.Add("@nom", OdbcType.VarChar).Value = administrateur.Nom; cmd.Parameters.Add("@prenom", OdbcType.VarChar).Value = administrateur.Prenom; cmd.Parameters.Add("@UserName", OdbcType.VarChar).Value = administrateur.UserName; cmd.Parameters.Add("@Password", OdbcType.VarChar).Value = administrateur.Password; cmd.ExecuteNonQuery(); cmd.Dispose(); } else { OdbcCommand cmd = new OdbcCommand("update administrateur set Numero=?,Nom=?,Prenom=?, User=?, Password=? where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = administrateur.Numero; cmd.Parameters.Add("@nom", OdbcType.VarChar).Value = administrateur.Nom; cmd.Parameters.Add("@prenom", OdbcType.VarChar).Value = administrateur.Prenom; cmd.Parameters.Add("@UserName", OdbcType.VarChar).Value = administrateur.UserName; cmd.Parameters.Add("@Password", OdbcType.VarChar).Value = administrateur.Password; cmd.Parameters.Add("@id", OdbcType.Int).Value = administrateur.Id; cmd.ExecuteNonQuery(); cmd.Dispose(); } }
public static List <Admin> findAll() { List <Admin> administrateurs = new List <Admin>(); OdbcCommand cmd = new OdbcCommand("select Id from administrateur", AccesBd.getConnection()); OdbcDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Admin administrateur = find(dr.GetInt32(0)); administrateurs.Add(administrateur); } cmd.Dispose(); return(administrateurs); }
public static void save(Chauffeur chauffeur) { if (chauffeur.Id == 0) { OdbcCommand cmd = new OdbcCommand("insert into chauffeur (Numero,Nom,Prenom, DateNaissance, Telephone, Adresse, Permis, Status) values(?,?,?,?,?,?,?,?)", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = chauffeur.Numero; cmd.Parameters.Add("@nom", OdbcType.VarChar).Value = chauffeur.Nom; cmd.Parameters.Add("@prenom", OdbcType.VarChar).Value = chauffeur.Prenom; cmd.Parameters.Add("@DateNais", OdbcType.DateTime).Value = chauffeur.DateNais; cmd.Parameters.Add("@Telephone", OdbcType.VarChar).Value = chauffeur.Telephone; cmd.Parameters.Add("@Adresse", OdbcType.VarChar).Value = chauffeur.Adresse; cmd.Parameters.Add("@Adresse", OdbcType.VarChar).Value = chauffeur.Permis; cmd.Parameters.Add("@Status", OdbcType.VarChar).Value = chauffeur.Status; cmd.ExecuteNonQuery(); cmd.Dispose(); } else { OdbcCommand cmd = new OdbcCommand("update chauffeur set Numero=?,Nom=?,Prenom=?, DateNaissance=?, Telephone=?, Adresse=?, Permis=?, Status=? where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = chauffeur.Numero; cmd.Parameters.Add("@nom", OdbcType.VarChar).Value = chauffeur.Nom; cmd.Parameters.Add("@prenom", OdbcType.VarChar).Value = chauffeur.Prenom; cmd.Parameters.Add("@DateNais", OdbcType.DateTime).Value = chauffeur.DateNais; cmd.Parameters.Add("@Telephone", OdbcType.VarChar).Value = chauffeur.Telephone; cmd.Parameters.Add("@Adresse", OdbcType.VarChar).Value = chauffeur.Adresse; cmd.Parameters.Add("@Adresse", OdbcType.VarChar).Value = chauffeur.Permis; cmd.Parameters.Add("@Status", OdbcType.VarChar).Value = chauffeur.Status; cmd.Parameters.Add("@id", OdbcType.Int).Value = chauffeur.Id; cmd.ExecuteNonQuery(); cmd.Dispose(); } }
public static Affecter findByNumero(string numero) { Affecter affecter = null; OdbcCommand cmd = new OdbcCommand("select * from affecter where Numero=?", AccesBd.getConnection()); cmd.Parameters.Add("@numero", OdbcType.VarChar).Value = numero; OdbcDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { affecter = new Affecter { Id = dr.GetInt32(0), Numero = dr.GetString(1), DateDebut = dr.GetDateTime(2), DateFin = dr.GetDateTime(3), ligne = LigneDao.findByNumero(dr.GetString(4)), bus = BusDao.findByNumero(dr.GetString(5)) }; } cmd.Dispose(); return(affecter); }
public static List <Chauffeur> findAll() { List <Chauffeur> chauffeurs = new List <Chauffeur>(); OdbcCommand cmd = new OdbcCommand("select Id from chauffeur", AccesBd.getConnection()); OdbcDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Chauffeur chauffeur = find(dr.GetInt32(0)); chauffeurs.Add(chauffeur); } cmd.Dispose(); return(chauffeurs); }
public static Paiement find(int Id) { Paiement paiement = null; OdbcCommand cmd = new OdbcCommand("select * from paiement where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@id", OdbcType.Int).Value = Id; OdbcDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { paiement = new Paiement { Id = dr.GetInt32(0), Montant = dr.GetInt32(1), Description = dr.GetString(2), Date = dr.GetDateTime(3), Lieu = dr.GetString(4) }; } cmd.Dispose(); return(paiement); }
public static void Recharge(Carte carte) { OdbcCommand cmd = new OdbcCommand("update carte set Solde=? where Numero=?", AccesBd.getConnection()); cmd.Parameters.Add("@Adresse", OdbcType.Double).Value = carte.Solde; cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = carte.Numero; cmd.ExecuteNonQuery(); cmd.Dispose(); }
public static Chauffeur findByNumero(string Numero) { Chauffeur chauffeur = null; OdbcCommand cmd = new OdbcCommand("select * from chauffeur where Numero=?", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = Numero; OdbcDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { chauffeur = new Chauffeur { Id = dr.GetInt32(0), Numero = dr.GetString(1), Nom = dr.GetString(2), Prenom = dr.GetString(3), DateNais = dr.GetDate(4), Telephone = dr.GetString(5), Adresse = dr.GetString(6), Permis = dr.GetString(6), Status = dr.GetString(7) }; } cmd.Dispose(); return(chauffeur); }
public static List <Carte> findby(string tab, string val) { List <Carte> cartes = new List <Carte>(); OdbcCommand cmd = new OdbcCommand("select Id from Carte where " + tab + " LIKE('%" + val + "%') ", AccesBd.getConnection()); OdbcDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Carte chau = find(dr.GetInt32(0)); cartes.Add(chau); } cmd.Dispose(); return(cartes); }
public static void save(Points point) { if (point.Id == 0) { OdbcCommand cmd = new OdbcCommand("insert into point (Numero, Description,coordonnee, Etat, Ligne) values(?,?,?,?)", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = point.Numero; cmd.Parameters.Add("@Description", OdbcType.VarChar).Value = point.Description; cmd.Parameters.Add("@coordonnee", OdbcType.VarChar).Value = point.coordonnee; cmd.Parameters.Add("@Etat", OdbcType.VarChar).Value = point.Etat; cmd.Parameters.Add("@ligne", OdbcType.VarChar).Value = point.ligne.Numero; cmd.ExecuteNonQuery(); cmd.Dispose(); } else { OdbcCommand cmd = new OdbcCommand("update point set Numero=?, Description=?,coordonnee=?,Etat=?,Ligne=? where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = point.Numero; cmd.Parameters.Add("@Description", OdbcType.VarChar).Value = point.Description; cmd.Parameters.Add("@coordonnee", OdbcType.VarChar).Value = point.coordonnee; cmd.Parameters.Add("@Etat", OdbcType.VarChar).Value = point.Etat; cmd.Parameters.Add("@ligne", OdbcType.VarChar).Value = point.ligne.Numero; cmd.Parameters.Add("@id", OdbcType.Int).Value = point.Id; cmd.ExecuteNonQuery(); cmd.Dispose(); } }
public static void save(Paiement paiement) { if (paiement.Id == 0) { OdbcCommand cmd = new OdbcCommand("insert into paiement (Montant,Description,Date, Lieu) values(?,?,?,?)", AccesBd.getConnection()); cmd.Parameters.Add("@Montant", OdbcType.VarChar).Value = paiement.Montant; cmd.Parameters.Add("@Description", OdbcType.VarChar).Value = paiement.Description; cmd.Parameters.Add("@Date", OdbcType.DateTime).Value = paiement.Date; cmd.Parameters.Add("@Lieu", OdbcType.VarChar).Value = paiement.Lieu; cmd.ExecuteNonQuery(); cmd.Dispose(); } else { OdbcCommand cmd = new OdbcCommand("update paiement set Montant=?,DateCreation=?,Date=?, Type=? where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@Montant", OdbcType.VarChar).Value = paiement.Montant; cmd.Parameters.Add("@Description", OdbcType.VarChar).Value = paiement.Description; cmd.Parameters.Add("@Date", OdbcType.DateTime).Value = paiement.Date; cmd.Parameters.Add("@Lieu", OdbcType.VarChar).Value = paiement.Lieu; cmd.Parameters.Add("@id", OdbcType.Int).Value = paiement.Id; cmd.ExecuteNonQuery(); cmd.Dispose(); } }
public static void save(Bus bus) { if (bus.Id == 0) { OdbcCommand cmd = new OdbcCommand("insert into bus (Numero,Type,Marque, Places, Kilometrage, Puissance, Energie, DateMise, CarteGrise, Chassis) values(?,?,?,?,?,?,?,?,?,?)", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = bus.Numero; cmd.Parameters.Add("@Type", OdbcType.VarChar).Value = bus.Type; cmd.Parameters.Add("@Marque", OdbcType.VarChar).Value = bus.Marque; cmd.Parameters.Add("@Place", OdbcType.VarChar).Value = bus.Place; cmd.Parameters.Add("@Kilometrage", OdbcType.VarChar).Value = bus.Kilometrage; cmd.Parameters.Add("@Puissance", OdbcType.VarChar).Value = bus.Puissance; cmd.Parameters.Add("@Energie", OdbcType.VarChar).Value = bus.Energie; cmd.Parameters.Add("@DateMise", OdbcType.DateTime).Value = bus.DateMise; cmd.Parameters.Add("@CarteGrise", OdbcType.VarChar).Value = bus.CarteGrise; cmd.Parameters.Add("@Chassis", OdbcType.VarChar).Value = bus.Chassis; cmd.ExecuteNonQuery(); cmd.Dispose(); } else { OdbcCommand cmd = new OdbcCommand("update bus set Numero=?,Type=?,Marque=?, Places=?, Kilometrage=?, Puissance=?, Energie=?, DateMise=?, CarteGrise=?, Chassis=? where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = bus.Numero; cmd.Parameters.Add("@Type", OdbcType.VarChar).Value = bus.Type; cmd.Parameters.Add("@Marque", OdbcType.VarChar).Value = bus.Marque; cmd.Parameters.Add("@Place", OdbcType.VarChar).Value = bus.Place; cmd.Parameters.Add("@Kilometrage", OdbcType.VarChar).Value = bus.Kilometrage; cmd.Parameters.Add("@Puissance", OdbcType.VarChar).Value = bus.Puissance; cmd.Parameters.Add("@Energie", OdbcType.VarChar).Value = bus.Energie; cmd.Parameters.Add("@DateMise", OdbcType.DateTime).Value = bus.DateMise; cmd.Parameters.Add("@CarteGrise", OdbcType.VarChar).Value = bus.CarteGrise; cmd.Parameters.Add("@Chassis", OdbcType.VarChar).Value = bus.Chassis; cmd.Parameters.Add("@id", OdbcType.Int).Value = bus.Id; cmd.ExecuteNonQuery(); cmd.Dispose(); } }
public static void save(Affecter affecter) { if (affecter.Id == 0) { OdbcCommand cmd = new OdbcCommand("insert into affecter (Numero, DateDebut,DateFin,id_ligne,id_bus) values(?,?,?,?,?)", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = affecter.Numero; cmd.Parameters.Add("@DateDebut", OdbcType.DateTime).Value = affecter.DateDebut; cmd.Parameters.Add("@DateFin", OdbcType.DateTime).Value = affecter.DateFin; cmd.Parameters.Add("@idlig", OdbcType.VarChar).Value = affecter.ligne.Numero; cmd.Parameters.Add("@idbus", OdbcType.VarChar).Value = affecter.bus.Numero; cmd.ExecuteNonQuery(); cmd.Dispose(); } else { OdbcCommand cmd = new OdbcCommand("update affecter Numero=?, DateDebut=?,DateFin=?,id_ligne=?,id_bus=? where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = affecter.Numero; cmd.Parameters.Add("@DateDebut", OdbcType.DateTime).Value = affecter.DateDebut; cmd.Parameters.Add("@DateFin", OdbcType.DateTime).Value = affecter.DateFin; cmd.Parameters.Add("@idlig", OdbcType.VarChar).Value = affecter.ligne.Numero; cmd.Parameters.Add("@idbus", OdbcType.VarChar).Value = affecter.bus.Numero; cmd.Parameters.Add("@id", OdbcType.Int).Value = affecter.Id; cmd.ExecuteNonQuery(); cmd.Dispose(); } }
public static void save(Carte carte) { if (carte.Id == 0) { OdbcCommand cmd = new OdbcCommand("insert into carte (Numero,DateCreation,DateExpiration, Type, Code, Porteur, Solde,SoldeMin) values(?,?,?,?,?,?,?,?)", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = carte.Numero; cmd.Parameters.Add("@nom", OdbcType.DateTime).Value = carte.DateCreation; cmd.Parameters.Add("@prenom", OdbcType.DateTime).Value = carte.DateExpiration; cmd.Parameters.Add("@DateNais", OdbcType.VarChar).Value = carte.Type; cmd.Parameters.Add("@Telephone", OdbcType.VarChar).Value = carte.Code; cmd.Parameters.Add("@porteur", OdbcType.VarChar).Value = carte.Porteur; cmd.Parameters.Add("@sol", OdbcType.Double).Value = carte.Solde; cmd.Parameters.Add("@min", OdbcType.Double).Value = carte.SoldeMin; cmd.ExecuteNonQuery(); cmd.Dispose(); } else { OdbcCommand cmd = new OdbcCommand("update carte set Numero=?,DateCreation=?,DateExpiration=?, Type=?, Code=?, Porteur=?, Solde=?, SoldeMin=? where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = carte.Numero; cmd.Parameters.Add("@nom", OdbcType.DateTime).Value = carte.DateCreation; cmd.Parameters.Add("@prenom", OdbcType.DateTime).Value = carte.DateExpiration; cmd.Parameters.Add("@DateNais", OdbcType.VarChar).Value = carte.Type; cmd.Parameters.Add("@Telephone", OdbcType.VarChar).Value = carte.Code; cmd.Parameters.Add("@porteur", OdbcType.VarChar).Value = carte.Porteur; cmd.Parameters.Add("@sol", OdbcType.Double).Value = carte.Solde; cmd.Parameters.Add("@min", OdbcType.Double).Value = carte.SoldeMin; cmd.Parameters.Add("@id", OdbcType.Int).Value = carte.Id; cmd.ExecuteNonQuery(); cmd.Dispose(); } }
public static void save(Ligne ligne) { if (ligne.Id == 0) { OdbcCommand cmd = new OdbcCommand("insert into ligne (Numero,Description,Etat, Distance, PointD, PointF) values(?,?,?,?,?,?)", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = ligne.Numero; cmd.Parameters.Add("@Description", OdbcType.VarChar).Value = ligne.Description; cmd.Parameters.Add("@Etat", OdbcType.VarChar).Value = ligne.Etat; cmd.Parameters.Add("@Distance", OdbcType.VarChar).Value = ligne.Distance; cmd.Parameters.Add("@Etat", OdbcType.VarChar).Value = ligne.PointD; cmd.Parameters.Add("@Distance", OdbcType.VarChar).Value = ligne.PointF; cmd.ExecuteNonQuery(); cmd.Dispose(); } else { OdbcCommand cmd = new OdbcCommand("update ligne set Numero=?,Description=?,Etat=?, Distance=?, PointD=?, PointF=?where Id=?", AccesBd.getConnection()); cmd.Parameters.Add("@Numero", OdbcType.VarChar).Value = ligne.Numero; cmd.Parameters.Add("@Description", OdbcType.VarChar).Value = ligne.Description; cmd.Parameters.Add("@Etat", OdbcType.VarChar).Value = ligne.Etat; cmd.Parameters.Add("@Distance", OdbcType.VarChar).Value = ligne.Distance; cmd.Parameters.Add("@Etat", OdbcType.VarChar).Value = ligne.PointD; cmd.Parameters.Add("@Distance", OdbcType.VarChar).Value = ligne.PointF; cmd.Parameters.Add("@id", OdbcType.Int).Value = ligne.Id; cmd.ExecuteNonQuery(); cmd.Dispose(); } }