You are on page 1of 38

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I PROYECTO FINAL 1.

INTRODUCCIN

GRUPO: 1

En la actualidad existen muchas empresas las cuales se manejan a travs de las redes de computadoras para poder enviarse informacin solicitada unas a otras, como la base de datos de varios clientes. Adems en esta poca es muy utilizado la tecnologa mvil para usarlo de diferentes maneras y con varias aplicaciones por ende mucha informacin podra ser enviada o receptada desde un telfono mvil Como un plus para el proyecto presentado se ver la realizacin del envo y recepcin de la informacin de los diferentes de una computadora hacia un celular y viceversa en donde se aplicar la comunicacin mediante redes. 2. MARCO TERICO WAMP Es un entorno de desarrollo web de Windows. Que permite crear aplicaciones web con Apache2, PHP y base de datos MySQL. Adems PhpMyAdmin permite fcilmente administrar la base de datos. El WAMP proporciona lenguajes de programacin para el desarrollo de aplicaciones web. Para simplificar la tarea de instalar Apache + PHP + MySQL en Windows, existen los llamados paquetes WAMP que instalan y configuran automticamente dichas aplicaciones para Windows y que proporcionan: Servidor Web Apache Base de datos MySQL Lenguaje de programacin PHP Accesos directos para el arranque y la parada de los servicios Gestores web para MySQL, configurar el servidor Apache Otros servicios De estos paquetes podemos destacar: Easyphp XAMPP AppServ WampServer Un servidor WAMP nos permite instalar aplicaciones web accesibles desde nuestra red local. Si abrimos el puerto correspondiente en el router podemos acceder desde Internet. Un servidor WAMP es la base donde podemos instalar infinidad de aplicaciones como: Gestores de contenidos: Joomla, Drupal. Plataformas educativas: Moodle, Claroline, Dokeos, etc Blogs: WordPress, Serendipity, etc Wikis: DokuWiki, TikiWiki , MediaWiki, etc Foros: phpBB, myBB, etc Galeras de imgenes: Coppermine, Gallery, etc

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I APPINVENTOR

GRUPO: 1

Fue creada a mediados del 2009 el profesor Harold Abelson del MIT, la aplicacin se puso a disposicin del pblico el 12 de julio de 2010 y est dirigida a personas que no estn familiarizadas con la programacin informtica. Es una aplicacin creada por google para que las personas con inters se puedan crear su propia aplicacin mvil de software, ya sea este para su hogar, empresa u otros intereses, esta aplicacin se usa con el sistema operativo Android. El usuario se puede crear la aplicacin con herramientas bsicas, en donde se puede ir enlazando una serie de bloques para crear la aplicacin. El sistema de AppInventor es gratuito y se puede descargar fcilmente de la web, para lo cual gracias a su simplicidad de uso se podran generar nuevas aplicaciones para la tecnologa Android El editor de bloques de la aplicacin utiliza la librera Open Blocks de Java para crear un lenguaje visual a partir de bloques. Estas libreras estn distribuidas por Massachusetts Institute of Technology ( MIT ) bajo su licencia libre (MIT License). El compilador que traduce el lenguaje visual de los bloques para la aplicacin en Android utiliza Kawa como lenguaje de programacin, distribuido como parte del sistema operativo GNU de la Free Software Foundation NETBEANS El IDE NetBeans es un entorno de desarrollo integrado, una herramienta para programadores pensada para escribir, compilar, depurar y ejecutar programas. Est escrito en Java, pero puede servir para cualquier otro lenguaje de programacin. El NetBeans IDE es un IDE de cdigo abierto escrito completamente en Java usando la plataforma NetBeans. El NetBeans IDE soporta el desarrollo de todos los tipos de aplicacin Java (J2SE, web, EJB y aplicaciones mviles). Entre sus caractersticas se encuentra un sistema de proyectos basado en Ant, control de versiones y refactoring. NetBeans es un entorno de desarrollo integrado libre, hecho principalmente para el lenguaje de programacin Java, NetBeans IDE1 es un producto libre y gratuito sin restricciones de uso. La plataforma NetBeans permite que las aplicaciones sean desarrolladas a partir de un conjunto de componentes de software llamados mdulos. Un mdulo es un archivo Java que contiene clases de java escritas para interactuar con las APIs de NetBeans y un archivo especial (manifest file) que lo identifica como mdulo. Las aplicaciones construidas a partir de mdulos pueden ser extendidas agregndole nuevos mdulos. Debido a que los mdulos pueden ser desarrollados independientemente, las aplicaciones basadas en la plataforma NetBeans pueden ser extendidas fcilmente por otros desarrolladores de software. La plataforma ofrece servicios comunes a las aplicaciones de escritorio, permitindole al desarrollador enfocarse en la lgica especfica de su aplicacin. Entre las caractersticas de la plataforma estn: Administracin de las interfaces de usuario (ej. mens y barras de herramientas) Administracin de las configuraciones del usuario

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

Administracin del almacenamiento (guardando y cargando cualquier tipo de dato) Administracin de ventanas Framework basado en asistentes (dilogos paso a paso)

BLUETOOTH Bluetooth es una tecnologa de comunicacin inalmbrica de corto alcance que se utiliza para comunicarse entre dispositivos a una distancia aproximada de 8 metros. Los dispositivos Bluetooth ms comunes son los auriculares para realizar llamadas o escuchar msica, los equipos de manos libres para automviles y otros dispositivos porttiles, incluidas las computadoras porttiles. Bluetooth es una especificacin industrial para Redes Inalmbricas de rea Personal (WPAN) que posibilita la transmisin de voz y datos entre diferentes dispositivos mediante un enlace por radiofrecuencia en la banda ISM de los 2,4 GHz. Los principales objetivos que se pretenden conseguir con esta norma son: Facilitar las comunicaciones entre equipos mviles y fijos. Eliminar los cables y conectores entre stos. Ofrecer la posibilidad de crear pequeas redes inalmbricas y facilitar la sincronizacin de datos entre equipos personales. 3. DESARROLLO En la siguiente figura se ver el esquema que se realiza para este proyecto en el cual se comunicarn los dos servidores mutuamente en donde el servidor A tiene la informacin del cliente y el servidor B la informacin de la cuenta bancaria del mismo, adems se podr enviar la informacin solicitada hacia un celular en donde se ver el tiempo transcurrido, el monto y algunos datos del cliente.

Figura1. Esquema del Proyecto

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

Para que los dos servidores se comuniquen entre s se ha hecho mediante un cable de red y con el servidor WAMP, para as poder conocer los IP de cada uno. En cuanto la conexin entre el un servidor y el celular con tecnologa Android se ha realizado por va Bluetooth en donde se conocer el MAC de cada una.

Figura2. Conexin entre hosts y celular Cada servidor tendr distinta informacin de un mismo cliente para lo que se ha hecho un programa en NetBeans - JAVA, para que nos permita ingresar, editar y visualizar los datos presentes en la Figura3. Para la aplicacin en el celular se ha hecho en AppInventor en donde nos permite visualizar los datos del cliente, el dbito bancario y el tiempo comprado.

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

FIGURA3. Clases y Atributos del servidor y cliente INSTALAR EL SERVIDOR WAMP Comenzamos la instalacin en un sistema Windows 7 SP1. Descargamos WampServer de wampserver.com.

El firewall de Windows nos avisar para permitir o denegar el acceso del programa a la red. Nosotros lo permitimos.

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

WampServer nos preguntar el servidor SMTP y la direccin de correo usada para la funcin mail(). Nosotros lo dejamos por defecto.

Una vez finalizada la instalacin abrimos el navegador web y comprobamos el acceso local al servidor entrando en http:// localhost/

Abajo tenemos un men de herramientas con un acceso directo a phpmyadmin y a la funcin phpinfo() de php.

Abrimos phpinfo() para comprobar que php funciona correctamente.

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I Configuracin del servidor WAMP

GRUPO: 1

En la barra de tareas de Windows tendremos un nuevo icono con el smbolo de WAMP. Su color nos indica el estado del servidor. Cuando se hace click saldr un men contextual desde el que podemos parar o reiniciar los servicios.

Desde el men de administracin de WampServer, empezando de arriba hacia abajo, podremos saber cada una de las opciones: Localhost: mediante la opcin localhost accedemos con el navegador a los contenidos del servidor web, tambin podemos visualizarlo mediante la direccin IP 127.0.0.1 phpMyAdmin: Es un administrador de bases de datos. Se accede de la siguiente forma http://localhost/phpmyadmin. directorio www: En esta carpeta es donde debemos copiar las aplicaciones que deseemos instalar. Apache: Sirve para acceder a la configuracin de Apache. PHP: Sirve para acceder a la configuracin de PHP. MySQL: Sirve para acceder a la configuracin de MySQL. Iniciar los servicios: permite iniciar Apache y MySQL. Detener los servicios: permite detener Apache y MySQL Reiniciar los servicios: permite Reiniciar Apache y MySQL, es til si hemos realizado alguna modificacin en la configuracin y queremos aplicar los cambios.

Desde el men de configuracin de Apache, podemos acceder a diferentes opciones:

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

Versin: permite elegir la versin de Apache. Podemos tener instaladas varias versiones y activar la versin que nos interese en un momento dado. Esto es til si alguna aplicacin necesita versiones antiguas para funcionar, pero habitualmente trabajaremos con la ltima versin de Apache. Service: permite iniciar o detener el servicio. Tambin permite instalar o desinstalar Apache como servicio del sistema Mdulos de Apache: permite activar o desactivar los mdulos de Apache sin necesidad de editar el archivo de configuracin httpd.conf. Directorios Alias: permite alias en Apache sin necesidad de editar el archivo de configuracin httpd.conf. httpd.conf: permite editar el archivo de configuracin httpd.conf. Si se hace algn cambio en la configuracin, hay que reiniciar Apache para que los cambios tomen efecto. Apache error log: permite visualizar el archivo de registro de errores de Apache. Resulta til para investigar las causas cuando algo no funciona. Apache access log: permite visualizar las peticiones de pginas que realizan los usuarios.

Desde el men de configuracin de PHP, podemos acceder a diferentes opciones: Versin: permite elegir la versin de PHP. Podemos tener instaladas varias versiones y activar la versin que nos interese en un momento dado. Esto es til si alguna aplicacin necesita versiones antiguas para funcionar, pero habitualmente trabajaremos con la ltima versin de PHP. Configuracin de PHP: permite activar o desactivar los parmetros ms usuales de la configuracin de PHP, sin necesidad de editar el archivo de configuracin php.ini. Extensiones de PHP: permite activar o desactivar las extensiones de PHP sin necesidad de editar el archivo de configuracin php.ini php.ini: permite editar el archivo de configuracin php.ini. Si se hace algn cambio en la configuracin, hay que reiniciar Apache para que los cambios tomen efecto. PHP error log: permite visualizar el archivo de registro de errores de PHP. til para investigar las causas cuando algo no funciona.

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

Desde el men de configuracin de MySQL, podemos acceder a diferentes opciones: Versin: permite elegir la versin de MySQL. Podemos tener instaladas varias versiones y activar la versin que nos interese en un momento dado. Esto es til si alguna aplicacin necesita versiones antiguas para funcionar, pero habitualmente trabajaremos con la ltima versin de MySQL. Service: permite iniciar o detener el servicio. Tambin permite instalar o desinstalar Apache como servicio del sistema. Consola de MySQL: abre el cliente de mysql en modo texto. Es necesario conocer el lenguaje SQL para utilizarlo. my.ini: permite editar el archivo de configuracin my.ini. Para hacer un uso normal, no es necesario realizar ninguna modificacin en este archivo. MySQL log: permite visualizar el archivo de registro de MySQL. til para investigar las causas cuando algo no funciona. COMO CREAR LA BASE DE DATOS EN SERVIDOR WAMP Lo que se ver en las siguientes figuras ser para la creacin de base de datos para el servidor A ya que para el servidor B se realizarn los mismos pasos sino que con diferentes variables. 1. Se Ingres a http://localhost/phpmyadmin/ que corresponde al servidor WAMP del primer servidor en este caso el servidor A el cual va a contener en su base de datos el numero de cedula, nombres, apellidos, direccin, placas, modelo, ao y color

2. Se ha creado la base de datos servidor_a :

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

3. Se ha creado la tabla datos_servidora, el cual va a contener todas las variables ya mencionadas (numero de cedula, nombres, apellidos, direccin, placas, modelo, ao y color)

4. Se le asignar los nombres a cada columna

10

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

5. Le asignamos el tipo de variable a cada una:

6. Definimos la longitud de cada variable:

11

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

7. En la primera variable id_clt2 la de finimos como la variable principal para esta base de datos modificando el ndice y el autoincremento(A_I).

