private void button1_Click(object sender, EventArgs e) { SqlData.CreateConnection(); DataTable dts = new DataTable(); dataGridView1.DataSource = dts; dataGridView1.DataSource = SqlData.GetData_0(); }
public AddNew_UC() { InitializeComponent(); try { SqlData.CreateConnection(); DataTable dts = new DataTable(); dataGridView1.DataSource = dts; dataGridView1.DataSource = SqlData.GetData_0(); } catch (Exception e) { MessageBox.Show("Error Found"); } }
private void DisableDetection_btn_Click(object sender, EventArgs e) { SqlData.CreateConnection(); SqlData.UpdateDG(UserName); }
private void Add_Btn_Click(object sender, EventArgs e) { for (int iii = 0; iii <= 5; iii++) { if (names != ",") { try { //Trained face counter ContTrain = ContTrain + 1; //Get a gray frame from capture device gray = grabber.QueryGrayFrame().Resize(420, 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(textBox1.Text); bookingDateTime.Add(Convert.ToString(DateTime.Now)); userCity.Add(City_tb.Text); Label_Role.Add(Role_tb.Text); Label_Mobile.Add(Mobile_tb.Text); Label_Status.Add("Not Attend"); Label_AttendDateTime.Add("Not Attend"); //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 number of triained faces in a file text for further load File.WriteAllText(Application.StartupPath + "/TrainedFaces/UserCity.txt", trainingImages.ToArray().Length.ToString() + "%"); //Write the number of triained faces in a file text for further load File.WriteAllText(Application.StartupPath + "/TrainedFaces/BookingDateTime.txt", trainingImages.ToArray().Length.ToString() + "%"); //Write the number of triained faces in a file text for further load File.WriteAllText(Application.StartupPath + "/TrainedFaces/UserMobile.txt", trainingImages.ToArray().Length.ToString() + "%"); //Write the number of triained faces in a file text for further load File.WriteAllText(Application.StartupPath + "/TrainedFaces/UserRole.txt", trainingImages.ToArray().Length.ToString() + "%"); //Write the number of triained faces in a file text for further load File.WriteAllText(Application.StartupPath + "/TrainedFaces/EventAttend.txt", trainingImages.ToArray().Length.ToString() + "%"); //Write the number of triained faces in a file text for further load File.WriteAllText(Application.StartupPath + "/TrainedFaces/EventAttendDateTime.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] + "%"); File.AppendAllText(Application.StartupPath + "/TrainedFaces/UserCity.txt", userCity.ToArray()[i - 1] + "%"); File.AppendAllText(Application.StartupPath + "/TrainedFaces/BookingDateTime.txt", bookingDateTime.ToArray()[i - 1] + "%"); File.AppendAllText(Application.StartupPath + "/TrainedFaces/UserMobile.txt", Label_Mobile.ToArray()[i - 1] + "%"); File.AppendAllText(Application.StartupPath + "/TrainedFaces/UserRole.txt", Label_Role.ToArray()[i - 1] + "%"); File.AppendAllText(Application.StartupPath + "/TrainedFaces/EventAttend.txt", Label_Status.ToArray()[i - 1] + "%"); File.AppendAllText(Application.StartupPath + "/TrainedFaces/EventAttendDateTime.txt", Label_AttendDateTime.ToArray()[i - 1] + "%"); } SqlData.CreateConnection(); SqlData.insertvalues(textBox1.Text, Role_tb.Text, City_tb.Text, Mobile_tb.Text, "Not Attend"); MessageBox.Show(textBox1.Text + "´s face detected and added :)", "Training OK", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show("Enable the face detection first", "Training Fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("Opps!! This Profile already Registered).", "Triained faces load", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } SqlData.CreateConnection(); SqlData.insertvalues(textBox1.Text, Role_tb.Text, City_tb.Text, Mobile_tb.Text, "Not Attend"); }