Ejemplo n.º 1
0
        public SpecialOfferProductCollection GetAllSpecialOfferProductsCollection()
        {
            IDBManager dbm = new DBManager();
            SpecialOfferProductCollection cols = new SpecialOfferProductCollection();

            try
            {
                IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectSpecialOfferProductAll");
                while (reader.Read())
                {
                    SpecialOfferProduct SOP = new SpecialOfferProduct();
                    SOP.SpecialOfferID = Int32.Parse(reader["SpecialOfferID"].ToString());
                    SOP.ProductID      = Int32.Parse(reader["ProductID"].ToString());
                    SOP.ModifiedDate   = DateTime.Parse(reader["ModifiedDate"].ToString());
                    cols.Add(SOP);
                }
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetAllSpecialOfferProductsCollection");
                throw (ex);
            }
            finally
            {
                dbm.Dispose();
            }
            return(cols);
        }
Ejemplo n.º 2
0
        public SpecialOfferProductCollection GetAllSpecialOfferProductsDynamicCollection(string whereExpression, string orderBy)
        {
            IDBManager dbm = new DBManager();
            SpecialOfferProductCollection cols = new SpecialOfferProductCollection();

            try
            {
                dbm.CreateParameters(2);
                dbm.AddParameters(0, "@WhereCondition", whereExpression);
                dbm.AddParameters(1, "@OrderByExpression", orderBy);
                IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectSpecialOfferProductsDynamic");
                while (reader.Read())
                {
                    SpecialOfferProduct SOP = new SpecialOfferProduct();
                    SOP.SpecialOfferID = Int32.Parse(reader["SpecialOfferID"].ToString());
                    SOP.ProductID      = Int32.Parse(reader["ProductID"].ToString());
                    SOP.ModifiedDate   = DateTime.Parse(reader["ModifiedDate"].ToString());
                    cols.Add(SOP);
                }
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetAllSpecialOfferProductsDynamicCollection");
                throw (ex);
            }
            finally
            {
                dbm.Dispose();
            }
            return(cols);
        }
Ejemplo n.º 3
0
        public void ExportSpecialOffers()
        {
            SqlCompactConnection          conn   = new SqlCompactConnection();
            SpecialOffer                  so     = new SpecialOffer();
            SpecialOfferCollection        soCol  = new SpecialOfferCollection();
            SpecialOfferProduct           sop    = new SpecialOfferProduct();
            SpecialOfferProductCollection sopCol = new SpecialOfferProductCollection();

            string where = "startdate <= getdate() and enddate >= getdate()";
            string orderby = "specialofferid";

            try
            {
                //ds = q.GetDataSet(false, sql);
                soCol          = so.GetSpecialOffersCollection(where, orderby);
                conn.SynchForm = this;
                conn.DropSepcialOfferTable();
                conn.CreateSpecialOfferTable();
                conn.AddSpecialOffer(soCol);
                where   = "specialofferid in (select specialofferid from specialoffer where startdate <= getdate() and enddate >= getdate())";
                orderby = "specialofferid";
                sopCol  = sop.GetSpecialOfferProductsCollection(where, orderby);
                conn.DropSepcialOfferProductTable();
                conn.CreateSpecialOfferProductTable();
                conn.AddSpecialOfferProduct(sopCol);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.CloseDatabase();
                conn   = null;
                so     = null;
                soCol  = null;
                sop    = null;
                sopCol = null;
                //ds.Dispose();
                // q = null;
            }
        }