public void CreateConnection()
 {
     OpenFileDialog open = new OpenFileDialog();
         open.Title = "Abrir database(.sdf)";
         open.Filter = "SQLCE files (*.sdf)|*.sdf";
         open.Multiselect = false;
         open.ShowDialog();
         DatabaseManager manager = new DatabaseManager();
         if (!open.CheckFileExists | !open.CheckPathExists | open.FileName.Equals(""))
         {
             MessageBox.Show("El archivo no existe.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else {
             dbM.OpenConnection(open.FileName);
             field1.Text = (String)dbM.Nombre;
             field2.Text = (String)dbM.Apellido;
             field3.Text = (String)dbM.edad;
             field4.Text = (String)dbM.cedula;
             field5.Text = (String)dbM.contrasena;
             field6.Text = (String)dbM.piel;
             base.Refresh();
         }
         open.Dispose();
 }
        private void button1_Click(object sender, EventArgs e)
        {
            int pass;
            //int isInteger = Int32.TryParse(Field3.Text,out pass);
            bool confirmPass = this.Field3.Text.Equals(this.Field4.Text);
            bool nonBlank = Field1.Text.Length == 0 | Field2.Text.Length == 0 | Field3.Text.Length == 0
               | Field4.Text.Length == 0 | Field6.Text.Length == 0 | Field7.Text.Length == 0
               | Field8.Text.Length == 0
               ;
            bool minor5 =
               Field1.Text.Length >= 3
               && Field2.Text.Length >= 3
               && Field3.Text.Length >= 3
               && Field4.Text.Length >= 3
               && Field5.Text.Length >= 3
               && Field7.Text.Length >= 3
               && Field8.Text.Length >= 3;
            //if(isInteger) {
            if (!nonBlank)
            {
                if (minor5)
                {
                    if (confirmPass)
                    {
                        if (imageIsSelected)
                        {
                            try
                            {
                                DatabaseManager database = new DatabaseManager();
                                database.OpenConnection(path);
                                database.CreateTables();
                                int affected = database.Insert(this.Field1.Text, this.Field2.Text, this.Field3.Text, this.Field5.Text, this.Field6.Text, this.Field7.Text, this.Field8.Text,bytes);
                                database.CloseConnection();
                                if (affected > 0)
                                {
                                    MessageBox.Show("Registro Completado!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    this.Close();
                                    this.Dispose();
                                }
                                else { MessageBox.Show("Registro fallo! Intentelo de nuevo.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); }
                            }
                            catch (SqlCeException ce) { MessageBox.Show(ce.Message, "Error"); }

                        }
                        else {
                            MessageBox.Show("Seleccione una imagen de usted.", "Obligatorio", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }else
                    {
                        MessageBox.Show("Las contraseñas no coinciden. Intentelo otra vez", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                            }else
                {
                    MessageBox.Show("Todos los campos necesitan ser de 3 caracteres ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                         } else { MessageBox.Show("Todos los campos son requeridos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }