In my table Event i have eventstart and eventend in this format (2012-09-18 12:30:00.000), now i like to have eventdatestart (2012-09-18) in one column and eventtimestart (12:30:00.000) in other column. I will make this in my table Event, but I'm not sure that i will can display events? Can i make this, and to display the event in the calendar ? What change i need to made in my code, can you help me?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DayPilotCalendar1.StartDate = DayPilot.Utils.Week.FirstDayOfWeek(new DateTime(2012, 09, 17));
DayPilotCalendar1.DataSource = dbGetEvents(DayPilotCalendar1.StartDate, DayPilotCalendar1.Days);
DataBind();
}
}
protected DataTable dbGetEvents(DateTime start, int days)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = @"Data Source=.\SQLEXPRESS;Initial Catalog=Korisnik;Integrated Security=True";
SqlDataAdapter da = new SqlDataAdapter("SELECT e.id, e.name, e.eventstart, e.eventend, p.ime FROM Event e INNER JOIN RegistracijaKorisnik p ON e.PersonID = p.id WHERE NOT ((e.eventend <= @start) OR (e.eventstart >= @end ))", con);
da.SelectCommand.Parameters.AddWithValue("start", start);
da.SelectCommand.Parameters.AddWithValue("end", start.AddDays(days));
DataTable dt = new DataTable();
da.Fill(dt);
return dt;
}
private static DateTime firstDayOfWeek(DateTime day, DayOfWeek weekStarts)
{
DateTime d = day;
while (d.DayOfWeek != weekStarts)
{
d = d.AddDays(-1);
}
return d;
}
protected void DayPilotCalendar1_BeforeEventRender(object sender, DayPilot.Web.Ui.Events.Calendar.BeforeEventRenderEventArgs e)
{
// string color = e.DataItem["color"] as string;
//if (!String.IsNullOrEmpty(color))
// {
// e.DurationBarColor = color;
// }
e.InnerHTML += "From: " + e.DataItem["ime"] as string;
}
}
}