This is a migrated thread and some comments may be shown as answers.

How get recurring appointment data from table field name(RecurringRule) and assign to gridview

0 Answers 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jiten
Top achievements
Rank 1
Jiten asked on 24 May 2011, 02:18 PM
Hello,
We have a table doctor appointment has field name recurring appointment.
This field is save from radscheduler control(it save string format like this: DTSTART:20110526T100000Z  DTEND:20110526T103000Z  RRULE:FREQ=DAILY;INTERVAL=1;BYDAY=MO,TU,WE,TH,FR,SA,SU).
we need to show diferrent row in a table according to DTSTART and DTEND date and time(it means that recurring  is weekly then show 7 rows in the gridview and recurring  is monthy then show 30/31 rows in the gridview from the start time and end time.

And  i Also try this code:

    private DataTable GetGridDataSource()
    {
        //Create a dynamic table to store the appointments' information:  
        DataTable table1 = new DataTable();
        table1.Columns.Add("Subject");
        table1.Columns.Add("StartDate");
        table1.Columns.Add("EndDate");




        SchedulesService schedulesService = new SchedulesService(); //Our custom service to get the schedules info from database
        TList<Schedules> schedulesList = schedulesService.GetAll(); //This will be a list of all schedules as it exists in database.


        foreach (Schedules schedule in schedulesList) //Each schedule as it exists in database
        {
            if (string.IsNullOrEmpty(schedule.RecurrenceRule)) //No recurrence rule
            {
                table1.Rows.Add(new string[] { schedule.Subject.ToString()
                    , schedule.StartTime.ToString()
                    , schedule.EndTime.ToString() });
            }
            else //Recurrence rule exists
            {
                RecurrenceRule parsedRule;
                RecurrenceRule.TryParse(schedule.RecurrenceRule, out parsedRule);
                foreach (DateTime occurrence in parsedRule.Occurrences)
                {
                    table1.Rows.Add(new string[] { schedule.Subject.ToString()
                        , occurrence.ToString()
                        , occurrence.AddHours(1).ToString() });
                }


            }
        }


        return table1;
    }
It will not work because this method is different from what we want.

please help me as soon as possible.
Thanks.

Mutum Jiten Singh
Akhil Systems

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Jiten
Top achievements
Rank 1
Share this question
or