private void addPlayerCoachButton_Click(object sender, RoutedEventArgs e)
        {
            AddPlayerWindow addPlayerWindow = new AddPlayerWindow();

            addPlayerWindow.Show();
            addPlayerWindow.Topmost = true;
        }
        private void addPlayerCoachButton_Click(object sender, RoutedEventArgs e)
        {
            AddPlayerWindow addPlayerWindow = new AddPlayerWindow();

            addPlayerWindow.Owner = this;
            if (IsOpen == false)
            {
                //addTeamWindow.deleteButton.Visibility = Visibility.Collapsed;
                addPlayerWindow.Show();
                addPlayerWindow.Topmost = true;
                IsOpen = true;
            }
        }
        private void editPlayerButton_Click(object sender, RoutedEventArgs e)
        {
            int    personID             = 0;
            string firstName            = "";
            string lastName             = string.Empty;
            string birthDate            = string.Empty;
            string positionName         = "";
            int    playerPrice          = 0;
            int    countryID            = 0;
            string personImage          = string.Empty;
            int    playerHeight         = 0;
            int    teamID               = 0;
            int    playerRepresentative = 0;
            bool   playerIsRep          = false;

            if (playersClubListBox.SelectedItems.Count == 1)
            {
                playerFirstName = playerFirstNameLabel.Content.ToString();
                playerLastName  = playerNameLabel.Content.ToString();


                OpenConnection();

                MySqlCommand cmd = new MySqlCommand("Select Person_ID, Person_First_Name, Person_Last_Name, Person_Birth_Date, Position_Name, Player_Price, Person_Country_ID, Person_Image, Height, Player_Representative, Player_Team_ID from people join players join positions on Person_ID = Player_Person_ID AND Person_Position_ID = Position_ID where Person_ID ='" + GetPersonID(playerFirstName, playerLastName) + "'", conn);
                if (conn.State == System.Data.ConnectionState.Closed)
                {
                    CloseConnection();
                    OpenConnection();
                    MySqlDataReader rd = cmd.ExecuteReader();


                    while (rd.Read())
                    {
                        personID             = rd.GetInt32(0);
                        firstName            = rd.GetString(1);
                        lastName             = rd.GetString(2);
                        birthDate            = rd.GetString(3);
                        positionName         = rd.GetString(4);
                        playerPrice          = rd.GetInt32(5);
                        countryID            = rd.GetInt32(6);
                        personImage          = rd.GetString(7);
                        playerHeight         = rd.GetInt32(8);
                        playerRepresentative = rd.GetInt32(9);
                        teamID = rd.GetInt32(10);
                    }
                    CloseConnection();
                }
                else
                {
                    MySqlDataReader rd = cmd.ExecuteReader();

                    while (rd.Read())
                    {
                        personID             = rd.GetInt32(0);
                        firstName            = rd.GetString(1);
                        lastName             = rd.GetString(2);
                        birthDate            = rd.GetString(3);
                        positionName         = rd.GetString(4);
                        playerPrice          = rd.GetInt32(5);
                        countryID            = rd.GetInt32(6);
                        personImage          = rd.GetString(7);
                        playerHeight         = rd.GetInt32(8);
                        playerRepresentative = rd.GetInt32(9);
                        teamID = rd.GetInt32(10);
                    }
                    CloseConnection();
                }



                CloseConnection();
                if (playerRepresentative == 1)
                {
                    playerIsRep = true;
                }
                else
                {
                    playerIsRep = false;
                }

                AddPlayerWindow addPlayerWindow = new AddPlayerWindow(personID, GetCountryName(countryID), firstName, lastName, birthDate, positionName, personImage, playerPrice, playerHeight, GetTeamName(teamID), playerIsRep, true);
                addPlayerWindow.Owner = this;

                addPlayerWindow.Show();
            }
            else
            {
                MessageBox.Show("Prosze zaznaczyć zawodnika");
            }
        }
Beispiel #4
0
        private void editCoachButton_Click(object sender, RoutedEventArgs e)
        {
            int    personID     = 0;
            string firstName    = "";
            string lastName     = string.Empty;
            string birthDate    = string.Empty;
            string positionName = "";

            int    countryID   = 0;
            string personImage = string.Empty;



            if (coachesWithoutClubListBox.SelectedItems.Count == 1)
            {
                coachFirstName = coachFirstNameLabel.Content.ToString();
                coachLastName  = coachNameLabel.Content.ToString();


                OpenConnection();

                MySqlCommand cmd = new MySqlCommand("Select Person_ID, Person_First_Name, Person_Last_Name, Person_Birth_Date, Person_Country_ID, Person_Image from people where Person_ID ='" + GetPersonID(coachFirstName, coachLastName) + "'", conn);
                if (conn.State == System.Data.ConnectionState.Closed)
                {
                    CloseConnection();
                    OpenConnection();
                    MySqlDataReader rd = cmd.ExecuteReader();


                    while (rd.Read())
                    {
                        personID  = rd.GetInt32(0);
                        firstName = rd.GetString(1);
                        lastName  = rd.GetString(2);
                        birthDate = rd.GetString(3);

                        countryID   = rd.GetInt32(4);
                        personImage = rd.GetString(5);
                    }
                    CloseConnection();
                }
                else
                {
                    MySqlDataReader rd = cmd.ExecuteReader();

                    while (rd.Read())
                    {
                        personID     = rd.GetInt32(0);
                        firstName    = rd.GetString(1);
                        lastName     = rd.GetString(2);
                        birthDate    = rd.GetString(3);
                        positionName = rd.GetString(4);
                        countryID    = rd.GetInt32(5);
                        personImage  = rd.GetString(6);
                    }
                    CloseConnection();
                }



                CloseConnection();


                AddPlayerWindow addPlayerWindow = new AddPlayerWindow(personID, GetCountryName(countryID), firstName, lastName, birthDate, personImage, true);
                addPlayerWindow.Owner = this;

                addPlayerWindow.Show();
            }
            else
            {
                MessageBox.Show("Prosze zaznaczyć trenera");
            }
        }