private void insertData(string usernames, string password, string email)
        {
            auth = new SprawdzW_BD();
            auth.getConnection();


            try
            {
                using (SQLiteConnection con = new SQLiteConnection(auth.connectionString))
                {
                    con.Open();
                    SQLiteCommand cmd   = new SQLiteCommand();
                    string        query = @"INSERT INTO Agus (Username, Password, Email) VALUES (@username, @password, @email)";
                    cmd.CommandText = query;
                    cmd.Connection  = con;

                    cmd.Parameters.Add(new SQLiteParameter("@username", usernames));
                    cmd.Parameters.Add(new SQLiteParameter("@password", password));
                    cmd.Parameters.Add(new SQLiteParameter("@email", email));
                    cmd.ExecuteNonQuery();

                    MessageBox.Show("Dokonales rejestracji na V semestr UTP!", "Rejestracja pomyslna!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void checkAccount(string username, string password)
        {
            auth = new SprawdzW_BD();
            auth.getConnection();

            try
            {
                using (SQLiteConnection con = new SQLiteConnection(auth.connectionString))
                {
                    con.Open();
                    SQLiteCommand cmd   = new SQLiteCommand();
                    string        query = @"SELECT * FROM Agus WHERE Username='******'";

                    int count = 0;
                    cmd.CommandText = query;
                    cmd.Connection  = con;

                    SQLiteDataReader read = cmd.ExecuteReader();
                    while (read.Read())
                    {
                        count++;
                    }

                    if (count == 1)
                    {
                        MessageBox.Show("Zalogowano pomyslnie!", "Komunikat poprawnego logowania", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        usernames = username;
                        this.Close();
                    }

                    else
                    {
                        MessageBox.Show("Podany uzytkownik nie istnieje lub podales nieprawidlowy login lub haslo.", "Bledne dane", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void checkAccount(string username)
        {
            auth = new SprawdzW_BD();

            auth.createDatabase();
            auth.getConnection();

            try {
                using (SQLiteConnection con = new SQLiteConnection(auth.connectionString))
                {
                    SQLiteCommand cmd = new SQLiteCommand();
                    con.Open();

                    int    count = 0;
                    string query = @"SELECT * FROM Agus WHERE Username='******'";
                    cmd.CommandText = query;
                    cmd.Connection  = con;

                    SQLiteDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        count++;
                    }
                    if (count == 1)
                    {
                        MessageBox.Show("Cos tam komunikat 33333", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    else if (count == 0)
                    {
                        insertData(txtUsername.Text, txtPassword.Text, txtEmail.Text);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }