コード例 #1
0
        /// <summary>
        /// Loads task data into controls on the form from the data row.
        /// </summary>
        private void SetTaskData(EditTaskFormData.TaskRow taskData)
        {
            this.taskNameEdit.Text = taskData.Name;
            this.startDate.Text = taskData.StartDate;
            this.startTime.Text = taskData.StartTime;
            WebUtil.SelectItem(this.endRadio, taskData.EndChoice.ToString());
            this.endMaxOccurrencesEdit.Text = taskData.Count;
            this.endDate.Text = taskData.EndDate;
            WebUtil.SelectItem(this.recurrenceRadio, taskData.RecurrenceChoice.ToString());

            WebUtil.SelectItem(this.dailyRadio, taskData.DailyChoice.ToString());
            this.dailyEveryNthDayEdit.Text = taskData.DailyEveryNthDay;

            this.weeklyEveryNthWeekEdit.Text = taskData.WeeklyEveryNthWeek;
            this.weekDaysBtns.Items[0].Selected = taskData.Sunday;
            this.weekDaysBtns.Items[1].Selected = taskData.Monday;
            this.weekDaysBtns.Items[2].Selected = taskData.Tuesday;
            this.weekDaysBtns.Items[3].Selected = taskData.Wednesday;
            this.weekDaysBtns.Items[4].Selected = taskData.Thursday;
            this.weekDaysBtns.Items[5].Selected = taskData.Friday;
            this.weekDaysBtns.Items[6].Selected = taskData.Saturday;

            WebUtil.SelectItem(this.monthlyRadio, taskData.MonthlyChoice.ToString());
            this.monthlyEveryNthMonthEdit.Text = taskData.MonthlyEveryNthMonth;
            WebUtil.SelectItem(this.monthlyDayCombo, taskData.MonthlyDay.ToString());
            WebUtil.SelectItem(this.monthlyNthOccurrenceCombo, taskData.MonthlyNthOccurrence.ToString());
            WebUtil.SelectItem(this.monthlyDayOfWeekCombo, taskData.MonthlyDayOfWeek.ToString());
            WebUtil.SelectItem(this.monthlyDayOccurrenceCombo, taskData.MonthlyDayOccurrence.ToString());
            WebUtil.SelectItem(this.monthlyWeekDayTypeCombo, taskData.MonthlyWeekDayType.ToString());

            WebUtil.SelectItem(this.yearlyRadio, taskData.YearlyChoice.ToString());
            this.yearlyEveryNthYearEdit.Text = taskData.YearlyEveryNthYear;
            WebUtil.SelectItem(this.yearlyDayMonthCombo, taskData.YearlyDayMonth.ToString());
            WebUtil.SelectItem(this.yearlyDayCombo, taskData.YearlyDay.ToString());
            WebUtil.SelectItem(this.yearlyNthOccurrenceCombo, taskData.YearlyNthOccurrence.ToString());
            WebUtil.SelectItem(this.yearlyDayOfWeekCombo, taskData.YearlyDayOfWeek.ToString());
            WebUtil.SelectItem(this.yearlyDayOfWeekMonthCombo, taskData.YearlyDayOfWeekMonth.ToString());
            WebUtil.SelectItem(this.yearlyDayOccurrenceCombo, taskData.YearlyDayOccurrence.ToString());
            WebUtil.SelectItem(this.yearlyWeekDayTypeCombo, taskData.YearlyWeekDayType.ToString());
            WebUtil.SelectItem(this.yearlyWeekDayMonthCombo, taskData.YearlyWeekDayMonth.ToString());

            UpdateiCalendar();
            UpdateControls();
        }
