private void LoadStudents() { // First time in, load the dropdown with students using (AttendanceModel.AttendanceEntities myEntities = new AttendanceModel.AttendanceEntities()) { // 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), chkOnlyUnexcused.Checked); } }
private void LoadStudents() { using (AttendanceModel.AttendanceEntities myEntities = new AttendanceModel.AttendanceEntities()) { // Get the data for the listview, filtering on the studentID and the type of attendance var students = from student in myEntities.Students orderby student.LastName, student.FirstName select student; // 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()); } }
private void LoadSections() { using (AttendanceModel.AttendanceEntities myEntities = new AttendanceModel.AttendanceEntities()) { // Get the data for the listview, filtering on the studentID and the type of attendance var sections = from section in myEntities.Sections select new { Section = section.Name, Hours = section.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()); } }
private void LoadSections() { using (AttendanceModel.AttendanceEntities myEntities = new AttendanceModel.AttendanceEntities()) { // Get the data for the gridview var sections = from s in myEntities.Sections join r in myEntities.Registrations on s.SectionID equals r.SectionID group s by s.Name into grouped select new { SectionName = grouped.Key, StudentCount = grouped.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()); } }
/// <summary> /// Load the ListView with the student passed /// </summary> /// <param name="studentID"></param> private void LoadClassMeetings(int studentID, bool onlyUnexcused) { using (AttendanceModel.AttendanceEntities myEntities = new AttendanceModel.AttendanceEntities()) { // Get the data for the listview, filtering on the studentID and the type of attendance // The query need to join ClassMeetings to Calendars and ClassMeetings to Attendances var classMeeting = from m in myEntities.ClassMeetings join c in myEntities.Calendars on m.CalendarID equals c.CalendarID join a in myEntities.Attendances on m.AttendanceID equals a.AttendanceID where m.StudentID == studentID orderby c.Date select new { Date = c.Date, Attendance = a.AttendanceID }; if (onlyUnexcused) { // Put code here to futher filter classMeeting classMeeting = from c in classMeeting where c.Attendance == 3 select c; } // 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()); } }
protected void Button1_Click(object sender, EventArgs e) { if (txtEmail.Text != "" && txtPassword.Text != "") { using (AttendanceModel.AttendanceEntities myEntities = new AttendanceModel.AttendanceEntities()) { var user = from user1 in myEntities.AppUsers where user1.EMail == txtEmail.Text && user1.Password == txtPassword.Text select user1; if (user.Count() == 1) { System.Web.Security.FormsAuthentication.RedirectFromLoginPage(txtEmail.Text, true); } else { lblCantLogIn.Visible = true; ViewState["TimeOfFailedLogin"] = DateTime.Now.ToString(); } } } }