Пример #1
0
        protected void gvProducts_PreRender(object sender, EventArgs e)
        {
            if (gvProducts.TopPagerRow != null)
            {
                gvProducts.TopPagerRow.Visible = true;
                ((TextBox)gvProducts.HeaderRow.FindControl("txtFilterId")).Text   = GetStringState(PRODUCT_ID_FILTER);
                ((TextBox)gvProducts.HeaderRow.FindControl("txtFilterName")).Text = GetStringState(PRODUCT_NAME_FILTER);
                ((DropDownList)gvProducts.HeaderRow.FindControl("ddlStatus")).Items.FindByValue(GetStringState(STATUS_FILTER)).Selected             = true;
                ((DropDownList)gvProducts.HeaderRow.FindControl("ddlDiscontinued")).Items.FindByValue(GetStringState(DISCONTINUED_FILTER)).Selected = true;
            }

            var products = gvProducts.DataSource as Product[];

            if (products != null)
            {
                for (int i = 0; i < gvProducts.Rows.Count; i++)
                {
                    CheckBox cb = gvProducts.Rows[i].FindControl("cbChosen") as CheckBox;

                    if (ChosenProducts.Contains(products[i].Id))
                    {
                        cb.Checked = true;
                    }

                    SetChosenProducts(products[i].Id, cb.Checked);
                }
            }

            if (gvProducts.Rows.Count == 1 && (int)gvProducts.DataKeys[0].Value == 0 && gvProducts.TopPagerRow != null)
            {
                gvProducts.TopPagerRow.FindControl(PH_RECORD_FOUND).Visible     = false;
                gvProducts.TopPagerRow.FindControl(PH_RECORD_NOT_FOUND).Visible = true;
            }
        }
Пример #2
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 gvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ProductOverviewModel product = e.Row.DataItem as ProductOverviewModel;
                CheckBox             cb      = e.Row.FindControl("cbChosen") as CheckBox;

                if (ChosenProducts.Contains(product.Id))
                {
                    cb.Checked = true;
                }
            }
        }
        protected void gvSubscribers_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Subscriber subscriber = e.Row.DataItem as Subscriber;
                CheckBox   cb         = e.Row.FindControl("cbChosen") as CheckBox;

                if (ChosenProducts.Contains(subscriber.Id))
                {
                    cb.Checked = true;
                }

                SetChosenSubscribers(subscriber.Id, cb.Checked);
            }
        }
 private void SetChosenSubscribers(int subscriberId, bool chosen)
 {
     if (subscriberId != 0)
     {
         if ((chosen) && !ChosenProducts.Contains(subscriberId))
         {
             ChosenProducts.Add(subscriberId);
             NotChosenProducts.Remove(subscriberId);
         }
         else if ((!chosen) && (ChosenProducts.Contains(subscriberId)))
         {
             ChosenProducts.Remove(subscriberId);
             NotChosenProducts.Add(subscriberId);
         }
     }
 }
Пример #7
0
 private void SetChosenProducts(int productId, bool chosen)
 {
     if (productId != 0)
     {
         if ((chosen) && !ChosenProducts.Contains(productId))
         {
             ChosenProducts.Add(productId);
             NotChosenProducts.Remove(productId);
         }
         else if ((!chosen) && (ChosenProducts.Contains(productId)))
         {
             ChosenProducts.Remove(productId);
             NotChosenProducts.Add(productId);
         }
     }
 }
        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();
        }
Пример #9
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();
        }
Пример #10
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";
        }
Пример #11
0
        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();
        }