public static BindingList<course> getClasses()
        {
            BindingList<course> courses = new BindingList<course>();
            DataTable dtCourses = _getDBCourses();

            foreach (DataRow dr in dtCourses.Rows)
            {
                course tempCourse = new course(dr["Module_code"].ToString(), dr["Module_name"].ToString());

                courses.Add(tempCourse);
            }
            return courses;
        }
        private static List<course> _GetCoursesForStudentNumber(string StudentNumber)
        {
            List<course> courses = new List<course>();
            SqlConnection conn = new SqlConnection(conRegistrationDB);
            conn.Open();
            string query = "SELECT [Module_code],[Module_name] FROM [RegistrationDB].[dbo].[module_registrations] WHERE Student_number = '" + StudentNumber + "' ORDER BY Module_code ";
            SqlCommand cmd = new SqlCommand(query, conn);
            DataTable dt = new DataTable();
            dt.Load(cmd.ExecuteReader());
            foreach (DataRow dr in dt.Rows)
            {
                course newCourse = new course((string)dr["Module_code"], (string)dr["Module_name"]);
                courses.Add(newCourse);
            }
            conn.Close();

            return courses;
        }
Beispiel #3
0
        private void cmbCourseList_TextChanged(object sender, EventArgs e)
        {
            if (lstCourseCodes.Contains(cmbCourseList.Text))
            {
                _selectedCourse = lstCoursesList.Find(c => c.CourseCode == cmbCourseList.Text);
                lblSelectedValue.Text = _selectedCourse.CourseCode;
                lblSelectedValue.Text = lblSelectedValue.Text + " - " + _selectedCourse.Description;
                IdentificationSelectedValue();
                btnAddCourse.Enabled = true;

            }
            else
            {
                btnAddCourse.Enabled = false;
            }
        }
