private void Btn_CariNIP_Click(object sender, EventArgs e) { CariPengguna cp = new CariPengguna(); if (cp.statuscariuser3(Txt_NIP.Text) == true) { string nip_baru = Txt_NIP.Text; string path_baru = nip_baru; string folder_baru = "TrainedFaces"; //load_traineface(nip_baru); FrmPrincipal frm = new FrmPrincipal(nip_baru, path_baru, folder_baru); this.Close(); frm.Show(); } else { MessageBox.Show("N.I.P yang anda masukkan tidak terdaftar di database"); Txt_NIP.Clear(); Txt_NIP.Focus(); } }
private void button_Enroll_Click(object sender, EventArgs e) { CariPengguna cp = new CariPengguna(); if (cp.statuscariuser3(textBox_NIP.Text) == true) { MessageBox.Show("N.I.P yang anda masukkan sudah terdaftar di database"); } else { int tahun_lahir = Convert.ToInt32(dateTimePicker_TglLhr.Value.ToString("yyyy")); int tahun_izin = Convert.ToInt32(DateTime.Now.ToString("yyyy")) - 17; if (textBox_Nama.Text == "" || textBox_Alamat.Text == "" || textBox_NIP.Text == "" || textBox_TmpLhr.Text == "" || textBox_Jabatan.Text == "" || comboBox_PendAkhir.SelectedIndex < 0) //if(textBox_Nama.Text == "") { MessageBox.Show("Isi semua data dengan benar"); } else if (tahun_lahir >= tahun_izin) { MessageBox.Show("Usia Pegawai Minimal 17 Tahun"); dateTimePicker_TglLhr.Focus(); } else { textBox_Nama.ReadOnly = true; textBox_Alamat.ReadOnly = true; textBox_NIP.ReadOnly = true; textBox_TmpLhr.ReadOnly = true; textBox_Jabatan.ReadOnly = true; comboBox_PendAkhir.Enabled = false; dateTimePicker_TglLhr.Enabled = false; button_Enroll.Enabled = false; button_Batal.Enabled = false; button_AddFace.Enabled = true; Group_Cat.Enabled = true; NIP_Enroll = textBox_NIP.Text; Nama_Enroll = textBox_Nama.Text; grabber = new Capture(); grabber.QueryFrame(); //Initialize the FrameGraber event Application.Idle += new EventHandler(FrameGrabber); } } }
private void button_SimpanAbsen_Click(object sender, EventArgs e) { CariPengguna cp = new CariPengguna(); if (Label_NIP.Text != "-" && Label_Nama.Text != "-") { if (cp.statuscariuser3(Label_NIP.Text) == true) { if (cp.statuscariuser(Label_NIP.Text) == false) { label11.Visible = false; 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]) //for (int i = 1; i<=1; i++) { 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); if (ketemu == true) { //CariPengguna cp = new CariPengguna(); if (cp.statuscariuser(nip_pegawai) == false) { //string identik_dgn = "face_" + nip_pegawai + "_" + label6.Text + ""; //input_absen(identik_dgn); input_absen(); ketemu = false; } } MessageBox.Show("Data Absensi " + Label_Nama.Text + " Berhasil Disimpan", "Save to Database OK", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } catch { MessageBox.Show("Wajah tidak terdeteksi", "Gagal", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { MessageBox.Show("Anda Sudah Melakukan Absensi untuk hari ini","Warning",MessageBoxButtons.OK,MessageBoxIcon.Warning); } } } else { MessageBox.Show("Wajah Anda Sulit Di Identifikasi, Silahkan Coba Untuk Mencari NIP Anda","Warning",MessageBoxButtons.OK,MessageBoxIcon.Warning); Txt_NIP.Focus(); } }
private void tampillogin() { this.Hide(); Login fmLogin = new Login(); DialogResult dr = fmLogin.ShowDialog(); if (dr != DialogResult.OK) { this.Close(); } else { //this.Text = "Input NIP : " + fmLogin.usernamelogin; usernamewelcome = fmLogin.usernamelogin; this.Show(); } if (usernamewelcome != "") { CariPengguna cp = new CariPengguna(); if (cp.statusCariUser2(usernamewelcome) == true) { DBConnect koneksi_db = new DBConnect(); MySqlConnection db = new MySqlConnection(koneksi_db.koneksi()); db.Open(); MySqlCommand dbcmd2 = db.CreateCommand(); string sql = "select user_login,Jab from user_system"; dbcmd2.CommandText = sql; MySqlDataReader reader = dbcmd2.ExecuteReader(); while (reader.Read()) { if ((reader.GetString(0).ToString().ToLower() == usernamewelcome)) { //label_Nama.Text = reader.GetString(1).ToString(); jabat = reader.GetString(1).ToString(); if (jabat == "Admin") { button_Daftar.Enabled = true; } } } db.Close(); } } }