8. Una vez realizado todos los pasos anteriormente vistos damos click en guardar.

12

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

9. Comprobamos que se ha creado la base de datos con lo cual seleccionamos a la izquierda la base de datos creada dato_servidora, y luego le damos click en Estructura para ver nuestra tabla de dicha base de datos:

13

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

PROGRAMA NETBEANS APLICACIN JAVA PARA LOS SERVIDORES A Y B Para el desarrollo de la aplicacin utilizamos NetBeans 7.2.1

Creamos un Nuevo Proyecto:

Creamos 2 clases las cuales se van a encargar de comunicarse con los servidores A y B, es decir con las bases de datos MySQL creadas anteriormente. A continuacin se presenta la clase encargada de enlazar los datos del servidor A, la clase tiene por nombre ConexionServerA, la cual como principal caracterstica debe tener la IP del servidor en el cual se ha alojado la base de datos servidor_a anteriormente creada con WAMP:

14

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

De igual manera para enlazarme con el servidor B tenemos la siguiente clase que es ConexionServerB, la cual de igual forma contiene la IP donde se ingreso la base de datos servidor_b creada en WAMP:

Por ltimo para la interfaz grfica con los usuarios de los servidores hemos creado un formulario java, en el cual podemos ingresar los clientes, editar sus datos, buscar los clientes ya ingresados y visualizar los datos de todos los clientes registrados en nuestras bases de datos.

15

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

Por los requerimientos del docente mediante el servidor A se ingresa solamente la cdula, nombres, apellidos, direccin (datos de cliente), la placa, modelo, ao y color (datos del vehculo). Tambin desde el servidor A establecemos la comunicacin con el dispositivo inalmbrico, con lo cual hemos creado un botn en donde habilitamos dicha conexin Bluetooth. Para crear la tabla en donde se ingresan los datos se seleccionar las diferentes opciones para el programa. Como se observa en esta figura usando los distintos bloques, podemos obtener como se ver nuestra pantalla del servidor cuando este arranque.

El cdigo fuente de dicho formulario contiene las clases necesarias para la comunicacin con los dos servidores A y B, dado lo extenso del cdigo lo hemos dejado como Anexo # 1 al final de este documento, lo importante de este formulario es que enlaza los datos de ambos servidores correspondientes a cada cliente, y con la comunicacin Bluetooth permite que un usuario mediante un dispositivo inalmbrico acceda a sus datos mediante su cedula y a su vez iniciar el servicio tarifado por tiempo, el cual cada que se acceda a este servicio debitara automticamente el saldo de cada cliente y se actualizar en los servidores. DESCRIPCION Y FUNCIONAMIENTO

16

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I Para ingresar un usuario le damos click en el botn Nuevo:

GRUPO: 1

A continuacin ingresamos todos los datos correspondientes al cliente y presionamos Guardar:

Por ltimo se ver la visualizacin de los datos creado tanto en el servidor A, como en el servidor B.

17

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

APPINVENTOR 1. Se ingres a http://appinventor.mit.edu/ en donde se podr escoger diferentes opciones, para nuestro caso se escoger Invent el cual nos sirve para crear nuevas aplicaciones para el celular.

2. Se seleccionar las diferentes herramientas que se necesita para la aplicacin que se ver en el celular como: label, text, button, etc.

18

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

3.

La pantalla que se ver en la aplicacin celular es la siguiente la cual hay que descargarse haciendo click en Open the Blocks Editor.

Para la programacin de esta aplicacin abrimos el editor de bloques y realizamos las siguientes instrucciones.

19

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

Una vez concluida la programacin de la interfaz grfica y la del editor de bloques procedemos a generar el archivo .apk, el cual posteriormente se instalar en el mvil con sistema operativo Android. Para realizar esta accin presionamos en Package to Phone.

20

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

Una vez generado el archivo .apk lo instalamos en el mvil y tendremos la aplicacin siguiente:

21

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

A continuacin se presenta la interfaz de la aplicacin en el cual para conectarnos al servidor presionamos Conectar Servidor, al hacer esto establecemos la conexin Bluetooth con el servidor A:

Una vez conectados al servidor ingresamos un nmero de cdula registrado en nuestros servidores:

22

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

Ahora presionamos Enviar CI y esperamos a que el servidor nos devuelva nuestra informacin:

23

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I

GRUPO: 1

Como podemos observar la aplicacin nos permite visualizar nuestra informacin, a continuacin podemos presionar Debitar Monto con lo que accederemos a tiempo tarifado. Una vez presionado dicho botn comenzar a correr un tiempo ya establecido descendentemente hasta llegar a 00:00; al mismo tiempo me debitar automticamente 2 dlares del monto de mi cuenta:

Una vez concluido el tiempo se activara una alarma, y al mismo tiempo un mensaje de advertencia. Para volver acceder al tiempo tarifado podemos presionar nuevamente Debitar Monto o presionaremos Reset, si queremos ingresar con otro usuario.

24

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I 4. CONCLUSIONES

GRUPO: 1

Al realizar la conexin de los servidores de datos A y B se pudo observar la interaccin de los mismos mediante su respectivas aplicaciones JAVA, adems se ha observado que desde los dos servidores podemos visualizar todos los datos de los clientes con la restriccin que solo se pueden modificar o ingresar las variables que estn asignadas para dichos servidores; para el caso del servidor A los datos del cliente y vehculo y para el servidor B la informacin de su cuenta bancaria. El cliente puede acceder a sus datos por medio de una aplicacin de celular, en dicha aplicacin ingresamos el nmero de cdula respectivo y el servidor A nos responde con nuestros datos para que tengamos conocimiento de nuestro estado bancario y tener acceso al servicio por tiempo tarifado que se encuentra en dicha aplicacin; todo este proceso de comunicacin se realiza por Bluetooth. Realizamos la aplicacin del celular en AppInventor, el cual es un programador grafico mediante internet, para celulares que tengan un sistema operativo Android; as tambin se hizo uso java para elaborar las interfaces de los servidores es decir sus ventanas, siendo esta programacin solo la eleccin de herramientas y libreras para componer dicha interfaz grfica, siendo una de las principales herramientas la librera mysql-connector-java-5.1.16-bin.jar que es el conector entre JAVA y la base de datos MySQL del servidor WAMP. 5. BIBLIOGRAFA [1]http://beta.appinventor.mit.edu/ [2] http://www.wampserver.com/ [3]http://www.trucoteca.com/trucoswindows/Windows2003Server/configuracionbasica-del-sitio-web 1041.html [4]http://www.herramientasparapymes.com/wampserver-5 [5]http://es.wikipedia.org/wiki/WAMP

