示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.drpBadges.Items.Count == 0)
        {
            DataSet ds = BadgeInfoProvider.GetBadges(null, null, 0, "BadgeDisplayName, BadgeIsAutomatic, BadgeID");

            // Check dataset
            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    BadgeInfo bi = new BadgeInfo(dr);

                    // Create and add custom table list item
                    string name = ResHelper.LocalizeString(bi.BadgeDisplayName);
                    if (bi.BadgeIsAutomatic)
                    {
                        name += GetString("badge.automatic");
                    }

                    drpBadges.Items.Add(new ListItem(name, bi.BadgeID.ToString()));
                }

                drpBadges.Items.Insert(0, new ListItem(GetString("general.selectnone"), "0"));

                drpBadges.SelectedValue = mValue;
            }
        }
    }
示例#2
0
    /// <summary>
    /// Gets and bulk updates badges. Called when the "Get and bulk update badges" button is pressed.
    /// Expects the CreateBadge method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateBadges()
    {
        // Prepare the parameters
        string where = "BadgeName LIKE N'MyNewBadge%'";

        // Get the data
        DataSet badges = BadgeInfoProvider.GetBadges(where, null);

        if (!DataHelper.DataSourceIsEmpty(badges))
        {
            // Loop through the individual items
            foreach (DataRow badgeDr in badges.Tables[0].Rows)
            {
                // Create object from DataRow
                BadgeInfo modifyBadge = new BadgeInfo(badgeDr);

                // Update the properties
                modifyBadge.BadgeDisplayName = modifyBadge.BadgeDisplayName.ToUpper();

                // Save the changes
                BadgeInfoProvider.SetBadgeInfo(modifyBadge);
            }

            return(true);
        }

        return(false);
    }
示例#3
0
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        if (drpBadges.Items.Count > 0)
        {
            return;
        }

        var badges = BadgeInfoProvider.GetBadges().Columns("BadgeDisplayName, BadgeIsAutomatic, BadgeID");

        foreach (BadgeInfo badge in badges)
        {
            string badgeDisplayName = ResHelper.LocalizeString(badge.BadgeDisplayName);
            if (badge.BadgeIsAutomatic)
            {
                badgeDisplayName += GetString("badge.automatic");
            }
            drpBadges.Items.Add(new ListItem(badgeDisplayName, badge.BadgeID.ToString()));
        }
        drpBadges.Items.Insert(0, new ListItem(GetString("general.selectnone"), "0"));
    }
示例#4
0
    /// <summary>
    /// Gets and bulk updates badges. Called when the "Get and bulk update badges" button is pressed.
    /// Expects the CreateBadge method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateBadges()
    {
        // Prepare the parameters
        string where = "BadgeName LIKE N'MyNewBadge%'";

        // Get the data from database
        var badges = BadgeInfoProvider.GetBadges().Where(where);

        // Loop through the individual items
        foreach (BadgeInfo modifyBadge in badges)
        {
            // Update the properties
            modifyBadge.BadgeDisplayName = modifyBadge.BadgeDisplayName.ToUpper();

            // Save the changes
            BadgeInfoProvider.SetBadgeInfo(modifyBadge);
        }

        // Return TRUE if any object was found and updated, FALSE otherwise
        return(badges.Count > 0);
    }