private void btnRegresar_Click(object sender, EventArgs e) { InicioSesion inicio = new InicioSesion(); this.Hide(); inicio.Show(); }
private void btnSalir_Click(object sender, EventArgs e) { DialogResult dialogResult = MessageBox.Show("¿Desea salir del sistema?", "Salir", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { InicioSesion inicio = new InicioSesion(); this.Hide(); inicio.Show(); } }
private void guardarcontraseña() { string Usuario = User; string Contraseña = Encriptacion.Encrypt(txtContraseña.Text); if (txtContraseña.Text == "" || txtConfirmarContraseña.Text == "") { MessageBox.Show("Ingrese su contraseña", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (txtContraseña.Text.Equals(txtConfirmarContraseña.Text)) { SqlCommand update = new SqlCommand(@"Update Empleados Set Contraseña='" + Contraseña + "', Codigo_Estado='" + 1 + "', Intentos='" + 0 + "' Where Usuario='" + Usuario + "'", Conexion.Obtenerconexion()); update.ExecuteNonQuery(); MessageBox.Show("Contraseña cambiada exitosamente.", "Cambio Exitoso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); InicioSesion inicio = new InicioSesion(); this.Hide(); inicio.Show(); } else { MessageBox.Show("Las contraseña no concuerdan. Intente de nuevo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Registrar() { string Identidad_Empleado = textboxIdentidadAgregar.Text; string Nombre_Empleado = textboxNombreAgregar.Text; string Apellido_Empleado = textboxApellidoAgregar.Text; string Usuario = textboxUsuarioAgregar.Text; string Telefono = textboxTelefonoAgregar.Text; string Celular = textboxCelularAgregar.Text; string Contraseña = Encriptacion.Encrypt(labelContraseñaTemporal.Text); int Intentos = 0; bool IsExist = false; SqlCommand sql = new SqlCommand("select * from Empleados Where Usuario = '" + Usuario + "' or Identidad_Empleado='" + Identidad_Empleado + "'", Conexion.Obtenerconexion()); SqlDataReader reader = sql.ExecuteReader(); if (reader.Read()) { Identidad_Empleado = reader.GetString(1); Usuario = reader.GetString(7); IsExist = true; } Conexion.Obtenerconexion().Close(); if (IsExist == true) { if (Identidad_Empleado.Equals(textboxIdentidadAgregar.Text) || Usuario.Equals(textboxUsuarioAgregar.Text)) { MessageBox.Show("Identidad de Empleado o Usuario ya existente", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (comboboxPuestoAgregar.Text == "Gerente") { int Codigo_Puesto = 1; int Cod_Estado = 6; if (textboxTelefonoAgregar.Text == "") { SqlCommand insert = new SqlCommand("Insert into Empleados(Identidad_Empleado, Nombre_Empleado, Apellido_Empleado, Celular, Usuario, Contraseña, Codigo_Puesto, Codigo_Estado, Intentos)Values('" + Identidad_Empleado + "', '" + Nombre_Empleado + "', '" + Apellido_Empleado + "', '" + Celular + "','" + Usuario + "', '" + Contraseña + "', '" + Codigo_Puesto + "', '" + Cod_Estado + "', '" + Intentos + "')", Conexion.Obtenerconexion()); insert.ExecuteNonQuery(); MessageBox.Show("Usuario Creado con Exito.", "Cuenta Creada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); PreguntasdeSeguridad seguridad = new PreguntasdeSeguridad(); InicioSesion inicio = new InicioSesion(); seguridad.lblUsuario.Text = textboxUsuarioAgregar.Text; this.Hide(); inicio.Show(); } else if (textboxCelularAgregar.Text == "") { SqlCommand insert = new SqlCommand("Insert into Empleados(Identidad_Empleado, Nombre_Empleado, Apellido_Empleado, , Telefono, Usuario, Contraseña, Codigo_Puesto, Codigo_Estado, Intentos)Values('" + Identidad_Empleado + "', '" + Nombre_Empleado + "', '" + Apellido_Empleado + "', '" + Telefono + "','" + Usuario + "', '" + Contraseña + "', '" + Codigo_Puesto + "', '" + Cod_Estado + "', '" + Intentos + "')", Conexion.Obtenerconexion()); insert.ExecuteNonQuery(); MessageBox.Show("Usuario Creado con Exito.", "Cuenta Creada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); PreguntasdeSeguridad seguridad = new PreguntasdeSeguridad(); InicioSesion inicio = new InicioSesion(); seguridad.lblUsuario.Text = textboxUsuarioAgregar.Text; this.Hide(); inicio.Show(); } else { SqlCommand insert = new SqlCommand("Insert into Empleados(Identidad_Empleado, Nombre_Empleado, Apellido_Empleado, , Telefono, Celular, Usuario, Contraseña, Codigo_Puesto, Codigo_Estado, Intentos)Values('" + Identidad_Empleado + "', '" + Nombre_Empleado + "', '" + Apellido_Empleado + "', '" + Telefono + "', '" + Celular + "','" + Usuario + "', '" + Contraseña + "', '" + Codigo_Puesto + "', '" + Cod_Estado + "', '" + Intentos + "')", Conexion.Obtenerconexion()); insert.ExecuteNonQuery(); MessageBox.Show("Usuario Creado con Exito.", "Cuenta Creada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); PreguntasdeSeguridad seguridad = new PreguntasdeSeguridad(); InicioSesion inicio = new InicioSesion(); seguridad.lblUsuario.Text = textboxUsuarioAgregar.Text; this.Hide(); inicio.Show(); } } if (comboboxPuestoAgregar.Text == "Cajero") { int Codigo_Puesto = 2; int Cod_Estado = 6; if (textboxTelefonoAgregar.Text == "") { SqlCommand insert = new SqlCommand("Insert into Empleados(Identidad_Empleado, Nombre_Empleado, Apellido_Empleado, Celular, Usuario, Contraseña, Codigo_Puesto, Codigo_Estado, Intentos)Values('" + Identidad_Empleado + "', '" + Nombre_Empleado + "', '" + Apellido_Empleado + "', '" + Celular + "','" + Usuario + "', '" + Contraseña + "', '" + Codigo_Puesto + "', '" + Cod_Estado + "', '" + Intentos + "')", Conexion.Obtenerconexion()); insert.ExecuteNonQuery(); MessageBox.Show("Usuario Creado con Exito.", "Cuenta Creada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); PreguntasdeSeguridad seguridad = new PreguntasdeSeguridad(); InicioSesion inicio = new InicioSesion(); seguridad.lblUsuario.Text = textboxUsuarioAgregar.Text; this.Hide(); inicio.Show(); } else if (textboxCelularAgregar.Text == "") { SqlCommand insert = new SqlCommand("Insert into Empleados(Identidad_Empleado, Nombre_Empleado, Apellido_Empleado, Telefono, Usuario, Contraseña, Codigo_Puesto, Codigo_Estado, Intentos)Values('" + Identidad_Empleado + "', '" + Nombre_Empleado + "', '" + Apellido_Empleado + "', '" + Telefono + "','" + Usuario + "', '" + Contraseña + "', '" + Codigo_Puesto + "', '" + Cod_Estado + "', '" + Intentos + "')", Conexion.Obtenerconexion()); insert.ExecuteNonQuery(); MessageBox.Show("Usuario Creado con Exito.", "Cuenta Creada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); PreguntasdeSeguridad seguridad = new PreguntasdeSeguridad(); InicioSesion inicio = new InicioSesion(); seguridad.lblUsuario.Text = textboxUsuarioAgregar.Text; this.Hide(); inicio.Show(); } else { SqlCommand insert = new SqlCommand("Insert into Empleados(Identidad_Empleado, Nombre_Empleado, Apellido_Empleado, Telefono, Celular, Usuario, Contraseña, Codigo_Puesto, Codigo_Estado, Intentos)Values('" + Identidad_Empleado + "', '" + Nombre_Empleado + "', '" + Apellido_Empleado + "', '" + Telefono + "', '" + Celular + "','" + Usuario + "', '" + Contraseña + "', '" + Codigo_Puesto + "', '" + Cod_Estado + "', '" + Intentos + "')", Conexion.Obtenerconexion()); insert.ExecuteNonQuery(); MessageBox.Show("Usuario Creado con Exito.", "Cuenta Creada", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); PreguntasdeSeguridad seguridad = new PreguntasdeSeguridad(); InicioSesion inicio = new InicioSesion(); seguridad.lblUsuario.Text = textboxUsuarioAgregar.Text; this.Hide(); inicio.Show(); } } } }