25

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I ANEXOS ANEXO I SERVIDOR A
package Formularios; import BaseDatos.ConexionServerB; import BaseDatos.ConexionServerA; import giovynet.serial.Baud; import giovynet.serial.Com; import giovynet.serial.Parameters; import java.awt.Color; import java.awt.ComponentOrientation; import java.sql.*; import java.util.ResourceBundle; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; public class Clientes extends javax.swing.JFrame { DefaultTableModel modelo; /** Creates new form Clientes */ public String montostring=""; public String clt=""; public int montoentero; public String cedulastring=""; public String numstring=""; public String bancostring=""; public Clientes() { initComponents(); CargarTablaClientes(""); inhabilitar(); } void CargarTablaClientes(String valor) { String[] titulos = {"ID", "Cdula", "Nombres", "Apellidos", "Direccin", "Placa", "Modelo", "Ao", "Color", "Cedula", "Numero Cuenta", "Monto", "Banco"}; String[] registro = new String[13]; String sSQL = ""; String sSQL2 = ""; modelo = new DefaultTableModel(null, titulos); //Conectar con el servidor A ConexionServerA mysql = new ConexionServerA(); Connection cn = mysql.Conectar(); //Conectar con el servidor B ConexionServerB mysql2 = new ConexionServerB(); Connection cn2 = mysql2.Conectar(); //Base de Datos Servidor A sSQL = "SELECT id_clt2, cedula2, nombres, apellidos, direccion, placa, modelo, ao, color FROM datos_servidora "+ "WHERE CONCAT(cedula2, ' ',nombres, ' ',apellidos, ' ',direccion, ' ',placa, ' ',modelo, ' ',ao, ' ',color) LIKE '%"+valor+"%'"; //Base de Datos Servidor B sSQL2 = "SELECT id_clt, cedula, num_cuenta, monto, banco FROM datos_servidorb " + "WHERE CONCAT(cedula, ' ',num_cuenta, ' ',monto, ' ',banco) LIKE '%"+valor+"%'"; try { //Servidor A Statement st = cn.createStatement(); ResultSet rs = st.executeQuery(sSQL); //Servidor B

GRUPO: 1

Statement st2 = cn2.createStatement(); ResultSet rs2 = st2.executeQuery(sSQL2); while(rs.next() && rs2.next()) { registro[0] = rs.getString("id_clt2"); registro[1] = rs.getString("cedula2"); registro[2] = rs.getString("nombres"); registro[3] = rs.getString("apellidos"); registro[4] = rs.getString("direccion"); registro[5] = rs.getString("placa"); registro[6] = rs.getString("modelo"); registro[7] = rs.getString("ao"); registro[8] = rs.getString("color"); registro[9] = rs2.getString("cedula"); registro[10] = rs2.getString("num_cuenta"); registro[11] = rs2.getString("monto"); registro[12] = rs2.getString("banco"); modelo.addRow(registro); } tblConsultaEmpleado.setModel(modelo); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex);} } String id_actualizar = ""; void SerialCargarTablaClientes(String valor) { String[] titulos = {"ID", "Cdula", "Nombres", "Apellidos", "Direccin", "Placa", "Modelo", "Ao", "Color", "Cedula", "Numero Cuenta", "Monto", "Banco"}; String[] registro2 = new String[13]; String sSQL = ""; String sSQL2 = ""; modelo = new DefaultTableModel(null, titulos); //Conectar con el servidor A ConexionServerA mysql = new ConexionServerA(); Connection cn = mysql.Conectar(); //Conectar con el servidor B ConexionServerB mysql2 = new ConexionServerB(); Connection cn2 = mysql2.Conectar(); //Base de Datos Servidor A sSQL = "SELECT id_clt2, cedula2, nombres, apellidos, direccion, placa, modelo, ao, color FROM datos_servidora "+ "WHERE CONCAT(cedula2, ' ',nombres, ' ',apellidos, ' ',direccion, ' ',placa, ' ',modelo, ' ',ao, ' ',color) LIKE '%"+valor+"%'"; //Base de Datos Servidor B sSQL2 = "SELECT id_clt, cedula, num_cuenta, monto, banco FROM datos_servidorb " + "WHERE CONCAT(cedula, ' ',num_cuenta, ' ',monto, ' ',banco) LIKE '%"+valor+"%'"; try { //Servidor A Statement st = cn.createStatement(); ResultSet rs = st.executeQuery(sSQL); //Servidor B Statement st2 = cn2.createStatement(); ResultSet rs2 = st2.executeQuery(sSQL2); while(rs.next() && rs2.next()) { registro2[0] = rs.getString("id_clt2"); registro2[1] = rs.getString("cedula2"); registro2[2] = rs.getString("nombres"); registro2[3] = rs.getString("apellidos");

26

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
registro2[4] = rs.getString("direccion"); registro2[5] = rs.getString("placa"); registro2[6] = rs.getString("modelo"); registro2[7] = rs.getString("ao"); registro2[8] = rs.getString("color"); registro2[9] = rs2.getString("cedula"); registro2[10] = rs2.getString("num_cuenta"); registro2[11] = rs2.getString("monto"); registro2[12] = rs2.getString("banco"); modelo.addRow(registro2); } tblConsultaEmpleado.setModel(modelo); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex);} //Manadar los datos al celular try { Parameters parameters = new Parameters(); //Create a parameter object parameters.setPort("COM9");//assigns the first port found parameters.setBaudRate(Baud._19200);//assigns baud rate parameters.setByteSize("8");// assigns byte size parameters.setParity("N");// assigns parity Com com = new Com(parameters);// With the "parameters" creates a "Com" com.sendString("Cedula: "+ registro2[1]+"\n"+"Cliente: "+registro2[3]+" "+registro2[2]+"\n"+"\n"+"Modelo: "+registro2[6]+"\n"+"Placa: "+registro2[5]+"\n"+"\n"+"Banco: "+registro2[12]+"\n"+"Monto: "+registro2[11]+" dolares"); clt=registro2[0]; cedulastring=registro2[1]; numstring=registro2[10]; bancostring=registro2[12]; montostring=registro2[11]; montoentero= Integer.parseInt (montostring); montoentero=montoentero-2; montostring=Integer.toString(montoentero);} void BuscarClienteEditar(String id) { String sSQL = ""; String ced = "", nom = "", ape = "", dir = "", pla= "", mod = "", ao = "", col = ""; ConexionServerA mysql = new ConexionServerA(); Connection cn = mysql.Conectar(); sSQL = "SELECT id_clt2, cedula2, nombres, apellidos, direccion, placa, modelo, ao, color FROM datos_servidora "+ "WHERE id_clt2 = "+id; try { Statement st = cn.createStatement(); ResultSet rs = st.executeQuery(sSQL); while(rs.next()) { ced = rs.getString("cedula2"); nom = rs.getString("nombres"); ape = rs.getString("apellidos"); dir = rs.getString("direccion"); pla = rs.getString("placa"); mod = rs.getString("modelo"); ao = rs.getString("ao"); col = rs.getString("color"); } txtCedula.setText(ced); txtNombres.setText(nom); txtApellidos.setText(ape); txtDireccion.setText(dir); txtPlaca.setText(pla); txtModelo.setText(mod);

