Beispiel #1
0
        // Creates the children based on the data
        //private int CreateDataBoundChildren(System.Data.DataView dv, Table table, DateTime todaysDate, DateTime visibleDate, System.Globalization.Calendar threadCalendar)
        //{
        //    DateTime firstDay = FirstCalendarDay(this.VisibleDate);

        //    int dayoffset = 0;

        //    for (int iRow = 0; iRow < 6; iRow++)
        //    {
        //        TableRow row = new TableRow();
        //        table.Rows.Add(row);

        //        for (int iDay = 0; iDay < 7; iDay++)
        //        {
        //            DateTime d = firstDay.AddDays(dayoffset);

        //            //Initialize the cell
        //            CalendarDay day = getDay(d, TodaysDate, visibleDate, threadCalendar);
        //            TableCell cell = CreateDayCell(day);
        //            row.Cells.Add(cell);

        //            //Process real data for this day
        //            dv.RowFilter = string.Format("{0}>= #{1}# AND {0} < #{2}#", this.DayField, d.ToString("MM/dd/yyyy"), d.AddDays(1).ToString("MM/dd/yyyy"));
        //            if (dv.Count > 0 && this.DayEventTemplate != null)
        //            {
        //                foreach (System.Data.DataRowView drv in dv)
        //                {
        //                    DataBoundCalendarItem dataitem = new DataBoundCalendarItem(drv, day);
        //                    DayEventTemplate.InstantiateIn(dataitem);
        //                    //add the controls to both collections
        //                    cell.Controls.Add(dataitem);
        //                    //databind the data item
        //                    dataitem.DataBind();
        //                }
        //            }
        //            else if (this.DayEmptyTemplate != null)
        //            {
        //                DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
        //               DayEmptyTemplate.InstantiateIn(dataitem);
        //                //add the controls to both collections
        //                cell.Controls.Add(dataitem);

        //            }
        //            dayoffset++;

        //        }

        //    }
        //    return 1;
        //}

        private int CreateDataBoundChildren(System.Data.DataView dv, Table table, DateTime todaysDate, DateTime visibleDate, System.Globalization.Calendar threadCalendar)
        {
            DateTime firstDay = FirstCalendarDay(this.VisibleDate);

            dv.Table.Locale = new CultureInfo("en-US");

            int    dayoffset   = 0;
            string dayField    = this.DayField;
            string endDayField = this.EndDayField;

            for (int iRow = 0; iRow < 6; iRow++)
            {
                TableRow row = new TableRow();
                table.Rows.Add(row);

                for (int iDay = 0; iDay < 7; iDay++)
                {
                    DateTime d = firstDay.AddDays(dayoffset);

                    //Initialize the cell
                    CalendarDay day  = getDay(d, TodaysDate, visibleDate, threadCalendar);
                    TableCell   cell = CreateDayCell(day);
                    row.Cells.Add(cell);

                    //Process real data for this day
                    dv.RowFilter = string.Format("IsNull({1},{0}) >= #{2}# AND {0}<#{3}#", dayField, endDayField, d.ToString("MM/dd/yyyy"), d.AddDays(1).ToString("MM/dd/yyyy"));

                    if (dv.Count > 0 && this.DayEventTemplate != null)
                    {
                        foreach (System.Data.DataRowView drv in dv)
                        {
                            DataBoundCalendarItem dataitem = new DataBoundCalendarItem(drv, day);
                            DayEventTemplate.InstantiateIn(dataitem);
                            //add the controls to both collections
                            cell.Controls.Add(dataitem);
                            //databind the data item
                            dataitem.DataBind();
                        }
                    }
                    else if (this.DayEmptyTemplate != null)
                    {
                        DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
                        DayEmptyTemplate.InstantiateIn(dataitem);
                        //add the controls to both collections
                        cell.Controls.Add(dataitem);
                    }
                    dayoffset++;
                }
            }
            return(1);
        }
