コード例 #1
0
ファイル: frmProducts.cs プロジェクト: aymanmirghani/SynTech
        private void PopulateSpecialOfferGrid(int productID)
        {
            SpecialOfferProduct sop = new SpecialOfferProduct();
            SpecialOffer        so  = new SpecialOffer();

            try
            {
                SetupSpecialOfferGrid();
                string where = string.Format("startDate <= getdate() and endDate >= getdate() and exists(select 1 from SpecialOfferProduct where specialofferid=SpecialOffer.specialofferid and productID={0})", productID);
                string orderBy             = "enddate";
                SpecialOfferCollection soc = so.GetSpecialOffersCollection(where, orderBy);
                DataTable dt = new DataTable();
                foreach (SpecialOffer s in soc)
                {
                    DataRow dr = dsSpeicalOffer.Tables[0].NewRow();
                    dr[0] = s.Description;
                    dr[1] = s.DiscountPct;
                    dsSpeicalOffer.Tables[0].Rows.Add(dr);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error. Failed to load Speical Offers for this product");
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #2
0
        public SpecialOfferCollection GetAllSpecialOffersCollection()
        {
            IDBManager             dbm  = new DBManager();
            SpecialOfferCollection cols = new SpecialOfferCollection();

            try
            {
                IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectSpecialOfferAll");
                while (reader.Read())
                {
                    SpecialOffer SO = new SpecialOffer();
                    SO.SpecialOfferID = Int32.Parse(reader["SpecialOfferID"].ToString());
                    SO.Description    = reader["Description"].ToString();
                    SO.Category       = reader["Category"].ToString();
                    SO.DiscountPct    = decimal.Parse(reader["DiscountPct"].ToString());
                    SO.EndDate        = DateTime.Parse(reader["EndDate"].ToString());
                    SO.MaxQty         = Int32.Parse(reader["MaxQty"].ToString());
                    SO.MinQty         = Int32.Parse(reader["MinQty"].ToString());
                    SO.StartDate      = DateTime.Parse(reader["StartDate"].ToString());
                    SO.Type           = reader["Type"].ToString();
                    SO.ModifiedDate   = DateTime.Parse(reader["ModifiedDate"].ToString());
                    cols.Add(SO);
                }
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetAllSpecialOffersCollection");
                throw (ex);;
            }
            finally
            {
                dbm.Dispose();
            }
            return(cols);
        }
コード例 #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;
            }
        }
コード例 #4
0
        public SpecialOfferCollection GetAllSpecialOffersDynamicCollection(string whereExpression, string orderBy)
        {
            IDBManager             dbm  = new DBManager();
            SpecialOfferCollection cols = new SpecialOfferCollection();

            try
            {
                dbm.CreateParameters(2);
                dbm.AddParameters(0, "@WhereCondition", whereExpression);
                dbm.AddParameters(1, "@OrderByExpression", orderBy);
                IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectSpecialOffersDynamic");
                while (reader.Read())
                {
                    SpecialOffer SO = new SpecialOffer();
                    SO.SpecialOfferID = Int32.Parse(reader["SpecialOfferID"].ToString());
                    SO.Description    = reader["Description"].ToString();
                    SO.Category       = reader["Category"].ToString();
                    SO.DiscountPct    = decimal.Parse(reader["DiscountPct"].ToString());
                    SO.EndDate        = DateTime.Parse(reader["EndDate"].ToString());
                    SO.MaxQty         = Int32.Parse(reader["MaxQty"].ToString());
                    SO.MinQty         = Int32.Parse(reader["MinQty"].ToString());
                    SO.StartDate      = DateTime.Parse(reader["StartDate"].ToString());
                    SO.Type           = reader["Type"].ToString();
                    SO.ModifiedDate   = DateTime.Parse(reader["ModifiedDate"].ToString());
                    cols.Add(SO);
                }
            }
            catch (Exception ex)
            {
                log.Write(ex.Message, "GetAllSpecialOffersDynamicCollection");
                throw (ex);;
            }
            finally
            {
                dbm.Dispose();
            }
            return(cols);
        }