예제 #1
0
    protected void Page_PreRenderOld(object sender, EventArgs e)
    {
        CalendarOptions options;

        try
        {
            options = CalendarOptions.Load(Server.MapPath(@"App_Data\LookupValues"));
        }
        catch
        {
            // temporary, as the service throws an exception for options not found
            // the service is not yet complete, but this allows testing of the UI
            options = CalendarOptions.CreateNew(Server.MapPath(@"App_Data\LookupValues"));
        }

        // set user defaults
        Utility.SetSelectedValue(ddlDefaultCalendarView, options.DefaultCalendarView);
        Utility.SetSelectedValue(ddlNumberOfEvents, options.NumberOfEvents);
        Utility.SetSelectedValue(ddlShowHistoryOnDayView, options.ShowHistoryOnDayView);
        Utility.SetSelectedValue(ddlRememberSelectedUsers, options.RememberSelectedUsers);
        Utility.SetSelectedValue(ddlDisplayContactAccount, options.DisplayContactAccount);

        if (!string.IsNullOrEmpty(options.DayStart))
        {
            DateTime timeHolder = DateTime.Parse(options.DayStart);
            ddlDayStart.ClearSelection();

            ListItem startItem = ddlDayStart.Items.FindByValue(timeHolder.ToString("t"));
            if (startItem != null)
            {
                startItem.Selected = true;
            }
            else
            {
                startItem = ddlDayStart.Items.FindByText(timeHolder.ToString("t"));
                if (startItem != null)
                {
                    startItem.Selected = true;
                }
            }
        }

        if (!string.IsNullOrEmpty(options.DayEnd))
        {
            DateTime timeHolder = DateTime.Parse(options.DayEnd);

            ddlDayEnd.ClearSelection();
            ListItem endItem = ddlDayEnd.Items.FindByValue(timeHolder.ToString("t"));
            if (endItem != null)
            {
                endItem.Selected = true;
            }
            else
            {
                endItem = ddlDayEnd.Items.FindByText(timeHolder.ToString("t"));
                if (endItem != null)
                {
                    endItem.Selected = true;
                }
            }
        }

        chkOpportunity.Checked = options.ShowOpportunities;
        chkPhoneNumber.Checked = options.ShowPhoneNumber;
        chkRegarding.Checked   = options.ShowRegarding;
        chkTime.Checked        = options.ShowTime;
        chkMon.Checked         = options.WorkWeekMon;
        chkTue.Checked         = options.WorkWeekTue;
        chkWed.Checked         = options.WorkWeekWed;
        chkThu.Checked         = options.WorkWeekThu;
        chkFri.Checked         = options.WorkWeekFri;
        chkSat.Checked         = options.WorkWeekSat;
        chkSun.Checked         = options.WorkWeekSun;

        Utility.SetSelectedValue(ddlDefaultInterval, options.DefaultInterval);
        Utility.SetSelectedValue(ddlDefaultActivityType, options.DefaultActivityType);
        Utility.SetSelectedValue(ddlFirstDayOfWeek, options.FirstDayOfWeek);
        Utility.SetSelectedValue(ddlFirstWeekOfYear, options.FirstWeekOfYear);
    }
예제 #2
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        CalendarOptions options = null;

        try
        {
            options = CalendarOptions.Load(Server.MapPath(@"App_Data\LookupValues"));
        }
        catch
        {
            // temporary, as the service throws an exception for options not found
            // the service is not yet complete, but this allows testing of the UI
            options = CalendarOptions.CreateNew(Server.MapPath(@"App_Data\LookupValues"));
        }

        _defaultCalendarView.DataSource     = options.DefaultCalendarViewLookupList;
        _defaultCalendarView.DataTextField  = options.DataTextField;
        _defaultCalendarView.DataValueField = options.DataValueField;

        _showHistoryOnDayView.DataSource     = options.ShowHistoryOnDayViewLookupList;
        _showHistoryOnDayView.DataTextField  = options.DataTextField;
        _showHistoryOnDayView.DataValueField = options.DataValueField;

        _showOnActivities.DataSource     = options.ShowOnActivitiesLookupList;
        _showOnActivities.DataTextField  = options.DataTextField;
        _showOnActivities.DataValueField = options.DataValueField;

        _dayStart.DataSource     = options.DayStartLookupList;
        _dayStart.DataTextField  = options.DataValueField;
        _dayStart.DataValueField = options.DataTextField;

        _dayEnd.DataSource     = options.DayEndLookupList;
        _dayEnd.DataTextField  = options.DataValueField;
        _dayEnd.DataValueField = options.DataTextField;

        _defaultInterval.DataSource     = options.DefaultIntervalLookupList;
        _defaultInterval.DataTextField  = options.DataValueField;
        _defaultInterval.DataValueField = options.DataValueField;

        _firstDayOfWeek.DataSource     = LocalizeLookup("DayOfWeek", options.FistDayOfWeekList);
        _firstDayOfWeek.DataTextField  = options.DataTextField;
        _firstDayOfWeek.DataValueField = options.DataValueField;


        DataBind();
        BindUsers();

        // set defaults
        Utility.SetSelectedValue(_defaultCalendarView, options.DefaultCalendarView);
        Utility.SetSelectedValue(_showHistoryOnDayView, options.ShowHistoryOnDayView);


        if (!Utility.SetSelectedValue(UserList, options.ViewCalendarFor))
        {
            Utility.SetSelectedValue(UserList,
                                     ((SLXUserService)(ApplicationContext.Current.Services.Get <IUserService>())).
                                     GetUser().Id.ToString());
        }

        Utility.SetSelectedValue(_showOnActivities, options.ShowOnActivities);

        if (!string.IsNullOrEmpty(options.DayStart))
        {
            DateTime timeHolder = DateTime.Parse(options.DayStart);
            _dayStart.ClearSelection();

            ListItem startItem = _dayStart.Items.FindByValue(timeHolder.ToString("t"));
            if (startItem != null)
            {
                startItem.Selected = true;
            }
            else
            {
                startItem = _dayStart.Items.FindByText(timeHolder.ToString("t"));
                if (startItem != null)
                {
                    startItem.Selected = true;
                }
            }
        }

        if (!string.IsNullOrEmpty(options.DayEnd))
        {
            DateTime timeHolder = DateTime.Parse(options.DayEnd);

            _dayEnd.ClearSelection();
            ListItem endItem = _dayEnd.Items.FindByValue(timeHolder.ToString("t"));
            if (endItem != null)
            {
                endItem.Selected = true;
            }
            else
            {
                endItem = _dayEnd.Items.FindByText(timeHolder.ToString("t"));
                if (endItem != null)
                {
                    endItem.Selected = true;
                }
            }
        }

        Utility.SetSelectedValue(_defaultInterval, options.DefaultInterval);
        Utility.SetSelectedValue(ddlDefaultActivityType, options.DefaultActivityType);
        Utility.SetSelectedValue(_firstDayOfWeek, options.FirstDayOfTheWeek);
    }