Misalignment of Appointments to actual Appointment Time

3 posts, 1 answers
  1. Michael
    Michael avatar
    3 posts
    Member since:
    Jun 2012

    Posted 08 Oct 2014 Link to this post

    Dear Telerik Team

    I have a Problem with the alignments of the appointments in Scheduler in a 3 Month view. The number of slots is assigned in the codebehind and calculated as The total number of days between start and end of the current view in Timeline.

    I made a testproject and a test stored procedure with which I hope you can find my Problem.

    I've attached the the SQLProcedure, with what the issue is visible.

    Stored Procedure:

    Create PROCEDURE [dbo].[sp_TrainingTimelineAppointmentsTest]
          -- Add the parameters for the stored procedure here
         
            
    AS
    BEGIN
          -- SET NOCOUNT ON added to prevent extra result sets from
          -- interfering with SELECT statements.
          SET NOCOUNT ON;
          SET DATEFIRST 1;
         



    DECLARE @OutputTable TABLE 

    --             isOK
      [HelpID] int identity(1,1) PRIMARY KEY,
      [RessourceFK] int,
      [BeginDate] datetime,
      [Enddate] datetime,
      [Description] nvarchar(2048),
      [StatusColor] nvarchar(20),
      [TyperatingID] int,
      [ID] int,
      [CourseID] int,
      [CourseGenID] int,
      [AptIcao] nvarchar(10),
      [Remark] nvarchar(MAX),
      [Status] nvarchar(50),
      [Color] nvarchar(10),
      [Border] nvarchar(10),
      [Relevant] bit,
      [isCrewCourse] bit,
      [isRealCourse] bit,
      [isDeletable] bit,
      [RelatedCheck] int
    )     


    Insert into @OutputTable
     ([RessourceFK],[BeginDate],[Enddate],[Description],[StatusColor],[TyperatingID] ,
      [ID],[CourseID],[CourseGenID],[AptIcao],[Remark],[Status],
      [Color],[Border],[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck] ) 
    Values
    (0, '2014-10-01T09:00:00', '2014-10-01T18:00:00', 'First Course' , '#333333',1, 1, 1, 1,1, 1,'Test1', '#444444', '#000000',1, 0,1,0,0)

    Insert into @OutputTable
     ([RessourceFK],[BeginDate],[Enddate],[Description],[StatusColor],[TyperatingID] ,
      [ID],[CourseID],[CourseGenID],[AptIcao],[Remark],[Status],
      [Color],[Border],[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck] ) 
    Values
    (0, '2014-10-05T09:00:00', '2014-10-05T18:00:00', 'Second Course' , '#333333',1, 2, 2, 1,1, 1,'Test2', '#444444', '#000000',1, 0,1,0,0)

    Insert into @OutputTable
     ([RessourceFK],[BeginDate],[Enddate],[Description],[StatusColor],[TyperatingID] ,
      [ID],[CourseID],[CourseGenID],[AptIcao],[Remark],[Status],
      [Color],[Border],[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck] ) 
    Values
    (0, '2014-10-15T09:00:00', '2014-10-15T18:00:00', 'Third Course' , '#333333',1, 3, 3, 1,1, 1,'Test3', '#444444', '#000000',1, 0,1,0,0)

    Insert into @OutputTable
     ([RessourceFK],[BeginDate],[Enddate],[Description],[StatusColor],[TyperatingID] ,
      [ID],[CourseID],[CourseGenID],[AptIcao],[Remark],[Status],
      [Color],[Border],[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck] ) 
    Values
    (0, '2014-10-18T09:00:00', '2014-10-18T18:00:00', 'Fourth Course' , '#333333',1, 4, 4, 1,1, 1,'Test4', '#444444', '#000000',1, 0,1,0,0)

    Insert into @OutputTable
     ([RessourceFK],[BeginDate],[Enddate],[Description],[StatusColor],[TyperatingID] ,
      [ID],[CourseID],[CourseGenID],[AptIcao],[Remark],[Status],
      [Color],[Border],[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck] ) 
    Values
    (0, '2014-11-02T09:00:00', '2014-11-02T18:00:00', 'Fifth Course' , '#333333',1, 5, 5, 1,1, 1,'Test5', '#444444', '#000000',1, 0,1,0,0)


    Insert into @OutputTable
     ([RessourceFK],[BeginDate],[Enddate],[Description],[StatusColor],[TyperatingID] ,
      [ID],[CourseID],[CourseGenID],[AptIcao],[Remark],[Status],
      [Color],[Border],[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck] ) 
    Values
    (0, '2014-11-09T09:00:00', '2014-11-09T18:00:00', 'Sixth Course' , '#333333',1, 6, 6, 1,1, 1,'Test6', '#444444', '#000000',1, 0,1,0,0)

    Insert into @OutputTable
     ([RessourceFK],[BeginDate],[Enddate],[Description],[StatusColor],[TyperatingID] ,
      [ID],[CourseID],[CourseGenID],[AptIcao],[Remark],[Status],
      [Color],[Border],[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck] ) 
    Values
    (0, '2014-11-11T09:00:00', '2014-11-11T18:00:00', 'Seventh Course' , '#333333',1, 7, 7, 1,1, 1,'Test7', '#444444', '#000000',1, 0,1,0,0)

    Insert into @OutputTable
     ([RessourceFK],[BeginDate],[Enddate],[Description],[StatusColor],[TyperatingID] ,
      [ID],[CourseID],[CourseGenID],[AptIcao],[Remark],[Status],
      [Color],[Border],[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck] ) 
    Values
    (0, '2014-11-18T09:00:00', '2014-11-18T18:00:00', 'Eigth Course' , '#333333',1, 8, 8, 1,1, 1,'Test8', '#444444', '#000000',1, 0,1,0,0)

    Insert into @OutputTable
     ([RessourceFK],[BeginDate],[Enddate],[Description],[StatusColor],[TyperatingID] ,
      [ID],[CourseID],[CourseGenID],[AptIcao],[Remark],[Status],
      [Color],[Border],[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck] ) 
    Values
    (0, '2014-12-03T09:00:00', '2014-12-03T18:00:00', 'Nineth Course' , '#333333',1, 9, 9, 1,1, 1,'Test9', '#444444', '#000000',1, 0,1,0,0)

    Insert into @OutputTable
     ([RessourceFK],[BeginDate],[Enddate],[Description],[StatusColor],[TyperatingID] ,
      [ID],[CourseID],[CourseGenID],[AptIcao],[Remark],[Status],
      [Color],[Border],[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck] ) 
    Values
    (0, '2014-12-06T09:00:00', '2014-12-06T18:00:00', 'Tenth Course' , '#333333',1, 10, 10, 1,1, 1,'Test10', '#444444', '#000000',1, 0,1,0,0)

    Insert into @OutputTable
     ([RessourceFK],[BeginDate],[Enddate],[Description],[StatusColor],[TyperatingID] ,
      [ID],[CourseID],[CourseGenID],[AptIcao],[Remark],[Status],
      [Color],[Border],[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck] ) 
    Values
    (0, '2014-12-12T09:00:00', '2014-12-12T18:00:00', 'Eleventh Course' , '#333333',1, 11, 11, 1,1, 1,'Test11', '#444444', '#000000',1, 0,1,0,0)

                               

    Select CASE WHEN [isRealCourse] = 1 THEN [HelpID] *-1 ELSE HelpID END AS ID ,[RessourceFK] ,[BeginDate] ,[Enddate] ,[Description] ,[StatusColor] ,[TyperatingID] ,[ID] AS RealID ,[CourseID] ,[CourseGenID] , [AptIcao] ,
    [Remark] ,[Status] ,[Color] ,[Border] ,[Relevant] ,[isCrewCourse] ,[isRealCourse],[isDeletable],[RelatedCheck]
      From @OutputTable

    END



    File: Default.aspx.cs


    using System;
    using System.Collections;
    using System.Collections.Specialized;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
    using System.Drawing;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Globalization;
    using Telerik.Web.UI.Scheduler.Views;


    public partial class Training_User_Timeline2 : System.Web.UI.Page
    {
        DateTime m_StartTime
        {
            set
            {
                

                ViewState["Training_User_Timeline_mStartTime"] = value.ToString("s");
            }
            get
            {
                DateTime temp = DateTime.Now.Date;
                if (DateTime.TryParse(ViewState["Training_User_Timeline_mStartTime"].ToString(), out temp))
                {
                    return temp.Date;
                }
                else
                {
                    return DateTime.Now.Date;
                }
            }

        }

        protected void Page_Load(object sender, EventArgs e)
        {



            if (!IsPostBack)
            {
                
                DateTime temp = DateTime.Now;
                
                    m_StartTime = DateTime.Now.Date;
                

                RadSchedulerApplicants.SelectedDate = m_StartTime;
                SetRadSchedulerPeriod(m_StartTime);





                        InitializeResources();


                



            }

            
        }

        private void InitializeResources()
        {
            

                RadSchedulerApplicants.Resources.Clear();
                RadSchedulerApplicants.ResourceTypes.Clear();


                ResourceType resTypeResources = new ResourceType("Resources");
                resTypeResources.ForeignKeyField = "RessourceFK";

                RadSchedulerApplicants.ResourceTypes.Add(resTypeResources);


                using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
                {
                    DataTable dt = null;
                    try
                    {
                        conn.Open();
                        SqlDataAdapter da = new SqlDataAdapter();
                        da.SelectCommand = new SqlCommand(@"
    SELECT DisplayName, RessourceKey FROM (SELECT 'Courses' AS DisplayName, 0 AS RessourceKey, 0 AS help ) AS TEST ORDER BY help, DisplayName", conn);
                        
                        dt = new DataTable();
                        da.Fill(dt);
                        DataRow[] rows = null;
                        
                        rows = dt.Select();

                        foreach (DataRow row in rows)
                        {

                            RadSchedulerApplicants.Resources.Add(new Resource("Resources", (int)row["RessourceKey"], (string)row["DisplayName"]));
                        }

                    }
                    catch (System.Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }

                    if (conn != null)
                        conn.Close();


                    RadSchedulerApplicants.TimelineView.GroupBy = "Resources";
                    RadSchedulerApplicants.DataBind();
                }
            

        }

        protected void DropDownListFilter_SelectedIndexChanged(object sender, EventArgs e)
        {
            //UpdateResources(CrewplanID);
            

        }
        protected void DropDownListCrewPlan_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {

            //CrewplanID = Convert.ToInt32(DropDownListCrewPlan.SelectedValue);

            InitializeResources();
            
        }

        protected void DropDownListInterval_SelectedIndexChanged(object sender, EventArgs e)
        {
            

        }

        private void SetRadSchedulerPeriod(DateTime StartDate)
        {
            
                    RadSchedulerApplicants.TimelineView.NumberOfSlots = (int)(StartDate.AddMonths(3) - StartDate).TotalDays;

                    RadSchedulerApplicants.TimelineView.TimeLabelSpan = 1;
                    //RadSchedulerApplicants.TimelineView.NumberOfSlots = 90;
                    //RadSchedulerCourses.TimelineView.TimeLabelSpan = 1;
                    


        }

        protected void DropDownListNaviInterval_SelectedIndexChanged(object sender, EventArgs e)
        {
            


        }
        protected void RadSchedulerApplicants_NavigationCommand(object sender, SchedulerNavigationCommandEventArgs e)
        {
            e.Cancel = true;
            int direction = 0;

            switch (e.Command)
            {
                case SchedulerNavigationCommand.NavigateToNextPeriod:
                    direction = 1;
                    break;
                case SchedulerNavigationCommand.NavigateToPreviousPeriod:
                    direction = -1;
                    break;
                case SchedulerNavigationCommand.NavigateToSelectedDate:
                case SchedulerNavigationCommand.SwitchToSelectedDay:

                    m_StartTime = e.SelectedDate.Date;


                    RadSchedulerApplicants.SelectedDate = m_StartTime.Date;

                    SetRadSchedulerPeriod(m_StartTime.Date);
                    return;

            }


            
                    m_StartTime = m_StartTime.Date.AddMonths(direction * 1);
                    


            RadSchedulerApplicants.SelectedDate = m_StartTime.Date;

            SetRadSchedulerPeriod(m_StartTime.Date);
        }

        protected void DropDownListCrewPlan_DataBound(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitializeResources();
            }
        }

        protected void SqlDataSourceCourses_Selected(object sender, SqlDataSourceStatusEventArgs e)
        {

            int i = e.AffectedRows;
        }

        #region Telerik Drag and drop Section

        protected void RadSchedulerApplicants_AppointmentInsert(object sender, SchedulerCancelEventArgs e)
        {
            /*e.Appointment.Attributes["BeginDate"] = e.Appointment.Start.AddDays(1).ToString("yyyy/MM/dd HH:mm", CultureInfo.InvariantCulture);
            e.Appointment.Attributes["EndDate"] = e.Appointment.Start.AddDays(2).ToString("yyyy/MM/dd HH:mm", CultureInfo.InvariantCulture);*/
            String test = "test";
        }



        private void HandleSchedulerDrop(int id, string subject, string targetSlotIndex, String targetSlotRessourceID)
        {
            RadSchedulerApplicants.Rebind();

            ISchedulerTimeSlot slot = RadSchedulerApplicants.GetTimeSlotFromIndex(targetSlotIndex);



            TimeSpan duration = TimeSpan.FromHours(1);
            if (slot.Duration == TimeSpan.FromDays(1))
            {
                duration = slot.Duration;
            }

            ScheduleAppointment(id, targetSlotRessourceID);
        }

        protected void RadSchedulerApplicants_AppointmentCommand(object sender, AppointmentCommandEventArgs e)
        {
            if (e.CommandName == "Unschedule")
            {
                if (int.Parse(e.Container.Appointment.Resources[0].Key.ToString()) > 0)
                {
                    int id = int.Parse(e.Container.Appointment.Attributes["RealID"]);
                    int crewid = (int)e.Container.Appointment.Resources[0].Key;

                    DateTime dueDate = DateTime.Now;

                    if (!string.IsNullOrEmpty(e.Container.Appointment.Attributes["BeginDate"]))
                        dueDate = Convert.ToDateTime(e.Container.Appointment.Attributes["BeginDate"]);



                    UnscheduleAppointment(id, crewid);
                    RadSchedulerApplicants.Rebind();
                }
                else
                {
                    int id = int.Parse(e.Container.Appointment.Attributes["RealID"]);
                    DeleteCourse(id);
                }
            }
        }

        private void DeleteCourse(int courseid)
        {
            
            RadSchedulerApplicants.DataBind();
        }

        private void UnscheduleAppointment(int id, int crewid)
        {
            
        }

        private void ScheduleAppointment(int id, String CrewID)
        {
            
        }

        private static bool OnDataSourceOperationComplete(int count, Exception e)
        {
            if (e != null)
            {
                throw e;
            }
            return true;
        }

        

        #endregion Telerik Drag and drop Section

        protected void SqlDataSourceCoursesToPlan_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {
            try
            {
                e.Command.Parameters["@DateFrom"].Value = m_StartTime.ToString("s");
                
                        e.Command.Parameters["@DateTo"].Value = m_StartTime.AddMonths(3).ToString("s");
                        
            }
            catch (Exception ex)
            {
                String test = "";
            }

        }

        protected void SqlDataSourceCoursesToPlan_Selected(object sender, SqlDataSourceStatusEventArgs e)
        {
            int test = e.AffectedRows;
        }

        protected void RadSchedulerApplicants_TimeSlotCreated(object sender, TimeSlotCreatedEventArgs e)
        {
            e.TimeSlot.CssClass = "RadSched_Back";
            if ((e.TimeSlot.End <= DateTime.Now.AddMinutes((e.TimeSlot.End - e.TimeSlot.Start).TotalMinutes)) && (e.TimeSlot.End >= DateTime.Now))
            {
                e.TimeSlot.CssClass = "NowCss";
            }
        }

        protected void RadSchedulerApplicants_AppointmentDataBound(object sender, SchedulerEventArgs e)
        {
            try
            {
                e.Appointment.BackColor = ColorTranslator.FromHtml(e.Appointment.Attributes["StatusColor"]);
                e.Appointment.BorderColor = ColorTranslator.FromHtml(e.Appointment.Attributes["Border"]);
                e.Appointment.AllowEdit = true;
                e.Appointment.AllowDelete = true;
                if (int.Parse(e.Appointment.ID.ToString()) < 0)
                {
                    e.Appointment.ContextMenuID = "RadSchedulerCourseContext";
                }
                else
                {
                    e.Appointment.ContextMenuID = "RadSchedulerOther";
                }





                
                   
                        if (e.Appointment.Duration.TotalHours < 24)
                        {
                            e.Appointment.End = e.Appointment.Start.AddHours(24);
                        }
                        
                e.Appointment.End = e.Appointment.End.AddMinutes(-1);
                e.Appointment.Start = e.Appointment.Start.AddMinutes(1);
            }
            catch (Exception ex)
            {
                String test = "";
            }
        }

        protected void DropDownListInterval_DataBound(object sender, EventArgs e)
        {
            
        }

        protected void RadButtonNewCourse_Click(object sender, EventArgs e)
        {
            RadWindowManager1.DataBind();

            String Script = "OpenRadWindow('NewCourse.aspx?start=" + DateTime.Now.ToString("s") + "')";
            RadAjaxPanel1.ResponseScripts.Add(Script);

        }

        protected void RadButtonApplyFilters_Click(object sender, EventArgs e)
        {
            RadSchedulerApplicants.Rebind();
        }

        protected void SqlDataSourceApplicantCourses_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
        {
            //e.Command.Parameters["@RangeStart"].Value = RadSchedulerApplicants.VisibleRangeStart;
            //e.Command.Parameters["@RangeEnd"].Value = RadSchedulerApplicants.VisibleRangeEnd;
            //e.Command.Parameters["@DutyPlanID"].Value = DropDownListCrewPlan.SelectedValue;
            //e.Command.Parameters["@TypeRatingID"].Value = RadComboBoxFilterTypeRating.SelectedValue;
            //e.Command.Parameters["@CheckId"].Value = RadComboBoxFilterCheck.SelectedValue;
            //if (RadComboBoxFilterExpiration.SelectedValue == "No")
            //{
            //    e.Command.Parameters["@Expiry"].Value = false;
            //}
            //else
            //{
            //    e.Command.Parameters["@Expiry"].Value = true;
            //}
            //if (RadComboBoxFilterPlanned.SelectedValue == "No")
            //{
            //    e.Command.Parameters["@Planned"].Value = false;
            //}
            //else
            //{
            //    e.Command.Parameters["@Planned"].Value = true;
            //}
            //if (RadComboBoxFilterDuties.SelectedValue == "No")
            //{
            //    e.Command.Parameters["@Duties"].Value = false;
            //}
            //else
            //{
            //    e.Command.Parameters["@Duties"].Value = true;
            //}

        }

        protected void RadComboBoxFilterExpiration_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            
        }

        protected void RadComboBoxFilterDuties_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            
        }

        protected void RadComboBoxFilterPlanned_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            
        }

        protected void RadAjaxPanel1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {
            String test = "test";
        }

        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e)
        {

        }

        protected void ButtonScheduleAppointment_Click(object sender, EventArgs e)
        {
            try
            {
                int id = int.Parse(HiddenFieldAppointmentId.Value);
                String CrewId = TargetSlotRessourceHiddenField.Value;
                ScheduleAppointment(id, CrewId);
            }
            catch (Exception ex)
            {

            }
        }

        protected void ButtonRefreshScheduler_Click(object sender, EventArgs e)
        {
            RadSchedulerApplicants.Rebind();
        }

        protected void RadSchedulerApplicants_ResourceHeaderCreated(object sender, ResourceHeaderCreatedEventArgs e)
        {
            Panel tempPanel = (Panel)e.Container.FindControl("HeaderTemplateContainer");
            String TooltipText = "";
            if (int.Parse(e.Container.Resource.Key.ToString()) > 0)
            {
                #region Functions
                TooltipText += "<h2>Functions</h2><table><thead><tr><th>FunctionName</th></tr></thead><tbody>";
                using (SqlConnection conn0 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
                {

                    try
                    {
                        conn0.Open();



                                    TooltipText += "<tr><td>" + "Testdescription" + "</td></tr>";


                    }
                    catch (System.Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                    TooltipText += "</tbody></table><br/>";
                }
                #endregion
                #region Typeratings
                TooltipText += "<h2>Typeratings</h2><table><thead><tr><th>TyperatingName</th></tr></thead><tbody>";
                using (SqlConnection conn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
                {

                    try
                    {


                                    TooltipText += "<tr><td>" + "TestTyperating" + "</td></tr>";


                    }
                    catch (System.Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                    TooltipText += "</tbody></table><br/>";
                }
                #endregion

                #region tooltipChecks
                TooltipText += "<h2>Checks</h2><table><thead><tr><th>Check</th><th>Typerating</th><th>Last planned</th><th>Earliest to perform </th></tr></thead><tbody>";
                using (SqlConnection conn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
                {

                    try
                    {
                        conn2.Open();

                        
      
                                    TooltipText += "<tr><td>" + "testdescription" + "</td><td>" + "testtyperating" + "</td><td>" +  "" + "</td><td>" +  "" + "</td></tr>";


                    }
                    catch (System.Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                    TooltipText += "</tbody></table>";

                }
                #endregion
                RadToolTip tip = new RadToolTip();
                tip.Text = TooltipText;
                tip.IsClientID = true;
                tip.AutoCloseDelay = 15000;
                tip.RelativeTo = ToolTipRelativeDisplay.Element;
                tip.TargetControlID = tempPanel.ClientID;
                tip.Animation = ToolTipAnimation.None;
                tip.Position = ToolTipPosition.TopLeft;
                e.Container.Controls.Add(tip);
            }

            Label ResourceText = new Label();
            ResourceText.Text = e.Container.Resource.Text;
            tempPanel.Controls.Add(ResourceText);
        }

        protected void RadSchedulerApplicants_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)
        {
            String HtmlTooltip = "";
            if (Boolean.Parse(e.Appointment.Attributes["isRealCourse"].ToString()) || Boolean.Parse(e.Appointment.Attributes["isCrewCourse"].ToString()))
            {
                #region Course

                HtmlTooltip = @"<h2>" + e.Appointment.Subject + @"</h2>
    <p>" + String.Format("{0:yyyy-MM-dd HH:mm}", e.Appointment.Start) + " to " + String.Format("{0:yyyy-MM-dd HH:mm}", e.Appointment.End) + "</p>";


                using (SqlConnection conn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
                {

                    try
                    {

                                    HtmlTooltip += "<h2>Typerating: " + "none" + "</h2>";


                    }
                    catch (System.Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }


                }


                HtmlTooltip += "<h2>Checks in Course</h2><table><thead><tr><th>Checkname</th><th>Checkdate</th></tr></thead><tbody>";
                using (SqlConnection conn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
                {

                    try
                    {
                        conn2.Open();



                                    HtmlTooltip += "<tr><td>" + "testdescription" + "</td><td>" + "" + "</td></tr>";


                    }
                    catch (System.Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                    HtmlTooltip += "</tbody></table>";

                }


                HtmlTooltip += "<h2>Crewmembers in Course</h2><table><tbody>";
                using (SqlConnection conn2 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
                {

                    try
                    {
                        conn2.Open();



                                    HtmlTooltip += "<tr><td>" + "Name" + "</td></tr>";


                    }
                    catch (System.Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                    HtmlTooltip += "</tbody></table>";

                }


                #region CheckColors
                String CheckColorDivs = "";
                using (SqlConnection conn4 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
                {

                    try
                    {
                        conn4.Open();

                        
                                int position = 1;
                                
                                    CheckColorDivs += "<div style=\"height:3px;width:100%;border:1px solid black;background-color:" +  "White" + ";position:absolute; left:0px;top:" + position + "px;z-index:1\"></div>";
                                    

                    }
                    catch (System.Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                    if (CheckColorDivs.Length > 0)
                    {
                        LiteralControl litcon = new LiteralControl(CheckColorDivs);
                        ((Panel)e.Container.FindControl("AppointmentContainer")).Controls.Add(litcon);
                    }

                }
                #endregion
                #endregion
            }
            if (e.Appointment.Attributes["RelatedCheck"] != null && int.Parse(e.Appointment.Attributes["RelatedCheck"].ToString()) > 0)
            {
                HtmlTooltip = @"<h2>" + e.Appointment.Subject + @"</h2>
    <p>" + String.Format("{0:yyyy-MM-dd}", e.Appointment.Start) + " to " + String.Format("{0:yyyy-MM-dd}", e.Appointment.End) + "</p>";


                #region CheckColors2
                String CheckColorDivs = "";
                using (SqlConnection conn4 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
                {

                    try
                    {
                        conn4.Open();


                                int position = 1;
                                
                        CheckColorDivs += "<div style=\"height:3px;width:100%;border:1px solid black;background-color:" +  "White" + ";position:absolute; left:0px;top:" + position + "px;z-index:1\"></div>";
                                   

                    }
                    catch (System.Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                    if (CheckColorDivs.Length > 0)
                    {
                        LiteralControl litcon = new LiteralControl(CheckColorDivs);
                        ((Panel)e.Container.FindControl("AppointmentContainer")).Controls.Add(litcon);
                    }

                }
                #endregion
            }

            RadToolTip tip = new RadToolTip();
            tip.Text = HtmlTooltip;
            tip.IsClientID = true;
            tip.AutoCloseDelay = 15000;
            tip.RelativeTo = ToolTipRelativeDisplay.Element;
            tip.TargetControlID = e.Appointment.ClientID;
            tip.Animation = ToolTipAnimation.None;
            tip.Position = ToolTipPosition.TopLeft;
            e.Container.Controls.Add(tip);




            //Panel tempPanel = (Panel)e.Container.FindControl("AppointmentContainer");


        }

        protected void ButtonDeleteCourse_Click(object sender, EventArgs e)
        {
            int CourseID = 0;

            if (int.TryParse(HiddenFieldDeleteCourse.Value, out CourseID))
            {
                DeleteCourse(CourseID);
            }
        }





    }

    File: Default.aspx

    <%@ Page Title="" Language="C#"  AutoEventWireup="True"
        Inherits="Training_User_Timeline2" CodeBehind="Default.aspx.cs" %>

    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <link rel="shortcut icon" href="<%=VirtualPathUtility.ToAbsolute("~/DocumentStorage/ThisCompanyLogo_2.ico")%>" />
    <html xmlns="http://www.w3.org/1999/xhtml">

    <head id="Head1" runat="server">
        
        <link rel="Shortcut Icon" href="" type="image/x-icon" />
        <title>Biz Flight Plus</title>
        <style type="text/css">
             .blockDisplay a
            {
                display: block;
             
            }
        </style>
        
        <style type="text/css">
                    .NowCss
            {
                border-left: 3px solid red !important;
                background-color: White !important;
            }
            
            .RadSched_Back
            {
                background-color: White !important;
            }
            .rsWrap
            {
                margin: 0px 0px 0px 0px !important;
                padding: 0px 0px 0px 0px !important;
            }
            .rsAptContent
            {
                margin: 0px 0px 0px 0px !important;
                padding: 0px 0px 0px 0px !important;
            }
            
            .rsAptDelete
            {
                display: none !important;
            }
            .rsAptResize
            {
                display: none;
            }
            .rsWrap
            {
                height: 17px !important;
            }
            .rsAptContent
            {
                font-size: 9px;
                text-shadow: -1px 0px 2px white, 0px 1px 2px white,
          1px 0px 2px white, 0px -1px 2px white;
                line-height: 12px;
                height: 14px;
            }
            
            .rsApt
            {
                height: 16px !important;
            }
            </style>
        <script type="text/javascript" language="javascript">
                
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <telerik:radscriptmanager ID="RadScriptManager1" runat="server" 
        AsyncPostBackTimeout="56000">
        </telerik:radscriptmanager>
     
        <telerik:radscriptblock ID="RadScriptBlock1" runat="server">
            <script type="text/javascript" language="javascript">
                var WindowOpen = false;

                function SchedulerApplicantsAppointmentMoveStart(sender, eventArgs) {

                    selectedAppointment = eventArgs.get_appointment();

                    if (selectedAppointment._id > 0) {
                        eventArgs.set_cancel(true);

                    }
                }
                function SchedulerApplicantsAppointmentMoveEnd(sender, eventArgs) {

                    selectedAppointment = eventArgs.get_appointment();

                    if (selectedAppointment._id > 0) {
                        eventArgs.set_cancel(true);

                    } else {
                        $get("<%=TargetSlotHiddenField.ClientID %>").value = eventArgs.get_targetSlot().get_index();
                        $get("<%=TargetSlotRessourceHiddenField.ClientID %>").value = eventArgs.get_targetSlot().get_resource().get_key();
                        $get("<%=HiddenFieldAppointmentId.ClientID %>").value = selectedAppointment._attributes._data.RealID;

                        document.getElementById("<%= ButtonScheduleAppointment.ClientID %>").click();

                    }
                }
                function SchedulerApplicantsAppointmentResizeStart(sender, eventArgs) {
                    eventArgs.set_cancel(true);
                }

                $telerik.$(".Disabled").bind("RadSchedulerOther", function (e) {
                    return false;
                });

                //Called when the user right-clicks an appointment
                function appointmentContextMenu(sender, eventArgs) {

                    selectedAppointment = eventArgs.get_appointment();


                }

                //Called when the user clicks an item from the appointment context menu
                function appointmentContextMenuItemClicked(sender, eventArgs) {

                    if (!selectedAppointment) {

                        return;
                    }

                    var clickedItem = eventArgs.get_item();
                    var scheduler = $find("<%= RadSchedulerApplicants.ClientID %>");

                    if (clickedItem._properties._data.value == "EditCourse") {
                        var oWnd = window.radopen('CourseEdit.aspx?id=' + selectedAppointment._attributes._data.RealID, "RadWindow1");
                        oWnd.center();
                        WindowOpen = true;

                    }
                    if (clickedItem._properties._data.value == "CourseClose") {
                        var oWnd = window.radopen('CourseClose.aspx?id=' + selectedAppointment._attributes._data.RealID, "RadWindow2");

                        oWnd.setSize(900, 600);
                        oWnd.set_minWidth(600);
                        oWnd.set_minHeight(900);
                        oWnd.center();
                        WindowOpen = true;

                    }
                    if (clickedItem._properties._data.value == "CourseDelete") {

                        DeleteCourse(selectedAppointment._attributes._data.RealID);
                    }
                }

                function DeleteCourse(courseID) {
                    if (confirm("Do you want to delete this course")) {
                        document.getElementById("<%= HiddenFieldDeleteCourse.ClientID %>").value = courseID;
                        document.getElementById("<%= ButtonDeleteCourse.ClientID %>").click();
                    }
                }

                function OnClientTimeSlotContextMenu(sender, args) {

                }

                function OnClientTimeSlotContextMenu(sender, args) {

                }

                function OnClientTimeSlotContextMenuItemClicked(sender, args) {
                    var clickedItem = args.get_item();
                    var clickedSlot = args.get_slot();

                    if (clickedItem._properties._data.value == "CommandNewCourse") {
                        OnClientNewCourse(clickedSlot.get_startTime());
                    }
                }

                function OnClientNewCourse(date) {


                    var oWnd = window.radopen('NewCourse.aspx?start=' + makedateString(date), "RadWindow1");

                    oWnd.setSize(900, 600);
                    oWnd.center();
                    oWnd.on
                    WindowOpen = true;
                }

                function makedateString(date) {
                    var datestring = date.getFullYear() + '-';
                    if (date.getMonth() < 10) {
                        datestring = datestring + '0' + (date.getMonth() + 1) + '-';
                    } else {
                        datestring = datestring + (date.getMonth() + 1) + '-';
                    }
                    if (date.getDate() < 10) {
                        datestring = datestring + '0' + date.getDate() + 'T00:00:00';
                    } else {
                        datestring = datestring + date.getDate() + 'T00:00:00';
                    }

                    return datestring;
                }



                function OpenRadWindow(url) {
                    var oWnd = window.radopen(url, "RadWindow1");


                    oWnd.setSize(900, 600);
                    oWnd.center();
                    WindowOpen = true;
                }

                function RadWindow1_close(sender, args) {
                    WindowOpen = false;

                    RefreshScheduler();

                }

                function RefreshScheduler() {

                    document.getElementById("<%= ButtonRefreshScheduler.ClientID %>").click();

                }









                //]]>
            </script>
        </telerik:radscriptblock>
        <asp:HiddenField ID="TargetSlotHiddenField" runat="server" />
        <asp:HiddenField ID="TargetSlotRessourceHiddenField" runat="server" />
        <asp:HiddenField ID="HiddenFieldAppointmentId" runat="server" />
        
        <telerik:radajaxmanager runat="server" ID="RadAjaxManager1" EnableAJAX="true" 
            onajaxrequest="RadAjaxManager1_AjaxRequest">
            <AjaxSettings>
                <telerik:ajaxsetting AjaxControlID="RadSchedulerApplicants">
                    <UpdatedControls>
                        <telerik:ajaxupdatedcontrol 
        ControlID="RadSchedulerApplicants"></telerik:AjaxUpdatedControl>
                        
                    </UpdatedControls>
                </telerik:AjaxSetting>
                
            </AjaxSettings>
        </telerik:radajaxmanager>
        <asp:SqlDataSource ID="SqlDataSourceEvents" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
            SelectCommand="SELECT [ID], [ResourceID], [Start], [Stop], [Name] FROM [TestScheduler]">
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSourceResources1" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
            SelectCommand="SELECT [ID] As ResourceID, [Name], [Description] FROM [TestResources]">
        </asp:SqlDataSource>
        <asp:Label ID="LabelFilterinformation" runat="server" Text="Label"></asp:Label>
        <br />
        
                Training schedule<br />
                &nbsp;<asp:SqlDataSource ID="SqlDataSourceApplicantCourses" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
                    DeleteCommand="DELETE FROM T_TrainingCrewInCourse
    WHERE     (ID = @ID)" InsertCommand="INSERT INTO T_TrainingCrewInCourse(CourseID, CrewID, present, Feedbackrecived) VALUES (@CourseID, @CrewID, 0, 0)"
                    OnSelected="SqlDataSourceCourses_Selected" 
                    
                    
                    
                    
                    SelectCommand="sp_TrainingTimelineAppointmentsTest" 
                    onselecting="SqlDataSourceApplicantCourses_Selecting" 
                    SelectCommandType="StoredProcedure">
                    <DeleteParameters>
                        <asp:Parameter Name="ID" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="CourseID" />
                        <asp:Parameter Name="CrewID" />
                    </InsertParameters>
                </asp:SqlDataSource>
                <asp:SqlDataSource ID="SqlDataSourceRecources" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
                    OnSelected="SqlDataSourceCourses_Selected" 
                    SelectCommand="SELECT DisplayName, RessourceKey FROM (SELECT 'Courses' AS DisplayName, 0 AS RessourceKey, 0 AS help ) AS TEST ORDER BY help, DisplayName">
                    
                </asp:SqlDataSource>
        <telerik:radformdecorator ID="QsfFromDecorator" runat="server" DecoratedControls="All"
                    EnableRoundedCorners="false" />
        <telerik:radscheduler ID="RadSchedulerApplicants" runat="server" 
                    AllowDelete="false" 
                    CustomAttributeNames="RessourceFK,CourseID,StatusColor, Description, Status, Color, ID, Border,RealID,isDeletable, isCrewCourse, isRealCourse,RelatedCheck" 
                    DataDescriptionField="Remark" DataEndField="Enddate" DataKeyField="ID" 
                    DataSourceID="SqlDataSourceApplicantCourses" DataStartField="BeginDate" 
                    DataSubjectField="Description" Height="600px" 
                    OnAppointmentCommand="RadSchedulerApplicants_AppointmentCommand" 
                    onappointmentcreated="RadSchedulerApplicants_AppointmentCreated" 
                    OnAppointmentDataBound="RadSchedulerApplicants_AppointmentDataBound" 
                    OnAppointmentInsert="RadSchedulerApplicants_AppointmentInsert" 
                    OnClientAppointmentContextMenu="appointmentContextMenu" 
                    OnClientAppointmentContextMenuItemClicked="appointmentContextMenuItemClicked" 
                    onclientappointmentmoveend="SchedulerApplicantsAppointmentMoveEnd" 
                    onclientappointmentmovestart="SchedulerApplicantsAppointmentMoveStart" 
                    onclientappointmentresizestart="SchedulerApplicantsAppointmentResizeStart" 
                    onclienttimeslotcontextmenuitemclicked="OnClientTimeSlotContextMenuItemClicked" 
                    OnClientTimeSlotContextMenuItemClicking="OnClientTimeSlotContextMenu" 
                    OnNavigationCommand="RadSchedulerApplicants_NavigationCommand" 
                    onresourceheadercreated="RadSchedulerApplicants_ResourceHeaderCreated" 
                    OnTimeSlotCreated="RadSchedulerApplicants_TimeSlotCreated" 
                    OverflowBehavior="Expand" RowHeight="17px" SelectedView="TimelineView" 
                    ShowFooter="False" Width="1350px">
                    <AdvancedForm Enabled="false" />
                    <AppointmentTemplate>
                        <asp:Panel ID="AppointmentContainer" runat="server" style="position:relative">
                            <div style="position:relative">
                                <span style="position:absolute; left:0px;top:0px;z-index:10;">
                                <%# Eval("Description")%></span>
                                <asp:ImageButton ID="UnscheduleAppointmentImageButton" runat="server" 
                                    CommandName="Unschedule" CssClass="simpleButton" ImageUrl="~/Images/delete.gif" 
                                    OnClientClick="return confirm('Do you want to Delete this course')" 
                                    style="position:absolute; right:0px;top:0px;z-index:10;" Text="&nbsp;" 
                                    ToolTip="Delete this Course" 
                                    Visible='<%# int.Parse(Eval("RealID").ToString()) > 0 && bool.Parse(Eval("isDeletable").ToString()) %>' />
                            </div>
                        </asp:Panel>
                    </AppointmentTemplate>
                    <ResourceHeaderTemplate>
                        <asp:Panel ID="HeaderTemplateContainer" runat="server">
                        </asp:Panel>
                    </ResourceHeaderTemplate>
                    <ResourceTypes>
                        <telerik:resourcetype AllowMultipleValues="False" 
                            DataSourceID="SqlDataSourceRecources" ForeignKeyField="RessourceFK" 
                            KeyField="RessourceKey" Name="DisplayName" 
        TextField="DisplayName" />
                    </ResourceTypes>
                    <TimelineView ColumnHeaderDateFormat="dd" EnableExactTimeRendering="True" 
                        GroupBy="DisplayName" GroupingDirection="Vertical" />
                    <DayView UserSelectable="false" />
                    <WeekView UserSelectable="false" />
                    <MonthView UserSelectable="false" />
                    <AppointmentContextMenuSettings EnableDefault="false" />
                    <AppointmentContextMenus>
                        <telerik:radschedulercontextmenu 
        ID="RadSchedulerCourseContext" runat="server" 
                            AppendDataBoundItems="True">
                            <Items>
                                <telerik:radmenuitem runat="server" Text="Edit Course" Value="EditCourse">
                                </telerik:RadMenuItem>
                                <telerik:radmenuitem runat="server" Text="Close Course" Value="CourseClose">
                                </telerik:RadMenuItem>
                                <telerik:radmenuitem runat="server" Text="Delete Course" Value="CourseDelete">
                                </telerik:RadMenuItem>
                            </Items>
                        </telerik:RadSchedulerContextMenu>
                        <telerik:radschedulercontextmenu ID="RadSchedulerOther" runat="server" 
                            AppendDataBoundItems="True">
                            <Items>
                            </Items>
                        </telerik:RadSchedulerContextMenu>
                    </AppointmentContextMenus>
                    <TimeSlotContextMenus>
                        <telerik:radschedulercontextmenu ID="SchedulerTimeSlotContextMenu" 
                            runat="server">
                            <Items>
                                <telerik:radmenuitem Text="New Course" Value="CommandNewCourse" />
                            </Items>
                        </telerik:RadSchedulerContextMenu>
                    </TimeSlotContextMenus>
                </telerik:radscheduler>
        <telerik:radwindowmanager ID="RadWindowManager1" runat="server">
                    <Windows>
                        <telerik:radwindow ID="RadWindow1" runat="server" 
        OnClientClose="RadWindow1_close" AutoSize="True"  
        Behavior="Close, Pin, Move, Reload, Resize" 
        Behaviors="Close, Pin, Move, Reload, Resize" Width="1000" Height="1200"
                    VisibleStatusbar="False" ReloadOnShow="true" 
        ShowContentDuringLoad="false">
                        </telerik:RadWindow>
                        <telerik:radwindow ID="RadWindow2" runat="server" 
        OnClientClose="RadWindow1_close" Width="1000" Height="1200" 
        Behavior="Close, Pin, Move, Reload" Behaviors="Close, Pin, Move, Reload" 
                    VisibleStatusbar="False" ReloadOnShow="true" 
        ShowContentDuringLoad="false">
                        </telerik:RadWindow>
                    </Windows>
                </telerik:radwindowmanager>
        <telerik:radajaxpanel ID="RadAjaxPanel1" runat="server" Height="2px" 
                    Width="2px" onajaxrequest="RadAjaxPanel1_AjaxRequest">
                    
                </telerik:radajaxpanel>
                <asp:Panel ID="HelpHidePanel" runat="server" style="display:none">
                <asp:Button ID="ButtonScheduleAppointment" runat="server" 
                    onclick="ButtonScheduleAppointment_Click" Text="Button" style="display:none"/>
                    <asp:Button ID="ButtonRefreshScheduler" runat="server" 
                     Text="Button" style="display:none" 
                    onclick="ButtonRefreshScheduler_Click"/>
                    <asp:Button ID="ButtonDeleteCourse" runat="server" 
                     Text="Button" style="display:none" onclick="ButtonDeleteCourse_Click" 
                    />
                    <asp:HiddenField ID="HiddenFieldDeleteCourse" runat="server" />
                    </asp:Panel>
           
       
    </form>
    </body>
    </html>











  2. Answer
    Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1968 posts

    Posted 13 Oct 2014 Link to this post

    Hello,

    Please remove this custom style in order to avoid this misalignment problem:
    //css
    .NowCss
           {
               border-left: 3px solid red !important;
            ...
           }



    Regards,
    Boyan Dimitrov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Michael
    Michael avatar
    3 posts
    Member since:
    Jun 2012

    Posted 16 Oct 2014 in reply to Boyan Dimitrov Link to this post

    Thank you, that solved it.
Back to Top