コード例 #2
0
        /// <summary>
        /// Saves data from the data set into a Task object.
        /// </summary>
        public void Save(EditTaskFormData.TaskRow taskData, Task task)
        {
            mTaskData = taskData;
            mTask = task;

            Validate();

            //Save task name
            mTask.Name = mTaskData.Name;

            //Create a new recurrence pattern that we will save the data into.
            mTask.Pattern = new RecurrencePattern();
            mRule = mTask.Pattern.RRules.Add();

            //Save the recurrence rule
            switch ((RecurrenceChoice)mTaskData.RecurrenceChoice)
            {
                case RecurrenceChoice.Daily:
                    SaveDaily();
                    break;
                case RecurrenceChoice.Weekly:
                    SaveWeekly();
                    break;
                case RecurrenceChoice.Monthly:
                    SaveMonthly();
                    break;
                case RecurrenceChoice.Yearly:
                    SaveYearly();
                    break;
                default:
                    throw new Exception("Unknown recurrence choice.");
            }

            //Save the range of the pattern
            mTask.Pattern.StartDate = DateTime.Parse(mTaskData.StartDate) + TimeSpan.Parse(mTaskData.StartTime);
            switch ((EndType)mTaskData.EndChoice)
            {
                case EndType.None:
                    mRule.EndType = EndType.None;
                    break;
                case EndType.Count:
                    mRule.Count = int.Parse(mTaskData.Count);
                    break;
                case EndType.Until:
                    mRule.Until = DateTime.Parse(mTaskData.EndDate);
                    break;
                default:
                    throw new Exception("Unknown end type.");
            }
        }
コード例 #3
0
        /// <summary>
        /// Saves data from form controls into the data row.
        /// </summary>
        private EditTaskFormData.TaskRow GetTaskData()
        {
            EditTaskFormData dataSet = new EditTaskFormData();
            EditTaskFormData.TaskRow taskData = dataSet.Task.NewTaskRow();

            taskData.Name = this.taskNameEdit.Text;
            taskData.StartDate = this.startDate.Text;
            taskData.StartTime = this.startTime.Text;
            taskData.EndChoice = int.Parse(this.endRadio.SelectedItem.Value);
            taskData.Count = this.endMaxOccurrencesEdit.Text;
            taskData.EndDate = this.endDate.Text;
            taskData.RecurrenceChoice = int.Parse(this.recurrenceRadio.SelectedItem.Value);

            taskData.DailyChoice = int.Parse(this.dailyRadio.SelectedItem.Value);
            taskData.DailyEveryNthDay = this.dailyEveryNthDayEdit.Text;

            taskData.WeeklyEveryNthWeek = this.weeklyEveryNthWeekEdit.Text;
            taskData.Sunday = this.weekDaysBtns.Items[0].Selected;
            taskData.Monday = this.weekDaysBtns.Items[1].Selected;
            taskData.Tuesday = this.weekDaysBtns.Items[2].Selected;
            taskData.Wednesday = this.weekDaysBtns.Items[3].Selected;
            taskData.Thursday = this.weekDaysBtns.Items[4].Selected;
            taskData.Friday = this.weekDaysBtns.Items[5].Selected;
            taskData.Saturday = this.weekDaysBtns.Items[6].Selected;

            taskData.MonthlyChoice = int.Parse(this.monthlyRadio.SelectedItem.Value);
            taskData.MonthlyEveryNthMonth = this.monthlyEveryNthMonthEdit.Text;
            taskData.MonthlyDay = int.Parse(this.monthlyDayCombo.SelectedItem.Value);
            taskData.MonthlyNthOccurrence = int.Parse(this.monthlyNthOccurrenceCombo.SelectedItem.Value);
            taskData.MonthlyDayOfWeek = int.Parse(this.monthlyDayOfWeekCombo.SelectedItem.Value);
            taskData.MonthlyDayOccurrence = int.Parse(this.monthlyDayOccurrenceCombo.SelectedItem.Value);
            taskData.MonthlyWeekDayType = int.Parse(this.monthlyWeekDayTypeCombo.SelectedItem.Value);

            taskData.YearlyChoice = int.Parse(this.yearlyRadio.SelectedItem.Value);
            taskData.YearlyEveryNthYear = this.yearlyEveryNthYearEdit.Text;
            taskData.YearlyDayMonth = int.Parse(this.yearlyDayMonthCombo.SelectedItem.Value);
            taskData.YearlyDay = int.Parse(this.yearlyDayCombo.SelectedItem.Value);
            taskData.YearlyNthOccurrence = int.Parse(this.yearlyNthOccurrenceCombo.SelectedItem.Value);
            taskData.YearlyDayOfWeek = int.Parse(this.yearlyDayOfWeekCombo.SelectedItem.Value);
            taskData.YearlyDayOfWeekMonth = int.Parse(this.yearlyDayOfWeekMonthCombo.SelectedItem.Value);
            taskData.YearlyDayOccurrence = int.Parse(this.yearlyDayOccurrenceCombo.SelectedItem.Value);
            taskData.YearlyWeekDayType = int.Parse(this.yearlyWeekDayTypeCombo.SelectedItem.Value);
            taskData.YearlyWeekDayMonth = int.Parse(this.yearlyWeekDayMonthCombo.SelectedItem.Value);

            return taskData;
        }
