public int AjoutEvent(Evenementiel unEvent) { string strSQL = ""; int nbEnreg = 0; SqlConnection cnx = Connexion.GetObjConnexion(); SqlCommand maCommande; maCommande = new SqlCommand("", cnx); strSQL = "insert into Evenementiel values (@nom, @rue, @telephone, @mail, @site, @ville)"; maCommande.CommandText = strSQL; maCommande.Parameters.Add("nom", SqlDbType.VarChar); maCommande.Parameters[0].Value = unEvent.Nom; maCommande.Parameters.Add("rue", SqlDbType.VarChar); maCommande.Parameters[1].Value = unEvent.Rue; maCommande.Parameters.Add("telephone", SqlDbType.VarChar); maCommande.Parameters[2].Value = unEvent.Telephone; maCommande.Parameters.Add("mail", SqlDbType.VarChar); maCommande.Parameters[3].Value = unEvent.Mail; maCommande.Parameters.Add("site", SqlDbType.VarChar); maCommande.Parameters[4].Value = unEvent.Site; maCommande.Parameters.Add("ville", SqlDbType.Int); maCommande.Parameters[5].Value = unEvent.LaVille.Id; nbEnreg = maCommande.ExecuteNonQuery(); return(nbEnreg); }
public int AjoutArtiste(Artiste unArtiste) { string nomArtiste; string site; int nbAjout = 0; int idCourant = 0; // on récupère l'objet responsable de la connexion à la base SqlConnection cnx = Connexion.GetObjConnexion(); maCommand = new SqlCommand(); maCommand.Connection = cnx; // requête SQL execution maCommand.CommandText = "ajoutartiste"; maCommand.CommandType = System.Data.CommandType.StoredProcedure; nomArtiste = unArtiste.Nom; site = unArtiste.Site; idCourant = unArtiste.LeCourant.Id; maCommand.Parameters.Add("nom", System.Data.SqlDbType.VarChar); maCommand.Parameters.Add("site", System.Data.SqlDbType.VarChar); maCommand.Parameters.Add("idCourant", System.Data.SqlDbType.Int); maCommand.Parameters[0].Value = nomArtiste; maCommand.Parameters[1].Value = site; maCommand.Parameters[2].Value = idCourant; nbAjout = maCommand.ExecuteNonQuery(); return(nbAjout); }
public int AjoutCampagne(Campagne uneCampagne) { int nbEnreg = 0; SqlConnection cnx = Connexion.GetObjConnexion(); SqlCommand maCommande; maCommande = new SqlCommand("", cnx); maCommande.CommandType = CommandType.StoredProcedure; maCommande.CommandText = "ajoutcampagne"; maCommande.Parameters.Add("intitule", SqlDbType.VarChar); maCommande.Parameters[0].Value = uneCampagne.Intitule; maCommande.Parameters.Add("objectif", SqlDbType.VarChar); maCommande.Parameters[1].Value = uneCampagne.Objectif; maCommande.Parameters.Add("dateDebut", SqlDbType.DateTime); maCommande.Parameters[2].Value = uneCampagne.DateDebut; maCommande.Parameters.Add("dateFin", SqlDbType.DateTime); maCommande.Parameters[3].Value = uneCampagne.DateFin; maCommande.Parameters.Add("evenementiel", SqlDbType.Int); maCommande.Parameters[4].Value = uneCampagne.LEvenementiel.Id; maCommande.Parameters.Add("communication", SqlDbType.Int); maCommande.Parameters[5].Value = uneCampagne.LaCommunication.Id; maCommande.Parameters.Add("categPublic", SqlDbType.Int); maCommande.Parameters[6].Value = uneCampagne.LaCategPublic.Id; maCommande.Parameters.Add("utilisateur", SqlDbType.Int); maCommande.Parameters[7].Value = uneCampagne.LUtilisateur; nbEnreg = maCommande.ExecuteNonQuery(); return(nbEnreg); }
public int AjoutEvenement(Evenement unEvenement) { string strSQL; int nbEnreg = 0; //on récupère l'objet responsable de la connexion à la base SqlConnection cnx = Connexion.GetObjConnexion(); //création de l'objet de type SqlCommand SqlCommand maCommande; maCommande = new SqlCommand("", cnx); maCommande.CommandType = CommandType.StoredProcedure; strSQL = "ajouterevenement"; maCommande.CommandText = strSQL; maCommande.Parameters.Add("theme", SqlDbType.VarChar); maCommande.Parameters[0].Value = unEvenement.Theme; maCommande.Parameters.Add("libelle", SqlDbType.VarChar); maCommande.Parameters[1].Value = unEvenement.Libelle; maCommande.Parameters.Add("dateDebut", SqlDbType.DateTime); maCommande.Parameters[2].Value = unEvenement.DateDebut; maCommande.Parameters.Add("dateFin", SqlDbType.DateTime); maCommande.Parameters[3].Value = unEvenement.DateFin; maCommande.Parameters.Add("idVille", SqlDbType.Int); maCommande.Parameters[4].Value = unEvenement.LaVille.Id; maCommande.Parameters.Add("idEvenementiel", SqlDbType.Int); maCommande.Parameters[5].Value = unEvenement.LeEvenementiel.Id; nbEnreg = maCommande.ExecuteNonQuery(); return(nbEnreg); }
public int AjoutComm(Communication uneComm) { int nbEnreg = 0; SqlConnection cnx = Connexion.GetObjConnexion(); SqlCommand maCommande; maCommande = new SqlCommand("", cnx); maCommande.CommandType = CommandType.StoredProcedure; maCommande.CommandText = "ajoutcommunication"; maCommande.Parameters.Add("nom", SqlDbType.VarChar); maCommande.Parameters[0].Value = uneComm.Nom; maCommande.Parameters.Add("rue", SqlDbType.VarChar); maCommande.Parameters[1].Value = uneComm.Rue; maCommande.Parameters.Add("telephone", SqlDbType.VarChar); maCommande.Parameters[2].Value = uneComm.Telephone; maCommande.Parameters.Add("mail", SqlDbType.VarChar); maCommande.Parameters[3].Value = uneComm.Mail; maCommande.Parameters.Add("site", SqlDbType.VarChar); maCommande.Parameters[4].Value = uneComm.Site; maCommande.Parameters.Add("ville", SqlDbType.Int); maCommande.Parameters[5].Value = uneComm.LaVille.Id; nbEnreg = maCommande.ExecuteNonQuery(); return(nbEnreg); }
// permet de récupérer public List <CategPublic> GetCategsPublic() { int idLu; string libelleLu; CategPublic uneCategPublic; SqlConnection cnx = Connexion.GetObjConnexion(); //création des différentes collections List <CategPublic> lesCategsPublic = new List <CategPublic>(); //création de l'objet de type SqlCommand SqlCommand maCommande; SqlDataReader monLecteur; maCommande = new SqlCommand("", cnx); maCommande.CommandType = System.Data.CommandType.StoredProcedure; maCommande.CommandText = "obtenirtouteslescategoriesdepublic"; monLecteur = maCommande.ExecuteReader(); while (monLecteur.Read()) { if (monLecteur["id"] == DBNull.Value) { idLu = default(int); } else { idLu = (int)monLecteur["id"]; } if (monLecteur["libelle"] == DBNull.Value) { libelleLu = default(string); } else { libelleLu = monLecteur["libelle"].ToString(); } uneCategPublic = new CategPublic(idLu, libelleLu); lesCategsPublic.Add(uneCategPublic); } monLecteur.Close(); return(lesCategsPublic); }
//la méthode GetClients retourne une collection contenant les clients //existant dans la table Client public List <Ville> GetVilles() { int idVille; string libelleVille; string strSQL = ""; Ville uneVille; //on récupère l'objet responsable de la connexion à la base SqlConnection cnx = Connexion.GetObjConnexion(); //création de la collection lesClients qui va contenir les caractéristiques de tous les clients List <Ville> lesVilles = new List <Ville>(); //création de l'objet de type SqlCommand SqlCommand maCommande; SqlDataReader monLecteur; maCommande = new SqlCommand("", cnx); strSQL = "select id, libelle from Ville"; maCommande.CommandText = strSQL; //DataReader qui récupère les enregistrements monLecteur = maCommande.ExecuteReader(); while (monLecteur.Read()) { //on récup les données du client if (monLecteur["Id"] == DBNull.Value) { idVille = default(int); } else { idVille = (int)monLecteur["Id"]; } if (monLecteur["Libelle"] == DBNull.Value) { libelleVille = default(string); } else { libelleVille = monLecteur["Libelle"].ToString(); } //on créer une instance de la classe Client uneVille = new Ville(idVille, libelleVille); //on ajoute dans la collection lesVilles.Add(uneVille); } monLecteur.Close(); return(lesVilles); }
public List <Artiste> GetArtistes() { // déclaration des variables de travail int idLu; string nomLu; string siteLu; int idCourantLu; string CourantLibelleLu; SqlConnection cnx = Connexion.GetObjConnexion(); Courant unCourant; SqlDataReader monLecteur; List <Artiste> lesArtistes; lesArtistes = new List <Artiste>(); maCommand = new SqlCommand(); maCommand.Connection = cnx; maCommand.CommandType = System.Data.CommandType.StoredProcedure; maCommand.CommandText = "selectartiste"; // execution de la requete monLecteur = maCommand.ExecuteReader(); while (monLecteur.Read()) { idLu = (int)monLecteur["id"]; nomLu = (string)monLecteur["nom"]; siteLu = (string)monLecteur["site"]; idCourantLu = (int)monLecteur["idCourant"]; CourantLibelleLu = (string)monLecteur["libelleCourant"]; unCourant = new Courant(idCourantLu, CourantLibelleLu); // on cree une instance de la classe Artiste Artiste unArtiste = new Artiste(idLu, nomLu, siteLu, unCourant); // on ajoute l'instance créée dans la collection lesArtistes.Add(unArtiste); } monLecteur.Close(); Connexion.CloseConnection(); return(lesArtistes); }
public List <Courant> GetCourant() { // déclaration des variables de travail int idLu; string libelleLu; // on récupère l'objet responsable de la connexion à la base SqlConnection cnx = Connexion.GetObjConnexion(); SqlDataReader monLecteur; List <Courant> lesCourant; lesCourant = new List <Courant>(); maCommand = new SqlCommand(); maCommand.Connection = cnx; maCommand.CommandText = "select id, libelle from Courant"; // execution de la requête monLecteur = maCommand.ExecuteReader(); while (monLecteur.Read()) { // on recupere le nom et le prenom du client idLu = (int)monLecteur["id"]; libelleLu = (string)monLecteur["libelle"]; // on cree une instance de la classe CategSocioPro Courant unCourant = new Courant(idLu, libelleLu); // on ajoute l'instance créée dans la collection lesCourant.Add(unCourant); } monLecteur.Close(); Connexion.CloseConnection(); return(lesCourant); }
public List <Evenementiel> GetEvenementiels() { string nomComm; string rueComm; string telephoneComm; string mailComm; string siteComm; string ville; int idEvenementiel; Evenementiel unEvent; Ville laVille; SqlConnection cnx = Connexion.GetObjConnexion(); //création de la collection lesClients qui va contenir les caractéristiques de tous les clients List <Evenementiel> lesEvents = new List <Evenementiel>(); List <Ville> lesVilles = new List <Ville>(); //création de l'objet de type SqlCommand SqlCommand maCommande; SqlDataReader monLecteur; maCommande = new SqlCommand("", cnx); maCommande.CommandType = CommandType.StoredProcedure; maCommande.CommandText = "obtenirlesagencesevenementiel"; monLecteur = maCommande.ExecuteReader(); while (monLecteur.Read()) { if (monLecteur["Nom"] == DBNull.Value) { nomComm = default(string); } else { nomComm = monLecteur["Nom"].ToString(); } if (monLecteur["Rue"] == DBNull.Value) { rueComm = default(string); } else { rueComm = monLecteur["Rue"].ToString(); } if (monLecteur["Telephone"] == DBNull.Value) { telephoneComm = default(string); } else { telephoneComm = monLecteur["Telephone"].ToString(); } if (monLecteur["Mail"] == DBNull.Value) { mailComm = default(string); } else { mailComm = monLecteur["Mail"].ToString(); } if (monLecteur["Site"] == DBNull.Value) { siteComm = default(string); } else { siteComm = monLecteur["Site"].ToString(); } if (monLecteur["Ville"] == DBNull.Value) { ville = default(string); } else { ville = monLecteur["Ville"].ToString(); } if (monLecteur["eventID"] == DBNull.Value) { idEvenementiel = default(int); } else { idEvenementiel = (int)monLecteur["eventID"]; } laVille = new Ville(ville); unEvent = new Evenementiel(idEvenementiel, nomComm, rueComm, telephoneComm, mailComm, siteComm, laVille); lesEvents.Add(unEvent); } monLecteur.Close(); return(lesEvents); }
public List <Agence> GetAgences() { int idAgence; string nomAgence; string rueAgence; string telephoneAgence; string mailAgence; string siteAgence; string ville; string typeAgence; Agence uneAgence; Ville laVille; SqlConnection cnx = Connexion.GetObjConnexion(); //création de la collection lesClients qui va contenir les caractéristiques de tous les clients List <Agence> lesAgences = new List <Agence>(); List <Ville> lesVilles = new List <Ville>(); //création de l'objet de type SqlCommand SqlCommand maCommande; SqlDataReader monLecteur; maCommande = new SqlCommand("", cnx); maCommande.CommandType = CommandType.StoredProcedure; maCommande.CommandText = "obtenirtouteslesagences"; monLecteur = maCommande.ExecuteReader(); while (monLecteur.Read()) { if (monLecteur["IdAgence"] == DBNull.Value) { idAgence = default(int); } else { idAgence = (int)monLecteur["IdAgence"]; } if (monLecteur["Nom"] == DBNull.Value) { nomAgence = default(string); } else { nomAgence = monLecteur["Nom"].ToString(); } if (monLecteur["Rue"] == DBNull.Value) { rueAgence = default(string); } else { rueAgence = monLecteur["Rue"].ToString(); } if (monLecteur["Telephone"] == DBNull.Value) { telephoneAgence = default(string); } else { telephoneAgence = monLecteur["Telephone"].ToString(); } if (monLecteur["Mail"] == DBNull.Value) { mailAgence = default(string); } else { mailAgence = monLecteur["Mail"].ToString(); } if (monLecteur["Site"] == DBNull.Value) { siteAgence = default(string); } else { siteAgence = monLecteur["Site"].ToString(); } if (monLecteur["ville"] == DBNull.Value) { ville = default(string); } else { ville = monLecteur["ville"].ToString(); } if (monLecteur["TypeAgence"] == DBNull.Value) { typeAgence = default(string); } else { typeAgence = monLecteur["TypeAgence"].ToString(); } laVille = new Ville(ville); uneAgence = new Agence(idAgence, nomAgence, rueAgence, telephoneAgence, mailAgence, siteAgence, laVille, typeAgence); lesAgences.Add(uneAgence); } monLecteur.Close(); return(lesAgences); }
// permet de récupérer public List <Campagne> GetCampagnes() { int idLu; string intituleLu; string objectifLu; DateTime dateDebutLu; DateTime dateFinLu; int idEvenementielLu; string nomEvenementielLu; int idCommunicationLu; string nomCommunicationLu; int idCategPublicLu; string libelleCategPublicLu; Campagne uneCampagne; Communication uneCommunication; Evenementiel unEvenementiel; CategPublic uneCategPublic; SqlConnection cnx = Connexion.GetObjConnexion(); //création des différentes collections List <Campagne> lesCampagnes = new List <Campagne>(); List <Communication> lesCommunications = new List <Communication>(); List <Evenementiel> lesEvenementiels = new List <Evenementiel>(); List <CategPublic> lesCategsPublic = new List <CategPublic>(); //création de l'objet de type SqlCommand SqlCommand maCommande; SqlDataReader monLecteur; maCommande = new SqlCommand("", cnx); maCommande.CommandType = CommandType.StoredProcedure; maCommande.CommandText = "obtenirtouteslescampagnes"; monLecteur = maCommande.ExecuteReader(); while (monLecteur.Read()) { if (monLecteur["idCampagne"] == DBNull.Value) { idLu = default(int); } else { idLu = (int)monLecteur["idCampagne"]; } if (monLecteur["intitule"] == DBNull.Value) { intituleLu = default(string); } else { intituleLu = monLecteur["intitule"].ToString(); } if (monLecteur["objectif"] == DBNull.Value) { objectifLu = default(string); } else { objectifLu = monLecteur["objectif"].ToString(); } if (monLecteur["dateDebut"] == DBNull.Value) { dateDebutLu = default(DateTime); } else { dateDebutLu = (DateTime)monLecteur["dateDebut"]; } if (monLecteur["dateFin"] == DBNull.Value) { dateFinLu = default(DateTime); } else { dateFinLu = (DateTime)monLecteur["dateFin"]; } if (monLecteur["idEvent"] == DBNull.Value) { idEvenementielLu = default(int); } else { idEvenementielLu = (int)monLecteur["idEvent"]; } if (monLecteur["nomEvent"] == DBNull.Value) { nomEvenementielLu = default(string); } else { nomEvenementielLu = monLecteur["nomEvent"].ToString(); } if (monLecteur["idComm"] == DBNull.Value) { idCommunicationLu = default(int); } else { idCommunicationLu = (int)monLecteur["idComm"]; } if (monLecteur["nomComm"] == DBNull.Value) { nomCommunicationLu = default(string); } else { nomCommunicationLu = monLecteur["nomComm"].ToString(); } if (monLecteur["idCatPublic"] == DBNull.Value) { idCategPublicLu = default(int); } else { idCategPublicLu = (int)monLecteur["idCatPublic"]; } if (monLecteur["libCatPublic"] == DBNull.Value) { libelleCategPublicLu = default(string); } else { libelleCategPublicLu = monLecteur["libCatPublic"].ToString(); } unEvenementiel = new Evenementiel(idEvenementielLu, nomEvenementielLu); uneCommunication = new Communication(idCommunicationLu, nomCommunicationLu); uneCategPublic = new CategPublic(idCategPublicLu, libelleCategPublicLu); uneCampagne = new Campagne(idLu, intituleLu, objectifLu, dateDebutLu, dateFinLu, unEvenementiel, uneCommunication, uneCategPublic); lesCampagnes.Add(uneCampagne); } monLecteur.Close(); return(lesCampagnes); }
public List <Evenement> GetEvenements() { string strSQL; string theme; string libelle; string libelleVille; string libelleEvent; int laVille; int leEvenementiel; DateTime dateDebut; DateTime dateFin; Evenement unEvenement; Evenementiel unEvenementiel; Ville uneVille; SqlConnection cnx = Connexion.GetObjConnexion(); //création de l'objet de type SqlCommand SqlCommand maCommande; SqlDataReader monLecteur; //création de la liste List <Evenement> lesEvenements = new List <Evenement>(); List <Evenementiel> lesEvenementiels = new List <Evenementiel>(); List <Ville> lesVilles = new List <Ville>(); maCommande = new SqlCommand("", cnx); maCommande.CommandType = CommandType.StoredProcedure; strSQL = "obtenirDonneeEvenement"; maCommande.CommandText = strSQL; // DataReader qui récupère les enregistrements monLecteur = maCommande.ExecuteReader(); while (monLecteur.Read()) { // on récupère nom prenom de la table Client if (monLecteur["Theme"] == DBNull.Value) { theme = default(string); } else { theme = monLecteur["Theme"].ToString(); } if (monLecteur["libellé"] == DBNull.Value) { libelle = default(string); } else { libelle = monLecteur["libellé"].ToString(); } if (monLecteur["dateDebut"] == DBNull.Value) { dateDebut = default(DateTime); } else { dateDebut = (DateTime)monLecteur["dateDebut"]; } if (monLecteur["dateFin"] == DBNull.Value) { dateFin = default(DateTime); } else { dateFin = (DateTime)monLecteur["dateFin"]; } if (monLecteur["idVille"] == DBNull.Value) { laVille = default(int); } else { laVille = (int)monLecteur["idVille"]; } if (monLecteur["idEvenementiel"] == DBNull.Value) { leEvenementiel = default(int); } else { leEvenementiel = (int)monLecteur["idEvenementiel"]; } if (monLecteur["villeLibelle"] == DBNull.Value) { libelleVille = default(string); } else { libelleVille = monLecteur["villeLibelle"].ToString(); } if (monLecteur["NomEvent"] == DBNull.Value) { libelleEvent = default(string); } else { libelleEvent = monLecteur["NomEvent"].ToString(); } unEvenementiel = new Evenementiel(leEvenementiel, libelleEvent); uneVille = new Ville(laVille, libelleVille); // on crée une instance de la classe Employe unEvenement = new Evenement(theme, libelle, dateDebut, dateFin, uneVille, unEvenementiel); // on ajoute l'instance créée dans la collection lesEvenements.Add(unEvenement); } monLecteur.Close(); return(lesEvenements); }