コード例 #1
0
        /// <summary>
        /// Build file list function that is used to
        /// grab all current files from the database and store them for use later
        /// </summary>
        private void buildFileList()
        {
            string[] fileColumns = { "id", "game_id", "title", "description", "filename" };                                         //what Columns I am wanting from the table
            string[] fileInfo    =
                SQLUltility.SelectSQL("files", cs, fileColumns).Split('_');                                                         //getting the requested columns from the table

            foreach (string info in fileInfo)                                                                                       //for every item returned by selectsql
            {
                if (info.Length > 0)                                                                                                //as long as it is not blank
                {
                    String[]    splitInfo  = info.Split('|');                                                                       //split the data from the SQL database up for easy parsing
                    FileElement newElement = new FileElement(splitInfo[1], splitInfo[2], splitInfo[3], splitInfo[4], splitInfo[5]); //make a new element with requested info
                    fileList.Add(newElement);                                                                                       //add it to filelist for later use
                }
            }

            //This section makes sure the dropdown list for the files is in line with the selected game on update
            if (GameDropDown.SelectedIndex != -1)                   //as long the drop down is not null
            {
                string text = GameDropDown.SelectedItem.ToString(); //grab the selected item into text
                string ID   = Regex.Match(text, @"\d+").Value;      //Grab the ID out of the string

                ClipDropDown.Items.Clear();                         //clear the file dropdown list

                foreach (FileElement info in fileList)              //check all the files
                {
                    if (info.GameID.Equals(ID))                     //if they match the current ID
                    {
                        ClipDropDown.Items.Add(info.Title);         //add it to the drop down list
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Event Listener for the Done Button the Add New Game page
        /// </summary>
        private void DoneButton_Click(object sender, RoutedEventArgs e)
        {
            string newTitle;
            int    lastID;

            Int32.TryParse(currentGameList[currentGameList.Count - 1].ID, out lastID); //parse out the ID from the last game in the list

            int newID = lastID + 1;                                                    //Add one to the the last ID

            newTitle = "'" + newID + "'" + "," + "'" + NewGameTitle.Text + "'";        //make the new game info string

            SQLUltility.addToTable("games", "id, title", newTitle, cs);                //add the new game to the table

            parentWindow.updateGameList();                                             //update the game list
            this.Close();
        }
コード例 #3
0
        /// <summary>
        /// Event Listener for the Update Button on the main screen
        /// Writes out whatever is written in the description box to the current selected item
        /// </summary>
        private void UpdateButton_Click(object sender, RoutedEventArgs e)
        {
            int selectedIndexCurrent;                                                               //variable to hold what file index was selected

            selectedIndexCurrent = ClipDropDown.SelectedIndex;                                      //Set the index to the current selection
            if (ClipDropDown.SelectedIndex != -1)                                                   //Check to make sure it is not null
            {
                string text = ClipDropDown.SelectedItem.ToString();                                 //convert the selected item to a string

                foreach (FileElement info in fileList)                                              //Check each file in filelist
                {
                    if (info.Title.Equals(text))                                                    //If the list matches the selected title
                    {
                        SQLUltility.updateTable("files", "description", ClipDes.Text, info.ID, cs); //update the current selection with the new description
                        updateFileList();                                                           //update the file list to show the changes
                        ClipDropDown.SelectedIndex = selectedIndexCurrent;                          //reset the dropdown to the previous selected item
                        break;
                    }
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Build game list function that is used to
        /// grab all current games from the database and store them for use later
        /// </summary>
        private void buildGameList()
        {
            string[] gameColumns = { "id", "title" };                                     //what Columns I am wanting from the table
            string[] gameInfo    =
                SQLUltility.SelectSQL("games", cs, gameColumns).Split('_');               //parsing the data from the SQL data base into a string array

            foreach (string info in gameInfo)                                             //for every item returned by selectsql
            {
                if (info.Length > 0)                                                      //as long as it is not blank
                {
                    String[]    splitInfo  = info.Split('|');                             //Split the data up between the ID and Name
                    GameElement newElement = new GameElement(splitInfo[1], splitInfo[2]); //make a new element with the ID and name
                    gameList.Add(newElement);                                             //add it to the game list
                }
            }

            foreach (GameElement info in gameList)                           //for every game loaded from the database
            {
                GameDropDown.Items.Add("ID: " + info.ID + " " + info.Title); //add it to the dropdown list
            }
        }
コード例 #5
0
        /// <summary>
        /// Event handle for the Done button on Add new File page
        /// </summary>
        private void DoneButton_Click(object sender, RoutedEventArgs e)
        {
            string newTitle;
            int    newID;

            newID = currentFileList.Count + 1; //set the new ID to the the current count + 1 to keep track

            if (selectedFile != null)          //if they have selected a file
            {
                //set up the new file info from the UI
                newTitle = "'" + newID + "'," + "'" + currentGameList[GameDropDown.SelectedIndex].ID + "'," + "'" + NewClipTitle.Text + "'," + "'" + NewClipDes.Text + "'," + "'" + selectedFile + "'";

                //Call the add to table funciton to add the new file to the table
                SQLUltility.addToTable("files", "id, game_id, title, description, filename", newTitle, cs);

                parentWindow.updateGameList();         //update the gamelist
                NoClip.Visibility = Visibility.Hidden; //make sure the "No Clip" error is hidden
                this.Close();
            }
            else
            {
                NoClip.Visibility = Visibility.Visible;//if no clip selected throw up the error
            }
        }