public TimeZone GetT10n()
 {
     // 08/30/2005 Paul.  Move the TimeZone creation to this get function so that the first control
     // that gets created will cause the creation of TimeZone.  The UserControls get the OnInit event before the Page onInit event.
     if (T10n == null)
     {
         m_gTIMEZONE = Sql.ToGuid(Session["USER_SETTINGS/TIMEZONE"]);
         T10n        = TimeZone.CreateTimeZone(m_gTIMEZONE);
         if (T10n.ID != m_gTIMEZONE)
         {
             // 08/30/2005 Paul. If we are using a default, then update the session so that future controls will be quicker.
             m_gTIMEZONE = T10n.ID;
             Session["USER_SETTINGS/TIMEZONE"] = m_gTIMEZONE.ToString();
         }
     }
     return(T10n);
 }
示例#2
0
 public TimeZone GetT10n()
 {
     // 08/30/2005 Paul.  Attempt to get the L10n & T10n objects from the parent page.
     // If that fails, then just create them because they are required.
     if (T10n == null)
     {
         // 04/30/2006 Paul.  Use the Context to store pointers to the localization objects.
         // This is so that we don't need to require that the page inherits from SplendidPage.
         // A port to DNN prompted this approach.
         T10n = Context.Items["T10n"] as TimeZone;
         if (T10n == null)
         {
             Guid gTIMEZONE = Sql.ToGuid(Session["USER_SETTINGS/TIMEZONE"]);
             T10n = TimeZone.CreateTimeZone(gTIMEZONE);
         }
     }
     return(T10n);
 }
        private void OnDataBinding(object sender, EventArgs e)
        {
            Literal      lbl          = (Literal)sender;
            DataGridItem objContainer = (DataGridItem)lbl.NamingContainer;
            DataRowView  row          = objContainer.DataItem as DataRowView;

            if (row != null)
            {
                // 04/30/2006 Paul.  Use the Context to store pointers to the localization objects.
                // This is so that we don't need to require that the page inherits from SplendidPage.
                TimeZone T10n = HttpContext.Current.Items["T10n"] as TimeZone;
                if (T10n == null)
                {
                    Guid gTIMEZONE = Sql.ToGuid(HttpContext.Current.Session["USER_SETTINGS/TIMEZONE"]);
                    T10n = TimeZone.CreateTimeZone(gTIMEZONE);
                }
                // 05/09/2006 Paul.  Convert the currency values before displaying.
                // The UI culture should already be set to format the currency.
                Currency C10n = HttpContext.Current.Items["C10n"] as Currency;
                if (C10n == null)
                {
                    Guid gCURRENCY_ID = Sql.ToGuid(HttpContext.Current.Session["USER_SETTINGS/CURRENCY"]);
                    C10n = Currency.CreateCurrency(gCURRENCY_ID);
                }
                if (row[sDATA_FIELD] != DBNull.Value)
                {
                    switch (sDATA_FORMAT)
                    {
                    case "DateTime":
                        if (T10n != null)
                        {
                            lbl.Text = Sql.ToString(T10n.FromServerTime(row[sDATA_FIELD]));
                        }
                        break;

                    case "Date":
                        if (T10n != null)
                        {
                            lbl.Text = Sql.ToDateString(T10n.FromServerTime(row[sDATA_FIELD]));
                        }
                        break;

                    case "Currency":
                    {
                        float f = Sql.ToFloat(row[sDATA_FIELD]);
                        f = C10n.ToCurrency(f);
                        Decimal d = Convert.ToDecimal(f);
                        lbl.Text = d.ToString("c");
                        break;
                    }

                    default:
                        lbl.Text = Sql.ToString(row[sDATA_FIELD]);
                        break;
                    }
                }
            }
            else
            {
                lbl.Text = sDATA_FIELD;
            }
        }