Exemplo n.º 1
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        // *** On callbacks we don't need to populate any data since they are
        // *** raw method calls. Callback routes to parser from here
        if (this.Callback.IsCallback)
        {
            return;
        }

        Response.Expires = 0;

        if (!Manager.IsLocalizationTable(null))
        {
            this.ErrorDisplay.ShowError(Res("ResourceTableDoesntExist"));
            this.btnCreateTable.Visible = true;
            return;
        }

        this.GetResourceSet();

        DataTable dt = Manager.GetAllResourceIds(ResourceSet);

        if (dt == null)
        {
            this.ErrorDisplay.ShowError("Couldn't load resources: " + Manager.ErrorMessage);
            return;
        }

        this.lstResourceIds.DataSource     = dt;
        this.lstResourceIds.DataValueField = "ResourceId";
        this.lstResourceIds.DataBind();

        if (this.lstResourceIds.Items.Count > 0)
        {
            this.lstResourceIds.SelectedIndex = 0;
        }

        dt = Manager.GetAllLocaleIds(ResourceSet);
        if (dt == null)
        {
            this.ErrorDisplay.ShowError("Couldn't load resources: " + Manager.ErrorMessage);
            return;
        }

        foreach (DataRow row in dt.Rows)
        {
            string      Code = row["LocaleId"] as string;
            CultureInfo ci   = CultureInfo.GetCultureInfo(Code.Trim());

            if (Code != "")
            {
                row["Language"] = ci.DisplayName + " (" + ci.Name + ")";
            }
            else
            {
                row["Language"] = "Invariant";
            }
        }

        this.lstLanguages.DataSource     = dt;
        this.lstLanguages.DataValueField = "LocaleId";
        this.lstLanguages.DataTextField  = "Language";
        this.lstLanguages.DataBind();

        if (this.lstLanguages.Items.Count > 0)
        {
            this.lstLanguages.SelectedIndex = 0;
        }
        else
        {
            this.lstLanguages.Items.Add(new ListItem("Invariant", ""));
        }
    }
Exemplo n.º 2
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        //Check if has rights to edit
        //switch (SessionManager.LoggedUser.Role.InternalID)
        //{
        //    case (int)RoleTypes.SystemAdministrator:
        //        break;
        //    default:
        //        Response.Redirect("~/Default.aspx");
        //        break;
        //}

        // *** On callbacks we don't need to populate any data since they are
        // *** raw method calls. Callback routes to parser from here
        if (Callback.IsCallback)
        {
            return;
        }

        Response.Expires = 0;

        if (!Manager.IsLocalizationTable(null))
        {
            ErrorDisplay.ShowError(Res("ResourceTableDoesntExist"));
            btnCreateTable.Visible = true;
            return;
        }

        GetResourceSet();

        DataTable dt = Manager.GetAllResourceIds(ResourceSet);

        if (dt == null)
        {
            ErrorDisplay.ShowError("Couldn't load resources: " + Manager.ErrorMessage);
            return;
        }

        lstResourceIds.DataSource     = dt;
        lstResourceIds.DataValueField = "ResourceId";
        lstResourceIds.DataBind();

        if (lstResourceIds.Items.Count > 0)
        {
            lstResourceIds.SelectedIndex = 0;
        }

        dt = Manager.GetAllLocaleIds(ResourceSet);
        if (dt == null)
        {
            ErrorDisplay.ShowError("Couldn't load resources: " + Manager.ErrorMessage);
            return;
        }

        foreach (DataRow row in dt.Rows)
        {
            string      Code = row["LocaleId"] as string;
            CultureInfo ci   = CultureInfo.GetCultureInfo(Code.Trim());

            if (Code != "")
            {
                row["Language"] = ci.DisplayName + " (" + ci.Name + ")";
            }
            else
            {
                row["Language"] = "Invariant";
            }
        }

        lstLanguages.DataSource     = dt;
        lstLanguages.DataValueField = "LocaleId";
        lstLanguages.DataTextField  = "Language";
        lstLanguages.DataBind();

        if (lstLanguages.Items.Count > 0)
        {
            lstLanguages.SelectedIndex = 0;
        }
        else
        {
            lstLanguages.Items.Add(new ListItem("Invariant", ""));
        }
    }