Beispiel #1
0
        void UpdateDataEdit(string selLinkTypeId)
        {
            panelGrid.Visible = false;

            if ((selLinkTypeId != null) && (selLinkTypeId.Length > 0))
            {
                webTab.EnableViewState = false;
                webTab.Tabs.FromKeyTab("Properties").ContentPane.TargetUrl = "./linktypes/linktype_properties.aspx?t=" + selLinkTypeId;

                LinkType linkType = LinkType.GetByKey(Convert.ToInt32(selLinkTypeId));
                if (linkType == null)                  // create new link type
                {
                    lbTitle.Text = "LinkType: New";
                    webTab.Tabs.FromKeyTab("Items").Visible     = false; // hide Items tab
                    webTab.Tabs.FromKeyTab("ItemTypes").Visible = false; // hide ItemTypes tab
                }
                else                                                     // update link type
                {
                    lbTitle.Text = "LinkType: " + linkType.Name;
                    webTab.Tabs.FromKeyTab("Items").ContentPane.TargetUrl = "./linktypes/linktype_items.aspx?t=" + selLinkTypeId;
                    webTab.Tabs.FromKeyTab("Items").Visible = true;
                    webTab.Tabs.FromKeyTab("Items").Text    = "Items (" + linkType.GetItemCount(false).ToString() + ")";              // LinkFrom is false (count of companions)

                    lbTitle.Text = "LinkType: " + linkType.Name;
                    webTab.Tabs.FromKeyTab("ItemTypes").ContentPane.TargetUrl = "./linktypes/linktype_itemtypes.aspx?t=" + selLinkTypeId;
                    webTab.Tabs.FromKeyTab("ItemTypes").Visible = true;
                    webTab.Tabs.FromKeyTab("ItemTypes").Text    = "Item types (" + linkType.GetItemTypeCount().ToString() + ")";
                }
                webTab.Visible = true;
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_LINKS))
            {
                System.Int64 itemId     = -1;        // selected item
                string       linkFrom   = string.Empty;
                int          linkTypeId = -1;        // id of the link type

                try
                {
                    // get properties
                    if (Request["f"] != null)
                    {
                        linkFrom = Request["f"].ToString();
                    }
                    if (Request["t"] != null)
                    {
                        linkTypeId = Convert.ToInt32(Request["t"]);
                    }
                    if (Request["i"] != null)
                    {
                        itemId = Convert.ToInt64(Request["i"]);
                    }

                    using (LinkType linkType = LinkType.GetByKey(linkTypeId))
                    {
                        // update title
                        Infragistics.WebUI.UltraWebToolbar.TBLabel lblTitle = uwToolBarTitle.Items.FromKeyLabel("Title");
                        lblTitle.Text = "New link";
                        if (linkType != null)
                        {
                            lblTitle.Text = lblTitle.Text + " [" + linkType.Name + "]";
                        }
                    }
                }
                catch (FormatException fe)
                {
                    UITools.DenyAccess(DenyMode.Popup);
                }

                // initialize tabs
                webTab.Tabs.FromKeyTab("Treeview").ContentPane.TargetUrl = webTab.Tabs.FromKeyTab("Treeview").ContentPane.TargetUrl + "?i=" + itemId + "&t=" + linkTypeId + "&f=" + linkFrom;
                webTab.Tabs.FromKeyTab("Editor").ContentPane.TargetUrl   = webTab.Tabs.FromKeyTab("Editor").ContentPane.TargetUrl + "?i=" + itemId + "&t=" + linkTypeId + "&f=" + linkFrom;
            }
            else
            {
                UITools.DenyAccess(DenyMode.Popup);
            }
        }
    protected void Page_Load(object sender, System.EventArgs e)
    {
        try
        {
            // Get parameters (Id of link type)
            if (Request["t"] != null)
            {
                linkTypeId = Convert.ToInt32(Request["t"]);
            }
            LinkType lt = LinkType.GetByKey(linkTypeId);

            if (lt != null)
            {
                linkFrom = uwToolbar.Items.FromKeyButton("LinkToFrom").Text.Equals("Display companions");

                if (!Page.IsPostBack)
                {
                    if (HyperCatalog.Shared.SessionState.User.HasCapability(CapabilitiesEnum.EXTEND_CONTENT_MODEL) &&
                        !HyperCatalog.Shared.SessionState.User.IsReadOnly)
                    {
                        UpdateTitles(); // Update grid title and tree title
                        InitTreeView(); // Init tree view
                        pnlTreeView.Visible = pnlTitleTreeView.Visible = true;
                    }
                    else
                    {
                        pnlTreeView.Visible = pnlTitleTreeView.Visible = false;
                    }
                    ExpandNodes();    // Expand nodes in tree view if a node is checked
                    UpdateDataView(); // Update grid
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", "<script>back();</script>");
            }
        }
        catch
        {
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", "<script>back();</script>");
        }
    }
Beispiel #4
0
    private void Delete()
    {
        lbError.Visible = false;

        // Retrieve link type selected
        LinkType linkType = LinkType.GetByKey(linkTypeId);

        if (linkType != null)
        {
            if (linkType.Delete(HyperCatalog.Shared.SessionState.User.Id))
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "back", "<script>back();</script>");
            }
            else
            {
                lbError.CssClass = "hc_error";
                lbError.Text     = LinkType.LastError;
                lbError.Visible  = true;
            }
        }
    }
