private void submenuItem_Click(object sender, EventArgs e) { ToolStripMenuItem clicked_menu_item = sender as ToolStripMenuItem; if (clicked_menu_item.Name != "nomDeDomainDuServerSQL") { /*In fact if the user want to change the domaine name of the sql server he could not anymore connect to the database * because the server name has changed (and users need to access database when they try to set a connection with the database */ //get the first parent of the submenu if (!Error.debug) { ToolStripItem source_item = clicked_menu_item.OwnerItem; while (source_item.OwnerItem != null) { source_item = source_item.OwnerItem; } int needed_right = SecurityManager.RIGHTS_LIST.LastIndexOf(source_item.Tag.ToString()); if (!SecurityManager.rightLevelEnoughToAccesSystem(SecurityManager.getConnectedAgentRight(), needed_right)) { if (SecurityManager.getFormatedSessionInfo() == "") { endPreviousSession(); } MessageBox.Show("Vous n'avez pas les droits nécessaires pour accéder à cette option"); return; } } } switch (clicked_menu_item.Name) { /*---------------------------------- Update ---------------------------------- */ case "nettoyerBaseDeDonnées": { clearData(); } break; case "purgerLaBaseDeDonnées": { string title = "Demande de confirmation"; string body = "Etes-vous certain(e) de vouloir purger la base de données ?\nAttention : cette action est irréversible!"; //check if user realy want to delete a student from database if (MessageBox.Show(body, title, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) // user clicked yes { changeBanner("Purge de la base de données" + Environment.NewLine + "Veuillez patienter...", Color.DarkOrange); //send mail to notice that the database has been clean string mail_title = "Purge de la base de données"; string mail_body = "L'agent " + SecurityManager.getFormatedSessionInfo() + " vient d'ordonner la purge de la base de données. " + "Cette action est irréversible et aura pour effet de supprimer l'intégralité des données sauvegardées, " + "hormis celle concernant les agents."; Tools.sendMail(mail_title, mail_body, ToolsClass.Settings.MailsList); //purge the whole database DataBase database = new DataBase(); if (database.purgeAllData() == Definition.NO_ERROR_INT_VALUE) { MessageBox.Show("La base de données a été effacée avec succès"); } else { MessageBox.Show("Une partie ou la totalité de la base de données n'a pas pu être effacée !"); } } } break; /*---------------------------------- Settings ---------------------------------- */ case "nomDeDomainDuServerSQL": { DatabaseSettings Form = new DatabaseSettings(); Form.ShowDialog(); } break; case "adresseIpDuServer": { /* Handler to the click event on the menu item "adresse Ip du server". * Allow user to change element of server like ip adress and cimmunication port */ SettingsServerElements Form = new SettingsServerElements(); Form.ShowDialog(); } break; case "fichierDaccèsAuServeur": { /* Handler to the click event on the menu item "fichier d'accès au serveur". * Allow user to select the location of file that contains the actual urlof the server */ SettingsAccessToServerFile Form = new SettingsAccessToServerFile(); Form.ShowDialog(); } break; case "gestionDesAdressesMails": { SettingsList Form = new SettingsList(Definition.USE_FOR_MAILS_LIST); Form.ShowDialog(); } break; case "gestionDuServiceDenvoiDeCourriel": { SetingsMailsSender Form = new SetingsMailsSender(); Form.ShowDialog(); } break; case "gestionDesDroitsDaccès": { AccessManagementForm Form = new AccessManagementForm(); Form.ShowDialog(); } break; /*---------------------------------- Administration ---------------------------------- */ case "SchoolData": { SchoolDataForm Form = new SchoolDataForm(); Form.ShowDialog(); } break; case "formatDesPhotos": { SettingsStudentPhoto Form = new SettingsStudentPhoto(); Form.ShowDialog(); } break; case "importerDesPhotos": { StudentPhotosFolderChooser Form = new StudentPhotosFolderChooser(); Form.ShowDialog(); } break; case "MAJBaseDeDonnées": { SettingsStudentsStateFile Form = new SettingsStudentsStateFile(); Form.ShowDialog(); } break; case "régimesDeSortie": { ExitRegime Form = new ExitRegime(); Form.ShowDialog(); } break; case "longueurIdentifiantRFID": { string title = "Longueur des identifiants RFID"; string message = "Veuillez indiquer le nombre de caractère composant les identifiant RFID utilisés"; string default_response = "" + ToolsClass.Settings.LengthRfidId; string user_answer = Microsoft.VisualBasic.Interaction.InputBox(message, title, default_response); if (user_answer != "" && user_answer != null) { int length_rfid_id = 10; int.TryParse(user_answer, out length_rfid_id); ToolsClass.Settings.LengthRfidId = length_rfid_id; } } break; case "gestionDesDonnéesÉlèves": { BrowseStudentData Form = new BrowseStudentData(); Form.Show(); } break; /*---------------------------------- School Life Office ---------------------------------- */ case "sonSortieNonAutorisé": { /* Handler to the click event on the menu item "son sortie non autorisée". * Allow user to select the new mp3 file that will be played when student can't * leave the school */ OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = "c:\\"; openFileDialog.Filter = Tools.getOpenDialogFilter(Definition.VALID_AUDIO_EXTENSION); openFileDialog.FilterIndex = 2; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { ToolsClass.Settings.changeErrorAudioFile(openFileDialog.FileName); } } break; case "motifsDinterdictionDeSortie": { SettingsList Form = new SettingsList(Definition.USE_FOR_EXIT_BAN_REASONS_LIST); Form.ShowDialog(); } break; default: break; } bannerToPreviousState(); }
/* Called when clicking on the "settings" menu option */ private void SettingsClick(object sender, EventArgs e) { var frm = new DatabaseSettings(); frm.ShowDialog(this); ConnStatus(); }