コード例 #1
0
        //////////////////////////////////////////////////////////////////////////////////////////////////
        ///                                                                                            ///
        ///                             Comprueba si el usuario es correcto                            ///
        ///                                                                                            ///
        //////////////////////////////////////////////////////////////////////////////////////////////////

        private void btnLogin_Click(object sender, EventArgs e)
        {
            using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["BBDD"].ConnectionString))
            {
                conn.Open();
                MySqlCommand cmd = new MySqlCommand($"SELECT id_member, passwd, active FROM smf_members WHERE member_name = '{user.Text}'", conn);
                using (MySqlDataReader rdr = cmd.ExecuteReader())
                {
                    rdr.Read();
                    if (!rdr.HasRows)
                    {
                        MessageBox.Show("Usuario incorrecto", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
                        return;
                    }
                    if (rdr[1].ToString() == stringToSHA1(user.Text.ToLower() + pass.Password))
                    {
                        if (rdr["active"].ToString() == "0")
                        {
                            ActivateUser au = new ActivateUser(rdr[0].ToString());
                            au.Show();
                            this.Close();
                            return;
                        }
                        GetStarted gs = new GetStarted(rdr[0].ToString());
                        gs.Show();
                        this.Close();
                        return;
                    }
                    MessageBox.Show("Contraseña incorrecta", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
                    return;
                }
            }
        }
コード例 #2
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["BBDD"].ConnectionString))
     {
         conn.Open();
         MySqlCommand    cmd = new MySqlCommand($"SELECT validation_code FROM smf_members WHERE id_member = '{user}'", conn);
         MySqlDataReader rdr = cmd.ExecuteReader();
         rdr.Read();
         if (rdr["validation_code"].ToString() == code.Text)
         {
             rdr.Close();
             MySqlCommand cmd2 = new MySqlCommand($"UPDATE smf_members SET active = '1' WHERE id_member = '{user}'", conn);
             cmd2.ExecuteNonQuery();
             GetStarted gs = new GetStarted(user);
             gs.Show();
             this.Close();
             return;
         }
         MessageBox.Show("El codigo introducido no es correcto", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);
         rdr.Close();
         return;
     }
 }
コード例 #3
0
ファイル: Game.xaml.cs プロジェクト: domlopluis94/Game-Geo
        private Boolean finishGame(int round)
        {
            if (round > 5)
            {
                temporizador.Stop();
                MessageBox.Show($"Puntuacion: {points}", "Partida finalizada", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, MessageBoxOptions.DefaultDesktopOnly);

                using (MySqlConnection conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["BBDD"].ConnectionString))
                {
                    conn.Open();
                    MySqlCommand cmd = new MySqlCommand($"INSERT INTO partida(Torneo_idTorneo, 	Torneo_Usuarios_idUsuarios, Usuarios_idUsuarios, Continente_IDContinente, P_fecha, P_puntuacion) VALUES ('0', '0', '{user}','{continent}', now(),'{points}')", conn);
                    cmd.ExecuteNonQuery();
                }

                GetStarted gs = new GetStarted(user);
                gs.Show();
                this.Close();

                return(true);
            }

            return(false);
        }