protected void Button1_Click(object sender, EventArgs e)
        {
            RecurrenceValues values = null;
            DateTime StartDate = Convert.ToDateTime(TextBox1.Text);
            DateTime EndDate = Convert.ToDateTime(TextBox3.Text);

            switch (DropDownList1.SelectedValue)
            {
                case "Daily": // Daily
                    DailyRecurrenceSettings da;
                    if (RadioButton1.Checked)
                        da = new DailyRecurrenceSettings(StartDate, Convert.ToInt32(TextBox2.Text));
                    else
                        da = new DailyRecurrenceSettings(StartDate, EndDate);

                    if (RadioButton3.Checked)
                        values = da.GetValues(int.Parse(TextBox4.Text));
                    else
                        values = da.GetValues(1, DailyRegenType.OnEveryWeekday);
                    break;

                case "Weekly": // Weekly
                    WeeklyRecurrenceSettings we;
                    SelectedDayOfWeekValues selectedValues = new SelectedDayOfWeekValues();

                    if (RadioButton1.Checked)
                        we = new WeeklyRecurrenceSettings(StartDate, Convert.ToInt32(TextBox2.Text));
                    else
                        we = new WeeklyRecurrenceSettings(StartDate, EndDate);

                    selectedValues.Sunday = Sunday.Checked;
                    selectedValues.Monday = Monday.Checked;
                    selectedValues.Tuesday = Tuesday.Checked;
                    selectedValues.Wednesday = Wednesday.Checked;
                    selectedValues.Thursday = Thursday.Checked;
                    selectedValues.Friday = Friday.Checked;
                    selectedValues.Saturday = Saturday.Checked;

                    values = we.GetValues(int.Parse(TextBox5.Text), selectedValues);
                    break;

                case "Monthly": // Monthly
                    MonthlyRecurrenceSettings mo;
                    if (RadioButton1.Checked)
                        mo = new MonthlyRecurrenceSettings(StartDate, Convert.ToInt32(TextBox2.Text));
                    else
                        mo = new MonthlyRecurrenceSettings(StartDate, EndDate);


                    if (RadioButton5.Checked)
                        values = mo.GetValues(int.Parse(TextBox6.Text), Convert.ToInt32(TextBox7.Text));
                    else
                    {
                        // Get the adjusted values
                        mo.AdjustmentValue = int.Parse(TextBox9.Text);
                        values = mo.GetValues((MonthlySpecificDatePartOne)DropDownList2.SelectedIndex, (MonthlySpecificDatePartTwo)DropDownList3.SelectedIndex, int.Parse(TextBox8.Text));
                    }
                    break;

                case "Yearly": // Yearly
                    YearlyRecurrenceSettings yr;
                    if (RadioButton1.Checked)
                        yr = new YearlyRecurrenceSettings(StartDate, Convert.ToInt32(TextBox2.Text));
                    else
                        yr = new YearlyRecurrenceSettings(StartDate, EndDate);


                    if (RadioButton7.Checked)
                        values = yr.GetValues(int.Parse(TextBox10.Text), DropDownList4.SelectedIndex + 1);
                    else
                    {
                        // Get the adjusted value
                        yr.AdjustmentValue = int.Parse(TextBox11.Text);
                        values = yr.GetValues((YearlySpecificDatePartOne)DropDownList5.SelectedIndex, (YearlySpecificDatePartTwo)DropDownList6.SelectedIndex, (YearlySpecificDatePartThree)(DropDownList7.SelectedIndex + 1));
                    }
                    break;
            }
            
            //build a string of the dates...
            string DateString = null;
            foreach (DateTime item in values.Values)
            {
                string dt = item.ToShortDateString();
                if (DateString == null)
                {
                    DateString = dt;
                }
                else
                {
                    DateString += "|" + dt;
                }                
            }
            strdatelist(DateString);
        }