Beispiel #4
0
        private void btnMatchConfirm_Click(object sender, EventArgs e)
        {
            //cancelMatchScan = true;
            bool enrolledForCourse = true;
            bckScanFinger.CancelAsync();
            Application.DoEvents();
            attendanceRecord NewAttendance = new attendanceRecord();
            student ThisMatchedStudent = dlRegistration.GetStudentFromStudentNumber(txtMatchStudentNumber.Text);
            course EnrolledCourse = new course("a","a");

            //See if there were multiple course codes selected.  If more than one selected see for which one the student is registered
            if (cmbCourses.Items.Count >= 1)
            {
                List<course> courses = dlRegistration.getCoursesForStudentNumber(ThisMatchedStudent.StudentNumber);
                List<course> _selectedCourses = new List<course>();
                foreach (course courseItem in cmbCourses.Items)
                {
                    course _tempCourse = new course(courseItem.CourseCode, courseItem.Description);
                    _selectedCourses.Add(_tempCourse);
                }

                foreach (course courseItem in _selectedCourses)
                {
                    foreach (course matchCourse in courses)
                    {
                        if (matchCourse.CourseCode == courseItem.CourseCode)
                            EnrolledCourse = new course(matchCourse.CourseCode, matchCourse.Description);
                    }

                }

                //Lets make sure the student is enrolled in this course
                if (EnrolledCourse.CourseCode == "a")
                {
                    enrolledForCourse = false;
                    course tempCourse = (course)cmbCourses.Items[0];
                    EnrolledCourse = new course(tempCourse.CourseCode, tempCourse.Description);
                }
            }
            else
            {

                course tempCourse = (course)cmbCourses.Items[0];
                EnrolledCourse = new course(tempCourse.CourseCode,tempCourse.Description);
            }

            byte[] templateBuffer = (byte[])fingerprintTemplate.Save();
            if (ThisMatchedStudent.Enrolled)
            {
                //If the student has a registered fingerprint then check the grace setting.
                //We use the score2 pvtComplSyncClass as the grace setting
                //Before we confirm the student as attended we have to check the student number typed in the text box
                //if the textbox student number is the same as the matchedStudentNumber then
                //we can use the ThisMatchedStudent otherwise
                //we have match the student again using the given template
                //and use that as the category and score result
                if (txtMatchStudentNumber.Text == matchedStudentNumber)
                {
                    NewAttendance.FingerAID = matchedFingerID - 1;
                    NewAttendance.FingerAImage = new byte[0];
                    NewAttendance.FingerATemplate = templateBuffer;
                    NewAttendance.FingerBID = 0;
                    NewAttendance.FingerBImage = new byte[0];
                    NewAttendance.FingerBTemplate = new byte[0];
                    NewAttendance.ScanResult = "A";
                    NewAttendance.score1 = matchedScore;
                    NewAttendance.score2 = 0;
                    strConfirmMessage = "Identified: " + ThisMatchedStudent.FirstName + " " + ThisMatchedStudent.LastName + ". Student number: " + ThisMatchedStudent.StudentNumber;
                    lblConfirmMessage.ForeColor = Color.Green;
                }
                else
                {
                    //The student changed the student number.  This means that we now have to first see if the template scanned
                    //belong to the new studentnumber
                    if (VerifyFingerprint(ThisMatchedStudent, fingerprintTemplate))
                    {
                        NewAttendance.FingerAID = matchedFingerID - 1;
                        NewAttendance.FingerAImage = new byte[0];
                        NewAttendance.FingerATemplate = templateBuffer;
                        NewAttendance.FingerBID = 0;
                        NewAttendance.FingerBImage = new byte[0];
                        NewAttendance.FingerBTemplate = new byte[0];
                        if (enrolledForCourse)
                        {
                            NewAttendance.ScanResult = "A";
                        }
                        else
                        {
                            NewAttendance.ScanResult = "B";
                        }

                        NewAttendance.score1 = matchedScore;
                        NewAttendance.score2 = 0;
                        strConfirmMessage = "Identified: " + ThisMatchedStudent.FirstName + " " + ThisMatchedStudent.LastName + ". Student number: " + ThisMatchedStudent.StudentNumber;
                        lblConfirmMessage.ForeColor = Color.Green;
                    }
                    else
                    {
                        //If the template does not belong to the new student then we need to look at the grace
                        //If grace is anything less than 3 then we add the matched FingedID and template, but with a score
                        //of 0 and a ScanResult of "C"

                        int grace = 0;
                        bool converted = Int32.TryParse(ThisMatchedStudent.CardHistory, out grace);
                        if (converted)
                        {
                            if (grace < 3)
                            {
                                NewAttendance.FingerAID = 6;
                                NewAttendance.FingerAImage = new byte[0];
                                NewAttendance.FingerATemplate = templateBuffer;
                                NewAttendance.FingerBID = 0;
                                NewAttendance.FingerBImage = new byte[0];
                                NewAttendance.FingerBTemplate = new byte[0];
                                NewAttendance.ScanResult = "C";
                                NewAttendance.score1 = 0;
                                NewAttendance.score2 = 0;

                                strConfirmMessage = "No Match: " + ThisMatchedStudent.FirstName + " " + ThisMatchedStudent.LastName + ". Student number: " + ThisMatchedStudent.StudentNumber;
                                lblConfirmMessage.ForeColor = Color.Red;
                                //We have to update the registration system with the grace number
                            }
                            else
                            {
                                //Fingerprints didn't match give it a "D" score
                                NewAttendance.FingerAID = 0;
                                NewAttendance.FingerAImage = new byte[0];
                                NewAttendance.FingerATemplate = new byte[0];
                                NewAttendance.FingerBID = 0;
                                NewAttendance.FingerBImage = new byte[0];
                                NewAttendance.FingerBTemplate = new byte[0];
                                NewAttendance.ScanResult = "D";
                                NewAttendance.score1 = 0;
                                NewAttendance.score2 = 0;
                                strConfirmMessage = "No Match: " + ThisMatchedStudent.FirstName + " " + ThisMatchedStudent.LastName + ". Student number: " + ThisMatchedStudent.StudentNumber;
                                lblConfirmMessage.ForeColor = Color.Red;
                            }

                        }
                        else
                        {   //If the conversion failed then there were no grace period then we can update the user

                            NewAttendance.FingerAID = 6;
                            NewAttendance.FingerAImage = new byte[0];
                            NewAttendance.FingerATemplate = templateBuffer;
                            NewAttendance.FingerBID = 0;
                            NewAttendance.FingerBImage = new byte[0];
                            NewAttendance.FingerBTemplate = new byte[0];
                            NewAttendance.ScanResult = "C";
                            NewAttendance.score1 = 0;
                            NewAttendance.score2 = 0;
                            strConfirmMessage = "No Match: " + ThisMatchedStudent.FirstName + " " + ThisMatchedStudent.LastName + ". Student number: " + ThisMatchedStudent.StudentNumber;
                            lblConfirmMessage.ForeColor = Color.Red;
                            //We have to update the registration system with the grace number
                        }
                    }

                }

                //If the grace setting is anything less than 3 then mark the student's record as graced
                //and increment the grace
                NewAttendance.StudentNumber = ThisMatchedStudent.StudentNumber;
                NewAttendance.CardNumber = ThisMatchedStudent.CardNumber;
                NewAttendance.AuditNumber = "";
                NewAttendance.ClassTime = DateTime.Now;
                NewAttendance.CourseCode = EnrolledCourse.CourseCode;

                NewAttendance.TimeStamp = DateTime.Now;
                NewAttendance.lat = "";
                NewAttendance.lon = "";
            }
            else
            {
                //What happens if the student is not enrolled?

                //If the student is not fingerprint enrolled then create a record in the registration DB for the user
                //and mark the grace as 1
                NewAttendance.StudentNumber = txtMatchStudentNumber.Text;
                NewAttendance.CardNumber = "";
                NewAttendance.AuditNumber = "";
                NewAttendance.ClassTime = DateTime.Now;
                NewAttendance.CourseCode = EnrolledCourse.CourseCode;
                NewAttendance.FingerAID = 6;
                NewAttendance.FingerAImage = new byte[0];
                NewAttendance.FingerATemplate = templateBuffer;
                NewAttendance.FingerBID = 0;
                NewAttendance.FingerBImage = new byte[0];
                NewAttendance.FingerBTemplate = new byte[0];
                NewAttendance.ScanResult = "X";
                NewAttendance.score1 = 0;
                NewAttendance.TimeStamp = DateTime.Now;
                NewAttendance.lat = "";
                NewAttendance.lon = "";

                universityStudent tempStudent = new universityStudent();
                tempStudent = dlRegistration.GetUniversityStudentFromStudentNumber(txtMatchStudentNumber.Text);

                if (tempStudent.FirstName != null || tempStudent.LastName != null)
                {

                    strConfirmMessage = "Fingerprint not enrolled: " + ThisMatchedStudent.FirstName + " " + ThisMatchedStudent.LastName + ". Student number: " + ThisMatchedStudent.StudentNumber;
                    lblConfirmMessage.ForeColor = Color.Orange;
                }
                else
                {
                    strConfirmMessage = "Fingerprint not enrolled: Student number: " + ThisMatchedStudent.StudentNumber;
                    lblConfirmMessage.ForeColor = Color.Orange;
                }

                //We have to now register the student's fingerprints here

            }

            dlExamID.InsertAttendanceRecord(NewAttendance);

            //Prepare the screen for next student
            btnMatchConfirm.Enabled = false;
            txtMatchStudentNumber.Enabled = false;
            lblMatchResult.Text = "";
            txtMatchStudentNumber.Text = "";
            nfView1.Template = null;
            nfView1.Image = null;
            nfView1.ResultImage = null;
            lblIdentifyActionMessage.Text = "Please scan right index finger";

            loadConfirmMessage();
        }