public void searchData(string valueToSearch) { string query = "SELECT * FROM `coaches` WHERE CONCAT(`ID`, `First Name`, `Last Name`, `Gender`, `Birth Date`, `Age`, `Address`, `Phone Number`, `Email`, `Swim Team/s`) like '%" + valueToSearch + "%' AND `Swim Team/s`= 'Sailfish'"; command = new MySqlCommand(query, connection); adapter = new MySqlDataAdapter(command); table = new DataTable(); adapter.Fill(table); dataGridView1.DataSource = coach.getCoaches(command); }
private void Grenada_Team_Coaches_Load(object sender, EventArgs e) { labelUser.Text = GLOBAL.userType; //populating the datagridview with swimmer's data MySqlCommand command = new MySqlCommand("SELECT * FROM `coaches` WHERE `Swim Team/s`='Sailfish and Grenada' OR 'Grenfin and Grenada' OR 'Dolphin and Grenada'"); dataGridView1.ReadOnly = true; dataGridView1.RowTemplate.Height = 30; dataGridView1.DataSource = coach.getCoaches(command); dataGridView1.AllowUserToAddRows = false; }
private void CoachesForm_Load(object sender, EventArgs e) { //populating the datagridview with swimmer's data MySqlCommand command = new MySqlCommand("SELECT * FROM `coaches`"); dataGridView1.ReadOnly = true; dataGridView1.RowTemplate.Height = 30; dataGridView1.DataSource = coach.getCoaches(command); dataGridView1.AllowUserToAddRows = false; labelUser.Text = GLOBAL.userType; searchData(""); }
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`, `Address`, `Phone Number`, `Email`, `Swim Team/s` FROM `coaches` WHERE `ID`=" + id); DataTable table = coach.getCoaches(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(); textBoxAddress.Text = table.Rows[0]["Address"].ToString(); textBoxPhone.Text = table.Rows[0]["Phone Number"].ToString(); textBoxEmail.Text = table.Rows[0]["Email"].ToString(); textBoxSwm.Text = table.Rows[0]["Swim Team/s"].ToString(); } } catch { MessageBox.Show("Enter a Valid Coach's ID", "Invalid ID", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void buttonFind_Click(object sender, EventArgs e) { COACHES coach = new COACHES(); //Search coaches by id try { int id = Convert.ToInt32(textBoxId.Text); MySqlCommand command = new MySqlCommand("SELECT `ID`, `First Name`, `Last Name`, `Swim Team/s` FROM `coaches` WHERE `ID`=" + id); DataTable table = coach.getCoaches(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(); } } catch { MessageBox.Show("Enter a Valid Swimmer's ID", "Invalid ID", MessageBoxButtons.OK, MessageBoxIcon.Error); } }