示例#1
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            FirstDayOfWeek = DateTimeHelper.GetFirstDayOfWeek(DateTime.Now);
            LastDayOfWeek  = FirstDayOfWeek.AddDays(6);

            rcRangeSelection.CultureInfo        = new CultureInfo("ru-RU");
            ucResponsible.SelectedIndexChanged += ucResponsible_SelectedIndexChanged;

            if (!rdpStartDate.SelectedDate.HasValue && !rdpEndDate.SelectedDate.HasValue)
            {
                var dataManager  = new DataManager();
                var userSettings = dataManager.UserSettings.SelectByClassName(CurrentUser.Instance.ID, TaskWidgetFilterClassName);
                if (userSettings != null)
                {
                    var filter = new TaskFilterSettings();
                    filter.Deserialize(userSettings.UserSettings);
                    rdpStartDate.SelectedDate = filter.StartDate;
                    rdpEndDate.SelectedDate   = filter.EndDate;
                    rcRangeSelection.RangeSelectionStartDate = filter.StartDate;
                    rcRangeSelection.RangeSelectionEndDate   = filter.EndDate;
                    ucResponsible.SelectedValue = filter.ResponsibleId;
                    FireFilterChangedEvent();
                }
                else
                {
                    rdpStartDate.SelectedDate = DateTime.Now;
                    rdpEndDate.SelectedDate   = DateTime.Now;
                    rcRangeSelection.RangeSelectionStartDate = DateTime.Now;
                    rcRangeSelection.RangeSelectionEndDate   = DateTime.Now;
                    FireFilterChangedEvent();
                }
            }
        }
示例#2
0
        /// <summary>
        /// Saves the settings.
        /// </summary>
        protected void SaveSettings()
        {
            var dataManager  = new DataManager();
            var userSettings = dataManager.UserSettings.SelectByClassName(CurrentUser.Instance.ID, TaskWidgetFilterClassName) ?? new tbl_UserSettings();
            var filter       = new TaskFilterSettings
            {
                StartDate     = rdpStartDate.SelectedDate ?? DateTime.Now,
                EndDate       = rdpEndDate.SelectedDate ?? DateTime.Now,
                ResponsibleId = ucResponsible.SelectedValue
            };

            userSettings.UserID       = CurrentUser.Instance.ID;
            userSettings.ClassName    = TaskWidgetFilterClassName;
            userSettings.UserSettings = filter.Serialize();

            dataManager.UserSettings.Save(userSettings);

            rcRangeSelection.RangeSelectionStartDate = rdpStartDate.SelectedDate ?? DateTime.Now;
            rcRangeSelection.RangeSelectionEndDate   = rdpEndDate.SelectedDate ?? DateTime.Now;

            Session["sd"] = rdpStartDate.SelectedDate;
            Session["ed"] = rdpEndDate.SelectedDate;
        }