Advertisement
Guest User

Clientes

a guest
Aug 2nd, 2015
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.58 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. import net.proteanit.sql.DbUtils;
  4.  
  5. import java.awt.*;
  6. import java.awt.event.*;
  7. import java.sql.PreparedStatement;
  8. import java.sql.ResultSet;
  9.  
  10. public class Clientes extends JFrame{
  11.  
  12. private static final long serialVersionUID = 1L;
  13.  
  14. private JButton btnMostrar;
  15.  
  16. private JPanel PanelContenido;
  17. private JTextField txtCliente;
  18. private JLabel lblCliente;
  19. private JTextField textField;
  20.  
  21. private JLabel lblApM;
  22. private JLabel lblApP;
  23. private JLabel lblNombre;
  24. private JLabel lblCorreo;
  25. private JLabel lblTel;
  26. private JLabel lblColonia;
  27. private JLabel lblCalle;
  28. private JLabel lblNumero;
  29. private JLabel lblCP;
  30. private JLabel lblEdo;
  31. private JLabel lblSucursal;
  32. private JLabel lblCredito;
  33. private JLabel lblClienteFor;
  34. private JTextField txtNombre;
  35. private JTextField txtApP;
  36. private JTextField txtApM;
  37. private JTextField txtCorreo;
  38. private JTextField txtTel;
  39. private JTextField txtColonia;
  40. private JTextField txtCalle;
  41. private JTextField txtNumero;
  42. private JTextField txtCP;
  43. private JTextField txtLimite;
  44. private JTextField txtNoCliente;
  45. private JComboBox cmbEdo;
  46. private JComboBox cmbSucursal;
  47. private JPanel panel_2;
  48.  
  49. private JLabel lblClienteMod;
  50. private JTextField txtClienteMod;
  51. private JButton btnAceptarMod;
  52. private JPanel panel_3;
  53.  
  54. private JLabel lblClienteEli;
  55. private JTextField txtClienteEli;
  56. private JButton btnAceptarEli;
  57. private JPanel panel_4;
  58.  
  59. private JButton btnMostrar_2;
  60. private JButton btnMostrar_3;
  61. private JTable table;
  62.  
  63. public Clientes (){
  64. getContentPane().setLayout(null);
  65.  
  66. JScrollPane scrollPane = new JScrollPane();
  67. scrollPane.setBounds(140, 88, 163, 74);
  68. getContentPane().add(scrollPane);
  69.  
  70. table = new JTable();
  71. scrollPane.setViewportView(table);
  72.  
  73. setTitle("Clientes");
  74. setSize(600, 600);
  75. setLocationRelativeTo(null);
  76. setResizable(false);
  77. setDefaultCloseOperation(HIDE_ON_CLOSE);
  78. getContentPane().setLayout(null);
  79.  
  80. PanelContenido = new JPanel();
  81. PanelContenido.setLayout(null);
  82. PanelContenido.setBounds(0, 0, 600, 600);
  83.  
  84. panel_2 = new JPanel();
  85. panel_2.setLayout(null);
  86. panel_2.setBounds(24, 48, 543, 450);
  87. panel_2.setVisible(false);
  88.  
  89. panel_3 = new JPanel();
  90. panel_3.setLayout(null);
  91. panel_3.setBounds(24, 48, 543, 400);
  92. panel_3.setVisible(false);
  93.  
  94. panel_4 = new JPanel();
  95. panel_4.setLayout(null);
  96. panel_4.setBounds(24, 48, 543, 400);
  97. panel_3.setVisible(false);
  98.  
  99. ClassLoader cl;
  100. cl = this.getClass().getClassLoader();
  101.  
  102. Icon imagen = new ImageIcon(cl.getResource("imagenes/RedPoint.jpg"));
  103. JLabel labelEtiqueta = new JLabel(imagen);
  104. labelEtiqueta.setBounds(0, 40, 100,100);
  105.  
  106. ClassLoader cl1;
  107. cl1 = this.getClass().getClassLoader();
  108.  
  109. Icon imagen1 = new ImageIcon(cl1.getResource("imagenes/final.jpg"));
  110. JLabel labelEtiq = new JLabel(imagen1);
  111. labelEtiq.setBounds(480, 40, 100,100);
  112.  
  113. JPanel panel = new JPanel();
  114. panel.setBounds(24, 48, 543, 400);
  115. panel.setLayout(null);
  116. panel.setVisible(false);
  117.  
  118. JPanel panel1 = new JPanel();
  119. panel1.setBounds(34, 48, 513, 390);
  120. panel1.setLayout(null);
  121.  
  122.  
  123. JButton btnNuevoCliente = new JButton("Nuevo Cliente");
  124. btnNuevoCliente.setBounds(391, 524, 161, 25);
  125. btnNuevoCliente.addActionListener(new ActionListener() {
  126.  
  127.  
  128. public void actionPerformed(ActionEvent arg0) {
  129.  
  130. panel.setVisible(false);
  131. panel_2.setVisible(true);
  132. panel_3.setVisible(false);
  133. panel_4.setVisible(false);
  134.  
  135. }
  136. });
  137.  
  138. JButton btnEliminarCliente = new JButton("Eliminar Cliente");
  139. btnEliminarCliente.setBounds(30, 524, 150, 25);
  140. btnEliminarCliente.addActionListener(new ActionListener(){
  141.  
  142. public void actionPerformed(ActionEvent e){
  143.  
  144. panel_4.setVisible(true);
  145. panel.setVisible(false);
  146. panel_2.setVisible(false);
  147. panel_3.setVisible(false);
  148. }
  149. });
  150.  
  151. lblApP = new JLabel("Apellido Paterno:");
  152. lblApP.setBounds(20,15,120,25);
  153. panel_2.add(lblApP);
  154.  
  155. lblApM = new JLabel("Apellido Materno:");
  156. lblApM.setBounds(20,55,120,25);
  157.  
  158. lblNombre = new JLabel("Nombre:");
  159. lblNombre.setBounds(20,95,120,25);
  160.  
  161. lblCorreo = new JLabel("Correo:");
  162. lblCorreo.setBounds(20,135,120,25);
  163.  
  164. lblTel = new JLabel("Teléfono:");
  165. lblTel.setBounds(20,175,120,25);
  166.  
  167. lblColonia = new JLabel("Colonia");
  168. lblColonia.setBounds(20,215,120,25);
  169.  
  170. lblCalle = new JLabel("Calle");
  171. lblCalle.setBounds(20,255,120,25);
  172.  
  173. lblNumero = new JLabel("Número");
  174. lblNumero.setBounds(20,295,120,25);
  175.  
  176. lblCP = new JLabel("Código Postal");
  177. lblCP.setBounds(250,295,120,25);
  178.  
  179. lblCredito = new JLabel("Límite de Crédito:");
  180. lblCredito.setBounds(20,335,120,25);
  181.  
  182. lblClienteFor = new JLabel("Número de Cliente:");
  183. lblClienteFor.setBounds(250,335,120,25);
  184.  
  185. lblEdo = new JLabel("Estado");
  186. lblEdo.setBounds(20,370,100,25);
  187.  
  188. lblSucursal = new JLabel("Sucursal");
  189. lblSucursal.setBounds(300,370,100,25);
  190.  
  191. txtApP = new JTextField();
  192. txtApP.setBounds(140,20,180,25);
  193.  
  194. txtApM = new JTextField();
  195. txtApM.setBounds(140,60,180,25);
  196.  
  197. txtNombre = new JTextField();
  198. txtNombre.setBounds(140,95,220,25);
  199.  
  200. txtCorreo = new JTextField();
  201. txtCorreo.setBounds(140,135,250,25);
  202.  
  203. txtTel = new JTextField();
  204. txtTel.setBounds(140,175,180,25);
  205.  
  206. txtColonia = new JTextField();
  207. txtColonia.setBounds(140,215,250,25);
  208.  
  209. txtCalle = new JTextField();
  210. txtCalle.setBounds(140,255,250,25);
  211.  
  212. txtNumero = new JTextField();
  213. txtNumero.setBounds(140,295,80,25);
  214.  
  215. txtCP = new JTextField();
  216. txtCP.setBounds(350,295,80,25);
  217.  
  218. txtLimite =new JTextField();
  219. txtLimite.setBounds(140,335,80,25);
  220.  
  221. txtNoCliente = new JTextField();
  222. txtNoCliente.setBounds(370,335,80,25);
  223.  
  224. JButton btnGuardar = new JButton("Guardar");
  225. btnGuardar.setBounds(80, 410, 100, 25);
  226.  
  227. panel_2.add(btnGuardar);
  228.  
  229. JButton btnCancelar = new JButton("Cancelar");
  230. btnCancelar.setBounds(320,410, 100, 25);
  231. btnCancelar.addActionListener(new ActionListener() {
  232.  
  233.  
  234. public void actionPerformed(ActionEvent arg0) {
  235.  
  236. new Clientes().setVisible(true);
  237. }
  238. });
  239. panel_2.add(btnCancelar);
  240.  
  241. cmbEdo = new JComboBox();
  242. cmbEdo.setBounds(100,370,180,25);
  243.  
  244. cmbSucursal = new JComboBox();
  245. cmbSucursal.setBounds(370,370,150,25);
  246. cmbSucursal.addItem("Veracruz");
  247. cmbSucursal.addItem("Guadalajara");
  248. cmbSucursal.addItem("Guerrero");
  249. cmbSucursal.addItem("Oaxaca");
  250.  
  251. lblCliente=new JLabel("Cliente:");
  252.  
  253. txtCliente= new JTextField();
  254.  
  255. lblCliente.setBounds(108, 55, 53, 20);
  256. panel.add(lblCliente);
  257. panel.add(txtCliente);
  258.  
  259. JButton btnAceptar = new JButton("Aceptar");
  260. btnAceptar.setBounds(100, 345, 89, 23);
  261. panel.add(btnAceptar);
  262.  
  263. textField = new JTextField();
  264. textField.setBounds(171, 55, 234, 20);
  265. panel.add(textField);
  266.  
  267. lblClienteMod = new JLabel("Cliente:");
  268. lblClienteMod.setBounds(108,55,53,20);
  269.  
  270. txtClienteMod = new JTextField();
  271. txtClienteMod.setBounds(171,55,234,20);
  272.  
  273. btnAceptarMod = new JButton("Aceptar");
  274. btnAceptarMod.setBounds(219,345,89,23);
  275.  
  276. lblClienteEli = new JLabel("Cliente:");
  277. lblClienteEli.setBounds(108,55,53,20);
  278.  
  279. txtClienteEli = new JTextField();
  280. txtClienteEli.setBounds(171,55,234,20);
  281.  
  282. btnAceptarEli = new JButton("Aceptar");
  283. btnAceptarEli.setBounds(219,345,89,23);
  284.  
  285. JButton btnEstadoDeCuenta = new JButton("Estado de Cuenta");
  286. btnEstadoDeCuenta.setBounds(10, 11, 133, 23);
  287. btnEstadoDeCuenta.addActionListener(new ActionListener() {
  288.  
  289.  
  290. public void actionPerformed(ActionEvent arg0) {
  291.  
  292. panel.setVisible(true);
  293. panel_2.setVisible(false);
  294. panel_3.setVisible(false);
  295. panel_4.setVisible(false);
  296.  
  297. }
  298. });
  299. PanelContenido.add(btnEstadoDeCuenta);
  300.  
  301.  
  302. JButton btnModificarCliente = new JButton("Modificar Cliente");
  303. btnModificarCliente.setBounds(388, 11, 135, 23);
  304. btnModificarCliente.addActionListener(new ActionListener(){
  305.  
  306. public void actionPerformed(ActionEvent e){
  307.  
  308. panel_3.setVisible(true);
  309. panel_2.setVisible(false);
  310. panel.setVisible(false);
  311. panel_4.setVisible(false);
  312. }
  313. });
  314.  
  315. btnMostrar = new JButton("Mostrar Datos");
  316. btnMostrar.setBounds(300,345,150,25);
  317. btnMostrar.addActionListener(new ActionListener(){
  318.  
  319. public void static showTables(){
  320.  
  321. try{
  322. PreparedStatement ps = (PreparedStatement) BD_Connect.Conection().prepareStatement
  323. ("select id_cliente as ID, nombre_Cliente as Cliente from Cliente");
  324.  
  325. ResultSet rs = ps.executeQuery();
  326. table.setModel(DbUtils.resultSetToTableModel(rs));
  327.  
  328. ps.close();
  329. rs.close();
  330. }
  331.  
  332. catch(Exception e){
  333. JOptionPane.showMessageDialog(null, "Exit");
  334. }
  335. }
  336. });
  337.  
  338. btnMostrar_2 = new JButton("Mostrar Datos");
  339. btnMostrar_2.setBounds(300,345,150,25);
  340.  
  341. btnMostrar_3 = new JButton("Mostrar Datos");
  342. btnMostrar_3.setBounds(300,345,150,25);
  343.  
  344. panel.add(btnMostrar);
  345. panel_3.add(btnMostrar_2);
  346. panel_4.add(btnMostrar_3);
  347.  
  348. panel_2.add(btnGuardar);
  349. panel_2.add(btnCancelar);
  350. panel_2.add(lblApP);
  351. panel_2.add(lblApM);
  352. panel_2.add(lblNombre);
  353. panel_2.add(lblCorreo);
  354. panel_2.add(lblTel);
  355. panel_2.add(lblColonia);
  356. panel_2.add(lblCalle);
  357. panel_2.add(lblNumero);
  358. panel_2.add(lblCP);
  359. panel_2.add(lblCredito);
  360. panel_2.add(lblClienteFor);
  361. panel_2.add(lblEdo);
  362. panel_2.add(lblSucursal);
  363. panel_2.add(txtApP);
  364. panel_2.add(txtApM);
  365. panel_2.add(txtCliente);
  366. panel_2.add(txtCorreo);
  367. panel_2.add(txtNombre);
  368. panel_2.add(txtTel);
  369. panel_2.add(txtColonia);
  370. panel_2.add(txtCalle);
  371. panel_2.add(txtCP);
  372. panel_2.add(txtNumero);
  373. panel_2.add(txtNoCliente);
  374. panel_2.add(txtLimite);
  375. panel_2.add(cmbEdo);
  376. panel_2.add(cmbSucursal);
  377.  
  378. panel_3.add(lblClienteMod);
  379. panel_3.add(txtClienteMod);
  380. panel_3.add(btnAceptarMod);
  381.  
  382. panel_4.add(lblClienteEli);
  383. panel_4.add(txtClienteEli);
  384. panel_4.add(btnAceptarEli);
  385.  
  386. PanelContenido.add(btnModificarCliente);
  387. PanelContenido.add(btnEliminarCliente);
  388. PanelContenido.add(btnNuevoCliente);
  389. PanelContenido.add(panel);
  390. PanelContenido.add(panel_2);
  391. PanelContenido.add(panel_3);
  392. PanelContenido.add(panel_4);
  393. PanelContenido.add(labelEtiq);
  394. PanelContenido.add(labelEtiqueta);
  395.  
  396. PanelContenido.setBackground(Color.red);
  397. panel.setBackground(Color.orange);
  398. panel_2.setBackground(Color.green);
  399. panel_3.setBackground(Color.gray);
  400. panel_4.setBackground(Color.blue);
  401.  
  402. getContentPane().add(PanelContenido);
  403. }
  404. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement