private void supp_item_button_Click(object sender, EventArgs e) { /*Delete the slected agent from the database*/ if (agent.tableId == -1)//no selected agent { MessageBox.Show("Veuillez sélectionner un agent avant de pouvoir modifier ses informations"); return; } if (agent.tableId == SecurityManager.getConnectedAgentTableIndex()) { MessageBox.Show("Vous ne pouvez pas supprimer votre propre compte"); return; } if (SecurityManager.getConnectedAgentRight() != SecurityManager.RIGHTS_LIST.LastIndexOf(SecurityManager.RIGHT_DEUS)) { //an user cannot delete an account with higer or equal priviledges if (SecurityManager.getConnectedAgentRight() == agent.getRight() || !SecurityManager.rightLevelEnoughToAccesSystem(SecurityManager.getConnectedAgentRight(), agent.getRight())) { MessageBox.Show("Vous ne disposez pas des droits necessaires pour supprimer un compte de plus haut (ou égal) privilège"); return; } } agent.deleteAgent();//delete agent if (database.updateAgent(agent) == ToolsClass.Definition.NO_ERROR_INT_VALUE) { int index = list_ids.LastIndexOf(agent.tableId); if (index != -1) { //update the listbox listBox.DataSource = new List <string>(); list_ids.RemoveAt(index); list_results.RemoveAt(index); listBox.DataSource = list_results; setDefault(); } MessageBox.Show("Les informations de l'agent ne sont désormais plus accessibles mais elles resteront en mémoire jusqu'à la prochaine purge"); } else //an error occured { MessageBox.Show("Un problème est survenu : impossible de mettre à jour les informations"); } }
/*---------------------------------------------------- Physical connexion ------------------------------------------------*/ public static int getConnectedAgentRight() { return(connected_agent.getRight()); }