private void btnAddSong_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.songs(songName, artistName, audioFile, Album_idAlbum) values" + " ('" + txtSongTitle.Text + "', '" + txtSongArt.Text + "', '" + txtSongLink.Text + "' , (select idAlbum from jukebox.album where albName = '" + boxAlbm.Text + "'))", con)) cmd.ExecuteNonQuery(); MessageBox.Show("Record Inserted successfully.", "Information Message", MessageBoxButtons.OK, MessageBoxIcon.Information); using (MySqlCommand del = new MySqlCommand("delete from jukebox.usrrequest where artist = '" + txtSongArt.Text + "' and songTitle = '" + txtSongTitle.Text + "'; ", con)) del.ExecuteNonQuery(); this.Hide(); AdminPage a1 = new AdminPage(); a1.ShowDialog(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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); } }
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); } }
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); } }