Пример #1
0
        protected void lkSave_Click(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                DevMod.Models.MSubCategory  mb = new DevMod.Models.MSubCategory();
                DevMod.Classes.CSubCategory cb = new DevMod.Classes.CSubCategory();
                if (fuImage1.HasFile)
                {
                    string fileName1 = fuImage1.FileName;
                    fuImage1.PostedFile.SaveAs(Server.MapPath("~\\Images\\" + fileName1.Trim()));
                    string path1 = "~\\Images\\" + fileName1.Trim();
                    mb.ImageUrl = path1;
                    mb.Code     = txtSubCategoryCode.Text;
                    mb.Name     = txtSubCategoryName.Text;

                    if (cb.Save(mb) > 0)
                    {
                        SendMessageToPage("New Sub Category Added");
                    }
                    else
                    {
                        SendMessageToPage("New Sub Category was not Added");
                    }
                }
                else
                {
                    SendMessageToPage("Please select an image");
                }
            }
        }
Пример #2
0
        private void BindSubCategories()
        {
            List <DevMod.Models.MSubCategory> subCategories = new List <DevMod.Models.MSubCategory>();

            DevMod.Classes.CSubCategory cs = new DevMod.Classes.CSubCategory();
            subCategories = cs.GetAll();
            subCategories = subCategories.Take(6).ToList();
            repFeaturedCategories.DataSource = subCategories;
            repFeaturedCategories.DataBind();
        }
Пример #3
0
        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);
        }
        private Dictionary <int, string> GetAll(DevMod.Models.MSubCategory model, DropDownList ddl)
        {
            Dictionary <int, string>          items     = new Dictionary <int, string>();
            List <DevMod.Models.MSubCategory> allBrands = new List <DevMod.Models.MSubCategory>();

            if (HttpContext.Current.Cache["allBrands"] != null)
            {
                allBrands = (List <DevMod.Models.MSubCategory>)HttpContext.Current.Cache["allSubCategories"];
            }
            else
            {
                DevMod.Classes.CSubCategory cb = new DevMod.Classes.CSubCategory();
                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);
        }