Professional Documents
Culture Documents
NOT NULL , nombre VARCHAR(45) NOT NULL , apellido_p VARCHAR(20) NOT NULL , apellido_m VARCHAR(20) NOT NULL , saldo Double precision NOT NULL , sucursal_id VARCHAR(8) NOT NULL , PRIMARY KEY (no_cuenta)); ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS Movimientos ( folio INT NOT NULL auto_increment unique, fecha DATE NOT NULL , deposito Double precision NOT NULL , retiro Double precision NOT NULL , cantidad Double precision NOT NULL , clientes_no_cuenta VARCHAR(15) NOT NULL , PRIMARY KEY (folio)); ENGINE = InnoDB; CREATE TABLE IF NOT EXISTS Sucursal ( id VARCHAR(8) NOT NULL , nombre VARCHAR(50) NOT NULL , PRIMARY KEY (id)); ENGINE = InnoDB;
insert into clientes values ('0100204050','Edna Isamar','Hernandez','Hernandez','1500','01'), ('0100204750','Adalyd','Castillo','Santander','15000','01'), ('0100204850','Dayra','Garcia','Marquez','5000','01'), ('0100204950','Yolanda','Zuiga','Mera','150000','01'), ('0100205050','Adalyd','Castillo','Santander','15000','01');
drop table surcursal; insert into sucursal values ('01','Actopan'),('02','Pachuca'); select * from clientes; PROGRAMACION PARA LA APLICACIN /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package bantec; import javax.swing.JOptionPane; public class Bantec {
double de,re;
int op =0;
JOptionPane.showMessageDialog(null," BIENVENIDO","Bancoin",JOptionPane.PLAIN_MESSAGE);
ax=JOptionPane.showInputDialog(null, "1.- Consultar \n 2.- Depositar \n 3.- Retirar \n 4.Salir"); //if(ax!=null && auxi.isNum(ax)){
op = Integer.parseInt(ax);
switch (op) {
case 1:
JOptionPane.showMessageDialog(null,"Consultar","Bancoin",JOptionPane.PLAIN_MESSAGE); nuevo.Cuenta(s);
//System.exit(0);
break; case 2:
JOptionPane.showMessageDialog(null,"Desea realizar un deposito?","BANTEC",JOptionPane.PLAIN_MESSAGE); d= JOptionPane.showInputDialog(null,"Deposito:","BANTEC",JOptionPane.PLAIN_MESSAGE); de=Double.parseDouble(d); nuevo.Deposito(de); JOptionPane.showMessageDialog(null,"Deposito realizado con exito!","Bancoin",JOptionPane.PLAIN_MESSAGE); nuevo.Cuenta(s); //System.exit(0); break; case 3: JOptionPane.showMessageDialog(null,"Accion: Realizar un retiro?","Bancoin",JOptionPane.PLAIN_MESSAGE);
nuevo.Cuenta(s);
//System.exit(0); break;
case 4:
JOptionPane.showMessageDialog(null,"SALIR","BANTEC",JOptionPane.PLAIN_MESSAGE);
//System.exit(0);
break;
default:
break;
// System.exit(0); }
nuevo.Cuenta(s);
} }
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
package bantec;
import java.sql.SQLException;
import java.util.logging.Level;
/** **/
String nc;
this.nc=t;
this.nc=cuenta;
try { Inicio();
if (this.datos.next()){
System.out.println("Numero cuenta: "+this.datos.getString("no_cuenta")+ "\n Nombre: "+this.datos.getString("nombre")+ "\n Apellido paterno: "+this.datos.getString("apellido_p")+ "\n Apellido materno: "+this.datos.getString("apellido_m")+ "\n Saldo: "+this.datos.getString("saldo")+ "\n Sucursal: "+this.datos.getString("sucursal_id"));
JOptionPane.showMessageDialog(null,"Numero cuenta: "+this.datos.getString("no_cuenta")+ "\n Nombre: "+this.datos.getString("nombre")+ this.datos.getString("apellido_p")+ this.datos.getString("apellido_m")+ "\n Saldo: "+this.datos.getString("saldo")+ "\n Sucursal: "+this.datos.getString("sucursal_id"),"BANTEC",JOptionPane.PLAIN_MESSAGE); } } catch (ClassNotFoundException ex) { Logger.getLogger(Servicio.class.getName()).log(Level.SEVERE, null, ex); } catch (SQLException ex) {
Logger.getLogger(Servicio.class.getName()).log(Level.SEVERE, null, ex); } } public void Deposito(double dp) { double gs; try { Inicio(); if (this.datos.next()){ gs=this.datos.getDouble("saldo")+dp; this.consulta = this.conn.prepareStatement("UPDATE clientes set saldo="+gs+"where no_cuenta="+nc);
this.consulta.executeUpdate();
String s = "saldo";
try {
Inicio();
if (this.datos.next()){
sal=this.datos.getDouble("saldo");
if (rt<=sal) {
ret=this.datos.getDouble("saldo")-rt;
this.consulta.executeUpdate();
} }
if("04001".equals(nc.substring(0, 5)))
this.datos = this.consulta.executeQuery();
} if("01001".equals(nc.substring(0, 5))) {
this.datos = this.consulta.executeQuery();
} if("04001".equals(nc.substring(0, 5))) {
this.datos = this.consulta.executeQuery(); } } }