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

Timeline view not starting at configured date

6 Answers 104 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Gavin
Top achievements
Rank 1
Gavin asked on 22 Jan 2014, 11:40 PM
Hi,

I have configured a scheduler in timeline view to start at 7am and have 39 20min slots, however when the page first loads the timeline view starts strange times (usually based loosely around the number of minutes ) and only corrects after reloading of the page.
I have attached the before and after screen shots.

Here is the aspx scheduler configuration.

<telerik:RadScheduler ID="rsAppointments" runat="server"
                DataEndField="AppointmentEndDate"
                DataKeyField="ID"
                DataStartField="AppointmentStartDate"
                DataSubjectField="AppointmentTypeID"
                DataDescriptionField="AppointmentTypeID"
                Height="600px"
                onnavigationcomplete="rsAppointments_NavigationComplete"
                OnClientAppointmentInserting="OnInsertAppointment"
                OnClientAppointmentEditing="OnEditAppointment"
                OnClientAppointmentContextMenuItemClicked="OnAppointmentMenuClicked"
                OnClientAppointmentContextMenu="OnAppointmentMenu"
                OnClientTimeSlotContextMenuItemClicked="OnTimeslotMenuClicked"
                GroupingDirection="Vertical" SelectedView="TimelineView"
                DayEndTime="20:00:00"
                DayStartTime="07:00:00"
                WorkDayEndTime="20:00:00"
                WorkDayStartTime="07:00:00"
                onappointmentcreated="rsAppointments_AppointmentCreated"
                onappointmentupdate="rsAppointments_AppointmentUpdate"
                onappointmentdelete="rsAppointments_AppointmentDelete">
                <WeekView UserSelectable="False" />
                <DayView UserSelectable="False" />
                <MonthView UserSelectable="False" />
                <TimelineView GroupBy="Resources" GroupingDirection="Vertical" UserSelectable="false"
                    NumberOfSlots="39" StartTime="07:00:00" ShowResourceHeaders="true" EnableExactTimeRendering="true"
                    ColumnHeaderDateFormat="HH:mm" SlotDuration="00:20:00" ShowInsertArea="false" />
                <ResourceTypes>
                    <telerik:ResourceType Name="Resources" KeyField="AppointmentResourceID" TextField="AppointmentResource" ForeignKeyField="AppointmentResourceID" />
                </ResourceTypes>
                <AppointmentTemplate>
                    <table border="0" cellpadding="3" cellspacing="0" width="100%">
                        <tr>
                            <td style="border: none;"><asp:Literal ID="litContent" runat="server"></asp:Literal></td>
                        </tr>
                    </table>
                </AppointmentTemplate>
                <AppointmentContextMenus>
                    <telerik:RadSchedulerContextMenu runat="server" ID="cmAppointment">
                        <Items>
                            <telerik:RadMenuItem Text="Open" Value="CommandEdit" />
                            <telerik:RadMenuItem IsSeparator="True" />
                            <telerik:RadMenuItem Text="Delete" Value="CommandDelete" />
                            <telerik:RadMenuItem IsSeparator="True" />
                            <telerik:RadMenuItem Text="Attended" Value="Attended" />
                            <telerik:RadMenuItem Text="Cancel" Value="Cancel" />
                            <telerik:RadMenuItem IsSeparator="True" />
                            <telerik:RadMenuItem Text="Go to Record Summary" Value="PatientRecord"></telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Go to Demographics" Value="Patient"></telerik:RadMenuItem>
                        </Items>
                    </telerik:RadSchedulerContextMenu>
                </AppointmentContextMenus>
                <TimelineView HeaderDateFormat="dddd, dd MMMM yyyy" />             
                <TimeSlotContextMenus>
                    <telerik:RadSchedulerContextMenu runat="server" ID="cmTimeSlot">
                        <Items>
                            <telerik:RadMenuItem Text="New Appointment" Value="CommandAddAppointment"></telerik:RadMenuItem>
                            <telerik:RadMenuItem IsSeparator="true" />
                            <telerik:RadMenuItem Text="Go to today" Value="CommandGoToToday" />
                        </Items>
                    </telerik:RadSchedulerContextMenu>
                </TimeSlotContextMenus>
                <TimeSlotContextMenuSettings />
            </telerik:RadScheduler>

We are using 2013 Q1 of the Telerik controls.

Thanks
Gavin.

6 Answers, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 27 Jan 2014, 04:30 PM
Hello Gavin,

Please find attached a sample project that implements the described scenario: 39 time slots that has 20 minutes duration. As you can notice when you run the project it shows the time line view as expected. Please list the steps needed to replicate the issue you are facing in order to investigate this problem.


Regards,
Boyan Dimitrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Gavin
Top achievements
Rank 1
answered on 27 Jan 2014, 11:27 PM
Hi Boyan,

Steps to reproduce are as follows...

1. Rebuild the application
2. Run and navigate to the page
3. Time will now be incorrect.
4. Select a different date (not today)
5. Time is now correct and will stay correct from then on.

