I need to display user schedule for a week, if a faculty is assigned for different batches in a week it should display the particular faculty's schedules for that week when the faculty login.

this is the query I used, it displays all the faculty's schedule. I need to display the particular faculty's schedule for each faculty.

 string faculty1 = User.Identity.Name;
 string faculty2 = User.Identity.Name;
 string faculty3 = User.Identity.Name;
 string faculty4 = User.Identity.Name;
 string faculty5 = User.Identity.Name;
  using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
   {
     SqlDataAdapter da = new SqlDataAdapter("select DISTINCT datedif,max(subject1+'/'+ batch) as subject1,max(faculty1) as faculty1, max(subject2+'/'+  batch) as subject2,max(faculty2) as faculty2,max(subject3+'/'+ batch) as subject3,max(faculty3) as faculty3,max(subject4+'/'+ batch) as subject4,max(faculty4) as faculty4,max(subject5+'/'+ batch) as subject5,max(faculty5) as faculty5 from test where datedif between '" + fromdate.Text + "' and '" + todate.Text + "' and session='" + ddlsession.SelectedItem + "' and ((CASE WHEN faculty1!='" + User.Identity.Name + "' THEN '" + DBNull.Value + "' ELSE '" + User.Identity.Name + "' END IS NOT NULL) and (CASE WHEN faculty2!='" + User.Identity.Name + "' THEN '" + DBNull.Value + "' ELSE '" + User.Identity.Name + "' END IS NOT NULL) and (CASE WHEN faculty3!='" + User.Identity.Name + "' THEN '" + DBNull.Value + "' ELSE '" + User.Identity.Name + "' END IS NOT NULL) and (CASE WHEN faculty4!='" + User.Identity.Name + "' THEN '" + DBNull.Value + "' ELSE '" + User.Identity.Name + "' END IS NOT NULL) and (CASE WHEN faculty5!='" + User.Identity.Name + "' THEN '" + DBNull.Value + "' ELSE '" + User.Identity.Name + "' END IS NOT NULL))  group by datedif", con);
     DataTable dt = new DataTable("dt");
     da.Fill(dt);
     Viewsubjects.DataSource = dt;
     Viewsubjects.DataBind();
 } 

Related posts

Recent Viewed