acceder
DESCRIPTION
TRANSCRIPT
![Page 1: Acceder](https://reader037.vdocumento.com/reader037/viewer/2022100318/546fb4f6af7959c70a8b46aa/html5/thumbnails/1.jpg)
REGISTRAR UN NUEVO USUARIO
![Page 2: Acceder](https://reader037.vdocumento.com/reader037/viewer/2022100318/546fb4f6af7959c70a8b46aa/html5/thumbnails/2.jpg)
ESTA IMAGEN ESTA EN LA PARTE DE LA BIENVENIDA Y LA UTILIZAMOS PARA REGISTRAR NUEVOS USUARIOS.
![Page 3: Acceder](https://reader037.vdocumento.com/reader037/viewer/2022100318/546fb4f6af7959c70a8b46aa/html5/thumbnails/3.jpg)
DENTRO DE LA IMAGEN SIGUIENTE NOS ABRIRA ESTA FORM QUE SIRVE PARA REGISTRAR A UN NUEVO USUARIO Y GUARDARLO DENTRO DE LA BASE DE DATOS.
![Page 4: Acceder](https://reader037.vdocumento.com/reader037/viewer/2022100318/546fb4f6af7959c70a8b46aa/html5/thumbnails/4.jpg)
DENTRO DE ESTA FORM VA EL SIGUIENTE CODIGO.
private void pictureBox1_Click(object sender, EventArgs e) { con = new SqlConnection(); con.ConnectionString = vgloba.liga; try { string insertar = "insert into usuarios (usuario,contraseña,confirmar) values (@usuario,@contraseña,@confirmar)"; SqlCommand comando = new SqlCommand(insertar, con); comando.Parameters.Add(new SqlParameter("@usuario", textBox1.Text)); comando.Parameters.Add(new SqlParameter("@contraseña", textBox2.Text)); comando.Parameters.Add(new SqlParameter("@confirmar", textBox3.Text)); //comando.Parameters.Add(new SqlParameter("@confirmar_contraseña", textBox3.Text.Trim())); comando.Connection.Open(); comando.ExecuteNonQuery(); comando.Connection.Close();
MessageBox.Show("Se ha agragado nuevo usuario ala base de datos"); Form nuevo = new Form3(); nuevo.Show(); this.Hide(); } catch { MessageBox.Show("No se pudo conectar a la base de datos"); } }
![Page 5: Acceder](https://reader037.vdocumento.com/reader037/viewer/2022100318/546fb4f6af7959c70a8b46aa/html5/thumbnails/5.jpg)
private void pictureBox2_Click(object sender, EventArgs e) { this.Close();
}
![Page 6: Acceder](https://reader037.vdocumento.com/reader037/viewer/2022100318/546fb4f6af7959c70a8b46aa/html5/thumbnails/6.jpg)
![Page 7: Acceder](https://reader037.vdocumento.com/reader037/viewer/2022100318/546fb4f6af7959c70a8b46aa/html5/thumbnails/7.jpg)
private void pictureBox3_Click(object sender, EventArgs e) { entrar(); this.pictureBox1.Visible = true; this.pictureBox3.Visible = false; }
ESTE CODIGO SE UTILIZA PARA ACCEDER AL SISTEMA Y ESTAMOS UTILIZABNDO UNA FUNCION LLAMADA ENTRAR.
![Page 8: Acceder](https://reader037.vdocumento.com/reader037/viewer/2022100318/546fb4f6af7959c70a8b46aa/html5/thumbnails/8.jpg)
System.Data.SqlClient.SqlConnection con; private void pictureBox1_Click(object sender, EventArgs e) { con = new SqlConnection(); con.ConnectionString = vgloba.liga; try { con.Open(); //AQUI CUENTO LOS REGISTROS DE USUARIO string cadenasql = "SELECT Count (usuario) FROM USUARIOS"; SqlCommand comando = new SqlCommand(cadenasql, con); int contador = ((int)comando.ExecuteScalar()); con.Close();
//SI EL CONTADOR VALE CERO SE ABRIRA UNA VENTANA DE NUEVO REGISTRO if (contador == 0) { Form nuevo = new Form5(); nuevo.Show(); this.Close(); } else { Form nuevo = new Form5(); nuevo.Show(); this.Close(); } } catch { MessageBox.Show("Error en la conexion"); }
}