コード例 #4
0
        /// <summary>
        /// Creates a task data row filled with default information.
        /// Such a data row is used to fill the EditTask form with default values when creating a new task.
        /// 
        /// Note that dates and integers are represented as strings in the form data set.
        /// This allows to perform user input validation in the controller, not in the form.
        /// </summary>
        public EditTaskFormData.TaskRow NewTask()
        {
            EditTaskFormData dataSet = new EditTaskFormData();
            EditTaskFormData.TaskRow mTaskData = dataSet.Task.NewTaskRow();

            //Load defaults into the mTaskData.
            mTaskData.Name = "New Task";
            //Some default task start date and time so it is suitable for the Evaluation License.
            DateTime start = new DateTime(2004, 1, 1, 10, 30, 0);
            mTaskData.StartDate = DemoUtil.FormatDate(start);
            mTaskData.StartTime = DemoUtil.FormatTime(start);
            mTaskData.EndChoice = (int)EndType.None;
            mTaskData.Count = "10";
            mTaskData.EndDate = DemoUtil.FormatDate(DateTime.Today.AddMonths(1));

            mTaskData.RecurrenceChoice = (int)RecurrenceChoice.Daily;

            mTaskData.DailyChoice = (int)DailyChoice.EveryNthDay;
            mTaskData.DailyEveryNthDay = "1";

            mTaskData.WeeklyEveryNthWeek = "1";
            mTaskData.Sunday = false;
            mTaskData.Monday = false;
            mTaskData.Tuesday = false;
            mTaskData.Wednesday = false;
            mTaskData.Thursday = false;
            mTaskData.Friday = false;
            mTaskData.Saturday = false;

            mTaskData.MonthlyChoice = (int)MonthlyChoice.Day;
            mTaskData.MonthlyEveryNthMonth = "1";
            mTaskData.MonthlyDay = 1;
            mTaskData.MonthlyDayOfWeek = (int)System.DayOfWeek.Sunday;
            mTaskData.MonthlyNthOccurrence = 1;
            mTaskData.MonthlyDayOccurrence = 1;
            mTaskData.MonthlyWeekDayType = (int)WeekDayType.WeekDay;

            mTaskData.YearlyChoice = (int)YearlyChoice.Day;
            mTaskData.YearlyEveryNthYear = "1";
            mTaskData.YearlyDay = 1;
            mTaskData.YearlyDayMonth = 1;
            mTaskData.YearlyNthOccurrence = 1;
            mTaskData.YearlyDayOfWeek = (int)System.DayOfWeek.Sunday;
            mTaskData.YearlyDayOfWeekMonth = 1;
            mTaskData.YearlyDayOccurrence = 1;
            mTaskData.YearlyWeekDayType = (int)WeekDayType.WeekDay;
            mTaskData.YearlyWeekDayMonth = 1;

            return mTaskData;
        }