Ejemplo n.º 1
0
        /// <summary>
        /// Deletes a selected game from the listbox and the system.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            //Instantiate a DBConnect class called connect.
            DBConnect connect = new DBConnect();

            //Check if the selected game is a ps4.
            if (lbxGames.SelectedItem is PS4)
            {
                //Cast the selected item into a ps4 class.
                PS4 toDelete = (PS4)lbxGames.SelectedItem;
                //Use the .DeleteGame method to delete the game from the system.
                connect.DeleteGame(toDelete.ID);
            }
            //Check if the selected game is a xbone.
            else if (lbxGames.SelectedItem is XBONE)
            {
                //Cast the selected item into a xbone class.
                XBONE toDelete = (XBONE)lbxGames.SelectedItem;
                //Use the .DeleteGame method to delete the game from the system.
                connect.DeleteGame(toDelete.ID);
            }
            //Check if the selected game is a wiiu.
            else if (lbxGames.SelectedItem is WII_U)
            {
                //Cast the selected item into a wiiu class.
                WII_U toDelete = (WII_U)lbxGames.SelectedItem;
                //Use the .DeleteGame method to delete the game from the system.
                connect.DeleteGame(toDelete.ID);
            }
            //Refresh the data shown in the listbox.
            RefreshData();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Get the selected item from the listbox and use the details as properties for a game class to edit.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnEdit_Click(object sender, EventArgs e)
 {
     //Check if the selected item is a ps4 game.
     if (lbxGames.SelectedItem is PS4)
     {
         //Create a ps4 class to edit.
         PS4 editGame = new PS4();
         //Cast the selected item in the listbox into a ps4 class.
         editGame = (PS4)lbxGames.SelectedItem;
         //Set the radio button to ps4.
         rdoPS4.Checked = true;
         //Set the texts in the textboxes to the properties of the ps4 class.
         tbxTitle.Text     = editGame.Title;
         tbxYear.Text      = editGame.Year.ToString();
         tbxPublisher.Text = editGame.Publisher;
         tbxQuantity.Text  = editGame.Quantity.ToString();
         tbxPrice.Text     = editGame.Price.ToString();
         tbxOther.Text     = editGame.PsMove;
     }
     //Check if the selected item is a xbone game.
     else if (lbxGames.SelectedItem is XBONE)
     {
         //Create a xbone class to edit.
         XBONE editGame = new XBONE();
         //Cast the selected item in the listbox into a xbone class.
         editGame = (XBONE)lbxGames.SelectedItem;
         //Set the radio button to xbone.
         rdoXBONE.Checked = true;
         //Set the texts in the textboxes to the properties of the xbone class.
         tbxTitle.Text     = editGame.Title;
         tbxYear.Text      = editGame.Year.ToString();
         tbxPublisher.Text = editGame.Publisher;
         tbxQuantity.Text  = editGame.Quantity.ToString();
         tbxPrice.Text     = editGame.Price.ToString();
         tbxOther.Text     = editGame.Kinect;
     }
     //Check if the selected item is a wiiu game.
     else if (lbxGames.SelectedItem is WII_U)
     {
         //Create a wiiu class to edit.
         WII_U editGame = new WII_U();
         //Cast the selected item in the listbox into a wiiu class.
         editGame = (WII_U)lbxGames.SelectedItem;
         //Set the radio button to wiiu.
         rdoWIIU.Checked = true;
         //Set the texts in the textboxes to the properties of the wiiu class.
         tbxTitle.Text     = editGame.Title;
         tbxYear.Text      = editGame.Year.ToString();
         tbxPublisher.Text = editGame.Publisher;
         tbxQuantity.Text  = editGame.Quantity.ToString();
         tbxPrice.Text     = editGame.Price.ToString();
         tbxOther.Text     = editGame.GamePad;
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Method to convert a string array to a ps4 game.
        /// </summary>
        /// <param name="gameSpecs"></param>
        /// <returns> Returns a game class. </returns>
        public Game ConvertToPS4(string[] gameSpecs)
        {
            //Create a new ps4 class.
            PS4 ps4Game = new PS4();

            //Check if the game is a ps4 game.
            if (gameSpecs[2] == "PS4")
            {
                //Use the string array as properties for the game.
                ps4Game.ID        = int.Parse(gameSpecs[0]);
                ps4Game.Title     = gameSpecs[1];
                ps4Game.Platform  = gameSpecs[2];
                ps4Game.Year      = int.Parse(gameSpecs[3]);
                ps4Game.Publisher = gameSpecs[4];
                ps4Game.Quantity  = int.Parse(gameSpecs[5]);
                ps4Game.Price     = int.Parse(gameSpecs[6]);
                ps4Game.PsMove    = gameSpecs[7];
            }
            //Return game.
            return(ps4Game);
        }