Red de conocimiento del abogados - Ley de patentes - Sistema integral de gestión de consultas de información estudiantil Programación JAVA

Sistema integral de gestión de consultas de información estudiantil Programación JAVA

prueba de paquete;

importar java.sql.*;

importar java.awt.*;

importar javax.swing. *;

importar java.awt.event.*;

importar javax.swing.border.*

importar javax.swing.JOptionPane

p>

importar javax.swing.border.*; p>

clase Agregar extiende Panel implementa ActionListener{

Conexión con

Declaración sql;

Botón b1,b2;

Campo de texto tf1,tf2,tf3,tf4,tf5,tf6

Caja baseBox,bv1,bv2; (){

prueba{

p>

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"

}

catch(ClassNotFoundException e){}

prueba {

con=DriverManager.getConnection("jdbc:odbc:data","",""

sql=con.createStatement();

}

catch(SQLException ee){}

setLayout(new BorderLayout());

Panel p1=nuevo Panel();

Panel p2=nuevo Panel();

tf1=nuevo TextField(16); p> tf2=nuevo Campo de Texto(16);

tf3= nuevo Campo de Texto(16);

tf4=nuevo Campo de Texto(16); TextField(16);

tf6=new TextField(16)

b1=new Button("Enter");

b1.setBackground(Color. verde);

b2=new Button("Restablecer" );

b2.setBackground(Color.green);

b1.addActionListener(this);

b2.addActionListener(this);

p1.add(b1);

p1.add(b2); =Box.createVerticalBox();

bv1.add( new Label("Número de estudiante"));

bv1.add(Box.createVerticalStrut(8)); >

bv1.add(nueva etiqueta("Nombre"));

bv1.add

(Box.createVerticalStrut(8));

bv1.add(new Label("Género"));

bv1.add(Box.createVerticalStrut(8)); p> p>

bv1.add(new Label("Profesional"));

bv1.add(Box.createVerticalStrut(8));

bv1.add( nueva etiqueta ("grado"));

bv1.add(Box.createVerticalStrut(8));

bv1.add(nueva etiqueta("nacimiento")); p>

bv1.add(Box.createVerticalStrut(8));

bv2=Box.createVerticalBox()

bv2.add(tf1);

bv2.add(Box.createVerticalStrut(8));

bv2.add(tf2

bv2.add(Box.createVerticalStrut(8)); p>

bv2.add(tf3);

bv2.add(Box.createVerticalStrut(8));

bv2.add(tf4); p> bv2.add(Box.createVerticalStrut(8));

bv2.add(tf5

bv2.add(Box.createVerticalStrut(8)); >

bv2.add(tf6);

bv2.add(Box.createVerticalStrut(8));

baseBox=Box.createHorizontalBox(); p> baseBox.add(bv1);

baseBox.add(Box.createHorizontalStrut(10));

baseBox.add(bv2); .add (baseBox);

add(p1,"Sur");

add(p2,"Centro");

p>

setBackground(Color.pink);

}

public void actionPerformed(ActionEvent e){

if (e.getSource()= =b1){

try{ insert();}

catch(SQLException ee){}

JOptionPane.showMessageDialog( this,"¡Los datos se han almacenado en la base de datos!", "Cuadro de diálogo emergente", JOptionPane.INFORMATION_MESSAGE

}

else if(e.getSource()==b2); ){

tf1 .setText(" ");

tf2.setText(" ");

tf3.setText(" ");

tf4.setText(" ");

tf5.setText(" "); p> tf6.setText(" ");

}

}

public void insert() lanza SQLException{

Cadena s1 ="'"+tf1.getText().trim()+"'";

Cadena s2="'"+tf2.getText().trim()+"'"; >

Cadena s3="'"+tf3.getText().trim()+"'"

Cadena s4="'"+tf4.getText().trim()+" '";

Cadena s5="'"+tf5.getText().trim()+"'";

Cadena s6="'"+tf6.getText() .trim()+"'";

String temp="INSERT INTO jesse VALUES ("+s1+","+s2+","+s3+","+s4+","+s5+", "+s6+")";

con=DriverManager.getConnection("jdbc:odbc:data","","");

sql.executeQuery(temp);

con.close();

}

}

clase Consulta extiende Panel implementa ActionListener{

Conexión con;

Declaración sql;

Campo de texto t1,t2,t3,t4,t5,t6

Botón b; baseBox,bv1,bv2;

int flag=0;

Consulta(){

prueba{

Class.forName(" sun.jdbc.odbc.JdbcOdbcDriver");

}

catch(ClassNotFoundException e){}

try{

con= DriverManager.getConnection("jdbc:odbc:data","","");

sql=con.createStatement()

}

captura (SQLException ee){}

setLayout(new BorderLayout());

b=new Button("Consulta"); .orange);

b.addActionListener(this);

t1=nuevo TextField(8);

t2=nuevo TextField(16);

/p>

t3=nuevo Campo de Texto(16);

t4=nuevo Campo de Texto(16);

t5=nuevo Campo de Texto(16); > t6=nuevo TextField(16);

t2.setEditable(falso);

t3.setEditable(falso);

t4.setEditable(falso)

t5.setEditable(false);

t6.setEditable(false

Panel p1=nuevo Panel(),p2=nuevo Panel(); ;

p1.add(new Label("Ingrese el número de estudiante a consultar"));

p1.add(t1); agregar (b);

bv1=Box.createVerticalBox();

bv1.add(new Label("Nombre")); ( Box.createVerticalStrut(8));

bv1.add(new Label("Género"));

bv1.add(Box.createVerticalStrut(8)); p >

bv1.add(new Label("Profesional"));

bv1.add(Box.createVerticalStrut(8));

bv1.add(new Label). ( "Calificación"));

bv1.add(Box.createVerticalStrut(8));

bv1.add(new Label("Nacimiento"));

bv1.add(Box.createVerticalStrut(8));

bv2=Box.createVerticalBox()

bv2.add(t2); > bv2.add(Box.createVerticalStrut(8));

bv2.add(t3

bv2.add(Box.createVerticalStrut(8));

bv2.add(t4);

bv2.add(Box.createVerticalStrut(8));

bv2.add(t5); bv2 .add(Box.createVerticalStrut(8));

bv2.add(t6

bv2.add(Box.createVerticalStrut(8)); p > baseBox=Box.createHorizontalBox();

baseBox.add(bv1

baseBox.add(Box.createHorizontalStrut(10)); baseBox .add(bv2);

p2.add(baseBox);

add(p1,"Norte");

dd(p2,"Centro");

setSize(300,250

setBackground(Color.rojo

}

); public void actionPerformed(ActionEvent e){

flag=0

try{query();}

catch(SQLException ee){}

}

public void query() lanza SQLException{

String num,nombre,sexo,asunto,grado,nacido

con=DriverManager; .getConnection("jdbc:odbc:data","","");

ResultSet rs=sql.executeQuery("SELECT * FROM jesse "); .next()){

num=rs.getString("número de estudiante");

nombre=rs.getString("nombre"); sex=rs.getString("género");

sujeto=rs.getString("principal");

grado=rs.getString("grado"); >

born=rs.getString("nacimiento");

if(num.equals(t1.getText().trim())){

t2.setText (nombre);

t3.setText(sexo);

t4.setText(sujeto);

t5.setText(grado);

t6.setText(nacido);

bandera=1;

descanso

}

}

con.close();

if(flag==0){t1.setText("No existe tal estudiante");}

}

}

clase Actualización extiende Panel implementa ActionListener{

Conexión con

Declaración sql

Botón b1,b2, b3;

Caja baseBox,bv1,bv2;

Campo de texto t1,t2,t3,t4,t5,t6

Actualizar(){

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}

catch(ClassNotFoundException e){}

intente{

con=DriverManager.getConnection("jdbc:odbc:data","","");

sql=con.createStatement();

}

catch(SQLException ee){}

setLayout(new BorderLayout()

b1=new Button("Comenzar a modificar");

b1.setBackground(Color.green

b2=new Button("Entrar); Modificar");

b2.setBackground(Color.amarillo);

b3=new Button("Restablecer");

b3.setBackground(Color . amarillo);

b1.addActionListener(este);

b2.addActionListener(este);

b3.addActionListener(este); p> t1=nuevo Campo de Texto(8);

t2=nuevo Campo de Texto(16);

t3=nuevo Campo de Texto(16); TextField(16);

t5=nuevo TextField(16);

t6=nuevo TextField(16);

Panel p1=nuevo Panel() , p2=new Panel(),p3=new Panel();

p1.add(new Label("Ingrese el número del estudiante cuya información desea modificar")); p1. add(t1);

p1.add(b1);

bv1=Box.createVerticalBox();

bv1.add(nueva etiqueta( "(Nuevo) Nombre"));

bv1.add(Box.createVerticalStrut(8));

bv1.add(new Label("(Nuevo)Género"))

bv1.add(Box.createVerticalStrut(8));

bv1.add(new Label("(Nuevo)Profesional")); bv1. add(Box.createVerticalStrut(8));

bv1.add(new Label("(Nuevo) Grado"));

bv1.add(Box.createVerticalStrut( 8) );

bv1.add(new Label("(Nuevo) Nacido")

bv1.add(Box.createVerticalStrut(8));

bv2=Box.createVerticalBox();

bv2.add(t2

bv2.add(Box.createVerticalStrut(8)); > bv2 .add(t3);

bv2.add(Box.createVerticalStrut(8));

bv2.add(t4);

bv2.add(Box.createVerticalStrut(8));

bv2.add(t5); (Box.createVerticalStrut(8));

bv2.add(t6

bv2.add(Box.createVerticalStrut(8)); =Box.createHorizontalBox();

baseBox.add(bv1);

baseBox.add(Box.createHorizontalStrut(10)); (bv2);

p2.add(baseBox);

p3.add(b2);

add(p1,"Norte");

add(p2,"Centro"

add(p3,"Sur"); > setSize(300,250);

setBackground(Color.cyan);

}

acción vacía públicaPerformed(ActionEvent e){

if(e.getSource()==b1){

try{

String num,nombre,sexo,tema,grado,nacido; DriverManager.getConnection("jdbc:odbc:data","","");

ResultSet rs=sql.executeQuery("SELECT * FROM jesse "); rs.next()){

num=rs.getString("número de estudiante");

nombre=rs.getString("nombre"); > sexo=rs.getString("género");

sujeto=rs.getString("mayor");

grado=rs.getString("grado"); p> p>

born=rs.getString("nacimiento");

if(num.equals(t1.getText().trim())){

t2. setText(nombre);

t3.setText(sexo);

t4.setText(sujeto);

t5.setText(grado); /p >

t6.setText(nacido);

descanso

}

}

con.close();

}

catch(SQLException ee){}

}

if(e.getSource()==b2){

try{update();}

catch(SQLException ee){}

}

if(e.getSource()==b3){

t2.setText(" ");

t3. setText(" ");

t4.setText(" ");

t5.setText(" ");

}

}

public void update() lanza SQLException{

String s1="'"+t1.getText( ).trim()+"'";

Cadena s2="'"+t2.getText().trim()+"'"; "+t3.getText().trim()+"'";

Cadena s4="'"+t4.getText().trim()+"'";

Cadena s5="'"+t5.getText().trim()+"'"

Cadena s6="'"+t6.getText().trim()+"'";

String temp="UPDATE jesse SET name="+s2+", género="+s3+", major="+s4+", grado="+s5+", nacimiento="+s6+" DONDE estudiar No.="+s1;

con=DriverManager.getConnection("jdbc:odbc:data","","");

sql.executeQuery(temp);

p>

con.close();

}

}

clase Eliminar extiende el Panel implementa ActionListener{

Conexión con

Declaración sql

TextField t1,t2,t3,t4,t5,t6

Botón b; > Caja baseBox, bv1, bv2;

Eliminar(){

intentar{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

}

catch(ClassNotFoundException e){}

try{

con=DriverManager.getConnection("jdbc:odbc:data "," ","");

sql=con.createStatement();

p>

}

catch(SQLException ee){}

setLayout(new BorderLayout());

b=new Button("Eliminar");

b.setBackground(Color.cian);

b.addActionListener(this);

t1=new TextField(8); >

t1.addActionListener(this);

t2=nuevo TextField(16);

t3=nuevo TextField(16); nuevo campo de texto(16);

t5=nuevo campo de texto(16);

t6=nuevo campo de texto(16);

t2.setEditable(falso);

t3.setEditable(falso);

t4.setEditable(falso);

t5.setEditable(falso); .setEditable(false);

Panel p1=new Panel(),p2=new Panel();

p1.add(new Label("Ingrese el número de estudiante que desea eliminar). " ));

p1.add(t1);

p1.add(b);

bv1=Box.createVerticalBox();

bv1.add(nueva Etiqueta("Nombre"));

bv1.add(Box.createVerticalStrut(8));

bv1.add(nueva Etiqueta( " Género"));

bv1.add(Box.createVerticalStrut(8));

bv1.add(new Label("Profesional")); p > bv1.add(Box.createVerticalStrut(8));

bv1.add(new Label("Calificación"));

bv1.add(Box.createVerticalStrut(8)); ) );

bv1.add(new Label("nacimiento"));

bv1.add(Box.createVerticalStrut(8)); = Box.createVerticalBox();

bv2.add(t2

bv2.add(Box.createVerticalStrut(8)); ( t3);

bv2.add(Box.createVerticalStrut(8));

bv2.add(t4);

bv2.add(Box. createVerticalStrut (8));

bv2.add(t5);

bv2.add(Box.createVertic);

alStrut(8));

bv2.add(t6);

bv2.add(Box.createVerticalStrut(8));

baseBox=Box. crearHorizontalBox();

baseBox.add(bv1);

baseBox.add(Box.createHorizontalStrut(10));

baseBox.add(bv2)

p2.add(baseBox);

add(p1,"Norte");

add(p2,"Centro"); >

setSize(300,250);

setBackground(Color.green);

}

acción vacía públicaPerformed(ActionEvent e){

if(e.getSource()==t1){

intente{delete();}

catch(SQLException ee){}

}

else if(e.getSource()==b){

int n=JOptionPane.showConfirmDialog(this, "¿Está seguro de que desea eliminar la identificación del estudiante y todo información?" ,"OK",JOptionPane.YES_NO_OPTION);

if(n==JOptionPane.YES_OPTION){

intentar{

String s1=" '"+ t1.getText().trim()+"'";

String temp="BORRAR DE jesse WHERE número de estudiante="+s1;

con=DriverManager. getConnection(" jdbc:odbc:data","","");

sql.executeUpdate(temp

con.close(); > }

catch(SQLException ee){}

}

else if(n==JOptionPane.NO_OPTION){}

}

}

p>

}

public void eliminar() lanza SQLException{

Cadena num,nombre,sexo ,subject,grade,born;

con= DriverManager.getConnection("jdbc:odbc:data","","");

ResultSet rs=sql.executeQuery(" SELECCIONAR * DE jesse ");

while( rs.next()){

num=rs.getStri

ng("número de estudiante");

nombre=rs.getString("nombre");

sexo=rs.getString("género"); > sujeto=rs.getString("mayor");

grado=rs.getString("grado");

nacido=rs.getString("nacimiento"); p> p>

if(num.equals(t1.getText().trim())){

t2.setText(nombre);

t3.setText( sexo)

t4.setText(sujeto);

t5.setText(grado);

t6.setText(nacido); p> romper;

}

}

con.close(); /p >

clase pública tyj extiende Frame implementa ActionListener{

MenuBar bar=null

Menú menu1,menu2,menu3,menu4,menu5; > Elemento de menú elemento1, elemento2, elemento3, elemento4, elemento5;

Agregar zengjia

Consultar chaxun

Actualizar gengxin

Eliminar; shanchu;

tyj(){

super("Bienvenido al sistema de gestión de información de estudiantes");

zengjia=new Add(); >

chaxun=nueva consulta();

gengxin=nueva actualización();

shanchu=nueva eliminación()

bar=nueva barra de menú; ();

menu1=nuevo Menú("Ingreso de Información");

menu2=nuevo Menú("Consulta de Información"); ("Actualización de información");

menu4=new Menu("Eliminar información");

menu5=new Menu("Salir del sistema"); item1=new MenuItem("Entrar");

item2=new MenuItem("Consulta"

item3=new MenuItem("Actualizar"); > item4= new MenuItem("Eliminar");

item5=new MenuItem("Salir"); .add( elemento2);

menu3.add(elemento3);

menu4.add(elemento4);

menu5.add(elemento5); p>

bar.add(menú1);

/p>

bar.add(menú2);

bar.add(menú3);

bar.add(menú4); agregar(menú5);

setMenuBar(bar);

item1.addActionListener(este);

item2.addActionListener(este); p> item3.addActionListener(this);

item4.addActionListener(this);

item5.addActionListener(this);

Etiqueta etiqueta=nueva Etiqueta( "Bienvenido al sistema de gestión de información de estudiantes",Label.CENTER);

String s=" "

Font f=new Font(s,Font.BOLD,22);

etiqueta.setFont(f);

etiqueta.setBackground(Color.GREEN

etiqueta.setForeground(Color.BLUE);

add(label,"Centro");

setVisible(true);

setSize(320,300

}

public void actionPerformed(ActionEvent e){

if(e.getSource()==item1){

removeAll(); " Centro");

validar();

}

if(e.getSource()==item2){

eliminarTodo ();

add(chaxun,"Centro");

validar();

}

if(e. getSource ()==item3){

removeAll();

add(gengxin,"Centro");

}

if(e.getSource()==item4){

removeAll()

add(shanchu,"Centro");

validar();

}

if(e.getSource()==item5){

removeAll(); /p>

p>

setBackground(Color.GREEN);

Label label=new Label("Bienvenido al Sistema de gestión de información estudiantil",Label.CENTER);

Cadena s=" ";

Fuente f=nueva Fuente(s,Font.BOLD,22);

/p>

label.setFont(f);

label.setForeground(Color.BLUE

add(label,"Centro"); p> validar();

}

}

public static void main(String[] args)

{

tyj jesse=nuevo tyj();

jesse.setVisible(true);

jesse.addWindowListener(nuevo WindowAdapter(){

público void windowClosing(WindowEvent e){

System.exit(0

}

}); >

}