public bool Inscription_List_Attente(int numeroEmprunteur, int codeOuvrage) { string VerifierQuery = "SELECT * FROM liste_attente WHERE code_ouvrage = " + codeOuvrage + " AND numero_emprunteur = " + numeroEmprunteur + ""; MySqlCommand command = new MySqlCommand(VerifierQuery, connection); manager.OpenConnection(); MySqlDataReader reader = command.ExecuteReader(); if (reader.Read()) { reader.Close(); manager.CloseConnection(); return(false); } else { reader.Close(); string query = "INSERT INTO liste_attente " + "(code_ouvrage , numero_emprunteur )" + "VALUES (" + codeOuvrage + " , " + numeroEmprunteur + ")"; MySqlCommand command1 = new MySqlCommand(query, connection); try { int result = command1.ExecuteNonQuery(); manager.CloseConnection(); return(result > 0); } catch (Exception e) { manager.CloseConnection(); return(false); } } }
public bool Ajouter_Membre_Etudiant(Etudiant etudiant) { string query = "INSERT INTO emprunteur" + "(numero_carte ,nom_utilisateur , mot_de_passe , nom , prenom , email , reservastion_non_confirme , statut)" + "VALUES (" + etudiant.Emp.Numero_carte + " , '" + etudiant.Emp.Nom_utilisateur + "' , '" + etudiant.Emp.Mot_de_passe + "' , '" + etudiant.Emp.Nom + "' , '" + etudiant.Emp.Prenom + "' , '" + etudiant.Emp.Email + "' , 0 , 0)"; Boolean firstResult; MySqlCommand command = new MySqlCommand(query, connection); manager.OpenConnection(); try { firstResult = command.ExecuteNonQuery() > 0; } catch (Exception e) { manager.CloseConnection(); firstResult = false; } if (firstResult) { string query1 = "INSERT INTO etudiant ( code_etudiant , specialite , niveau )" + "VALUES (" + etudiant.Emp.Numero_carte + " , '" + etudiant.Specialite + "' , '" + etudiant.Niveau + "') "; MySqlCommand command2 = new MySqlCommand(query1, connection); try { bool result = command2.ExecuteNonQuery() > 0; manager.CloseConnection(); return(result); } catch (Exception e) { manager.CloseConnection(); return(false); } } else { return(false); } }