private void AllStudentRecord_Load(object sender, EventArgs e) { List <string[]> items = new List <string[]>(); dynamic attendanceAll = new AttendanceTable().All(); if (attendanceAll != null) { foreach (var attendance in attendanceAll) { string studentName = new StudentTable().GetStudentName(attendance.matric_number.ToString()); items.Add(new string[] { studentName, attendance.matric_number.ToString() }); } } // Convert to DataTable. DataTable table = ConvertListToDataTable(items); dataGridView1.DataSource = table; }
private void buttonView_Click(object sender, EventArgs e) { List <string[]> items = new List <string[]>(); string dateTime = comboBoxDate.SelectedItem.ToString(); dynamic attendanceByDate = new AttendanceTable().All(where : String.Format("date_taken='{0}'", dateTime)); if (attendanceByDate != null) { foreach (var attendance in attendanceByDate) { string studentName = new StudentTable().GetStudentName(attendance.matric_number.ToString()); items.Add(new string[] { studentName, attendance.matric_number.ToString() }); } } // Convert to DataTable. DataTable table = ConvertListToDataTable(items); dataGridView1.DataSource = table; }
private void button2_Click(object sender, EventArgs e) { try { //Trained face counter ContTrain = ContTrain + 1; //Get a gray frame from capture device gray = grabber.QueryGrayFrame().Resize(320, 240, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); //Face Detector MCvAvgComp[][] facesDetected = gray.DetectHaarCascade( face, 1.2, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20)); //Action for each element detected foreach (MCvAvgComp f in facesDetected[0]) { TrainedFace = currentFrame.Copy(f.rect).Convert <Gray, byte>(); break; } //resize face detected image for force to compare the same size with the //test image with cubic interpolation type method TrainedFace = result.Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); trainingImages.Add(TrainedFace); labels.Add(textBoxMatricNumber.Text); //Show face added in gray scale imageBox1.Image = TrainedFace; //Write the number of triained faces in a file text for further load File.WriteAllText(Application.StartupPath + "/TrainedFaces/TrainedLabels.txt", trainingImages.ToArray().Length.ToString() + "%"); //Write the labels of triained faces in a file text for further load for (int i = 1; i < trainingImages.ToArray().Length + 1; i++) { trainingImages.ToArray()[i - 1].Save(Application.StartupPath + "/TrainedFaces/face" + i + ".bmp"); File.AppendAllText(Application.StartupPath + "/TrainedFaces/TrainedLabels.txt", labels.ToArray()[i - 1] + "%"); } StudentTable student = new StudentTable(); dynamic studentRecord = new ExpandoObject(); studentRecord.first_name = textBoxFirstName.Text; studentRecord.last_name = textBoxLastName.Text; studentRecord.matric_number = textBoxMatricNumber.Text; student.RegisterStudent(studentRecord); MessageBox.Show(textBoxMatricNumber.Text + "´s face detected and added.", "Training OK", MessageBoxButtons.OK, MessageBoxIcon.Information); conn = new OleDbConnection(); conn.ConnectionString = "provider=Microsoft.ACE.OLEBD.12.0; Data Source = |DataDirectory|/facialRec.accdb"; try { conn.Open(); string query; query = "INSERT INTO student(matno,fullname,department,coursecode,semester) VALUES ('" + textBoxMatricNumber.Text + "','" + (textBoxFirstName.Text + " " + textBoxLastName.Text) + "','" + combodept.SelectedIndex + "', '" + textcc.Text + "','" + combosms.SelectedIndex + "')"; cmd = new OleDbCommand(query, conn); rd = cmd.ExecuteReader(); conn.Close(); } catch (OleDbException ex) { MessageBox.Show(ex.Message); } finally { conn.Dispose(); } } catch { MessageBox.Show("Wait For Face To Be Detected First", "Training Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }