Exemplo n.º 1
0
        private void BindValues()
        {
            lstTimeZone.DataSource     = User.GetListTimeZone();
            lstTimeZone.DataTextField  = "DisplayName";
            lstTimeZone.DataValueField = "TimeZoneId";
            lstTimeZone.DataBind();
            string sTimeZoneId = Security.CurrentUser.TimeZoneId.ToString();

            ListItem[] liArray = new ListItem[5];
            liArray[0] = new ListItem(LocRM.GetString("First"), "1");
            liArray[1] = new ListItem(LocRM.GetString("Second"), "2");
            liArray[2] = new ListItem(LocRM.GetString("Third"), "3");
            liArray[3] = new ListItem(LocRM.GetString("Fourth"), "4");
            liArray[4] = new ListItem(LocRM.GetString("Last"), "8");
            WeekNumber32.Items.AddRange(liArray);
            WeekNumber42.Items.AddRange(liArray);

            liArray = new ListItem[7];
            int k = 0;

            foreach (System.DayOfWeek day in Enum.GetValues(typeof(System.DayOfWeek)))
            {
                liArray[k] = new ListItem(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.DayNames[(int)day], ((int)CalendarEntry.GetBitDayOfWeek(day)).ToString());
                k++;
            }

            Weekday32.Items.AddRange(liArray);
            Weekday42.Items.AddRange(liArray);

            liArray = new ListItem[12];
            for (int i = 1; i <= 12; i++)
            {
                liArray[i - 1] = new ListItem(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(i), i.ToString());
            }
            MonthNumber41.Items.AddRange(liArray);
            MonthNumber42.Items.AddRange(liArray);
            SetDefaulValues();
            if (EventId != 0)
            {
                using (IDataReader reader = CalendarEntry.GetRecurrence(EventId))
                {
                    ///		RecurrenceId, ObjectTypeId, ObjectId, StartTime,
                    ///		EndTime, Pattern, SubPattern, Frequency, Weekdays,
                    ///		DayOfMonth, WeekNumber, MonthNumber, EndAfter
                    if (reader.Read())
                    {
                        TimeStart   = (int)reader["StartTime"];
                        TimeEnd     = (int)reader["EndTime"];
                        Pattern     = (byte)reader["Pattern"];
                        SubPattern  = (byte)reader["SubPattern"];
                        Frequency   = (byte)reader["Frequency"];
                        Weekdays    = (byte)reader["Weekdays"];
                        MonthDay    = (byte)reader["DayOfMonth"];
                        WeekNumber  = (byte)reader["WeekNumber"];
                        MonthNumber = (byte)reader["MonthNumber"];
                        int iEndAfter = (int)reader["EndAfter"];
                        if (iEndAfter != 0)
                        {
                            rbEndBy.Checked    = false;
                            rbEndAfter.Checked = true;
                            tbEndAfter.Text    = iEndAfter.ToString();
                        }
                        else
                        {
                            rbEndAfter.Checked = false;
                            rbEndBy.Checked    = true;
                        }
                        if (reader["TimeZoneId"] != DBNull.Value)
                        {
                            sTimeZoneId = reader["TimeZoneId"].ToString();
                        }
                    }
                }
            }
            ListItem lItem = lstTimeZone.Items.FindByValue(sTimeZoneId);

            if (lItem != null)
            {
                lstTimeZone.ClearSelection();
                lItem.Selected = true;
            }
        }
Exemplo n.º 2
0
 private void BindValues()
 {
     using (IDataReader reader = CalendarEntry.GetRecurrence(EventId))
     {
         if (reader.Read())
         {
             lblNoRecurrence.Visible = false;
             ShowRecurrence.Visible  = true;
             DateTime dt = DateTime.MinValue.AddMinutes((int)reader["StartTime"]);
             txtStartTime.Text = dt.ToShortTimeString();
             dt = DateTime.MinValue.AddMinutes((int)reader["EndTime"]);
             txtEndTime.Text = dt.ToShortTimeString();
             Pattern         = (byte)reader["Pattern"];
             SubPattern      = (byte)reader["SubPattern"];
             Frequency       = (byte)reader["Frequency"];
             bWeekdays       = (byte)reader["Weekdays"];
             MonthDay        = (byte)reader["DayOfMonth"];
             bWeekNumber     = (byte)reader["WeekNumber"];
             MonthNumber     = (byte)reader["MonthNumber"];
             EndAfter        = (int)reader["EndAfter"];
             Label lblControl = (Label)this.FindControl("txtInfo" + Pattern + SubPattern);
             if (lblControl != null)
             {
                 lblControl.Visible = true;
             }
             if (EndAfter != 0)
             {
                 lblEnd.Text = LocRM.GetString("Endafter") + ":";
                 txtEnd.Text = EndAfter.ToString() + " " + LocRM.GetString("occurrences");
             }
             else
             {
                 using (IDataReader rdr = CalendarEntry.GetEvent(EventId))
                 {
                     if (rdr.Read())
                     {
                         lblEnd.Text = LocRM.GetString("Endby") + ":";
                         txtEnd.Text = ((DateTime)rdr["FinishDate"]).ToShortDateString();
                     }
                 }
             }
             if (reader["TimeZoneId"] != DBNull.Value)
             {
                 TimeSpan Offset = new TimeSpan(0, -User.GetTimeZoneBias((int)reader["TimeZoneId"]), 0);
                 txtTimeZone.Text = "GMT ";
                 if (Offset.TotalMinutes != 0)
                 {
                     string str = "";
                     str += (Offset.TotalMinutes > 0) ? "+" : "-";
                     if (Math.Abs(Offset.Hours) < 10)
                     {
                         str += "0";
                     }
                     str += Math.Abs(Offset.Hours).ToString() + ":";
                     if (Math.Abs(Offset.Minutes) < 10)
                     {
                         str += "0";
                     }
                     str += Math.Abs(Offset.Minutes).ToString();
                     txtTimeZone.Text += str;
                 }
             }
         }
         else
         {
             lblNoRecurrence.Text    = "<br>&nbsp; " + LocRM.GetString("NotSet") + "<br>&nbsp;";
             lblNoRecurrence.Visible = true;
             ShowRecurrence.Visible  = false;
         }
     }
     DataBind();
 }