version 2009.3.1208 35
Followed the 'getting started' fairly closely. Used the object data source method. Obviously I needed to deviate to a persisted datasource. I also needed to add a couple resources. Location/room and User. Once again followed very closely the dataset schema design.
ok so here we are:
Every time I go to edit the appt. both the location and user resource are not selected to their respective values. ie 1,3. I can confirm that the data is good.
im using a sql datasource exactly as the demos show here to populate dropdowns..which they do: http://demos.telerik.com/aspnet-ajax/scheduler/examples/resources/defaultvb.aspx
When I move the appt I notice it posts back to update the event. I find all the items in the updateAppt except the user and room. i have extended the apptInfo class. I ended up rewriting to check if it was nothing then leave it what it used to be.
Can anyone tell me what might the issue be?
html
AppointmentList.vb
AppointmentInfo.vb
Followed the 'getting started' fairly closely. Used the object data source method. Obviously I needed to deviate to a persisted datasource. I also needed to add a couple resources. Location/room and User. Once again followed very closely the dataset schema design.
ok so here we are:
Every time I go to edit the appt. both the location and user resource are not selected to their respective values. ie 1,3. I can confirm that the data is good.
im using a sql datasource exactly as the demos show here to populate dropdowns..which they do: http://demos.telerik.com/aspnet-ajax/scheduler/examples/resources/defaultvb.aspx
When I move the appt I notice it posts back to update the event. I find all the items in the updateAppt except the user and room. i have extended the apptInfo class. I ended up rewriting to check if it was nothing then leave it what it used to be.
Can anyone tell me what might the issue be?
html
<
telerik:RadScheduler
ID
=
"RadScheduler1"
runat
=
"server"
DataEndField
=
"End"
DataKeyField
=
"ID"
DataRecurrenceField
=
"RecurrenceRule"
DataRecurrenceParentKeyField
=
"RecurrenceParentID"
StartInsertingInAdvancedForm
=
"true"
StartEditingInAdvancedForm
=
"true"
DataSourceID
=
"ObjectDataSource1"
DataStartField
=
"Start"
ShowFooter
=
"false"
MinutesPerRow
=
"15"
DayStartTime
=
"7:00"
DayEndTime
=
"21:00"
DataSubjectField
=
"Subject"
>
<
ResourceTypes
>
<
telerik:ResourceType
KeyField
=
"LocID"
Name
=
"Room"
TextField
=
"LocCity"
ForeignKeyField
=
"RoomID"
DataSourceID
=
"DS_Locations"
/>
<
telerik:ResourceType
KeyField
=
"UserID"
Name
=
"User"
TextField
=
"UserFName"
ForeignKeyField
=
"UserID"
DataSourceID
=
"DS_Users"
/>
</
ResourceTypes
>
</
telerik:RadScheduler
>
<
asp:ObjectDataSource
ID
=
"ObjectDataSource1"
runat
=
"server"
DeleteMethod
=
"DeleteAppointment"
InsertMethod
=
"InsertAppointment"
SelectMethod
=
"AllData"
TypeName
=
"AppointmentList"
UpdateMethod
=
"UpdateAppointment"
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"ID"
Type
=
"String"
/>
</
DeleteParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"Subject"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"Start"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"End"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"RecurrenceRule"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"RecurrenceParentID"
Type
=
"Object"
/>
<
asp:Parameter
Name
=
"RecurrenceState"
Type
=
"Object"
/>
<
asp:Parameter
Name
=
"RoomID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"UserID"
Type
=
"Int32"
/>
</
InsertParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"ID"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"Subject"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"Start"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"End"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"RecurrenceRule"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"RecurrenceParentID"
Type
=
"Object"
/>
<
asp:Parameter
Name
=
"RecurrenceState"
Type
=
"Object"
/>
<
asp:Parameter
Name
=
"RoomID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"UserID"
Type
=
"Int32"
/>
</
UpdateParameters
>
</
asp:ObjectDataSource
>
<
br
/>
<
asp:SqlDataSource
ID
=
"DS_Users"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
SelectCommand="SELECT * FROM [Tbl_Users]"></
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"DS_Locations"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
SelectCommand="SELECT * FROM [Tbl_Locations]"></
asp:SqlDataSource
>
AppointmentList.vb
Public
Shared
Function
buildSess()
As
List(Of AppointmentInfo)
Dim
dt
As
DataTable =
New
DataTable
Using con
As
New
SqlConnection(ConfigurationManager.ConnectionStrings(
"ApplicationServices"
).ToString)
Dim
da
As
New
SqlDataAdapter()
da.SelectCommand =
New
SqlCommand(
"Select * from Appointments"
, con)
da.Fill(dt)
Dim
sessApts
As
List(Of AppointmentInfo) =
New
List(Of AppointmentInfo)()
For
Each
row
In
dt.Rows
Dim
ai
As
New
AppointmentInfo(row.Item(
"Subject"
), row.Item(
"Start"
), row.Item(
"End"
))
ai.ID = row.item(
"ApptGuid"
)
ai.RecurrenceRule = row.item(
"RecurrenceRule"
).ToString
ai.RecurrenceParentID =
CType
(row.item(
"RecurrenceParentID"
), [
Object
])
ai.RoomID = row.item(
"RoomID"
).ToString
ai.UserID = row.item(
"UserID"
).ToString
sessApts.Add(ai)
Next
Return
sessApts
End
Using
End
Function
Public
Shared
Function
AllData()
As
List(Of AppointmentInfo)
Return
buildSess()
' Dim sessApts As List(Of AppointmentInfo) = TryCast(HttpContext.Current.Session(AppointmentsKey), List(Of AppointmentInfo))
'Dim sessApts As List(Of AppointmentInfo) = TryCast(HttpContext.Current.Session(AppointmentsKey), List(Of AppointmentInfo))
'If sessApts Is Nothing Then
' sessApts = buildSess() ' New List(Of AppointmentInfo)()
' HttpContext.Current.Session(AppointmentsKey) = sessApts
'End If
'Return sessApts
End
Function
Public
Shared
Sub
InsertAppointment(
ByVal
Subject
As
String
,
ByVal
Start
As
DateTime,
ByVal
[
End
]
As
DateTime, _
ByVal
RecurrenceRule
As
String
,
ByVal
RecurrenceParentID
As
[
Object
], _
ByVal
RecurrenceState
As
Telerik.Web.UI.RecurrenceState,
ByVal
RoomID
As
Int32,
ByVal
UserID
As
Int32)
' Dim sessApts As List(Of AppointmentInfo) = AllData()
Dim
ai
As
New
AppointmentInfo(Subject, Start, [
End
])
ai.RecurrenceRule = RecurrenceRule
ai.RecurrenceParentID = RecurrenceParentID
ai.RecurrenceState = RecurrenceState
ai.RoomID = RoomID
ai.UserID = UserID
' sessApts.Add(ai)
Dim
guid
As
String
= ai.ID
'add it to the db
Dim
SQL
As
String
=
"INSERT INTO Appointments "
& _
" ([Subject]"
& _
", [Description]"
& _
", [Start]"
& _
", [End]"
& _
", [RecurrenceRule]"
& _
", [RecurrenceParentID]"
& _
", [Reminder]"
& _
", [Annotations], ApptGuid, RoomID, UserID) "
& _
" VALUES ("
& _
" @Subject"
& _
", @Description"
& _
", @Start"
& _
", @End"
& _
", @RecurrenceRule"
& _
", @RecurrenceParentID"
& _
", @Reminder"
& _
", @Annotations, @ApptGuid, @RoomID, @UserID)"
' RecurrenceParentID.ToString = Nothing
Using con
As
New
SqlConnection(ConfigurationManager.ConnectionStrings(
"ApplicationServices"
).ToString)
Dim
cmd
As
New
SqlCommand
cmd.CommandText = SQL
cmd.Connection = con
cmd.Parameters.Add(
"@Subject"
, Data.SqlDbType.NVarChar).Value = Subject
cmd.Parameters.Add(
"@Description"
, Data.SqlDbType.NVarChar).Value =
""
cmd.Parameters.Add(
"@Start"
, Data.SqlDbType.DateTime).Value = Start
cmd.Parameters.Add(
"@End"
, Data.SqlDbType.DateTime).Value = [
End
]
cmd.Parameters.Add(
"@RecurrenceRule"
, Data.SqlDbType.NVarChar).Value = IIf(IsNothing(RecurrenceRule), System.Data.SqlTypes.SqlString.Null, RecurrenceRule)
cmd.Parameters.Add(
"@RecurrenceParentID"
, Data.SqlDbType.Int).Value = IIf(RecurrenceParentID
Is
Nothing
, System.Data.SqlTypes.SqlInt32.Null, GetParentID(RecurrenceParentID))
cmd.Parameters.Add(
"@Reminder"
, Data.SqlDbType.NVarChar).Value =
""
cmd.Parameters.Add(
"@Annotations"
, Data.SqlDbType.NVarChar).Value =
""
cmd.Parameters.Add(
"@ApptGuid"
, Data.SqlDbType.NVarChar).Value = guid
cmd.Parameters.Add(
"@RoomID"
, SqlDbType.Int).Value = IIf(IsNumeric(RoomID) =
False
, SqlTypes.SqlInt32.Null, RoomID)
cmd.Parameters.Add(
"@UserID"
, SqlDbType.Int).Value = IIf(IsNumeric(UserID) =
False
, SqlTypes.SqlInt32.Null, UserID)
' cmd.Parameters.Add("@RecurrenceState", Data.SqlDbType.NVarChar).Value = IIf(RecurrenceState.NotRecurring, System.Data.SqlTypes.SqlString.Null, RecurrenceState)
cmd.Connection.Open()
cmd.ExecuteNonQuery()
End
Using
End
Sub
Public
Shared
Sub
DeleteAppointment(
ByVal
ID
As
String
)
Dim
sessApts
As
List(Of AppointmentInfo) = AllData()
sessApts.Remove(FindById(ID, sessApts))
Using con
As
SqlConnection =
New
SqlConnection(ConfigurationManager.ConnectionStrings(
"ApplicationServices"
).ToString)
Dim
cmd
As
New
SqlCommand(
"Delete from Appointments where ApptGuid = @ID"
, con)
cmd.Parameters.Add(
"@ID"
, SqlDbType.NVarChar).Value = ID
cmd.Connection.Open()
cmd.ExecuteNonQuery()
End
Using
End
Sub
Public
Shared
Sub
UpdateAppointment(
ByVal
ID
As
String
,
ByVal
Subject
As
String
,
ByVal
Start
As
DateTime,
ByVal
[
End
]
As
DateTime,
ByVal
RecurrenceRule
As
String
,
ByVal
RecurrenceParentID
As
[
Object
], _
ByVal
RecurrenceState
As
Telerik.Web.UI.RecurrenceState,
ByVal
RoomID
As
Int32,
ByVal
UserID
As
Int32)
Dim
sessApts
As
List(Of AppointmentInfo) = AllData()
Dim
ai
As
AppointmentInfo = FindById(ID, sessApts)
ai.Subject = Subject
ai.Start = Start
ai.[
End
] = [
End
]
ai.RecurrenceRule = RecurrenceRule
ai.RecurrenceParentID = RecurrenceParentID
ai.RecurrenceState = RecurrenceState
ai.RoomID = IIf(RoomID = 0, ai.RoomID, RoomID)
ai.UserID = IIf(UserID = 0, ai.UserID, UserID)
Dim
SQL
As
String
=
"Update Appointments set subject = @subject, [start] = @start, [end] = @end "
& _
" , RecurrenceRule = @RecurrenceRule, RecurrenceParentID = @RecurrenceParentID, RoomID = @RoomID, UserID = @UserID where ApptGuid = @ApptGuid"
Using con
As
SqlConnection =
New
SqlConnection(ConfigurationManager.ConnectionStrings(
"ApplicationServices"
).ToString)
Dim
cmd
As
SqlCommand =
New
SqlCommand(SQL, con)
cmd.Parameters.Add(
"@Subject"
, Data.SqlDbType.NVarChar).Value = Subject
cmd.Parameters.Add(
"@Description"
, Data.SqlDbType.NVarChar).Value =
""
cmd.Parameters.Add(
"@Start"
, Data.SqlDbType.DateTime).Value = Start
cmd.Parameters.Add(
"@End"
, Data.SqlDbType.DateTime).Value = [
End
]
cmd.Parameters.Add(
"@RecurrenceRule"
, Data.SqlDbType.NVarChar).Value = IIf(RecurrenceRule =
Nothing
, System.Data.SqlTypes.SqlString.Null, RecurrenceRule)
cmd.Parameters.Add(
"@RecurrenceParentID"
, Data.SqlDbType.Int).Value = IIf(RecurrenceParentID =
Nothing
, System.Data.SqlTypes.SqlInt32.Null, GetParentID(RecurrenceParentID))
cmd.Parameters.Add(
"@Reminder"
, Data.SqlDbType.NVarChar).Value =
""
cmd.Parameters.Add(
"@Annotations"
, Data.SqlDbType.NVarChar).Value =
""
cmd.Parameters.Add(
"@ApptGuid"
, Data.SqlDbType.NVarChar).Value = ai.ID
cmd.Parameters.Add(
"@RoomID"
, SqlDbType.Int).Value = IIf(ai.RoomID = 0, SqlTypes.SqlInt32.Null, ai.RoomID)
cmd.Parameters.Add(
"@UserID"
, SqlDbType.Int).Value = IIf(ai.UserID = 0, SqlTypes.SqlInt32.Null, ai.UserID)
cmd.Connection.Open()
cmd.ExecuteNonQuery()
End
Using
End
Sub
Public
Shared
Function
FindById(
ByVal
ID
As
String
,
ByVal
sessApts
As
List(Of AppointmentInfo))
As
AppointmentInfo
For
Each
ai
As
AppointmentInfo
In
sessApts
If
ai.ID = ID
Then
Return
ai
End
If
Next
Return
Nothing
End
Function
Public
Shared
Function
GetParentID(
ByVal
RecurrenceParentID
As
String
)
As
Int32
'Dim i As Int32
If
RecurrenceParentID IsNot
Nothing
Then
Using con
As
SqlConnection =
New
SqlConnection(ConfigurationManager.ConnectionStrings(
"ApplicationServices"
).ToString)
Dim
cmd
As
SqlCommand =
New
SqlCommand(
"Select ID from Appointments where ApptGuid = @Guid"
, con)
cmd.Parameters.Add(
"@Guid"
, SqlDbType.NVarChar).Value = RecurrenceParentID
cmd.Connection.Open()
Dim
i
As
Integer
= cmd.ExecuteScalar
Return
i
End
Using
Else
Return
Nothing
End
If
' Return (cmd.ExecuteScalar)
End
Function
AppointmentInfo.vb
Private
idString
As
String
Private
subj
As
String
Private
startTime
As
DateTime
Private
endTime
As
DateTime
Private
RID
As
String
Private
UID
As
String
Private
recur
As
String
Private
recurParent
As
Object
Private
recurState
As
RecurrenceState
Public
Property
RoomID()
As
String
Get
Return
RID
End
Get
Set
(
ByVal
value
As
String
)
RID = value
End
Set
End
Property
Public
Property
UserID()
As
String
Get
Return
UID
End
Get
Set
(
ByVal
value
As
String
)
UID = value
End
Set
End
Property
Public
Property
ID()
As
String
Get
Return
idString
End
Get
Set
(
ByVal
value
As
String
)
idString = value
End
Set
End
Property
Public
Property
Subject()
As
String
Get
Return
subj
End
Get
Set
(
ByVal
value
As
String
)
subj = value
End
Set
End
Property
Public
Property
Start()
As
DateTime
Get
Return
startTime
End
Get
Set
(
ByVal
value
As
DateTime)
startTime = value
End
Set
End
Property
Public
Property
[
End
]()
As
DateTime
Get
Return
endTime
End
Get
Set
(
ByVal
value
As
DateTime)
endTime = value
End
Set
End
Property
Public
Property
RecurrenceRule()
As
String
Get
Return
recur
End
Get
Set
(
ByVal
value
As
String
)
recur = value
End
Set
End
Property
Public
Property
RecurrenceParentID()
As
Object
Get
Return
recurParent
End
Get
Set
(
ByVal
value
As
Object
)
recurParent = value
End
Set
End
Property
Public
Property
RecurrenceState()
As
RecurrenceState
Get
Return
recurState
End
Get
Set
(
ByVal
value
As
RecurrenceState)
recurState = value
End
Set
End
Property
Private
Sub
New
()
Me
.idString = Guid.NewGuid().ToString()
End
Sub
Public
Sub
New
(
ByVal
subject
As
String
,
ByVal
start
As
DateTime,
ByVal
[end]
As
DateTime)
Me
.
New
()
Me
.subj = subject
Me
.startTime = start
Me
.endTime = [end]
End
Sub