private void CacheData()
        {
            List <DevMod.Models.MCategory>          allCategories               = new List <DevMod.Models.MCategory>();
            List <DevMod.Models.MPrice>             allPrice                    = new List <DevMod.Models.MPrice>();
            List <DevMod.Models.MProductContainer>  allProductContainer         = new List <DevMod.Models.MProductContainer>();
            List <DevMod.Models.MSubCategory>       allSubCategories            = new List <DevMod.Models.MSubCategory>();
            List <DevMod.Models.MCategoryContainer> allCategoryContainer        = new List <DevMod.Models.MCategoryContainer>();
            List <DevMod.Models.MBrand>             allBrands                   = new List <DevMod.Models.MBrand>();
            List <DevMod.Models.MColor>             allColors                   = new List <DevMod.Models.MColor>();
            List <DevMod.Models.MCommon.MViewObjects.MViewProducts> allProducts = new List <DevMod.Models.MCommon.MViewObjects.MViewProducts>();

            DevMod.Classes.CSubCategory         msc = new DevMod.Classes.CSubCategory();
            DevMod.Classes.CCommon.CViewObjects cv  = new DevMod.Classes.CCommon.CViewObjects();
            DevMod.Classes.CCategory            mc  = new DevMod.Classes.CCategory();
            DevMod.Classes.CCategoryContainer   mcc = new DevMod.Classes.CCategoryContainer();
            DevMod.Classes.CPrice            cp     = new DevMod.Classes.CPrice();
            DevMod.Classes.CBrand            cb     = new DevMod.Classes.CBrand();
            DevMod.Classes.CColor            cc     = new DevMod.Classes.CColor();
            DevMod.Classes.CProductContainer cpc    = new DevMod.Classes.CProductContainer();
            allPrice             = cp.GetAll();
            allSubCategories     = msc.GetAll();
            allCategories        = mc.GetAll();
            allCategoryContainer = mcc.GetAll();
            allBrands            = cb.GetAll();
            allColors            = cc.GetAll();
            allProductContainer  = cpc.GetAll();
            allProducts          = cv.GetAllProducts();
            HttpContext.Current.Cache.Remove("allPrice");
            HttpContext.Current.Cache.Remove("allCategories");
            HttpContext.Current.Cache.Remove("allSubCategories");
            HttpContext.Current.Cache.Remove("allCategoryContainer");
            HttpContext.Current.Cache.Remove("allProductContainer");
            HttpContext.Current.Cache["allSubCategories"]     = allSubCategories;
            HttpContext.Current.Cache["allCategories"]        = allCategories;
            HttpContext.Current.Cache["allCategoryContainer"] = allCategoryContainer;
            HttpContext.Current.Cache["allPrice"]             = allPrice;
            HttpContext.Current.Cache["allBrands"]            = allBrands;
            HttpContext.Current.Cache["allColors"]            = allColors;
            HttpContext.Current.Cache["allProducts"]          = allProducts;
            HttpContext.Current.Cache["allProductContainer"]  = allProductContainer;
            BindCategoriesRepeater();
            BindPriceRanges();
            BindAllBrands();
            BindAllColors();
            BindItemsPerPageDll();
            BindAllProducts(0, itemsPerPage, allProducts);
            BindPagingRepeater(0, itemsPerPage, allProducts);
        }
Beispiel #2
0
 protected void lkSave_Click(object sender, EventArgs e)
 {
     if (Page.IsPostBack)
     {
         DevMod.Models.MBrand  mb = new DevMod.Models.MBrand();
         DevMod.Classes.CBrand cb = new DevMod.Classes.CBrand();
         mb.Code = txtBrandCode.Text;
         mb.Name = txtBrandName.Text;
         if (cb.Save(mb) > 0)
         {
             SendMessageToPage("New Brand Added");
         }
         else
         {
             SendMessageToPage("New Brand was not Added");
         }
     }
 }
        private Dictionary <int, string> GetAll(DevMod.Models.MBrand model, DropDownList ddl)
        {
            Dictionary <int, string>    items     = new Dictionary <int, string>();
            List <DevMod.Models.MBrand> allBrands = new List <DevMod.Models.MBrand>();

            if (HttpContext.Current.Cache["allBrands"] != null)
            {
                allBrands = (List <DevMod.Models.MBrand>)HttpContext.Current.Cache["allBrands"];
            }
            else
            {
                DevMod.Classes.CBrand cb = new DevMod.Classes.CBrand();
                allBrands = cb.GetAll();
            }
            foreach (var item in allBrands)
            {
                items.Add(Convert.ToInt32(item.id), item.Name);
            }
            ddl.DataTextField  = "Value";
            ddl.DataValueField = "Key";
            ddl.DataSource     = items;
            ddl.DataBind();
            return(items);
        }