public int AjoutPromotion(Promotion unePromotion) { SqlConnection cnx = AccesBDD.GetInstance().GetSqlConnexion(); SqlCommand maCommand = new SqlCommand(); maCommand.Parameters.Clear(); maCommand.Connection = cnx; maCommand.CommandType = System.Data.CommandType.StoredProcedure; maCommand.CommandText = "ajoutPromotion"; maCommand.Parameters.Add("intitulePromo", System.Data.SqlDbType.VarChar); maCommand.Parameters[0].Value = unePromotion.IntitulePromo; maCommand.Parameters.Add("datePromo", System.Data.SqlDbType.Date); maCommand.Parameters[1].Value = unePromotion.DatePromo.ToString("dd/MM/yyyy"); maCommand.Parameters.Add("commentairePromo", System.Data.SqlDbType.VarChar); maCommand.Parameters[2].Value = unePromotion.CommentairePromo; maCommand.Parameters.Add("idpharmacie", System.Data.SqlDbType.VarChar); maCommand.Parameters[3].Value = unePromotion.UnePharmacie.IdPharmacie; maCommand.Parameters.Add("idtypepromo", System.Data.SqlDbType.VarChar); maCommand.Parameters[4].Value = unePromotion.UnTypePromo.IdTypePromo; maCommand.Parameters.Add("idintervenant", System.Data.SqlDbType.VarChar); maCommand.Parameters[5].Value = unePromotion.UnIntervenant.IdIntervenant; return maCommand.ExecuteNonQuery(); }
public List<Promotion>SelectPromotionPourUneRegionPourUnType(int idType,int idRegion) { SqlConnection cnx = AccesBDD.GetInstance().GetSqlConnexion(); SqlCommand maCommand = new SqlCommand(); SqlDataReader monLecteur; maCommand.Parameters.Clear(); List<Promotion> lesPromotions = new List<Promotion>(); maCommand.Connection = cnx; maCommand.CommandType = System.Data.CommandType.StoredProcedure; maCommand.CommandText = "SelectPromotionPourUneRegionPourUnType"; maCommand.Parameters.Add("idPromo", System.Data.SqlDbType.Int); maCommand.Parameters[0].Value = idType; maCommand.Parameters.Add("idRegion", System.Data.SqlDbType.Int); maCommand.Parameters[1].Value = idRegion; monLecteur = maCommand.ExecuteReader(); while(monLecteur.Read()) { Pharmacie unePharmacie = new Pharmacie((string)monLecteur["nomPharmacie"]); Intervenant unIntervenant = new Intervenant((string)monLecteur["nomIntervenant"]); Promotion unePromotion = new Promotion((int)monLecteur["idPromotion"], (string)monLecteur["intitulePromo"], (DateTime)monLecteur["datePromo"], (string)monLecteur["commentairePromo"], unIntervenant, unePharmacie); lesPromotions.Add(unePromotion); } return lesPromotions; }
public int CreerPromotion(string sonIntitulePromo,DateTime saDatePromo,string sonCommentairePromo,int sonIdPharmacie,int sonIdTypePromo,int sonIdIntervenant) { Pharmacie laPharmacie = new Pharmacie(sonIdPharmacie); TypePromo leTypePromo = new TypePromo(sonIdTypePromo); Intervenant lIntervenant = new Intervenant(sonIdIntervenant); Promotion laPromotion = new Promotion(sonIntitulePromo, saDatePromo, sonCommentairePromo, laPharmacie, leTypePromo,lIntervenant); return PromotionDAO.GetInstanceDAOPromotion().AjoutPromotion(laPromotion); }