1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
| using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
namespace Phone_Party
{
public partial class Form5 : Form
{
public Form5()
{
InitializeComponent();
}
private void Form5_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Form2 Form2 = new Form2();
Form2.Show();
this.Hide();
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboBox1.Text == "GROUPE")
{
textBox2.Visible = true;
textBox3.Visible = false;
textBox4.Visible = false;
textBox5.Visible = false;
textBox6.Visible = false;
}
else if (comboBox1.Text == "SERVICE")
{
textBox2.Visible = false;
textBox3.Visible = true;
textBox4.Visible = false;
textBox5.Visible = false;
textBox6.Visible = false;
textBox6.Visible = false;
}
else if (comboBox1.Text == "NOM")
{
textBox2.Visible = false;
textBox3.Visible = false;
textBox4.Visible = true;
textBox5.Visible = false;
textBox6.Visible = false;
}
else if (comboBox1.Text == "PRENOM")
{
textBox2.Visible = false;
textBox3.Visible = false;
textBox4.Visible = false;
textBox5.Visible = true;
textBox6.Visible = false;
}
else if (comboBox1.Text == "PAYS")
{
textBox2.Visible = false;
textBox3.Visible = false;
textBox4.Visible = false;
textBox5.Visible = false;
textBox6.Visible = true;
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
if (comboBox1.Text == "GROUPE")
{
MySqlConnection con = new MySqlConnection("datasource = BLACK-PEARL; port = 3306; Initial Catalog = phone; username = root; password = toto");
MySqlDataAdapter sda = new MySqlDataAdapter("SELECT ID_table, Sexe, Nom, Prenom, Societer, Service, Poste, Groupe, Courriel, Adresse_1, Adresse_2, Dpt, Ville, Pays, Tel, Port, Fax FROM Table1 where Groupe like '" + textBox1.Text + "%'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
textBox2.Visible = true;
}
else if (comboBox1.Text == "SERVICE")
{
MySqlConnection con = new MySqlConnection("datasource = BLACK-PEARL; port = 3306; Initial Catalog = phone; username = root; password = toto");
MySqlDataAdapter sda = new MySqlDataAdapter("SELECT ID_table, Sexe, Nom, Prenom, Societer, Service, Poste, Groupe, Courriel, Adresse_1, Adresse_2, Dpt, Ville, Pays, Tel, Port, Fax FROM Table1 where Service like '" + textBox1.Text + "%'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
}
else if (comboBox1.Text == "NOM")
{
MySqlConnection con = new MySqlConnection("datasource = BLACK-PEARL; port = 3306; Initial Catalog = phone; username = root; password = toto");
MySqlDataAdapter sda = new MySqlDataAdapter("SELECT ID_table, Sexe, Nom, Prenom, Societer, Service, Poste, Groupe, Courriel, Adresse_1, Adresse_2, Dpt, Ville, Pays, Tel, Port, Fax FROM Table1 where Nom like '" + textBox1.Text + "%'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
}
else if (comboBox1.Text == "PRENOM")
{
MySqlConnection con = new MySqlConnection("datasource = BLACK-PEARL; port = 3306; Initial Catalog = phone; username = root; password = toto");
MySqlDataAdapter sda = new MySqlDataAdapter("SELECT ID_table, Sexe, Nom, Prenom, Societer, Service, Poste, Groupe, Courriel, Adresse_1, Adresse_2, Dpt, Ville, Pays, Tel, Port, Fax FROM Table1 where Prenom like '" + textBox1.Text + "%'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
}
else if (comboBox1.Text == "PAYS")
{
MySqlConnection con = new MySqlConnection("datasource = BLACK-PEARL; port = 3306; Initial Catalog = phone; username = root; password = toto");
MySqlDataAdapter sda = new MySqlDataAdapter("SELECT ID_table, Sexe, Nom, Prenom, Societer, Service, Poste, Groupe, Courriel, Adresse_1, Adresse_2, Dpt, Ville, Pays, Tel, Port, Fax FROM Table1 where Pays like '" + textBox1.Text + "%'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
dataGridView1.DataSource = dt;
}
}
}
} |
Partager