public ActionResult ViewPlaylist()
        {
            DB.Start();

            String PName = Request.Form["playListDropdown"];

            string queryViewSongs = "UPDATE [dbo].[Song] ";

            queryViewSongs += "SET [dbo].[Song].[PLIST_ID] = (SELECT [dbo].[Playlist].[PLIST_ID] FROM [dbo].[Playlist] ";

            SqlCommand commandViewSongs = new SqlCommand(queryViewSongs, DB.cnn);

            if (PName == "")
            {
                //If no playlist name enterred, don't do anything ...
                MessageBox.Show("Please complete required fields.");

                //Close data readers
                DB.CloseDB(DB.cnn);

                //Redirect to Login
                return(RedirectToAction("Index", "ViewPlaylist"));
            }
            else
            {
                //If playlist name is valid, add the song to the table
                MessageBox.Show("Playlist loaded successfully. :-)");

                //Close data readers
                DB.CloseDB(DB.cnn);

                //Redirect to Login
                return(RedirectToAction("Index", "ViewPlaylist"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult CreateUser()
        {
            DB.Start();

            String FName   = Request.Form["firstName"];
            String LName   = Request.Form["lastName"];
            String EMail   = Request.Form["eMail"];
            String UName   = Request.Form["userName"];
            String PWord   = Request.Form["passWord"];
            String PNumber = Request.Form["phoneNumber"];
            String BDay    = Request.Form["birthDay"];

            SqlCommand queryUsername = new SqlCommand("Select * From [dbo].[User] Where [dbo].[User].[USER_UNAME] = '" + UName + "';", DB.cnn);
            string     insertString  = "Insert into [dbo].[User] (USER_UNAME, USER_PASSWORD, USER_FNAME, USER_LNAME, USER_BIRTHDAY, USER_PHONE, USER_EMAIL)";

            insertString += "Values('" + UName + "', '" + PWord + "', '" + FName + "', '" + LName + "', '" + BDay + "', '" + PNumber + "', '" + EMail + "');";

            SqlCommand insertQuery = new SqlCommand(insertString, DB.cnn);

            SqlDataReader tableReader = queryUsername.ExecuteReader();

            //SqlDataReader insertUser = insertQuery.ExecuteReader();

            if (tableReader.HasRows)
            {
                //If a username exists, don't do anything
                MessageBox.Show("The username '" + UName + "' is already taken.");

                //Close data readers
                tableReader.Close();
                DB.CloseDB(DB.cnn);

                //Redirect to Login
                return(RedirectToAction("Index", "SignUp"));
            }
            else
            {
                //If username doesn't exist, add them to the User table
                MessageBox.Show("Congratulations! Sign up successful.");

                //Close data readers
                tableReader.Close();
                SqlDataReader insertUser = insertQuery.ExecuteReader();
                insertUser.Close();
                DB.CloseDB(DB.cnn);

                //Redirect to Login
                return(RedirectToAction("Index", "Login"));
            }
        }
Ejemplo n.º 3
0
        public ActionResult MoveSong()
        {
            DB.Start();

            String SName     = Request.Form["songName"];
            String AName     = Request.Form["artistName"];
            String CurrPName = Request.Form["currPlaylistName"];
            String NewPName  = Request.Form["newPlaylistName"];

            string queryMoveSong = "UPDATE [dbo].[Song] ";

            queryMoveSong += "SET [dbo].[Song].[PLIST_ID] = (SELECT [dbo].[Playlist].[PLIST_ID] FROM [dbo].[Playlist] ";
            queryMoveSong += "WHERE '" + NewPName + "' = [dbo].[Playlist].[PLIST_PNAME]) WHERE [dbo].[Song].[SONG_NAME] = '" + SName + "';";
            queryMoveSong += "UPDATE [dbo].[Catalog] ";
            queryMoveSong += "SET [dbo].[Catalog].[PLIST_ID] = (SELECT [dbo].[Playlist].[PLIST_ID] FROM [dbo].[Playlist] WHERE '" + NewPName + "' = [dbo].[Playlist].[PLIST_PNAME]) ";
            queryMoveSong += "WHERE [dbo].[Catalog].[SONG_ID] = (SELECT [dbo].[SONG].[SONG_ID] FROM [dbo].[Song] WHERE '" + SName + "' = [dbo].[SONG].[SONG_NAME]);";

            SqlCommand commandMoveSong = new SqlCommand(queryMoveSong, DB.cnn);

            if (CurrPName == "" || NewPName == "" || AName == "" || SName == "")
            {
                //If no playlist name enterred, don't do anything ...
                MessageBox.Show("Please complete required fields.");

                //Close data readers
                DB.CloseDB(DB.cnn);

                //Redirect to Login
                return(RedirectToAction("Index", "UpdatePlaylist"));
            }
            else
            {
                //If playlist name is valid, add the song to the table
                MessageBox.Show(SName + " has been moved from playlist " + CurrPName + " to " + NewPName + ".");

                //Close data readers
                SqlDataReader moveSong = commandMoveSong.ExecuteReader();
                moveSong.Close();
                DB.CloseDB(DB.cnn);

                //Redirect to Login
                return(RedirectToAction("Index", "UpdatePlaylist"));
            }
        }
Ejemplo n.º 4
0
        public ActionResult CreateSong()
        {
            DB.Start();

            String SName = Request.Form["songName"];
            String AName = Request.Form["artistName"];
            String PName = Request.Form["playlistNameDropdown"];
            String PDesc = Request.Form["playlistDescr"];

            //string queryAddSong = "INSERT INTO [dbo].[Playlist] (PLIST_PNAME, PLIST_DESC) VALUES('" + PName +"', '" + PDesc + "');";
            string queryAddSong = "INSERT INTO [dbo].[Song] (SONG_NAME, PLIST_ID) VALUES('" + SName + "', (SELECT [dbo].[Playlist].[PLIST_ID] FROM [dbo].[Playlist] WHERE'" + PName + "' = [dbo].[Playlist].[PLIST_PNAME]));";

            queryAddSong += "INSERT INTO [dbo].[Artist] (ARTIST_NAME, SONG_ID) VALUES('" + AName + "', (SELECT [dbo].[Song].[SONG_ID] FROM [dbo].[Song] WHERE '" + SName + "' = [dbo].[Song].[SONG_NAME]));";
            queryAddSong += "INSERT INTO [dbo].[Catalog] (SONG_ID, PLIST_ID) VALUES((SELECT [dbo].[Song].[SONG_ID] FROM [dbo].[Song] WHERE '" + SName + "' = [dbo].[Song].[SONG_NAME]), ";
            queryAddSong += "(SELECT [dbo].[Playlist].[PLIST_ID] FROM [dbo].[Playlist] WHERE '" + PName + "' = [dbo].[Playlist].[PLIST_PNAME]));";


            SqlCommand commandAddSong = new SqlCommand(queryAddSong, DB.cnn);

            if (PName == "" || AName == "" || SName == "")
            {
                //If no playlist name enterred, don't do anything ...
                MessageBox.Show("Please complete required fields.");

                //Close data readers
                DB.CloseDB(DB.cnn);

                //Redirect to Login
                return(RedirectToAction("Index", "AddSong"));
            }
            else
            {
                //If playlist name is valid, add the song to the table
                MessageBox.Show(SName + " has been added to playlist: " + PName + ".");

                //Close data readers
                SqlDataReader addSong = commandAddSong.ExecuteReader();
                addSong.Close();
                DB.CloseDB(DB.cnn);

                //Redirect to Login
                return(RedirectToAction("Index", "AddSong"));
            }
        }