Пример #1
0
    void UpdateDataView()
    {
        lbError.Visible = false;

        using (Database dbObj = Utils.GetMainDB())
        {
            using (DataSet ds = dbObj.RunSPReturnDataSet("_User_GetCulturesSorted", "cultures", new SqlParameter("@UserId", userId)))
            {
                dbObj.CloseConnection();
                if (dbObj.LastError.Length == 0)
                {
                    if (ds != null)
                    {
                        dg.DataSource = ds.Tables[0];
                        Utils.InitGridSort(ref dg, false);
                        dg.DataBind();
                        dg.DisplayLayout.AllowSortingDefault = AllowSorting.No;
                        ds.Dispose();

                        if (!SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_USERS) || SessionState.User.IsReadOnly)
                        {
                            TemplatedColumn colHeader      = (TemplatedColumn)dg.Columns.FromKey("Select");
                            HeaderItem      cellItemHeader = colHeader.HeaderItem;
                            CheckBox        cbHeader       = (CheckBox)cellItemHeader.FindControl("g_ca");
                            cbHeader.Enabled = false;

                            foreach (UltraGridRow r in dg.Rows)
                            {
                                TemplatedColumn col      = (TemplatedColumn)r.Cells.FromKey("Select").Column;
                                CellItem        cellItem = (CellItem)col.CellItems[r.Index];
                                CheckBox        cb       = (CheckBox)cellItem.FindControl("g_sd");
                                cb.Enabled = false;
                            }
                        }
                    }
                }
                else
                {
                    lbError.CssClass = "hc_error";
                    lbError.Text     = dbObj.LastError;
                    lbError.Visible  = true;
                }
            }
        }
    }
Пример #2
0
    private void BindLists()
    {
        SessionState.EditedUser.ClearNotifications();
        cv            = new HyperCatalog.Business.CollectionView(SessionState.EditedUser.Notifications);
        dg.DataSource = SessionState.EditedUser.Role.Notifications;
        dg.DataBind();
        Utils.InitGridSort(ref dg, false);

        if (!SessionState.User.HasCapability(CapabilitiesEnum.MANAGE_USERS) || SessionState.User.IsReadOnly)
        {
            TemplatedColumn colHeader      = (TemplatedColumn)dg.Columns.FromKey("Select");
            HeaderItem      cellItemHeader = colHeader.HeaderItem;
            CheckBox        cbHeader       = (CheckBox)cellItemHeader.FindControl("g_ca");
            cbHeader.Enabled = false;

            foreach (UltraGridRow r in dg.Rows)
            {
                TemplatedColumn col      = (TemplatedColumn)r.Cells.FromKey("Select").Column;
                CellItem        cellItem = (CellItem)col.CellItems[r.Index];
                CheckBox        cb       = (CheckBox)cellItem.FindControl("g_sd");
                cb.Enabled = false;
            }
        }
    }