Beispiel #1
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dview = (DataGridView)sender;

            if (e.ColumnIndex == 0 && e.RowIndex >= 0)
            {
                TeamPage Teamform = new TeamPage();
                Teamform.gridInnit();
                GetTeam(dview.SelectedCells[0].Value.ToString(), Teamform);
                Teamform.ShowDialog();
            }
        }
Beispiel #2
0
        public void GetTeam(string teamName, TeamPage form)
        {
            //-------------------------------------------------Jogadores---------------------------------------------------------
            CN.Open();
            SqlCommand sqlcmd = new SqlCommand("PROJETO.GetEquipa", CN);

            sqlcmd.CommandType = CommandType.StoredProcedure;
            sqlcmd.Parameters.Add(new SqlParameter("@Clube", teamName));
            SqlDataReader reader = sqlcmd.ExecuteReader();

            form.setTeam(teamName);
            List <string[]> rows = new List <string[]>();

            form.getGrid().Rows.Clear();

            while (reader.Read())
            {
                string[] row = { reader["Nome"].ToString(), reader["NrCamisola"].ToString(), reader["Posicao"].ToString() };
                rows.Add(row);

                form.GetLabelNomeClube().Text = reader["clube"].ToString();
            }



            for (int i = 0; i < rows.Count; i++)
            {
                //dtbl.NewRow. = "Sporting Clube de Portugal " + i + " vitórias";
                form.getGrid().RowHeadersVisible = false;
                string[] row = rows.ElementAt(i);
                form.getGrid().Rows.Add(row);
            }
            CN.Close();

            //-------------------------------------------------Estadio---------------------------------------------------------
            string select_str = "SELECT PROJETO.getEstadioInfo('" + teamName + "')";

            CN.Open();

            SqlCommand    cmdEstadio    = new SqlCommand(select_str, CN);
            SqlDataReader estadioReader = cmdEstadio.ExecuteReader();

            while (estadioReader.Read())
            {
                form.getlabelEstadio().Text = estadioReader[0].ToString();
            }
            CN.Close();


            //-------------------------------------------------Direcao---------------------------------------------------------
            CN.Open();
            SqlCommand cmdDirecao = new SqlCommand("PROJETO.getDirecao", CN);

            cmdDirecao.CommandType = CommandType.StoredProcedure;
            cmdDirecao.Parameters.Add(new SqlParameter("@clube", teamName));
            SqlDataReader direcaoReader = cmdDirecao.ExecuteReader();

            form.getDirecao().Items.Clear();
            while (direcaoReader.Read())
            {
                form.getDirecao().Items.Add("Presidente: " + direcaoReader["pres"]);
                form.getDirecao().Items.Add("");
                form.getDirecao().Items.Add("Pres. Ass. Geral: " + direcaoReader["presAss"]);
                form.getDirecao().Items.Add("");
                form.getDirecao().Items.Add("Administrador: " + direcaoReader["admini"]);
                form.getDirecao().Items.Add("");
            }
            CN.Close();
            //-------------------------------------------------Treinadores---------------------------------------------------------
            CN.Open();
            SqlCommand cmdTrainers = new SqlCommand("PROJETO.GetTeamTrainer", CN);

            cmdTrainers.CommandType = CommandType.StoredProcedure;
            cmdTrainers.Parameters.Add(new SqlParameter("@equipa", teamName));
            SqlDataReader TReader = cmdTrainers.ExecuteReader();

            while (TReader.Read())
            {
                form.getDirecao().Items.Add(TReader["Especializacao"] + ": " + TReader["Nome"]);
                form.getDirecao().Items.Add("");
            }
            CN.Close();

            // ---------------------------- TROFÉUS -------------------------------------------------------------
            CN.Open();
            SqlCommand cmdTrofeu = new SqlCommand("PROJETO.TeamTitles", CN);

            cmdTrofeu.CommandType = CommandType.StoredProcedure;
            cmdTrofeu.Parameters.Add(new SqlParameter("@equipa", teamName));
            SqlDataReader trofeuReader = cmdTrofeu.ExecuteReader();

            form.getTrofeu().Items.Clear();
            while (trofeuReader.Read())
            {
                form.getTrofeu().Items.Add(trofeuReader["Ano"] + " - Campeão da liga");
            }
            CN.Close();
        }