Beispiel #1
0
    /// <summary>
    /// Gets and bulk updates timezones. Called when the "Get and bulk update timezones" button is pressed.
    /// Expects the CreateTimezone method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateTimezones()
    {
        // Prepare the parameters
        string where = "TimeZoneName LIKE N'MyNewTimezone%'";

        // Get the data
        DataSet timezones = TimeZoneInfoProvider.GetTimeZones(where, null);

        if (!DataHelper.DataSourceIsEmpty(timezones))
        {
            // Loop through the individual items
            foreach (DataRow timezoneDr in timezones.Tables[0].Rows)
            {
                // Create object from DataRow
                TimeZoneInfo modifyTimezone = new TimeZoneInfo(timezoneDr);

                // Update the properties
                modifyTimezone.TimeZoneDisplayName = modifyTimezone.TimeZoneDisplayName.ToUpper();

                // Save the changes
                TimeZoneInfoProvider.SetTimeZoneInfo(modifyTimezone);
            }

            return(true);
        }

        return(false);
    }
Beispiel #2
0
    /// <summary>
    /// Fill drop down list.
    /// </summary>
    /// <param name="ds">Data set with time zones</param>
    /// <param name="dataValue">Data value field</param>
    private void FillDropdown(string dataValue)
    {
        if (drpTimeZoneSelector.Items.Count == 0)
        {
            DataSet ds = TimeZoneInfoProvider.GetTimeZones(null, "TimeZoneGMT", -1, "TimeZoneID ,TimeZoneGMT, TimeZoneName, TimeZoneDisplayName");

            if (!DataHelper.DataSourceIsEmpty(ds))
            {
                string text = null;

                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    text = String.Format("(UTC{0:+00.00;-00.00}) {1}", row["TimeZoneGMT"], row["TimeZoneDisplayName"]);
                    drpTimeZoneSelector.Items.Add(new ListItem(text, row[dataValue].ToString()));
                }
            }

            // Add none record if needed
            if (AddNoneItemsRecord)
            {
                drpTimeZoneSelector.Items.Insert(0, new ListItem(GetString("General.SelectNone"), ""));
            }
        }
    }