Keine Cache-Version

Caching deaktiviert Standardeinstellung für diese Seite:aktiviert (code LNG204)
Wenn die Anzeige zu langsam ist, können Sie den Benutzermodus deaktivieren, um die zwischengespeicherte Version anzuzeigen.

NoChangeSerieDao.cs

Description du code

NoChangeSerieDao.cs est un fichier du projet BiblioBrol.
Ce fichier est situé dans /var/www/bin/sniplets/bibliobrol/src/.

Projet BiblioBrol :

Gestion de media en CSharp.

Pour plus d'infos, vous pouvez consulter la brève analyse.

Code source ou contenu du fichier

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using System.Data.Common;
  5. using System.Data;
  6. using be.gaudry.observer;
  7.  
  8. namespace be.gaudry.bibliobrol.model.dao.mysql
  9. {
  10. class NoChangeSerieDao : Observable, ISerieDao
  11. {
  12. #region singleton
  13. static NoChangeSerieDao instance = null;
  14. static readonly object padlock = new object();
  15. private String conStr;
  16. private DbProviderFactory dbpf;
  17. NoChangeSerieDao()
  18. {
  19. notify(new Notification(Notification.VERBOSE.debug, "AccessSerieDao singleton call", this));
  20. dbpf = ((MySQLFactory)MySQLFactory.Instance).getDbpf();
  21. conStr = ((MySQLFactory)MySQLFactory.Instance).getConnectionString();
  22. }
  23. public static NoChangeSerieDao Instance
  24. {
  25. get
  26. {
  27. lock (padlock)
  28. {
  29. if (instance == null)
  30. {
  31. instance = new NoChangeSerieDao();
  32. }
  33. return instance;
  34. }
  35. }
  36. }
  37. #endregion
  38.  
  39. #region ISerieDao Membres
  40.  
  41. public bool insertSerie(Serie serie)
  42. {
  43. if (serie.Id > 0)
  44. {
  45. notify(new Notification(Notification.VERBOSE.opsResult, "Impossible d'insérer la série.", this));
  46. return false;
  47. }
  48. DbConnection dbCon = dbpf.CreateConnection();
  49. DbDataAdapter dbDa = dbpf.CreateDataAdapter();
  50. dbDa.InsertCommand = dbCon.CreateCommand();
  51. dbCon.ConnectionString = conStr;
  52. dbCon.Open();
  53. dbDa.InsertCommand.CommandText = string.Format(
  54. "INSERT INTO serie (name) VALUES ('{0}');",
  55. MySQLUtils.escapeAndTrim(serie.Name)
  56. );
  57. notify(new Notification(Notification.VERBOSE.persistentOperation, dbDa.InsertCommand.CommandText, this));
  58. try
  59. {
  60. dbDa.InsertCommand.ExecuteNonQuery();
  61. }
  62. catch (Exception e)
  63. {
  64. notify(new Notification(Notification.VERBOSE.error, "Insertion d'une série", e, this));
  65. return false;
  66. }
  67. finally
  68. {
  69. dbCon.Close();
  70. }
  71. notify(new Notification(Notification.VERBOSE.opsResult, "La série \"" + serie.Name + "\" est ajoutée", this));
  72. return true;
  73. }
  74.  
  75. public bool updateSerie(Serie serie)
  76. {
  77. if (serie.Id <= 0)
  78. {
  79. return insertSerie(serie);
  80. }
  81. DbConnection dbCon = dbpf.CreateConnection();
  82. DbDataAdapter dbDa = dbpf.CreateDataAdapter();
  83. dbDa.UpdateCommand = dbCon.CreateCommand();
  84. dbCon.ConnectionString = conStr;
  85. dbCon.Open();
  86.  
  87. dbDa.UpdateCommand.CommandText = string.Format(
  88. "UPDATE serie SET name='{0}' WHERE id={1};",
  89. MySQLUtils.escapeAndTrim(serie.Name),
  90. serie.Id
  91. );
  92. notify(new Notification(Notification.VERBOSE.persistentOperation, dbDa.UpdateCommand.CommandText, this));
  93. try
  94. {
  95. dbDa.UpdateCommand.ExecuteNonQuery();
  96. }
  97. catch (Exception e)
  98. {
  99. notify(new Notification(Notification.VERBOSE.error, "Modification d'une série", e, this));
  100. return false;
  101. }
  102. finally
  103. {
  104. dbCon.Close();
  105. }
  106. notify(new Notification(Notification.VERBOSE.opsResult, "La série \"" + serie.Name + "\" est modifiée", this));
  107. return true;
  108. }
  109. public bool deleteSerie(int serieId)
  110. {
  111. if (serieId <= 0)
  112. {
  113. notify(new Notification(Notification.VERBOSE.opsResult, "Impossible de supprimer la série.", this));
  114. return false;
  115. }
  116. DbConnection dbCon = dbpf.CreateConnection();
  117. DbDataAdapter dbDa = dbpf.CreateDataAdapter();
  118. dbDa.DeleteCommand = dbCon.CreateCommand();
  119. dbCon.ConnectionString = conStr;
  120. dbCon.Open();
  121. dbDa.DeleteCommand.CommandText = "DELETE FROM serie WHERE id=" + serieId;
  122. notify(new Notification(Notification.VERBOSE.persistentOperation, dbDa.DeleteCommand.CommandText, this));
  123. try
  124. {
  125. dbDa.DeleteCommand.ExecuteNonQuery();
  126. }
  127. catch (Exception e)
  128. {
  129. notify(new Notification(Notification.VERBOSE.error, "Suppression d'une série", e, this));
  130. return false;
  131. }
  132. finally
  133. {
  134. dbCon.Close();
  135. }
  136. notify(new Notification(Notification.VERBOSE.opsResult, "La série est supprimée", this));
  137. return true;
  138. }
  139.  
  140. public List<Serie> loadSeries()
  141. {
  142. List<Serie> series = new List<Serie>();
  143. DbConnection dbCon = dbpf.CreateConnection();
  144. DbDataAdapter dbDa = dbpf.CreateDataAdapter();
  145. dbDa.SelectCommand = dbCon.CreateCommand();
  146. dbCon.ConnectionString = conStr;
  147. String str = "SELECT * FROM serie ORDER BY name";
  148. dbDa.SelectCommand.CommandText = str;
  149. notify(new Notification(Notification.VERBOSE.persistentOperation, dbDa.SelectCommand.CommandText, this));
  150. DataTable dt = new DataTable();
  151. try
  152. {
  153. dbDa.Fill(dt);
  154. foreach (DataRow row in dt.Rows)
  155. {
  156. series.Add(new Serie(
  157. (int)row["id"],
  158. (row["name"] is DBNull) ? "Sans nom" : (String)row["name"]));
  159. }
  160. }
  161. catch (Exception e)
  162. {
  163. notify(new Notification(Notification.VERBOSE.lowError,"Chargement des séries", e, this));
  164. }
  165. dt.Dispose();
  166. dbCon.Close();
  167. return series;
  168. }
  169.  
  170. #endregion
  171. }
  172. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/src/model/dao/mysql/ 
IcôneNomTailleModification
IcôneNomTailleModification
| _ Répertoire parent0 octets1719822445 01/07/2024 10:27:25
| _utils0 octets1541007203 31/10/2018 18:33:23
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/src/model/dao/mysql/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csNoChangeImporterDao.cs27.14 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csNoChangeExporterDao.cs33.69 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csNoChangeSerieDao.cs6.22 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csMySQLFactory.cs3.75 Ko31/10/2018 18:33:17-refusé-
Afficher le fichier .cs|.csNoChangeConfigDao.cs12.25 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csNoChangePersonDao.cs59.9 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csNoChangeTaskDao.cs8.92 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csNoChangeBrolDao.cs58.25 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csMySQLStatsDao.cs10.63 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csMySQLMediaBrolDao.cs50.51 Ko31/10/2018 18:33:18-refusé-

Utilisation de l'explorateur de code

  • Navigation :
    • Un clic sur une icône de répertoire ouvre ce répertoire pour en afficher les fichiers.
    • Lorsque le répertoire en cours ne contient pas de sous-répertoires il est possible de remonter vers le répertoire parent.
    • La structure de répertoires en treetable (tableau en forme d'arborescence) n'est plus possibledans cette version.
    • Un clic sur une icône de fichier ouvre ce fichier pour en afficher le code avec la coloration syntaxique adaptée en fonction du langage principal utilisé dans le fichier.
  • Affichage :
    • Il est possible de trier les répertoires ou les fichiers selon certains critères (nom, taille, date).
  • Actions :
    • Les actions possible sur les fichiers dépendent de vos droits d'utilisateur sur le site. Veuillez activer le mode utilisateur pour activer les actions.

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 16/10/2009, zuletzt geändert 26/10/2018
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/cs-bibliobrol-source-rf-model/dao/mysql/NoChangeSerieDao.cs.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.