GRUPO: 1

txtAo.setText(ao); txtColor.setText(col); id_actualizar = id; } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } } void serialport(){ try { //Create a parameter object Parameters parameters = new Parameters();//Create a parameter object parameters.set Port("COM9");//assigns the first port found parameters.setBaudRate(Baud._19200);//assigns baud rate parameters.setByteSize("8");// assigns byte size parameters.setParity("N");// assigns parity Com com = new Com(parameters);// With the "parameters" creates a "Com" String j; String k; int i; j=""; k=""; i=0; String data; while(true){ data=com.receiveSingleString(); System.out.println(data); j=j+data; System.out. println("CI: "+j); if(j.endsWith("exit")){ break; //salir si se desconecta el dispositivo} if(j.endsWith("play")){ // System.out.println(k) ; ModificarMonto(); j=""; } i=j.length(); if(i==10){ txtDato.setText(j); //com.sendString(j); com.close(); SerialCargarTablaClientes(j); k=j; j=""; i=0; } } //endif com.close(); } catch (Exception ex) { Logger.getLogger(Clientes.class.getName()).log(Level.SEV ERE, null, ex); } // String dato3 = txtDato.getText(); // SerialCargarTablaClientes(dato3); } private void initComponents() { mnEditar.setText("Modificar"); mnEditar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnEditarActionPerformed(evt); } }); jPopupMenu1.add(mnEditar); setDefaultCloseOperation(javax.swing.WindowConstants.E XIT_ON_CLOSE); setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { formKeyPressed(evt); } });

27

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
jPanel1.setBorder(javax.swing.BorderFactory.createTitledB order("Ingreso Datos Servidor A")); jLabel1.setText("# Cdula :"); txtCedula.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtCedulaActionPerformed(evt); } }); jLabel2.setText("Nombres : "); txtNombres.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtNombresActionPerformed(evt); } }); jLabel3.setText("Apellidos : "); txtApellidos.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtApellidosActionPerformed(evt); } }); jLabel4.setText("Direccin : "); txtDireccion.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtDireccionActionPerformed(evt); } }); btnNuevo.setText("Nuevo"); btnNuevo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNuevoActionPerformed(evt); } }); btnGuardar.setText("Guardar"); btnGuardar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnGuardarActionPerformed(evt); } }); btnCancelar.setText("Cancelar"); btnCancelar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCancelarActionPerformed(evt); } }); btnSalir.setText("Salir"); btnSalir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSalirActionPerformed(evt); } }); txtColor.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtColorActionPerformed(evt); } }); jLabel5.setText("Color : "); jLabel6.setText("Ao : "); txtAo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtAoActionPerformed(evt); } }); txtModelo.addActionListener(new java.awt.event.ActionListener() {

GRUPO: 1

public void actionPerformed(java.awt.event.ActionEvent evt) { txtModeloActionPerformed(evt); } }); jLabel8.setText("Modelo : "); jLabel9.setText("Placa :"); txtPlaca.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtPlacaActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayo ut.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(30, 30, 30) .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.TRAILING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED) .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED) .addComponent(txtApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel2) redGap(javax.swing.LayoutStyle.ComponentPlacement.UN RELATED) .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)) addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED) .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED) .addComponent(txtColor, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel6) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED)

28

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
.addComponent(txtAo, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel8) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED) .addComponent(txtModelo, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jLabel9) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED) .addComponent(txtPlaca, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addComponent(btnNuevo) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.RELATED) .addComponent(btnGuardar) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.RELATED) .addComponent(btnCancelar) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED) .addComponent(btnSalir))) .addContainerGap(23, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayo ut.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(txtNombres, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(txtApellidos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.BASELINE) .addComponent(jLabel4)

GRUPO: 1

.addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.BASELINE) .addComponent(jLabel9) .addComponent(txtPlaca, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.BASELINE) .addComponent(jLabel8) .addComponent(txtModelo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(txtAo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.BASELINE) .addComponent(jLabel5) .addComponent(txtColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.BASELINE) .addComponent(btnNuevo) .addComponent(btnGuardar) .addComponent(btnCancelar) .addComponent(btnSalir)) .addContainerGap()) ); jPanel2.setBorder(javax.swing.BorderFactory.createTitledB order("Consulta de Datos")); tblConsultaEmpleado.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {}, {}, {}, {} }, new String [] { } )); tblConsultaEmpleado.setComponentPopupMenu(jPopupMe nu1); jScrollPane1.setViewportView(tblConsultaEmpleado);

29

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
jLabel7.setText("Buscar Cliente : "); btnBuscar.setText("Buscar"); btnBuscar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBuscarActionPerformed(evt); } }); btnBuscar1.setText("Actualizar"); btnBuscar1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBuscar1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayo ut.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1153, Short.MAX_VALUE) .addContainerGap()) .addGroup(jPanel2Layout.createSequentialGroup() .addGap(316, 316, 316) .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED) .addComponent(txtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED) .addComponent(btnBuscar) .addGap(18, 18, 18) .addComponent(btnBuscar1) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SI ZE, Short.MAX_VALUE)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayo ut.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.BASELINE) .addComponent(jLabel7) .addComponent(txtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE,

GRUPO: 1

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnBuscar) .addComponent(btnBuscar1)) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(14, Short.MAX_VALUE)) ); jLabel10.setBackground(new java.awt.Color(0, 102, 255)); jLabel10.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N jLabel10.setForeground(new java.awt.Color(255, 0, 0)); jLabel10.setText(" SERVIDOR A"); jLabel10.setBorder(javax.swing.BorderFactory.createLineB order(new java.awt.Color(0, 0, 0))); jLabel10.setHorizontalTextPosition(javax.swing.SwingCons tants.CENTER);

