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()); } }
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; } }