Ejemplo n.º 2
0
        private void UpdateDisplay()
        {
            try
            {
                int      occurrences = int.Parse(rangeRadio2Text1.Text);
                DateTime start       = (DateTime)startDate.SelectedDate;
                DateTime?end         = rangeRadio3Picker1.SelectedDate;

                if (dailyTab.IsSelected)
                {
                    DailyRecurrenceSettings daily;

                    if (rangeRadio3.IsChecked == true)
                    {
                        daily = new DailyRecurrenceSettings(start, (DateTime)end);
                    }
                    else
                    {
                        daily = new DailyRecurrenceSettings(start, occurrences);
                    }

                    if (dailyRadio1.IsChecked == true)
                    {
                        values = daily.GetValues(int.Parse(dailyRadio1Text1.Text), DailyRegenType.OnEveryXDays);
                    }
                    else if (dailyRadio2.IsChecked == true)
                    {
                        values = daily.GetValues(1, DailyRegenType.OnEveryWeekday);
                    }

                    rangeRadio2Text1.Text = daily.NumberOfOccurrences.ToString();
                }
                else if (weeklyTab.IsSelected)
                {
                    WeeklyRecurrenceSettings weekly;

                    if (rangeRadio3.IsChecked == true)
                    {
                        weekly = new WeeklyRecurrenceSettings(start, (DateTime)end);
                    }
                    else
                    {
                        weekly = new WeeklyRecurrenceSettings(start, occurrences);
                    }

                    SelectedDayOfWeekValues sdwv = new SelectedDayOfWeekValues();
                    sdwv.Sunday    = (bool)weeklySunday.IsChecked;
                    sdwv.Monday    = (bool)weeklyMonday.IsChecked;
                    sdwv.Tuesday   = (bool)weeklyTuesday.IsChecked;
                    sdwv.Wednesday = (bool)weeklyWednesday.IsChecked;
                    sdwv.Thursday  = (bool)weeklyThursday.IsChecked;
                    sdwv.Friday    = (bool)weeklyFriday.IsChecked;
                    sdwv.Saturday  = (bool)weeklySaturday.IsChecked;

                    values = weekly.GetValues(int.Parse(weeklyText1.Text), sdwv);

                    rangeRadio2Text1.Text = weekly.NumberOfOccurrences.ToString();
                }
                else if (monthlyTab.IsSelected)
                {
                    MonthlyRecurrenceSettings monthly;

                    if (rangeRadio3.IsChecked == true)
                    {
                        monthly = new MonthlyRecurrenceSettings(start, (DateTime)end);
                    }
                    else
                    {
                        monthly = new MonthlyRecurrenceSettings(start, occurrences);
                    }

                    if (monthlyRadio1.IsChecked == true)
                    {
                        values = monthly.GetValues(int.Parse(monthlyRadio1Text1.Text), int.Parse(monthlyText1.Text));
                    }
                    else if (monthlyRadio2.IsChecked == true)
                    {
                        values = monthly.GetValues((MonthlySpecificDatePartOne)monthlyRadio2Combo1.SelectedIndex, (MonthlySpecificDatePartTwo)monthlyRadio2Combo2.SelectedIndex, int.Parse(monthlyText1.Text));
                    }

                    rangeRadio2Text1.Text = monthly.NumberOfOccurrences.ToString();
                }
                else if (yearlyTab.IsSelected)
                {
                    YearlyRecurrenceSettings yearly;

                    if (rangeRadio3.IsChecked == true)
                    {
                        yearly = new YearlyRecurrenceSettings(start, (DateTime)end);
                    }
                    else
                    {
                        yearly = new YearlyRecurrenceSettings(start, occurrences);
                    }

                    if (yearlyRadio1.IsChecked == true)
                    {
                        values = yearly.GetValues(int.Parse(yearlyRadio1Text1.Text), yearlyRadio1Combo1.SelectedIndex + 1, int.Parse(yearlyText1.Text));
                    }
                    else if (yearlyRadio2.IsChecked == true)
                    {
                        values = yearly.GetValues((YearlySpecificDatePartOne)yearlyRadio2Combo1.SelectedIndex, (YearlySpecificDatePartTwo)yearlyRadio2Combo2.SelectedIndex, (YearlySpecificDatePartThree)(yearlyRadio2Combo3.SelectedIndex + 1), int.Parse(yearlyText1.Text));
                    }

                    rangeRadio2Text1.Text = yearly.NumberOfOccurrences.ToString();
                }

                if (rangeRadio3.IsChecked == false)
                {
                    _suspendUpdateRangeRadio3Picker1 = true;
                    rangeRadio3Picker1.SelectedDate  = values.EndDate;
                }
            }
            catch { }
        }
