void ICdsManager.saveCd(Cd cd) { try { _laSession.BeginTransaction(); _laSession.SaveOrUpdate(cd); _laSession.Transaction.Commit(); } catch (Exception e) { _laSession.Transaction.Rollback(); throw e; } }
/// <summary> /// Ajout/Màj média /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void btnValider_Click(object sender, EventArgs e) { if (Page.IsValid) { Media media = null; switch(Action) { case "upd" : media = mediaManager.getMedia(MediaId); break; case "add": //media = System.Reflection.Assembly.GetAssembly(typeof(MyConnector)).CreateInstance(ddlTypeMedia.SelectedValue) as Media; //media = System.Reflection.Assembly.GetEntryAssembly().CreateInstance(ddlTypeMedia.SelectedValue) as Media; // pas convainquant... switch (ddlTypeMedia.SelectedValue) { case "Cd": media = new Cd(); break; case "Dvd": media = new Dvd(); break; case "Livre": media = new Livre(); break; case "Divx": media = new Divx(); break; case "Jeu" : media = new Jeu(); break; default: throw new ArgumentException("Impossible de déterminer le type de média à sauvegarder"); } break; default: throw new ArgumentNullException("type d'opération inconnue"); } SaveMedia(media); displayMessage("success", "Le média a bien été enregistré !"); } else displayMessage("error", csVal.ErrorMessage); }