Server) : Features
Server) : Features
Downloads
TutorialAspnetDoctorAppointment.VS2017.20170921.zip 2514 kB
Visual Studio 2017 solution with the tutorial source code. Microsoft SQL Server 2014 database (LocalDB). Includes
C# and VB projects
Features
Public interface for patients
Doctor's interface for managing appointments
Manager's interface for scheduling shifts
Using pre-defined appointment slots
Appointment status: "free", "waiting", "confirmed"
SQL Server database
Visual Studio 2017
C# source code
VB.NET source code
Includes the trial version of DayPilot Pro for ASP.NET WebForms
License
Licensed for testing and evaluation purposes. You can use the source code of the tutorial if you are
a licensed user of DayPilot Pro for ASP.NET WebForms. Buy a license.
See Also
This tutorial is also available for AngularJS: AngularJS Doctor Appointment Scheduling (PHP)
Requesting an Appointment
The user can click on a selected appointment slot and display a "Request an Appointment" modal
dialog.
<div>
<p>Available time slots:</p>
<DayPilot:DayPilotCalendar
runat="server"
ID="DayPilotCalendar1"
...
EventClickHandling="JavaScript"
EventClickJavaScript="edit(e)"
/>
</div>
<script>
function edit(e) {
new DayPilot.Modal({
onClosed: function (args) {
if (args.result == "OK") {
dp.commandCallBack('refresh');
}
}
}).showUrl("Request.aspx?id=" + e.id());
}
</script>
After entering the name the appointment status will be changed to "waiting" and it will be displayed
with an orange bar.
For the purposes of this demo the appointment is recognized using the current user session id.
C#
protected void ButtonOK_Click(object sender, EventArgs e)
{
string name = TextBoxName.Text;
int id = Convert.ToInt32(Request.QueryString["id"]);
VB
The public interface displays all free slots and also all slots belonging to the current user. In this
sample project, the user is recognized using the session ID (Session.SessionID) - normally this
would be the ID from a user database.
C#
return dt;
VB
Public Shared Function LoadFreeAndMyAppointments(ByVal start As Date, ByVal
[end] As Date, ByVal sessionId As String) As DataTable
Dim da As New SqlDataAdapter("SELECT * FROM [Appointment] WHERE
([AppointmentStatus] = 'free' OR ([AppointmentStatus] <> 'free' AND
[AppointmentPatientSession] = @session)) AND NOT (([AppointmentEnd] <= @start)
OR ([AppointmentStart] >= @end))",
ConfigurationManager.ConnectionStrings("daypilot").ConnectionString)
da.SelectCommand.Parameters.AddWithValue("session", sessionId)
da.SelectCommand.Parameters.AddWithValue("start", start)
da.SelectCommand.Parameters.AddWithValue("end", [end])
Dim dt As New DataTable()
da.Fill(dt)
Return dt
End Function
Shifts View
This view uses the ASP.NET scheduler control to display appointments for all doctors.
C#
private void LoadDoctors()
{
DataTable doctors = Db.LoadDoctors();
DayPilotScheduler1.Resources.Clear();
foreach (DataRow row in doctors.Rows)
{
DayPilotScheduler1.Resources.Add((string)row["DoctorName"],
Convert.ToString(row["DoctorId"]));
}
}
VB
DayPilotScheduler1.Resources.Clear()
For Each row As DataRow In doctors.Rows
DayPilotScheduler1.Resources.Add(DirectCast(row("DoctorName"), String),
Convert.ToString(row("DoctorId")))
Next row
End Sub
The time header displays a custom timeline. The timeline only includes the pre-defined shifts
(morning shift from 9am to 13pm, afternoon shift from 2pm to 6pm).
C#
DayPilotScheduler1.Timeline.Add(day.AddHours(MorningShiftStarts),
day.AddHours(MorningShiftEnds));
DayPilotScheduler1.Timeline.Add(day.AddHours(AfternoonShiftStarts),
day.AddHours(AfternoonShiftEnds));
}
DayPilotScheduler1.TimeHeaders.Clear();
DayPilotScheduler1.TimeHeaders.Add(new TimeHeader(GroupByEnum.Month));
DayPilotScheduler1.TimeHeaders.Add(new TimeHeader(GroupByEnum.Day, "ddd
d"));
DayPilotScheduler1.TimeHeaders.Add(new TimeHeader(GroupByEnum.Cell, "tt"));
VB
DayPilotScheduler1.Timeline.Add(day.AddHours(MorningShiftStarts),
day.AddHours(MorningShiftEnds))
DayPilotScheduler1.Timeline.Add(day.AddHours(AfternoonShiftStarts),
day.AddHours(AfternoonShiftEnds))
Next i
DayPilotScheduler1.TimeHeaders.Clear()
DayPilotScheduler1.TimeHeaders.Add(New TimeHeader(GroupByEnum.Month))
DayPilotScheduler1.TimeHeaders.Add(New TimeHeader(GroupByEnum.Day, "ddd d"))
DayPilotScheduler1.TimeHeaders.Add(New TimeHeader(GroupByEnum.Cell, "tt"))
End Sub
Hours View
It is possible to switch to a more detailed "hours" scale.
.aspx
<script type="text/javascript">
function scale(size) {
dp.clientState.size = size;
dp.commandCallBack("refresh");
}
</script>
C#
// ...
}
}
switch (scaleSize)
{
case "hours":
LoadTimelineHours();
break;
case "shifts":
LoadTimelineShifts();
break;
}
}
DayPilotScheduler1.Scale = TimeScale.Manual;
DayPilotScheduler1.Timeline.Clear();
DayPilotScheduler1.TimeHeaders.Clear();
DayPilotScheduler1.TimeHeaders.Add(new TimeHeader(GroupByEnum.Month));
DayPilotScheduler1.TimeHeaders.Add(new TimeHeader(GroupByEnum.Day, "ddd
d"));
DayPilotScheduler1.TimeHeaders.Add(new TimeHeader(GroupByEnum.Hour, "ht"));
VB
Protected Sub DayPilotScheduler1_OnCommand(ByVal sender As Object, ByVal e As
CommandEventArgs)
Select Case e.Command
Case "refresh"
LoadTimeline()
LoadDoctors()
LoadAppointments()
' ...
End Select
End Sub
DayPilotScheduler1.Scale = TimeScale.Manual
DayPilotScheduler1.Timeline.Clear()
Next i
DayPilotScheduler1.TimeHeaders.Clear()
DayPilotScheduler1.TimeHeaders.Add(New TimeHeader(GroupByEnum.Month))
DayPilotScheduler1.TimeHeaders.Add(New TimeHeader(GroupByEnum.Day, "ddd d"))
DayPilotScheduler1.TimeHeaders.Add(New TimeHeader(GroupByEnum.Hour, "ht"))
End Sub
Slots booked by patients using the public interface have a "waiting" status and are displayed with an
orange bar.
As soon as the appointment request is confirmed by the doctor the status changes to "confirmed"
and the appointment is displayed with a red bar.
The status is stored in [AppointmentStatus] database field. This field is loaded as a special "tag"
using DataTagFields property:
C#
VB
This tag is later available in BeforeEventRender event handler and we can use it to set a custom bar
color:
C#
VB
End Sub
The doctor's view (Doctor.aspx) displays a full week (all 24 hours each day) for the selected doctor.
[Appointment] Table