Você está na página 1de 7

http://www.hispanosnet.

com/videotutoriales/java/crear_usuario_contrasena_ja
va.html
import java.util.*;
import java.sql.*;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;

public class transito


{
Connection conec;
Statement est;
ResultSet res;
Frame pant;
Label et1,et2,et3,et4,et5,et6,et7,et8,et9;
TextField text1,text2,text3,text4,text5,text6,text7,text8,text9;
Button ingresar,consultar,limpiar;

String
num_inf,cod_inf,tarj_pro,fecha_inf,dir,ciudad,placa_ag,placa_ve,docu_infra;

public void construir()


{
pant=new Frame("INFRACCIONES DE TRANSITO");
pant.setLayout(new FlowLayout());

pant.setSize(8000,200);
pant.setVisible(true);
pant.addWindowListener(new WindowAdapter(){public void
windowClosing(WindowEvent evt){System.exit(0);}});

et1=new Label("NUMERO DE INFRACCION");


et2=new Label("FECHA DE INFRACCION");
et3=new Label("CIUDAD DE SUCESOS");
et4=new Label("DIRECCION DE SUCESOS");
et5=new Label("PLACA DEL AGENTE");
et6=new Label("CODIGO DE INFRACCION");
et7=new Label("PLACA VEHICULO");
et8=new Label("TARJETA PROPIEDAD");
et9=new Label("DOCUMENTO INFRACTOR");

text1=new TextField();
text2=new TextField();
text3=new TextField();
text4=new TextField();
text5=new TextField();
text6=new TextField();
text7=new TextField();
text8=new TextField();
text9=new TextField();

ingresar=new Button("INGRESAR INFRACCION");

consultar=new Button("CONSULTAR INFRACCION");


limpiar=new Button("LIMPIAR REGISTRO");

pant.add(et1);
pant.add(text1);
pant.add(et2);
pant.add(text2);
pant.add(et3);
pant.add(text3);
pant.add(et4);
pant.add(text4);
pant.add(et5);
pant.add(text5);
pant.add(et6);
pant.add(text6);
pant.add(et7);
pant.add(text7);
pant.add(et8);
pant.add(text8);
pant.add(et9);
pant.add(text9);
pant.add(ingresar);
ingresar.addActionListener(new ActionListener (){public void
actionPerformed(ActionEvent e) {insertar();}});
pant.add(consultar);
ingresar.addActionListener(new ActionListener (){public void
actionPerformed(ActionEvent e) {consulta();}});

pant.add(limpiar);
ingresar.addActionListener(new ActionListener (){public void
actionPerformed(ActionEvent e) {limpio();}});
}

public void insertar()


{
num_inf=text1.getText();
fecha_inf=text2.getText();
ciudad=text3.getText();
dir=text4.getText();
placa_ag=text5.getText();
cod_inf=text6.getText();
placa_ve=text7.getText();
tarj_pro=text8.getText();
docu_infra=text9.getText();

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
conec=DriverManager.getConnection("jdbc:odbc:transito_infraccion");
est=conec.createStatement();
est.executeUpdate("insert into registro_infracciones
values(""+num_inf+"",""+cod_inf+"",""+tarj_pro+"",""+fecha_inf+"",""+dir_c
iudad+"",""+placa_ag+"",""+placa_ve+"",""+docu_infra+"")");
}
catch(ClassNotFoundExeption e)

{
e.printStacktrace();
}
catch(SQLExeption e)
{
e.printStacktrace();
}
JOptionPane.showMessageDialog(null,"informacion almacenada");
text1.setText("");
text2.setText("");
text3.setText("");
text4.setText("");
text5.setText("");
text6.setText("");
text7.setText("");
text8.setText("");
text9.setText("");
}

public void consulta()


{
docu_infra=text9.getText();

}
public void limpio()

{
text1.setText("");
text2.setText("");
text3.setText("");
text4.setText("");
text5.setText("");
text6.setText("");
text7.setText("");
text8.setText("");
text9.setText("");

public static void main(String[] args)


{
transito hd=new transito();
hd.construir();

}
}

comparendo

Você também pode gostar