Ejemplo n.º 3
0
        private static void CalculateRecurrenceEnd(this Appointment appt)
        {
            Recurrence recur = appt.Recurrence;

            int      occurrences = recur.EndCount;
            DateTime start       = appt.StartDate;

            RecurrenceValues values = null;

            if (recur.Type == RepeatType.Daily)
            {
                DailyRecurrenceSettings daily = new DailyRecurrenceSettings(start, occurrences);

                if (recur.Day != "-1")
                {
                    values = daily.GetValues(int.Parse(recur.Day), DailyRegenType.OnEveryXDays);
                }
                else
                {
                    values = daily.GetValues(1, DailyRegenType.OnEveryWeekday);
                }

                recur.EndCount = daily.NumberOfOccurrences;
            }
            else if (recur.Type == RepeatType.Weekly)
            {
                WeeklyRecurrenceSettings weekly = new WeeklyRecurrenceSettings(start, occurrences);

                SelectedDayOfWeekValues sdwv = new SelectedDayOfWeekValues();
                sdwv.Sunday    = recur.Day.IndexOf('0') != -1;
                sdwv.Monday    = recur.Day.IndexOf('1') != -1;
                sdwv.Tuesday   = recur.Day.IndexOf('2') != -1;
                sdwv.Wednesday = recur.Day.IndexOf('3') != -1;
                sdwv.Thursday  = recur.Day.IndexOf('4') != -1;
                sdwv.Friday    = recur.Day.IndexOf('5') != -1;
                sdwv.Saturday  = recur.Day.IndexOf('6') != -1;

                values = weekly.GetValues(recur.Week, sdwv);

                recur.EndCount = weekly.NumberOfOccurrences;
            }
            else if (recur.Type == RepeatType.Monthly)
            {
                MonthlyRecurrenceSettings monthly = new MonthlyRecurrenceSettings(start, occurrences);

                if (recur.Week == -1)
                {
                    values = monthly.GetValues(int.Parse(recur.Day), recur.Month);
                }
                else
                {
                    values = monthly.GetValues((MonthlySpecificDatePartOne)recur.Week, (MonthlySpecificDatePartTwo)int.Parse(recur.Day), recur.Month);
                }

                recur.EndCount = monthly.NumberOfOccurrences;
            }
            else if (recur.Type == RepeatType.Yearly)
            {
                YearlyRecurrenceSettings yearly = new YearlyRecurrenceSettings(start, occurrences);

                if (recur.Week == -1)
                {
                    values = yearly.GetValues(int.Parse(recur.Day), recur.Month + 1, recur.Year);
                }
                else
                {
                    values = yearly.GetValues((YearlySpecificDatePartOne)recur.Week, (YearlySpecificDatePartTwo)int.Parse(recur.Day), (YearlySpecificDatePartThree)(recur.Month + 1), recur.Year);
                }

                recur.EndCount = yearly.NumberOfOccurrences;
            }

            recur.EndDate = values.EndDate;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            RecurrenceValues values = null;

            switch (tabControl1.SelectedIndex)
            {
            case 0:     // Daily
                DailyRecurrenceSettings da;
                if (radioOccurrences.Checked)
                {
                    da = new DailyRecurrenceSettings(dtStartDate.Value, Convert.ToInt32(txtOccurrences.Text));
                }
                else
                {
                    da = new DailyRecurrenceSettings(dtStartDate.Value, dtEndDate.Value);
                }

                if (radioButton1.Checked)
                {
                    values = da.GetValues(int.Parse(textBox1.Text));
                }
                else
                {
                    values = da.GetValues(1, DailyRegenType.OnEveryWeekday);
                }
                break;

            case 1:     // Weekly
                WeeklyRecurrenceSettings we;
                SelectedDayOfWeekValues  selectedValues = new SelectedDayOfWeekValues();

                if (radioOccurrences.Checked)
                {
                    we = new WeeklyRecurrenceSettings(dtStartDate.Value, Convert.ToInt32(txtOccurrences.Text));
                }
                else
                {
                    we = new WeeklyRecurrenceSettings(dtStartDate.Value, dtEndDate.Value);
                }

                selectedValues.Sunday    = chkSunday.Checked;
                selectedValues.Monday    = chkMonday.Checked;
                selectedValues.Tuesday   = chkTuesday.Checked;
                selectedValues.Wednesday = chkWednesday.Checked;
                selectedValues.Thursday  = chkThursday.Checked;
                selectedValues.Friday    = chkFriday.Checked;
                selectedValues.Saturday  = chkSaturday.Checked;

                values = we.GetValues(int.Parse(txtWeeklyRegenXWeeks.Text), selectedValues);
                break;

            case 2:     // Monthly
                MonthlyRecurrenceSettings mo;
                if (radioOccurrences.Checked)
                {
                    mo = new MonthlyRecurrenceSettings(dtStartDate.Value, Convert.ToInt32(txtOccurrences.Text));
                }
                else
                {
                    mo = new MonthlyRecurrenceSettings(dtStartDate.Value, dtEndDate.Value);
                }


                if (radioButton3.Checked)
                {
                    values = mo.GetValues(int.Parse(textBox4.Text), Convert.ToInt32(textBox2.Text));
                }
                else
                {
                    // Get the adjusted values
                    mo.AdjustmentValue = int.Parse(txtMonthlyAdjustedValue.Text);
                    values             = mo.GetValues((MonthlySpecificDatePartOne)comboBox2.SelectedIndex, (MonthlySpecificDatePartTwo)comboBox3.SelectedIndex, int.Parse(textBox3.Text));
                }
                break;

            case 3:     // Yearly
                YearlyRecurrenceSettings yr;
                if (radioOccurrences.Checked)
                {
                    yr = new YearlyRecurrenceSettings(dtStartDate.Value, Convert.ToInt32(txtOccurrences.Text));
                }
                else
                {
                    yr = new YearlyRecurrenceSettings(dtStartDate.Value, dtEndDate.Value);
                }


                if (radioYearlyEvery.Checked)
                {
                    values = yr.GetValues(int.Parse(txtYearEvery.Text), cboYearEveryMonth.SelectedIndex + 1);
                }
                else
                {
                    // Get the adjusted value
                    yr.AdjustmentValue = int.Parse(txtYearlyAdjustedValue.Text);
                    values             = yr.GetValues((YearlySpecificDatePartOne)comboBox5.SelectedIndex, (YearlySpecificDatePartTwo)comboBox4.SelectedIndex, (YearlySpecificDatePartThree)(comboBox6.SelectedIndex + 1));
                }
                break;
            }

            txtSeriesInfo.Text          = values.GetSeriesInfo();
            txtGetRecurrenceValues.Text = txtSeriesInfo.Text;

            lstResults.Items.Clear();
            DateTime[] bolded  = new DateTime[values.Values.Count];
            int        counter = 0;

            foreach (DateTime dt in values.Values)
            {
                bolded[counter] = dt;
                lstResults.Items.Add(new DateItem(dt));
                counter++;
            }
            monthCalendar1.BoldedDates = bolded;

            if (lstResults.Items.Count > 0)
            {
                lstResults.SelectedIndex = 0;
            }

            txtTotal.Text          = lstResults.Items.Count.ToString();
            txtEndDate.Text        = values.EndDate.ToShortDateString();
            txtStartDate.Text      = values.StartDate.ToShortDateString();
            btnGetNextDate.Enabled = lstResults.Items.Count > 0;
            txtNextDate.Text       = string.Empty;
            lstRecurrenceValues.Items.Clear();
            tabMain.SelectedTab   = tabSecond;
            txtAdjustedTotal.Text = lstRecurrenceValues.Items.Count.ToString();

            // Get reccurrence info object to use for setting controls
            RecurrenceInfo info = RecurrenceHelper.GetFriendlySeriesInfo(values.GetSeriesInfo());

            dateTimePickerStartDate.Value = info.StartDate;
            if (info.EndDate.HasValue)
            {
                dateTimePickerStartDateEndDate.Value = info.EndDate.Value;
                dtAdjustedDateTime.Value             = info.EndDate.Value;
                dateTimePicker1.Value = info.EndDate.Value;
            }
        }
Ejemplo n.º 5
0
        public List <TemplateEvents> getEvents(T_Schedule task)//mahesh
        {
            ApplicationContext dbschedule = new ApplicationContext(new SystemUser());

            List <TemplateEvents> result = new List <TemplateEvents>();

            //var ScheduledStartTime = task.T_StartTime.Value.ToLongTimeString();
            //var ScheduledEndTime = task.T_EndTime.Value.ToLongTimeString();
            var ScheduledStartTime = TimeZoneInfo.ConvertTimeFromUtc(task.T_StartTime.Value, task.m_Timezone).ToLongTimeString(); //mahesh
            var ScheduledEndTime   = TimeZoneInfo.ConvertTimeFromUtc(task.T_EndTime.Value, task.m_Timezone).ToLongTimeString();   //mahesh

            //task.T_StartDateTime = Convert.ToDateTime(task.T_StartDateTime.ToLongDateString() + " " + task.T_StartTime.Value.ToLongTimeString());
            task.T_StartDateTime = Convert.ToDateTime(task.T_StartDateTime.ToLongDateString() + " " + ScheduledStartTime);//mahesh

            var ScheduledDateTimeEnd = DateTime.UtcNow.AddYears(1);
            var occurrences          = task.T_OccurrenceLimitCount != null ? task.T_OccurrenceLimitCount : 0;
            var skip = task.T_RecurringRepeatFrequencyID != null?Convert.ToInt32(task.T_RecurringRepeatFrequencyID) : 0;

            if (task.T_AssociatedScheduleTypeID == 1)
            {
                TemplateEvents obj = new TemplateEvents();
                obj.EventDate = task.T_StartDateTime;
                obj.StartTime = task.T_StartDateTime;
                obj.Title     = task.T_Name;
                obj.EndTime   = Convert.ToDateTime(task.T_StartDateTime.ToShortDateString() + " " + ScheduledEndTime);
                result.Add(obj);
                return(result);
            }

            if (task.T_RecurringTaskEndTypeID == 3)
            {
                //ScheduledDateTimeEnd = task.T_EndDate.Value;
                task.T_EndDate = TimeZoneInfo.ConvertTimeFromUtc(task.T_EndDate.Value, task.m_Timezone);//mahesh
                try
                {
                    ScheduledDateTimeEnd = AbsoluteEnd(task.T_EndDate.Value);
                }
                catch { ScheduledDateTimeEnd = task.T_EndDate.Value; }
            }

            if (task.T_AssociatedRecurringScheduleDetailsTypeID == 1)
            {
                DailyRecurrenceSettings we;
                if (task.T_RecurringTaskEndTypeID == 2)
                {
                    we = new DailyRecurrenceSettings(task.T_StartDateTime, occurrences.Value);
                }
                else
                {
                    we = new DailyRecurrenceSettings(task.T_StartDateTime, ScheduledDateTimeEnd);
                }
                var values = we.GetValues(skip);
                foreach (var evt in values.Values)
                {
                    TemplateEvents obj = new TemplateEvents();
                    obj.EventDate = evt;
                    obj.StartTime = evt;
                    obj.Title     = task.T_Name;
                    obj.EndTime   = Convert.ToDateTime(evt.ToShortDateString() + " " + ScheduledEndTime);
                    result.Add(obj);
                }
            }
            if (task.T_AssociatedRecurringScheduleDetailsTypeID == 2)
            {
                WeeklyRecurrenceSettings we;
                SelectedDayOfWeekValues  selectedValues = new SelectedDayOfWeekValues();
                if (task.T_RecurringTaskEndTypeID == 2)
                {
                    we = new WeeklyRecurrenceSettings(task.T_StartDateTime, occurrences.Value);
                }
                else
                {
                    we = new WeeklyRecurrenceSettings(task.T_StartDateTime, ScheduledDateTimeEnd);
                }
                selectedValues.Sunday    = task.SelectedT_RecurrenceDays_T_RepeatOn.ToList().Contains(1);
                selectedValues.Monday    = task.SelectedT_RecurrenceDays_T_RepeatOn.ToList().Contains(2);
                selectedValues.Tuesday   = task.SelectedT_RecurrenceDays_T_RepeatOn.ToList().Contains(3);
                selectedValues.Wednesday = task.SelectedT_RecurrenceDays_T_RepeatOn.ToList().Contains(4);
                selectedValues.Thursday  = task.SelectedT_RecurrenceDays_T_RepeatOn.ToList().Contains(5);
                selectedValues.Friday    = task.SelectedT_RecurrenceDays_T_RepeatOn.ToList().Contains(6);
                selectedValues.Saturday  = task.SelectedT_RecurrenceDays_T_RepeatOn.ToList().Contains(7);
                var values = we.GetValues(skip, selectedValues);
                foreach (var evt in values.Values)
                {
                    TemplateEvents obj = new TemplateEvents();
                    obj.EventDate = evt;
                    obj.StartTime = evt;
                    obj.Title     = task.T_Name;
                    obj.EndTime   = Convert.ToDateTime(evt.ToShortDateString() + " " + ScheduledEndTime);
                    result.Add(obj);
                }
            }
            if (task.T_AssociatedRecurringScheduleDetailsTypeID == 3)
            {
                MonthlyRecurrenceSettings we;


                if (task.T_RecurringTaskEndTypeID == 2)
                {
                    we = new MonthlyRecurrenceSettings(task.T_StartDateTime, occurrences.Value);
                }
                else
                {
                    we = new MonthlyRecurrenceSettings(task.T_StartDateTime, ScheduledDateTimeEnd);
                }
                we.AdjustmentValue = 0;
                skip = skip++;
                RecurrenceValues value = new RecurrenceValues();
                if (task.T_RepeatByID == 3)
                {
                    value = we.GetValues(MonthlySpecificDatePartOne.Last, MonthlySpecificDatePartTwo.Day, skip);
                }
                if (task.T_RepeatByID == 4)
                {
                    value = we.GetValues(MonthlySpecificDatePartOne.First, MonthlySpecificDatePartTwo.Day, skip);
                }
                if (task.T_RepeatByID == 1)
                {
                    value = we.GetValues(task.T_StartDateTime.Day, skip);
                }
                if (task.T_RepeatByID == 2)
                {
                    value = we.GetValues(MonthlySpecificDatePartOne.Last, MonthlySpecificDatePartTwo.WeekendDay, skip);
                }
                foreach (var evt in value.Values)
                {
                    TemplateEvents obj = new TemplateEvents();
                    obj.EventDate = evt;
                    obj.StartTime = evt;
                    obj.Title     = task.T_Name;
                    obj.EndTime   = Convert.ToDateTime(evt.ToShortDateString() + " " + ScheduledEndTime);
                    result.Add(obj);
                }
            }
            if (task.T_AssociatedRecurringScheduleDetailsTypeID == 4)
            {
                YearlyRecurrenceSettings we;
                if (task.T_RecurringTaskEndTypeID == 2)
                {
                    we = new YearlyRecurrenceSettings(task.T_StartDateTime, occurrences.Value);
                }
                else
                {
                    we = new YearlyRecurrenceSettings(task.T_StartDateTime, ScheduledDateTimeEnd);
                }
                var values = we.GetValues(task.T_StartDateTime.Day, task.T_StartDateTime.Month);
                foreach (var evt in values.Values)
                {
                    TemplateEvents obj = new TemplateEvents();
                    obj.EventDate = evt;
                    obj.StartTime = evt;
                    obj.Title     = task.T_Name;
                    obj.EndTime   = Convert.ToDateTime(evt.ToShortDateString() + " " + ScheduledEndTime);
                    result.Add(obj);
                }
            }
            //return Json(result, "application/json", System.Text.Encoding.UTF8, JsonRequestBehavior.AllowGet);
            return(result);
        }
Ejemplo n.º 6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            DailyRecurrenceSettings daily = new DailyRecurrenceSettings(DateTime.Today);

            daily.RecurrenceInterval = 8;
        }