Пример #1
0
        public static Promo GetPromoByPromoId(int promoId)
        {
            Database  db         = DatabaseFactory.CreateDatabase("SPARInsightManagement");
            string    sqlCommand = "GetPromoByPromoId";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "@PromoId", DbType.Int32, promoId);
            db.AddOutParameter(dbCommand, "@Description", DbType.String, 50);
            db.ExecuteNonQuery(dbCommand);
            Promo promo = new Promo();

            promo.PromoId     = promoId;
            promo.Description = db.GetParameterValue(dbCommand, "Description").ToString();
            return(promo);
        }
Пример #2
0
        public static List <Promo> GetPromoList()
        {
            List <Promo> list = new List <Promo>();

            Database  db         = DatabaseFactory.CreateDatabase("SPARInsightManagement");
            string    sqlCommand = "GetPromoList";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    Promo promo = new Promo();
                    promo.PromoId     = Convert.ToInt32(dataReader["PromoId"]);
                    promo.Description = dataReader["Description"].ToString();
                    list.Add(promo);
                }
            }
            return(list);
        }