Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                MySqlConnection con = new MySqlConnection(connectionString);

                MySqlCommand selectCommand = new MySqlCommand("select * from jukebox.users where userName= '******' and userPassword='******' ;", con);

                MySqlDataReader myReader;
                con.Open();
                myReader = selectCommand.ExecuteReader();

                int count = 0;
                while (myReader.Read())
                {
                    count = count + 1;
                }

                if (count == 1)
                {
                    if (this.txtUser.Text == "ADMIN")
                    {
                        MessageBox.Show("Welcome Administrator");
                        this.Hide();
                        AdminPage a1 = new AdminPage();
                        a1.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Username and password is correct");
                        this.Hide();
                        FirstPage p1 = new FirstPage("Welcome to Phoenix Jukebox! " + txtUser.Text);
                        p1.ShowDialog();
                    }
                }
                else if (count > 1)
                {
                    MessageBox.Show("Duplicate credentials...Access denied.");
                }
                else
                {
                    MessageBox.Show("Username and password is incorrect, please try again");
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                MySqlConnection con           = new MySqlConnection(connectionString);
                MySqlCommand    selectCommand = new MySqlCommand("select * from jukebox.songs where songName= '" + this.textDelSong.Text + "' and artistName ='" + this.textDelArt.Text + "' ;", con);
                MySqlCommand    deleteCommand = new MySqlCommand("delete from jukebox.songs where songName = '" + this.textDelSong.Text + "' and artistName = '" + this.textDelArt.Text + "'; ", con);
                MySqlDataReader myReader;
                con.Open();
                myReader = selectCommand.ExecuteReader();


                int count = 0;
                while (myReader.Read())
                {
                    count = count + 1;
                }

                myReader.Close();

                if (count == 1)
                {
                    myReader = deleteCommand.ExecuteReader();
                    MessageBox.Show("Deletion Successful");
                    this.Hide();
                    AdminPage a1 = new AdminPage();
                    a1.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Delete Unsuccessful");
                }
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #3
0
        private void btnAddAlb_Click(object sender, EventArgs e)
        {
            try
            {
                using (MySqlConnection con = new MySqlConnection(connectionString))
                {
                    if (con.State == System.Data.ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    using (MySqlCommand cmd = new MySqlCommand("insert into jukebox.album(AlbName, AlbGenre, Albart) values ('" + txtAlbName.Text + "', '" + boxAddGenre.Text + "', '" + pictureBox1.ImageLocation + "')", con))

                        cmd.ExecuteNonQuery();
                    MessageBox.Show("Record Inserted successfully.", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Hide();
                    AdminPage a1 = new AdminPage();
                    a1.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }