protected void ProductsGrid_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            if (e.CommandName.StartsWith("Do_"))
            {
                int     productId = AlwaysConvert.ToInt(e.CommandArgument);
                Product product   = ProductDataSource.Load(productId);
                switch (e.CommandName)
                {
                case "Do_Copy":
                    int newProductId = CatalogDataSource.Copy(productId, CatalogNodeType.Product, 0);
                    Response.Redirect(string.Format("EditProduct.aspx?ProductId={0}", newProductId));
                    break;

                case "Do_Delete":
                    if (product != null)
                    {
                        product.Delete();
                    }
                    break;

                case "Do_Pub":
                    // TOGGLE VISIBILITY
                    switch (product.Visibility)
                    {
                    case CatalogVisibility.Public:
                        product.Visibility = CatalogVisibility.Hidden;
                        break;

                    case CatalogVisibility.Hidden:
                        product.Visibility = CatalogVisibility.Private;
                        break;

                    default:
                        product.Visibility = CatalogVisibility.Public;
                        break;
                    }
                    product.Save();
                    break;
                }
                PG.DataBind();
            }
        }
Example #2
0
        protected void CGrid_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            if (e.CommandName.StartsWith("Do_"))
            {
                string[]        args            = e.CommandArgument.ToString().Split("|".ToCharArray());
                CatalogNodeType catalogNodeType = (CatalogNodeType)AlwaysConvert.ToInt(args[0]);
                int             catalogNodeId   = AlwaysConvert.ToInt(args[1]);
                switch (e.CommandName)
                {
                case "Do_Open":
                    //IF CATEGORY, REBIND CURRENT PAGE,
                    //OTHERWISE REDIRECT TO CORRECT EDIT PAGE
                    switch (catalogNodeType)
                    {
                    case CatalogNodeType.Category:
                        //REBIND CURRENT CATEGORY
                        CurrentCategoryId = catalogNodeId;
                        //RESET PAGE INDEX
                        CGrid.PageIndex = 0;
                        break;

                    case CatalogNodeType.Product:
                        Response.Redirect("~/Admin/Products/EditProduct.aspx?CategoryId=" + CurrentCategoryId.ToString() + "&ProductId=" + catalogNodeId.ToString());
                        break;

                    case CatalogNodeType.Webpage:
                        Response.Redirect("~/Admin/Catalog/EditWebpage.aspx?CategoryId=" + CurrentCategoryId.ToString() + "&WebpageId=" + catalogNodeId.ToString());
                        break;

                    case CatalogNodeType.Link:
                        Response.Redirect("~/Admin/Catalog/EditLink.aspx?CategoryId=" + CurrentCategoryId.ToString() + "&LinkId=" + catalogNodeId.ToString());
                        break;
                    }
                    break;

                case "Do_Copy":
                    // THIS WILL COPY THE PRODUCTS WITH THE ORIGNAL CATEGORY INFORMATION PRESERVED
                    CatalogDataSource.Copy(catalogNodeId, catalogNodeType, 0);
                    break;

                case "Do_Delete":
                    DoDelete(catalogNodeType, catalogNodeId);
                    break;

                case "Do_Pub":
                    ICatalogable pubNode = CatalogDataSource.Load(catalogNodeId, catalogNodeType);
                    if (pubNode != null)
                    {
                        //FOR CATEGORIES, WE MUST FIND OUT MORE INFORMATION
                        if (pubNode is Category)
                        {
                            Response.Redirect("ChangeVisibility.aspx?CategoryId=" + ((Category)pubNode).ParentId.ToString() + String.Format("&Objects={0}:{1}", ((Category)pubNode).Id, (byte)(CatalogNodeType.Category)));
                        }
                        //FOR OTHER OBJECTS, WE CAN ADJUST
                        switch (pubNode.Visibility)
                        {
                        case CatalogVisibility.Public:
                            pubNode.Visibility = CatalogVisibility.Hidden;
                            break;

                        case CatalogVisibility.Hidden:
                            pubNode.Visibility = CatalogVisibility.Private;
                            break;

                        default:
                            pubNode.Visibility = CatalogVisibility.Public;
                            break;
                        }
                        if (pubNode is Product)
                        {
                            ((Product)pubNode).Save();
                        }
                        else if (pubNode is Webpage)
                        {
                            ((Webpage)pubNode).Save();
                        }
                        else if (pubNode is Link)
                        {
                            ((Link)pubNode).Save();
                        }
                    }
                    break;
                }
            }
            CGrid.DataBind();
        }
