Exemplo n.º 1
0
        protected void lbSubmit_Click(object sender, EventArgs e)
        {
            SaveLastViewedProduct();
            switch (ddlActions.SelectedValue)
            {
            case CHANGE_STATUS:
                bool status = ddlActionStatus.SelectedValue == ENABLED ? true : false;
                ProductService.UpdateProductStatusByProductIdList(ChosenProducts, status);

                enbNotice.Message = "Product status was updated successfully.";
                break;

            case CHANGE_DISCONTINUED:
                bool discontinued = ddlActionDiscontinued.SelectedValue == ENABLED ? true : false;
                ProductService.UpdateProductDiscontinuedStatusByProductIdList(ChosenProducts.ToArray(), discontinued);

                enbNotice.Message = "Product discontinued status was updated successfully.";
                break;
            }

            ddlActions.SelectedIndex = -1;

            ChosenProducts.Clear();
            NotChosenProducts.Clear();
            LoadProducts();
        }
 private void ClearInfo()
 {
     txtName.Text         = string.Empty;
     txtDesc.Text         = string.Empty;
     txtUrlKey.Text       = string.Empty;
     imgThumbnail.Visible = false;
     imgThumbnail.Src     = string.Empty;
     ChosenProducts.Clear();
     NotChosenProducts.Clear();
 }
        protected void lbSave_Click(object sender, EventArgs e)
        {
            SaveLastViewedSubscriber();

            if (NotChosenProducts.Count > 0)
            {
                AccountService.UpdateSubscribersStatus(NotChosenProducts, false);
            }

            if (ChosenProducts.Count > 0)
            {
                AccountService.UpdateSubscribersStatus(ChosenProducts, true);
            }

            ChosenProducts.Clear();
            NotChosenProducts.Clear();

            enbNotice.Message = "Subscribers were updated successfully.";

            LoadSubscribers();
        }
Exemplo n.º 4
0
        private void ClearInfo()
        {
            txtName.Text                = string.Empty;
            txtUrlKey.Text              = string.Empty;
            imgLogo.Src                 = string.Empty;
            imgLogo.Alt                 = string.Empty;
            fuLogo.Visible              = true;
            txtMetaDesc.Text            = string.Empty;
            txtMetaTitle.Text           = string.Empty;
            txtMetaKeywords.Text        = string.Empty;
            cbEnforceStockCount.Checked = false;
            ddlDelivery.SelectedIndex   = -1;

            cbMicrosite.Checked = false;
            txtDesc.Text        = string.Empty;

            ChosenProducts.Clear();
            NotChosenProducts.Clear();

            gvFeaturedProducts.DataBind();
            gvBanners.DataBind();
        }
