如何使用asp.net连接完整日历v 1.5.3与MS SQL Server C#/ VB
我已成功连接FullCalendar v1.4.2与SQL Server使用asp.net webforms和vb.net。我想更新到v1.5.3,但原始的集成代码不再起作用,我看不到如何解决它。如何使用asp.net连接完整日历v 1.5.3与MS SQL Server C#/ VB
其次,我想帮助添加拖放功能,以便更新数据库从asp.net拖放,但我不知道从哪里开始。
的代码我有工作当V 1.4.2如下:
<script type="text/javascript" language="javascript"> $(document).ready(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev, next today',
center: 'title',
right: 'month, basicWeek, basicDay'
},
events: "Calendar.asmx/EventList"
});
});
</script>
Imports System Imports System.Data
Imports System.Web.Services
Imports System.Data.SqlClient
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Collections.Generic
Imports System.Web.UI.Page
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Calendar
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function EventList(ByVal startDate As String, ByVal endDate As String) As String
' List to hold events
Dim events As List(Of CalendarDTO) = New List(Of CalendarDTO)()
Dim WebConfigConnection As String = ConfigurationManager.ConnectionStrings("FresheyeTimeTrackerConnectionString").ConnectionString
Dim query As String = "SELECT * FROM CORE_PROJECT"
Dim conn As New SqlConnection(WebConfigConnection)
Dim cmd As New SqlCommand(query, conn)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
da.Fill(ds)
'If startDate > ToUnixTimespan(DateTime.Now) Then
'GoTo x
'End If
Dim starting As DateTime = FromUnixTimespan(startDate)
' Loop through events to be added
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
If String.IsNullOrEmpty(ds.Tables(0).Rows(i)("ProjectDeliveryDate").ToString()) Then
Else
' Create a new event and start to populate
Dim value As CalendarDTO = New CalendarDTO()
' Date is required to be in a unix format
value.StartDate = ToUnixTimespan(DateTime.Parse(ds.Tables(0).Rows(i)("ProjectAddedDate").ToString))
value.id = ds.Tables(0).Rows(i)("ProjectID").ToString()
value.title = ds.Tables(0).Rows(i)("ProjectTitle").ToString()
value.EndDate = ToUnixTimespan(DateTime.Parse(ds.Tables(0).Rows(i)("ProjectDeliveryDate").ToString))
events.Add(value)
End If
Next
' Serialize the return value so it can be decoded in java.
x:
Dim js As New System.Web.Script.Serialization.JavaScriptSerializer
Return js.Serialize(events)
End Function
Private Function ToUnixTimespan(ByVal d As DateTime) As Int64
Dim time As New TimeSpan()
time = d.ToUniversalTime().Subtract(New DateTime(1970, 1, 1, 0, 0, 0))
Return CType(Math.Truncate(time.TotalSeconds), Int64)
End Function
Private Function FromUnixTimespan(ByVal s As String) As DateTime
Dim time As DateTime = New DateTime(1970, 1, 1, 0, 0, 0)
Return time.AddSeconds(s)
End Function
End Class
回答:
我也为此而努力......它看起来就像我们从类似的地方借来的代码。 ..
在上面的代码中,您似乎并未将startDate和endDate转换回开始和结束。你在FullCalendar.js中做这个吗?
基本上我有很多相同的除了之前返回事件我做一个替换,以便发回的字符串包含开始和结束,而不是startDate和EndDate。
我的代码似乎在Chrome中可以正常工作,但在IE中却不行。
至于更新Db的......我在看一对夫妇张贴在回答....
FullCalendar, how do I allow users to edit/delete events and remove them from the database?
以上是 如何使用asp.net连接完整日历v 1.5.3与MS SQL Server C#/ VB 的全部内容, 来源链接: utcz.com/qa/263883.html