Exemplo n.º 1
0
 public int CreerCampagne(string unIntitule, string unObjectif, DateTime uneDateDebut, DateTime uneDateFin, int unIdPublic, int unIdEmploye)
 {
     Campagne laCampagne;
     Public unPublic = new Public(unIdPublic);
     Employe unEmploye = new Employe(unIdEmploye);
     laCampagne = new Campagne( unIntitule, unObjectif, uneDateDebut, uneDateFin, unPublic, unEmploye);
     return CampagneDAO.GetInstanceDAOCampagne().AjoutCampagne(laCampagne);
 }
Exemplo n.º 2
0
 public Event(Theme theme, DateTime dateDebut, DateTime dateFin,Campagne laCampagne, Ville laVille)
 {
     this.Theme = theme;
     this.dateDebut = dateDebut;
     this.dateFin = dateFin;
     this.LaVille=laVille;
     this.LaCampagne=laCampagne;
 }
Exemplo n.º 3
0
        //appel de la couche DAL pour creer un new client
        public int CreerEvent(int theme, DateTime dateDebut, DateTime dateFin, int laCampagne, int laVille )
        {
            Event leEvenement;
            Campagne uneCampagne=new Campagne(laCampagne);
            Ville uneVille = new Ville(laVille);
            Theme unTheme = new Theme(theme);

            leEvenement = new Event( unTheme,  dateDebut,  dateFin, uneCampagne,uneVille);
            return EventDAO.GetInstanceDAOEvent().AjoutEvent(leEvenement);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Ajoute une campagne passé en paramètre si elle n'existe pas déjà.
        /// </summary>
        /// <param name="uneCampagne">référence à campagne</param>
        /// <returns>Retourne 0 si elle existe et 1 si elle s'ajoute.</returns>
        public int AjoutCampagne(Campagne uneCampagne)
        {
            SqlConnection cnx = AccesBD.GetInstance().GetSqlConnexion();
            SqlCommand maCommand = new SqlCommand();
            maCommand.Connection = cnx;

            maCommand.Parameters.Clear();
            maCommand.CommandType = CommandType.StoredProcedure;
            maCommand.CommandText = "spCountCampagne";
            //maCommand.CommandText = "select count(*) from Campagne where intitule=@intitule and objectif=@objectif";
            maCommand.Parameters.Add("intitule", System.Data.SqlDbType.VarChar);
            maCommand.Parameters[0].Value = uneCampagne.Intitule;
            maCommand.Parameters.Add("objectif", System.Data.SqlDbType.VarChar);
            maCommand.Parameters[1].Value = uneCampagne.Objectif;

            int nbRet = (int)maCommand.ExecuteScalar();

            if (nbRet > 0)
            {
                AccesBD.GetInstance().CloseConnection();
                return 0;
            }
            else
            {
                maCommand.Parameters.Clear();
                maCommand.CommandType = CommandType.StoredProcedure;
                maCommand.CommandText = "spAjoutCampagne";
                //maCommand.CommandText = "insert into Campagne values(@intitule,@objectif,@dateDebut,@dateFin,@idPublic,@idEmploye)";
                maCommand.Parameters.Add("intitule", System.Data.SqlDbType.VarChar);
                maCommand.Parameters[0].Value = uneCampagne.Intitule;
                maCommand.Parameters.Add("objectif", System.Data.SqlDbType.VarChar);
                maCommand.Parameters[1].Value = uneCampagne.Objectif;
                maCommand.Parameters.Add("dateDebut", System.Data.SqlDbType.DateTime);
                maCommand.Parameters[2].Value = uneCampagne.DateDebut;
                maCommand.Parameters.Add("dateFin", System.Data.SqlDbType.DateTime);
                maCommand.Parameters[3].Value = uneCampagne.DateFin;
                maCommand.Parameters.Add("idPublic", System.Data.SqlDbType.Int);
                maCommand.Parameters[4].Value = uneCampagne.IdPublic.Id;
                maCommand.Parameters.Add("idEmploye", System.Data.SqlDbType.Int);
                maCommand.Parameters[5].Value = uneCampagne.IdEmploye.Id;

                int nb = (int)maCommand.ExecuteNonQuery();

                AccesBD.GetInstance().CloseConnection();
                return nb;
            }
        }