jPanel3.setBorder(javax.swing.BorderFactory.createTitledB order(javax.swing.BorderFactory.createTitledBorder("Comu nicacin Movil"))); jbtnHabilitar.setText("Habilitar Bluetooth"); jbtnHabilitar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbtnHabilitarActionPerformed(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayo ut.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addContainerGap() .addGroup(jPanel3Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING) .addComponent(txtDato, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jbtnHabilitar, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(58, Short.MAX_VALUE)) ); jPanel3Layout.setVerticalGroup( jPanel3Layout.createParallelGroup(javax.swing.GroupLayo ut.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(jbtnHabilitar)

30

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlac ement.UNRELATED) .addComponent(txtDato, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILIN G, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SI ZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLa yout.Alignment.LEADING) .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 325, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(54, 54, 54) .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(271, 271, 271)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(28, 28, 28) .addGroup(layout.createParallelGroup(javax.swing.GroupLa yout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(29, 29, 29)

GRUPO: 1

.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) );

jPanel2.getAccessibleContext().setAccessibleName("Consul ta de Empleado"); setBounds(550, 250, 1201, 763); }// </editor-fold> private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) { this.dispose(); } private void btnNuevoActionPerformed(java.awt.event.ActionEvent evt) { habilitar(); } private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) { inhabilitar(); } private void txtCedulaActionPerformed(java.awt.event.ActionEvent evt) { txtCedula.transferFocus(); } private void txtNombresActionPerformed(java.awt.event.ActionEvent evt) { txtNombres.transferFocus(); } private void txtApellidosActionPerformed(java.awt.event.ActionEvent evt) { txtApellidos.transferFocus(); } private void txtDireccionActionPerformed(java.awt.event.ActionEvent evt) { txtDireccion.transferFocus(); } String accion = "Insertar"; private void btnGuardarActionPerformed(java.awt.event.ActionEvent evt) { ConexionServerA mysql = new ConexionServerA(); Connection cn = mysql.Conectar(); String ced, nom, ape, dir, pla, mod, ao, col; String sSQL = ""; String mensaje = ""; ced = txtCedula.getText();

31

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
nom = txtNombres.getText(); ape = txtApellidos.getText(); dir = txtDireccion.getText(); pla = txtPlaca.getText(); mod = txtModelo.getText(); ao = txtAo.getText(); col = txtColor.getText(); } if(accion.equals("Insertar")) { sSQL = "INSERT INTO datos_servidora(cedula2, nombres, apellidos, direccion, placa, modelo, ao, color)" + "VALUES(?, ?, ?, ?, ?, ?, ?, ?)"; mensaje = "Los datos se han Insertado de Manera Satisfactoria..."; } else if(accion.equals("Modificar")) { sSQL = "UPDATE datos_servidora " + "SET cedula2 = ?," + "nombres = ?," + "apellidos = ?," + "direccion = ?," + "placa = ?," + "modelo = ?," + "ao = ?," + "color = ? " + "WHERE id_clt2 = "+id_actualizar; mensaje = "Los datos se han Modificado Correctamente..."; accion = "Insertar"; } try { PreparedStatement pst = cn.prepareStatement(sSQL); pst.setString(1, ced); pst.setString(2, nom); pst.setString(3, ape); pst.setString(4, dir); pst.setString(5, pla); pst.setString(6, mod); pst.setString(7, ao);

GRUPO: 1

pst.setString(8, col); int n = pst.executeUpdate(); if(n > 0) { JOptionPane.showMessageDialog(null, mensaje); CargarTablaClientes(""); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } void ModificarMonto(){ ConexionServerB mysql = new ConexionServerB(); Connection cn = mysql.Conectar(); String ced,num, banco; String mont=""; String sSQL = ""; String mensaje = ""; ced=cedulastring; num=numstring; banco=bancostring; mont=montostring; System.out.println(clt); sSQL = "UPDATE datos_servidorb " + "SET cedula = ?," + "num_cuenta = ?," + "monto = ?," + "banco = ? " + "WHERE id_clt = "+clt; mensaje = "Los datos se han Modificado de Manera Satisfactoria..."; accion = "Insertar"; // } try { PreparedStatement pst = cn.prepareStatement(sSQL); pst.setString(1, ced); pst.setString(2, num); pst.setString(3, mont); pst.setString(4, banco); int n = pst.executeUpdate(); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } }

SERVIDOR B
package Formularios; // librerias import BaseDatos.ConexionServerA; import BaseDatos.ConexionServerB; import java.sql.*; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; Public class Clientes extends javax.swing.JFrame { DefaultTableModel modelo; /** Creates new form Clientes */ public Clientes() { initComponents(); CargarTablaClientes(""); inhabilitar(); } void CargarTablaClientes(String valor) { String[] titulos = {"ID", "Cdula", "Nmero Cuenta", "Monto", "Banco", "Cdula", "Nombres", "Apellidos", "Direccin", "Placa", "Modelo", "Ao", "Color"}; String[] registro = new String[13]; String sSQL = ""; String sSQL2 = ""; modelo = new DefaultTableModel(null, titulos); //Conectar con el servidor A ConexionServerA mysql2 = new ConexionServerA(); Connection cn2 = mysql2.Conectar(); //Conectar con el servidor B ConexionServerB mysql = new ConexionServerB(); Connection cn = mysql.Conectar(); //Base de Datos Servidor B sSQL = "SELECT id_clt, cedula, num_cuenta, monto, banco FROM datos_servidorb " + "WHERE CONCAT(cedula, ' ',num_cuenta, ' ',monto, ' ',banco) LIKE '%"+valor+"%'"; //Base de Datos Servidor A

32

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
sSQL2 = "SELECT id_clt2, cedula2, nombres, apellidos, direccion, placa, modelo, ao, color FROM datos_servidora " + "WHERE CONCAT(cedula2, ' ',nombres, ' ',apellidos, ' ',direccion, ' ',placa, ' ',modelo, ' ',ao, ' ',color) LIKE '%"+valor+"%'"; try { //Servidor B Statement st = cn.createStatement(); ResultSet rs = st.executeQuery(sSQL); //Servidor A Statement st2 = cn2.createStatement(); ResultSet rs2 = st2.executeQuery(sSQL2); while(rs.next() && rs2.next()) { registro[0] = rs.getString("id_clt"); registro[1] = rs.getString("cedula"); registro[2] = rs.getString("num_cuenta"); registro[3] = rs.getString("monto"); registro[4] = rs.getString("banco"); registro[5] = rs2.getString("cedula2"); registro[6] = rs2.getString("nombres"); registro[7] = rs2.getString("apellidos"); registro[8] = rs2.getString("direccion"); registro[9] = rs2.getString("placa"); registro[10] = rs2.getString("modelo"); registro[11] = rs2.getString("ao"); registro[12] = rs2.getString("color"); modelo.addRow(registro) } tblConsultaEmpleado.setModel(modelo); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } } String id_actualizar = ""; void BuscarClienteEditar(String id) { String sSQL = ""; String ap1 = "", ap2 = "", nom1 = "", nom2 = "", fn = "", gen = ""; ConexionServerB mysql = new ConexionServerB(); Connection cn = mysql.Conectar(); sSQL = "SELECT id_clt, cedula, num_cuenta, monto, banco FROM datos_servidorb " + "WHERE id_clt = "+id; try { Statement st = cn.createStatement(); ResultSet rs = st.executeQuery(sSQL); while(rs.next()) { ap1 = rs.getString("cedula"); ap2 = rs.getString("num_cuenta"); nom1 = rs.getString("monto"); nom2 = rs.getString("banco"); //fn = rs.getString("fecha_nac"); //gen } =

GRUPO: 1
rs.getString("genero");

txtCedula.setText(ap1); txtCuenta.setText(ap2); txtMonto.setText(nom1); txtBanco.setText(nom2); id_actualizar = id; } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } } void habilitar() // HABILITA CUANDO SE PULSA NUEVO Y DEJA EN BLANCO LOS TEXT { txtCedula.setEnabled(true); txtCuenta.setEnabled(true); txtMonto.setEnabled(true); txtBanco.setEnabled(true); txtCedula.setText(""); txtCuenta.setText(""); txtMonto.setText(""); txtBanco.setText(""); btnGuardar.setEnabled(true); btnCancelar.setEnabled(true); txtCedula.requestFocus(); } void inhabilitar() { txtCedula.setEnabled(false); txtCuenta.setEnabled(false); txtMonto.setEnabled(false); txtBanco.setEnabled(false); txtCedula.setText(""); txtCuenta.setText(""); txtMonto.setText(""); txtBanco.setText(""); btnGuardar.setEnabled(false); btnCancelar.setEnabled(false); } private void initComponents() { jPopupMenu1 = new javax.swing.JPopupMenu(); mnEditar = new javax.swing.JMenuItem(); jLabel10 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); txtCedula = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); txtCuenta = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); txtMonto = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); txtBanco = new javax.swing.JTextField(); btnNuevo = new javax.swing.JButton(); btnGuardar = new javax.swing.JButton(); btnCancelar = new javax.swing.JButton(); btnSalir = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); tblConsultaEmpleado = new javax.swing.JTable(); jLabel7 = new javax.swing.JLabel();

