Esempio n. 1
0
    private void LoadStudents()
    {
        using (Lab12Entities myEntities = new Lab12Entities())
        {
            // Set the studentSelect object with the results of the LINQ query
            var studentSelect = from student in myEntities.Students
                                orderby student.LastName
                                select new
            {
                ID   = student.StudentID,
                Name = student.LastName + ", " + student.FirstName
            };

            //  Load the dropdown with the query results.
            ddlStudent.DataSource = studentSelect.ToList();
            // Specify which data columns show up in the dropdown
            ddlStudent.DataValueField = "ID";
            ddlStudent.DataTextField  = "Name";
            ddlStudent.DataBind();
            // Preselect the first entry in the dropdown.
            ddlStudent.SelectedIndex = 0;

            // Load the listview with the first student in the dropdown.
            LoadClassMeetings(int.Parse(ddlStudent.SelectedValue));
        }
    }
Esempio n. 2
0
    private void LoadStudents()
    {
        using (Lab12Entities myEntities = new Lab12Entities())
        {
            // Code your LINQ Statment here then uncomment the lines below
            var students = from st in myEntities.Students
                           orderby st.LastName
                           select new { st.LastName, st.FirstName, st.ScholarShip, st.Enrolled };

            //// Load the listview with the data.
            grvStudents.DataSource = students.ToList();
            grvStudents.DataBind();

            //// Set the record count into the label
            lblRecordsFound.Text = string.Format("Records Found: {0}", students.Count());
        }
    }
Esempio n. 3
0
    private void LoadSections()
    {
        using (Lab12Entities myEntities = new Lab12Entities())
        {
            // Code your LINQ Statment here then uncomment the lines below
            var sections = from sl in myEntities.Sections

                           select new { Section = sl.Name, Hours = sl.CreditHours };



            //// Load the listview with the data.
            grvSections.DataSource = sections.ToList();
            grvSections.DataBind();

            //// Set the record count into the label
            lblRecordsFound.Text = string.Format("Records Found: {0}", sections.Count());
        }
    }
Esempio n. 4
0
    /// <summary>
    /// Load the ListView with the student passed
    /// </summary>
    /// <param name="studentID"></param>
    private void LoadClassMeetings(int studentID)
    {
        using (Lab12Entities myEntities = new Lab12Entities())
        {
            // Code your LINQ Statment here then uncomment the lines below
            var classMeeting = from cm in myEntities.ClassMeetings
                               join calendar in myEntities.Calendars on cm.CalendarID equals calendar.CalendarID
                               join name in myEntities.Attendances on cm.AttendanceID equals name.AttendanceID
                               where cm.StudentID == studentID
                               select new { calendar.Date, Attendance = name.Name };

            //// Load the listview with the data.
            grvAttendance.DataSource = classMeeting.ToList();
            grvAttendance.DataBind();

            //// Set the record count into the label
            lblRecordsFound.Text = string.Format("Records Found: {0}", classMeeting.Count());
        }
    }
Esempio n. 5
0
    private void LoadSections()
    {
        using (Lab12Entities myEntities = new Lab12Entities())
        {
            // Code your LINQ Statment here then uncomment the lines below
            var sections = from s in myEntities.Sections
                           join e in myEntities.Registrations on s.SectionID equals e.SectionID
                           group s by s.Name into e
                           select new { SectionName = e.Key, StudentCount = e.Count() };



            //// Load the listview with the data.
            grvSections.DataSource = sections.ToList();
            grvSections.DataBind();

            //// Set the record count into the label
            lblRecordsFound.Text = string.Format("Records Found: {0}", sections.Count());
        }
    }