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
|
public MySqlConnection maconnexion;
private void liste_Load(object sender, EventArgs e)
{
try
{
timer_reload.Enabled = true;
// Connexion à la base de données
string connexion = "Server=IP;Port=3306;Database=db_commande;Uid=PSEUDO;Pwd=MDP;";
maconnexion = new MySqlConnection(connexion);
maconnexion.Open(); // Ouverture
MySqlDataAdapter adapter_commande_attente = new MySqlDataAdapter("SELECT co_ref, co_fich, co_dat, co_qte, co_del, co_com, for_nom, gra_nom, pro_nom FROM commande,forma,grammage,produit WHERE co_for=for_id AND co_gra=gra_id AND co_pro=pro_id AND co_sta=0 ORDER BY co_dat DESC", maconnexion);
MySqlDataAdapter adapter_commande_termine = new MySqlDataAdapter("SELECT co_ref, co_fich, co_dat, co_qte, co_del, co_com, for_nom, gra_nom, pro_nom FROM commande,forma,grammage,produit WHERE co_for=for_id AND co_gra=gra_id AND co_pro=pro_id AND co_sta=1 ORDER BY co_dat ASC LIMIT 10", maconnexion);
MySqlCommandBuilder builder = new MySqlCommandBuilder(adapter_commande_attente);
DataSet dataset_commande = new DataSet();
adapter_commande_attente.Fill(dataset_commande, "commande_attente");
DataSet dataset_termine = new DataSet();
adapter_commande_termine.Fill(dataset_commande, "commande_termine");
DataView MonDataView = dataset_commande.Tables["commande_attente"].DefaultView;
dataGridView_attente.DataSource = MonDataView;
DataView MonDataView2 = dataset_commande.Tables["commande_termine"].DefaultView;
dataGridView_termine.DataSource = MonDataView2;
}
catch (Exception)
{
MessageBox.Show("Connexion impossible avec le serveur, veuillez vérifier son état !", "Erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void dataGridView_attente_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0 && e.ColumnIndex == details.Index)
{
MySqlDataAdapter adapter_commande_attente = new MySqlDataAdapter("SELECT co_ref, co_fich, co_dat, co_qte, co_del, co_com, for_nom, gra_nom, pro_nom FROM commande,forma,grammage,produit WHERE co_for=for_id AND co_gra=gra_id AND co_pro=pro_id AND co_sta=0 ORDER BY co_dat DESC", maconnexion);
// obtenir la DataRow correspondant à la ligne courante du DataGridView
DataRowView drv = dataGridView_attente.CurrentRow.DataBoundItem as DataRowView;
drv.Row["co_sta"] = 1;
adapter_commande_attente.Update(new DataRow[] { drv.Row });
}
} |