//Function that is performed when button is clicked
        //Adjusts depending on action to be performed and node being performed on
        private async void Add_Click(object sender, RoutedEventArgs e)
        {
            object           data = null;                                         //Data that is added to databse
            object           obj  = null;                                         //obj is used to get unique key data
            FirebaseResponse resp = await client.GetTaskAsync("Counter/" + Node); //Gets data for counter

            Counter get = resp.ResultAs <Counter>();                              //Sets counter object to response from database

            //MessageBox.Show(get.cnt.ToString());

            if (Action == "Add") //Add
            {
                //Catches exception
                try
                {
                    if (Node == "Coaches") //Coaches
                    {
                        //Sets data to new coaches object with information that was inserted from user
                        data = new Coaches
                        {
                            CoachId  = Convert.ToInt32(get.cnt) + 1,
                            Age      = int.Parse(txt2.Text),
                            FName    = txt3.Text,
                            LName    = txt4.Text,
                            Phone_no = txt5.Text,
                            Role     = txt6.Text,
                            TeamID   = int.Parse(txt7.Text)
                        };

                        //Sets obj to new counter object and increases count by 1 to represent amount of unique key IDs in a node
                        obj = new Counter
                        {
                            cnt = Convert.ToInt32(get.cnt) + 1
                        };
                    }
                    else if (Node == "Extras") //Extras
                    {
                        //Sets data to new Extras object with user inputs
                        data = new Extras
                        {
                            ExtraID  = Convert.ToInt32(get.cnt) + 1,
                            Age      = int.Parse(txt2.Text),
                            FName    = txt3.Text,
                            LName    = txt4.Text,
                            Phone_no = txt5.Text,
                            Role     = txt6.Text,
                            TeamID   = int.Parse(txt7.Text)
                        };

                        //Sets obj to new Counter object and increasing amount of key IDs by 1
                        obj = new Counter
                        {
                            cnt = Convert.ToInt32(get.cnt) + 1
                        };
                    }
                }
                catch (Exception ex) //Catch exception when a string is inserted in a textbox but an integer is needed
                {
                    MessageBox.Show(ex.Message + ", Check what you inserted in the Textboxes");
                    return;
                }


                //Used to access the correct data for node and not overwriting data
                string index = (get.cnt + 1).ToString();

                SetResponse response = await client.SetTaskAsync(Node + "/" + index, data); //Updates data in Node



                SetResponse response1 = await client.SetTaskAsync("Counter/" + Node, obj); //Updates count

                //After button pressed all textboxes will clear
                this.txt1.Text = "";
                this.txt2.Text = "";
                this.txt3.Text = "";
                this.txt4.Text = "";
                this.txt5.Text = "";
                this.txt6.Text = "";
                this.txt7.Text = "";

                //Messagebox that informs user data was inserted
                MessageBox.Show("Data Inserted");
                return;
            }
            else if (Action == "Update")  //Update
            {
                //Catches exception
                try
                {
                    if (Node == "Coaches")
                    {
                        //Sets data to new coaches object with user inputted data
                        data = new Coaches
                        {
                            CoachId  = int.Parse(txt1.Text),
                            Age      = int.Parse(txt2.Text),
                            FName    = txt3.Text,
                            LName    = txt4.Text,
                            Phone_no = txt5.Text,
                            Role     = txt6.Text,
                            TeamID   = int.Parse(txt7.Text)
                        };
                    }
                    else if (Node == "Extras")
                    {
                        //Sets data to new Extras object with user inputted data
                        data = new Extras
                        {
                            ExtraID  = int.Parse(txt1.Text),
                            Age      = int.Parse(txt2.Text),
                            FName    = txt3.Text,
                            LName    = txt4.Text,
                            Phone_no = txt5.Text,
                            Role     = txt6.Text,
                            TeamID   = int.Parse(txt7.Text)
                        };
                    }
                }
                catch (Exception ex) //Catches exception when input data is not correct
                {
                    MessageBox.Show(ex.Message + ", Check what you inserted in the Textboxes");
                    return;
                }


                FirebaseResponse response = await client.UpdateTaskAsync(Node + "/" + txt1.Text, data); //Updates node data

                MessageBox.Show("Data Updated");                                                        //Messagebox that showws after data has been updated
            }
            else if (Action == "Retrieve")                                                              //Retrieve
            {
                string print = null;                                                                    //String that used for returning data wanting to be retrieved
                if (txt1.IsEnabled == true)                                                             //If ID textbox is enabled on window
                {
                    FirebaseResponse response = await client.GetTaskAsync("Counter/" + Node);           //Gets counter to check if ID entered is valid

                    Counter cnt = response.ResultAs <Counter>();                                        //Sets response to a counter object

                    try                                                                                 //Catches exception
                    {
                        int count = cnt.cnt;                                                            //Sets count

                        int ID = int.Parse(txt1.Text);                                                  //Sets ID

                        if (ID > count || ID < 1)                                                       //Checks if ID entered is between 1 and count
                        {
                            MessageBox.Show(txt1.Text + " is not a valid ID");
                            return;
                        }
                    }
                    catch (Exception ex) //Catches exception when input data is entered wrong
                    {
                        MessageBox.Show(ex.Message + ", Check what you inserted in the Textboxes");
                        return;
                    }

                    response = await client.GetTaskAsync(Node + "/" + txt1.Text); //Get data with ID inputted

                    //Creates correct object data and calls print function
                    if (Node == "Coaches")
                    {
                        Coaches result = response.ResultAs <Coaches>();
                        print = result.printAll();
                    }
                    else if (Node == "Extras")
                    {
                        Extras result = response.ResultAs <Extras>();
                        print = result.printAll();
                    }

                    MessageBox.Show(print); //Prints data to a messagebox

                    //List<string> elements = new List<string>();
                    //elements.Add(print);

                    //DataWindow dataWindow = new DataWindow(Node, elements);

                    //dataWindow.Show();
                }
                else
                {
                    List <string> elements = new List <string>(); //List of strings that hold different data from databse.

                    //Runs through all key IDs
                    for (int i = 1; i <= get.cnt; i++)
                    {
                        FirebaseResponse result = await client.GetTaskAsync(Node + "/" + i); //Gets node

                        //Catches exceptions
                        try {
                            if (Node == "Coaches")
                            {
                                Coaches coach      = result.ResultAs <Coaches>(); //Turns response into coaches object
                                bool    addElement = true;                        //Sets add element to true
                                //******The next lines of code was a lot of copy and paste and save myself I will explain it clearly once
                                if (AgeLabel)                                     //Checks if Label is enabled on window
                                {
                                    if (txt2.Text != "")                          //Checks if user inputted into textbox that corresponds with label
                                    {
                                        if (coach.Age != int.Parse(txt2.Text))    //If the data inserted by the user and data in the databse does not match
                                        {
                                            addElement = false;                   //Sets to false because this element is not being added
                                        }
                                    }
                                }
                                if (FNameLabel)
                                {
                                    if (txt3.Text != "")
                                    {
                                        if (coach.FName != txt3.Text)
                                        {
                                            addElement = false;
                                        }
                                    }
                                }
                                if (LNameLabel)
                                {
                                    if (txt4.Text != "")
                                    {
                                        if (coach.LName != txt4.Text)
                                        {
                                            addElement = false;
                                        }
                                    }
                                }
                                if (PhoneNumLabel)
                                {
                                    if (txt5.Text != "")
                                    {
                                        if (coach.Phone_no != txt5.Text)
                                        {
                                            addElement = false;
                                        }
                                    }
                                }
                                if (RoleLabel)
                                {
                                    if (txt6.Text != "")
                                    {
                                        if (coach.Role != txt6.Text)
                                        {
                                            addElement = false;
                                        }
                                    }
                                }
                                if (TeamIDLabel)
                                {
                                    if (txt7.Text != "")
                                    {
                                        if (coach.TeamID != int.Parse(txt7.Text))
                                        {
                                            addElement = false;
                                        }
                                    }
                                }

                                if (addElement)                                                                                                    // If addElement is not false
                                {
                                    elements.Add(coach.printRestirction(AgeLabel, FNameLabel, LNameLabel, PhoneNumLabel, RoleLabel, TeamIDLabel)); //Calss print function and adds to list of strings
                                }
                            }
                            else if (Node == "Extras")
                            {
                                Extras extras     = result.ResultAs <Extras>(); //Turns respons into Extra object
                                bool   addElement = true;                       //Sets add element to true
                                //******The next lines of code was a lot of copy and paste and save myself it is explained above at line 297
                                if (AgeLabel)
                                {
                                    if (txt2.Text != "")
                                    {
                                        if (extras.Age != int.Parse(txt2.Text))
                                        {
                                            addElement = false;
                                        }
                                    }
                                }
                                if (FNameLabel)
                                {
                                    if (txt3.Text != "")
                                    {
                                        if (extras.FName != txt3.Text)
                                        {
                                            addElement = false;
                                        }
                                    }
                                }
                                if (LNameLabel)
                                {
                                    if (txt4.Text != "")
                                    {
                                        if (extras.LName != txt4.Text)
                                        {
                                            addElement = false;
                                        }
                                    }
                                }
                                if (PhoneNumLabel)
                                {
                                    if (txt5.Text != "")
                                    {
                                        if (extras.Phone_no != txt5.Text)
                                        {
                                            addElement = false;
                                        }
                                    }
                                }
                                if (RoleLabel)
                                {
                                    if (txt6.Text != "")
                                    {
                                        if (extras.Role != txt6.Text)
                                        {
                                            addElement = false;
                                        }
                                    }
                                }
                                if (TeamIDLabel)
                                {
                                    if (txt7.Text != "")
                                    {
                                        if (extras.TeamID != int.Parse(txt7.Text))
                                        {
                                            addElement = false;
                                        }
                                    }
                                }

                                if (addElement)
                                {
                                    elements.Add(extras.printRestirction(AgeLabel, FNameLabel, LNameLabel, PhoneNumLabel, RoleLabel, TeamIDLabel));
                                }
                            }
                        }
                        catch (Exception ex) //Catches exception when input data is incorrect
                        {
                            MessageBox.Show(ex.Message + ", Check what you inserted in the Textboxes");
                            return;
                        }
                    }


                    if (elements.Count == 0) //If there are no strings in list shows that no elements cooresponded with what the user was looking for
                    {
                        MessageBox.Show("There are no elements with the inputs inserted!");
                        return;
                    }

                    //DataWindow dataWindow = new DataWindow(Node, elements);

                    //dataWindow.Show();

                    foreach (string ele in elements)  //Shows all data in message boxes
                    {
                        MessageBox.Show(ele);
                    }
                }



                //foreach (string ele in arr){
                //  MessageBox.Show(ele);
                //}
            }
        }