33

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
txtBuscar = new javax.swing.JTextField(); btnBuscar = new javax.swing.JButton(); btnBuscar1 = new javax.swing.JButton(); jLabel11 = new javax.swing.JLabel(); mnEditar.setText("Modificar"); mnEditar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { mnEditarActionPerformed(evt); } }); jPopupMenu1.add(mnEditar); jLabel10.setBackground(new java.awt.Color(0, 102, 255)); jLabel10.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N jLabel10.setForeground(new java.awt.Color(255, 0, 0)); jLabel10.setText(" SERVIDOR A"); jLabel10.setBorder(javax.swing.BorderFactory. createLineBorder(new java.awt.Color(0, 0, 0))); jLabel10.setHorizontalTextPosition(javax.swing .SwingConstants.CENTER); setDefaultCloseOperation(javax.swing.Window Constants.EXIT_ON_CLOSE); setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_C URSOR)); jPanel1.setBorder(javax.swing.BorderFactory.cr eateTitledBorder("Ingreso Datos Servidor B")); jLabel1.setText("# Cdula :"); txtCedula.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtCedulaActionPerformed(evt); } }); jLabel2.setText("Nmero Cuenta : "); txtCuenta.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtCuentaActionPerformed(evt); } }); jLabel3.setText("Monto : "); txtMonto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtMontoActionPerformed(evt); } }); jLabel4.setText("Banco : ");

GRUPO: 1

txtBanco.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtBancoActionPerformed(evt); } }); btnNuevo.setText("Nuevo"); btnNuevo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNuevoActionPerformed(evt); } }); btnGuardar.setText("Guardar"); btnGuardar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnGuardarActionPerformed(evt); } }); btnCancelar.setText("Cancelar"); btnCancelar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCancelarActionPerformed(evt); } }); btnSalir.setText("Salir"); btnSalir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSalirActionPerformed(evt); } }); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGrou p() .addGroup(jPanel1Layout.createParallelGroup(j avax.swing.GroupLayout.Alignment.LEADING ) .addGroup(jPanel1Layout.createSequentialGrou p() .addGap(30, 30, 30) .addGroup(jPanel1Layout.createParallelGroup(j

34

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
avax.swing.GroupLayout.Alignment.TRAILIN G) .addGroup(jPanel1Layout.createSequentialGrou p() .addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.UNRELATED) .addComponent(txtBanco, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE) ) .addGroup(jPanel1Layout.createSequentialGrou p() .addComponent(jLabel3) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.UNRELATED) .addComponent(txtMonto, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE) ) .addGroup(jPanel1Layout.createSequentialGrou p() .addComponent(jLabel2) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.UNRELATED) .addComponent(txtCuenta, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE) ) .addGroup(jPanel1Layout.createSequentialGrou p() .addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.UNRELATED) .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE) ))) .addGroup(jPanel1Layout.createSequentialGrou p() .addContainerGap() .addComponent(btnNuevo) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.RELATED) .addComponent(btnGuardar)

GRUPO: 1

.addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.RELATED) .addComponent(btnCancelar) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.UNRELATED) .addComponent(btnSalir))) .addContainerGap(18, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGrou p() .addContainerGap() addGroup(jPanel1Layout.createParallelGroup(ja vax.swing.GroupLayout.Alignment.BASELINE ) .addComponent(jLabel1) .addComponent(txtCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) ) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(j avax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(jLabel2) .addComponent(txtCuenta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) ) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(j avax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(jLabel3) .addComponent(txtMonto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) ) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(j

35

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
avax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(jLabel4) .addComponent(txtBanco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) ) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.RELATED, 37, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(j avax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(btnNuevo) .addComponent(btnGuardar) .addComponent(btnCancelar) .addComponent(btnSalir)) .addContainerGap()) ); jPanel2.setBorder(javax.swing.BorderFactory.cr eateTitledBorder("Consulta de Datos")); tblConsultaEmpleado.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {}, {}, {}, {} }, new String [] { } )); tblConsultaEmpleado.setComponentPopupMen u(jPopupMenu1); jScrollPane1.setViewportView(tblConsultaEmp leado); jLabel7.setText("Buscar Cliente : "); btnBuscar.setText("Buscar"); btnBuscar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBuscarActionPerformed(evt); } }); btnBuscar1.setText("Actualizar"); btnBuscar1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnBuscar1ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup( jPanel2Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING)

GRUPO: 1

.addGroup(jPanel2Layout.createSequentialGrou p() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1134, Short.MAX_VALUE) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignmen t.TRAILING, jPanel2Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.D EFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel7) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.UNRELATED) .addComponent(txtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.UNRELATED) .addComponent(btnBuscar) .addGap(18, 18, 18) .addComponent(btnBuscar1) .addGap(371, 371, 371)) ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing. GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGrou p() .addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(j avax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(jLabel7) .addComponent(txtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnBuscar) .addComponent(btnBuscar1)) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 269, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(25, Short.MAX_VALUE)) ); jLabel11.setBackground(new java.awt.Color(0, 102, 255)); jLabel11.setFont(new java.awt.Font("Tahoma", 0, 48)); // NOI18N

36

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
jLabel11.setForeground(new java.awt.Color(0, 51, 255)); jLabel11.setText(" SERVIDOR B"); jLabel11.setBorder(javax.swing.BorderFactory. createLineBorder(new java.awt.Color(0, 0, 0))); jLabel11.setHorizontalTextPosition(javax.swing .SwingConstants.CENTER); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupL ayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignmen t.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.D EFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swi ng.GroupLayout.Alignment.TRAILING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 325, javax.swing.GroupLayout.PREFERRED_SIZE) ) .addGap(410, 410, 410)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupL ayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.Co mponentPlacement.RELATED, 33, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,

GRUPO: 1

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()) ); jPanel2.getAccessibleContext().setAccessibleN ame("Consulta de Empleado"); setBounds(550, 250, 1202, 759); }// </editor-fold> private void btnSalirActionPerformed(java.awt.event.Action Event evt) { this.dispose(); } private void btnNuevoActionPerformed(java.awt.event.Actio nEvent evt) { habilitar(); } private void btnCancelarActionPerformed(java.awt.event.Ac tionEvent evt) { inhabilitar(); } private void txtCedulaActionPerformed(java.awt.event.Actio nEvent evt) { txtCedula.transferFocus(); } private void txtCuentaActionPerformed(java.awt.event.Actio nEvent evt) { txtCuenta.transferFocus(); } private void txtMontoActionPerformed(java.awt.event.Actio nEvent evt) { txtMonto.transferFocus(); } private void txtBancoActionPerformed(java.awt.event.Actio nEvent evt) { txtBanco.transferFocus(); } String accion = "Insertar"; private void btnGuardarActionPerformed(java.awt.event.Act ionEvent evt) { ConexionServerB mysql = new ConexionServerB(); Connection cn = mysql.Conectar(); String ap1, ap2, nom1, nom2; String sSQL = ""; String mensaje = ""; ap1 = txtCedula.getText(); ap2 = txtCuenta.getText(); nom1 = txtMonto.getText(); nom2 = txtBanco.getText(); if(accion.equals("Insertar")) { sSQL = "INSERT INTO datos_servidorb(cedula, num_cuenta, monto, banco)" + "VALUES(?, ?, ?, ?)";

37

INTEGRANTES: SEBASTIN CAMPOVERDE, EDWIN GAMBOA JORGE DUCHITANGA, MARIELA JIMBO REDES DE CMPUTO I
mensaje = "Los datos se han Insertado de Manera Satisfactoria..."; } else if(accion.equals("Modificar")) { sSQL = "UPDATE datos_servidorb " + "SET cedula = ?," + "num_cuenta = ?," + "monto = ?," + "banco = ? " + "WHERE id_clt = "+id_actualizar; mensaje = "Los datos se han Modificado de Manera Satisfactoria..."; accion = "Insertar"; } try { PreparedStatement pst = cn.prepareStatement(sSQL); pst.setString(1, ap1); pst.setString(2, ap2); pst.setString(3, nom1); pst.setString(4, nom2); // pst.setString(5, fn); // pst.setString(6, gen); int n = pst.executeUpdate(); if(n > 0) { JOptionPane.showMessageDialog(null, mensaje); CargarTablaClientes(""); } } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex); } } private void btnBuscarActionPerformed(java.awt.event.Acti onEvent evt) { String valor = txtBuscar.getText(); CargarTablaClientes(valor); } private void mnEditarActionPerformed(java.awt.event.Actio nEvent evt) { int filasel; String id; try { filasel = tblConsultaEmpleado.getSelectedRow(); if(filasel == -1) { JOptionPane.showMessageDialog(null, "No se ha seleccionado ninguna fila"); }

GRUPO: 1

else { accion = "Modificar"; modelo = (DefaultTableModel) tblConsultaEmpleado.getModel(); id = (String) modelo.getValueAt(filasel, 0); habilitar(); BuscarClienteEditar(id); } } catch (Exception e) { } } private void btnBuscar1ActionPerformed(java.awt.event.Act ionEvent evt) { public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new Clientes().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton btnBuscar; private javax.swing.JButton btnBuscar1; private javax.swing.JButton btnCancelar; private javax.swing.JButton btnGuardar; private javax.swing.JButton btnNuevo; private javax.swing.JButton btnSalir; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel7; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPopupMenu jPopupMenu1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JMenuItem mnEditar; private javax.swing.JTable tblConsultaEmpleado; private javax.swing.JTextField txtBanco; private javax.swing.JTextField txtBuscar; private javax.swing.JTextField txtCedula; private javax.swing.JTextField txtCuenta; private javax.swing.JTextField txtMonto; // End of variables declaration }

38

You might also like