private void radButton4_Click(object sender, EventArgs e) { int size = -1; OpenFileDialog openFileDialog1 = new OpenFileDialog(); //prompts the user to open a file DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog. indicate the return value of the dialog box if (result == DialogResult.OK) // Test result. if the OK button is pressed { string file = openFileDialog1.FileName; //set the string containing the file name selected in the file dialog box txtFileName.Text = file.ToString(); //display the file path in the textbox paper = file; try { string text = File.ReadAllText(file); //opens a text file, read all lines in the text file and then closes it size = text.Length; } catch (IOException) { } panel1.BackgroundImage = System.Drawing.Image.FromFile(paper); //sets the background image of the panel this.Invalidate(); //redraw the control } examId = int.Parse(ddlExamId.SelectedValue.ToString()); //selected exam id from the combo box DataSet dsM = DB_Connect.ExecuteQuery("SELECT marking_scheme_id FROM mcq_marking_scheme_tab WHERE exam_id = '" + examId + "';"); markingSchemeId = int.Parse(dsM.Tables[0].Rows[0][0].ToString()); //get the marking scheme id corresponding to the selected exam id from the database }
public Candidate getCandidate(int id) { //int c_id = 2; DataSet ds = DB_Connect.ExecuteQuery("SELECT * FROM candidate_tab WHERE candidate_id = " + id + ";"); int cid = int.Parse(ds.Tables[0].Rows[0][0].ToString()); string cfullName = ds.Tables[0].Rows[0][1].ToString(); string cnameInitials = ds.Tables[0].Rows[0][2].ToString(); int ctitleId = int.Parse(ds.Tables[0].Rows[0][3].ToString()); string cnationality = ds.Tables[0].Rows[0][4].ToString(); string cnic = ds.Tables[0].Rows[0][5].ToString(); DateTime cdob = (DateTime)ds.Tables[0].Rows[0][6]; char cgender = Convert.ToChar(ds.Tables[0].Rows[0][7].ToString()); string caddr_l1 = ds.Tables[0].Rows[0][8].ToString(); string caddr_l2 = ds.Tables[0].Rows[0][9].ToString(); string caddr_l3 = ds.Tables[0].Rows[0][10].ToString(); string ctelNo = ds.Tables[0].Rows[0][11].ToString(); string cemail = ds.Tables[0].Rows[0][12].ToString(); string cimg = ds.Tables[0].Rows[0][13].ToString(); Candidate c = new Candidate(cfullName, cnameInitials, ctitleId, cnationality, cnic, cdob, cgender, caddr_l1, caddr_l2, caddr_l3, ctelNo, cemail, cimg); return(c); }
public SeatingPositions(int id) { InitializeComponent(); this.examid = id; DataSet ds = DB_Connect.ExecuteQuery("SELECT C.candidate_name_initials AS CANDIDATE, CP.position_id AS POSITION FROM candidate_position CP LEFT JOIN candidate_tab C ON CP.candidate_id = C.candidate_id WHERE CP.exam_id = " + examid + " ORDER BY CP.position_id"); gvSeatingPositions.DataSource = ds.Tables[0]; }
private void AddCandidate_Load(object sender, EventArgs e) { //load values to Examination ID combo box from database DataSet dsTitle = DB_Connect.ExecuteQuery("SELECT DISTINCT title_id, title_name FROM title_tab "); ddlTitle.DataSource = dsTitle.Tables[0]; ddlTitle.DisplayMember = "title_name"; ddlTitle.ValueMember = "title_id"; //ddlTitle.SelectedIndex = -1; }
public AlertLog(int id) { InitializeComponent(); this.examid = id; DataSet ds = DB_Connect.ExecuteQuery("SELECT E.exam_date AS DATE, S.subject_name AS SUBJECT, A.position_id AS POSITION, C.candidate_name_initials AS CANDIDATE, CASE A.alert_type WHEN 'S' THEN 'Suspicious' WHEN 'H' THEN 'Help Request' ELSE 'Alert' END AS TYPE, A.alert_time AS TIME FROM alert_tab A LEFT JOIN examination_tab E ON A.exam_id = E.exam_id LEFT JOIN subject_tab S ON E.exam_subject_id = S.subject_id LEFT JOIN candidate_position CP ON A.position_id = CP.position_id LEFT JOIN candidate_tab C ON CP.candidate_id = C.candidate_id WHERE A.exam_id = " + examid + " AND CP.exam_id = " + examid + " ORDER BY A.alert_time desc"); gvAlerts.DataSource = ds.Tables[0]; }
private void Form1_Load(object sender, EventArgs e) { //load values to Examination ID combo box from database DataSet dsMarks = DB_Connect.ExecuteQuery("SELECT DISTINCT e.exam_id, s.subject_name, e.exam_date, (s.subject_name + ' - ' + CAST(e.exam_date as varchar(10) ) ) AS displayValue FROM subject_tab s, examination_tab e WHERE s.subject_id = e.exam_subject_id ORDER BY e.exam_id desc;"); ddlExamId.DataSource = dsMarks.Tables[0]; ddlExamId.DisplayMember = "displayValue"; ddlExamId.ValueMember = "exam_id"; ddlExamId.SelectedIndex = -1; }
private void cbExam_SelectedIndexChanged(object sender, EventArgs e) { DataRowView examDataView = (DataRowView)cbExam.SelectedItem; if (examDataView[0] != null) { examid = int.Parse(examDataView[0].ToString()); DataSet ds = DB_Connect.ExecuteQuery("SELECT E.* FROM examination_tab E WHERE E.exam_id =" + examDataView[0].ToString()); endtime = DateTime.Parse(ds.Tables[0].Rows[0][3].ToString()); } }
private void radButton1_Click(object sender, EventArgs e) { panel1.Invalidate(); Application.DoEvents(); Rectangle[] Blocks = new Rectangle[] { OMRSheetReader.GetSheetPropertyLocation("sheets", OMREnums.OMRSheet.A550, OMREnums.OMRProperty.tensBlock1), OMRSheetReader.GetSheetPropertyLocation("sheets", OMREnums.OMRSheet.A550, OMREnums.OMRProperty.tensBlock2), OMRSheetReader.GetSheetPropertyLocation("sheets", OMREnums.OMRSheet.A550, OMREnums.OMRProperty.tensBlock3), OMRSheetReader.GetSheetPropertyLocation("sheets", OMREnums.OMRSheet.A550, OMREnums.OMRProperty.tensBlock4) }; List <Bitmap[]> bmps = new List <Bitmap[]>(); for (int i = 0; i < 4; i++) { bmps.Add(rr.SliceOMarkBlock(panel1.BackgroundImage, Blocks[i], 10)); } DataSet dsMarks = DB_Connect.ExecuteQuery("SELECT a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31, a32, a33, a34, a35, a36, a37, a38, a39, a40 FROM mcq_marking_scheme_tab WHERE marking_scheme_id = '" + markingSchemeId + "';"); int[] ans_arr; ans_arr = new int[40]; string img_path = txtFileName.Text.ToString(); int cnt = 0; int result = 0; foreach (Bitmap[] blk in bmps) { foreach (Bitmap line in blk) { ans_arr[cnt] = rr.rateSlice(line, 5); if (ans_arr[cnt] == int.Parse(dsMarks.Tables[0].Rows[0][cnt].ToString())) { result++; } cnt++; } } DB_Connect.InsertQuery("INSERT INTO mcq_answers_tab(candidate_id,exam_id,answersheet_path,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21,a22,a23,a24,a25,a26,a27,a28,a29,a30,a31,a32,a33,a34,a35,a36,a37,a38,a39,a40,total_mark) VALUES('" + candidateId + "','" + examId + "','" + img_path + "', " + ans_arr[0] + ", " + ans_arr[1] + ", " + ans_arr[2] + ", " + ans_arr[3] + "," + ans_arr[4] + "," + ans_arr[5] + "," + ans_arr[6] + "," + ans_arr[7] + "," + ans_arr[8] + "," + ans_arr[9] + "," + ans_arr[10] + "," + ans_arr[11] + "," + ans_arr[12] + "," + ans_arr[13] + "," + ans_arr[14] + "," + ans_arr[15] + "," + ans_arr[16] + "," + ans_arr[17] + "," + ans_arr[18] + "," + ans_arr[19] + "," + ans_arr[20] + ", " + ans_arr[21] + "," + ans_arr[22] + "," + ans_arr[23] + "," + ans_arr[24] + "," + ans_arr[25] + "," + ans_arr[26] + "," + ans_arr[27] + "," + ans_arr[28] + "," + ans_arr[29] + "," + ans_arr[30] + "," + ans_arr[31] + "," + ans_arr[32] + "," + ans_arr[33] + "," + ans_arr[34] + "," + ans_arr[35] + "," + ans_arr[36] + "," + ans_arr[37] + "," + ans_arr[38] + "," + ans_arr[39] + "," + result + ");"); lblResult.Text = result.ToString(); }
public FaceRecognition() { InitializeComponent(); DataSet ds = DB_Connect.ExecuteQuery("SELECT E.exam_id , (S.subject_name +' '+CAST(E.exam_start_time as varchar(5) )+' - '+CAST(E.exam_end_time as varchar(5) ) ) AS subject_name FROM examination_tab E LEFT JOIN subject_tab S ON E.exam_subject_id = S.subject_id"); cmbExam.DataSource = ds.Tables[0]; cmbExam.DisplayMember = "subject_name"; cmbExam.ValueMember = "exam_id"; //ReadExisting(); }
public ExaminationInvigilation() { InitializeComponent(); //Load haarcascades for hand detection face = new HaarCascade(path + "haars\\haarcascade_hand3.xml"); DataSet ds = DB_Connect.ExecuteQuery("SELECT E.exam_id , (S.subject_name +' '+CAST(E.exam_start_time as varchar(5) )+' - '+CAST(E.exam_end_time as varchar(5) ) ) AS subject_name FROM examination_tab E LEFT JOIN subject_tab S ON E.exam_subject_id = S.subject_id"); cbExam.DataSource = ds.Tables[0]; cbExam.DisplayMember = "subject_name"; cbExam.ValueMember = "exam_id"; dsPos = DB_Connect.ExecuteQuery("SELECT HP.position_id, HP.pos_x, HP.pos_y , C.candidate_name_initials FROM examination_tab E LEFT JOIN hall_position HP ON E.exam_hall_id = HP.hall_id LEFT JOIN candidate_position CP ON HP.position_id = CP.position_id AND E.exam_id = CP.exam_id LEFT JOIN candidate_tab C ON CP.candidate_id = C.candidate_id WHERE E.exam_id = 8"); }
private void AlertTimer_Tick(object sender, EventArgs e) { //foreach (int i in motionQueue.GroupBy(x => x).OrderByDescending(g => g.Count()).Select(g => g.Key) ) var selectedCategories = motionQueue.GroupBy(x => x).OrderByDescending(g => g.Count()).Select(g => new { pos = g.Key, cnt = g.Count() }); foreach (var pos in selectedCategories) { bool isAlert = false; if (severetyThreshold < pos.cnt) { isAlert = true; } if (isAlert) { if (pos.pos == 1) { red1 = true; } else if (pos.pos == 2) { red2 = true; } else if (pos.pos == 3) { red3 = true; } else if (pos.pos == 4) { red4 = true; } //lbAlerts.Items.Add("Suspicious Act at #" + pos.pos.ToString()); dgAlerts.Rows.Add("Suspicious Act", pos.pos.ToString()); DB_Connect.InsertQuery("INSERT INTO alert_tab(exam_id,position_id,alert_type,alert_time) VALUES(" + examid + "," + pos.pos.ToString() + ",'S','" + DateTime.Now + "')"); //GCM cheat //AndroidGCMPushNotification apnGCM = new AndroidGCMPushNotification(); //string strResponse = apnGCM.SendNotification(regID, pos.pos.ToString() + " "+ DateTime.Now, "S"); dgAlerts.FirstDisplayedScrollingRowIndex = dgAlerts.RowCount - 1; } motionQueue.Clear(); } }
public ExaminationControlPanel() { InitializeComponent(); DataSet ds = DB_Connect.ExecuteQuery("SELECT E.exam_id AS ID, E.exam_date AS DATE, S.subject_name AS Subject, E.exam_start_time AS START, E.exam_end_time AS Finish, H.hall_code AS Hall FROM examination_tab E LEFT JOIN subject_tab S ON E.exam_subject_id = S.subject_id LEFT JOIN hall_tab H ON E.exam_hall_id = H.hall_id ORDER BY E.exam_date DESC"); dgvExaminationList.DataSource = ds.Tables[0]; DataSet dssub = DB_Connect.ExecuteQuery("SELECT S.subject_id , S.subject_name FROM subject_tab S ORDER BY S.subject_name"); cbSubject.DataSource = dssub.Tables[0]; cbSubject.DisplayMember = "subject_name"; cbSubject.ValueMember = "subject_id"; DataSet dshall = DB_Connect.ExecuteQuery("SELECT H.hall_id , H.hall_code , H.hall_capacity FROM hall_tab H ORDER BY H.hall_code"); cbHall.DataSource = dshall.Tables[0]; cbHall.DisplayMember = "hall_code"; cbHall.ValueMember = "hall_id"; }
public DataSet getCandidateFullName(int id) { DataSet ds = DB_Connect.ExecuteQuery("SELECT candidate_id, candidate_full_name FROM candidate_tab WHERE candidate_id = " + id + ";"); return(ds); }
public void updateCandidate(Candidate c) { DB_Connect.ExecuteQuery("UPDATE candidate_tab SET candidate_full_name = '" + c.fullName + "',candidate_name_initials = '" + c.nameInitials + "',candidate_title = '" + c.title + "',candidate_nationality_id = '" + c.nationality + "',candidate_nic = '" + c.nic + "',candidate_dob = '" + c.dob + "',candidate_gender = '" + c.gender + "',candidate_address = '" + c.addr_l1 + "',candidate_address = '" + c.addr_l2 + "',candidate_address = '" + c.addr_l3 + "',candidate_telno = '" + c.telNo + "',candidate_email = '" + c.email + "',candidate_img = '" + c.img + "' WHERE candidate_id = " + c.id + ";"); }
private void btnSave_Click(object sender, EventArgs e) { DB_Connect.InsertQuery("INSERT INTO examination_tab ( exam_date, exam_start_time, exam_end_time, exam_hall_id, exam_subject_id) VALUES ('" + radDateTimePicker1.Value + "', '" + radDateTimePicker3.Value.TimeOfDay + "', '" + radDateTimePicker4.Value.TimeOfDay + "', " + cbSubject.SelectedValue + ", " + cbHall.SelectedValue + ");"); }
public void deleteCandidate(int id) { DB_Connect.ExecuteQuery("DELETE FROM candidate_tab WHERE candidate_id = " + id + ";"); }
void FrameGrabber(object sender, EventArgs e) { try { //Get the current frame form capture device currentFrame = grabber.QueryFrame().Resize(520, 340, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); } catch (NullReferenceException e1) { _motionHistory = new MotionHistory(2.0, 0.05, 0.5); _forgroundDetector = null; motionQueue.Clear(); helpQueue.Clear(); grabber = new Capture(vidlist[excnt]); excnt++; if (excnt == 5) { excnt = 0; } currentFrame = grabber.QueryFrame().Resize(520, 340, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); green1 = false; green2 = false; green3 = false; green4 = false; red1 = false; red2 = false; red3 = false; red4 = false; } //Convert it to Grayscale gray = currentFrame.Convert <Gray, Byte>(); //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]) { t = t + 1; result = currentFrame.Copy(f.rect).Convert <Gray, byte>().Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); //MessageBox.Show("wiidth " + f.rect.Width + " height " + f.rect.Height + " area " + f.rect.Width * f.rect.Height); if (f.rect.Width > 80) { continue; } //draw the face detected in the 0th (gray) channel with blue color if (showHand) { currentFrame.Draw(f.rect, new Bgr(Color.LightGreen), 2); } int nearespos = nearestPosition(f.rect.X, f.rect.Y); if (helpQueue.ToArray().ToList().IndexOf(nearespos) == -1) { //lbAlerts.Items.Add("Help request at #" + nearespos.ToString()); dgAlerts.Rows.Add("Help Request", nearespos.ToString()); DB_Connect.InsertQuery("INSERT INTO alert_tab(exam_id,position_id,alert_type,alert_time) VALUES(" + examid + "," + nearespos.ToString() + ",'H','" + DateTime.Now + "')"); dgAlerts.FirstDisplayedScrollingRowIndex = dgAlerts.RowCount - 1; //GCM - help //AndroidGCMPushNotification apnGCM = new AndroidGCMPushNotification(); //string strResponse = apnGCM.SendNotification(regID, nearespos.ToString() + " "+ DateTime.Now, "H"); if (nearespos == 1) { green1 = true; } else if (nearespos == 2) { green2 = true; } else if (nearespos == 3) { green3 = true; } else if (nearespos == 4) { green4 = true; } if (helpQueue.Count == 10) { helpQueue.Dequeue(); helpQueue.Enqueue(nearespos); } else { helpQueue.Enqueue(nearespos); } } } //Show the faces procesed and recognized imageBoxFrameGrabber.Image = ProcessFrame(currentFrame); if (captureOutput == null && xdoc.Descendants("RecordVideo").First().Value == "1") { MessageBox.Show("reording start"); captureOutput = new VideoWriter(@"video" + examid + ".avi", (int)grabber.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_FOURCC), 15, 520, 340, true); } if (currentFrame != null && xdoc.Descendants("RecordVideo").First().Value == "1") { captureOutput.WriteFrame <Bgr, Byte>(currentFrame); } }
public void insertCandidate(Candidate c) { DB_Connect.InsertQuery("INSERT INTO candidate_tab(candidate_full_name,candidate_name_initials,candidate_title,candidate_nationality_id,candidate_nic,candidate_dob,candidate_gender,candidate_addr_l1,candidate_addr_l2, candidate_addr_l3, candidate_telno,candidate_email) VALUES('" + c.fullName + "', '" + c.nameInitials + "', '" + c.title + "', '" + c.nationality + "', '" + c.nic + "', '" + c.dob + "','" + c.gender + "','" + c.addr_l1 + " ','" + c.addr_l2 + " ','" + c.addr_l3 + " ', '" + c.telNo + "', '" + c.email + "');"); }