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.

AccessControl.cs

Description du code

AccessControl.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.Text;
  3. using System.Windows.Forms;
  4. using be.gaudry.bibliobrol.config;
  5. using be.gaudry.bibliobrol.model.dao;
  6. using be.gaudry.bibliobrol.model.dao.config;
  7. using be.gaudry.bibliobrol.model.enums;
  8. using be.gaudry.model.enums;
  9.  
  10. namespace be.gaudry.bibliobrol.view.controls.dao
  11. {
  12. public partial class AccessControl : UserControl, IDBControl
  13. {
  14. #region declarations and constructors
  15. private OpenFileDialog openDBDialog;
  16. private AccessConfig dbConfig;
  17. private bool allowSaving;
  18. public AccessControl()
  19. {
  20. allowSaving = false;
  21. InitializeComponent();
  22. openDBDialog = new OpenFileDialog();
  23. reset();
  24. allowSaving = true;
  25. }
  26. #endregion
  27.  
  28. #region private methods
  29.  
  30. #region modify db path
  31. /// <summary>
  32. /// Uses an <code>OpenFileDialog</code> to select the db file to use.
  33. /// </summary>
  34. /// <param name="sender"></param>
  35. /// <param name="e"></param>
  36. private void dbBrowseBtn_Click(object sender, EventArgs e)
  37. {
  38. //openDBDialog.RestoreDirectory = true;
  39. openDBDialog.CheckFileExists = true;
  40. openDBDialog.Title = "Sélection de la base de données Access à utiliser...";
  41.  
  42. StringBuilder filterSB = new StringBuilder("Tous (*.bdb;*.mdb;*.accdb;*.bdb3;*bdb7)|*.bdb;*.mdb;*.accdb;*.bdb3;*bdb7");
  43. filterSB.Append("|Bibliobrol DataBase (*.bdb)|*.bdb");
  44. filterSB.Append("|Bibliobrol DataBase V.3 (*.bdb3)|*.bdb3");
  45. filterSB.Append("|Bibliobrol DataBase V.7 (*.bdb7)|*.bdb7");
  46. filterSB.Append("|Microsoft Office Access (*.mdb)|*.mdb");
  47. openDBDialog.Filter = filterSB.ToString();
  48.  
  49. openDBDialog.InitialDirectory = dbConfig.getAdaptedDirectory();//Application.StartupPath;
  50. if (openDBDialog.ShowDialog(this) == DialogResult.OK)
  51. {
  52. dbPathLbl.Text = openDBDialog.FileName;
  53. toolTip1.SetToolTip(dbPathLbl, openDBDialog.FileName);
  54. openDBDialog.Dispose();
  55. if (dbPathLbl.Text.EndsWith(".bdb7") || dbPathLbl.Text.EndsWith(".accdb"))
  56. {
  57. version2007RB.Checked = true;
  58. }
  59. else
  60. {
  61. version2003RB.Checked = true;
  62. }
  63. save();
  64. }
  65. }
  66.  
  67. /// <summary>
  68. /// Shows a <code>TextBox</code> to modify the path of the db file.
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. private void editBtn_Click(object sender, EventArgs e)
  73. {
  74. if (dbPathTB.Visible)
  75. {
  76. dbPathLbl.Visible = true;
  77. dbPathLbl.Text = dbPathTB.Text;
  78. this.toolTip1.SetToolTip(this.dbPathLbl, dbPathLbl.Text);
  79. dbPathTB.Visible = false;
  80. editBtn.Text = "Modifier";
  81. //todo : use global::be.gaudry.Properties.Resources.brolEditBtn;
  82. editBtn.Image = global::be.gaudry.bibliobrol.Properties.Resources.brolEditBtn;
  83. dbBrowseBtn.Enabled = true;
  84. save();
  85. }
  86. else
  87. {
  88. dbPathLbl.Visible = false;
  89. dbPathTB.Text = dbPathLbl.Text;
  90. dbPathTB.Visible = true;
  91. editBtn.Text = "Appliquer";
  92. editBtn.Image = global::be.gaudry.bibliobrol.Properties.Resources.brolSaveBtn;
  93. dbBrowseBtn.Enabled = false;
  94. }
  95. }
  96. #endregion
  97.  
  98. #region adapt display on resize
  99.  
  100. private void AccessControl_Resize(object sender, EventArgs e)
  101. {
  102. showButtonsText(
  103. this.Size.Height > this.AutoScrollMinSize.Height &&
  104. this.Size.Width > this.AutoScrollMinSize.Width
  105. );
  106. }
  107. private void showButtonsText(bool showText)
  108. {
  109. if (showText)
  110. {
  111. editBtn.Text = "Modifier";
  112. editBtn.Width = 80;
  113.  
  114. dbBrowseBtn.Text = "Explorer";
  115. dbBrowseBtn.Width = editBtn.Width;
  116. //dbBrowseBtn.Location.Offset(50, 0);
  117. //dbBrowseBtn.Location = new System.Drawing.Point(95, 45);
  118. }
  119. else
  120. {
  121. editBtn.Text = "";
  122. editBtn.Width = 23;
  123.  
  124. dbBrowseBtn.Text = "";
  125. dbBrowseBtn.Width = editBtn.Width;
  126. //dbBrowseBtn.Location.Offset(-50, 0);
  127. //dbBrowseBtn.Location = new System.Drawing.Point(40, 45);
  128. }
  129. }
  130. #endregion
  131.  
  132. /// <summary>
  133. /// Get an enum from the checked option.
  134. /// Used to set the driver to access to the db.
  135. /// </summary>
  136. /// <returns>
  137. /// ACCESS_VERSION Version of the selected Access file.
  138. /// </returns>
  139. private ACCESS_VERSION getSelectedVersion()
  140. {
  141. return (version2007RB.Checked) ? ACCESS_VERSION.Access07 : ACCESS_VERSION.Access03;
  142. }
  143.  
  144. private void version_CheckedChanged(object sender, EventArgs e)
  145. {
  146. save();
  147. }
  148. #endregion
  149.  
  150. #region IDBControl Members
  151.  
  152. public void save()
  153. {
  154. if (!allowSaving)
  155. return;
  156. ACCESS_VERSION selectedVersion = getSelectedVersion();
  157. // Test if values must be saved
  158. if (!dbPathTB.Text.Equals(dbConfig.getAdaptedPath()) || (selectedVersion != dbConfig.AccessVersion))
  159. {
  160. //File.Exists doesn't throw exceptions if path is not valid, just return false
  161. bool validPath = System.IO.File.Exists(dbPathLbl.Text);
  162. if (validPath)
  163. {
  164.  
  165. Config.savePersistenceType(PERSISTENCE_TYPE.Access);
  166.  
  167. dbConfig.AccessVersion = selectedVersion;
  168. dbConfig.DBFileName = System.IO.Path.GetFileName(dbPathLbl.Text);
  169. dbConfig.DBPath = System.IO.Path.GetDirectoryName(dbPathLbl.Text);
  170. if (dbConfig.DBPath.Equals(Config.DataDirectory))
  171. {
  172. dbConfig.DBPath = "";
  173. }
  174. dbConfig.save();
  175. DialogResult dr = MessageBox.Show(
  176. "Une base de données vient d'être sélectionnée (" +
  177. dbConfig.getAdaptedPath() + " [" + EnumHelper.GetDescription(selectedVersion) +
  178. "]).\nLes données actuellement utilisées par l'application sont probablement incohérentes avec la nouvelle db " +
  179. "et il est fortement recommandé de redémarrer l'application.\nRedémarrer maintenant ?",
  180. "Sélection de la base de données",
  181. MessageBoxButtons.YesNo,
  182. MessageBoxIcon.Exclamation,
  183. MessageBoxDefaultButton.Button1);
  184. if (DialogResult.Yes == dr)
  185. {
  186. Application.Restart();
  187. }
  188. else
  189. {
  190. DAOFactory.resetDAO();
  191. }
  192. }
  193. else
  194. {
  195. MessageBox.Show(
  196. String.Format("Impossible de trouver la base de données à l'emplacement {0}", dbPathLbl.Text),
  197. "Sélection de la base de données",
  198. MessageBoxButtons.OK,
  199. MessageBoxIcon.Error,
  200. MessageBoxDefaultButton.Button1);
  201. }
  202. }
  203. //else : no modification detected
  204. }
  205.  
  206. /// <summary>
  207. /// Load data from the settings file, and update the view
  208. /// </summary>
  209. public void reset()
  210. {
  211. dbConfig = DAOFactory.Instance.getDBConfig() as AccessConfig;
  212. if (dbConfig == null)
  213. {
  214. dbConfig = new AccessConfig();
  215. }
  216. ACCESS_VERSION version = dbConfig.AccessVersion;
  217. switch (version)
  218. {
  219. case ACCESS_VERSION.Access03: version2003RB.Checked = true; break;
  220. case ACCESS_VERSION.Access07: version2007RB.Checked = true; break;
  221. }
  222. dbPathLbl.Text = dbConfig.getAdaptedPath();
  223. }
  224. #endregion
  225. }
  226. }

