RadCalendar tooltips not rendering

9 posts, 0 answers
  1. Tayonee
    Tayonee avatar
    52 posts
    Member since:
    Nov 2006

    Posted 25 Mar 2015 Link to this post

    (I just posted this, but the page blew up so I apologize if the content is being posted twice - I couldn't find the original after posting)

    I am having a problem getting my RadTooltips to render on my calendar controls. I have followed the following demo with no problems: http://demos.telerik.com/aspnet-ajax/tooltip/examples/tooltipcalendar/defaultvb.aspx?show-source=true. I was able to run the local sample with no problems but when I translate that to my own page, the "standard" tooltips appear (see attached screenshot), instead of my customized content. 

    I have noticed what I think may be close to the source of the problem - the Ajax Update event never fires, despite the fact that I see the controls properly added to the calendar's RadTooltipManager. 

    Can anyone see what I am missing here? I have done a detailed comparison between my local working demo sample and my real page and cannot see what is missing.

    Here is the content and code-behind pages for reference. The calendar code starts around line 147 and the calendar event handler code starts in a Region block around line 719. Hopefully that makes it a little easier to track.

    <%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/masterpages/OneColumn.master" CodeBehind="ReconcileTime.aspx.vb" Inherits="SOREOIB.ReconcileTime" %>
    <%@ Register Src="~/controls/pickers/CustomerPicker.ascx" TagName="CustomerPicker" TagPrefix="uc1" %>
    <%@ Register Src="~/controls/pickers/EmployeePicker.ascx" TagName="EmployeePicker" TagPrefix="uc2" %>
    <%@ Register Src="~/controls/linkers/ContactLink.ascx" TagName="ContactLink" TagPrefix="uc3" %>
    <%@ Register Src="~/controls/pickers/AuthorizationPicker.ascx" TagName="AuthorizationPicker" TagPrefix="uc4" %>
    <%@ Register Src="~/controls/linkers/AuthorizationLink.ascx" TagName="AuthorizationLink" TagPrefix="uc5" %>
    <%@ Register Src="../../../controls/pickers/ServiceCodePicker.ascx" TagName="ServiceCodePicker" TagPrefix="uc8" %>
    <%@ Register Src="../../../controls/pickers/FundingOrganizationPicker.ascx" TagName="FundingOrganizationPicker" TagPrefix="uc6" %>
    <%@ Register Src="../../../controls/BillingPeriodPicker.ascx" TagName="BillingPeriodPicker" TagPrefix="uc7" %>
    <%@ Register Assembly="Telerik.OpenAccess.Web, Version=2014.3.1209.1, Culture=neutral, PublicKeyToken=7ce17eeaf1d59342" Namespace="Telerik.OpenAccess" TagPrefix="telerik" %>
    <%@ Register src="controls/TimeForDay.ascx" tagname="TimeForDay" tagprefix="uc9" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="cphMain" runat="server">
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </telerik:RadAjaxLoadingPanel>
     
        <script type="text/javascript">
     
            function onRequestStart(sender, args) {
                if (args.get_eventTarget().indexOf("btnExportToExcel") >= 0)
                    args.set_enableAjax(false);
            }
     
        </script>
     
        <div style="background-image: url(../../../images/betasoftware-s.jpg); background-repeat: no-repeat; background-position: right top;">
            <table cellpadding="5">
                <tr>
                    <td rowspan="4">
                        <span style="position: relative; top: 15px;">
                            <asp:Image ID="Image1" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/images/window_gear-m.png" />
                        </span>
                    </td>
                    <td>
                        <h2>Step 1: Import Raw Time Report Data
                        </h2>
                        <div class="Instructions">
                            Import the raw
                            <asp:Label ID="Label2" runat="server" Text="<%$ Resources:G3Resources, TimekeepingSystemName %>"></asp:Label>
                            timesheet file using the form below.
                        </div>
                    </td>
                </tr>
                <tr>
                    <td>
                        <telerik:RadAsyncUpload ID="uplTimesheetDetailReportFile" runat="server" TargetFolder="~/App_Data/Temp">
                        </telerik:RadAsyncUpload>
                    </td>
                </tr>
                <tr>
                    <td>
                        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server">
                        </telerik:RadAjaxLoadingPanel>
                        <telerik:RadAjaxPanel ID="RadAjaxPanel2" LoadingPanelID="RadAjaxLoadingPanel2" ClientEvents-OnRequestStart="onRequestStart" runat="server" Width="300px" Height="50px">
                            <asp:Label ID="lblStatus" runat="server" Text="Ready."></asp:Label>
                            <br />
                            <br />
                            <telerik:RadButton ID="btnImport" runat="server" Text="Import File"></telerik:RadButton>
                        </telerik:RadAjaxPanel>
                    </td>
                </tr>
            </table>
            <br />
            <br />
            <br />
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" ClientEvents-OnRequestStart="onRequestStart" runat="server">
            </telerik:RadAjaxPanel>
                <table cellpadding="5">
                    <tr>
                        <td rowspan="4">
                            <span style="position: relative; top: 15px;">
                                <asp:Image ID="Image2" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/images/window_gear-m.png" />
                            </span>
                        </td>
                        <td colspan="4">
                            <h2>Step 2: Verify the content</h2>
                            <div class="Instructions">
                                Verify that the dates within the source data are overlapping.
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <table width="100%" cellpadding="5">
                                <tr>
                                    <td>
                                        <asp:Button ID="btnGetStatistics" runat="server" Text="Get Statistics" />
                                    </td>
                                    <td align="center">
                                        <span style="position:relative; font-size:larger; font-weight:bold;">                                   
                                        Dates with Relevant Time Records in Green
                                            </span>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div style="font-size: large; font-weight: bold;">CMS Report</div>
                                        <table>
                                            <tr>
                                                <td>
                                                    Begin:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblCMSReportStartDate" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    End:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblCMSReportEndDate" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2">
                                                      
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Records:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblCMSReportRecordCount" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    First ID:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblCMSReportFirstTimesheetID" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Last ID:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblCMSReportLastTimesheetID" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td>
                                        <telerik:RadCalendar ID="datCMSReport" runat="server" EnableWeekends="True" FastNavigationNextText="&lt;&lt;" SelectedDate="" MultiViewColumns="3" AutoPostBack="false" CssClass="RadCalendarMultiView RadCalendarMultiView_Default">
                                            <SpecialDays>
                                                <telerik:RadCalendarDay Date="" Repeatable="Today">
                                                    <ItemStyle CssClass="rcToday" />
                                                </telerik:RadCalendarDay>
                                            </SpecialDays>
                                            <WeekendDayStyle CssClass="rcWeekend" />
                                            <CalendarTableStyle CssClass="rcMainTable" />
                                            <OtherMonthDayStyle CssClass="rcOtherMonth" />
                                            <OutOfRangeDayStyle CssClass="rcOutOfRange" />
                                            <DisabledDayStyle CssClass="rcDisabled" />
                                            <SelectedDayStyle CssClass="rcSelected" />
                                            <DayOverStyle CssClass="rcHover" />
                                            <FastNavigationStyle CssClass="RadCalendarMonthView RadCalendarMonthView_Default" />
                                            <ViewSelectorStyle CssClass="rcViewSel" />
                                        </telerik:RadCalendar>
                                    </td>
                                </tr>
                                <tr id="rowLastImport" runat="server">
                                    <td>
                                        <div style="font-size: large; font-weight: bold;">Last Billing File</div>
                                        <table>
                                            <tr>
                                                <td>
                                                    Begin:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblLatestBillingFileImportStartDate" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    End:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblLatestBillingFileImportEndDate" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                      
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Records:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblLatestBillingFileImportRecordCount" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    First ID:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblLatestBillingFileImportFirstTimesheetID" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Last ID:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblLatestBillingFileImportLastTimesheetID" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td>
                                        <telerik:RadCalendar ID="datLatestBillingFileImport" runat="server" AutoPostBack="True" EnableWeekends="True" FastNavigationNextText="&lt;&lt;" SelectedDate="" MultiViewColumns="3">
                                            <SpecialDays>
                                                <telerik:RadCalendarDay Date="" Repeatable="Today">
                                                    <ItemStyle CssClass="rcToday" />
                                                </telerik:RadCalendarDay>
                                            </SpecialDays>
                                            <WeekendDayStyle CssClass="rcWeekend" />
                                            <CalendarTableStyle CssClass="rcMainTable" />
                                            <OtherMonthDayStyle CssClass="rcOtherMonth" />
                                            <OutOfRangeDayStyle CssClass="rcOutOfRange" />
                                            <DisabledDayStyle CssClass="rcDisabled" />
                                            <SelectedDayStyle CssClass="rcSelected" />
                                            <DayOverStyle CssClass="rcHover" />
                                            <FastNavigationStyle CssClass="RadCalendarMonthView RadCalendarMonthView_Default" />
                                            <ViewSelectorStyle CssClass="rcViewSel" />
                                        </telerik:RadCalendar>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <div style="font-size: large; font-weight: bold;">G2 Timesheet</div>
                                        <table>
                                            <tr>
                                                <td>
                                                    Begin:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblG2StartDate" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    End:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblG2EndDate" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                              <tr>
                                                <td>
                                                      
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Records:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblG2RecordCount" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    First ID:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblFirstG2TimesheetID" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    Last ID:
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblLastG2TimesheetID" runat="server" Text="?"></asp:Label>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td>
                                        <telerik:RadCalendar ID="datG2Timesheet" runat="server" AutoPostBack="True"  EnableWeekends="True" FastNavigationNextText="&lt;&lt;" SelectedDate="" MultiViewColumns="3">
                                            <SpecialDays>
                                                <telerik:RadCalendarDay Date="" Repeatable="Today">
                                                    <ItemStyle CssClass="rcToday" />
                                                </telerik:RadCalendarDay>
                                            </SpecialDays>
                                            <WeekendDayStyle CssClass="rcWeekend" />
                                            <CalendarTableStyle CssClass="rcMainTable" />
                                            <OtherMonthDayStyle CssClass="rcOtherMonth" />
                                            <OutOfRangeDayStyle CssClass="rcOutOfRange" />
                                            <DisabledDayStyle CssClass="rcDisabled" />
                                            <SelectedDayStyle CssClass="rcSelected" />
                                            <DayOverStyle CssClass="rcHover" />
                                            <FastNavigationStyle CssClass="RadCalendarMonthView RadCalendarMonthView_Default" />
                                            <ViewSelectorStyle CssClass="rcViewSel" />
                                        </telerik:RadCalendar>
                                    </td>
     
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
                <br />
                <br />
                <br />
                <table cellpadding="5">
                    <tr>
                        <td rowspan="4">
                            <span style="position: relative; top: 15px;">
                                <asp:Image ID="Image5" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/images/window_gear-m.png" />
                            </span>
                        </td>
                        <td colspan="4">
                            <h2>Step 3: Configure Filters & Settings
                            </h2>
                            <div class="Instructions">
                                Change the filtering criteria for data inspection using the form below.
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:HyperLink ID="lnkManageDiscipline" runat="server" CssClass="SectionTitle">Date Ranges</asp:HyperLink>
                            <span class="SectionInstructions">Choose what time frame to view.</span>
                        </td>
                        <td>
                            <asp:HyperLink ID="HyperLink3" runat="server" CssClass="SectionTitle">People Filter</asp:HyperLink>
                            <span class="SectionInstructions">Filter by the
                                <asp:Label ID="Label1" runat="server" Text="<%$ Resources:G3Resources, ClientNomenclature %>"></asp:Label>
                                or
                                <asp:Label ID="Label3" runat="server" Text="<%$ Resources:G3Resources, ProviderNomenclature %>"></asp:Label>.</span>
                        </td>
                        <td align="left">
                            <asp:HyperLink ID="HyperLink1" runat="server" CssClass="SectionTitle">MCO Filter</asp:HyperLink>
                            <span class="SectionInstructions">Filter by Funding Organization.</span>
                        </td>
                        <td align="left">
                            <asp:HyperLink ID="HyperLink2" runat="server" CssClass="SectionTitle">Other Filters</asp:HyperLink>
                            <span class="SectionInstructions">Miscellaneous filters.</span>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <uc7:BillingPeriodPicker ID="ctlBillingPeriodPicker" runat="server" OverrideDatePresets="true" />
                        </td>
                        <td>
                            <uc2:EmployeePicker ID="ctlEmployeePicker" runat="server" DisplayMode="SimpleWithLabel" Label="<%$ Resources:G3Resources, ProviderNomenclature %>" DisableAutoPostback="true" />
                            <uc1:CustomerPicker ID="ctlCustomerPicker" runat="server" DisplayMode="SimpleWithLabel" Label="<%$ Resources:G3Resources, ClientNomenclature %>" DisableAutoPostback="true" />
                        </td>
                        <td>
                            <uc6:FundingOrganizationPicker ID="ctlFundingOrganization" runat="server" DisplayMode="SimpleWithLabel" Label="Funding Org:" DisableAutoPostback="true" />
                        </td>
                        <td>
     
                            <asp:CheckBox ID="chkIncludeLastImport" runat="server" AutoPostBack="false" Text="Include data from last billing file import" Checked="true" />
                            <asp:CheckBox ID="chkErrorsOnly" runat="server" Text="Include only records with time differences" Enabled="True" />
                            <asp:CheckBox ID="chkSingleTimesheetID" runat="server" Text="Filter on only one TimesheetID" Enabled="True" />
                            <div style="position: relative; left: 20px;">
                                <telerik:RadNumericTextBox ID="radTimesheetID" runat="server" DataType="System.Int32" LabelWidth="40px" MinValue="1" Width="75px">
                                    <NegativeStyle Resize="None" />
                                    <NumberFormat DecimalDigits="0" GroupSeparator="" ZeroPattern="n" />
                                    <EmptyMessageStyle Resize="None" />
                                    <ReadOnlyStyle Resize="None" />
                                    <FocusedStyle Resize="None" />
                                    <DisabledStyle Resize="None" />
                                    <InvalidStyle Resize="None" />
                                    <HoveredStyle Resize="None" />
                                    <EnabledStyle Resize="None" />
                                </telerik:RadNumericTextBox>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <asp:Button ID="btnSearch" runat="server" Text="Search" /> <asp:Button ID="btnReset" runat="server" Text="Reset" />
                             </td>
                    </tr>
                </table>
                <br />
                <br />
                <br />
                <table cellpadding="5">
                    <tr>
                        <td rowspan="4">
                            <span style="position: relative; top: 15px;">
                                <asp:Image ID="Image3" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/images/window_gear-m.png" />
                            </span>
                        </td>
                        <td colspan="4">
                            <h2>Step 4: View the results
                            </h2>
                            <div class="Instructions">
                                View and pivot the results below.
                            </div>
                        </td>
                    </tr>
                       <tr>
                        <td colspan="2" align="right">
                            <telerik:RadButton ID="btnExportToExcel" runat="server" Text="Export to Excel">
                            </telerik:RadButton>
                            <telerik:RadButton ID="btnExpandCollapseGroups" runat="server" Text="Expand / Collapse Groups">
                            </telerik:RadButton>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <telerik:RadPivotGrid ID="pvtCMStoG2" runat="server" EnableToolTips="true" EnableCaching="true" RowTableLayout="Outline" DataSourceID="sqlCMStoG2TimesheetValidation" PageSize="15" AggregatesLevel="1" RowGroupsDefaultExpanded="False">
                                <PagerStyle ChangePageSizeButtonToolTip="Change Page Size" PageSizeControlType="RadComboBox" AlwaysVisible="True"></PagerStyle>
                                <Fields>
                                    <telerik:PivotGridColumnField Caption="Source" DataField="Source" UniqueName="Source">
                                        <CalculatedItems>
                                            <telerik:PivotGridCalculatedItem GroupName="Difference"></telerik:PivotGridCalculatedItem>
                                        </CalculatedItems>
                                    </telerik:PivotGridColumnField>
                                    <telerik:PivotGridRowField DataField="MCO" UniqueName="MCO" Caption="MCO">
                                    </telerik:PivotGridRowField>
                                    <telerik:PivotGridRowField Caption="<%$ Resources:G3Resources, ClientNomenclature %>" DataField="Customer" UniqueName="Customer">
                                    </telerik:PivotGridRowField>
                                    <telerik:PivotGridRowField DataField="ServiceStarted" Caption="Start Time" DataFormatString="{0:f}" UniqueName="ServiceStarted">
                                    </telerik:PivotGridRowField>
                                    <telerik:PivotGridAggregateField Aggregate="Sum" DataField="Hours" GrandTotalAggregateFormatString="" Caption="Total Hours" UniqueName="SumOfHours">
                                        <TotalFormat Axis="Rows" Level="0" SortOrder="Ascending" GroupName="SumOfHours" />
                                        <HeaderCellTemplate>
                                            <asp:Label ID="lblHeader" runat="server" Text="Total Hours"></asp:Label>
                                        </HeaderCellTemplate>
                                    </telerik:PivotGridAggregateField>
                                    <telerik:PivotGridAggregateField Aggregate="Count" DataField="Hours" GrandTotalAggregateFormatString="" Caption="Service Visits" UniqueName="CountOfVisits">
                                        <TotalFormat Axis="Rows" Level="0" SortOrder="Ascending" />
                                        <HeaderCellTemplate>
                                            <asp:Label ID="lblHeader" runat="server" Text="Service Count"></asp:Label>
                                        </HeaderCellTemplate>
                                    </telerik:PivotGridAggregateField>
                                </Fields>
                                <TotalsSettings RowGrandTotalsPosition="Last" ColumnGrandTotalsPosition="None" />
                                <ConfigurationPanelSettings EnableOlapTreeViewLoadOnDemand="True"></ConfigurationPanelSettings>
                            </telerik:RadPivotGrid>
                            <asp:SqlDataSource ID="sqlCMStoG2TimesheetValidation" runat="server" ConnectionString="<%$ ConnectionStrings:SOREOConnection %>" SelectCommand="reconciliation.cspCMStoG2TimesheetValidation" SelectCommandType="StoredProcedure" CancelSelectOnNullParameter="false">
                                <SelectParameters>
                                    <asp:Parameter Name="BeginDate" Type="DateTime" />
                                    <asp:Parameter Name="EndDate" Type="DateTime" />
                                    <asp:ControlParameter ControlID="ctlEmployeePicker" PropertyName="SelectedEmployeeID" Name="EmployeeID" />
                                    <asp:ControlParameter ControlID="ctlCustomerPicker" PropertyName="SelectedCustomerID" Name="CustomerID" />
                                    <asp:ControlParameter ControlID="ctlFundingOrganization" PropertyName="SelectedFundingOrganizationName" Name="FundingAgency" />
                                    <asp:Parameter Name="TimesheetID" Type="Int32" />
                                    <asp:ControlParameter ControlID="chkIncludeLastImport" PropertyName="Checked" Name="IncludeLastImport" />
                                    <asp:ControlParameter ControlID="chkErrorsOnly" PropertyName="Checked" Name="ErrorsOnly" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                        </td>
                    </tr>
                </table>
        </div>
    <telerik:RadToolTipManager Width="250px" Height="300px" RelativeTo="Element" ID="RadToolTipManager2"
    runat="server" OffsetX="15" Position="MiddleRight"
    Skin="Telerik">
    </telerik:RadToolTipManager>
    </asp:Content>


    and here is the code-behind:

    Imports Telerik.Web.UI.PivotGrid.Core.Aggregates
    Imports System.Drawing
    Imports System.IO
    Imports LumenWorks.Framework.IO.Csv
     
    Public Class ReconcileTime
        Inherits System.Web.UI.Page
     
     
    #Region "GLOBAL OBJECTS"
     
        'Constants...
        Private Const pc_strRelevantBackgroundCellColor As String = "#CCFFCC"
     
    #End Region
     
     
    #Region "PAGE EVENT OVERRIDES"
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            'Perform initial page processing.
            If Not Page.IsPostBack Then
                'Preset the date pickers.
                'ctlBillingPeriodPicker.RootDate
                'datFrom.SelectedDate = BillingPeriodHelper.ComputeStartDate(BillingFrequencyEnum.Weekly)
                'datTo.SelectedDate = BillingPeriodHelper.ComputeEndDate(BillingFrequencyEnum.Weekly)
                ctlBillingPeriodPicker.StartDate = #1/1/2015#
                ctlBillingPeriodPicker.EndDate = #1/31/2015#
     
                'Set the focused date for the calendars.
                datCMSReport.FocusedDate = Now.Date.AddMonths(-2)
                datLatestBillingFileImport.FocusedDate = Now.Date.AddMonths(-2)
                datG2Timesheet.FocusedDate = Now.Date.AddMonths(-2)
            End If
     
            'Toggle item visibility based on preferences.
            rowLastImport.Visible= chkIncludeLastImport.Checked
        End Sub
     
    #End Region
     
     
    #Region "MISCELLANEOUS EVENT HANDLERS"
     
        Protected Sub btnSearch_Click(sender As Object, e As EventArgs) Handles btnSearch.Click
            ''Collapse the pivot grid content.
            'pvtCMStoG2.CollapseAllRowGroups()
            'pvtCMStoG2.CollapseAllColumnGroups()
     
            'Bind the pivot grid.
            pvtCMStoG2.DataBind()
        End Sub
     
     
        Protected Sub btnGetStatistics_Click(sender As Object, e As EventArgs) Handles btnGetStatistics.Click
            'Calculate the date boundaries.
            Call RetrieveStatistics()
        End Sub
     
     
        Protected Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
            'datFrom.SelectedDate=
            'datTo.SelectedDate =
     
            'Reset the people pickers.
            ctlCustomerPicker.ResetPicker()
            ctlEmployeePicker.ResetPicker()
     
            'Reset other controls.
            ctlFundingOrganization.ResetPicker()
        End Sub
     
     
        Protected Sub btnImport_Click(sender As Object, e As EventArgs) Handles btnImport.Click
            Try
                'Get the name of the file that was just uploaded.
                Dim m_strUploadedFileName As String = uplTimesheetDetailReportFile.UploadedFiles(0).FileName
     
                'Process the CSV file
                Call ProcessCSVUsingCSVReader(Server.MapPath("~/App_Data/Temp/" & m_strUploadedFileName))
     
                'Compute the earliest and latest dates in the file.
                Using dbContext As New EntitiesModel()
                    'Get the first imported record.
                    Dim FirstResult = (From item In dbContext.DetailedTimesheetReports
                                                                                          Order By item.ServiceStarted Ascending).First
     
                    'Get the last record.
                    Dim LastResult = (From item In dbContext.DetailedTimesheetReports
                                                                                          Order By item.ServiceStarted Ascending).Last
     
                    'Set the status
                    lblStatus.Text = String.Format("<span style='font-weight:bold;'>Successfully imported the csv file.</span><br>The import contains records from {0:d} (Timesheet ID {1}) to {2:d} (Timesheet ID {3}).", FirstResult.ServiceStarted, FirstResult.TimesheetID, LastResult.ServiceStarted, LastResult.TimesheetID)
                    lblStatus.ForeColor = Color.Green
                End Using
            Catch ex As Exception
                'Set the status
                lblStatus.Text = "Error importing the csv file."
                lblStatus.ToolTip = ex.Message
                lblStatus.Font.Bold = True
                lblStatus.ForeColor = Color.Red
            End Try
        End Sub
     
     
        Protected Sub btnExportToExcel_Click(sender As Object, e As EventArgs) Handles btnExportToExcel.Click
            'Export the file.
            pvtCMStoG2.ExportToExcel()
        End Sub
     
     
        Protected Sub btnExpandCollapseGroups_Click(sender As Object, e As EventArgs) Handles btnExpandCollapseGroups.Click
            'Toggle groups.
            pvtCMStoG2.ExpandAllRowGroups()
        End Sub
     
    #End Region
     
     
    #Region "PIVOT GRID EVENT HANDLERS"
     
        Private Sub pvtCMStoG2_CellDataBound(sender As Object, e As PivotGridCellDataBoundEventArgs) Handles pvtCMStoG2.CellDataBound
            'Process the cell formats as needed.
            If TypeOf (e.Cell) Is PivotGridDataCell Then
                'Get a reference to the cell.
                Dim cell As PivotGridDataCell = TryCast(e.Cell, PivotGridDataCell)
     
                If cell.CellType = PivotGridDataCellType.DataCell Then
                    'Check for valid format before proceeding.
                    If String.IsNullOrEmpty(cell.DataItem) = False Then
                        Select Case cell.ParentColumnIndexes(0).ToString
                            Case "Difference"
                                'Get the current value.
                                Dim quantity As Double = Convert.ToDouble(cell.DataItem)
     
                                'Conditionally set the format.
                                If quantity > 0 Then
                                    cell.BackColor = Color.LightGreen
                                    cell.ForeColor = Color.Green
                                ElseIf quantity < 0 Then
                                    cell.BackColor = ColorTranslator.FromHtml("#FF7373")
                                    cell.ForeColor = Color.White
                                End If
                            Case "Last Billing File"
                                cell.BackColor = Color.LightYellow
                        End Select
                    End If
     
                ElseIf cell.CellType = PivotGridDataCellType.RowTotalDataCell OrElse cell.CellType = PivotGridDataCellType.ColumnTotalDataCell Then
                    'Check for valid format before proceeding.
                    If String.IsNullOrEmpty(cell.DataItem) = False Then
                        Select Case cell.ParentColumnIndexes(0).ToString
                            Case "Difference"
                                If cell.DataItem.ToString().Length > 0 Then
                                    'Get the current value.
                                    Dim quantity As Double = Convert.ToDouble(cell.DataItem)
     
                                    'Conditionally set the format.
                                    If quantity > 0 Then
                                        cell.BackColor = Color.LightGreen
                                        cell.ForeColor = Color.Green
                                        cell.Font.Bold = True
                                    ElseIf quantity < 0 Then
                                        cell.BackColor = ColorTranslator.FromHtml("#FF7373")
                                        cell.ForeColor = Color.White
                                        cell.Font.Bold = True
                                    End If
                                End If
                                Exit Select
                        End Select
                    End If
     
                ElseIf cell.CellType = PivotGridDataCellType.RowGrandTotalDataCell OrElse cell.CellType = PivotGridDataCellType.ColumnGrandTotalDataCell Then
                    'Check for valid format before proceeding.
                    If cell.ParentColumnIndexes(0) IsNot Nothing AndAlso String.IsNullOrEmpty(cell.ParentColumnIndexes(0).ToString) = False Then
                        Select Case cell.ParentColumnIndexes(0).ToString
                            Case "Difference"
                                'Get the current value.
                                Dim quantity As Double = Convert.ToDouble(cell.DataItem)
     
                                'Conditionally set the format.
                                If quantity > 0 Then
                                    cell.BackColor = Color.Green
                                    cell.ForeColor = Color.Black
                                    cell.Font.Bold = True
                                ElseIf quantity < 0 Then
                                    cell.BackColor = Color.Red
                                    cell.ForeColor = Color.White
                                    cell.Font.Bold = True
                                End If
                                Exit Select
                        End Select
                    End If
     
                End If
            ElseIf TypeOf (e.Cell) Is PivotGridRowHeaderCell Then
                'Get a reference to the cell.
                Dim cell As PivotGridRowHeaderCell = TryCast(e.Cell, PivotGridRowHeaderCell)
     
                Select Case cell.Text
                    Case "columnname"
                        cell.Font.Bold = True
                End Select
     
            ElseIf TypeOf (e.Cell) Is PivotGridColumnHeaderCell Then
                'Get a reference to the cell.
                Dim cell As PivotGridColumnHeaderCell = TryCast(e.Cell, PivotGridColumnHeaderCell)
     
                Select Case cell.Text
                    Case "Difference"
                        cell.Font.Bold = True
                        cell.Font.Italic = True
                End Select
     
                'Set the alignment of the cell
                cell.HorizontalAlign = HorizontalAlign.Center
            End If
        End Sub
     
     
        Private Sub pvtCMStoG2_ItemNeedCalculation(sender As Object, e As PivotGridCalculationEventArgs) Handles pvtCMStoG2.ItemNeedCalculation
            'Calculate the difference between G2 and CMS hours.
            If e.GroupName.ToString() = "Difference" Then
                'Declare local variables.
                Dim m_dblCMSValue, m_dblG2Value As Double
     
     
                'Get the current CMS value.
                If e.GetAggregateSummaryValue("CMS") IsNot Nothing AndAlso String.IsNullOrEmpty(e.GetAggregateSummaryValue("CMS").GetValue().ToString()) = False Then
                    m_dblCMSValue = Double.Parse(e.GetAggregateSummaryValue("CMS").GetValue().ToString())
                Else
                    m_dblCMSValue = 0D
                End If
     
                'Get the current G2 value.
                If e.GetAggregateSummaryValue("G2") IsNot Nothing AndAlso String.IsNullOrEmpty(e.GetAggregateSummaryValue("G2").GetValue().ToString()) = False Then
                    m_dblG2Value = Double.Parse(e.GetAggregateSummaryValue("G2").GetValue().ToString())
                Else
                    m_dblG2Value = 0D
                End If
     
     
                'Calculate the final difference value.
                e.CalculatedValue = New DoubleAggregateValue(m_dblG2Value - m_dblCMSValue)
            End If
        End Sub
     
     
    #End Region
     
     
    #Region "MISCELLANEOUS SUPPORT ROUTINES"
     
        'Private Function CleanNumber(InputString As String) As Integer
        '    'Declare local variables.
        '    Dim m_intReturnValue As Integer
     
        '    If String.IsNullOrEmpty(InputString) = False Then
        '        'Clean out everything but the numbers
        '        m_intReturnValue = Convert.ToInt32(Regex.Replace(InputString, "[^\d.]", "", RegexOptions.IgnoreCase Or RegexOptions.Multiline))
        '    End If
     
        '    'Return the value.
        '    Return m_intReturnValue
        'End Function
     
    #End Region
     
     
    #Region "DATASOURCE EVENT HANDLERS"
     
        '''////////////////////////////////////////////////////////////////////////////////////////////////////
        ''' <summary>
        '''     Event handler. Called by ASP.NET SQL Server Datasource Line Item Data Inspection
        '''     Selecting control (sdsLineItemDataInspection class) for selecting events.
        ''' </summary>
        ''' <remarks>
        '''     Commented by Mike Danielski.
        ''' </remarks>
        ''' <param name="sender">
        '''     Source of the event.
        ''' </param>
        ''' <param name="e">
        '''     SQL data source selecting event information.
        ''' </param>
        '''////////////////////////////////////////////////////////////////////////////////////////////////////
        Private Sub sdsLineItemDataInspection_Selecting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles sqlCMStoG2TimesheetValidation.Selecting
            'Cancel the intiial page load select.
            If Page.IsPostBack = False Then
                e.Cancel = True
            End If
     
            'Set the command timeout value to wait indefinitely.
            e.Command.CommandTimeout = 0
     
            'Address the timesheet ID.
            If chkSingleTimesheetID.Checked = True Then
                e.Command.Parameters("@TimesheetID").Value = radTimesheetID.Value
            Else
                e.Command.Parameters("@TimesheetID").Value = System.DBNull.Value
            End If
     
            'Set the date-based parameters.
            e.Command.Parameters("@BeginDate").Value = ctlBillingPeriodPicker.StartDate
            e.Command.Parameters("@EndDate").Value = ctlBillingPeriodPicker.EndDate
        End Sub
     
    #End Region
     
     
    #Region "FILE UPLOAD ROUTINES"
     
        '''////////////////////////////////////////////////////////////////////////////////////////////////////
        ''' <summary>
        '''     Upl timesheet detail report file uploaded method.
        ''' </summary>
        ''' <remarks>
        '''     Commented by Mike Danielski.
        ''' </remarks>
        ''' <param name="sender">
        '''     Source of the event.
        ''' </param>
        ''' <param name="e">
        '''     File uploaded event information.
        ''' </param>
        '''////////////////////////////////////////////////////////////////////////////////////////////////////
        Private Sub uplTimesheetDetailReportFile_FileUploaded(sender As Object, e As FileUploadedEventArgs) Handles uplTimesheetDetailReportFile.FileUploaded
            'Get the full filename.
            Dim m_strFullFileName As String
            m_strFullFileName = Server.MapPath(uplTimesheetDetailReportFile.TargetFolder & "\" & e.File.FileName)
     
            'Save the file to the proper location.
            e.File.SaveAs(m_strFullFileName)
     
            'Remove the first line and resave the file.
            Call RemoveFileHeaderAndFooter(m_strFullFileName)
        End Sub
     
     
        '''////////////////////////////////////////////////////////////////////////////////////////////////////
        ''' <summary>
        '''     Remove standard header method.
        ''' </summary>
        ''' <remarks>
        '''     Commented by Mike Danielski.
        ''' </remarks>
        ''' <param name="filePath">
        '''     Full pathname of the file.
        ''' </param>
        '''////////////////////////////////////////////////////////////////////////////////////////////////////
        Public Sub RemoveFileHeaderAndFooter(ByVal filePath As String)
            'Make sure we have a file.
            If (String.IsNullOrEmpty(filePath)) Then
                Return
            End If
     
            'Get the lines from the file.
            Dim lines As New List(Of String)(File.ReadAllLines(filePath))
     
     
            'Check to see if the line can be removed.
            If lines.Count > 2 AndAlso lines(0).ToString.StartsWith("Detail Timesheet Report") Then
                'Remove the first line only
                lines.RemoveAt(0)
            End If
     
     
            'Remove the last two lines - the footer.
            lines.RemoveRange(lines.Count - 2, 2)
     
            'Write the modified file back to disk.
            File.WriteAllLines(filePath, lines.ToArray())
        End Sub
     
     
        '''////////////////////////////////////////////////////////////////////////////////////////////////////
        ''' <summary>
        '''     Process CSV using CSV reader method.
        ''' </summary>
        ''' <remarks>
        '''     Commented by Mike Danielski.
        ''' </remarks>
        ''' <param name="FileName">
        '''     Filename of the file.
        ''' </param>
        '''////////////////////////////////////////////////////////////////////////////////////////////////////
        Private Sub ProcessCSVUsingCSVReader(FileName As String)
            'Open the file
            Using csv As New CsvReader(New StreamReader(FileName), True)
                'Call the method to generate the account numbers.
                Using dbContext As New EntitiesModel()
                    'Purge the destination table.
                    dbContext.ExecuteNonQuery("TRUNCATE TABLE reconciliation.tblDetailedTimesheetReport")
     
                    'Save Changes
                    dbContext.SaveChanges()
     
                    'Process the individual fields.
                    While csv.ReadNextRecord()
                        'Create a new record
                        Dim m_objNewTimesheetRecord As New reconciliation.DetailedTimesheetReport
     
                        'Source column variables to hold CSV content.
                        Dim m_strDate As String = csv("Date")
                        Dim m_strStart As String = csv("Start")
                        Dim m_strEnd As String = csv("End")
                        Dim m_strServiceCode As String = csv("SvcCode").ToUpper
                        Dim m_strTimeEntryID As String = csv("Time Entry Id")
                        Dim m_strClientNumber As String = csv("Client#")
                        Dim m_strDCWPIN As String = csv("DCW PIN")
                        Dim m_strAuthorizationID As String = csv("AuthID")
                        Dim m_strHours As String = csv("Hours")
                        Dim m_strApproved As String = csv("Approved")
                        Dim m_strMCO As String = csv("MCO")
                        Dim m_strAuthorizationName As String = csv("AuthName")
                        Dim m_strAuthorizationNumber As String = csv("AuthNumber")
                        Dim m_strDCW As String = csv("DCW")
                        Dim m_strSC As String = csv("SC")
                        Dim m_strModifiers As String = csv("Modifiers")
                        Dim m_strStatus As String = csv("Status")
                        Dim m_strRegion As String = csv("Region")
     
     
                        'Declare strongly typed destination variables to hold final values.
                        Dim m_intTimesheetID As Integer
                        Dim m_intClientID As Integer
                        Dim m_intPIN As Integer
                        Dim m_intAuthorizationID As Integer
                        Dim m_decHours As Decimal
                        Dim m_datServiceStarted As Date
                        Dim m_datServiceEnded As Date
                        Dim m_datApprovedDate As Date
                        Dim m_strDCWFirstName As String = String.Empty
                        Dim m_strDCWLastName As String = String.Empty
     
     
                        'Assign TimesheetID
                        If Integer.TryParse(m_strTimeEntryID, m_intTimesheetID) = False Then
                            Throw New Exception("A 'Time Entry Id' value in the uploaded file is not valid.")
                        End If
     
                        'ClientID
                        If Integer.TryParse(m_strClientNumber, m_intClientID) = False Then
                            Throw New Exception("A 'Client#' value in the uploaded file is not valid.")
                        End If
     
                        'PIN
                        If Integer.TryParse(m_strDCWPIN, m_intPIN) = False Then
                            Throw New Exception("A 'DCW PIN' value in the uploaded file is not valid.")
                        End If
     
                        'Authorization ID.
                        If Integer.TryParse(m_strAuthorizationID, m_intAuthorizationID) = False Then
                            Throw New Exception("The Authorization ID value in the uploaded file is not valid.")
                        End If
     
                        'Hours.
                        If Decimal.TryParse(m_strHours, m_decHours) = False Then
                            Throw New Exception("The Hours value in the uploaded file is not valid.")
                        End If
     
                        'Calculate start date.
                        If String.IsNullOrEmpty(m_strDate) = False AndAlso String.IsNullOrEmpty(m_strStart) = False Then
                            If Date.TryParse(m_strDate & " " & m_strStart, m_datServiceStarted) = False Then
                                'm_datServiceStarted = Convert.ToDateTime(m_strDate & " " & m_strStart)
                                Throw New Exception("The service start date and time value in the uploaded file is not valid.")
                            End If
                        End If
     
                        'Calculate end date
                        If String.IsNullOrEmpty(m_strDate) = False AndAlso String.IsNullOrEmpty(m_strEnd) = False Then
                            If Date.TryParse(m_strDate & " " & m_strEnd, m_datServiceEnded) = False Then
                                'm_datServiceEnded = Convert.ToDateTime(m_strDate & " " & m_strEnd)
                                Throw New Exception("The service end date and time value in the uploaded file is not valid.")
                            End If
                        End If
     
                        'Approval date
                        If Date.TryParse(m_strApproved, m_datApprovedDate) = False Then
                            Throw New Exception("The approved date value in the uploaded file is not valid.")
                        End If
     
                        'Clean the service code.
                        Select Case m_strServiceCode
                            Case String.Empty
                                m_strServiceCode = String.Empty
                            Case "PENDING"
                                m_strServiceCode = m_strServiceCode
                            Case "COMP"
                                m_strServiceCode = m_strServiceCode
                            Case Else
                                m_strServiceCode = Left(m_strServiceCode, 3)
                        End Select
     
                        'Parse the name
                        If String.IsNullOrEmpty(m_strDCW) = False Then
                            m_strDCWFirstName = StrConv(m_strDCW.ToString.Split(" ")(0), vbProperCase)
                            m_strDCWLastName = StrConv(m_strDCW.ToString.Split(" ")(1), vbProperCase)
                        End If
     
     
                        'Set the properties.
                        With m_objNewTimesheetRecord
                            'Integer fields.
                            .TimesheetID = m_intTimesheetID
                            .ClientID = m_intClientID
                            .PIN = m_intPIN
                            .AuthorizationID = m_intAuthorizationID
     
                            'Decimal fields.
                            .Hours = m_decHours
     
                            'Date fields
                            .ServiceStarted = m_datServiceStarted
                            .ServiceEnded = m_datServiceEnded
                            .ApprovedDate = m_datApprovedDate
     
                            'String fields.
                            .Agency = IIf(String.IsNullOrEmpty(m_strMCO), String.Empty, m_strMCO)
                            .AuthorizationName = StrConv(m_strAuthorizationName, vbProperCase)
                            .AuthorizationNumber = IIf(String.IsNullOrEmpty(m_strAuthorizationNumber), String.Empty, m_strAuthorizationNumber)
                            .ServiceCode = m_strServiceCode
                            .DCWFirstName = m_strDCWFirstName
                            .DCWLastName = m_strDCWLastName
                            .ServiceCoordinator = m_strSC
                            .Modifiers = m_strModifiers
                            .Status = m_strStatus
                            .Region = m_strRegion
                        End With
     
     
                        'Add the new record.
                        dbContext.Add(m_objNewTimesheetRecord)
                    End While
     
     
                    'Save Changes
                    dbContext.SaveChanges()
                End Using
            End Using
        End Sub
     
     
        Private Sub RetrieveStatistics()
            'Compute the earliest and latest dates in the file.
            Using dbContext As New EntitiesModel()
                '--------- CMS REPORT Data --------------------------------------------------------------------------------------------------
                'Get the first billing file record.
                Dim CMSReportResults = (From item In dbContext.DetailedTimesheetReports
                                                        Order By item.ServiceStarted Ascending)
     
                'Get the first imported record.
                Dim CMSReportFirstResult = (From item In dbContext.DetailedTimesheetReports
                                                        Order By item.ServiceStarted Ascending).FirstOrDefault
     
                'Get the last record.
                Dim CMSReportLastResult = (From item In dbContext.DetailedTimesheetReports
                                                        Order By item.ServiceStarted Ascending).LastOrDefault
     
                'Declare local variables.
                Dim m_intCMSReportRecordCount As Integer = CMSReportResults.Count
     
                'Assign content to labels.
                lblCMSReportRecordCount.Text = m_intCMSReportRecordCount.ToString("N0")
     
                If CMSReportFirstResult IsNot Nothing AndAlso CMSReportLastResult IsNot Nothing Then
                    lblCMSReportStartDate.Text = CMSReportFirstResult.ServiceStarted
                    lblCMSReportEndDate.Text = CMSReportLastResult.ServiceEnded
                    lblCMSReportFirstTimesheetID.Text = CMSReportFirstResult.TimesheetID
                    lblCMSReportLastTimesheetID.Text = CMSReportLastResult.TimesheetID
     
                    'Set the values into session.
                    Session("BillingFileStartDate") = CMSReportFirstResult.ServiceStarted
                    Session("BillingFileEndDate") = CMSReportLastResult.ServiceEnded
                Else
                    lblCMSReportStartDate.Text = "?"
                    lblCMSReportEndDate.Text = "?"
                    lblCMSReportFirstTimesheetID.Text = "?"
                    lblCMSReportLastTimesheetID.Text = "?"
                End If
     
     
     
                '--------- BILLING FILE Data --------------------------------------------------------------------------------------------------
                'Get the first Billing File record.
                Dim LatestBillingFileImportResults = (From item In dbContext.Timesheets
                                                                                      Order By item.StartDate Ascending)
     
                'Get the first Billing File record.
                Dim LatestBillingFileImportFirstResult = (From item In dbContext.Timesheets
                                                                                      Order By item.StartDate Ascending).FirstOrDefault
     
                'Get the last Billing File record.
                Dim LatestBillingFileImportLastResult = (From item In dbContext.Timesheets
                                                                                      Order By item.StartDate Ascending).LastOrDefault
     
                'Declare local variables.
                Dim m_intLatestBillingFileImportRecordCount As Integer = LatestBillingFileImportResults.Count
     
                'Assign content to labels.
                lblLatestBillingFileImportRecordCount.Text = m_intLatestBillingFileImportRecordCount.ToString("N0")
     
                'Process the results.
                If LatestBillingFileImportFirstResult IsNot Nothing AndAlso LatestBillingFileImportLastResult IsNot Nothing Then
                    lblLatestBillingFileImportStartDate.Text = LatestBillingFileImportFirstResult.StartDate
                    lblLatestBillingFileImportEndDate.Text = LatestBillingFileImportLastResult.EndDate
                    lblLatestBillingFileImportFirstTimesheetID.Text = LatestBillingFileImportFirstResult.TimeSheetId
                    lblLatestBillingFileImportLastTimesheetID.Text = LatestBillingFileImportLastResult.TimeSheetId
     
                    'Store the date ranges in the session.
                    Session("BillingFileStartDate") = LatestBillingFileImportFirstResult.StartDate
                    Session("BillingFileEndDate") = LatestBillingFileImportLastResult.EndDate
                Else
                    lblLatestBillingFileImportStartDate.Text = "?"
                    lblLatestBillingFileImportEndDate.Text = "?"
                    lblLatestBillingFileImportFirstTimesheetID.Text = "?"
                    lblLatestBillingFileImportLastTimesheetID.Text = "?"
                End If
     
     
     
     
                '--------- G2 Data --------------------------------------------------------------------------------------------------
                'Calculate the proper range of dates that should be pulled from G2, based on smallest overlapping window of imported data.
                Dim m_datG2BeginDate As Date
                Dim m_datG2EndDate As Date
     
                'Perform different analysis depending on whether last import was to be included.
                If chkIncludeLastImport.Checked Then
                    If LatestBillingFileImportFirstResult IsNot Nothing AndAlso CMSReportFirstResult IsNot Nothing Then
                        'Calculate the start of the period.
                        If LatestBillingFileImportFirstResult.StartDate > CMSReportFirstResult.ServiceStarted Then
                            m_datG2BeginDate = CMSReportFirstResult.ServiceStarted
                        Else
                            m_datG2BeginDate = LatestBillingFileImportFirstResult.StartDate
                        End If
     
                        'Calculate the end of the period.
                        If LatestBillingFileImportLastResult.EndDate > CMSReportLastResult.ServiceEnded Then
                            m_datG2EndDate = CMSReportLastResult.ServiceEnded
                        Else
                            m_datG2EndDate = LatestBillingFileImportLastResult.EndDate
                        End If
                    Else
                        'Get the values from the period picker.
                        m_datG2BeginDate = ctlBillingPeriodPicker.StartDate
                        m_datG2EndDate = ctlBillingPeriodPicker.EndDate
                    End If
                Else
                    'Copy dates from CMS data since there is nothing else to compare to.
                    m_datG2BeginDate = LatestBillingFileImportFirstResult.StartDate
                    m_datG2EndDate = LatestBillingFileImportLastResult.StartDate
                End If
     
     
                If m_datG2BeginDate <> #12:00:00 AM# AndAlso m_datG2EndDate <> #12:00:00 AM# Then
                    'Get the first G2 record.
                    Dim G2Results = (From item In dbContext.LineItems
                                                Where item.ServiceStarted >= m_datG2BeginDate And item.ServiceEnded <= m_datG2EndDate
                                                Order By item.ServiceStarted Ascending)
     
                    'Get the first imported record.
                    Dim FirstG2Result = (From item In dbContext.LineItems
                                                    Where item.ServiceStarted >= m_datG2BeginDate And item.ServiceEnded <= m_datG2EndDate
                                                    Order By item.ServiceStarted Ascending).FirstOrDefault
     
                    'Get the last record.
                    Dim LastG2Result = (From item In dbContext.LineItems
                                                    Where item.ServiceStarted >= m_datG2BeginDate And item.ServiceEnded <= m_datG2EndDate
                                                    Order By item.ServiceStarted Ascending).LastOrDefault
     
                    'Declare local variables.
                    Dim m_intG2RecordCount As Integer = G2Results.Count
     
                    'Assign content to labels.
                    lblG2RecordCount.Text = m_intG2RecordCount.ToString("N0")
     
                    'Set the date ranges
                    lblG2StartDate.Text = m_datG2BeginDate
                    lblG2EndDate.Text = m_datG2EndDate
     
     
                    'Process the final results.
                    If FirstG2Result IsNot Nothing AndAlso LastG2Result IsNot Nothing Then
                        lblFirstG2TimesheetID.Text = FirstG2Result.SourceKey
                        lblLastG2TimesheetID.Text = LastG2Result.SourceKey
     
                        'Set the values into session.
                        Session("EarliestG2Date") = m_datG2BeginDate
                        Session("LatestG2Date") = m_datG2EndDate
                    Else
                        lblFirstG2TimesheetID.Text = "?"
                        lblLastG2TimesheetID.Text = "?"
                    End If
                Else
                    lblG2StartDate.Text = "?"
                    lblG2EndDate.Text = "?"
                    lblG2RecordCount.Text = "0"
                    lblFirstG2TimesheetID.Text = "?"
                    lblLastG2TimesheetID.Text = "?"
                End If
     
     
                ''DEBUG DATA.
                'Session("BillingFileStartDate") = #2/20/2015#
                'Session("BillingFileEndDate") = #2/28/2015#
                'Session("EarliestBillingFileDate") = #2/1/2015#
                'Session("LatestBillingFileDate") = #2/7/2015#
                'Session("EarliestG2Date") = #2/27/2015#
                'Session("LatestG2Date") = #3/5/2015#
            End Using
        End Sub
     
    #End Region
     
     
    #Region "CALENDAR EVENTS"
     
        Private Sub datCMSReport_DayRender(sender As Object, e As Telerik.Web.UI.Calendar.DayRenderEventArgs) Handles datCMSReport.DayRender
            ''Prepare the cell for "tooltipifying".
            'e.Cell.Attributes.Add("ID", e.Day.[Date].ToString())
            'RadToolTipManager1.TargetControls.Add(e.Cell.Attributes("ID"), True)
     
     
            'Only perform this process if there are values to work with.
            If Session("BillingFileStartDate") IsNot Nothing AndAlso Session("BillingFileEndDate") IsNot Nothing Then
                'For Each row As Data.DataRow In dt.Rows
                Dim IsInMonth As Boolean = e.Day.Date.Month = e.View.MonthStartDate.Month
     
                'Check if the current date format should be changed
                If (e.Day.Date >= Convert.ToDateTime(Session("BillingFileStartDate")) And e.Day.Date <= Convert.ToDateTime(Session("BillingFileEndDate"))) And IsInMonth Then
                    e.Cell.Style("background-color") = pc_strRelevantBackgroundCellColor
     
                    'Get a reference to the cell itself.
                    Dim cell As TableCell = e.Cell
     
                    'Set the properties
                    cell.CssClass = "Appointment"
                    cell.Attributes.Add("id", "datG2Timesheet_" + ID.ToString())
     
                    'Add the control to the collection
                    RadToolTipManager2.TargetControls.Add(e.Cell.Attributes("id"), ID.ToString(), True)
                End If
            End If
        End Sub
     
     
        Private Sub datLatestBillingFileImport_DayRender(sender As Object, e As Telerik.Web.UI.Calendar.DayRenderEventArgs) Handles datLatestBillingFileImport.DayRender
            ''Prepare the cell for "tooltipifying".
            'e.Cell.Attributes.Add("ID", e.Day.[Date].ToString())
            'RadToolTipManager1.TargetControls.Add(e.Cell.Attributes("ID"), True)
     
     
            'Only perform this process if there are values to work with.
            If Session("BillingFileStartDate") IsNot Nothing AndAlso Session("BillingFileEndDate") IsNot Nothing Then
                'For Each row As Data.DataRow In dt.Rows
                Dim IsInMonth As Boolean = e.Day.Date.Month = e.View.MonthStartDate.Month
     
                'Check if the current date format should be changed
                If (e.Day.Date >= Convert.ToDateTime(Session("BillingFileStartDate")) And e.Day.Date <= Convert.ToDateTime(Session("BillingFileEndDate"))) And IsInMonth Then
                    e.Cell.Style("background-color") = pc_strRelevantBackgroundCellColor
     
                    'Get a reference to the cell itself.
                    Dim cell As TableCell = e.Cell
     
                    'Set the properties
                    cell.CssClass = "Appointment"
                    cell.Attributes.Add("id", "datG2Timesheet_" + ID.ToString())
     
                    'Add the control to the collection
                    RadToolTipManager2.TargetControls.Add(e.Cell.Attributes("id"), ID.ToString(), True)
                End If
            End If
        End Sub
     
     
        Private Sub datG2Timesheet_DayRender(sender As Object, e As Telerik.Web.UI.Calendar.DayRenderEventArgs) Handles datG2Timesheet.DayRender
            ''Prepare the cell for "tooltipifying".
            'e.Cell.Attributes.Add("ID", e.Day.[Date].ToString())
            'RadToolTipManager1.TargetControls.Add(e.Cell.Attributes("ID"), True)
     
     
            'Only perform this process if there are values to work with.
            If Session("EarliestG2Date") IsNot Nothing AndAlso Session("LatestG2Date") IsNot Nothing Then
                'For Each row As Data.DataRow In dt.Rows
                Dim IsInMonth As Boolean = e.Day.Date.Month = e.View.MonthStartDate.Month
     
                'Check if the current date format should be changed
                If (e.Day.Date >= Convert.ToDateTime(Session("EarliestG2Date")) And e.Day.Date <= Convert.ToDateTime(Session("LatestG2Date"))) And IsInMonth Then
                    e.Cell.Style("background-color") = pc_strRelevantBackgroundCellColor
     
                    'Get a reference to the cell itself.
                    Dim cell As TableCell = e.Cell
     
                    'Set the properties
                    cell.CssClass = "Appointment"
                    cell.Attributes.Add("id", "datG2Timesheet_" + ID.ToString())
     
                    'Add the control to the collection
                    RadToolTipManager2.TargetControls.Add(e.Cell.Attributes("id"), ID.ToString(), True)
                End If
            End If
        End Sub
     
     
        Private Sub RadToolTipManager2_AjaxUpdate(sender As Object, e As ToolTipUpdateEventArgs) Handles RadToolTipManager2.AjaxUpdate
            'Create a reference to the child control that will be oaded dynamically.
            Dim ctlTimeForTheDay As TimeForDay = DirectCast(Me.LoadControl("TimeForDay.ascx"), TimeForDay)
     
            'Set the control properties.
            ctlTimeForTheDay.ID = "ctlTimeForDay"
            ctlTimeForTheDay.TargetDate = DateTime.Parse(e.Value)
     
            'Add the control to the collection.
            e.UpdatePanel.ContentTemplateContainer.Controls.Add(ctlTimeForTheDay)
        End Sub
     
     
    #End Region
     
     
     
    End Class
  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 30 Mar 2015 Link to this post

    Hi,

    I tried to reproduce the behavior, however I was unable to. For reference I am attaching a sample project I used for testing. Give it a try and let me know how it works for you.

    On a side note, have in mind that if there are script errors on the page they will prevent the controls from working as expected. Would you open the browser console by pressing F12 and ensure that there are no errors listed?

    Regards,
    Viktor Tachev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tayonee
    Tayonee avatar
    52 posts
    Member since:
    Nov 2006

    Posted 31 Mar 2015 in reply to Viktor Tachev Link to this post

    Hi Viktor,

    I ran your sample and it does work properly on my machine. I will do a very close comparison on the existing page to see if there are any errors that may be causing the problem. Otherwise I will extract the calendar components to a new page and see if I can isolate the issue. I'll let you know how that testing goes to see if I can nail down the cause.

    Thanks,
    Mike
  5. Tayonee
    Tayonee avatar
    52 posts
    Member since:
    Nov 2006

    Posted 31 Mar 2015 Link to this post

    Hi Viktor,

    I was able to copy over my calendar code and got the tooltip running PARTIALLY. I have included my new test page below (mike.aspx), which shows what I am dealing with. Per the attached screenshot, it appears that despite the fact that the tooltip is set to show on yesterday, today and tomorrow, the only day that it actually renders the custom content is on yesterday, in the first of the three displayed views of the calendar.

    Any thoughts as to why this would happen? I think that this is likely the cause of the issue for me though, so we are getting closer!

    Here is the content page:

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="mike.aspx.vb" Inherits="mike" %>
     
    <!DOCTYPE html>
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <telerik:RadScriptManager runat="server" ID="RadScriptManager1">
                </telerik:RadScriptManager>
                <telerik:RadCalendar ID="datCMSReport" runat="server" EnableWeekends="True" FastNavigationNextText="&lt;&lt;" SelectedDate="" MultiViewColumns="3" AutoPostBack="false" CssClass="RadCalendarMultiView RadCalendarMultiView_Default">
                    <SpecialDays>
                        <telerik:RadCalendarDay Date="" Repeatable="Today">
                            <ItemStyle CssClass="rcToday" />
                        </telerik:RadCalendarDay>
                    </SpecialDays>
                    <WeekendDayStyle CssClass="rcWeekend" />
                    <CalendarTableStyle CssClass="rcMainTable" />
                    <OtherMonthDayStyle CssClass="rcOtherMonth" />
                    <OutOfRangeDayStyle CssClass="rcOutOfRange" />
                    <DisabledDayStyle CssClass="rcDisabled" />
                    <SelectedDayStyle CssClass="rcSelected" />
                    <DayOverStyle CssClass="rcHover" />
                    <FastNavigationStyle CssClass="RadCalendarMonthView RadCalendarMonthView_Default" />
                    <ViewSelectorStyle CssClass="rcViewSel" />
                </telerik:RadCalendar>
     
                <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server"
                    Width="250px" Height="300px"
                    RelativeTo="Element"
                    OffsetX="15"
                    OnAjaxUpdate="RadToolTipManager1_AjaxUpdate">
                </telerik:RadToolTipManager>
            </div>
        </form>
    </body>
    </html>


    and here is the code behind:

    Imports Telerik.Web.UI
     
    Partial Class mike
        Inherits System.Web.UI.Page
     
        'Constants...
        Private Const pc_strRelevantBackgroundCellColor As String = "#CCFFCC"
     
        Private Sub datCMSReport_DayRender(sender As Object, e As Telerik.Web.UI.Calendar.DayRenderEventArgs) Handles datCMSReport.DayRender
            If e.Day.Date = DateTime.Today OrElse e.Day.Date = DateTime.Today.AddDays(-1) OrElse e.Day.Date = DateTime.Today.AddDays(1) Then
                Dim cell As TableCell = e.Cell
                cell.CssClass = "rcSelected"
                cell.Attributes.Add("id", "Calendar1_" & ID.ToString())
     
                RadToolTipManager1.TargetControls.Add(e.Cell.Attributes("id"), ID.ToString(), True)
            End If
        End Sub
     
        Protected Sub RadToolTipManager1_AjaxUpdate(sender As Object, e As ToolTipUpdateEventArgs)
            Dim details As UserControl = TryCast(Me.LoadControl("CustomToolTip.ascx"), UserControl)
     
            e.UpdatePanel.ContentTemplateContainer.Controls.Add(details)
        End Sub
     
    End Class

  6. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 01 Apr 2015 Link to this post

    Hi Mike,

    In this scenario you need to use JavaScript to open the tooltip on the client. Try to modify the code like illustrated below and see how it works.

    DateRender handler:

    Protected Sub RadCalendar1_DayRender(sender As Object, e As Telerik.Web.UI.Calendar.DayRenderEventArgs)
        If e.Day.Date = DateTime.Today OrElse e.Day.Date = DateTime.Today.AddDays(-1) OrElse e.Day.Date = DateTime.Today.AddDays(1) Then
            Dim cell As TableCell = e.Cell
     
            cell.Attributes.Add("onmouseover", "showToolTip(this, event);")
     
            cell.Attributes.Add("id", "Calendar1_" & ID.ToString())
            cell.CssClass = "rcSelected"
     
        End If
     
    End Sub


    JavaScript:


    function showToolTip(sender, args) {
         
        var tooltipManager = $find("<%= RadToolTipManager1.ClientID %>");
     
        //If the user hovers the image before the page has loaded, there is no manager created
        if (!tooltipManager) return;
     
        //Find the tooltip for this element if it has been created
        var tooltip = tooltipManager.getToolTipByElement(sender);
     
        //Create a tooltip if no tooltip exists for such element
        if (!tooltip) {
            tooltip = tooltipManager.createToolTip(sender);
            var longValue = sender.getAttribute("ID");
            var neededValue = longValue.substring(longValue.indexOf('_') + 1)
            tooltip.set_value(neededValue);
            setTimeout(function () {
                tooltip.show();
            }, 10);
        }
    }


    Regards,
    Viktor Tachev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  7. Tayonee
    Tayonee avatar
    52 posts
    Member since:
    Nov 2006

    Posted 06 Apr 2015 in reply to Viktor Tachev Link to this post

    Hi Viktor,

    Well, I managed to get the code working in the sample app you provided but when I copy the code over to the real page I am running into an exception that says: "The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)."

    I am actually running this control on a nested master page. I put the Jacascript code in one of the body content placeholders (actually the only one). Some quick searches seem to indicate that the RadScriptBlock may need to be moved to a HEAD content placeholder. I haven't found eactly how to do that on a nested master page (the top level master exposes the HEAD tag, but not the second level one).

    I just wanted to make sure that I am barking up the right tree here. Is there some other method I should be trying?

  8. Tayonee
    Tayonee avatar
    52 posts
    Member since:
    Nov 2006

    Posted 06 Apr 2015 Link to this post

    Hi Viktor,

     I managed to get that code block moved to the HEAD content placeholder, and the error is no longer happening. I also found that hovering the mouse over one of the "populated" days, the Ajax Update event DOES fire, but for some reason the event data no longer seems to contain the date that was hovered over, which I need to populate data in the tooltip.

    Here is my Ajax Update code:

     

    Private Sub RadToolTipManager2_AjaxUpdate(sender As Object, e As ToolTipUpdateEventArgs) Handles RadToolTipManager1.AjaxUpdate
        'Create a reference to the child control that will be oaded dynamically.
        Dim ctlTimeForTheDay As TimeForDay = DirectCast(Me.LoadControl("~/protected/billing/cms/controls/TimeForDay.ascx"), TimeForDay)
     
        'Set the control properties.
        ctlTimeForTheDay.ID = "ctlTimeForDay"
        ctlTimeForTheDay.TargetDate = DateTime.Parse(e.Value)
     
        'Add the control to the collection.
        e.UpdatePanel.ContentTemplateContainer.Controls.Add(ctlTimeForTheDay)
    End Sub

    Can you see why I would lose the date data? The actual debugging info is attached. It shows the current value of the event as "__Page"????

     Thanks for your continued support!

  9. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 07 Apr 2015 Link to this post

    Hi Mike,

    The error you describe is usually observed when a JavaScript code contains server code blocks (<%...%>). In order to resolve the error you need to wrap the JavaScript in a RadScriptBlock. If you would like additional information on RadScriptBlock you would find the following article interesting.

    Regarding your other query. Note that the e.Value property depends on the value that is passed to the tooltip via the set_value() client-side method. In the Current implementation the string "__Page" is passed.

    In order to change the behavior you can modify the DayRender handler for RadCalendar. Check out the following code snippet as illustration.

    Protected Sub RadCalendar1_DayRender(sender As Object, e As Telerik.Web.UI.Calendar.DayRenderEventArgs)
        Dim currentDate As DateTime = e.Day.Date
     
        If e.Day.Date = DateTime.Today OrElse e.Day.Date = DateTime.Today.AddDays(-1) OrElse e.Day.Date = DateTime.Today.AddDays(1) Then
            Dim cell As TableCell = e.Cell
     
            cell.Attributes.Add("onmouseover", "showToolTip(this, event);")
            cell.Attributes.Add("id", "Calendar1_" & currentDate.ToString())
            cell.CssClass = "rcSelected"
     
     
            RadToolTipManager1.TargetControls.Add(e.Cell.Attributes("id"), currentDate.ToString(), True)
        End If
     
    End Sub


    In addition I am attaching the previous sample with modifications. Give it a try and see how it works for you.


    Regards,
    Viktor Tachev
    Telerik
     

    See What's Next in App Development. Register for TelerikNEXT.

     
  10. Tayonee
    Tayonee avatar
    52 posts
    Member since:
    Nov 2006

    Posted 18 Apr 2015 in reply to Viktor Tachev Link to this post

    Well, it looks like that did the trick - everything is working just fine now, thank you Viktor!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017