コード例 #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;
        }
    }