public void searchData(string valueToSearch) { string query = "SELECT * FROM `swimmers` WHERE CONCAT(`ID`, `First Name`, `Last Name`, `Gender`, `Birth Date`, `Age`, `School`, `Medical`, `Swim Team/s`, `Swim Group`, `Parent/s Name`, `Parent/s Address`, `Parent/s Number`, `Parent Email`) like '%" + valueToSearch + "%' AND `Swim Team/s`= 'Grenfin'"; command = new MySqlCommand(query, connection); adapter = new MySqlDataAdapter(command); table = new DataTable(); adapter.Fill(table); dataGridView1.DataSource = swimmer.getSwimmers(command); }
private void Grenada_Team_Load(object sender, EventArgs e) { labelUser.Text = GLOBAL.userType; //populating the datagridview with swimmer's data MySqlCommand command = new MySqlCommand("SELECT * FROM `swimmers` WHERE `Swim Team/s`='Sailfish and Grenada' OR 'Grenfin and Grenada' OR 'Dolphin and Grenada'"); dataGridView1.ReadOnly = true; dataGridView1.RowTemplate.Height = 30; dataGridView1.DataSource = swimmer.getSwimmers(command); dataGridView1.AllowUserToAddRows = false; }
private void Swimmer_List_Load(object sender, EventArgs e) { //populating the datagridview with swimmer's data MySqlCommand command = new MySqlCommand("SELECT * FROM `swimmers`"); dataGridView1.ReadOnly = true; dataGridView1.RowTemplate.Height = 30; dataGridView1.DataSource = swimmer.getSwimmers(command); dataGridView1.AllowUserToAddRows = false; labelUser.Text = GLOBAL.userType; searchData(""); }
private void buttonFind_Click(object sender, EventArgs e) { SWIMMER swimmer = new SWIMMER(); //Search coaches by id try { int id = Convert.ToInt32(textBoxId.Text); MySqlCommand command = new MySqlCommand("SELECT `ID`, `First Name`, `Last Name`, `Swim Team/s`, `Swim Group` FROM `swimmers` WHERE `ID`=" + id); DataTable table = swimmer.getSwimmers(command); if (table.Rows.Count > 0) { textBoxFname.Text = table.Rows[0]["First Name"].ToString(); textBoxLname.Text = table.Rows[0]["Last Name"].ToString(); textBoxSwmT.Text = table.Rows[0]["Swim Team/s"].ToString(); textBoxSwimG.Text = table.Rows[0]["Swim Group"].ToString(); } } catch { MessageBox.Show("Enter a Valid Swimmer's ID", "Invalid ID", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonFind_Click(object sender, EventArgs e) { //Search coaches by id try { int id = Convert.ToInt32(textBoxId.Text); MySqlCommand command = new MySqlCommand("SELECT `ID`, `First Name`, `Last Name`, `Gender`, `Birth Date`, `Age`, `School`, `Medical`, `Swim Team/s`, `Swim Group`, `Parent/s Name`, `Parent/s Address`, `Parent/s Number`, `Parent Email` FROM `swimmers` WHERE `ID`=" + id); DataTable table = swimmer.getSwimmers(command); if (table.Rows.Count > 0) { textBoxFname.Text = table.Rows[0]["First Name"].ToString(); textBoxLname.Text = table.Rows[0]["Last Name"].ToString(); //gender if (table.Rows[0]["Gender"].ToString() == "Female") { radioButtonFemale.Checked = true; } else { radioButtonMale.Checked = true; } dateTimePicker1.Value = (DateTime)table.Rows[0]["Birth Date"]; textBoxAge.Text = table.Rows[0]["Age"].ToString(); textBoxSchool.Text = table.Rows[0]["School"].ToString(); textBoxMedical.Text = table.Rows[0]["Medical"].ToString(); textBoxSwmT.Text = table.Rows[0]["Swim Team/s"].ToString(); textBoxGroup.Text = table.Rows[0]["Swim Group"].ToString(); textBoxPname.Text = table.Rows[0]["Parent/s Name"].ToString(); textBoxPaddress.Text = table.Rows[0]["Parent/s Address"].ToString(); textBoxPnum.Text = table.Rows[0]["Parent/s Number"].ToString(); textBoxPemail.Text = table.Rows[0]["Parent Email"].ToString(); } } catch { MessageBox.Show("Enter a Valid Swimmer's ID", "Invalid ID", MessageBoxButtons.OK, MessageBoxIcon.Error); } }