All of my three events in the timetable is in green colour. I would like to for etc to have red for monday, yellow for tuesday and for the other days to have different colour too. Attached are my images, there are limited event handler so hope it can be solved too like my previous question.
public partial class number2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstWorkingDayOfWeek(new DateTime(2014, 04, 03));
//DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstWorkingDayOfWeek(DateTime.Now.AddDays(-(int)DateTime.Now.DayOfWeek).Date);
DayPilotCalendar1.DataSource = dbGetEvents(DayPilotCalendar1.StartDate, DayPilotCalendar1.Days);
DataBind();
}
}
private DataTable dbGetEvents(DateTime start, int days)
{
string constr = ConfigurationManager.ConnectionStrings["ProjectConnectionString"].ConnectionString;
SqlDataAdapter da = new SqlDataAdapter("SELECT ID, PURPOSE, [START_DATE], [END_DATE], [START_TIME], [END_TIME] FROM [Schedule]", constr);
da.SelectCommand.Parameters.AddWithValue("start", start);
da.SelectCommand.Parameters.AddWithValue("end", start.AddDays(days));
DataTable dt = new DataTable();
da.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i]["START_DATE"] = CombineDateAndTime(dt.Rows[i]["START_DATE"], dt.Rows[i]["START_TIME"]);
dt.Rows[i]["END_DATE"] = CombineDateAndTime(dt.Rows[i]["END_DATE"], dt.Rows[i]["END_TIME"]);
}
return dt;
}
public static DateTime CombineDateAndTime(object date, object time)
{
if (date == null)
{
// Add some logic for this scenario. Here are 2 examples:
//throw new ArgumentNullException("date");
//date = DateTime.MaxValue;
}
if (time == null)
{
// Add some logic for this scenario.
//throw new ArgumentNullException("time");
//time = 0;
}
DateTime dt = Convert.ToDateTime(date);
float hoursAndMinutes = Convert.ToInt32(time);
return CombineDateAndTime(dt, hoursAndMinutes);
}
public static DateTime CombineDateAndTime(DateTime date, float time)
{
int hours = Convert.ToInt32(Math.Round((decimal)time / 100, MidpointRounding.AwayFromZero));
float remainder = time - (hours * 100);
int minutes = Convert.ToInt32(Math.Round((decimal)remainder, MidpointRounding.AwayFromZero));
DateTime returnDate = date.Date.AddHours(hours).AddMinutes(minutes);
return returnDate;
}
}