public StudentAttendanceItem GetStudentAttendance(StudentAttendanceParameter parameter)
        {
            if (parameter.IntakeID.Equals("Select Intake"))
            {
                return(null);
            }
            StudentAttendanceItem studentAttendance = new StudentAttendanceItem();
            int presentTimes          = 0;
            int absentTimes           = 0;
            int totalClasses          = 0;
            var studentAttendanceItem = _studentAttendanceDal.GetStudentAttendace(parameter);

            if (studentAttendanceItem.Count == 0)
            {
                return(null);
            }
            presentTimes = studentAttendanceItem.ToList().Where(x => x.presenceStatus == 1).Count();
            absentTimes += studentAttendanceItem.ToList().Where(x => x.presenceStatus == 2).Count();
            absentTimes += studentAttendanceItem.ToList().Where(x => x.presenceStatus == 3).Count();
            totalClasses = presentTimes + absentTimes;
            double percentage = 0;

            if (presentTimes != 0)
            {
                percentage = ((double)presentTimes / (double)totalClasses) * 100;
            }
            else
            {
                percentage = 0;
            }

            if (percentage < 80)
            {
                studentAttendance.isAttendancePassed = true;
            }
            else
            {
                studentAttendance.isAttendancePassed = false;
            }

            studentAttendance.Attendance   = percentage.ToString("0.##") + "%" + "(" + presentTimes + "/" + totalClasses + ")";
            studentAttendance.LecturerName = studentAttendanceItem[0].LecturerName;
            studentAttendance.SubjectName  = studentAttendanceItem[0].SubjectName;

            return(studentAttendance);
        }
예제 #2
0
 public List <StudentAttendanceItem> GetStudentAttendace(StudentAttendanceParameter parameter)
 {
     using (var context = new ApuAttendanceContext())
     {
         var studentAttendanceItem = from sa in context.StudentAttendances
                                     join
                                     sbj in context.Subjects on sa.SubjectID equals sbj.SubjectID
                                     join l in context.Lecturers on sa.LecturerID equals l.LecturerID
                                     where sa.IntakeID == parameter.IntakeID && sa.SubjectID == parameter.SubjectID && sa.StudentID == parameter.StudentID
                                     select new StudentAttendanceItem
         {
             SubjectName    = sbj.SubjectName,
             LecturerName   = l.FirstName + " " + (String.IsNullOrEmpty(l.MiddleName) ? "" : l.MiddleName + " ") + l.LastName,
             presenceStatus = sa.PresenceStatusID
         };
         return(studentAttendanceItem.ToList());
     }
 }
예제 #3
0
        private void PopulateFlpAttendance()
        {
            List <CourseSubjectItem> courseSubjects = _courseSubjectService.GetStudentCourseByStudentID(Program.student.StudentID);

            flpAttendance.Controls.Clear();
            foreach (var courseSubject in courseSubjects)
            {
                StudentAttendanceParameter parameter = new StudentAttendanceParameter {
                    IntakeID = cbxIntake.SelectedValue.ToString(), StudentID = Program.student.StudentID, SubjectID = courseSubject.SubjectID
                };

                StudentAttendanceItem studentAttendanceItem = _studentAttendanceService.GetStudentAttendance(parameter);
                if (studentAttendanceItem != null)
                {
                    Panel holderPanel = new Panel();

                    holderPanel.BackColor   = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
                    holderPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                    holderPanel.Dock        = System.Windows.Forms.DockStyle.Top;
                    holderPanel.Anchor      = AnchorStyles.None;
                    holderPanel.Name        = "holderPanel";
                    holderPanel.Size        = new System.Drawing.Size(320, 95);
                    holderPanel.TabIndex    = 0;

                    Label lblSubjectName = new Label();
                    lblSubjectName.Dock      = DockStyle.Fill;
                    lblSubjectName.Font      = new System.Drawing.Font("MS Gothic", 10.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    lblSubjectName.ForeColor = System.Drawing.SystemColors.ButtonFace;
                    lblSubjectName.Name      = "lblSubjectName";
                    lblSubjectName.Size      = new System.Drawing.Size(holderPanel.ClientSize.Width, 20);
                    lblSubjectName.TabIndex  = 0;
                    lblSubjectName.TextAlign = ContentAlignment.MiddleCenter;
                    lblSubjectName.Text      = studentAttendanceItem.SubjectName;

                    Panel panelTop = new Panel();
                    panelTop.BackColor = System.Drawing.Color.DimGray;
                    panelTop.Controls.Add(lblSubjectName);
                    panelTop.Dock     = System.Windows.Forms.DockStyle.Top;
                    panelTop.Location = new System.Drawing.Point(0, 0);
                    panelTop.Name     = "panelTop";
                    panelTop.Size     = new System.Drawing.Size(300, 18);
                    panelTop.TabIndex = 1;

                    Label lblAttendance = new Label();
                    lblAttendance.Anchor    = System.Windows.Forms.AnchorStyles.None;
                    lblAttendance.Font      = new System.Drawing.Font("MS Gothic", 14.25F, FontStyle.Bold);
                    lblAttendance.ForeColor = System.Drawing.SystemColors.ButtonFace;
                    lblAttendance.Location  = new System.Drawing.Point(-1, 60);
                    lblAttendance.Name      = "lblAttendance";
                    lblAttendance.Size      = new System.Drawing.Size(holderPanel.ClientSize.Width, 17);
                    lblAttendance.TabIndex  = 2;
                    lblAttendance.Text      = "Attendance: " + studentAttendanceItem.Attendance;
                    lblAttendance.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;

                    if (studentAttendanceItem.isAttendancePassed)
                    {
                        lblAttendance.ForeColor = Color.DarkRed;
                    }


                    Label lblLecturerName = new Label();
                    lblLecturerName.Font      = new System.Drawing.Font("MS Gothic", 14.25F, FontStyle.Bold);
                    lblLecturerName.ForeColor = System.Drawing.SystemColors.ButtonFace;
                    lblLecturerName.Location  = new System.Drawing.Point(3, 32);
                    lblLecturerName.Name      = "lblLecturerName";
                    lblLecturerName.Size      = new System.Drawing.Size(holderPanel.ClientSize.Width, 17);
                    lblLecturerName.TabIndex  = 1;
                    lblLecturerName.Text      = "Lecturer: " + studentAttendanceItem.LecturerName;
                    lblLecturerName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;



                    holderPanel.Controls.Add(lblAttendance);
                    holderPanel.Controls.Add(lblLecturerName);
                    holderPanel.Controls.Add(panelTop);
                    flpAttendance.Controls.Add(holderPanel);
                }
            }
        }