This tutorial shows how to create a courtroom schedule ASP.NET application using DayPilot Scheduler control.
Tutorial:
The tutorial was updated:
Features
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();
}