예제 #1
0
        public form_main()
        {
            InitializeComponent();
            //create necessary program folders
            logic log = new logic();

            log.create_app_folders();
            //declare eventhandlers for form events
            this.FormClosing += new FormClosingEventHandler(form_closing);
            this.MouseDown   += new MouseEventHandler(form_mouse_down);
            this.MouseMove   += new MouseEventHandler(form_mouse_move);
        }
예제 #2
0
        void save_records(TFaceRecord tr)
        {
            MySqlConnection sqlconnect = null;

            try
            {
                //lets prepare the face record to save
                Image img      = null;
                Image img_face = null;
                System.IO.MemoryStream strm      = new System.IO.MemoryStream();
                System.IO.MemoryStream strm_face = new System.IO.MemoryStream();
                img      = fr.image.ToCLRImage();
                img_face = fr.faceImage.ToCLRImage();
                img.Save(strm, System.Drawing.Imaging.ImageFormat.Jpeg);
                img_face.Save(strm_face, System.Drawing.Imaging.ImageFormat.Jpeg);
                Byte[] img_array      = new byte[strm.Length - 1];
                Byte[] img_array_face = new byte[strm_face.Length - 1];
                strm.Position = 0;
                strm.Read(img_array, 0, img_array.Length);
                strm_face.Position = 0;
                strm_face.Read(img_array_face, 0, img_array_face.Length);
                //lets connect to ur mysql database and save record
                sqlconnect = new MySqlConnection("server=127.0.0.1;user id=root;password=;database=verification_system");
                sqlconnect.Open();
                MySqlCommand sqlcmd = new MySqlCommand();
                sqlcmd.Connection  = sqlconnect;
                sqlcmd.CommandText = "INSERT INTO records(ImageFileName, FacePositionXc, FacePositionYc, FacePositionW, FacePositionAngle, Eye1X, Eye1Y, Eye2X, Eye2Y, imagetemplate, Image, FaceImage, name, email, phone, gender, marital, address, dob) " + " VALUES(@ImageFileName, @FacePositionXc, @FacePositionYc, @FacePositionW, @FacePositionAngle, @Eye1X, @Eye1Y, @Eye2X, @Eye2Y, @imageTemplate, @Image, @FaceImage, @name, @email, @phone, @gender, @marital, @address, @dob)";
                //
                sqlcmd.Parameters.AddWithValue("@ImageFileName", fr.ImageFileName);
                sqlcmd.Parameters.AddWithValue("@FacePositionXc", fr.FacePosition.xc);
                sqlcmd.Parameters.AddWithValue("@FacePositionYc", fr.FacePosition.yc);
                sqlcmd.Parameters.AddWithValue("@FacePositionW", fr.FacePosition.w);
                sqlcmd.Parameters.AddWithValue("@FacePositionAngle", (Single)(fr.FacePosition.angle));
                sqlcmd.Parameters.AddWithValue("@Eye1X", fr.FacialFeatures[0].x);
                sqlcmd.Parameters.AddWithValue("@Eye1Y", fr.FacialFeatures[0].y);
                sqlcmd.Parameters.AddWithValue("@Eye2X", fr.FacialFeatures[1].x);
                sqlcmd.Parameters.AddWithValue("@Eye2Y", fr.FacialFeatures[1].y);
                sqlcmd.Parameters.AddWithValue("@imageTemplate", fr.Template);
                sqlcmd.Parameters.AddWithValue("@Image", img_array);
                sqlcmd.Parameters.AddWithValue("@FaceImage", img_array_face);
                //sqlcmd.Parameters.AddWithValue("@ID", bio.c);
                sqlcmd.Parameters.AddWithValue("@name", txt_firstname.Text + " " + txt_surname.Text);
                sqlcmd.Parameters.AddWithValue("@email", txt_email.Text);
                sqlcmd.Parameters.AddWithValue("@phone", txt_phone.Text);
                sqlcmd.Parameters.AddWithValue("@gender", cbo_gender.Text);
                sqlcmd.Parameters.AddWithValue("@marital", cbo_marital.Text);
                sqlcmd.Parameters.AddWithValue("@address", txt_address.Text);
                sqlcmd.Parameters.AddWithValue("@dob", dt_staff.Value.ToShortDateString());
                sqlcmd.ExecuteNonQuery();
                logic log = new logic();
                //log action here -> ID card generation in progress
                log.generate_qrcode(txt_firstname.Text + " " + txt_surname.Text, txt_phone.Text, get_staffname());
                log.generate_user_id(Application.StartupPath + "\\images\\" + get_staffname() + ".jpg", txt_firstname.Text + " " + txt_surname.Text, dt_staff.Value.ToShortDateString(), cbo_gender.Text, get_staffname());
                MessageBox.Show("Staff successfully registered", "Registration");
                //clear all input fields
                txt_address.Text    = "";
                txt_email.Text      = "";
                txt_firstname.Text  = "";
                txt_phone.Text      = "";
                txt_surname.Text    = "";
                staff_picture.Image = null;
                img.Dispose();
                img_face.Dispose();
                cbo_gender.SelectedItem  = null;
                cbo_marital.SelectedItem = null;
                dt_staff.Value           = DateTime.Now;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception on saving to database");
                //log error here
            }
            finally
            {
                sqlconnect.Close();
            }
        }