In the default.aspx i have the checkboxlist that i fill in the load :
DataTable dt = new DataTable();
SqlConnection con = new SqlConnection("Data Source=server;Initial Catalog=base;Persist Security Info=True;User ID=sa;Password=pasword");
SqlDataAdapter sda = new SqlDataAdapter();
SqlCommand cmd = new SqlCommand("select prénom from cadres", con);
cmd.Connection = con;
con.Open();
sda.SelectCommand = cmd;
sda.Fill(dt);
CheckBoxList1.Items.Clear();
CheckBoxList1.DataSource = dt.DefaultView;
CheckBoxList1.DataTextField = "prénom";
CheckBoxList1.DataValueField = "prénom";
CheckBoxList1.AppendDataBoundItems = true;
CheckBoxList1.DataBind();
and the calendar created by jquery so in the markup i have just :
<div id="calendar" >
</div>
I have a class separated called EVENTDAO where's i have my query to show the calendar :
public static List<CalendarEvent> getEvents(DateTime start, DateTime end)
{
List<CalendarEvent> events = new List<CalendarEvent>();
SqlConnection con = new SqlConnection(connectionString);
string sql;
sql ="select D.date_deb as deb,D.date_fin as fin ,M.code as code,M.Objet as ob,M.type_mission as t,M.ville," +
" M.Etat_mission,prénom,'Mission' AS type,S.nom from Mission_date D inner join missions M on " +
" M.code=D.code_mission inner join mission_cadre C on D.code_mission=C.code_mission inner join cadres on cadres.code=C.code_cadre" +
" join sociétés S on S.code=M.code_client " +
" where ((D.Date_deb>='" + start + "' and D.Date_deb<='" + end + "') OR (D.Date_fin>='" + start + "' and D.Date_fin<='" + end + "')) and " +
" C.code_cadre In (select code from cadres ) union select tache_date.date_deb,tache_date.date_fin ,taches.code,Objet,type_tache,'',Etat_tache,prénom,'Tache' AS type,'' from tache_date " +
"inner join taches on taches.code=tache_date.code_tache inner join tache_cadre C on tache_date.code_tache=C.code_tache inner join cadres on cadres.code=C.code_cadre where " +
"((tache_date.Date_deb>='" + start + "' and tache_date.Date_deb<='" + end + "') OR (tache_date.Date_fin>='" + start + "' and tache_date.Date_fin<='" + end + "')) and C.code_cadre In (select code from cadres ) " +
"union select Réunions.DateRéunion + Réunions.HeureDébut,Réunions.DateRéunion + Réunions.HeureFin ,Réunions.code,Réunions.Objet,''," +
" '','',prénom,'Réunion' AS type,'' from Réunions inner join réunion_cadre on réunions.code=réunion_cadre.code_réunion inner join cadres T on T.code=réunion_cadre.code_cadre where " +
" ((Réunions.DateRéunion>='" + start + "' and Réunions.DateRéunion<='" + end + "') OR (Réunions.DateRéunion>='" + start + "' and Réunions.DateRéunion<='" + end + "')) and réunion_cadre.code_cadre In (select code from cadres )" +
" union select CD.date_deb,CD.date_fin,CC.code,prénom,type_conge,'',CC.etat_conge,prénom,'Congé' AS type,'' " +
" from conge_date CD inner join conges CC on CD.code_conge=CC.code inner join cadres CR on CC.code_cadre=CR.code " +
"where ((CD.Date_deb>='" + start + "' " +
" and CD.Date_deb<='" + end + "') OR (convert(datetime, CD.date_fin, 103) between " +
" convert(datetime, '" + start + "', 103) and " +
" convert(datetime, '" + end + " ', 103)) ) and code_cadre In (select code from cadres ) " ;
SqlCommand cmd = new SqlCommand(sql, con);
// cmd.Parameters.AddWithValue("@start", start);
// cmd.Parameters.AddWithValue("@end", end);
using (con)
{
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
CalendarEvent cevent = new CalendarEvent();
// cevent.id = (Int32 )reader["code"];
cevent.title = (string)reader[8] + ":" + "|" + unicode_iso8859((string)reader[7]) + "|" + unicode_iso8859((string)reader[9]) + "|" + unicode_iso8859((string)reader[6]) + "|" + unicode_iso8859((string)reader[4]) + "|" + unicode_iso8859((string)reader[3]) + "|" + (string)reader[5] + "|";
cevent.description = (string)reader[8] + ":" + "|" + (string)reader[7] + "|" + (string)reader[9] + "|" + (string)reader[6] + "|" + (string)reader[4] + "|" + (string)reader[3] + "|" + (string)reader[5] + "|";
cevent.start = (DateTime)reader["deb"];
cevent.end = (DateTime)reader["fin"];
events.Add(cevent);
}
}
return events;
}
So my question is it possible to detect selected checkboxlist items in default.aspx and to pass it to the class evendao in order to use it in the query to replace the clause In (select code from cadres ) by selected items
The code is downloadable from the link in first thread i just change the ado query and added a checkboxlist
Regards