Пример #1
0
 protected void lkSave_Click(object sender, EventArgs e)
 {
     if (Page.IsPostBack)
     {
         try
         {
             if (fuImage1.HasFile && fuImage2.HasFile && fuImage3.HasFile)
             {
                 string filename1 = fuImage1.FileName;
                 string filename2 = fuImage2.FileName;
                 string filename3 = fuImage3.FileName;
                 fuImage1.PostedFile.SaveAs(Server.MapPath("~\\Images\\" + filename1.Trim()));
                 fuImage2.PostedFile.SaveAs(Server.MapPath("~\\Images\\" + filename2.Trim()));
                 fuImage3.PostedFile.SaveAs(Server.MapPath("~\\Images\\" + filename3.Trim()));
                 string path1                = "~\\Images\\" + filename1.Trim();
                 string path2                = "~\\Images\\" + filename2.Trim();
                 string path3                = "~\\Images\\" + filename3.Trim();
                 string Name                 = txtProductName.Text;
                 string Name2                = txtProductName2.Text;
                 string Name3                = txtProductName3.Text;
                 string Description          = txtDescription.Text;
                 string Price                = txtPrice.Text;
                 string Code                 = txtProductCode.Text;
                 DevMod.Classes.CProducts cp = new DevMod.Classes.CProducts();
                 DevMod.Models.MProducts  mp = new DevMod.Models.MProducts();
                 mp.Code        = Code;
                 mp.Name1       = Name;
                 mp.Name2       = Name2;
                 mp.Name3       = Name3;
                 mp.ImageUrl1   = path1;
                 mp.ImageUrl2   = path2;
                 mp.ImageUrl3   = path3;
                 mp.Description = Description;
                 mp.Price       = Price;
                 if (cp.Save(mp) > 0)
                 {
                     SendMessageToPage("Product Successfully Saved");
                 }
                 else
                 {
                     SendMessageToPage("Product was not Saved");
                 }
             }
             else
             {
                 SendMessageToPage("Please select images");
             }
         }
         catch
         {
         }
     }
 }
Пример #2
0
        private void CacheData()
        {
            List <DevMod.Models.MProductContainer>  allProductContainer         = new List <DevMod.Models.MProductContainer>();
            List <DevMod.Models.MCategory>          allCategories               = new List <DevMod.Models.MCategory>();
            List <DevMod.Models.MPrice>             allPrice                    = new List <DevMod.Models.MPrice>();
            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>();
            List <DevMod.Models.MProducts> allCompleteProducts                  = new List <DevMod.Models.MProducts>();

            DevMod.Classes.CProducts            ccp = new DevMod.Classes.CProducts();
            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();
            allProductContainer  = cpc.GetAll();
            allPrice             = cp.GetAll();
            allCompleteProducts  = ccp.GetAll();
            allSubCategories     = msc.GetAll();
            allCategories        = mc.GetAll();
            allCategoryContainer = mcc.GetAll();
            allBrands            = cb.GetAll();
            allColors            = cc.GetAll();
            allProducts          = cv.GetAllProducts();
            HttpContext.Current.Cache.Remove("allProductContainer");
            HttpContext.Current.Cache.Remove("allCompleteProducts");
            HttpContext.Current.Cache.Remove("allPrice");
            HttpContext.Current.Cache.Remove("allCategories");
            HttpContext.Current.Cache.Remove("allSubCategories");
            HttpContext.Current.Cache.Remove("allCategoryContainer");
            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["allCompleteProducts"]  = allCompleteProducts;
            HttpContext.Current.Cache["allProductContainer"]  = allProductContainer;
        }
Пример #3
0
        private void BindAllProductControls(string ProductId)
        {
            List <DevMod.Models.MProducts> allProducts =
                (List <DevMod.Models.MProducts>)HttpContext.Current.Cache["allCompleteProducts"];
            string productId = ProductId, productCode = string.Empty, productName = string.Empty, productImage1 = string.Empty,
                   productImage2 = string.Empty, productImage3 = string.Empty, productDescription = string.Empty, productPrice = string.Empty
            , productDiscountedPrice = string.Empty;

            if (allProducts.Count > 0)
            {
                productDescription     = allProducts.Where(o => o.id == productId).Select(o => o.Description).FirstOrDefault();
                productCode            = allProducts.Where(o => o.id == productId).Select(o => o.Code).FirstOrDefault();
                productImage1          = allProducts.Where(o => o.id == productId).Select(o => o.ImageUrl1).FirstOrDefault();
                productImage2          = allProducts.Where(o => o.id == productId).Select(o => o.ImageUrl2).FirstOrDefault();
                productImage3          = allProducts.Where(o => o.id == productId).Select(o => o.ImageUrl3).FirstOrDefault();
                productPrice           = allProducts.Where(o => o.id == productId).Select(o => o.Price).FirstOrDefault();
                productDiscountedPrice = GetDiscountedRate(productId);

                lblDescription.Text     = productDescription;
                lblDiscountedPrice.Text = productDiscountedPrice;
                lblName.Text            = productName;
                lblPrice.Text           = productPrice;
                lblProductCode.Text     = productCode;
                lblProductId.Text       = productId;
                imgLarge.ImageUrl       = productImage1;
                imgZoom1.ImageUrl       = productImage1;
                imgZoom2.ImageUrl       = productImage2;
                imgZoom3.ImageUrl       = productImage3;
                imgZoom1.DataBind();
                imgZoom2.DataBind();
                imgZoom3.DataBind();
            }
            else
            {
                DevMod.Classes.CProducts cp = new DevMod.Classes.CProducts();
                allProducts = cp.GetAll();
                HttpContext.Current.Cache["allCompleteProducts"] = allProducts;
                BindAllProductControls(ProductId);
            }
        }
        private Dictionary <int, string> GetAll(DevMod.Models.MProducts model, DropDownList ddl)
        {
            Dictionary <int, string>       items     = new Dictionary <int, string>();
            List <DevMod.Models.MProducts> allBrands = new List <DevMod.Models.MProducts>();

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