public static bool act(constructor_de_respuestas ac) { bool retorno = false; try { MySqlCommand cmdupt = new MySqlCommand(string.Format("UPDATE tbrespuesta SET usuarioss ='{0}' ", ac.usuarioss), Conexion.obtenerconexion()); retorno = Convert.ToBoolean(cmdupt.ExecuteNonQuery()); if (true) { if (retorno == true) { MessageBox.Show("Los datos fueron actualizados correctamente.", "Proceso completado", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Los Datos no pudieron ser actualizados.", "Proceso no completado", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(retorno); } } catch (Exception e) { MessageBox.Show("Ha ocurrido un problema, revise su internet o los servicios del servidor, Consulte al programador " + e, "Error critico", MessageBoxButtons.OK, MessageBoxIcon.Error); return(retorno); } }
public static bool Actualizar_empresa(constructor_de_respuestas upd) { bool retorno = false; try { MySqlCommand cmdupd = new MySqlCommand(string.Format("UPDATE datos_empresa SET nombre= '{0}', email = '{1}', telefono = '{2}', foto_empresa = '{3}', nit = '{4}', direccion = '{5}', Representante = '{6}', tipo_empresa = '{7}' WHERE id_datos_empresa ='{8}'", upd.), Conexion.obtenerconexion); retorno = Convert.ToBoolean(cmdupd.ExecuteNonQuery()); if (retorno == true) { MessageBox.Show("los datos han sido actualizados correctamente.", "El proceso ha sido completado", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Los Datos no pudieron ser actualizados.", "El proceso no fue completado", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(retorno); } catch (Exception e) { MessageBox.Show("Ha ocurrido un problema, revise los servicios del servidor o el internet, Consulte al Administrador " + e, "Error critico", MessageBoxButtons.OK, MessageBoxIcon.Error); return(retorno); } }
public static bool actualizarusu(constructor_primer_usuario upt) { bool retorno = false; try { constructor_de_respuestas ni = new constructor_de_respuestas(); MySqlCommand cmdupt = new MySqlCommand(string.Format("UPDATE tbusuarios SET nickname ='{0}', nombre_usuario ='{1}', apellido_usuario ='{2}', telefono = '{3}',Foto_usuario = '{4}', Correo ='{5}', dui = '{6}', nit = '{7}', id_estaado = '{8}', id_tipo_usuarios = '{9}', empresa = '{10}' WHERE id_usuarios='{11}' ", upt.usuario, upt.nombre_usuario, upt.apellido_usuario, upt.telefono, upt.Foto_usuario, upt.Correo, upt.dui, upt.nit, upt.id_estados, upt.id_tipo_usuarios, upt.empresa, upt.id_usuarios), Conexion.obtenerconexion()); retorno = Convert.ToBoolean(cmdupt.ExecuteNonQuery()); if (retorno == true) { MessageBox.Show("Los datos fueron actualizados correctamente.", "Proceso completado", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Los Datos no pudieron ser actualizados.", "Proceso no completado", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(retorno); } catch (Exception e) { MessageBox.Show("Ha ocurrido un problema, revise su internet o los servicios del servidor, Consulte al programador " + e, "Error critico", MessageBoxButtons.OK, MessageBoxIcon.Error); return(retorno); } }
private void button2_Click(object sender, EventArgs e) { constructor_de_respuestas res = new constructor_de_respuestas(); constructor_de_respuestas res2 = new constructor_de_respuestas(); constructor_de_respuestas res3 = new constructor_de_respuestas(); constructor_de_respuestas res4 = new constructor_de_respuestas(); int id = preguntas_y_respuestas.id(res); int id1 = preguntas_y_respuestas.id(res2); int id2 = preguntas_y_respuestas.id(res3); int id3 = preguntas_y_respuestas.id(res4); res.Respuesta = txtRespuesta1.Text; res.preguntas = Convert.ToInt32(cmbPregunta1.SelectedValue); res.usuarioss = id; int retornar = preguntas_y_respuestas.agregar_re(res); res2.Respuesta = txtRespuesta2.Text; res2.preguntas = Convert.ToInt32(cmbPregunta2.SelectedValue); res2.usuarioss = id1; int retorna = preguntas_y_respuestas.agregar_re(res2); res3.Respuesta = textBox1.Text; res3.preguntas = Convert.ToInt32(cmbPregunta3.SelectedValue); res3.usuarioss = id2; int retornara = preguntas_y_respuestas.agregar_re(res3); res4.Respuesta = textBox2.Text; res4.preguntas = Convert.ToInt32(cmbPregunta4.SelectedValue); res4.usuarioss = id3; int retornas = preguntas_y_respuestas.agregar_re(res4); button2.Visible = false; BtnGuardar.Visible = false; button1.Visible = true; }
private void BtnGuardar_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtNombres.Text) || string.IsNullOrWhiteSpace(txtApellidos.Text) || string.IsNullOrWhiteSpace(txtUsuario.Text) || string.IsNullOrWhiteSpace(txtClave.Text) || string.IsNullOrWhiteSpace(txtConfClave.Text) || string.IsNullOrWhiteSpace(txtEmail.Text) || string.IsNullOrWhiteSpace(txtRespuesta1.Text) || string.IsNullOrWhiteSpace(txtRespuesta2.Text) || string.IsNullOrWhiteSpace(textBox1.Text) || string.IsNullOrWhiteSpace(textBox2.Text) || string.IsNullOrWhiteSpace(txt_cel.Text) || string.IsNullOrWhiteSpace(maskDui.Text)) { MessageBox.Show("Llene todos los campos ", "WARNIG", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { if (txtClave.Text == txtConfClave.Text) { int usu = 1; constructor_de_respuestas res = new constructor_de_respuestas(); constructor_primer_usuario usuario = new constructor_primer_usuario(); usuario.usuario = txtUsuario.Text; usuario.nombre_usuario = txtUsuario.Text; usuario.apellido_usuario = txtApellidos.Text; usuario.Correo = txtEmail.Text; usuario.nit = txtCarne.Text; usuario.telefono = txt_cel.Text; usuario.fecha_de_nacimiento = dtNacimiento.Text; string intentos = "0"; usuario.intentos = intentos; usuario.id_estados = Convert.ToInt32(cmbEstado.SelectedValue.ToString()); usuario.id_tipo_usuarios = Convert.ToInt32(cmbTipoUsuario.SelectedValue.ToString()); usuario.empresa = Convert.ToInt32(cmbEmpresa.SelectedValue.ToString()); res.Respuesta = txtRespuesta1.Text; res.preguntas = Convert.ToInt32(cmbPregunta1.SelectedIndex.ToString()); res.usuarioss = usu; res.Respuesta = txtRespuesta2.Text; res.preguntas = Convert.ToInt32(cmbPregunta2.SelectedIndex.ToString()); res.usuarioss = usu; res.Respuesta = textBox1.Text; res.preguntas = Convert.ToInt32(cmbPregunta3.SelectedIndex.ToString()); res.usuarioss = usu; res.Respuesta = textBox2.Text; res.preguntas = Convert.ToInt32(cmbPregunta4.SelectedIndex.ToString()); res.usuarioss = usu; MemoryStream ms = new MemoryStream(); pbFoto.Image.Save(ms, ImageFormat.Jpeg); byte[] aByte = ms.ToArray(); string imagen = Convert.ToBase64String(aByte); usuario.Foto_usuario = imagen; int retorno = control_usuario.registro_usuario(usuario); usuario.contraseña_usuario = Validaciones.md5(txtClave.Text); } else { MessageBox.Show("La contraseña no es la misma porfavor corrijala y pongala denuevo", "La contraseña no es la misma"); } } }
private void btnSelect_Preguntas_Click(object sender, EventArgs e) { constructor_de_respuestas resp = new constructor_de_respuestas(); resp.Respuesta = txtRespuesta_1.Text; resp.preguntas = Convert.ToInt32(cbPregunta_1.SelectedIndex.ToString()); resp.Respuesta = txtRespuesta_2.Text; resp.preguntas = Convert.ToInt32(cbPregunta_2.SelectedIndex.ToString()); resp.Respuesta = txtRespuesta_3.Text; resp.preguntas = Convert.ToInt32(cbPregunta_3.SelectedIndex.ToString()); resp.Respuesta = txtRepuesta_4.Text; resp.preguntas = Convert.ToInt32(cbPregunta_4.SelectedIndex.ToString()); }
public static int agregar_re(constructor_de_respuestas add) { int retorno = 0; try { MySqlCommand cmdagregar = new MySqlCommand(string.Format("INSERT INTO tbusuarios(preguntas, Respuesta, usuarioss) VALUES ('{0}','{1}','{2}')", add.preguntas, add.Respuesta, add.usuarioss), Conexion.obtenerconexion()); retorno = Convert.ToInt16(cmdagregar.ExecuteNonQuery()); if (retorno > 0) { MessageBox.Show("Caracteres correctos", "preguntas y respuestas", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(retorno); } catch (Exception ex) { MessageBox.Show("error en la base de datos" + ex, "Error en Preguntas y respuestas", MessageBoxButtons.OK, MessageBoxIcon.Warning); return(retorno); } }
public static int id(constructor_de_respuestas jj) { int datos = 0; try { string query5 = "SELECT id_usuarios FROM tbusuarios"; MySqlCommand cmdselect = new MySqlCommand(string.Format(query5, jj.usuario), Conexion.obtenerconexion()); datos = Convert.ToInt16(cmdselect.ExecuteScalar()); if (datos >= 1) { MessageBox.Show("se pudo contactar con su empresa", "FELICIDADES", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(datos); } catch (Exception) { MessageBox.Show("no se pudo contactar con su empresa", "ADVERTENCIA", MessageBoxButtons.OK, MessageBoxIcon.Information); return(datos); } }
private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("¿ya has terminado de responder? ¿no has duplicado preguntas verdad?", "Preguntas", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (textBox1.Text.Trim() == "" || textBox4.Text.Trim() == "" || textBox2.Text.Trim() == "" || textBox3.Text.Trim() == "") { MessageBox.Show("Llene todo los campos", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { constructor_de_respuestas agr = new constructor_de_respuestas(); constructor_de_respuestas res2 = new constructor_de_respuestas(); constructor_de_respuestas res3 = new constructor_de_respuestas(); constructor_de_respuestas res4 = new constructor_de_respuestas(); agr.Respuesta = textBox1.Text; agr.preguntas = Convert.ToInt16(comboBox1.SelectedValue); agr.usuarioss = Convert.ToInt16(textBox5.Text); res2.Respuesta = textBox4.Text; res2.preguntas = Convert.ToInt16(comboBox2.SelectedValue); res2.usuarioss = Convert.ToInt16(textBox5.Text); res3.Respuesta = textBox2.Text; res3.preguntas = Convert.ToInt16(comboBox3.SelectedValue); res3.usuarioss = Convert.ToInt16(textBox5.Text); res4.Respuesta = textBox3.Text; res4.preguntas = Convert.ToInt16(comboBox4.SelectedValue); res4.usuarioss = Convert.ToInt16(textBox5.Text); int retorno = preguntas_y_respuestas.agregar_re(agr); int retor = preguntas_y_respuestas.agregar_re(res2); int re = preguntas_y_respuestas.agregar_re(res3); int rep = preguntas_y_respuestas.agregar_re(res4); frmLogin frm = new frmLogin(); frm.Show(); this.Hide(); } } }
private void btnSelect_Preguntas_Click(object sender, EventArgs e) { try { string usuario = lblUsuario.Text; if (cbPregunta_1.Text != cbPregunta_2.Text && cbPregunta_1.Text != cbPregunta_3.Text && cbPregunta_1.Text != cbPregunta_4.Text && cbPregunta_2.Text != cbPregunta_3.Text && cbPregunta_2.Text != cbPregunta_4.Text && cbPregunta_3.Text != cbPregunta_4.Text) { Console.WriteLine("asdfa" + cbPregunta_1.SelectedValue); int idpregunta1 = (int)cbPregunta_1.SelectedValue; int idpregunta2 = (int)cbPregunta_2.SelectedValue; int idpregunta3 = (int)cbPregunta_3.SelectedValue; int idpregunta4 = (int)cbPregunta_4.SelectedValue; constructor_de_respuestas respt1 = new constructor_de_respuestas(usuario, idpregunta1); respt1.asignarRespuesta(); Console.WriteLine(respt1.Respuesta); constructor_de_respuestas respt2 = new constructor_de_respuestas(usuario, idpregunta2); respt2.asignarRespuesta(); constructor_de_respuestas respt3 = new constructor_de_respuestas(usuario, idpregunta3); respt3.asignarRespuesta(); constructor_de_respuestas respt4 = new constructor_de_respuestas(usuario, idpregunta4); respt4.asignarRespuesta(); string pgta1 = txtRespuesta_1.Text; Boolean comparacion1 = pgta1.ToUpper().Equals(respt1.Respuesta.ToUpper()); Console.WriteLine(comparacion1); string pgta2 = txtRespuesta_2.Text; Boolean comparacion2 = pgta2.ToUpper().Equals(respt2.Respuesta.ToUpper()); Console.WriteLine(comparacion2); string pgta3 = txtRespuesta_3.Text; Boolean comparacion3 = pgta3.ToUpper().Equals(respt3.Respuesta.ToUpper()); Console.WriteLine(comparacion3); string pgta4 = txtRepuesta_4.Text; Boolean comparacion4 = pgta4.ToUpper().Equals(respt4.Respuesta.ToUpper()); Console.WriteLine(comparacion4); Console.WriteLine(pgta1.ToUpper().CompareTo(respt1.Respuesta.ToUpper())); if (comparacion1 && comparacion2 && comparacion3 && comparacion4) { Console.WriteLine("Son iguales"); frmPreguntaSeguridad_RecuContra frm_rec = new frmPreguntaSeguridad_RecuContra(); frm_rec.Show(); this.Close(); } else { Console.WriteLine("Son diferentes"); } } else { MessageBox.Show("Seleccione preguntas diferentes."); } } catch (Exception ex) { Console.WriteLine(ex); } cn.Open(); cmd.Connection = cn; try { cmd.CommandText = "select count(*) from tbrespuesta where respuesta = '" + txtRespuesta_1.Text + "'"; int valor = int.Parse(cmd.ExecuteScalar().ToString()); //Comparamos si el valor recibido es 1 entonces existe si no NO if (valor == 1) { frmNuevaContraseña frm = new frmNuevaContraseña(); frm.Show(); this.Hide(); } else { labelMensaje.Text = "La respuesta es incorrecta o no existe"; } } catch (Exception ex) { MessageBox.Show("Error en encontrar usuario" + ex, "Error de encontrame al usuario", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } cn.Close(); }