完整日历未在我的日历中显示事件

时间:2013-01-10 10:00:30

标签: jquery asp.net

事件未在fullcalender中加载。我的代码是

            public static List<CalendarEvent> getEvents(int clubkey)
    {

        List<CalendarEvent> events = new List<CalendarEvent>();
        //SqlConnection con = new SqlConnection(connectionString);
        //SqlCommand cmd = new SqlCommand("SELECT event_id, description, title, event_start, event_end FROM event where event_start>=@start AND event_end<=@end", con);
        ////cmd.Parameters.AddWithValue("@start", start);
        ////cmd.Parameters.AddWithValue("@end", end);
        BEvents obj = new BEvents();
        obj.ClubKey = clubkey;
        DataTable DT = obj.View();            
           foreach(DataRow dr in DT.Rows)
           {
                CalendarEvent cevent = new CalendarEvent();
                cevent.id = int.Parse(dr["Event_Key"].ToString());
                cevent.title = (string)dr["Event_Title"].ToString();
                cevent.description = (string)dr["Event_Description"].ToString();
                cevent.start =Convert.ToDateTime(dr["Event_StartDate"].ToString());
                cevent.end = Convert.ToDateTime(dr["Event_EndDate"].ToString());

                events.Add(cevent);
            }
        return events;}

这是我的json类方法调用此方法。

public class JsonResponse:IHttpHandler,IRequiresSessionState     {         public void ProcessRequest(HttpContext context)         {             context.Response.ContentType =“application / json”;

        DateTime start = new DateTime(1970, 1, 1);
        DateTime end = new DateTime(1970, 1, 1);

        start = start.AddSeconds(double.Parse(context.Request.QueryString["start"]));
        end = end.AddSeconds(double.Parse(context.Request.QueryString["end"]));
        int key = 3;

        String result = String.Empty;

        result += "[";

        List<int> idList = new List<int>();
        foreach (CalendarEvent cevent in EventDAO.getEvents(key))
        {
            result += convertCalendarEventIntoString(cevent);
            idList.Add(cevent.id);
        }

        if (result.EndsWith(","))
        {
            result = result.Substring(0, result.Length - 1);
        }

        result += "]";
        //store list of event ids in Session, so that it can be accessed in web methods
        context.Session["idList"] = idList;

        context.Response.Write(result);
    }

    private String convertCalendarEventIntoString(CalendarEvent cevent)
    {
        String allDay = "true";
        if (ConvertToTimestamp(cevent.start).ToString().Equals(ConvertToTimestamp(cevent.end).ToString()))
        {

            if (cevent.start.Hour == 0 && cevent.start.Minute == 0 && cevent.start.Second == 0)
            {
                allDay = "true";
            }
            else
            {
                allDay = "false";
            }
        }
        else
        {
            if (cevent.start.Hour == 0 && cevent.start.Minute == 0 && cevent.start.Second == 0
                && cevent.end.Hour == 0 && cevent.end.Minute == 0 && cevent.end.Second == 0)
            {
                allDay = "true";
            }
            else
            {
                allDay = "false";
            }
        }
        return "{" +
                  "id: '" + cevent.id + "'," +
                  "title: '" + HttpContext.Current.Server.HtmlEncode(cevent.title) + "'," +
                  "start:  " + ConvertToTimestamp(cevent.start).ToString() + "," +
                  "end: " + ConvertToTimestamp(cevent.end).ToString() + "," +
                  "allDay:" + allDay + "," +
                  "description: '" + HttpContext.Current.Server.HtmlEncode(cevent.description) + "'" +
                  "},";
    }


    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

    private long ConvertToTimestamp(DateTime value)
    {


        long epoch = (value.ToUniversalTime().Ticks - 621355968000000000) / 10000000;
        return epoch;

    }

}

这是我的设计页面代码

<link href="css/cupertino/jquery-ui-1.7.3.custom.css" rel="stylesheet" type="text/css" />
<link href="fullcalendar/fullcalendar.css" rel="stylesheet" type="text/css" />

<script src="jquery/jquery-1.3.2.min.js" type="text/javascript"></script>

<script src="jquery/jquery-ui-1.7.3.custom.min.js" type="text/javascript"></script>

<script src="jquery/jquery.qtip-1.0.0-rc3.min.js" type="text/javascript"></script>

<script src="fullcalendar/fullcalendar.min.js" type="text/javascript"></script>

<script src="scripts/calendarscript.js" type="text/javascript"></script>

<script src="jquery/jquery-ui-timepicker-addon-0.6.2.min.js" type="text/javascript"></script>

<form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>    
    <div id="calendar">
    </div>

0 个答案:

没有答案