gestion de paiement des
employés
Acceuil Mode console Classe main Mode graphique
2009/2010. 4éme Année Encadrant EMSI.
Mr: M.Mansouri.
Ingénieurie Automatismes
et Informatique Industrielle.
La fonction main.
public class Maine {
public static void main(String[] args) {
new menu();
}
}
La fonction menu.
import javax.swing.*;
import java.awt.*;
import
java.awt.event.*;
class menu extends JFrame implements ActionListener
{
JFrame fen;
JPanel panel;
JButton in,tech,com,man,ret;
public menu ()
{
fen = new JFrame("PROGRAMME
PAIEMENT");
fen.setSize(300, 300);
panel= new JPanel();
GridLayout GL = new GridLayout(5,1);
in = new JButton("INGENIEUR");
in.addActionListener(this);
tech = new JButton("TECHNICIEN");
tech.addActionListener(this);
com = new JButton("COMMERCIAL");
com.addActionListener(this);
man = new JButton("MANNUTENSIONNAIRE");
man.addActionListener(this);
ret = new JButton("RETOUR");
ret.addActionListener(this);
panel.setLayout(GL);
panel.add(in);
panel.add(tech);
panel.add(com);
panel.add(man);
panel.add(ret);
fen.add(panel);
fen.setVisible(true);
}
public void actionPerformed(ActionEvent
ev)
{
if (ev.getSource().equals(in))
{
new inge();
}
else if (ev.getSource().equals(tech))
{
new tech();
}
else if (ev.getSource().equals(com))
{
new comm();
}
else if (ev.getSource().equals(man))
{
new man();
}
}
}
On crée dans cette fonction l’interface graphique de lancement qui
contient 4 boutons pour les 4 types d’employés.
Chaque employé possède un autre menu de choix entre l’ajout, la
recherche, la consultation d’absences, de retards et le paiement
On s’intéresse dans ce champ par le congé payé, la prime et la
promotion.
Un exemple de cette
méthode dans la classe ingénieur.
import
java.awt.GridLayout;
import
java.awt.event.ActionEvent;
import
java.awt.event.ActionListener;
import
javax.swing.JButton;
import
javax.swing.JFrame;
import
javax.swing.JOptionPane;
import
javax.swing.JPanel;
public class inge extends JFrame implements ActionListener
{
static ingenieur i[]=new ingenieur[20];
static int ng=0;
JFrame inge;
JPanel panel;
JButton rech,aj,abs,ret,pai,reto;
public inge()
{
inge = new JFrame("INGENIEUR");
inge.setSize(300, 300);
panel= new JPanel();
GridLayout GL = new GridLayout(5,1);
rech = new JButton("RECHERCH");
rech.addActionListener(this);
aj = new JButton("AJOUTER");
aj.addActionListener(this);
abs = new JButton("ABSENSE");
abs.addActionListener(this);
ret = new JButton("RETARD");
ret.addActionListener(this);
pai = new JButton("PAIEMENT");
pai.addActionListener(this);
reto = new JButton("RETOUR");
reto.addActionListener(this);
panel.setLayout(GL);
panel.add(rech);
panel.add(aj);
panel.add(abs);
panel.add(ret);
panel.add(pai);
panel.add(reto);
inge.add(panel);
inge.setVisible(true);
}
public void actionPerformed(ActionEvent
ev)
{
if(ev.getSource().equals(rech)){
String ma=JOptionPane.showInputDialog
(null, "Donnez
le matricule");
int ma1=Integer.parseInt(ma);
i[ma1-1].affiche_un(ma1);
}
else if(ev.getSource().equals(aj)){
String nom= JOptionPane.showInputDialog
(null, "Donnez
le NOM");
String prenom= JOptionPane.showInputDialog
(null, "Donnez
le PRENOM");
String jour= JOptionPane.showInputDialog
(null, "Donnez
la date d'embauche : le jour");
int jour1=Integer.parseInt(jour);
String mois= JOptionPane.showInputDialog
(null, "Donnez
la date d'embauche : le mois");
int mois1=Integer.parseInt(mois);
String an= JOptionPane.showInputDialog
(null, "Donnez
la date d'embauche : l'année");
int an1=Integer.parseInt(an);
String salair= JOptionPane.showInputDialog
(null, "Donnez
le salaire");
int salair1=Integer.parseInt(salair);
i[ng]=new ingenieur(nom,prenom,jour1,mois1,an1,salair1);ng++;
}
else if(ev.getSource().equals(abs)){
String mat=JOptionPane.showInputDialog
(null, "Donnez
le Matricule");
int mat1=Integer.parseInt(mat);
i[mat1-1].absenses();
}
else if(ev.getSource().equals(ret)){
String mat=JOptionPane.showInputDialog
(null, "Donnez
le Matricule");
int mat1=Integer.parseInt(mat);
String heu=JOptionPane.showInputDialog
(null, "Donnez
le nobre d'heurs");
int heu1=Integer.parseInt(heu);
i[mat1-1].retards(heu1);
}
else if(ev.getSource().equals(pai)){
String pay=JOptionPane.showInputDialog
(null, "Donnez le Matricule");
int pay1=Integer.parseInt(pay);
i[pay1-1].absenses();
}
else if(ev.getSource().equals(reto)){
inge.setVisible(false);
}
}
}
Pour télécharger le fichier du programme en mode console pour le logiciel eclips
Clique ICI.