Beispiel #2
0
        //Creates the control hierarchy based on the counts of data in viewstate
        //To be smart, we don't databind on postback. We rely on creating the same number of controls as the
        //initial population, the values for the controls then come from viewstate.
        private int createChildrenFromViewstate(Table table, DateTime todaysDate, DateTime visibleDate, System.Globalization.Calendar threadCalendar)
        {
            System.Collections.Generic.Dictionary <DateTime, int> ctrlcount;
            ctrlcount = (System.Collections.Generic.Dictionary <DateTime, int>)ViewState[ViewStateDataKey];

            DateTime firstDay  = FirstCalendarDay(this.VisibleDate);
            int      dayoffset = 0;

            for (int iRow = 0; iRow < 6; iRow++)
            {
                TableRow row = new TableRow();
                table.Rows.Add(row);

                for (int iDay = 0; iDay < 7; iDay++)
                {
                    DateTime d = firstDay.AddDays(dayoffset);

                    //Initialize the cell
                    CalendarDay day  = getDay(d, TodaysDate, visibleDate, threadCalendar);
                    TableCell   cell = CreateDayCell(day);
                    row.Cells.Add(cell);

                    if (ctrlcount != null)
                    {
                        if (this.DayEventTemplate != null && ctrlcount.ContainsKey(d))
                        {
                            int nControlsForDay = ctrlcount[d];

                            for (int count = 0; count < nControlsForDay; count++)
                            {
                                DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
                                DayEventTemplate.InstantiateIn(dataitem);
                                cell.Controls.Add(dataitem);
                                //Note we don't databind these new controls.
                            }
                        }
                        else if (this.DayEmptyTemplate != null)
                        {
                            DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
                            DayEmptyTemplate.InstantiateIn(dataitem);
                            cell.Controls.Add(dataitem);
                        }
                    }
                    dayoffset++;
                }
            }
            return(1);
        }
Beispiel #3
0
        // Creates the children based on the data
        //private int CreateDataBoundChildren(System.Data.DataView dv, Table table, DateTime todaysDate, DateTime visibleDate, System.Globalization.Calendar threadCalendar)
        //{
        //    DateTime firstDay = FirstCalendarDay(this.VisibleDate);
        //    int dayoffset = 0;
        //    for (int iRow = 0; iRow < 6; iRow++)
        //    {
        //        TableRow row = new TableRow();
        //        table.Rows.Add(row);
        //        for (int iDay = 0; iDay < 7; iDay++)
        //        {
        //            DateTime d = firstDay.AddDays(dayoffset);
        //            //Initialize the cell
        //            CalendarDay day = getDay(d, TodaysDate, visibleDate, threadCalendar);
        //            TableCell cell = CreateDayCell(day);
        //            row.Cells.Add(cell);
        //            //Process real data for this day
        //            dv.RowFilter = string.Format("{0}>= #{1}# AND {0} < #{2}#", this.DayField, d.ToString("MM/dd/yyyy"), d.AddDays(1).ToString("MM/dd/yyyy"));
        //            if (dv.Count > 0 && this.DayEventTemplate != null)
        //            {
        //                foreach (System.Data.DataRowView drv in dv)
        //                {
        //                    DataBoundCalendarItem dataitem = new DataBoundCalendarItem(drv, day);
        //                    DayEventTemplate.InstantiateIn(dataitem);
        //                    //add the controls to both collections
        //                    cell.Controls.Add(dataitem);
        //                    //databind the data item
        //                    dataitem.DataBind();
        //                }
        //            }
        //            else if (this.DayEmptyTemplate != null)
        //            {
        //                DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
        //               DayEmptyTemplate.InstantiateIn(dataitem);
        //                //add the controls to both collections
        //                cell.Controls.Add(dataitem);
        //            }
        //            dayoffset++;
        //        }
        //    }
        //    return 1;
        //}
        private int CreateDataBoundChildren(System.Data.DataView dv, Table table, DateTime todaysDate, DateTime visibleDate, System.Globalization.Calendar threadCalendar)
        {
            DateTime firstDay = FirstCalendarDay(this.VisibleDate);
            dv.Table.Locale = new CultureInfo("en-US");

            int dayoffset = 0;
            string dayField = this.DayField;
            string endDayField = this.EndDayField;

            for (int iRow = 0; iRow < 6; iRow++)
            {
                TableRow row = new TableRow();
                table.Rows.Add(row);

                for (int iDay = 0; iDay < 7; iDay++)
                {
                    DateTime d = firstDay.AddDays(dayoffset);

                    //Initialize the cell
                    CalendarDay day = getDay(d, TodaysDate, visibleDate, threadCalendar);
                    TableCell cell = CreateDayCell(day);
                    row.Cells.Add(cell);

                    //Process real data for this day
                    dv.RowFilter = string.Format("IsNull({1},{0}) >= #{2}# AND {0}<#{3}#", dayField, endDayField, d.ToString("MM/dd/yyyy"), d.AddDays(1).ToString("MM/dd/yyyy"));

                    if (dv.Count > 0 && this.DayEventTemplate != null)
                    {
                        foreach (System.Data.DataRowView drv in dv)
                        {
                            DataBoundCalendarItem dataitem = new DataBoundCalendarItem(drv, day);
                            DayEventTemplate.InstantiateIn(dataitem);
                            //add the controls to both collections
                            cell.Controls.Add(dataitem);
                            //databind the data item
                            dataitem.DataBind();
                        }
                    }
                    else if (this.DayEmptyTemplate != null)
                    {
                        DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
                        DayEmptyTemplate.InstantiateIn(dataitem);
                        //add the controls to both collections
                        cell.Controls.Add(dataitem);

                    }
                    dayoffset++;
                }
            }
            return 1;
        }
