Esempio n. 1
0
 private void btnGet_Click(object sender, EventArgs e)
 {
     students = students.GetAll();
     this.dgvStudent.DataSource = students.List;
 }
Esempio n. 2
0
        protected void btnEditAttendance_Click(object sender, EventArgs e)
        {
            Instructor instructor = (Instructor)Session["Instructor"];
            TermClass  termclass  = new TermClass();
            Student    student    = new Student();
            Section    section    = new Section();
            Class      clas       = new Class();
            Attendance attendance = new Attendance();

            List <Student> sList       = new List <Student>();
            TermClassList  tClassList  = new TermClassList();
            StudentList    studentList = new StudentList();
            DataTable      dt          = new DataTable();

            tClassList  = tClassList.GetAll(); // Get Term classes
            studentList = studentList.GetAll();


            dt.Columns.Add("Student Name");
            dt.Columns.Add("Class Name");
            dt.Columns.Add("Instructor Name");
            dt.Columns.Add("Section Name");
            dt.Columns.Add("Total Absences");
            //dt.Columns.Add(new DataColumn("Absent", typeof(CheckBox)));

            Guid sectionID = new Guid(ddlSections.SelectedValue);
            Guid classID   = new Guid(ddlSelectClass.SelectedValue);

            foreach (TermClass tc in tClassList.List)
            {
                if (tc.InstructorId == instructor.Id)
                {
                    if (tc.SectionId == sectionID)
                    {
                        if (tc.ClassId == classID)
                        {
                            clas       = clas.GetById(tc.ClassId);
                            student    = student.GetById(tc.StudentId);
                            attendance = attendance.GetByStudentId(tc.StudentId);
                            string className      = clas.Name;
                            string instructorName = instructor.FirstName + " " + instructor.LastName;
                            string studentName    = student.FullName;
                            string sectionName    = ddlSections.SelectedItem.ToString();
                            int    totalAbsences  = attendance.TotalAbsences;



                            dt.Rows.Add(studentName, className, instructorName, sectionName, totalAbsences);
                            foreach (Student stud in studentList.List)
                            {
                                if (stud.Id == tc.StudentId)
                                {
                                    sList.Add(stud);
                                }
                            }
                        }
                    }
                }
            }
            if (sList != null)
            {
                ddlSelectStudent.DataSource = sList;
                ddlSelectStudent.DataBind();
                ddlSelectStudent.Items.Add("Choose Student");
                ddlSelectStudent.SelectedValue = "Choose Student";
                ddlSelectStudent.Visible       = true;
                btnMarkAbsent.Visible          = true;
            }
            Session["SaveTable"] = dt;

            GridView1.DataSource = dt;
            GridView1.DataBind();
        }