Beispiel #5
0
    private void UpdateDataView()
    {
        lbError.Visible = false;

        if (linkTypeId == -1)         // new link type
        {
            // Default value
            cbBidirectional.Checked = true;
            wneTypeId.Value         = -1;

            // hide Id of the link type
            pnlId.Visible = false;

            // hide Delete button
            UITools.HideToolBarButton(uwToolbar, "Delete");
            UITools.HideToolBarSeparator(uwToolbar, "DeleteSep");
        }
        else         // update link type
        {
            LinkType linkType = LinkType.GetByKey(linkTypeId);
            if (linkType != null)
            {
                // update field
                wneTypeId.Value         = linkType.Id;
                txtTypeName.Text        = linkType.Name;
                cbBidirectional.Checked = linkType.IsBidirectional;
                txtIcon.Text            = linkType.Icon;
                txtDescription.Text     = linkType.Description;

                // show Id of the link type but it is disable
                lbTypeId.Visible  = true;
                wneTypeId.Visible = true;
                wneTypeId.Enabled = false;

                int linkCount = linkType.GetLinkCount();
                cbBidirectional.Enabled = !(linkCount > 0);
            }
        }
    }
    private bool RemoveItem(string itemId)
    {
        lbError.Visible = false;
        using (LinkType lt = LinkType.GetByKey(linkTypeId))
        {
            if ((itemId != null) && (lt != null))
            {
                if (!lt.RemoveItem(Convert.ToInt64(itemId), linkFrom))
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = LinkType.LastError;
                    lbError.Visible  = true;

                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Beispiel #7
0
    private void InitializeLinksGridGrouping()
    {
        int      i = 0;
        int      groupLinkTypeCount = 0;
        int      groupLinkFromCount = 0;
        int      groupFamilyCount   = 0;
        bool     currentLinkFrom    = false;
        string   currentFamily      = string.Empty;
        LinkType currentLinkType    = null;
        bool     newLinkType        = true;
        bool     newLinkFrom        = true;

        while (i < dg.Rows.Count)
        {
            #region Group by LinkType
            int linkTypeId = Convert.ToInt32(dg.Rows[i].Cells.FromKey("LinkTypeId").Value);
            if (i == 0 || (currentLinkType != null && currentLinkType.Id != linkTypeId))
            {
                currentLinkType = LinkType.GetByKey(linkTypeId);
                newLinkType     = true;
                dg.Rows.Insert(i, new UltraGridRow());
                UltraGridRow  groupRow     = dg.Rows[i];
                UltraGridCell groupCellMax = groupRow.Cells[dg.Columns.Count - 1]; // initialize all cells for this row
                foreach (UltraGridCell cell in groupRow.Cells)
                {
                    cell.Style.CssClass = string.Empty;
                }
                dg.Rows[i].Style.CssClass = "ptbgroup";
                UltraGridCell groupCell = groupRow.Cells.FromKey("Class");
                groupCell.Text    = HyperCatalog.Business.LinkType.GetByKey(linkTypeId).Name;
                groupCell.ColSpan = 4;
                i++;
            }
            #endregion

            if (currentLinkType != null && currentLinkType.IsBidirectional && dg.Rows[i].Cells.FromKey("LinkFrom") != null)
            {
                #region Group by LinkFrom
                bool linkFrom = Convert.ToBoolean(dg.Rows[i].Cells.FromKey("LinkFrom").Value);
                if (newLinkType || currentLinkFrom != linkFrom)
                {
                    currentLinkFrom = linkFrom;
                    newLinkFrom     = true;
                    newLinkType     = false;
                    dg.Rows.Insert(i, new UltraGridRow());
                    UltraGridRow  groupRow     = dg.Rows[i];
                    UltraGridCell groupCellMax = groupRow.Cells[dg.Columns.Count - 1]; // initialize all cells for this row
                    foreach (UltraGridCell cell in groupRow.Cells)
                    {
                        cell.Style.CssClass = string.Empty;
                    }
                    dg.Rows[i].Style.CssClass = "ptb4";
                    UltraGridCell groupCell = groupRow.Cells.FromKey("Class");
                    if (linkFrom)
                    {
                        groupCell.Text = "Companion list";
                    }
                    else
                    {
                        //Code modified for Links Requirement (PR668013) - to change 'Hardware' to 'Host' by Prachi on 10th Dec 2012
                        //groupCell.Text = "Hardware list";
                        groupCell.Text = "Host list";
                    }

                    groupCell.ColSpan = 4;
                    i++;
                }
                #endregion

                #region Group by Family
                if (dg.Rows[i].Cells.FromKey("Family") != null && dg.Rows[i].Cells.FromKey("Family").Value != null)
                {
                    string family = string.Empty;
                    if (linkFrom) // Companion list
                    {
                        family = dg.Rows[i].Cells.FromKey("SubFamily").Value.ToString();
                    }
                    else // Hardware list
                    {
                        family = dg.Rows[i].Cells.FromKey("Family").Value.ToString();
                    }
                    if (newLinkType || newLinkFrom || currentFamily != family)
                    {
                        currentFamily = family;
                        newLinkType   = false;
                        newLinkFrom   = false;
                        dg.Rows.Insert(i, new UltraGridRow());
                        UltraGridRow  groupRow     = dg.Rows[i];
                        UltraGridCell groupCellMax = groupRow.Cells[dg.Columns.Count - 1]; // initialize all cells for this row
                        foreach (UltraGridCell cell in groupRow.Cells)
                        {
                            cell.Style.CssClass = string.Empty;
                        }
                        dg.Rows[i].Style.CssClass = "ptb5";
                        UltraGridCell groupCell = groupRow.Cells.FromKey("Class");
                        groupCell.Text    = family;
                        groupCell.ColSpan = 4;
                        i++;
                    }
                }
                #endregion
            }

            #region bidirectional link type
            if (dg.Rows[i].Cells.FromKey("Bidirectional") != null && dg.Rows[i].Cells.FromKey("Bidirectional").Value != null)
            {
                bool isBidirectional = Convert.ToBoolean(dg.Rows[i].Cells.FromKey("Bidirectional").Value);
                if (!isBidirectional && dg.Rows[i].Cells.FromKey("Name") != null) // Cross sell, Bundle, ...
                {
                    dg.Rows[i].Cells.FromKey("Name").ColSpan = 2;
                }
            }
            #endregion

            i++;
        }
    }
Beispiel #8
0
    private void Save()
    {
        lbError.Visible = false;

        LinkType linkType = null;

        if (linkTypeId == -1)         // new link type
        {
            linkType = new LinkType(linkTypeId, txtTypeName.Text, txtIcon.Text, txtDescription.Text, 0, cbBidirectional.Checked);
        }
        else
        {
            linkType = LinkType.GetByKey(linkTypeId);

            // Update field
            if (linkType != null)
            {
                linkType.Name            = txtTypeName.Text;
                linkType.Icon            = txtIcon.Text;
                linkType.Description     = txtDescription.Text;
                linkType.IsBidirectional = cbBidirectional.Checked;
            }
            else
            {
                lbError.CssClass = "hc_error";
                lbError.Text     = "Link type doesn't exist";
                lbError.Visible  = true;

                return;
            }
        }

        // Save link type
        if (linkType.Save())
        {
            if (linkTypeId == -1)             // created link type
            {
                linkTypeId = linkType.Id;

                // Show Delete button
                if (SessionState.User.HasCapability(CapabilitiesEnum.EXTEND_CONTENT_MODEL))
                {
                    UITools.ShowToolBarSeparator(uwToolbar, "DeleteSep");
                    UITools.ShowToolBarButton(uwToolbar, "Delete");
                }

                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientScript", "<script>DisplayTab(" + linkType.Id + ");</script>");
            }
            else             // updated link type
            {
                lbError.Text     = "Data saved!";
                lbError.CssClass = "hc_success";
                lbError.Visible  = true;
            }
        }
        else
        {
            lbError.CssClass = "hc_error";
            lbError.Text     = LinkType.LastError;
            lbError.Visible  = true;
        }
    }