Example #1
0
    /// <summary>
    /// Bind data to the fields on the screen
    /// </summary>
    protected void BindData()
    {
        CategoryAdmin categoryAdmin = new CategoryAdmin();
        Category category = categoryAdmin.GetByCategoryId(ItemId);

        if (category != null)
        {
            ProductCategoryName = category.Name;
        }
        else
        {
            throw (new ApplicationException("Category Requested could not be found."));
        }
    }
Example #2
0
    /// <summary>
    /// Bind data to the fields on the edit screen
    /// </summary>
    protected void BindEditData()
    {
        CategoryAdmin categoryAdmin = new CategoryAdmin();
        Category category = categoryAdmin.GetByCategoryId(ItemId);

        if (category != null)
        {
            txtName.Text = category.Name;
            txtshortdescription.Text = category.ShortDescription;
            ctrlHtmlText.Html = category.Description;
            ParentCategoryID.SelectedValue = category.ParentCategoryID.ToString();
            DisplayOrder.Text = category.DisplayOrder.ToString();
            VisibleInd.Checked = category.VisibleInd;

            txtTitle.Text = category.Title;
            chkSubCategoryGridVisibleInd.Checked = category.SubCategoryGridVisibleInd;
            txtSEOMetaDescription.Text = category.SEODescription;
            txtSEOMetaKeywords.Text = category.SEOKeywords;
            txtSEOTitle.Text = category.SEOTitle;
            txtSEOURL.Text = category.SEOURL;
            Image1.ImageUrl = ZNode.Libraries.Framework.Business.ZNodeConfigManager.EnvironmentConfig.MediumImagePath + category.ImageFile;
            txtImageAltTag.Text = category.ImageAltTag;
            try
            {
                RowDropDown.SelectedIndex = Int32.Parse(category.Custom1);
            }
            catch (Exception e)
            { RowDropDown.SelectedIndex = 0; }
            try
            {
                ColumnDropDown.SelectedIndex = Int32.Parse(category.Custom2);

            }
            catch (Exception e)
            {
                ColumnDropDown.SelectedIndex = 0;

            }
            ddlPageTemplateList.SelectedValue = category.MasterPage;
        }
        else
        {
            throw (new ApplicationException("Category Requested could not be found."));
        }
    }
    /// <summary>
    /// Bind data to the fields on the edit screen
    /// </summary>
    protected void BindEditData()
    {
        CategoryAdmin categoryAdmin = new CategoryAdmin();
        Category category = categoryAdmin.GetByCategoryId(ItemId);

        if (category != null)
        {
            lblTitle.Text += category.Title;
            txtTitle.Text = category.Title;
            txtshortdescription.Text = category.ShortDescription;
            ctrlHtmlText.Html = category.Description;
            txtSEOMetaDescription.Text = category.SEODescription;
            txtSEOMetaKeywords.Text = category.SEOKeywords;
            txtSEOTitle.Text = category.SEOTitle;
            txtSEOURL.Text = category.SEOURL;
        }
        else
        {
            throw (new ApplicationException("Category Requested could not be found."));
        }
    }