Example #3
0
        protected void CGrid_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            if (e.CommandName.StartsWith("Do_"))
            {
                string[]        args            = e.CommandArgument.ToString().Split("|".ToCharArray());
                CatalogNodeType catalogNodeType = (CatalogNodeType)AlwaysConvert.ToInt(args[0]);
                int             catalogNodeId   = AlwaysConvert.ToInt(args[1]);
                int             index;
                switch (e.CommandName)
                {
                case "Do_Copy":
                    CatalogDataSource.Copy(catalogNodeId, catalogNodeType, CurrentCategory.Id);
                    break;

                case "Do_Delete":
                    DoDelete(catalogNodeType, catalogNodeId);
                    break;

                case "Do_Up":
                    index = CurrentCategory.CatalogNodes.IndexOf(CurrentCategory.Id, catalogNodeId, (byte)catalogNodeType);
                    if (index > 0)
                    {
                        CatalogNode tempNode = CurrentCategory.CatalogNodes[index - 1];
                        CurrentCategory.CatalogNodes[index - 1] = CurrentCategory.CatalogNodes[index];
                        CurrentCategory.CatalogNodes[index]     = tempNode;
                        short newOrderBy = 0;
                        foreach (CatalogNode node in CurrentCategory.CatalogNodes)
                        {
                            node.OrderBy = newOrderBy;
                            node.Save();
                            newOrderBy++;
                        }

                        // recalculate orderby for impacted child products
                        RecalculateOrderBy(CurrentCategory.CatalogNodes[index - 1]);
                        RecalculateOrderBy(CurrentCategory.CatalogNodes[index]);
                    }
                    break;

                case "Do_Down":
                    index = CurrentCategory.CatalogNodes.IndexOf(CurrentCategory.Id, catalogNodeId, (byte)catalogNodeType);
                    if (index < CurrentCategory.CatalogNodes.Count - 1)
                    {
                        CatalogNode tempNode = CurrentCategory.CatalogNodes[index + 1];
                        CurrentCategory.CatalogNodes[index + 1] = CurrentCategory.CatalogNodes[index];
                        CurrentCategory.CatalogNodes[index]     = tempNode;
                        short newOrderBy = 0;
                        foreach (CatalogNode node in CurrentCategory.CatalogNodes)
                        {
                            node.OrderBy = newOrderBy;
                            node.Save();
                            newOrderBy++;
                        }

                        // recalculate orderby for impacted child products
                        RecalculateOrderBy(CurrentCategory.CatalogNodes[index + 1]);
                        RecalculateOrderBy(CurrentCategory.CatalogNodes[index]);
                    }
                    break;

                case "Do_Pub":
                    index = CurrentCategory.CatalogNodes.IndexOf(CurrentCategory.Id, catalogNodeId, (byte)catalogNodeType);
                    if (index > -1)
                    {
                        CatalogNode node = CurrentCategory.CatalogNodes[index];
                        //FOR CATEGORIES, WE MUST FIND OUT MORE INFORMATION
                        if (node.CatalogNodeType == CatalogNodeType.Category)
                        {
                            Response.Redirect("ChangeVisibility.aspx?CategoryId=" + CurrentCategory.Id.ToString() + String.Format("&Objects={0}:{1}", node.CatalogNodeId, (byte)node.CatalogNodeType));
                        }
                        //FOR OTHER OBJECTS, WE CAN ADJUST
                        switch (node.Visibility)
                        {
                        case CatalogVisibility.Public:
                            node.Visibility = CatalogVisibility.Hidden;
                            break;

                        case CatalogVisibility.Hidden:
                            node.Visibility = CatalogVisibility.Private;
                            break;

                        default:
                            node.Visibility = CatalogVisibility.Public;
                            break;
                        }
                        node.ChildObject.Visibility = node.Visibility;
                        node.Save(true);
                    }
                    break;
                }
            }
        }