private void groupLabel_Click(object sender, EventArgs e) { GroupLabel tp = (GroupLabel)sender; Art_track_table.Controls.Clear(); string sql = "SELECT tracks.* FROM tracks INNER JOIN track_group ON tracks.idtracks = track_group.idTrack LEFT JOIN `group` ON `group`.idGroup = track_group.idGroup WHERE `group`.idGroup = " + tp.id + " GROUP BY tracks.trackName"; MySqlCommand command = new MySqlCommand(sql, conn); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { byte[] data = ((byte[])reader.GetValue(6)); TrackLabel t = new TrackLabel(reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), Convert.ToInt32(reader[4]), data); t.Click += new System.EventHandler(this.trackLabel_Click); t.Text = reader[1].ToString(); Art_track_table.Controls.Add(t, 0, MyPl_track_table.RowCount - 1); } reader.Close(); }
private void tab_panel_SelectedIndexChanged(object sender, EventArgs e) { TabControl tc; tc = (TabControl)sender; //MessageBox.Show(tc.SelectedIndex.ToString()); switch (tc.SelectedIndex) { case 0: { //news News_track_table.Controls.Clear(); string sql = "SELECT * from tracks;"; MySqlCommand command = new MySqlCommand(sql, conn); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { byte[] data = ((byte[])reader.GetValue(6)); TrackLabel t = new TrackLabel(reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), Convert.ToInt32(reader[4]), data); t.Click += new System.EventHandler(this.trackLabel_Click); t.Text = reader[1].ToString(); News_track_table.Controls.Add(t, 0, Tr_track_table.RowCount - 1); } reader.Close(); break; } case 1: { //charts Charts_track_table.Controls.Clear(); string sql = "SELECT * FROM tracks ORDER BY countListens DESC LIMIT 10; "; MySqlCommand command = new MySqlCommand(sql, conn); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { byte[] data = ((byte[])reader.GetValue(6)); TrackLabel t = new TrackLabel(reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), Convert.ToInt32(reader[4]), data); t.Click += new System.EventHandler(this.trackLabel_Click); t.Text = reader[1].ToString(); Charts_track_table.Controls.Add(t, 0, Tr_track_table.RowCount - 1); } reader.Close(); break; } case 2: { //Artists Art_artisits_table.Controls.Clear(); string sql = "SELECT * FROM `group`;"; MySqlCommand command = new MySqlCommand(sql, conn); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { GroupLabel t = new GroupLabel(reader[0].ToString(), reader[1].ToString(), reader[2].ToString()); t.Click += new System.EventHandler(this.groupLabel_Click); t.Text = reader[1].ToString(); Art_artisits_table.Controls.Add(t, 0, Art_artisits_table.RowCount - 1); } reader.Close(); break; } case 3: { //Tracks Tr_track_table.Controls.Clear(); string sql = "SELECT * from tracks;"; MySqlCommand command = new MySqlCommand(sql, conn); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { byte[] data = ((byte[])reader.GetValue(6)); TrackLabel t = new TrackLabel(reader[1].ToString(), reader[2].ToString(), reader[3].ToString(), Convert.ToInt32(reader[4]), data); t.Click += new System.EventHandler(this.trackLabel_Click); t.Text = reader[1].ToString(); Tr_track_table.Controls.Add(t, 0, Tr_track_table.RowCount - 1); } reader.Close(); break; } case 4: { //Playlists MyPl_pl_table.Controls.Clear(); string sql = "SELECT playlists.* FROM playlists INNER JOIN user_playlist ON user_playlist.idPlayList = playlists.idPlayLists LEFT JOIN user ON user_playlist.idUser = user.idUser WHERE user.idUser = "******" GROUP BY playlists.playListName"; MySqlCommand command = new MySqlCommand(sql, conn); MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { PlaylistLabel t = new PlaylistLabel(reader[0].ToString(), reader[1].ToString()); t.Click += new System.EventHandler(this.playlistLabel_Click); t.Text = reader[1].ToString(); MyPl_pl_table.Controls.Add(t, 0, MyPl_pl_table.RowCount - 1); } reader.Close(); break; } case 5: { //Settings login_textBox.Text = usr_login; password_textBox.Text = usr_pass; //Bitmap t = new Bitmap(avatar_patch); avatar_picturebox.Image = new Bitmap(avatar_patch); //t.Dispose(); break; } } }