Example #1
0
        private void Searchbutton_Click(object sender, EventArgs e)
        {
            if (NametextBox.Text == "")
            {
                MessageBox.Show("Player Name Must Be Given to Search", "ERROR");
            }
            else
            {
                SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString);
                connection.Open();
                string        sql     = "SELECT * FROM injuries where name = '" + NametextBox.Text + "'";
                SqlCommand    command = new SqlCommand(sql, connection);
                SqlDataReader reader  = command.ExecuteReader();

                List <Injured> players = new List <Injured>();

                while (reader.Read())
                {
                    Injured players1 = new Injured();

                    players1.Name     = reader["name"].ToString();
                    players1.Image    = (byte[])reader["photo"];
                    players1.Position = reader["position"].ToString();
                    players1.Id       = Convert.ToInt32(reader["playerId"]);

                    players.Add(players1);
                }

                SquaddataGridView.DataSource = players;

                connection.Close();
            }
        }
Example #2
0
        private void RecoverPlayer_Load(object sender, EventArgs e)
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString);

            connection.Open();

            string        sql     = "SELECT * FROM injuries";
            SqlCommand    command = new SqlCommand(sql, connection);
            SqlDataReader reader  = command.ExecuteReader();

            List <Injured> injury = new List <Injured>();

            while (reader.Read())
            {
                Injured injury1 = new Injured();

                injury1.Name     = reader["name"].ToString();
                injury1.Image    = (byte[])reader["photo"];
                injury1.Position = reader["position"].ToString();
                injury1.Id       = Convert.ToInt32(reader["playerId"]);
                injury1.Event    = reader["event"].ToString();

                injury.Add(injury1);
            }
            SquaddataGridView.DataSource = injury;
            connection.Close();
        }