Courtroom Reservation Tutorial Updated

A new version of the courtroom reservation tutorial. Sample ASP.NET web application with C# and VB.NET source code.
Jan 21, 2014
courtroom schedule asp.net tutorial

This tutorial shows how to create a courtroom schedule ASP.NET application using DayPilot Scheduler control.

Tutorial:

The tutorial was updated:

  • Visual Studio 2012 Solution (LocalDB SQL Server database connection)
  • DayPilot Pro for ASP.NET WebForms 7.6 Trial

Features

  • Queue of unscheduled cases on the left side - drag items to the schedule
  • Hierarchy of courtrooms (buildings and rooms)
  • Scheduling cases using drag&drop from the unscheduled list
  • Available time slots limited to working hours (8 am - 6 pm)
  • Custom CSS3 theme
  • C# source code
  • VB.NET source code
  • Microsoft SQL Server database
  • Checking for conflicting assignments

Sample assignment moving code with integrated rules/business logic (C#):

protected void DayPilotScheduler1_EventMove(object sender, EventMoveEventArgs e)
{
	// check if this row is a courtroom
	if (e.NewResource == null)
	{
		DayPilotScheduler1.DataSource = new DataManager().GetAssignments(DayPilotScheduler1);
		DayPilotScheduler1.DataBind();
		DayPilotScheduler1.UpdateWithMessage("Sorry, this is not a courtroom. The case cannot be scheduled here.");
		return;
	}

	// check for conflicts with existing assignments
	int existing = new DataManager().GetExistingAssignments(e.Value, e.NewStart, e.NewEnd, e.NewResource);
	if (existing > 0)
	{
		DayPilotScheduler1.DataSource = new DataManager().GetAssignments(DayPilotScheduler1);
		DayPilotScheduler1.DataBind();
		DayPilotScheduler1.UpdateWithMessage(String.Format("The case cannot be scheduled here. It conflicts with {0} other assignments.", existing));
		return;
	}

	// check the business hours (8 - 18)
	if (e.NewStart.Hour < 8 || e.NewEnd > new DateTime(e.NewEnd.Year, e.NewEnd.Month, e.NewEnd.Day, 18, 0, 0))
	{
		DayPilotScheduler1.DataSource = new DataManager().GetAssignments(DayPilotScheduler1);
		DayPilotScheduler1.DataBind();
		DayPilotScheduler1.UpdateWithMessage("Sorry, it can't be scheduled outside of the business hours.");
		return;
	}

	// scheduling a new case
	if ((bool)e.Data["external"])
	{
		new DataManager().CreateAssignment(e.NewStart, e.NewEnd, Convert.ToInt32(e.NewResource), Convert.ToInt32(e.Value));
		DayPilotScheduler1.UpdateWithMessage("The assignment has been created.");
	}
	// moving an existing assignment
	else
	{
		new DataManager().MoveAssignment(Convert.ToInt32(e.Value), e.NewStart, e.NewEnd, e.NewResource);
		DayPilotScheduler1.UpdateWithMessage("The assignment has been updated.");
	}

	DayPilotScheduler1.DataSource = new DataManager().GetAssignments(DayPilotScheduler1);
	DayPilotScheduler1.DataBind();

}

DayPilot for JavaScript, ASP.NET WebForms, ASP.NET MVC, Java