private void valider_btn_Click(object sender, EventArgs e) { try { if (!database) { Program.ajout_etagere(numero_txt.Text); } else { dbconnexion = new DBConnexion(); SqlCommand cmd = dbconnexion.connexion.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "Insert into Etagere values ('" + numero_txt.Text + "')"; cmd.ExecuteNonQuery(); dbconnexion.connexion.Close(); } } catch (ExistenceException exp) { exception_lbl.Text = exp.Message; } catch (Exception exp) { exception_lbl.Text = "Données incorrectes (étagère déjà existant,...)!"; } reinitialiser_btn_Click(sender, e); }
private void valider_btn_Click(object sender, EventArgs e) { try { if (!database) { Livre livre = new Livre(code_txt.Text, titre_txt.Text, Convert.ToInt32(prix_txt.Text)); Program.ajout_livre(livre, numero_txt.Text); } else { dbconnexion = new DBConnexion(); SqlCommand cmd = dbconnexion.connexion.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "Insert into Livre values ('" + code_txt.Text + "','" + titre_txt.Text + "','" + Convert.ToInt32(prix_txt.Text) + "','" + numero_txt.Text + "')"; cmd.ExecuteNonQuery(); dbconnexion.connexion.Close(); } } catch (SaisieException exp) { exception_lbl.Text = exp.Message; } catch (ExistenceException exp) { exception_lbl.Text = exp.Message; } catch (Exception exp) { exception_lbl.Text = "Données incorrectes (étagère introuvable, code déjà existant,...)!"; } reinitialiser_btn_Click(sender, e); }
private void valider_btn_Click(object sender, EventArgs e) { try { if (!database) { Program.Remettre_livre_etagere(code_txt.Text, numero_txt.Text); } else { dbconnexion = new DBConnexion(); SqlCommand cmd = dbconnexion.connexion.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "Insert into Livre select * from LivreRetires where code='" + code_txt.Text + "' and numero_etagere ='" + numero_txt.Text + "'"; cmd.ExecuteNonQuery(); dbconnexion.connexion.Close(); } } catch (NullReferenceException exp) { exception_lbl.Text = "Le livre demandé est inconnu !"; } catch (ExistenceException exp) { exception_lbl.Text = exp.Message; } catch (Exception exp) { exception_lbl.Text = "Données incorrectes (étagère/code introuvable, code déjà existant,...)!"; } reinitialiser_btn_Click(sender, e); }
private void valider_btn_Click(object sender, EventArgs e) { try { if (!database) { Livre nouveau = new Livre(code_nouveau_txt.Text, titre_nouveau_txt.Text, Convert.ToInt32(prix_nouveau_txt.Text)); Program.remplacer_livre_etagere(code_ancien_txt.Text, nouveau, numero_txt.Text); } else { dbconnexion = new DBConnexion(); SqlCommand cmd = dbconnexion.connexion.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "Delete from Livre where code='" + code_ancien_txt.Text + "' and numero_etagere='" + numero_txt.Text + "'"; cmd.ExecuteNonQuery(); Livre livre = new Livre(code_nouveau_txt.Text, titre_nouveau_txt.Text, Convert.ToInt32(prix_nouveau_txt.Text)); cmd.CommandText = "Insert into Livre values ('" + livre.Code + "','" + livre.Titre + "','" + livre.Prix + "','" + numero_txt.Text + "')"; cmd.ExecuteNonQuery(); dbconnexion.connexion.Close(); } } catch (SaisieException exp) { exception_lbl.Text = exp.Message; } catch (NullReferenceException exp) { exception_lbl.Text = "Le livre demandé est introuvable !"; } catch (ExistenceException exp) { exception_lbl.Text = exp.Message; } catch (Exception exp) { exception_lbl.Text = "Données incorrectes (étagère/code introuvable, livre déjà existant,...)!"; } reinitialiser_btn_Click(sender, e); }
private void lister_btn_Click(object sender, EventArgs e) { try { if (!database) { dataGridView2.Hide(); remplirDataGrid(Program.lister_livre_etagere(numero_txt.Text)); } else { dbconnexion = new DBConnexion(); SqlCommand cmd = dbconnexion.connexion.CreateCommand(); cmd.CommandType = CommandType.Text; cmd.CommandText = "Select * from Livre where numero_etagere='" + numero_txt.Text + "'"; cmd.ExecuteNonQuery(); DataTable dataTable = new DataTable(); SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd.CommandText, dbconnexion.connexion); dataAdapter.Fill(dataTable); dataGridView2.DataSource = dataTable; dbconnexion.connexion.Close(); } } catch (NullReferenceException exp) { exception_lbl.Text = "Cette étagère n'existe pas !"; } catch (ExistenceException exp) { exception_lbl.Text = exp.Message; } catch (Exception exp) { exception_lbl.Text = "Données incorrectes (étagère introuvable,...)!"; } }