Running your sample works.  Main difference I can see are that I am working from a database driven scheduler and you are working from an XML driven one (don't know if that would make a difference).

I have attached the source for the page and the data class I use to bind the grid.

<%@ Page Title="" Language="C#" MasterPageFile="~/Clinician.Master" AutoEventWireup="true" CodeBehind="ResourceAppointments.aspx.cs" Inherits="Episoft.Clinician.Appointments.ResourceAppointments" Theme="Clinician" %>
 
<%@ Register Src="~/Appointments/AppointmentTabs.ascx" TagPrefix="uc1" TagName="AppointmentTabs" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
 
    <script type="text/javascript">
        var lastArgs = null;
        var lastContext = null;
        var longTouchID = 0;
        var menuShown = false;
 
        function LoadPage()
        {
            SetContentWidth();
            var scheduler = $find('<%= rsAppointments.ClientID %>');
            // set the scheduler height to page height
            var sh = GetHeight() - 154;
            scheduler._element.style.height = sh + 'px';
            scheduler.repaint();
            var ch = GetHeight() - 440;
            $find("<%= lstSites.ClientID %>")._element.style.height = ch + 'px';
            scheduler.repaint();
            if ($telerik.isMobileSafari)
            {
                var scrollArea = $('.rsContent')[0];
                scrollArea.addEventListener('touchstart', handleTouchStart, false);
                scrollArea.addEventListener('touchend', handleTouchEnd, false);
            }
        }
 
        function longTouch()
        {
            longTouchID = 0;
            menuShown = true;
 
            var scheduler = $find('<%= rsAppointments.ClientID %>');
            var eventArgs = null;
            var target = null;
 
            if (lastContext.target.nodeName == 'TD')
            {
                target = scheduler._activeModel.getTimeSlotFromDomElement(lastContext.target);
                eventArgs = new Telerik.Web.UI.SchedulerTimeSlotContextMenuEventArgs(target.get_startTime(), target.get_isAllDay(), lastContext, target);
                scheduler._raiseTimeSlotContextMenu(eventArgs);
            } else
            {
                target = scheduler.getAppointmentFromDomElement(lastContext.target);
                eventArgs = new Telerik.Web.UI.SchedulerAppointmentContextMenuEventArgs(target, lastContext);
                scheduler._raiseAppointmentContextMenu(eventArgs);
            }
        }
 
        function handleTouchStart(e)
        {
            lastContext = e;
            lastContext.target = e.originalTarget;
            lastContext.pageX = e.targetTouches[0].pageX;
            lastContext.pageY = e.targetTouches[0].pageY;
            lastContext.clientX = e.targetTouches[0].clientX;
            lastContext.clientY = e.targetTouches[0].clientY;
            longTouchID = setTimeout(longTouch, 1000);
        }
 
        function handleClick(e)
        {
            if (menuShown)
            {
                menuShown = false;
                document.body.removeEventListener('click', handleClick, true);
                e.stopPropagation();
                e.preventDefault();
            }
        }
 
        function handleTouchEnd(e)
        {
            if (longTouchID != 0)
                clearTimeout(longTouchID);
 
            if (menuShown)
            {
                document.body.addEventListener('click', handleClick, true);
                e.preventDefault();
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpWizard" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cpContent" runat="server">
    <uc1:AppointmentTabs runat="server" id="ucAppointmentTabs" />
    <div id="AppointmentContent">
        <div class="Left">
            <telerik:RadCalendar ID="rcDate" Runat="server"
                CultureInfo="English (Australia)" EnableMultiSelect="False" SelectedDate=""
                ViewSelectorText="x" AutoPostBack="True"
                onselectionchanged="rcDate_SelectionChanged">
                <DayOverStyle CssClass="rcHover"></DayOverStyle>
                <FastNavigationStyle CssClass="RadCalendarMonthView RadCalendarMonthView_Default"></FastNavigationStyle>
                <DisabledDayStyle CssClass="rcDisabled"></DisabledDayStyle>
                <WeekendDayStyle CssClass="rcWeekend"></WeekendDayStyle>
                <ViewSelectorStyle CssClass="rcViewSel"></ViewSelectorStyle>
                <SelectedDayStyle CssClass="rcSelected"></SelectedDayStyle>
                <CalendarTableStyle CssClass="rcMainTable"></CalendarTableStyle>
                <OtherMonthDayStyle CssClass="rcOtherMonth"></OtherMonthDayStyle>
                <SpecialDays>
                    <telerik:RadCalendarDay Date="" Repeatable="Today">
                        <ItemStyle CssClass="rcToday" />
                    </telerik:RadCalendarDay>
                </SpecialDays>
                <OutOfRangeDayStyle CssClass="rcOutOfRange"></OutOfRangeDayStyle>
            </telerik:RadCalendar>
            <div id="AdditionalIdentifiers" class="FormSection" style="width: 220px;">
                <a href="javascript:;">Locations</a>
            </div>
            <telerik:RadListBox ID="lstSites" runat="server" CheckBoxes="false"
                Height="350px" Width="220px" SelectionMode="Single" DataValueField="SiteID"
                DataKeyField="SiteID" DataTextField="SiteName" AutoPostBack="True" OnSelectedIndexChanged="lstSites_SelectedIndexChanged">
            </telerik:RadListBox>
            <div id="Filter" class="FormSection" style="width: 220px;">
                <a href="javascript:;">Filter</a>
            </div>
            <div style="width: 220px;">
                <asp:CheckBox ID="chkShowCanceled" runat="server"
                    Text="Show Cancelled Appointments" AutoPostBack="True"
                    oncheckedchanged="chkShowCanceled_CheckedChanged" /><br />
                <asp:CheckBox ID="chkShowArchive" runat="server"
                    Text="Show Archived Appointments" AutoPostBack="True"
                    oncheckedchanged="chkShowArchive_CheckedChanged" />
            </div>
        </div>
         
        <div class="Right">
            <telerik:RadScheduler ID="rsAppointments" runat="server"
                DataEndField="AppointmentEndDate"
                DataKeyField="ID"
                DataStartField="AppointmentStartDate"
                DataSubjectField="AppointmentTypeID"
                DataDescriptionField="AppointmentTypeID"
                Height="600px"
                onnavigationcomplete="rsAppointments_NavigationComplete"
                OnClientAppointmentInserting="OnInsertAppointment"
                OnClientAppointmentEditing="OnEditAppointment"
                OnClientAppointmentContextMenuItemClicked="OnAppointmentMenuClicked"
                OnClientAppointmentContextMenu="OnAppointmentMenu"
                OnClientTimeSlotContextMenuItemClicked="OnTimeslotMenuClicked"
                GroupingDirection="Vertical" SelectedView="TimelineView"
                DayEndTime="20:00:00"
                DayStartTime="07:00:00"
                WorkDayEndTime="20:00:00"
                WorkDayStartTime="07:00:00"
                onappointmentcreated="rsAppointments_AppointmentCreated"
                onappointmentupdate="rsAppointments_AppointmentUpdate"
                onappointmentdelete="rsAppointments_AppointmentDelete">
                <WeekView UserSelectable="False" />
                <DayView UserSelectable="False" />
                <MonthView UserSelectable="False" />
                <TimelineView GroupBy="Resources" GroupingDirection="Vertical" UserSelectable="false"
                    NumberOfSlots="39" StartTime="07:00:00" ShowResourceHeaders="true" EnableExactTimeRendering="true"
                    ColumnHeaderDateFormat="HH:mm" SlotDuration="00:20:00" ShowInsertArea="false" />
                <ResourceTypes>
                    <telerik:ResourceType Name="Resources" KeyField="AppointmentResourceID" TextField="AppointmentResource" ForeignKeyField="AppointmentResourceID" />
                </ResourceTypes>
                <AppointmentTemplate>
                    <table border="0" cellpadding="3" cellspacing="0" width="100%">
                        <tr>
                            <td style="border: none;"><asp:Literal ID="litContent" runat="server"></asp:Literal></td>
                        </tr>
                    </table>
                </AppointmentTemplate>
                <AppointmentContextMenus>
                    <telerik:RadSchedulerContextMenu runat="server" ID="cmAppointment">
                        <Items>
                            <telerik:RadMenuItem Text="Open" Value="CommandEdit" />
                            <telerik:RadMenuItem IsSeparator="True" />
                            <telerik:RadMenuItem Text="Delete" Value="CommandDelete" />
                            <telerik:RadMenuItem IsSeparator="True" />
                            <telerik:RadMenuItem Text="Attended" Value="Attended" />
                            <telerik:RadMenuItem Text="Cancel" Value="Cancel" />
                            <telerik:RadMenuItem IsSeparator="True" />
                            <telerik:RadMenuItem Text="Go to Record Summary" Value="PatientRecord"></telerik:RadMenuItem>
                            <telerik:RadMenuItem Text="Go to Demographics" Value="Patient"></telerik:RadMenuItem>
                        </Items>
                    </telerik:RadSchedulerContextMenu>
                </AppointmentContextMenus>
                <TimelineView HeaderDateFormat="dddd, dd MMMM yyyy" />             
                <TimeSlotContextMenus>
                    <telerik:RadSchedulerContextMenu runat="server" ID="cmTimeSlot">
                        <Items>
                            <telerik:RadMenuItem Text="New Appointment" Value="CommandAddAppointment"></telerik:RadMenuItem>
                            <telerik:RadMenuItem IsSeparator="true" />
                            <telerik:RadMenuItem Text="Go to today" Value="CommandGoToToday" />
                        </Items>
                    </telerik:RadSchedulerContextMenu>
                </TimeSlotContextMenus>
                <TimeSlotContextMenuSettings />
            </telerik:RadScheduler>
        </div>
        <div class="Clear"></div>
    </div>
    <telerik:RadWindowManager ID="rwmMain" runat="server">
        <Windows>
            <telerik:RadWindow ID="rwAppointment" runat="server"
                Behavior="Close"
                Behaviors="Close"
                KeepInScreenBounds="True"
                Modal="True"
                Width="700px"
                Height="650px"
                ShowContentDuringLoad="False"
                style="display:none;"
                VisibleStatusbar="False"
                OnClientClose="OnAppointmentClose">
            </telerik:RadWindow>
            <telerik:RadWindow ID="rwCancelAppointment" runat="server"
                Behavior="Close"
                Behaviors="Close"
                KeepInScreenBounds="True"
                Modal="True"
                Width="400px"
                height="150px"
                ShowContentDuringLoad="False"
                style="display:none;"
                VisibleStatusbar="False"
                OnClientClose="OnCancelAppointmentClose">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
 
    <script type="text/javascript">
        function OnInsertAppointment(sender, args)
        {
            var slot = args.get_targetSlot();
            var res = slot.get_resource();
            var resourceID = res.get_key();
            var dteStart = slot.get_startTime();
            var oManager = GetRadWindowManager();
            var oWnd = oManager.getWindowByName("rwAppointment");
            var URL = "AppointmentEdit.aspx?mode=insert&IsResource=1" +
                                "&start=" + dteStart.toString("dd/MM/yyyy HH:mm:ss tt") +
                                "&siteid=<%= SelectedSiteID %>" +
                                "&rID=" + resourceID;
            oWnd.setUrl(URL);
            oWnd.show();
            args.set_cancel(true);
        }
 
        function OnEditAppointment(sender, args)
        {
            var apt = args.get_appointment()
            var vals = apt.get_description().split('~');
            EditAppointment(vals[0], vals[1]);
            args.set_cancel(true);
        }
 
        function EditAppointment(id, type)
        {
            var oManager = GetRadWindowManager();
            var oWnd = oManager.getWindowByName("rwAppointment");
            var URL = "";
            URL = "AppointmentEdit.aspx?mode=edit&IsResource=1&id=" + id + "&type=" + type;
            oWnd.setUrl(URL);
            oWnd.show();
        }
 
        function OnAppointmentClose(sender, args)
        {
            var val = args.get_argument();
            if (val == "1")
            {
                __doPostBack("REFRESH_PAGE", "");
            }
        }
 
        function OnCancelAppointmentClose(sender, args)
        {
            var val = args.get_argument();
            if (val == "1")
            {
                __doPostBack("REFRESH_PAGE", "");
            }
        }
 
        function OnAppointmentMenuClicked(sender, args)
        {
            var itm = args.get_item();
            var apt = args.get_appointment();
            var vals = apt.get_description().split('~');
            if (itm.get_value() == "PatientRecord")
            {
                __doPostBack("GOTO_PATIENT_RECORD", vals[0]);
            }
            else if (itm.get_value() == "Patient")
            {
                __doPostBack("GOTO_PATIENT", vals[0]);
            }
            else if (itm.get_value() == "Attended")
            {
                __doPostBack("APPOINTMENT_ATTENDED", vals[0] + '~' + vals[1]);
            }
            else if (itm.get_value() == "Cancel")
            {
                var oManager = GetRadWindowManager();
                var oWnd = oManager.getWindowByName("rwCancelAppointment");
                var URL = "CancelAppointment.aspx?id=" + vals[0];
                oWnd.setUrl(URL);
                oWnd.show();
            }
        }
 
        function OnTimeslotMenuClicked(sender, args)
        {
 
        }
 
        function OnAppointmentMenu(sender, args)
        {
            var menu = $find("<%= cmAppointment.ClientID %>");
            selectedAppointment = args.get_appointment();
            var vals = selectedAppointment.get_description().split('~');
             
            menu.findItemByValue("PatientRecord").set_visible(true);
            menu.findItemByValue("Patient").set_visible(true);
            menu.findItemByValue("CommandDelete").set_visible(true);
            menu.findItemByValue("CommandDelete").set_text("Delete");
            menu.findItemByValue("Attended").set_visible(true);
            menu.findItemByValue("Cancel").set_visible(true);
 
            if (vals[2] == "true")
            {
                $.ajax({
                    type: "POST",
                    url: "../AjaxRequest.svc/AllowAppointmentAttended",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data: '{"PatientAppointmentID":' + vals[0] + '}',
                    success: function (msg)
                    {
                        if (msg.d)
                        {
                            menu.findItemByValue("Attended").set_enabled(true);
                        }
                        else
                        {
                            menu.findItemByValue("Attended").set_enabled(false);
                        }
                    }
                });
 
                $.ajax({
                    type: "POST",
                    url: "../AjaxRequest.svc/AllowAppointmentDeleted",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data: '{"PatientAppointmentID":' + vals[0] + '}',
                    success: function (msg) {
                        if (msg.d) {
                            menu.findItemByValue("CommandDelete").set_enabled(true);
                        }
                        else {
                            menu.findItemByValue("CommandDelete").set_enabled(false);
                        }
                    }
                });
 
                $.ajax({
                    type: "POST",
                    url: "../AjaxRequest.svc/AllowAppointmentCancel",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    data: '{"PatientAppointmentID":' + vals[0] + '}',
                    success: function (msg)
                    {
                        if (msg.d == 1)
                        {
                            menu.findItemByValue("Cancel").set_enabled(false);
                            menu.findItemByValue("Cancel").set_text('Cancel');
                        }
                        else if (msg.d == 2)
                        {
                            menu.findItemByValue("Cancel").set_text('Change Reason or Reactivate');
                        }
                        else
                        {
                            menu.findItemByValue("Cancel").set_text('Cancel');
                        }
                    }
                });
            }
            else
            {
                menu.findItemByValue("CommandDelete").set_enabled(false);
                menu.findItemByValue("Attended").set_enabled(false);
                menu.findItemByValue("Cancel").set_enabled(false);
            }
 
            menu.show(args.get_domEvent());
        }
    </script>
</asp:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
 
namespace Episoft.Clinician.Appointments
{
    public partial class ResourceAppointments : System.Web.UI.Page
    {
        protected List<Data.Appointment.vPatientAppointments> _Appointments
        {
            get
            {
                return (List<Data.Appointment.vPatientAppointments>)Session["RESOURCE_APPOINTMENTS"];
            }
            set
            {
                Session["RESOURCE_APPOINTMENTS"] = value;
            }
        }
 
        protected List<Data.Appointment.lAppointmentResource> _Resources
        {
            get
            {
                return (List<Data.Appointment.lAppointmentResource>)Session["RESOURCES"];
            }
            set
            {
                Session["RESOURCES"] = value;
            }
        }
 
        protected int SelectedSiteID
        {
            get
            {
                if (ViewState["SelectedSiteID"] == null)
                {
                    ViewState["SelectedSiteID"] = -1;
                }
                return (int)ViewState["SelectedSiteID"];
            }
            set
            {
                ViewState["SelectedSiteID"] = value;
            }
        }
 
        protected DateTime _SelectedDateResource
        {
            get
            {
                if (Session["SELECTED_DATE_RESOURCE"] != null)
                {
                    return (DateTime)Session["SELECTED_DATE_RESOURCE"];
                }
                else
                {
                    return DateTime.Now;
                }
            }
            set
            {
                Session["SELECTED_DATE_RESOURCE"] = value;
            }
        }
 
        protected DateTime _SelectedDateClinician
        {
            get
            {
                if (Session["SELECTED_DATE_CLINICIAN"] != null)
                {
                    return (DateTime)Session["SELECTED_DATE_CLINICIAN"];
                }
                else
                {
                    return DateTime.Now;
                }
            }          
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            ((Clinician)Page.Master).PageLoadJavaScript += "LoadPage();";
            if (!IsPostBack)
            {
                if (Logic.Helper.SecurityHelper.IsAuthenticated)
                {
                    ((Clinician)Page.Master).PageHeading = "Appointments";
                    ((Clinician)Page.Master).SetSelectedMenuItem(Logic.SystemSettings.MenuItem.Appointments);
                    InitPage();
                }
            }
            else if (Logic.Helper.SecurityHelper.IsAuthenticated)
            {
                if (Request.Form["__EVENTTARGET"] == "REFRESH_PAGE")
                {
                    LoadResources();
                    LoadAppointments(false);
                    rsAppointments.Rebind();
                }
                else if (Request.Form["__EVENTTARGET"] == "APPOINTMENT_ATTENDED")
                {
                    // GET APPOINTMENT ID
                    // run attended code
                    string[] args = Request.Form["__EVENTARGUMENT"].Split('~');
                    int id = int.Parse(args[0]);
                    int aptType = int.Parse(args[1]);
                    Episoft.Logic.Appointment.AppointmentControler obj = new Logic.Appointment.AppointmentControler();
                    if (aptType == 1)
                    {
                        int visit_id = obj.PatientAppointmentAttended(id, Logic.Helper.SecurityHelper.AuthenticatedUser.UserID);
                        // get the patient id from the visit
                        Logic.Visit.VisitControler visitObj = new Logic.Visit.VisitControler();
                        Data.Visit.tVisit visit = visitObj.GetVisit(visit_id);
                        Response.Redirect(string.Format("../VisitSummary.aspx?pid={0}&vid={1}", visit.PatientID, visit_id));
                    }
                }
                else if (Request.Form["__EVENTTARGET"] == "GOTO_PATIENT_RECORD")
                {
                    int ApptID = int.Parse(Request.Form["__EVENTARGUMENT"]);
                    Episoft.Logic.Appointment.AppointmentControler obj = new Logic.Appointment.AppointmentControler();
                    Data.Appointment.tPatientAppointment appt = obj.GetPatientAppointment(ApptID);
                    Response.Redirect(string.Format("../PatientHome.aspx?pid={0}", appt.PatientID));
                }
                else if (Request.Form["__EVENTTARGET"] == "GOTO_PATIENT")
                {
                    int ApptID = int.Parse(Request.Form["__EVENTARGUMENT"]);
                    Episoft.Logic.Appointment.AppointmentControler obj = new Logic.Appointment.AppointmentControler();
                    Data.Appointment.tPatientAppointment appt = obj.GetPatientAppointment(ApptID);
                    Response.Redirect(string.Format("../Patient.aspx?pid={0}", appt.PatientID));
                }
            }
            ucAppointmentTabs.BuildTabs(Logic.Appointment.AppointmentTabs.Resource);
            ucAppointmentTabs.OnTabSelected += ucAppointmentTabs_OnTabSelected;
        }
 
        void ucAppointmentTabs_OnTabSelected(object sender, Logic.Common.TabSelectedEvent e)
        {
            switch ((Logic.Appointment.AppointmentTabs)e.TabID)
            {
                case Logic.Appointment.AppointmentTabs.Clinician:
                    Response.Redirect("Appointments.aspx", false);
                    break;
                case Logic.Appointment.AppointmentTabs.Resource:
                    Response.Redirect("ResourceAppointments.aspx", false);
                    break;
            }
        }
 
        private void InitPage()
        {
            rsAppointments.SelectedDate = DateTime.Now.Date;
            LoadSites();
            LoadResources();
            LoadAppointments(true);
        }
 
        private void LoadSites()
        {
            Logic.Lookup.LookupControler obj = new Logic.Lookup.LookupControler();
            lstSites.DataSource = obj.GetSites(Logic.Helper.SecurityHelper.AuthenticatedUser.OrganisationID);
            lstSites.DataBind();
            lstSites.DataSource = null;
            if (Logic.Helper.SecurityHelper.AuthenticatedUser.SiteID.HasValue)
            {
                lstSites.SelectedIndex = lstSites.FindItemIndexByValue(Logic.Helper.SecurityHelper.AuthenticatedUser.SiteID.Value.ToString());
                if (lstSites.SelectedIndex >= 0)
                {
                    lstSites.Items[lstSites.SelectedIndex].Checked = true;
                }
            }
            if (lstSites.SelectedIndex < 0 && lstSites.Items.Count > 0)
            {
                lstSites.Items[0].Selected = true;
                lstSites.Items[0].Checked = true;
            }
            SelectedSiteID = int.Parse(lstSites.SelectedValue);
        }
 
        private void LoadResources()
        {
            Logic.Appointment.AppointmentControler obj = new Logic.Appointment.AppointmentControler();
            _Resources = obj.GetAppointmentResources(Logic.Helper.SecurityHelper.AuthenticatedUser.OrganisationID, int.Parse(lstSites.SelectedValue));
            rsAppointments.ResourceTypes[0].DataSource = _Resources;
        }
 
        private void LoadAppointments(bool FirstLoad)
        {
            Logic.Appointment.AppointmentControler obj = new Logic.Appointment.AppointmentControler();
            _Appointments = obj.GetResourceAppointments(Logic.Helper.SecurityHelper.AuthenticatedUser.OrganisationID, int.Parse(lstSites.SelectedValue), chkShowCanceled.Checked, chkShowArchive.Checked);
 
            rsAppointments.DataSource = _Appointments;
 
            if (FirstLoad)
            {
                rsAppointments.SelectedDate = _SelectedDateClinician;
                rcDate.FocusedDate = _SelectedDateClinician;
                rcDate.SelectedDate = _SelectedDateClinician;
                _SelectedDateResource = _SelectedDateClinician;
            }
            RadCalendarDay day = null;
            rcDate.SpecialDays.Clear();
            bool todayAdded = false;
            // setup special days in the cal to show appointments exist on that day
            foreach (Episoft.Data.Appointment.vPatientAppointments apt in _Appointments)
            {
                day = new RadCalendarDay();
                day.Date = apt.AppointmentStartDate;
                if (apt.AppointmentStartDate.Date == DateTime.Now.Date)
                {
                    day.ItemStyle.CssClass = "rcToday";
                    todayAdded = true;
                }
                day.ItemStyle.Font.Bold = true;
                rcDate.SpecialDays.Add(day);
            }
            if (!todayAdded)
            {
                day = new RadCalendarDay();
                day.Repeatable = Telerik.Web.UI.Calendar.RecurringEvents.Today;
                day.ItemStyle.CssClass = "rcToday";
                rcDate.SpecialDays.Add(day);
            }
        }
 
        protected void rcDate_SelectionChanged(object sender, Telerik.Web.UI.Calendar.SelectedDatesEventArgs e)
        {
            if (e.SelectedDates.Count > 0)
            {
                rsAppointments.SelectedDate = e.SelectedDates[0].Date;
                _SelectedDateResource = e.SelectedDates[0].Date;
            }
        }
 
        protected void rsAppointments_NavigationComplete(object sender, Telerik.Web.UI.SchedulerNavigationCompleteEventArgs e)
        {
            rcDate.FocusedDate = rsAppointments.SelectedDate;
            rcDate.SelectedDate = rsAppointments.SelectedDate;
            _SelectedDateResource = rsAppointments.SelectedDate;
        }
 
        protected void rsAppointments_AppointmentCreated(object sender, Telerik.Web.UI.AppointmentCreatedEventArgs e)
        {
            Data.Appointment.vPatientAppointments data = GetAppointment((Guid)e.Appointment.ID);
            if (data != null && Logic.Helper.SecurityHelper.IsAuthenticated)
            {
                Logic.Appointment.AppointmentControler obj = new Logic.Appointment.AppointmentControler();
                Literal lit = (Literal)e.Container.FindControl("litContent");
                //HyperLink hl = (HyperLink)e.Container.FindControl("hlEdit");
                //CheckBox chk = (CheckBox)e.Container.FindControl("chkAttended");
                if (data.AppointmentTypeID == 1)
                {
                    // individual                  
                    e.Appointment.BackColor = System.Drawing.Color.FromArgb(173, 204, 160);
                    e.Appointment.BorderColor = System.Drawing.Color.FromArgb(66, 149, 57);
                    e.Appointment.BorderStyle = BorderStyle.Solid;
                    e.Appointment.BorderWidth = new Unit(2, UnitType.Pixel);
 
                    if (obj.CanSeeAppointment(data.PatientAppointmentID, Logic.Helper.SecurityHelper.AuthenticatedUser.UserID,
                                             Logic.Helper.SecurityHelper.AuthenticatedUser.OrganisationID,
                                             Logic.Helper.SecurityHelper.AuthenticatedUser.RoleID,
                                             Logic.Helper.SecurityHelper.AuthenticatedUser.CountryID.Value))
                    {
                        e.Appointment.Description = string.Format("{0}~{1}~{2}", data.PatientAppointmentID, data.AppointmentTypeID, "true");
 
                        if (GetPatientContactNumbers(data.PatientID) != "")
                        {
                            lit.Text = string.Format("{0} at {1}", data.PatientName, data.AppointmentStartDate.ToShortTimeString());
                            e.Appointment.ToolTip = string.Format("{0} at {1} - {2} for {3}, {4}, {5}", data.PatientName, data.AppointmentStartDate.ToShortTimeString(), data.AppointmentEndDate.ToShortTimeString(), data.VisitReason, GetPatientContactNumbers(data.PatientID), data.Note);
                        }
                        else
                        {
                            lit.Text = string.Format("{0} at {1}", data.PatientName, data.AppointmentStartDate.ToShortTimeString());
                            e.Appointment.ToolTip = string.Format("{0} at {1} - {2} for {3}, {4}", data.PatientName, data.AppointmentStartDate.ToShortTimeString(), data.AppointmentEndDate.ToShortTimeString(), data.VisitReason, data.Note);
                        }
                        if (data.Attended.HasValue && data.Attended.Value)
                        {
                            e.Appointment.AllowDelete = false;
                            lit.Text = string.Format("<img src=\"../images/SaveTick.png\" style=\"height:16px;\" /> {0}", data.PatientName);
                        }
                        if (obj.AppointmentCreatedInCycle(data.PatientAppointmentID) || obj.AppointmentCreatedInProtocol(data.PatientAppointmentID))
                        {
                            e.Appointment.AllowDelete = false;
                        }
                        //hl.NavigateUrl = string.Format("javascript:EditAppointment(\"{0}\",\"{1}\");", data.PatientAppointmentID, data.AppointmentTypeID);
                        //chk.Attributes.Add("onclick", string.Format("AttendedClicked(this,\"{0}~{1}\");", data.PatientAppointmentID, data.AppointmentTypeID));
                        //if (data.Attended.HasValue)
                        //{
                        //  chk.Enabled = !data.Attended.Value;
                        //  chk.Checked = data.Attended.Value;
                        //}                    
                    }
                    else
                    {
                        e.Appointment.Description = string.Format("{0}~{1}~{2}", data.PatientAppointmentID, data.AppointmentTypeID, "false");
                        e.Appointment.AllowEdit = false;
                        e.Appointment.AllowDelete = false;
 
                        if (data.Attended.HasValue && data.Attended.Value)
                        {
                            lit.Text = string.Format("<img src=\"../images/SaveTick.png\" style=\"height:16px;\" /> {0} Not available", data.PatientName);
                        }
                        else
                        {
                            lit.Text = string.Format("{0} Not available", data.PatientName);
                        }
                    }
                }
 
                if (data.CancelReasonID.HasValue && data.CancelReasonID.Value != -1)
                {
                    e.Appointment.BackColor = System.Drawing.Color.FromArgb(255, 237, 146);
                }
 
                if (data.PatientAppointmentID == -1)
                {
                    e.Appointment.AllowDelete = false;
                    e.Appointment.AllowEdit = false;
                    e.Appointment.BackColor = System.Drawing.Color.FromArgb(226, 225, 224);
                    //hl.Visible = false;
                    //chk.Visible = false;
                }
            }
        }
 
        private Episoft.Data.Appointment.vPatientAppointments GetAppointment(Guid id)
        {
            if (_Appointments != null)
            {
                foreach (Episoft.Data.Appointment.vPatientAppointments a in _Appointments)
                {
                    if (a.ID == id)
                    {
                        return a;
                    }
                }
            }
            return null;
        }
 
        private string GetPatientContactNumbers(int PatientID)
        {
            string res = "";
            Logic.Patient.PatientControler obj = new Logic.Patient.PatientControler();
            Data.Patient.tPatient pat = obj.GetPatient(PatientID);
            string homePhone = Logic.Helper.Crypto.decrypt(pat.HomePhone);
            if (!string.IsNullOrEmpty(homePhone))
            {
                res = string.Format("H: {0}", homePhone);
            }
            string mobilePhone = Logic.Helper.Crypto.decrypt(pat.MobilePhone);
            if (!string.IsNullOrEmpty(mobilePhone))
            {
                if (res == "")
                {
                    res = string.Format("M: {0}", mobilePhone);
                }
                else
                {
                    res += string.Format("; M: {0}", mobilePhone);
                }
            }
            return res;
        }
 
        protected void chkShowCanceled_CheckedChanged(object sender, EventArgs e)
        {
            LoadAppointments(false);
        }
 
        protected void rsAppointments_AppointmentDelete(object sender, Telerik.Web.UI.AppointmentDeleteEventArgs e)
        {
            Episoft.Data.Appointment.vPatientAppointments apt = GetAppointment((Guid)e.Appointment.ID);
            if (apt != null)
            {
                Episoft.Logic.Appointment.AppointmentControler obj = new Logic.Appointment.AppointmentControler();
                if (apt.AppointmentTypeID == 1)
                {
                    obj.DeletePatientAppointment(apt.PatientAppointmentID);
                }
                LoadAppointments(false);
            }
        }
 
        protected void rsAppointments_AppointmentUpdate(object sender, Telerik.Web.UI.AppointmentUpdateEventArgs e)
        {
            Episoft.Data.Appointment.vPatientAppointments data = GetAppointment((Guid)e.ModifiedAppointment.ID);
            if (data != null && Logic.Helper.SecurityHelper.IsAuthenticated)
            {
                Episoft.Logic.Appointment.AppointmentControler obj = new Logic.Appointment.AppointmentControler();
                if (data.AppointmentTypeID == 1)
                {
                    Episoft.Data.Appointment.tPatientAppointment patApt = obj.GetPatientAppointment(data.PatientAppointmentID);
                    patApt.AppointmentStartDate = e.ModifiedAppointment.Start;
                    patApt.AppointmentEndDate = e.ModifiedAppointment.End;
                    if ((int)e.ModifiedAppointment.Resources[0].Key != patApt.AppointmentResourceID)
                    {
                        patApt.AppointmentResourceID = (int)e.ModifiedAppointment.Resources[0].Key;
                    }
                    patApt.ModifiedDate = DateTime.Now;
                    patApt.ModifiedUserID = Logic.Helper.SecurityHelper.AuthenticatedUser.UserID;
                    patApt.ModifiedUserOrganisationID = Logic.Helper.SecurityHelper.AuthenticatedUser.OrganisationID;
                    patApt.ModifiedUserRoleID = Logic.Helper.SecurityHelper.AuthenticatedUser.RoleID;
                    patApt.ModifiedUserSiteID = Logic.Helper.SecurityHelper.AuthenticatedUser.SiteID;
                    obj.SaveAppointment(patApt, false);
                    LoadAppointments(false);
                    rsAppointments.Rebind();
                }
            }
        }
 
        protected void lstSites_SelectedIndexChanged(object sender, EventArgs e)
        {
            LoadResources();
            LoadAppointments(false);
            SelectedSiteID = int.Parse(lstSites.SelectedValue);
        }
 
        protected void chkShowArchive_CheckedChanged(object sender, EventArgs e)
        {
            LoadAppointments(false);
        }
    }
}
using System;
 
namespace Episoft.Data.Appointment
{
    [Serializable]
    public class vPatientAppointments
    {
        private Guid _ID;
        private int _PatientAppointmentID;
        private int _AppointmentTypeID;
        private int _PatientID;
        private string _PatientName;
        private int _ReferralID;
        private DateTime? _ReferralDate;
        private DateTime _AppointmentStartDate;
        private DateTime _AppointmentEndDate;
        private int _VisitReasonID;
        private string _VisitReason;
        private int _VisitTypeID;
        private string _VisitType;
        private int _ClinicianID;
        private string _Clinician;
        private int _ClinicianOrganisationID;
        private int _SiteID;
        private string _SiteName;
        private bool? _Confirmed;
        private bool? _Attended;
        private int? _CancelReasonID;
        private string _CancelReason;
        private int? _VisitID;
        private string _Note;
        private int _CreateUserID;
        private string _CreateUser;
        private int? _AppointmentResourceID;
        private string _AppointmentResource;
        private int? _AppointmentStatusID;
        private string _AppointmentStatus;
 
        public Guid ID
        {
            get { return _ID; }
            set { _ID = value; }
        }
        public int PatientAppointmentID
        {
            get { return _PatientAppointmentID; }
            set { _PatientAppointmentID = value; }
        }
        public int AppointmentTypeID
        {
            get { return _AppointmentTypeID; }
            set { _AppointmentTypeID = value; }
        }
        public int PatientID
        {
            get { return _PatientID; }
            set { _PatientID = value; }
        }
        public string PatientName
        {
            get { return _PatientName; }
            set { _PatientName = value; }
        }
        public int ReferralID
        {
            get { return _ReferralID; }
            set { _ReferralID = value; }
        }
        public DateTime? ReferralDate
        {
            get { return _ReferralDate; }
            set { _ReferralDate = value; }
        }
        public DateTime AppointmentStartDate
        {
            get { return _AppointmentStartDate; }
            set { _AppointmentStartDate = value; }
        }
        public DateTime AppointmentEndDate
        {
            get { return _AppointmentEndDate; }
            set { _AppointmentEndDate = value; }
        }
        public int VisitReasonID
        {
            get { return _VisitReasonID; }
            set { _VisitReasonID = value; }
        }
        public string VisitReason
        {
            get { return _VisitReason; }
            set { _VisitReason = value; }
        }
        public int VisitTypeID
        {
            get { return _VisitTypeID; }
            set { _VisitTypeID = value; }
        }
        public string VisitType
        {
            get { return _VisitType; }
            set { _VisitType = value; }
        }
        public int ClinicianID
        {
            get { return _ClinicianID; }
            set { _ClinicianID = value; }
        }
        public string Clinician
        {
            get { return _Clinician; }
            set { _Clinician = value; }
        }
        public int ClinicianOrganisationID
        {
            get { return _ClinicianOrganisationID; }
            set { _ClinicianOrganisationID = value; }
        }
        public int SiteID
        {
            get { return _SiteID; }
            set { _SiteID = value; }
        }
        public string SiteName
        {
            get { return _SiteName; }
            set { _SiteName = value; }
        }
        public bool? Confirmed
        {
            get { return _Confirmed; }
            set { _Confirmed = value; }
        }
        public bool? Attended
        {
            get { return _Attended; }
            set { _Attended = value; }
        }
        public int? CancelReasonID
        {
            get { return _CancelReasonID; }
            set { _CancelReasonID = value; }
        }
        public string CancelReason
        {
            get { return _CancelReason; }
            set { _CancelReason = value; }
        }
        public int? VisitID
        {
            get { return _VisitID; }
            set { _VisitID = value; }
        }
        public string Note
        {
            get { return _Note; }
            set { _Note = value; }
        }
        public int CreateUserID
        {
            get { return _CreateUserID; }
            set { _CreateUserID = value; }
        }
        public string CreateUser
        {
            get { return _CreateUser; }
            set { _CreateUser = value; }
        }
        public int? AppointmentResourceID
        {
            get { return _AppointmentResourceID; }
            set { _AppointmentResourceID = value; }
        }
        public string AppointmentResource
        {
            get { return _AppointmentResource; }
            set { _AppointmentResource = value; }
        }
        public int? AppointmentStatusID
        {
            get { return _AppointmentStatusID; }
            set { _AppointmentStatusID = value; }
        }
        public string AppointmentStatus
        {
            get { return _AppointmentStatus; }
            set { _AppointmentStatus = value; }
        }
        public override bool Equals(object obj)
        {
            if (obj == null || GetType() != obj.GetType())
            {
                return false;
            }
            else
            {
                return (((vPatientAppointments)obj).ID == this.ID);
            }
        }
        public override int GetHashCode()
        {
            return ID.GetHashCode();
        }
    }
}


Thanks

Gavin.
0
Boyan Dimitrov
Telerik team
answered on 30 Jan 2014, 03:18 PM
Hello Gavin,

I would like to clarify that I was not able to run and inspect the provided project due to some missing custom functionality. Please find attached a very similar project as the one I sent you in my last response with database driven scheduler. Please try to replicate the issue with this project and explain how exactly we can reproduce it. This way we can investigate this behavior thoroughly and find what might cause it.

Regards,
Boyan Dimitrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Gavin
Top achievements
Rank 1
answered on 03 Feb 2014, 11:44 PM
Hi Boyan,

 Here is a VS 2012 solution that replicates the issue, all you need to do is run it.  Please note the Telerik version is 2013.1.220.40.

You can download it from https://staging.episoft.com.au/TestTimelineCal.zip

cheers
Gavin.
0
Accepted
Boyan Dimitrov
Telerik team
answered on 06 Feb 2014, 02:41 PM
Hello,

I would like to clarify that I have run and reproduced the problem. It is due to the fact that when the page is initially loaded it goes through the LoadAppointments method and sets the RadScheduler SelectedDate to _SelectedDateClinician. In this case the DateTime.Now returns not only the current date but the current time as well. Setting the time value conflicts with the time line view start time and cause this behavior. In order to avoid this issue please modify your  _SelectedDateClinician definition as shown in the code snippet below:
//code behind
protected DateTime _SelectedDateClinician
        {
            get
            {
                if (Session["SELECTED_DATE_CLINICIAN"] != null)
                {
                    return (DateTime)Session["SELECTED_DATE_CLINICIAN"];
                }
                else
                {
                    return DateTime.Now.Date;
                }
            }
        }


Just modify return return DateTime.Now to DateTime.Now.Date.


Regards,
Boyan Dimitrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
0
Gavin
Top achievements
Rank 1
answered on 07 Feb 2014, 02:26 AM
Thanks Boyan, looks like it's working now.
Tags
Scheduler
Asked by
Gavin
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Gavin
Top achievements
Rank 1
Share this question
or