Structure et Fichiers du projet

Afficher/masquer...


Répertoires contenus dans /var/www/bin/sniplets/bibliobrol/src/view/controls/dao/ 
IcôneNomTailleModification
Pas de sous-répertoires.
IcôneNomTailleModification
| _ Répertoire parent0 octets1719427242 26/06/2024 20:40:42
Fichiers contenus dans /var/www/bin/sniplets/bibliobrol/src/view/controls/dao/ 
IcôneNomTailleModificationAction
IcôneNomTailleModificationAction
Afficher le fichier .cs|.csAccessControl.Designer.cs9.77 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .resx|.resxAccessControl.resx5.87 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csMySQLControl.cs1.56 Ko31/10/2018 18:33:19-refusé-
Afficher le fichier .cs|.csAccessControl.cs8.65 Ko31/10/2018 18:33:18-refusé-
Afficher le fichier .resx|.resxSQLEControl.resx5.68 Ko31/10/2018 18:33:19-refusé-
Afficher le fichier .resx|.resxDBProvidersControl.resx5.68 Ko31/10/2018 18:33:19-refusé-
Afficher le fichier .cs|.csDBProvidersControl.cs574 octets31/10/2018 18:33:18-refusé-
Afficher le fichier .cs|.csSQLEControl.Designer.cs6.99 Ko31/10/2018 18:33:19-refusé-
Afficher le fichier .cs|.csMySQLControl.Designer.cs6.6 Ko31/10/2018 18:33:19-refusé-
Afficher le fichier .cs|.csDBProvidersControl.Designer.cs2.35 Ko31/10/2018 18:33:19-refusé-
Afficher le fichier .cs|.csSQLEControl.cs1.16 Ko31/10/2018 18:33:19-refusé-
Afficher le fichier .cs|.csIDBControl.cs223 octets31/10/2018 18:33:19-refusé-
Afficher le fichier .resx|.resxMySQLControl.resx5.68 Ko31/10/2018 18:33:19-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-view/controls/dao/AccessControl.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.