Beispiel #4
0
        //Creates the control hierarchy based on the counts of data in viewstate
        //To be smart, we don't databind on postback. We rely on creating the same number of controls as the
        //initial population, the values for the controls then come from viewstate.
        private int createChildrenFromViewstate(Table table, DateTime todaysDate, DateTime visibleDate, System.Globalization.Calendar threadCalendar)
        {
            System.Collections.Generic.Dictionary<DateTime, int> ctrlcount;
            ctrlcount = (System.Collections.Generic.Dictionary<DateTime, int>)ViewState[ViewStateDataKey];

            DateTime firstDay = FirstCalendarDay(this.VisibleDate);
            int dayoffset = 0;

            for (int iRow = 0; iRow < 6; iRow++)
            {
                TableRow row = new TableRow();
                table.Rows.Add(row);

                for (int iDay = 0; iDay < 7; iDay++)
                {
                    DateTime d = firstDay.AddDays(dayoffset);

                    //Initialize the cell
                    CalendarDay day = getDay(d, TodaysDate, visibleDate, threadCalendar);
                    TableCell cell = CreateDayCell(day);
                    row.Cells.Add(cell);

                    if (ctrlcount != null)
                    {
                        if (this.DayEventTemplate != null && ctrlcount.ContainsKey(d))
                        {
                            int nControlsForDay = ctrlcount[d];

                            for (int count = 0; count < nControlsForDay; count++)
                            {
                                DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
                                DayEventTemplate.InstantiateIn(dataitem);
                                cell.Controls.Add(dataitem);
                                //Note we don't databind these new controls.
                            }

                        }
                        else if (this.DayEmptyTemplate != null)
                        {
                            DataBoundCalendarItem dataitem = new DataBoundCalendarItem(null, day);
                            DayEmptyTemplate.InstantiateIn(dataitem);
                            cell.Controls.Add(dataitem);
                        }
                    }
                    dayoffset++;
                }
            }
            return 1;
        }