Beispiel #1
0
        public static int ActualizarPreguntas(MySqlConnection conexion, Preguntas p)
        {
            int          retorno = 0;
            MySqlCommand comando = new MySqlCommand(String.Format("UPDATE recuperaciones SET id_pregunta1='{1}', respuesta='{2}' WHERE id_user1='{0}' AND id_recuperacion='{3}'", p.id_user1, p.id_pregunta, p.respuesta, p.id_recuperacion), conexion);

            retorno = comando.ExecuteNonQuery();
            return(retorno);
        }
Beispiel #2
0
        public static Preguntas pre(MySqlDataReader reader)
        {
            Preguntas pregunta = new Preguntas();

            pregunta.id_pregunta = Convert.ToInt32(reader["id_pregunta"]);
            pregunta.pregunta    = Convert.ToString(reader["pregunta"]);

            return(pregunta);
        }
Beispiel #3
0
        private void obtenerIDPreguntas(int id_usuario)
        {
            try
            {
                if (conexion.abrirconexion() == true)
                {
                    List <Clases.Preguntas> pregunta = new List <Clases.Preguntas>();
                    int n_pre = 0;
                    int i     = 0;

                    pregunta = Clases.Preguntas.ObtenerIDPreguntas(conexion.conexion, id_usuario);
                    conexion.cerrarconexion();

                    if (pregunta != null)
                    {
                        while (n_pre < 3 && i < pregunta.Count)
                        {
                            if (pregunta[i].id_user1 == id_usuario)
                            {
                                if (i == 0)
                                {
                                    pre = pregunta[i];
                                    i++;
                                    n_pre++;
                                }
                                else if (i == 1)
                                {
                                    pre2 = pregunta[i];
                                    i++;
                                    n_pre++;
                                }
                                else if (i == 2)
                                {
                                    pre3 = pregunta[i];
                                    i++;
                                    n_pre++;
                                }
                            }
                            else
                            {
                                i++;
                                n_pre++;
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("No existen preguntas de seguridad de este usuario.", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Ha ocurrido un error: " + ex, "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void ObtenerIdRecuperacion()
        {
            int n_pre = 0;

            try
            {
                conexion.cerrarconexion();
                if (conexion.abrirconexion() == true)
                {
                    List <Clases.Preguntas> pregunta = new List <Clases.Preguntas>();


                    pregunta = Clases.Preguntas.ObtenerIDPreguntas(conexion.conexion, Clases.Usuario_logeado.id_usuario);
                    conexion.cerrarconexion();

                    if (pregunta != null)
                    {
                        while (n_pre < pregunta.Count)
                        {
                            //if (pregunta[i].id_user1 == Clases.Usuario_logeado.id_usuario)
                            //{
                            if (n_pre == 0)
                            {
                                pre = pregunta[0];
                                n_pre++;
                            }
                            else if (n_pre == 1)
                            {
                                pre2 = pregunta[1];

                                n_pre++;
                            }
                            else if (n_pre == 2)
                            {
                                pre3 = pregunta[2];

                                n_pre++;
                            }

                            //}
                            //else
                            //{
                            //    i++;
                            //    n_pre++;
                            //}
                        }
                    }
                }
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #5
0
        public static List <Preguntas> ObtenerIDPreguntas(MySqlConnection conexion, int id_usuario)
        {
            List <Preguntas> listap  = new List <Preguntas>();
            MySqlCommand     comando = new MySqlCommand(String.Format("SELECT id_pregunta1, respuesta, id_user1, id_recuperacion FROM recuperaciones WHERE recuperaciones.id_user1='{0}'", id_usuario), conexion);
            MySqlDataReader  reader  = comando.ExecuteReader();

            while (reader.Read())
            {
                Preguntas p = new Preguntas();
                p.id_pregunta     = reader.GetInt32(0);
                p.respuesta       = reader.GetString(1);
                p.id_user1        = reader.GetInt32(2);
                p.id_recuperacion = reader.GetInt32(3);

                listap.Add(p);
            }
            return(listap);
        }