Example #4
0
    /// <summary>
    /// Submit button click event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        System.IO.FileInfo fileInfo = null;
        CategoryAdmin categoryAdmin = new CategoryAdmin();
        Category category = new Category();
        string mappedSEOUrl = "";

        if (ItemId > 0)
        {
            category = categoryAdmin.GetByCategoryId(ItemId);

            if (category.SEOURL != null)
                mappedSEOUrl = category.SEOURL;
        }
        category.CategoryID = ItemId;
        category.PortalID = ZNodeConfigManager.SiteConfig.PortalID ;
        category.Name = txtName.Text;
        category.ShortDescription = txtshortdescription.Text;
        category.Description = ctrlHtmlText.Html;
        category.Title = txtTitle.Text;
        category.SubCategoryGridVisibleInd = chkSubCategoryGridVisibleInd.Checked;
        category.SEOTitle = txtSEOTitle.Text;
        category.SEOKeywords = txtSEOMetaKeywords.Text;
        category.SEODescription = txtSEOMetaDescription.Text;
        category.SEOURL = null;
        if(txtSEOURL.Text.Trim().Length > 0)
            category.SEOURL = txtSEOURL.Text.Trim().Replace(" ","-");

        if (int.Parse(ParentCategoryID.SelectedValue) > 0)
        {
            category.ParentCategoryID = int.Parse(ParentCategoryID.SelectedValue);
        }
        else
        {
            category.ParentCategoryID = null;
        }

        category.ImageAltTag = txtImageAltTag.Text.Trim();
        category.MasterPage = ddlPageTemplateList.SelectedItem.Text;
        category.DisplayOrder = int.Parse(DisplayOrder.Text);
        category.VisibleInd = VisibleInd.Checked;
        category.Custom1 = RowDropDown.SelectedItem.ToString();
        category.Custom2 = ColumnDropDown.SelectedIndex.ToString();

        #region Image Validation

        //Validate image
        if ((ItemId == 0) || (RadioCategoryNewImage.Checked == true))
        {
            if(UploadCategoryImage.PostedFile.FileName != "")
            {
                //Check for Product Image
                fileInfo = new System.IO.FileInfo(UploadCategoryImage.PostedFile.FileName);

                if (fileInfo != null)
                {
                  category.ImageFile = fileInfo.Name;
                }
            }
        }
        else
        {
            category.ImageFile = category.ImageFile;
        }
        #endregion

        //Upload File if this is a new product or the New Image option was selected for an existing product
        if (RadioCategoryNewImage.Checked || ItemId == 0)
        {
            if (fileInfo != null)
            {
                UploadCategoryImage.SaveAs(Server.MapPath(ZNodeConfigManager.EnvironmentConfig.OriginalImagePath + fileInfo.Name));
                ZNodeImage image = new ZNodeImage();
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemLargeWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.LargeImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemThumbnailWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.ThumbnailImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemMediumWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.MediumImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemSmallWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.SmallImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemSwatchWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.SwatchImagePath));
                ZNodeImage.ResizeImage(fileInfo, ZNode.Libraries.Framework.Business.ZNodeConfigManager.SiteConfig.MaxCatalogItemCrossSellWidth, Server.MapPath(ZNodeConfigManager.EnvironmentConfig.CrossSellImagePath));
            }
        }
        bool retval = false;

        // create transaction
        TransactionManager tranManager = ConnectionScope.CreateTransaction();

        if (ItemId > 0)
        {
            retval = categoryAdmin.Update(category);
        }
        else
        {
            retval = categoryAdmin.Add(category);
        }

        if (retval)
        {
            UrlRedirectAdmin urlRedirectAdmin = new UrlRedirectAdmin();
            bool status = false;

            try
            {
                status = urlRedirectAdmin.UpdateUrlRedirectTable(SEOUrlType.Category, mappedSEOUrl, category.SEOURL, category.CategoryID.ToString(), chkAddURLRedirect.Checked);
            }
            catch
            {
                //error occurred so rollback transaction
                tranManager.Rollback();
                lblMsg.Text = "The SEO Friendly URL you entered is already in use on another page. Please select another name for your URL.";

                return;
            }

            if (status) //check status whether urlmapping table updated successfully
            {
                //Commit transaction
                tranManager.Commit();

                if (ItemId > 0)
                    Response.Redirect("~/admin/secure/catalog/product_category/list.aspx");
                else
                    Response.Redirect("~/admin/secure/catalog/product_category/add_next.aspx");
            }
            else
            {
                //error occurred so rollback transaction
                tranManager.Rollback();

                lblMsg.Text = "Could not update the product category SEO Url. Please try again.";
            }
        }
        else
        {
            if (ItemId > 0)
                lblMsg.Text = "Could not update the product category. Please try again.";
            else
                lblMsg.Text = "Could not add the product category. Please try again.";

            return;
        }
    }
    /// <summary>
    /// Submit button click event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        CategoryAdmin categoryAdmin = new CategoryAdmin();
        Category category = new Category();
        string mappedSEOUrl = "";

        if (ItemId > 0)
        {
            category = categoryAdmin.GetByCategoryId(ItemId);

            if (category.SEOURL != null)
                mappedSEOUrl = category.SEOURL;
        }

        category.CategoryID = ItemId;
        category.PortalID = ZNodeConfigManager.SiteConfig.PortalID;
        category.ShortDescription = txtshortdescription.Text;
        category.Description = ctrlHtmlText.Html;
        category.Title = txtTitle.Text;
        category.SEOTitle = txtSEOTitle.Text;
        category.SEOKeywords = txtSEOMetaKeywords.Text;
        category.SEODescription = txtSEOMetaDescription.Text;
        category.SEOURL = null;
        if (txtSEOURL.Text.Trim().Length > 0)
            category.SEOURL = txtSEOURL.Text.Trim().Replace(" ", "-");

        bool retval = false;
        //create transaction
        TransactionManager tranManager = ConnectionScope.CreateTransaction();

        if (ItemId > 0)
        {
            retval = categoryAdmin.Update(category);
        }

        if (retval)
        {
            UrlRedirectAdmin urlRedirectAdmin = new UrlRedirectAdmin();
            bool status = false;

            try
            {
                status = urlRedirectAdmin.UpdateUrlRedirectTable(SEOUrlType.Category, mappedSEOUrl, category.SEOURL, ItemId.ToString(), chkAddURLRedirect.Checked);
            }
            catch
            {
                //error occurred so rollback transaction
                tranManager.Rollback();
                lblError.Text = "The SEO Friendly URL you entered is already in use on another page. Please select another name for your URL.";

                return;
            }

            if (status) // check status whether urlmapping table updated successfully
            {
                // Commit transaction
                tranManager.Commit();

                Response.Redirect(ManagePageLink);

            }
            else
            {
                //error occurred so rollback transaction
                tranManager.Rollback();

                lblError.Text = "Could not update the product category SEO Url. Please try again.";
            }
        }
        else
        {
            if (ItemId > 0)
                lblError.Text = "Could not update the product category. Please try again.";

            return;
        }
    }