Exemplo n.º 5
0
        protected void lbSaveBrand_Click(object sender, EventArgs e)
        {
            string urlKey = txtUrlKey.Text.Trim();

            txtUrlKey.BackColor = Color.Empty;

            // If urlKey is empty, regenerate with given category name
            if (urlKey == string.Empty)
            {
                urlKey         = AdminStoreUtility.GetFriendlyUrlKey(txtName.Text.Trim());
                txtUrlKey.Text = urlKey;
            }

            // Make sure urlKey is unique
            if (((GetStringState(MODE) == NEW) && (BrandService.GetBrandByUrlKey(urlKey) != null)) ||
                ((GetStringState(MODE) == EDIT) && (BrandService.GetBrandByUrlKey(urlKey) != null) && (BrandService.GetBrandByUrlKey(urlKey).Id != GetIntState(BRAND_ID))))
            {
                enbNotice.Message = "Url Key is not unique.";
            }
            else
            {
                SaveLastViewedProduct();

                Brand brand = new Brand();

                brand.Name             = Server.HtmlEncode(txtName.Text.Trim());
                brand.FlashImageHeight = -1;
                brand.FlashImageWidth  = -1;
                brand.UrlRewrite       = urlKey;

                string logoFilename = string.Empty;
                //added string empty to avoid the exception
                brand.FlashImage = string.Empty;
                if (fuLogo.HasFile)
                {
                    logoFilename = brand.UrlRewrite.Trim().ToLower() + "-logo" + Path.GetExtension(fuLogo.FileName).ToLower();
                    fuLogo.SaveAs(MediaSettings.BrandMediaLocalPath + logoFilename);
                    brand.FlashImage = logoFilename;
                }

                // Get old logo filename
                if (!fuLogo.HasFile && imgLogo.Alt != string.Empty)
                {
                    brand.FlashImage = imgLogo.Alt;
                }

                // Remove logo file
                if (cbRemoveLogo.Checked && imgLogo.Alt != string.Empty)
                {
                    File.Delete(MediaSettings.BrandMediaLocalPath + imgLogo.Alt);
                    brand.FlashImage     = string.Empty;
                    cbRemoveLogo.Checked = false;
                }

                brand.Description       = txtDesc.Text.Trim();
                brand.HasMicrosite      = cbMicrosite.Checked;
                brand.MetaDescription   = txtMetaDesc.Text.Trim();
                brand.MetaTitle         = txtMetaTitle.Text.Trim();
                brand.MetaKeywords      = txtMetaKeywords.Text.Trim();
                brand.EnforceStockCount = cbEnforceStockCount.Checked;
                brand.DeliveryId        = Convert.ToInt32(ddlDelivery.SelectedValue);
                brand.Enabled           = cbEnabled.Checked;

                if (GetStringState(MODE) == NEW)
                {
                    int brandId = BrandService.InsertBrand(brand);
                    brand.Id = brandId;
                    SetState(BRAND_ID, brand.Id);

                    enbNotice.Message = "Brand was created successfully.";
                }
                else // Edit mode
                {
                    brand.Id = GetIntState(BRAND_ID);
                    BrandService.UpdateBrand(brand);

                    if (NotChosenProducts.Count > 0)
                    {
                        BrandService.UpdateProductWithBrand(AppConstant.DEFAULT_BRAND, NotChosenProducts);
                    }

                    enbNotice.Message = "Brand was updated successfully.";
                }

                if (ChosenProducts.Count > 0)
                {
                    BrandService.UpdateProductWithBrand(brand.Id, ChosenProducts);
                }
            }

            ChosenProducts.Clear();
            NotChosenProducts.Clear();
            LoadProducts();

            hfCurrentPanel.Value = "general";
        }
        protected void lbSaveBrandCategory_Click(object sender, EventArgs e)
        {
            string urlKey = txtUrlKey.Text.Trim();

            txtUrlKey.BackColor = Color.Empty;

            // If url key is empty, regenerate with given category name
            if (urlKey == string.Empty)
            {
                urlKey         = AdminStoreUtility.GetFriendlyUrlKey(txtName.Text.Trim());
                txtUrlKey.Text = urlKey;
            }

            // Make sure url key is unique
            if (((GetStringState(MODE) == NEW) && (BrandService.GetBrandCategoryByUrlKey(urlKey) != null)) ||
                ((GetStringState(MODE) == EDIT) && (BrandService.GetBrandCategoryByUrlKey(urlKey) != null) && (BrandService.GetBrandCategoryByUrlKey(urlKey).Id != GetIntState(BRAND_CATEGORY_ID))))
            {
                enbNotice.Message = "Url key is not unique.";
            }
            else
            {
                string thumbnailFilename = string.Empty;

                if (fuThumbnail.HasFile)
                {
                    thumbnailFilename = txtUrlKey.Text.Trim() + Path.GetExtension(fuThumbnail.FileName).ToLower();
                    fuThumbnail.SaveAs(MediaSettings.BrandMediaLocalPath + thumbnailFilename);
                }
                else
                {
                    if (!cbRemoveThumb.Checked)
                    {
                        BrandCategory category = BrandService.GetBrandCategoryByUrlKey(urlKey);

                        if (category != null)
                        {
                            thumbnailFilename = category.ImageUrl;
                        }
                    }
                }

                BrandCategory brandCategory = new BrandCategory();
                brandCategory.Name        = Server.HtmlEncode(txtName.Text.Trim());
                brandCategory.BrandId     = QueryBrandId;
                brandCategory.Description = Server.HtmlEncode(txtDesc.Text.Trim());
                brandCategory.ImageUrl    = thumbnailFilename;
                brandCategory.UrlRewrite  = txtUrlKey.Text.Trim();
                brandCategory.Visible     = cbVisible.Checked;

                if (!string.IsNullOrEmpty(hfParent.Value))
                {
                    brandCategory.ParentId = Convert.ToInt32(hfParent.Value);
                }

                if (GetStringState(MODE) == NEW)
                {
                    if (string.IsNullOrEmpty(hfParent.Value))
                    {
                        brandCategory.ParentId = AppConstant.DEFAULT_BRAND_CATEGORY;
                    }

                    brandCategory.Id = BrandService.InsertBrandCategory(brandCategory);
                }
                else // Edit mode
                {
                    brandCategory.Id = GetIntState(LAST_CHOSEN_BRAND_CATEGORY);
                    BrandService.UpdateBrandCategory(brandCategory);
                }

                ectBrandCategory.Repopulate();

                var treeList = BrandService.GetBrandCategoryTreeList(brandCategory.Id);
                ectBrandCategory.FindSelectedNode(AppConstant.DEFAULT_BRAND_CATEGORY, treeList);

                PopulateBrandCategoryInfo(brandCategory.Id);

                enbNotice.Message = "Brand category was saved successfully.";
            }

            cbRemoveThumb.Checked = false;

            ChosenProducts.Clear();
            NotChosenProducts.Clear();
            LoadProducts();
        }