Example #1
0
        private void addNewSongToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddSong open = new AddSong();

            if (listView1.Items.Count == 0)
            {
                open.songNumberProperty = "1";
            }
            else
            {
                int songNoInt = listView1.Items.Count;
                songNoInt++;
                open.songNumberProperty = songNoInt.ToString();;
            }

            this.Hide();
            open.Show();
        }
Example #2
0
        private void fill(string queryString, string path)
        {
            //connect to server
            SqlConnection connection = new SqlConnection(path);

            connection.Open();
            //execute sql command
            SqlCommand command = new SqlCommand(queryString, connection);
            var        reader  = command.ExecuteReader();

            try
            {
                int counter = 1;

                while (reader.Read())
                {
                    Playlist oPlaylist      = new Playlist();
                    string[] studentElement = { reader["SongNo"].ToString(), reader["SongName"].ToString(), reader["Artist"].ToString(), reader["Album"].ToString() };
                    oPlaylist.songNo   = counter.ToString();
                    oPlaylist.songName = studentElement[1];
                    oPlaylist.artist   = studentElement[2];
                    oPlaylist.album    = studentElement[3];
                    playlist.Add(oPlaylist);

                    ListViewItem listview = new ListViewItem(counter.ToString());
                    for (int i = 1; i < studentElement.Length; i++)
                    {
                        listview.SubItems.Add(studentElement[i]);
                    }
                    listView1.Items.Add(listview);
                    counter++;
                }
            }
            catch
            {
                AddSong newSong = new AddSong();
                newSong.ShowDialog();
            }
            connection.Close();
            reader.Close();
        }