Ejemplo n.º 1
0
        //open connection to database
        private bool OpenConnection()
        {
            try
            {
                connection.Open();
                return(true);
            }
            catch (MySqlException ex)
            {
                //When handling errors, you can your application's response based
                //on the error number.
                //The two most common error numbers when connecting are as follows:
                //0: Cannot connect to server.
                //1045: Invalid user name and/or password.
                switch (ex.Number)
                {
                case 0:
                    Msgbox.Show("Cannot connect to server.  Contact administrator");
                    break;

                case 1045:
                    Msgbox.Show("Invalid username/password, please try again");
                    break;
                }
                return(false);
            }
        }
Ejemplo n.º 2
0
 //Close connection
 private bool CloseConnection()
 {
     try
     {
         connection.Close();
         return(true);
     }
     catch (MySqlException ex)
     {
         Msgbox.Show(ex.Message);
         return(false);
     }
 }
Ejemplo n.º 3
0
        private void btnIngresar_Click(object sender, RoutedEventArgs e)
        {
            var      username = txtUsuario.Text;
            var      pass     = txtPassword.Password.ToString();
            MySQLCon mysql    = new MySQLCon();

            List <string>[] checkUsers = new List <string> [1000];
            checkUsers = mysql.Select();
            if (username == "NobleSix" && pass == "haha")
            {
                Msgbox.Show("Bienvenido NobleSix");
            }
            else
            {
                Msgbox.Show("Usuario/Password Incorrecto");
            }
        }
Ejemplo n.º 4
0
        private async void btnRegistrar_Click(object sender, RoutedEventArgs e)
        {
            string stringKey   = "XZ*+2!@#4>.";
            var    button      = sender as Button;
            var    username    = txtUsuario.Text;
            var    password    = txtPassword.Password.ToString();
            var    confpass    = txtConfirmaPassword.Password.ToString();
            string encryptPass = await EncryptStringHelper(password, stringKey);

            if (password == confpass)
            {
                MySQLCon mysql = new MySQLCon();
                mysql.InsertUser(username, password);
            }
            else
            {
                Msgbox.Show("Los passwords no coinciden.");
            }
        }