Пример #1
0
    /// <summary>
    /// Event triggered when a command button is clicked on the grid
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void uxGrid_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        // Convert the row index stored in the CommandArgument
        // property to an Integer.
        int index = Convert.ToInt32(e.CommandArgument);

        // Get the values from the appropriate
        // cell in the GridView control.
        GridViewRow selectedRow = uxGrid.Rows[index];

        TableCell Idcell = selectedRow.Cells[0];
        string Id = Idcell.Text;

        if (e.CommandName == "Edit")
        {
            Response.Redirect(EditPageLink + Id);
        }
        else if (e.CommandName == "Delete")
        {
            UrlRedirectAdmin urlRedirectAdmin = new UrlRedirectAdmin();
            UrlRedirect urlRedirect = urlRedirectAdmin.GetById(int.Parse(Id));

            bool status = urlRedirectAdmin.Delete(int.Parse(Id));

            if (status)
            {
                if (urlRedirect != null)
                {
                    ZNodeSEOUrl seoUrl = new ZNodeSEOUrl();
                    seoUrl.RemoveRedirectURL(urlRedirect.OldUrl);
                }

                Bind();
            }
        }
    }
Пример #2
0
    /// <summary>
    /// Submit Button Click Event
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        ProductAdmin productAdmin = new ProductAdmin();
        Product product = new Product();
        string mappedSEOUrl = "";

        // If edit mode then get all the values first
        if (ItemID > 0)
        {
            product = productAdmin.GetByProductId(ItemID);

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

        // Passing Values
        product.ProductID = ItemID;
        product.PortalID = ZNodeConfigManager.SiteConfig.PortalID;
        product.Name = txtProductName.Text;
        product.Description = ctrlHtmlDescription.Html.Trim();
        product.ShortDescription = txtshortdescription.Text;
        product.AdditionalInformation = ctrlHtmlProdInfo.Html.Trim();
        product.Specifications = ctrlHtmlPrdSpec.Html.Trim();
        product.FeaturesDesc = ctrlHtmlPrdFeatures.Html.Trim();

        product.SEOTitle = txtSEOTitle.Text.Trim();
        product.SEOKeywords = txtSEOMetaKeywords.Text.Trim();
        product.SEODescription = txtSEOMetaDescription.Text.Trim();
        product.SEOURL = null;

        if (txtSEOUrl.Text.Trim().Length > 0)
        {
            product.SEOURL = txtSEOUrl.Text.Trim().Replace(" ", "-");
        }

        bool status = false;

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

        try
        {
            if (ItemID > 0) // PRODUCT UPDATE
            {
                status = productAdmin.Update(product);
            }

        }
        catch (Exception)
        {
            // Error occurred so rollback transaction
            tranManager.Rollback();

            lblError.Text = "Unable to update product SEO settings. Please try again.";
            return;
        }

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

            try
            {
                retval = urlRedirectAdmin.UpdateUrlRedirectTable(SEOUrlType.Product, mappedSEOUrl, product.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 (retval)
            {
                // Commit transaction
                tranManager.Commit();

                Response.Redirect(ManagePageLink);
            }
            else
            {
                lblError.Text = "Could not update the product SEO Url. Please try again.";
            }
        }
        else
        {
            lblError.Text = "Unable to update product SEO settings. Please try again.";
        }
    }
Пример #3
0
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        UrlRedirectAdmin urlRedirectAdmin = new UrlRedirectAdmin();
        UrlRedirect urlRedirectEntity = new UrlRedirect();
        bool status = false;
        string oldSeoURL = "";
        bool activeInd = false;

        if (ItemId > 0)
        {
            urlRedirectEntity = urlRedirectAdmin.GetById(ItemId);
            oldSeoURL = urlRedirectEntity.OldUrl;
            activeInd = urlRedirectEntity.IsActive;
        }

        urlRedirectEntity.IsActive = chkIsActive.Checked;
        urlRedirectEntity.OldUrl = MakeUrl(txtOldUrl.Text.Trim());
        urlRedirectEntity.NewUrl = MakeUrl(txtNewUrl.Text.Trim());

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

        if (ItemId > 0)
        {
            status = urlRedirectAdmin.Update(urlRedirectEntity);
        }
        else
        {
            status = urlRedirectAdmin.Add(urlRedirectEntity);
        }

        if (status)
        {
            try
            {
                ZNodeSEOUrl seoUrl = new ZNodeSEOUrl();
                bool urlRedirectExists = urlRedirectAdmin.Exists(urlRedirectEntity.OldUrl, urlRedirectEntity.NewUrl, urlRedirectEntity.UrlRedirectID);

                if (ItemId > 0 && activeInd && !chkIsActive.Checked)
                {
                    status &= seoUrl.RemoveRedirectURL(oldSeoURL);
                }
                else if(chkIsActive.Checked && !urlRedirectExists)
                {
                    status &= seoUrl.AddRedirectUrl(oldSeoURL, urlRedirectEntity.OldUrl, urlRedirectEntity.NewUrl, chkIsActive.Checked);
                }
                else if(urlRedirectExists)
                {
                    status &= false;

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

                    lblMsg.Text = "Unable to update SEO Friendly URL. Please try again.";

                    return;
                }
            }
            catch
            {
                status = false;

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

                lblMsg.Text = "Unable to update SEO Friendly URL. Please try again.";

                return;
            }
        }

        if (status)
        {
            // Commit transaction
            tranManager.Commit();

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

            lblMsg.Text = "Unable to process your request.";
        }
    }