public override Groupe create(Groupe obj) { //Si l'objet n'a pas d'id, on récupère le dernier id dans la table, pour que l'id de l'objet actuel soit le suivant if (obj.Id == -1) { obj.Id = OutilsSQL.getLastInsertedId("groupe", Connexion.getInstance()) + 1; } /* * id * nom * id_enseignant * id_cours */ string query = @"INSERT INTO groupe(id, nom, id_enseignant, id_cours) VALUES (" + obj.Id + ", '" + obj.Nom + "', " + obj.enseignant.Id + ", " + obj.idCours + ");"; //Console.ReadLine(); using (SqlCommand command = new SqlCommand(query, Connexion.getInstance())) { command.ExecuteNonQuery(); //Connexion.getInstance().Close(); } return(obj); }
public override TypeCours create(TypeCours obj) { AbstractDAOFactory factoSQL = AbstractDAOFactory.getFactory(types.SQL_FACTORY); DAO <Categorie> categorie = factoSQL.getCategorieDAO(); if (obj.Id == -1) { obj.Id = OutilsSQL.getLastInsertedId("type_cours", Connexion.getInstance()) + 1; } using (SqlCommand command_c = new SqlCommand("INSERT INTO type_cours VALUES (" + obj.Id + ", '" + obj.Nom + "', '" + obj.Groupes + "');", Connexion.getInstance())) { command_c.ExecuteNonQuery(); // Connexion.getInstance().Close(); } //foreach (Categorie categ in categorie.findAll()) //{ // int idT = OutilsSQL.getLastInsertedId("equivalent_td", Connexion.getInstance()) + 1; // using (SqlCommand command_test = new SqlCommand("INSERT INTO equivalent_td VALUES (" + idT + ", '" + categ.Id + "', '" + obj.Id + "', 1 );", Connexion.getInstance())) // { // command_test.ExecuteNonQuery(); // } //} return(obj); }
public override Enseignant create(Enseignant obj) { if (obj.Id == -1) { obj.Id = OutilsSQL.getLastInsertedId("enseignant", Connexion.getInstance()) + 1; } using (SqlCommand command_c = new SqlCommand("INSERT INTO enseignant VALUES (" + obj.Id + ", '" + obj.Nom + "', '" + obj.Prenom + "', " + obj.nbHeuresTravaillees.ToString().Replace(",", ".") + ", " + obj.Categorie.Id + ", '" + obj.lienImage + "');", Connexion.getInstance())) { command_c.ExecuteNonQuery(); } return(obj); }
public override Enseignement create(Enseignement obj) { if (obj.Id == -1) { obj.Id = OutilsSQL.getLastInsertedId("enseignement", Connexion.getInstance()) + 1; } using (SqlCommand command_c = new SqlCommand("INSERT INTO enseignement VALUES (" + obj.Id + ", '" + obj.Nom + "', " + obj.PartieAnnee.Id + ", '" + obj.Description + "');", Connexion.getInstance())) { command_c.ExecuteNonQuery(); } return(obj); }
public override Departement create(Departement obj) { if (obj.Id == -1) { obj.Id = OutilsSQL.getLastInsertedId("departement", Connexion.getInstance()) + 1; } using (SqlCommand command_c = new SqlCommand("INSERT INTO departement VALUES (" + obj.Id + ", '" + obj.Nom + "');", Connexion.getInstance())) { command_c.ExecuteNonQuery(); } return(obj); }
public override EC create(EC obj) { if (obj.Id == -1) { obj.Id = OutilsSQL.getLastInsertedId("ec", Connexion.getInstance()) + 1; } using (SqlCommand command_c = new SqlCommand("INSERT INTO ec VALUES (" + obj.Id + ", '" + obj.Nom + "', " + obj.Enseignement.Id + ");", Connexion.getInstance())) { command_c.ExecuteNonQuery(); } return(obj); }
public override Annee create(Annee obj) { if (obj.Id == -1) { obj.Id = OutilsSQL.getLastInsertedId("annee", Connexion.getInstance()) + 1; } using (SqlCommand command_c = new SqlCommand("INSERT INTO annee VALUES (" + obj.Id + ", '" + obj.Nom + "', " + obj._departement.Id + ", '" + obj._description + "');", Connexion.getInstance())) { command_c.ExecuteNonQuery(); // Connexion.getInstance().Close(); } return(obj); }
public override Categorie create(Categorie obj) { AbstractDAOFactory factoSQL = AbstractDAOFactory.getFactory(types.SQL_FACTORY); DAO <Categorie> categorie = factoSQL.getCategorieDAO(); if (obj.Id == -1) { obj.Id = OutilsSQL.getLastInsertedId("categorie_enseignant", Connexion.getInstance()) + 1; } using (SqlCommand command_c = new SqlCommand(@"INSERT INTO categorie_enseignant VALUES (" + obj.Id + ", '" + obj.Nom + "', " + obj.Heures + ");", Connexion.getInstance())) { command_c.ExecuteNonQuery(); } return(obj); }
public override EquivalentTD create(EquivalentTD obj) { if (obj.Id == -1) { obj.Id = OutilsSQL.getLastInsertedId("equivalent_td", Connexion.getInstance()) + 1; } string query = "INSERT INTO dbo.equivalent_td (id, id_categorie_enseignant, id_type_cours, ratio_cours_td) VALUES (@id, @id_categorie_enseignant, @id_type_cours, @ratio_cours_td)"; using (SqlCommand command = new SqlCommand(query, Connexion.getInstance())) { command.Parameters.AddWithValue("@id", obj.Id); command.Parameters.AddWithValue("@id_categorie_enseignant", obj.Categorie.Id); command.Parameters.AddWithValue("@id_type_cours", obj.TypeCours is null ? DBNull.Value : (object)obj.TypeCours.Id); command.Parameters.AddWithValue("@ratio_cours_td", obj.Ratio); command.ExecuteNonQuery(); } return(obj); }
public override InfosAssignation create(InfosAssignation obj) { if (obj.Id == -1) { obj.Id = OutilsSQL.getLastInsertedId("infos_assignation", Connexion.getInstance()) + 1; } string query = "INSERT INTO dbo.infos_assignation (id, nom, id_ec, id_typecours, id_enseignant, nb_heures) VALUES (@id, @nom, @id_ec, @id_typecours, @id_enseignant, @nb_heures)"; using (SqlCommand command = new SqlCommand(query, Connexion.getInstance())) { command.Parameters.AddWithValue("@id", obj.Id); command.Parameters.AddWithValue("@nom", obj.Nom); command.Parameters.AddWithValue("@id_ec", obj.EC.Id); command.Parameters.AddWithValue("@id_typecours", obj.TypeCours is null ? DBNull.Value : (object)obj.TypeCours.Id); command.Parameters.AddWithValue("@id_enseignant", obj.Enseignant is null ? DBNull.Value : (object)obj.Enseignant.Id); command.Parameters.AddWithValue("@nb_heures", obj.NbHeures.ToString().Replace(",", ".")); command.ExecuteNonQuery(); } return(obj); }