コード例 #1
0
    private void Save()
    {
        lbError.Visible = false;

        HyperCatalog.Business.LinkType linkType = HyperCatalog.Business.LinkType.GetByKey(linkTypeId);
        if (linkType != null)
        {
            if (dg != null)
            {
                System.Text.StringBuilder sItemTypes = new System.Text.StringBuilder(String.Empty);
                foreach (Infragistics.WebUI.UltraWebGrid.UltraGridRow r in dg.Rows)
                {
                    Infragistics.WebUI.UltraWebGrid.TemplatedColumn col = (Infragistics.WebUI.UltraWebGrid.TemplatedColumn)r.Cells.FromKey("Select").Column;
                    CheckBox cb = (CheckBox)((Infragistics.WebUI.UltraWebGrid.CellItem)col.CellItems[r.Index]).FindControl("g_sd");
                    if (cb.Checked)
                    {
                        string itemTypeId = r.Cells.FromKey("ItemTypeId").Value.ToString();
                        if (sItemTypes.Length > 0)
                        {
                            sItemTypes.Append("|");
                        }

                        sItemTypes.Append(itemTypeId);
                    }
                }

                if (!linkType.SaveItemTypes(sItemTypes.ToString()))
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = HyperCatalog.Business.LinkType.LastError;
                    lbError.Visible  = true;
                }
                else
                {
                    // Refresh title tab
                    UITools.RefreshTab(Page, "ItemTypes", linkType.GetItemTypeCount());

                    lbError.CssClass = "hc_success";
                    lbError.Text     = "Data saved!";
                    lbError.Visible  = true;
                }
            }
        }
        else
        {
            lbError.CssClass = "hc_error";
            lbError.Text     = "Link type (" + linkTypeId + ") doesn't exist";
            lbError.Visible  = true;
        }
    }
コード例 #2
0
    private void UpdateDataView()
    {
        lbError.Visible = false;
        DataSet ds = null;

        HyperCatalog.Business.LinkType linkType = HyperCatalog.Business.LinkType.GetByKey(linkTypeId);
        try
        {
            if (linkType != null)
            {
                ds = linkType.GetItemTypes();

                if (ds != null)
                {
                    dg.DataSource = ds;
                    Utils.InitGridSort(ref dg, false);
                    dg.DataBind();

                    dg.DisplayLayout.AllowSortingDefault = Infragistics.WebUI.UltraWebGrid.AllowSorting.No;

                    lbNoresults.Visible = false;
                    dg.Visible          = true;
                }
                else
                {
                    dg.Visible          = false;
                    lbNoresults.Visible = true;
                }
            }
        }
        finally
        {
            if (ds != null)
            {
                ds.Dispose();
            }
        }
    }