Interfaz de Gestión de Empleados
Interfaz de Gestión de Empleados
/**
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* $Id$
* Universidad de los Andes (Bogot - Colombia)
* Departamento de Ingeniera de Sistemas y Computacin
* Licenciado bajo el esquema Academic Free License version 2.1
*
* Proyecto Cupi2
* Ejercicio: n1_empleado
* Autor: Mario Snchez - 13/06/2005
* Autor: Mario Snchez - 02/2005
* Autor: Pablo Barvo - 22/08/2005
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
* Esta es la ventana principal de la aplicacin. Contiene a los paneles
que tienen los botones y muestran la informacin del empleado.
*/
public class InterfazEmpleado extends JFrame
{
//----------------------------------------------------------------// Atributos
//----------------------------------------------------------------/**
* El empleado que se est mostrando
*/
private Empleado empleado;
//----------------------------------------------------------------// Atributos de la interfaz
//----------------------------------------------------------------/**
* Es el panel que contiene los elementos para mostrar los datos del
empleado
*/
private PanelDatos panelDatos;
/**
panel principal
).setLayout( new BorderLayout( ) );
).add( panelDatos, [Link] );
).add( panelCentral, [Link] );
).add( panelExtensiones, [Link] );
empleado = e;
[Link]( e );
}
//----------------------------------------------------------------// Mtodos
//----------------------------------------------------------------/**
* Este mtodo sirve para actualizar los campos de la forma con los datos
actuales del empleado. <br>
* <b>post: </b>Los campos de la ventana contienen la informacin del
empleado. <br>
*/
public void actualizarEmpleado( )
{
String nombre, apellido, sexo, fechaI, fechaN, imagen;
int salario;
nombre = [Link]( );
apellido = [Link]( );
int iSexo = [Link]( );
if( iSexo == 1 )
sexo = "m";
else
sexo = "f";
fechaI = [Link]( );
fechaN = [Link]( );
salario = [Link]( );
imagen = [Link]( );
[Link]( nombre, apellido, sexo, fechaI, fechaN,
imagen );
[Link]( salario );
[Link]( );
validate( );
}
/**
* En este mtodo se solicita al usuario que ingrese el nuevo salario del
empleado y se actualiza su informacin. <br>
* <b>post: </b> Se actualiz el salario del empleado y se present la
informacin actualizada. <br>
*/
public void modificarSalario( )
{
String strSalario = [Link]( this, "Introduzca el
nuevo salario" );
if( strSalario != null )
{
try
{
int nuevoSalario = [Link]( strSalario );
[Link]( nuevoSalario );
[Link]( [Link]( ) );
}
catch( NumberFormatException nfe )
{
[Link]( this, "El salario indicado no es vlido."
);
}
}
}
//----------------------------------------------------------------// Puntos de Extensin
//----------------------------------------------------------------/**
* Mtodo 1 de extensin del ejemplo
*/
public void reqFuncOpcion1( )
{
String respuesta = empleado.metodo1( );
[Link]( this, respuesta, "Respuesta",
JOptionPane.INFORMATION_MESSAGE );
}
/**
* Mtodo 2 de extensin del ejemplo
*/
public void reqFuncOpcion2( )
{
String respuesta = empleado.metodo2( );
[Link]( this, respuesta, "Respuesta",
JOptionPane.INFORMATION_MESSAGE );
}
//----------------------------------------------------------------// Main
//----------------------------------------------------------------/**
* Este mtodo ejecuta la aplicacin, creando una nueva interfaz e
inicializndola con un empleado.
* @param args Los argumentos no son utilizados.
*/
public static void main( String[] args )
{
Fecha fechaNacimiento = new Fecha( );
[Link]( 16, 6, 1982 );
//**PANEL CONSULTA**//
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* $Id$
* Universidad de los Andes (Bogot - Colombia)
* Departamento de Ingeniera de Sistemas y Computacin
* Licenciado bajo el esquema Academic Free License version 2.1
*
* Proyecto Cupi2 ([Link]
* Ejercicio: n1_empleado
* Autor: Mario Snchez - Jun 13, 2005
* Autor: Mario Snchez - Jun 13, 2005
* Autor: Pablo Barvo - 22/08/2005
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
package [Link];
import
import
import
import
import
import
import
import
import
import
import
import
import
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
import [Link];
/**
* En este panel se muestran los campos y botones necesarios para realizar
las consultas
*/
public class PanelConsultas extends JPanel implements ActionListener
{
//----------------------------------------------------------------// Constantes
//----------------------------------------------------------------/**
* El comando para el botn de calcular la edad del empleado
*/
private final static String CALCULAR_EDAD = "CALCULAR EDAD";
/**
* El comando para el botn de calcular la antigedad del empleado
*/
private final static String CALCULAR_ANTIGUEDAD = "CALCULAR ANTIGUEDAD";
/**
* El comando para el botn de calcular las prestaciones del empleado
*/
private final static String CALCULAR_PRESTACIONES = "CALCULAR
PRESTACIONES";
//----------------------------------------------------------------// Atributos
//----------------------------------------------------------------/**
* El empleado sobre el que se realizan los clculos
*/
private Empleado empleado;
//----------------------------------------------------------------// Atributos de la interfaz
//----------------------------------------------------------------/**
* El campo donde se muestra la edad
*/
private JTextField txtEdad;
/**
* El campo donde se muestra la antigedad
*/
private JTextField txtAntiguedad;
/**
* El campo donde se muestran las prestaciones
*/
private JTextField txtPrestaciones;
/**
* El botn para calcular la edad
*/
private JButton butEdad;
/**
* El botn para calcular la antigedad
*/
private JButton butAntiguedad;
/**
* El botn para calcular las prestaciones
*/
private JButton butPrestaciones;
//-----------------------------------------------------------------
// Constructores
//----------------------------------------------------------------/**
* Construye el panel de datos a consultar.
*/
public PanelConsultas( )
{
GridBagLayout gridbag = new GridBagLayout( );
setLayout( gridbag );
setBorder( new CompoundBorder( new EmptyBorder( 0, 0, 5, 0 ), new
TitledBorder( "Clculos" ) ) );
butEdad = new JButton( );
GridBagConstraints gbc = new GridBagConstraints( 0, 0, 1, 1, 0, 0,
[Link], [Link], new Insets( 5, 5, 5,
5 ), 0, 0 );
add( butEdad, gbc );
butAntiguedad = new JButton( );
gbc = new GridBagConstraints( 0, 1, 1, 1, 0, 0,
[Link], [Link], new Insets( 5, 5, 5,
5 ), 0, 0 );
add( butAntiguedad, gbc );
butPrestaciones = new JButton( );
gbc = new GridBagConstraints( 0, 2, 1, 1, 0, 0,
[Link], [Link], new Insets( 5, 5, 5,
5 ), 0, 0 );
add( butPrestaciones, gbc );
txtEdad = new JTextField( 10 );
gbc = new GridBagConstraints( 1, 0, 1, 1, 0, 0, [Link],
[Link], new Insets( 5, 5, 5, 5 ), 0, 0 );
add( txtEdad, gbc );
[Link]( false );
txtAntiguedad = new JTextField( 10 );
gbc = new GridBagConstraints( 1, 1, 1, 1, 0, 0, [Link],
[Link], new Insets( 5, 5, 5, 5 ), 0, 0 );
add( txtAntiguedad, gbc );
[Link]( false );
txtPrestaciones = new JTextField( 10 );
gbc = new GridBagConstraints( 1, 2, 1, 1, 0, 0, [Link],
[Link], new Insets( 5, 5, 5, 5 ), 0, 0 );
add( txtPrestaciones, gbc );
[Link]( false );
[Link]( "Calcular Edad" );
[Link]( PanelConsultas.CALCULAR_EDAD );
[Link]( this );
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* $Id$
* Universidad de los Andes (Bogot - Colombia)
* Departamento de Ingeniera de Sistemas y Computacin
* Licenciado bajo el esquema Academic Free License version 2.1
*
* Proyecto Cupi2 ([Link]
* Ejercicio: n1_empleado
* Autor: Mario Snchez - Jun 13, 2005
* Autor: Mario Snchez - Jun 13, 2005
* Autor: Pablo Barvo - 22/08/2005
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
package [Link];
import
import
import
import
import
import
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
import
import
import
import
import
import
import
import
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
/**
* En este panel se muestran los datos del empleado
*/
public class PanelDatos extends JPanel
{
//----------------------------------------------------------------// Atributos de la Interfaz
//----------------------------------------------------------------/**
* Etiqueta del nombre
*/
private JLabel labNombre;
/**
* Etiqueta del apellido
*/
*/
public PanelDatos( )
{
GridBagLayout gridbag = new GridBagLayout( );
setLayout( gridbag );
setBorder( new CompoundBorder( new EmptyBorder( 0, 0, 5, 0 ), new
TitledBorder( "Datos Personales" ) ) );
GridBagConstraints gbc;
labNombre = new JLabel( "Nombre: " );
gbc = new GridBagConstraints( 0, 0, 1, 1, 0, 0, [Link],
[Link], new Insets( 5, 5, 5, 5 ), 0, 0 );
add( labNombre, gbc );
labApellido = new JLabel( "Apellido: " );
gbc = new GridBagConstraints( 0, 1, 1, 1, 0, 0, [Link],
[Link], new Insets( 5, 5, 5, 5 ), 0, 0 );
add( labApellido, gbc );
labSexo = new JLabel( "Sexo: " );
gbc = new GridBagConstraints( 0, 2, 1, 1, 0, 0, [Link],
[Link], new Insets( 5, 5, 5, 5 ), 0, 0 );
add( labSexo, gbc );
labFNacimiento = new JLabel( "Fecha de Nacimiento: " );
gbc = new GridBagConstraints( 0, 3, 1, 1, 0, 0, [Link],
[Link], new Insets( 5, 5, 5, 5 ), 0, 0 );
add( labFNacimiento, gbc );
labFIngreso = new JLabel( "Fecha de Ingreso: " );
gbc = new GridBagConstraints( 0, 4, 1, 1, 0, 0, [Link],
[Link], new Insets( 5, 5, 5, 5 ), 0, 0 );
add( labFIngreso, gbc );
txtNombre = new JTextField( 15 );
gbc = new GridBagConstraints( 1, 0, 1, 1, 0, 0, [Link],
[Link], new Insets( 5, 5, 5, 5 ), 0, 0 );
add( txtNombre, gbc );
[Link]( false );
txtApellido = new JTextField( 15 );
gbc = new GridBagConstraints( 1, 1, 1, 1, 0, 0, [Link],
[Link], new Insets( 5, 5, 5, 5 ), 0, 0 );
add( txtApellido, gbc );
[Link]( false );
txtSexo = new JTextField( 2 );
gbc = new GridBagConstraints( 1, 2, 1, 1, 0, 0, [Link],
[Link], new Insets( 5, 5, 5, 5 ), 0, 0 );
add( txtSexo, gbc );
[Link]( false );
//**PANEL EXTENSIONES**//
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* $Id$
* Universidad de los Andes (Bogot - Colombia)
* Departamento de Ingeniera de Sistemas y Computacin
* Licenciado bajo el esquema Academic Free License version 2.1
*
* Proyecto Cupi2 ([Link]
* Ejercicio: n1_empleado
* Autor: Mario Snchez - 14/06/2005
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
package [Link];
import
import
import
import
import
import
import
import
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
/**
* Es el panel para las extensiones del ejemplo
*/
public class PanelExtensiones extends JPanel implements ActionListener
{
//----------------------------------------------------------------// Constantes
//----------------------------------------------------------------/**
* El comando para el botn 1
*/
private final String OPCION_1 = "opcion1";
/**
* El comando para el botn 2
*/
private final String OPCION_2 = "opcion2";
//----------------------------------------------------------------// Atributos
//----------------------------------------------------------------/**
* Es la referencia a la interfaz de la aplicacin
*/
private InterfazEmpleado interfazEmpleado;
//**PANEL SALARIO**//
/**~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* $Id$
* Universidad de los Andes (Bogot - Colombia)
* Departamento de Ingeniera de Sistemas y Computacin
* Licenciado bajo el esquema Academic Free License version 2.1
*
* Proyecto Cupi2 ([Link]
* Ejercicio: n1_empleado
* Autor: Mario Snchez - Jun 13, 2005
* Autor: Mario Snchez - Jun 13, 2005
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
package [Link];
import
import
import
import
import
[Link];
[Link];
[Link];
[Link];
[Link];
import
import
import
import
import
import
import
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
[Link];
/**
* Es el panel en el que se muestra y se modifica el salario del empleado
*/
public class PanelSalario extends JPanel implements ActionListener
{
//----------------------------------------------------------------// Constantes
//----------------------------------------------------------------/**
* Es el comando para el botn de modificar el salario
*/
private final static String BUT_MODIFICAR_SALARIO = "MODIFICAR SALARIO";
//----------------------------------------------------------------// Atributos
//----------------------------------------------------------------/**
* Es una referencia a la interfaz de la aplicacin
*/
[Link]( false );
}
//----------------------------------------------------------------// Mtodos
//----------------------------------------------------------------/**
* Este mtodo se llama cuando se presiona uno de los botones. <br>
* <b>post: </b> Se ejecut la accin correspondiente al botn presionado.
<br>
* @param evento El evento del click en el botn. evento != null.
*/
public void actionPerformed( ActionEvent evento )
{
String command = [Link]( );
if( [Link]( BUT_MODIFICAR_SALARIO ) )
{
[Link]( );
}
}
/**
* Actualiza el salario que se muestra. <br>
* <b>post: </b> Se cambi el salario mostrado. <br>
* @param salario.
*/
public void actualizarSalario( int salario )
{
DecimalFormat df = ( DecimalFormat )[Link]( );
[Link]( "$###,###.##" );
[Link]( [Link]( salario ) );
}
}