Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 118.29 KB | None | 0 0
  1. import java.awt.EventQueue;
  2.  
  3. import java.awt.Font;
  4.  
  5. import java.awt.Frame;
  6.  
  7. import javax.swing.JFrame;
  8. import javax.swing.JToolBar;
  9. import javax.swing.ListModel;
  10. import javax.swing.ListSelectionModel;
  11. import javax.swing.JPanel;
  12. import javax.swing.JComboBox;
  13. import javax.swing.JLabel;
  14. import javax.swing.JOptionPane;
  15. import javax.swing.JSeparator;
  16. import javax.swing.JTextField;
  17. import java.awt.event.ActionListener;
  18. import java.awt.event.KeyEvent;
  19. import java.awt.event.ActionEvent;
  20. import javax.swing.JButton;
  21. import java.awt.Color;
  22. import java.awt.SystemColor;
  23. import javax.swing.UIManager;
  24. import javax.swing.table.DefaultTableModel;
  25. import javax.swing.JRadioButton;
  26. import java.awt.event.MouseAdapter;
  27. import java.awt.event.MouseEvent;
  28. import java.io.FileNotFoundException;
  29. import java.io.FileOutputStream;
  30. import java.io.PrintStream;
  31. import java.sql.*;
  32. import javax.swing.JTable;
  33. import javax.swing.border.BevelBorder;
  34. import javax.swing.JTextArea;
  35. import javax.swing.DefaultComboBoxModel;
  36. import javax.swing.DefaultListModel;
  37.  
  38. import java.awt.event.KeyAdapter;
  39. import javax.swing.JScrollPane;
  40. import javax.swing.JList;
  41. import com.toedter.calendar.JCalendar;
  42. import javax.swing.JMenuBar;
  43. import javax.swing.JPopupMenu;
  44. import javax.swing.JMenuItem;
  45.  
  46. public class UI {
  47.  
  48. private JFrame frmAplicacionCooperativa;
  49. private JTextField textField;
  50. private JTextField textField_1;
  51. private JTextField textField_2;
  52. private JLabel lblCdula;
  53. private JLabel lblNewLabel;
  54. private JLabel lblApellido;
  55. private JLabel lblCelular;
  56. private JTextField textField_3;
  57. Statement stmt = null;
  58. ResultSet rs;
  59. ResultSet rs1;
  60. private JTextField textField_4;
  61. private JLabel lblquInformacinDesea;
  62. private JLabel lblIngreseLaCdula;
  63. private JTextField textField_5;
  64. private JLabel lblEscribaLaNueva;
  65. private JButton btnModificar;
  66. private JComboBox ModifyOP;
  67. private JTextField textField_6;
  68. private JPanel ViewClient;
  69. private JTextField textField_7;
  70. private JLabel lblIngreseLaCdula_1;
  71. private JLabel lblIngreseLaCdula_1_1;
  72. private JButton btnBuscar;
  73. private JLabel lblId_Cliente;
  74. private JLabel lblId_Cliente_1;
  75. private JLabel lblNombre;
  76. private JLabel lblNombre_2;
  77. private JLabel lblApellido_1;
  78. private JLabel lblApellido_1_1;
  79. private JLabel lblCelular_1;
  80. private JLabel lblCelular_1_1;
  81. private JLabel lblCargo;
  82. private JComboBox Venta;
  83. private JLabel lblIngreseIdCliente_1;
  84. private JLabel lblId_Empleado;
  85. private JLabel lblEscribaLaNueva1;
  86. private JComboBox ModifyOP1;
  87. private JButton btnModificar1;
  88. private JTextField textField_17;
  89. private JButton btnBuscar1;
  90. private JLabel lblIngreseLaCdula_11;
  91. private JLabel lblquInformacinDesea1;
  92. private JLabel lblNombreEmpleado;
  93. private JLabel lblApellido_11;
  94. private JLabel lblIngreseLaCdula1;
  95. private JTextField textField_15;
  96. private JTextField textField_16;
  97. private JLabel lblCdula1;
  98. private JTextField textField1;
  99. private JTextField textField_11;
  100. private JTextField textField_12;
  101. private JLabel lblNewLabel1;
  102. private JLabel lblApellido1;
  103. private JTextField textField_13;
  104. private JTextField textField_14;
  105. private JComboBox comboBox;
  106. private JComboBox Productos;
  107. private JTextField Barcode;
  108. private JTextField textField_8;
  109. private JTextField textField_9;
  110. private JTextField textField_10;
  111. private JScrollPane scrollPaneList;
  112. private JComboBox ModifyOP_1;
  113. private JTextField textField_18;
  114. private JLabel lblCdigoDeBarras;
  115. private JLabel lblNombre_1;
  116. private JLabel lblPrecioVenta;
  117. private JLabel lblStock;
  118. private JLabel lblId_Proveedor;
  119. private JLabel lblNombreProveedor;
  120. private JLabel lblApellidoProveedor;
  121. private JTextField textField_Proveedor;
  122. private JTextField textField_15Proveedor;
  123. private JTextField textField_7Producto;
  124. private JButton btnBuscarProducto;
  125. private JTextField textField_11Pedido;
  126. private JTextField textField_12Pedido;
  127. private JLabel lblNewLabel1Fecha;
  128. private JLabel lblValorPedido;
  129. private JTextField textField_19;
  130. private JLabel lblquInformacinDeseaPedido;
  131. private JLabel lblIngreseElIdPedido;
  132. private JTextField textField_15Pedido;
  133. private JLabel lblEscribaLaNuevaPedido;
  134. private JComboBox ModifyOP1Pedido;
  135. private JTextField textField_16Pedido;
  136. private JButton btnModificar1Pedido;
  137. private JTextField textField_14Pedido;
  138. private JLabel lblId_Pedido;
  139. private JLabel lblNombrePedido;
  140. private JLabel lblApellido_11Pedido;
  141. private JScrollPane scrollPanePedido;
  142. protected JList listEmpleados;
  143. protected JLabel textField_19Venta;
  144. private JTextField textField_19Vent;
  145. private JLabel lblIngreseElValor;
  146. private JLabel lblSeleccioneElEmpleado;
  147. private JLabel lblSeleccioneProductosQue;
  148. private JTextField textField_20;
  149. private JLabel lblInserteCdulaDel;
  150. private JScrollPane scrollPane;
  151. private JScrollPane scrollPane_1;
  152. private JScrollPane scrollPane_DetalleVenta;
  153. private JTextField textField_21;
  154. private JTextField textField_22;
  155.  
  156. /**
  157. * Launch the application.
  158. */
  159. public static void main(String[] args) {
  160. EventQueue.invokeLater(new Runnable() {
  161. public void run() {
  162. try {
  163. UI window = new UI();
  164. window.frmAplicacionCooperativa.setVisible(true);
  165. } catch (Exception e) {
  166. e.printStackTrace();
  167. }
  168. }
  169. });
  170. }
  171.  
  172. /**
  173. * Create the application.
  174. * @throws SQLException
  175. */
  176. public UI() throws SQLException {
  177. initialize();
  178. }
  179.  
  180. /**
  181. * Initialize the contents of the frame.
  182. * @throws SQLException
  183. */
  184. private void initialize() throws SQLException {
  185.  
  186. try{
  187. java.sql.Connection connection = null;
  188. //Este es el string de conexión para Oracle Express 11gR2
  189. connection = DriverManager.getConnection(
  190. "jdbc:oracle:thin:@localhost:1521:xe", "tiendaescolar", "Oraclemichael");
  191.  
  192. //Este es el string de conexión para Oracle 12C
  193. //Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:Orcl","system","Victor");
  194.  
  195. stmt = connection.createStatement();
  196. rs = null;
  197. //ejempleProfe(rs, stmt, i, id, nombre);
  198. }
  199. catch(Exception e){
  200. System.out.println(e);
  201. }
  202.  
  203. DefaultListModel modelo= new DefaultListModel();
  204. DefaultListModel modeloPedido= new DefaultListModel();
  205. DefaultListModel modeloVenta= new DefaultListModel();
  206. DefaultListModel modeloVentaP= new DefaultListModel();
  207. DefaultListModel modeloVerPedido= new DefaultListModel();
  208. DefaultListModel modeloMostrarVenta= new DefaultListModel();
  209. DefaultListModel modeloMostrarDetalleV= new DefaultListModel();
  210. DefaultListModel modeloModifyVenta= new DefaultListModel();
  211. DefaultListModel modeloModifyDetalleV= new DefaultListModel();
  212.  
  213. frmAplicacionCooperativa = new JFrame();
  214. frmAplicacionCooperativa.setTitle("Aplicacion Cooperativa");
  215. frmAplicacionCooperativa.setBounds(100, 100, 506, 336);
  216. frmAplicacionCooperativa.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  217. frmAplicacionCooperativa.getContentPane().setLayout(null);
  218.  
  219. JPanel ModifyVenta = new JPanel();
  220. ModifyVenta.setBackground(new Color(192, 192, 192));
  221. ModifyVenta.setBounds(0, 23, 497, 274);
  222. frmAplicacionCooperativa.getContentPane().add(ModifyVenta);
  223. ModifyVenta.setLayout(null);
  224.  
  225. JCalendar calendarModifyVenta = new JCalendar();
  226. calendarModifyVenta.setTodayButtonVisible(true);
  227. calendarModifyVenta.setBounds(10, 44, 184, 155);
  228. ModifyVenta.add(calendarModifyVenta);
  229.  
  230. JScrollPane scrollPane_ModifyVentas = new JScrollPane();
  231. scrollPane_ModifyVentas.setBounds(250, 29, 214, 80);
  232. ModifyVenta.add(scrollPane_ModifyVentas);
  233.  
  234. JList listModifyVentas = new JList();
  235. scrollPane_ModifyVentas.setViewportView(listModifyVentas);
  236. listModifyVentas.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  237. listModifyVentas.setModel(modeloModifyVenta);
  238.  
  239. JLabel lblSeleccioneLaFecha_1Modify = new JLabel("Seleccione la fecha de la venta \r\n\r\na modificar");
  240. lblSeleccioneLaFecha_1Modify.setBounds(10, 17, 160, 16);
  241. ModifyVenta.add(lblSeleccioneLaFecha_1Modify);
  242. textField_21 = new JTextField();
  243. textField_21.setBounds(378, 147, 86, 20);
  244. ModifyVenta.add(textField_21);
  245. textField_21.setColumns(10);
  246.  
  247. JLabel lblNewLabel_1 = new JLabel("Cedula del Cliente:");
  248. lblNewLabel_1.setBounds(271, 147, 111, 14);
  249. ModifyVenta.add(lblNewLabel_1);
  250.  
  251. JLabel lblValorPagado = new JLabel("Valor Pagado:");
  252. lblValorPagado.setBounds(298, 170, 79, 14);
  253. ModifyVenta.add(lblValorPagado);
  254.  
  255.  
  256. JScrollPane scrollPaneModidyDetalleVenta = new JScrollPane();
  257. scrollPaneModidyDetalleVenta.setBounds(170, 213, 225, 60);
  258. ModifyVenta.add(scrollPaneModidyDetalleVenta);
  259.  
  260. JList listModifyDetalleVenta = new JList();
  261. scrollPaneModidyDetalleVenta.setViewportView(listModifyDetalleVenta);
  262. listModifyDetalleVenta.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  263. listModifyDetalleVenta.setModel(modeloModifyDetalleV);
  264.  
  265.  
  266. JLabel lblSeleccioneLasTransaciones = new JLabel("Seleccione las transaciones a modificar:");
  267. lblSeleccioneLasTransaciones.setBounds(170, 195, 199, 14);
  268. ModifyVenta.add(lblSeleccioneLasTransaciones);
  269.  
  270. textField_22 = new JTextField();
  271. textField_22.setBounds(378, 167, 86, 20);
  272. ModifyVenta.add(textField_22);
  273. textField_22.setColumns(10);
  274. JLabel lblVentasDelDiaModify = new JLabel("Seleccione la venta a modificar");
  275. lblVentasDelDiaModify.setBounds(250, 11, 214, 16);
  276. ModifyVenta.add(lblVentasDelDiaModify);
  277.  
  278. JButton btnBuscarPorFechaModify = new JButton("Buscar");
  279. btnBuscarPorFechaModify.addActionListener(new ActionListener() {
  280. public void actionPerformed(ActionEvent arg0) {
  281. String Fecha_ModifyVenta=calendarModifyVenta.getDayChooser().getDay()+"-"+((calendarModifyVenta.getMonthChooser().getMonth())+1)+"-"+(calendarModifyVenta.getYearChooser().getYear());
  282. try {
  283. modeloModifyDetalleV.clear();
  284. modeloModifyVenta.clear();
  285. modeloModifyVenta.addElement("Id_Venta-----FechaVenta-----Valor_Venta-----Valor_Pagado-----Id_Empleado-----Id_Cliente");
  286. rs=stmt.executeQuery("SELECT * FROM VENTA WHERE \"FechaVenta\"=TO_DATE ('"+Fecha_ModifyVenta+"','DD-MM-YYYY')");
  287. while(rs.next()) {
  288. String Id_Venta=rs.getString("Id_Venta");
  289. String FechaVenta=rs.getString("FechaVenta");
  290. int Valor_Venta=rs.getInt("Valor_Venta");
  291. int Valor_Pagado=rs.getInt("Valor_Pagado");
  292. String Id_Empleado=rs.getString("Id_Empleado");
  293. String Id_Cliente=rs.getString("Id_Cliente");
  294. modeloModifyVenta.addElement(Id_Venta+"-----"+FechaVenta+"-----"+Valor_Venta+"-----"+Valor_Pagado+"-----"+Id_Empleado+"-----"+Id_Cliente);
  295. }
  296. } catch (SQLException e1) {
  297. // TODO Auto-generated catch block
  298. e1.printStackTrace();
  299. }
  300. }
  301. });
  302. btnBuscarPorFechaModify.setBounds(35, 210, 97, 25);
  303. ModifyVenta.add(btnBuscarPorFechaModify);
  304.  
  305. JLabel lblTransaccionesDeLaModify = new JLabel("Valores a modificar:");
  306. lblTransaccionesDeLaModify.setBounds(204, 132, 235, 16);
  307. ModifyVenta.add(lblTransaccionesDeLaModify);
  308.  
  309. JButton btnBuscarVentasModify = new JButton("Ver Transaciones");
  310. btnBuscarVentasModify.addActionListener(new ActionListener() {
  311. public void actionPerformed(ActionEvent e) {
  312. modeloModifyDetalleV.clear();
  313. String p= listModifyVentas.getSelectedValue().toString();
  314. String[] pValues=p.split("-----");
  315.  
  316. textField_21.setText(pValues[5]);
  317. textField_22.setText(pValues[3]);
  318. modeloModifyDetalleV.addElement("Id_DetalleVenta-----Desc_Producto-----Cantidad-----Costo_Total-----Id_Producto-----Id_Venta");
  319. try {
  320. rs=stmt.executeQuery("SELECT * FROM DETALLE_VENTA WHERE \"Id_Venta\"="+pValues[0]);
  321. while(rs.next()) {
  322. String Id_DetalleVenta=rs.getString("Id_DetalleVenta");
  323. String Desc_Producto=rs.getString("Desc_Producto");
  324. int Cantidad=rs.getInt("Cantidad");
  325. int Costo_Total=rs.getInt("Costo_Total");
  326. String Id_Producto=rs.getString("Id_Producto");
  327. String Id_Venta=rs.getString("Id_Venta");
  328. modeloModifyDetalleV.addElement(Id_DetalleVenta+"-----"+Desc_Producto+"-----"+Cantidad+"-----"+Costo_Total+"-----"+Id_Producto+"-----"+Id_Venta);
  329. }
  330.  
  331. } catch (SQLException e1) {
  332. // TODO Auto-generated catch block
  333. e1.printStackTrace();
  334. }
  335.  
  336. }
  337. });
  338. btnBuscarVentasModify.setBounds(288, 111, 123, 25);
  339. ModifyVenta.add(btnBuscarVentasModify);
  340.  
  341.  
  342.  
  343. JButton btnNewButton = new JButton("Modificar");
  344. btnNewButton.addActionListener(new ActionListener() {
  345. public void actionPerformed(ActionEvent arg0) {
  346. String dv= listModifyDetalleVenta.getSelectedValue().toString();
  347. String[] pDetalleValues=dv.split("-----");
  348. String p= listModifyVentas.getSelectedValue().toString();
  349. String[] pValues=p.split("-----");
  350.  
  351. try {
  352. double precio=0;
  353. rs = stmt.executeQuery("select \"Precio_Unitario\" from producto where \"Id_Producto\"="+Integer.parseInt(pDetalleValues[4]));
  354.  
  355. if (rs.next()) {
  356. precio= rs.getInt("Precio_Unitario");
  357. }
  358.  
  359. int cantidad= Interface.recibirEntero("Ingrese la cantidad del producto: ");
  360. rs=stmt.executeQuery("delete from DETALLE_VENTA WHERE \"Id_DetalleVenta\"="+pDetalleValues[0]);
  361. Detalle_Venta dp=new Detalle_Venta(Integer.parseInt(pDetalleValues[0]), pDetalleValues[1], cantidad, precio*cantidad, Integer.parseInt(pDetalleValues[4]), Integer.parseInt(pValues[0]));
  362. dp.añadirDetalleVenta(stmt);
  363. rs=stmt.executeQuery("SELECT SUM(\"Costo_Total\") FROM DETALLE_VENTA WHERE \"Id_Venta\"="+pValues[0]);
  364. String Valor_Venta="";
  365. if (rs.next()) {
  366. Valor_Venta=rs.getString("SUM(\"Costo_Total\")");
  367. }
  368. rs=stmt.executeQuery("update venta set \"Id_Cliente\"="+textField_21.getText()+" where \"Id_Venta\"="+pValues[0]);
  369. rs=stmt.executeQuery("update venta set \"Valor_Pagado\"="+textField_22.getText()+" where \"Id_Venta\"="+pValues[0]);
  370. rs=stmt.executeQuery("update venta set \"Valor_Venta\"="+Valor_Venta+" where \"Id_Venta\"="+pValues[0]);
  371. Interface.imprimir("Venta Modificada con exito");
  372. } catch (SQLException e1) {
  373. // TODO Auto-generated catch block
  374. e1.printStackTrace();
  375. }
  376. }
  377. });
  378. btnNewButton.setBounds(398, 240, 89, 23);
  379. ModifyVenta.add(btnNewButton);
  380.  
  381. JPanel panel = new JPanel();
  382. panel.setBounds(0, 23, 497, 274);
  383. frmAplicacionCooperativa.getContentPane().add(panel);
  384. panel.setBackground(Color.BLACK);
  385. panel.setLayout(null);
  386. panel.setVisible(true);
  387.  
  388. JLabel lblTienndaEscolar = new JLabel("Cooperativa");
  389. lblTienndaEscolar.setForeground(Color.WHITE);
  390. lblTienndaEscolar.setFont(new Font("Comic Sans MS", Font.PLAIN, 40));
  391. lblTienndaEscolar.setBounds(128, 80, 267, 92);
  392. panel.add(lblTienndaEscolar);
  393.  
  394. JLabel lblSteveenDominguez = new JLabel("Steveen Dominguez");
  395. lblSteveenDominguez.setForeground(Color.LIGHT_GRAY);
  396. lblSteveenDominguez.setBounds(10, 249, 153, 14);
  397. panel.add(lblSteveenDominguez);
  398.  
  399. JLabel lblMichaelRivera = new JLabel("Michael Rivera");
  400. lblMichaelRivera.setForeground(Color.LIGHT_GRAY);
  401. lblMichaelRivera.setBounds(10, 236, 99, 14);
  402. panel.add(lblMichaelRivera);
  403.  
  404. //MostrarVenta
  405. JPanel MostrarVenta = new JPanel();
  406. MostrarVenta.setBackground(new Color(192, 192, 192));
  407. MostrarVenta.setBounds(0, 23, 497, 274);
  408. frmAplicacionCooperativa.getContentPane().add(MostrarVenta);
  409. MostrarVenta.setLayout(null);
  410.  
  411. JCalendar calendarMostrarVenta = new JCalendar();
  412. calendarMostrarVenta.setBounds(23, 48, 184, 155);
  413. MostrarVenta.add(calendarMostrarVenta);
  414.  
  415. JScrollPane scrollPane_Ventas = new JScrollPane();
  416. scrollPane_Ventas.setBounds(250, 39, 214, 64);
  417. MostrarVenta.add(scrollPane_Ventas);
  418.  
  419. JList listVentas = new JList();
  420. scrollPane_Ventas.setViewportView(listVentas);
  421. listVentas.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  422. listVentas.setModel(modeloMostrarVenta);
  423.  
  424. JLabel lblSeleccioneLaFecha_1 = new JLabel("Seleccione la fecha, y si desea");
  425. lblSeleccioneLaFecha_1.setBounds(23, 13, 184, 16);
  426. MostrarVenta.add(lblSeleccioneLaFecha_1);
  427.  
  428. JLabel lblYSiDesea = new JLabel("Las transacciones de cada una");
  429. lblYSiDesea.setBounds(23, 30, 184, 16);
  430. MostrarVenta.add(lblYSiDesea);
  431.  
  432. JLabel lblVentasDelDia = new JLabel("Ventas del dia seleccionado");
  433. lblVentasDelDia.setBounds(250, 13, 214, 16);
  434. MostrarVenta.add(lblVentasDelDia);
  435.  
  436. JButton btnBuscarPorFecha = new JButton("Buscar");
  437. btnBuscarPorFecha.addActionListener(new ActionListener() {
  438. public void actionPerformed(ActionEvent arg0) {
  439. String Fecha_Venta=calendarMostrarVenta.getDayChooser().getDay()+"-"+((calendarMostrarVenta.getMonthChooser().getMonth())+1)+"-"+(calendarMostrarVenta.getYearChooser().getYear());
  440. try {
  441. modeloMostrarDetalleV.clear();
  442. modeloMostrarVenta.clear();
  443. modeloMostrarVenta.addElement("Id_Venta-----FechaVenta-----Valor_Venta-----Valor_Pagado-----Id_Empleado-----Id_Cliente");
  444. rs=stmt.executeQuery("SELECT * FROM VENTA WHERE \"FechaVenta\"=TO_DATE ('"+Fecha_Venta+"','DD-MM-YYYY')");
  445. while(rs.next()) {
  446. String Id_Venta=rs.getString("Id_Venta");
  447. String FechaVenta=rs.getString("FechaVenta");
  448. int Valor_Venta=rs.getInt("Valor_Venta");
  449. int Valor_Pagado=rs.getInt("Valor_Pagado");
  450. String Id_Empleado=rs.getString("Id_Empleado");
  451. String Id_Cliente=rs.getString("Id_Cliente");
  452. modeloMostrarVenta.addElement(Id_Venta+"-----"+FechaVenta+"-----"+Valor_Venta+"-----"+Valor_Pagado+"-----"+Id_Empleado+"-----"+Id_Cliente);
  453. }
  454. } catch (SQLException e1) {
  455. // TODO Auto-generated catch block
  456. e1.printStackTrace();
  457. }
  458. }
  459. });
  460. btnBuscarPorFecha.setBounds(66, 216, 97, 25);
  461. MostrarVenta.add(btnBuscarPorFecha);
  462.  
  463. JLabel lblTransaccionesDeLa = new JLabel("Transacciones de la venta seleccionada");
  464. lblTransaccionesDeLa.setBounds(250, 150, 235, 16);
  465. MostrarVenta.add(lblTransaccionesDeLa);
  466.  
  467. scrollPane_DetalleVenta = new JScrollPane();
  468. scrollPane_DetalleVenta.setBounds(250, 179, 214, 62);
  469. MostrarVenta.add(scrollPane_DetalleVenta);
  470.  
  471. JList listDetalleVenta = new JList();
  472. scrollPane_DetalleVenta.setViewportView(listDetalleVenta);
  473. listDetalleVenta.setModel(modeloMostrarDetalleV);
  474.  
  475. JButton btnBuscarVentas = new JButton("Buscar Ventas");
  476. btnBuscarVentas.addActionListener(new ActionListener() {
  477. public void actionPerformed(ActionEvent e) {
  478. modeloMostrarDetalleV.clear();
  479. String p= listVentas.getSelectedValue().toString();
  480. String[] pValues=p.split("-----");
  481. modeloMostrarDetalleV.addElement("Id_DetalleVenta-----Desc_Producto-----Cantidad-----Costo_Total-----Id_Producto-----Id_Venta");
  482. try {
  483. rs=stmt.executeQuery("SELECT * FROM DETALLE_VENTA WHERE \"Id_Venta\"="+pValues[0]);
  484. while(rs.next()) {
  485. String Id_DetalleVenta=rs.getString("Id_DetalleVenta");
  486. String Desc_Producto=rs.getString("Desc_Producto");
  487. int Cantidad=rs.getInt("Cantidad");
  488. int Costo_Total=rs.getInt("Costo_Total");
  489. String Id_Producto=rs.getString("Id_Producto");
  490. String Id_Venta=rs.getString("Id_Venta");
  491. modeloMostrarDetalleV.addElement(Id_DetalleVenta+"-----"+Desc_Producto+"-----"+Cantidad+"-----"+Costo_Total+"-----"+Id_Producto+"-----"+Id_Venta);
  492. }
  493. } catch (SQLException e1) {
  494. // TODO Auto-generated catch block
  495. e1.printStackTrace();
  496. }
  497.  
  498. }
  499. });
  500. btnBuscarVentas.setBounds(289, 112, 123, 25);
  501. MostrarVenta.add(btnBuscarVentas);
  502.  
  503.  
  504. JPanel ViewPedido = new JPanel();
  505. ViewPedido.setBackground(new Color(192, 192, 192));
  506. ViewPedido.setBounds(0, 23, 497, 274);
  507. frmAplicacionCooperativa.getContentPane().add(ViewPedido);
  508. ViewPedido.setLayout(null);
  509.  
  510.  
  511. lblIngreseLaCdula_11 = new JLabel("Lista de pedidos hechos hasta el momento");
  512. lblIngreseLaCdula_11.setFont(new Font("Tahoma", Font.BOLD, 14));
  513. lblIngreseLaCdula_11.setBounds(12, 30, 309, 16);
  514. ViewPedido.add(lblIngreseLaCdula_11);
  515.  
  516. lblId_Pedido = new JLabel("Id_Pedido");
  517. lblId_Pedido.setBounds(12, 84, 84, 16);
  518. ViewPedido.add(lblId_Pedido);
  519.  
  520. lblNombrePedido = new JLabel("Fecha");
  521. lblNombrePedido.setBounds(87, 84, 56, 16);
  522. ViewPedido.add(lblNombrePedido);
  523.  
  524. lblApellido_11Pedido = new JLabel("Costo");
  525. lblApellido_11Pedido.setBounds(153, 84, 56, 16);
  526. ViewPedido.add(lblApellido_11Pedido);
  527.  
  528. JScrollPane scrollPane_listPedido = new JScrollPane();
  529. scrollPane_listPedido.setBounds(12, 100, 475, 163);
  530. ViewPedido.add(scrollPane_listPedido);
  531.  
  532. JList listVerPedido = new JList();
  533. scrollPane_listPedido.setViewportView(listVerPedido);
  534. listVerPedido.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  535. listVerPedido.setModel(modeloVerPedido);
  536.  
  537. JLabel lblEmpleadoQueLo = new JLabel("Empleado que lo pid\u00EDo");
  538. lblEmpleadoQueLo.setBounds(208, 85, 128, 14);
  539. ViewPedido.add(lblEmpleadoQueLo);
  540.  
  541. JLabel lblProveedorContratado = new JLabel("Proveedor contratado");
  542. lblProveedorContratado.setBounds(346, 85, 138, 14);
  543. ViewPedido.add(lblProveedorContratado);
  544. JPanel AddPedido = new JPanel();
  545. AddPedido.setBackground(new Color(192, 192, 192));
  546. AddPedido.setBounds(0, 23, 497, 274);
  547. frmAplicacionCooperativa.getContentPane().add(AddPedido);
  548. AddPedido.setLayout(null);
  549.  
  550. scrollPanePedido = new JScrollPane();
  551. scrollPanePedido.setBounds(194, 27, 293, 143);
  552. AddPedido.add(scrollPanePedido);
  553. JList productListPedido = new JList();
  554. scrollPanePedido.setViewportView(productListPedido);
  555. productListPedido.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  556. productListPedido.setModel(modeloPedido);
  557. productListPedido.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  558.  
  559. textField_11Pedido = new JTextField();
  560. textField_11Pedido.setBounds(21, 224, 82, 22);
  561. AddPedido.add(textField_11Pedido);
  562. textField_11Pedido.setColumns(10);
  563. AddPedido.setVisible(false);
  564. textField_11Pedido.setEditable(false);
  565.  
  566. textField_12Pedido = new JTextField();
  567. textField_12Pedido.setBounds(224, 200, 101, 22);
  568. AddPedido.add(textField_12Pedido);
  569. textField_12Pedido.setColumns(10);
  570.  
  571.  
  572. lblNewLabel1Fecha = new JLabel("Seleccione la fecha: ");
  573. lblNewLabel1Fecha.setBounds(10, 0, 116, 16);
  574. AddPedido.add(lblNewLabel1Fecha);
  575.  
  576. lblValorPedido = new JLabel("Valor Pedido: ");
  577. lblValorPedido.setBounds(21, 203, 93, 16);
  578. AddPedido.add(lblValorPedido);
  579.  
  580. JButton btnAgregarPedido = new JButton("Agregar Pedido");
  581. btnAgregarPedido.setBounds(360, 223, 127, 25);
  582. AddPedido.add(btnAgregarPedido);
  583.  
  584. JLabel lblIdcliente = new JLabel("Id_Empleado:");
  585. lblIdcliente.setBounds(139, 204, 82, 14);
  586. AddPedido.add(lblIdcliente);
  587.  
  588. JLabel lblIdProveedor = new JLabel("Id Proveedor:");
  589. lblIdProveedor.setBounds(137, 246, 84, 14);
  590. AddPedido.add(lblIdProveedor);
  591.  
  592. textField_19 = new JTextField();
  593. textField_19.setBounds(224, 243, 101, 20);
  594. AddPedido.add(textField_19);
  595. textField_19.setColumns(10);
  596.  
  597. JCalendar calendarPedido = new JCalendar();
  598. calendarPedido.setTodayButtonVisible(true);
  599. calendarPedido.setBounds(0, 17, 184, 153);
  600. AddPedido.add(calendarPedido);
  601.  
  602. JLabel lblListaDeProductos = new JLabel("Lista de productos");
  603. lblListaDeProductos.setBounds(194, 11, 131, 14);
  604. AddPedido.add(lblListaDeProductos);
  605. btnAgregarPedido.addMouseListener(new MouseAdapter() {
  606. @Override
  607. public void mouseClicked(MouseEvent e) {
  608. textField_11Pedido.setText("");
  609. try {
  610. int id_Pedido=countId("pedido", stmt, rs)+1;
  611. System.out.println(","+id_Pedido+","+calendarPedido.getDayChooser().getDay()+","+calendarPedido.getMonthChooser().getMonth()+","+calendarPedido.getYearChooser().getYear()+","+0+","+textField_12Pedido.getText()+","+textField_19.getText());
  612. Pedido c= new Pedido(id_Pedido,(calendarPedido.getDayChooser().getDay()),(calendarPedido.getMonthChooser().getMonth()+1),(calendarPedido.getYearChooser().getYear()),0,Integer.parseInt(textField_12Pedido.getText()),Integer.parseInt(textField_19.getText()));
  613. c.añadirPedido(stmt);
  614. Object [] p= productListPedido.getSelectedValues();
  615. int [] pIndex= productListPedido.getSelectedIndices();
  616. int sum=0;
  617. for(int i=0;i<pIndex.length;i++) {
  618. String pedido= p[i].toString();
  619. String[] DataPedido= pedido.split("-----");
  620. int Cantidad=Integer.parseInt(JOptionPane.showInputDialog(null, "Ingrese la cantidad que pedirá"));
  621. int Costo_Total= Cantidad*(Integer.parseInt(DataPedido[2]));
  622. System.out.println("insert into detalle_pedido values("+(countId("detalle_pedido", stmt, rs)+1)+","+Cantidad+","+Costo_Total+",'"+DataPedido[1]+"',"+DataPedido[0]+","+id_Pedido+")");
  623. rs=stmt.executeQuery("insert into detalle_pedido values("+(countId("detalle_pedido", stmt, rs)+1)+","+Cantidad+","+Costo_Total+",'"+DataPedido[1]+"',"+DataPedido[0]+","+id_Pedido+")");
  624. sum+=Costo_Total;
  625. }
  626. textField_11Pedido.setText(""+sum);
  627. rs=stmt.executeQuery("update pedido set \"Valor_Pedido\"="+sum+" where \"Id_Pedido\"="+id_Pedido);
  628. JOptionPane.showMessageDialog(null, "Ha guardado un Pedido satisfactoriamente");
  629. textField_12Pedido.setText("");
  630. textField_19.setText("");
  631. }catch (SQLException e1) {
  632. e1.printStackTrace();
  633. System.out.println("acc "+e1);
  634. Interface.imprimir("Error a la hora de hacer pedido, porfavor intente de nuevo :\n"+e1);
  635. }
  636. }
  637. });
  638.  
  639.  
  640. JPanel AddVenta = new JPanel();
  641. AddVenta.setBounds(0, 23, 497, 274);
  642. frmAplicacionCooperativa.getContentPane().add(AddVenta);
  643. AddVenta.setBackground(new Color(192, 192, 192));
  644. AddVenta.setLayout(null);
  645.  
  646. textField_19Vent = new JTextField();
  647. textField_19Vent.setBounds(244, 249, 116, 22);
  648. AddVenta.add(textField_19Vent);
  649. textField_19Vent.setColumns(10);
  650.  
  651. lblIngreseElValor = new JLabel("Ingrese el valor \r\nque pagaron en total");
  652. lblIngreseElValor.setBounds(247, 230, 218, 16);
  653. AddVenta.add(lblIngreseElValor);
  654.  
  655. scrollPane = new JScrollPane();
  656. scrollPane.setBounds(244, 49, 244, 87);
  657. AddVenta.add(scrollPane);
  658.  
  659. listEmpleados = new JList();
  660. scrollPane.setViewportView(listEmpleados);
  661. listEmpleados.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  662. listEmpleados.setModel(modeloVenta);
  663.  
  664. lblSeleccioneElEmpleado = new JLabel("Seleccione el empleado que vendi\u00F3");
  665. lblSeleccioneElEmpleado.setBounds(239, 22, 218, 16);
  666. AddVenta.add(lblSeleccioneElEmpleado);
  667.  
  668. lblSeleccioneProductosQue = new JLabel("Seleccione Productos que vendi\u00F3");
  669. lblSeleccioneProductosQue.setBounds(12, 194, 218, 16);
  670. AddVenta.add(lblSeleccioneProductosQue);
  671.  
  672. textField_20 = new JTextField();
  673. textField_20.setBounds(244, 206, 116, 22);
  674. AddVenta.add(textField_20);
  675. textField_20.setColumns(10);
  676.  
  677. lblInserteCdulaDel = new JLabel("Inserte c\u00E9dula del cliente");
  678. lblInserteCdulaDel.setBounds(242, 187, 167, 16);
  679. AddVenta.add(lblInserteCdulaDel);
  680.  
  681. scrollPane_1 = new JScrollPane();
  682. scrollPane_1.setBounds(12, 209, 214, 54);
  683. AddVenta.add(scrollPane_1);
  684.  
  685. JList listaVentaP = new JList();
  686. scrollPane_1.setViewportView(listaVentaP);
  687. listaVentaP.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
  688. listaVentaP.setModel(modeloVentaP);
  689. listaVentaP.setVisible(true);
  690.  
  691. JCalendar calendarVenta = new JCalendar();
  692. calendarVenta.setTodayButtonVisible(true);
  693. calendarVenta.setBounds(12, 28, 184, 155);
  694. AddVenta.add(calendarVenta);
  695.  
  696. //listEmpleados;
  697.  
  698. JButton btnAadirVenta = new JButton("A\u00F1adir Venta");
  699. btnAadirVenta.addActionListener(new ActionListener() {
  700.  
  701.  
  702. public void actionPerformed(ActionEvent arg0) {
  703. try {
  704. String registro=listEmpleados.getSelectedValue().toString();
  705. System.out.println("ww "+registro);
  706. String temp[]=registro.split(" ");
  707. String Id_Empleado=temp[0];
  708. Object[] seleccionVenta=listaVentaP.getSelectedValues();
  709. int[] seleccionIndexVenta=listaVentaP.getSelectedIndices();
  710. //if() {
  711. //Interface.imprimir("Lo sentimos pero al parecer tienes ");
  712. //}
  713.  
  714. int Id_Venta=0;
  715. rs=stmt.executeQuery("SELECT COUNT(\"Id_Venta\") FROM VENTA");
  716. if (rs.next()) {
  717. Id_Venta=rs.getInt("COUNT(\"Id_Venta\")");
  718. Id_Venta++;
  719. }
  720. String Valor_Pagado=textField_19Vent.getText().toString();
  721. String Id_Cliente= textField_20.getText().toString();
  722. rs=stmt.executeQuery("INSERT INTO VENTA VALUES("+Id_Venta+",Date '"+(calendarVenta.getYearChooser().getYear())+"-"+(calendarVenta.getMonthChooser().getMonth()+1)+"-"+calendarVenta.getDayChooser().getDay()+"'"+","+0+","+Valor_Pagado+","+Id_Empleado+","+Id_Cliente+")");
  723.  
  724. //Creacion de Detalle-factura
  725.  
  726. rs=stmt.executeQuery("SELECT COUNT(\"Id_DetalleVenta\") FROM DETALLE_VENTA");
  727. int autoIdDetalle=0;
  728. if (rs.next()) {
  729. autoIdDetalle=rs.getInt("COUNT(\"Id_DetalleVenta\")");
  730. autoIdDetalle++;
  731. }
  732. for (int i=0; i<listaVentaP.getSelectedIndices().length;i++) {
  733. String temp1=seleccionVenta[i].toString();
  734. System.out.println(temp1);
  735. String[] DataVentaP=temp1.split(" ");
  736. int Cantidad=Integer.parseInt(JOptionPane.showInputDialog(null, "Ingrese la cantidad que venderá"));
  737. System.out.println("xaxs "+Cantidad);
  738. System.out.println(DataVentaP[2]);
  739. int Costo_Total=Cantidad*(Integer.parseInt(DataVentaP[2]));
  740. System.out.println("INSERT INTO DETALLE_VENTA VALUES ("+autoIdDetalle+",'"+DataVentaP[1]+"',"+Cantidad+","+Costo_Total+","+DataVentaP[0]+","+Id_Venta+")");
  741. rs=stmt.executeQuery("INSERT INTO DETALLE_VENTA VALUES ("+autoIdDetalle+",'"+DataVentaP[1]+"',"+Cantidad+","+Costo_Total+","+DataVentaP[0]+","+Id_Venta+")");
  742. autoIdDetalle++;
  743. rs=stmt.executeQuery("UPDATE PRODUCTO SET \"Stock\"=\"Stock\"-"+Cantidad+" WHERE \"Id_Producto\"="+DataVentaP[0]);
  744. }
  745. //Creacion de Venta
  746.  
  747. System.out.println("SELECT SUM(\"Costo_Total\") FROM DETALLE_VENTA WHERE \"Id_Venta\"="+Id_Venta);
  748. rs=stmt.executeQuery("SELECT SUM(\"Costo_Total\") FROM DETALLE_VENTA WHERE \"Id_Venta\"="+Id_Venta);
  749. String Valor_Venta="";
  750. if (rs.next()) {
  751. Valor_Venta=rs.getString("SUM(\"Costo_Total\")");
  752. }
  753. rs=stmt.executeQuery("update venta set \"Valor_Venta\"="+Valor_Venta+" where \"Id_Venta\"="+Id_Venta);
  754.  
  755. }catch (SQLException e) {
  756. // TODO Auto-generated catch block
  757. e.printStackTrace();
  758. }
  759. }
  760. });
  761. btnAadirVenta.setBounds(372, 248, 118, 25);
  762. AddVenta.add(btnAadirVenta);
  763. JLabel lblSeleccioneLaFecha = new JLabel("Seleccione la fecha de la venta");
  764. lblSeleccioneLaFecha.setBounds(12, 11, 185, 16);
  765. AddVenta.add(lblSeleccioneLaFecha);
  766.  
  767. JPanel RemovePedido = new JPanel();
  768. RemovePedido.setBounds(0, 23, 497, 230);
  769. frmAplicacionCooperativa.getContentPane().add(RemovePedido);
  770. RemovePedido.setBackground(new Color(192, 192, 192));
  771. RemovePedido.setLayout(null);
  772.  
  773. JLabel lblBuscarPedidoPor = new JLabel("Buscar Pedido por N\u00FAmero de C\u00E9dula");
  774. lblBuscarPedidoPor.setBounds(12, 31, 247, 16);
  775. RemovePedido.add(lblBuscarPedidoPor);
  776.  
  777. textField_14Pedido = new JTextField();
  778. textField_14Pedido.setBounds(12, 60, 116, 22);
  779. RemovePedido.add(textField_14Pedido);
  780. textField_14Pedido.setColumns(10);
  781.  
  782. JButton btnEliminarPedido = new JButton("Eliminar ");
  783. btnEliminarPedido.addActionListener(new ActionListener() {
  784. public void actionPerformed(ActionEvent e) {
  785. int tempIdVenta=0;
  786. if(JOptionPane.showConfirmDialog(null, "¿Está seguro de borrar a su Pedido identificado como"+textField_14Pedido.getText()+"? Se pondrá triste :(", "Confirmar", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.OK_OPTION) {
  787. try {
  788. rs= stmt.executeQuery("SELECT \"Id_Venta\" FROM VENTA WHERE \"Id_Pedido\"="+textField_14Pedido.getText()+"");
  789. while (rs.next()){
  790. tempIdVenta=rs.getInt("Id_Venta");
  791. }
  792. rs=stmt.executeQuery("DELETE FROM DETALLE_VENTA WHERE \"Id_Venta\"="+tempIdVenta+"");
  793. rs=stmt.executeQuery("DELETE FROM VENTA WHERE \"Id_Pedido\"="+textField_14Pedido.getText()+"");
  794. rs=stmt.executeQuery("DELETE FROM Pedido WHERE \"Id_Pedido\"="+textField_14Pedido.getText()+"");
  795. JOptionPane.showMessageDialog(null, "Pedido eliminado correctamente");
  796. } catch (SQLException e1) {
  797. // TODO Auto-generated catch block
  798. e1.printStackTrace();
  799. }
  800. }else {
  801. }
  802. textField_14Pedido.setText("");
  803. }
  804. });
  805. btnEliminarPedido.setBounds(12, 128, 97, 25);
  806. RemovePedido.add(btnEliminarPedido);
  807.  
  808.  
  809. JPanel ModifyPedido = new JPanel();
  810. ModifyPedido.setBackground(new Color(192, 192, 192));
  811. ModifyPedido.setBounds(0, 23, 497, 274);
  812. frmAplicacionCooperativa.getContentPane().add(ModifyPedido);
  813. ModifyPedido.setLayout(null);
  814. ModifyPedido.setVisible(false);
  815.  
  816. lblquInformacinDeseaPedido = new JLabel("\u00BFQu\u00E9 informaci\u00F3n desea editar?");
  817. lblquInformacinDeseaPedido.setBounds(12, 92, 240, 16);
  818. ModifyPedido.add(lblquInformacinDeseaPedido);
  819.  
  820. lblIngreseElIdPedido = new JLabel("Ingrese el Id del Pedido");
  821. lblIngreseElIdPedido.setBounds(12, 29, 180, 16);
  822. ModifyPedido.add(lblIngreseElIdPedido);
  823.  
  824. textField_15Pedido = new JTextField();
  825. textField_15Pedido.setBounds(12, 46, 116, 22);
  826. ModifyPedido.add(textField_15Pedido);
  827. textField_15Pedido.setColumns(10);
  828.  
  829. lblEscribaLaNuevaPedido = new JLabel("Escriba la nueva informaci\u00F3n");
  830. lblEscribaLaNuevaPedido.setBounds(12, 146, 180, 16);
  831. ModifyPedido.add(lblEscribaLaNuevaPedido);
  832.  
  833. ModifyOP1Pedido = new JComboBox();
  834. ModifyOP1Pedido.setBounds(12, 108, 90, 22);
  835. ModifyPedido.add(ModifyOP1Pedido);
  836. ModifyOP1Pedido.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Opciones","Id_Pedido", "Fecha","Valor Pedido","Id_Empleado","Id_Proveedor"}));
  837.  
  838. textField_16Pedido = new JTextField();
  839. textField_16Pedido.setBounds(12, 168, 116, 22);
  840. ModifyPedido.add(textField_16Pedido);
  841. textField_16Pedido.setColumns(10);
  842.  
  843. btnModificar1Pedido = new JButton("Modificar");
  844. btnModificar1Pedido.addActionListener(new ActionListener() {
  845. public void actionPerformed(ActionEvent e) {
  846. int Id_Pedido=Integer.parseInt(textField_15Pedido.getText());
  847. String ModifyOp="";
  848. ModifyOp=ModifyOP1Pedido.getSelectedItem().toString();
  849. String ModifyValue=textField_16Pedido.getText();
  850. if(JOptionPane.showConfirmDialog(null, "¿Está seguro de modificar la/el"+ModifyOp+" a su Pedido identificado como: "+Id_Pedido+"?", "Confirmar", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.OK_OPTION) {
  851. try {
  852. if(ModifyOp.equals("Id_Pedido")) {
  853. rs= stmt.executeQuery("SELECT * FROM Pedido WHERE \"Id_Pedido\"="+Id_Pedido+"");
  854. String Nombre="";
  855. Date fecha = null;
  856. int valorpedido=0;
  857. int Empleado=0;
  858. int Proveedor=0;
  859. while(rs.next()) {
  860. Nombre = rs.getString("Nombre");
  861. fecha = rs.getDate("Fecha");
  862. valorpedido= rs.getInt("Valor_Pedido");
  863. Empleado= rs.getInt("Id_Empleado");
  864. Proveedor= rs.getInt("Id_Proveedor");
  865. }
  866. rs=stmt.executeQuery("insert into Pedido values("+ModifyValue+",date"+fecha+","+valorpedido+","+Empleado+","+Proveedor+")");
  867. rs=stmt.executeQuery("update VENTA set \"Id_Pedido\"="+ModifyValue+" where \"Id_Pedido\"="+Id_Pedido);
  868. rs=stmt.executeQuery("update pedido set \"Id_Pedido\"="+ModifyValue+" where \"Id_Pedido\"="+Id_Pedido);
  869. rs=stmt.executeQuery("delete from Pedido WHERE \"Id_Pedido\"="+Id_Pedido+"");
  870. JOptionPane.showMessageDialog(null, "Informacion cambiada satisfactoriamente");
  871. }else {
  872. System.out.println("UPDATE Pedido SET \""+ModifyOp+"\"='"+ModifyValue+"'"
  873. + " WHERE \"Id_Pedido\"="+Id_Pedido+"");
  874. rs=stmt.executeQuery("UPDATE Pedido SET \""+ModifyOp+"\"='"+ModifyValue+"'"
  875. + " WHERE \"Id_Pedido\"="+Id_Pedido+"");
  876. JOptionPane.showMessageDialog(null, "Informacion cambiada satisfactoriamente");
  877. }
  878. } catch (SQLException e1) {
  879. // TODO Auto-generated catch block
  880. e1.printStackTrace();
  881. }
  882. }else {
  883.  
  884. }
  885. textField_15Pedido.setText("");
  886. textField_16Pedido.setText("");
  887. }
  888. });
  889. btnModificar1Pedido.setBounds(265, 88, 97, 25);
  890. ModifyPedido.add(btnModificar1Pedido);
  891.  
  892.  
  893. JPanel ModificarProducto = new JPanel();
  894. ModificarProducto.setBounds(0, 23, 497, 230);
  895. frmAplicacionCooperativa.getContentPane().add(ModificarProducto);
  896. ModificarProducto.setBackground(new Color(192, 192, 192));
  897. ModificarProducto.setVisible(false);
  898. ModificarProducto.setLayout(null);
  899.  
  900. scrollPaneList = new JScrollPane();
  901. scrollPaneList.setBounds(33, 209, 371, -145);
  902. ModificarProducto.add(scrollPaneList);
  903.  
  904. JList productList = new JList();
  905. productList.setBounds(12, 75, 369, 143);
  906. ModificarProducto.add(productList);
  907. productList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  908. productList.setModel(modelo);
  909.  
  910. ModifyOP_1 = new JComboBox();
  911. ModifyOP_1.addActionListener(new ActionListener() {
  912. public void actionPerformed(ActionEvent e) {
  913. }
  914. });
  915. ModifyOP_1.setBounds(9, 25, 90, 22);
  916. ModificarProducto.add(ModifyOP_1);
  917. ModifyOP_1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Opciones","Id_Producto", "Nombre","Precio_Unitario","Stock"}));
  918.  
  919. JButton btnModificarProducto = new JButton("Modificar");
  920. btnModificarProducto.setBounds(284, 24, 97, 25);
  921. btnModificarProducto.addActionListener(new ActionListener() {
  922. public void actionPerformed(ActionEvent arg0) {
  923. String registro=productList.getSelectedValue().toString();
  924. String temp[]=registro.split(" ");
  925. String IdProdModificar=temp[0];
  926. String ModifyOp_1=ModifyOP_1.getSelectedItem().toString();
  927. String ModifyValue=textField_18.getText();
  928. if(JOptionPane.showConfirmDialog(null, "¿Está seguro de modificar la/el"+ModifyOp_1+" a ese producto identificado con codigo de barras: "+IdProdModificar+"?", "Confirmar", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.OK_OPTION) {
  929. try {
  930. if(ModifyOp_1.equals("Id_Producto") || ModifyOp_1.equals("Precio_Unitario") || ModifyOp_1.equals("Stock")) {
  931. rs=stmt.executeQuery("UPDATE PRODUCTO SET \""+ModifyOp_1+"\"="+ModifyValue+ " WHERE \"Id_Producto\"="+IdProdModificar+"");
  932. JOptionPane.showMessageDialog(null, "Informacion cambiada satisfactoriamente");
  933. }else {
  934. rs=stmt.executeQuery("UPDATE PRODUCTO SET \""+ModifyOp_1+"\"='"+ModifyValue+"'"+ " WHERE \"Id_Producto\"="+IdProdModificar+"");
  935. JOptionPane.showMessageDialog(null, "Informacion cambiada satisfactoriamente");
  936. }
  937. } catch (SQLException e1) {
  938. // TODO Auto-generated catch block
  939. e1.printStackTrace();
  940. }
  941. }else {
  942.  
  943. }
  944. textField_5.setText("");
  945. textField_6.setText("");
  946. }
  947. });
  948. ModificarProducto.add(btnModificarProducto);
  949.  
  950. JLabel lblSeleccioneElProducto = new JLabel("Ingrese valor a modificar");
  951. lblSeleccioneElProducto.setBounds(14, 8, 207, 16);
  952. ModificarProducto.add(lblSeleccioneElProducto);
  953.  
  954. textField_18 = new JTextField();
  955. textField_18.addKeyListener(new KeyAdapter() {
  956. @Override
  957. public void keyTyped(KeyEvent arg0) {
  958. if(textField_18.getText().length()==20) {
  959. arg0.consume();
  960. }
  961. }
  962. });
  963. textField_18.setBounds(137, 25, 116, 22);
  964. ModificarProducto.add(textField_18);
  965. textField_18.setColumns(10);
  966.  
  967. lblCdigoDeBarras = new JLabel("Id_Producto");
  968. lblCdigoDeBarras.setBounds(12, 52, 74, 22);
  969. ModificarProducto.add(lblCdigoDeBarras);
  970.  
  971. lblNombre_1 = new JLabel("Nombre");
  972. lblNombre_1.setBounds(112, 55, 56, 16);
  973. ModificarProducto.add(lblNombre_1);
  974.  
  975. lblPrecioVenta = new JLabel("Precio");
  976. lblPrecioVenta.setBounds(212, 55, 41, 16);
  977. ModificarProducto.add(lblPrecioVenta);
  978.  
  979. lblStock = new JLabel("Stock");
  980. lblStock.setBounds(259, 55, 56, 16);
  981. ModificarProducto.add(lblStock);
  982.  
  983.  
  984.  
  985.  
  986.  
  987. JPanel ViewClient_1 = new JPanel();
  988. ViewClient_1.setBackground(new Color(192, 192, 192));
  989. ViewClient_1.setBounds(0, 23, 497, 230);
  990. frmAplicacionCooperativa.getContentPane().add(ViewClient_1);
  991. ViewClient_1.setLayout(null);
  992.  
  993. textField_7 = new JTextField();
  994. textField_7.setBounds(12, 30, 116, 22);
  995. ViewClient_1.add(textField_7);
  996. textField_7.setColumns(10);
  997.  
  998.  
  999. btnBuscar = new JButton("Buscar");
  1000. btnBuscar.addActionListener(new ActionListener() {
  1001. public void actionPerformed(ActionEvent e) {
  1002. try {
  1003. rs = stmt.executeQuery("SELECT * FROM CLIENTE WHERE \"Id_Cliente\"="+textField_7.getText()+"");
  1004. } catch (SQLException e1) {
  1005. // TODO Auto-generated catch block
  1006. e1.printStackTrace();
  1007. }
  1008. try {
  1009. JTextArea textArea = new JTextArea();
  1010. textArea.setBounds(12, 103, 408, 114);
  1011. ViewClient_1.add(textArea);
  1012. textArea.setWrapStyleWord(true);
  1013. while (rs.next()){
  1014. int Id_Cliente = rs.getInt("Id_Cliente");
  1015. String Nombre = rs.getString("Nombre");
  1016. String Apellido = rs.getString("Apellido");
  1017. String Celular= rs.getString("Celular");
  1018. String Cargo= rs.getString("Cargo");
  1019. textArea.setText(Id_Cliente+" "+Nombre+" "+Apellido+" "+Celular+" "+Cargo);
  1020. }
  1021. } catch (SQLException e1) {
  1022. // TODO Auto-generated catch block
  1023. e1.printStackTrace();
  1024. }
  1025. textField_7.setText("");
  1026. }
  1027. });
  1028. btnBuscar.setBounds(166, 29, 97, 25);
  1029. ViewClient_1.add(btnBuscar);
  1030. ViewClient_1.setVisible(false);
  1031.  
  1032.  
  1033. lblIngreseLaCdula_1 = new JLabel("Ingrese la c\u00E9dula");
  1034. lblIngreseLaCdula_1.setBounds(12, 13, 116, 16);
  1035. ViewClient_1.add(lblIngreseLaCdula_1);
  1036.  
  1037. lblId_Cliente = new JLabel("Id_Cliente");
  1038. lblId_Cliente.setBounds(12, 84, 56, 16);
  1039. ViewClient_1.add(lblId_Cliente);
  1040.  
  1041. lblNombre = new JLabel("Nombre");
  1042. lblNombre.setBounds(106, 84, 56, 16);
  1043. ViewClient_1.add(lblNombre);
  1044.  
  1045. lblApellido_1 = new JLabel("Apellido");
  1046. lblApellido_1.setBounds(166, 84, 56, 16);
  1047. ViewClient_1.add(lblApellido_1);
  1048.  
  1049. lblCelular_1 = new JLabel("Celular");
  1050. lblCelular_1.setBounds(241, 84, 56, 16);
  1051. ViewClient_1.add(lblCelular_1);
  1052.  
  1053. lblCargo = new JLabel("Cargo");
  1054. lblCargo.setBounds(364, 84, 56, 16);
  1055. ViewClient_1.add(lblCargo);
  1056.  
  1057. JPanel RemoveClient = new JPanel();
  1058. RemoveClient.setBackground(new Color(192, 192, 192));
  1059. RemoveClient.setBounds(0, 23, 497, 230);
  1060. frmAplicacionCooperativa.getContentPane().add(RemoveClient);
  1061. RemoveClient.setLayout(null);
  1062.  
  1063. JLabel lblBuscarClientePor = new JLabel("Buscar Cliente por N\u00FAmero de C\u00E9dula");
  1064. lblBuscarClientePor.setBounds(12, 31, 247, 16);
  1065. RemoveClient.add(lblBuscarClientePor);
  1066.  
  1067. textField_4 = new JTextField();
  1068. textField_4.setBounds(12, 60, 116, 22);
  1069. RemoveClient.add(textField_4);
  1070. textField_4.setColumns(10);
  1071.  
  1072. JButton btnEliminar = new JButton("Eliminar ");
  1073. btnEliminar.addActionListener(new ActionListener() {
  1074. public void actionPerformed(ActionEvent e) {
  1075. int tempIdVenta=0;
  1076. if(JOptionPane.showConfirmDialog(null, "¿Está seguro de borrar a su cliente identificado como"+textField_4.getText()+
  1077. "? Se borraran sus ventas asociadas y se pondrá triste :(", "Confirmar", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.OK_OPTION) {
  1078. try {
  1079. rs= stmt.executeQuery("SELECT \"Id_Venta\" FROM VENTA WHERE \"Id_Cliente\"="+textField_4.getText()+"");
  1080. while (rs.next()){
  1081. tempIdVenta=rs.getInt("Id_Venta");
  1082. }
  1083. rs=stmt.executeQuery("DELETE FROM DETALLE_VENTA WHERE \"Id_Venta\"="+tempIdVenta+"");
  1084. rs=stmt.executeQuery("DELETE FROM VENTA WHERE \"Id_Cliente\"="+textField_4.getText()+"");
  1085. rs=stmt.executeQuery("DELETE FROM CLIENTE WHERE \"Id_Cliente\"="+textField_4.getText()+"");
  1086. JOptionPane.showMessageDialog(null, "Cliente eliminado correctamente");
  1087. } catch (SQLException e1) {
  1088. // TODO Auto-generated catch block
  1089. e1.printStackTrace();
  1090. }
  1091. }else {
  1092. }
  1093. textField_4.setText("");
  1094. }
  1095. });
  1096. btnEliminar.setBounds(12, 128, 97, 25);
  1097. RemoveClient.add(btnEliminar);
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107. JPanel ModifyClient = new JPanel();
  1108. ModifyClient.setBackground(new Color(192, 192, 192));
  1109. ModifyClient.setBounds(0, 23, 497, 230);
  1110. frmAplicacionCooperativa.getContentPane().add(ModifyClient);
  1111. ModifyClient.setLayout(null);
  1112. ModifyClient.setVisible(false);
  1113.  
  1114. lblquInformacinDesea = new JLabel("\u00BFQu\u00E9 informaci\u00F3n desea editar?");
  1115. lblquInformacinDesea.setBounds(12, 92, 240, 16);
  1116. ModifyClient.add(lblquInformacinDesea);
  1117.  
  1118. lblIngreseLaCdula = new JLabel("Ingrese la c\u00E9dula del cliente");
  1119. lblIngreseLaCdula.setBounds(12, 29, 180, 16);
  1120. ModifyClient.add(lblIngreseLaCdula);
  1121.  
  1122. textField_5 = new JTextField();
  1123. textField_5.setBounds(12, 46, 116, 22);
  1124. ModifyClient.add(textField_5);
  1125. textField_5.setColumns(10);
  1126.  
  1127. lblEscribaLaNueva = new JLabel("Escriba la nueva informaci\u00F3n");
  1128. lblEscribaLaNueva.setBounds(12, 146, 180, 16);
  1129. ModifyClient.add(lblEscribaLaNueva);
  1130.  
  1131. ModifyOP = new JComboBox();
  1132. ModifyOP.setBounds(12, 108, 90, 22);
  1133. ModifyClient.add(ModifyOP);
  1134. ModifyOP.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Opciones","Id_Cliente", "Nombre","Apellido","Celular","Cargo"}));
  1135.  
  1136. textField_6 = new JTextField();
  1137. textField_6.setBounds(12, 168, 116, 22);
  1138. ModifyClient.add(textField_6);
  1139. textField_6.setColumns(10);
  1140.  
  1141. btnModificar = new JButton("Modificar");
  1142. btnModificar.addActionListener(new ActionListener() {
  1143. private String Apellido;
  1144. private String Nombre;
  1145. private String Celular;
  1146. private String Cargo;
  1147. private int tempIdVenta;
  1148.  
  1149. public void actionPerformed(ActionEvent e) {
  1150. int Id_Cliente=Integer.parseInt(textField_5.getText());
  1151. String ModifyOp="";
  1152. ModifyOp=ModifyOP.getSelectedItem().toString();
  1153. String ModifyValue=textField_6.getText();
  1154. if(JOptionPane.showConfirmDialog(null, "¿Está seguro de modificar la/el "+ModifyOp+" a su cliente identificado como: "+Id_Cliente+"?", "Confirmar", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.OK_OPTION) {
  1155. try {
  1156. if(ModifyOp.equals("Id_Cliente")) {
  1157. rs= stmt.executeQuery("SELECT * FROM cliente WHERE \"Id_Cliente\"="+Id_Cliente+"");
  1158. while(rs.next()) {
  1159. Nombre = rs.getString("Nombre");
  1160. Apellido = rs.getString("Apellido");
  1161. Celular= rs.getString("Celular");
  1162. Cargo= rs.getString("Cargo");
  1163.  
  1164. }
  1165. rs=stmt.executeQuery("insert into cliente values("+ModifyValue+",'"+Nombre+"','"+Apellido+"','"+Celular+"','"+Cargo+"')");
  1166. rs=stmt.executeQuery("update VENTA set \"Id_Cliente\"="+ModifyValue+" where \"Id_Cliente\"="+Id_Cliente);
  1167. rs=stmt.executeQuery("delete from CLIENTE WHERE \"Id_Cliente\"="+Id_Cliente+"");
  1168. JOptionPane.showMessageDialog(null, "Informacion cambiada satisfactoriamente");
  1169. }else if(ModifyOp.equals("Celular")){
  1170. rs=stmt.executeQuery("update CLIENTE set \"Celular\"="+ModifyValue+" where \"Id_Cliente\"="+Id_Cliente+"");
  1171. }else {
  1172.  
  1173. System.out.println("UPDATE CLIENTE SET \""+ModifyOp+"\"='"+ModifyValue+"'"
  1174. + " WHERE \"Id_Cliente\"="+Id_Cliente+"");
  1175. rs=stmt.executeQuery("UPDATE CLIENTE SET \""+ModifyOp+"\"='"+ModifyValue+"'"
  1176. + " WHERE \"Id_Cliente\"="+Id_Cliente+"");
  1177. JOptionPane.showMessageDialog(null, "Informacion cambiada satisfactoriamente");
  1178. }
  1179. } catch (SQLException e1) {
  1180. // TODO Auto-generated catch block
  1181. e1.printStackTrace();
  1182. }
  1183. }else {
  1184.  
  1185. }
  1186. textField_5.setText("");
  1187. textField_6.setText("");
  1188. }
  1189. });
  1190. btnModificar.setBounds(265, 88, 97, 25);
  1191. ModifyClient.add(btnModificar);
  1192.  
  1193. JPanel AddClient = new JPanel();
  1194. AddClient.setBackground(new Color(192, 192, 192));
  1195. AddClient.setBounds(0, 23, 497, 230);
  1196. frmAplicacionCooperativa.getContentPane().add(AddClient);
  1197. AddClient.setLayout(null);
  1198.  
  1199. lblCdula = new JLabel("C\u00E9dula");
  1200. lblCdula.setForeground(new Color(0, 0, 0));
  1201. lblCdula.setBackground(new Color(255, 255, 255));
  1202. lblCdula.setBounds(12, 24, 56, 16);
  1203. AddClient.add(lblCdula);
  1204.  
  1205. textField = new JTextField();
  1206. textField.setBounds(12, 43, 116, 22);
  1207. AddClient.add(textField);
  1208. textField.setColumns(10);
  1209.  
  1210. textField_1 = new JTextField();
  1211. textField_1.setBounds(12, 143, 116, 22);
  1212. AddClient.add(textField_1);
  1213. textField_1.setColumns(10);
  1214. AddClient.setVisible(false);
  1215.  
  1216. textField_2 = new JTextField();
  1217. textField_2.setBounds(12, 91, 116, 22);
  1218. AddClient.add(textField_2);
  1219. textField_2.setColumns(10);
  1220.  
  1221. lblNewLabel = new JLabel("Nombre");
  1222. lblNewLabel.setBounds(12, 78, 56, 16);
  1223. AddClient.add(lblNewLabel);
  1224.  
  1225. lblApellido = new JLabel("Apellido");
  1226. lblApellido.setBounds(12, 126, 56, 16);
  1227. AddClient.add(lblApellido);
  1228.  
  1229. lblCelular = new JLabel("Celular");
  1230. lblCelular.setBounds(12, 180, 56, 16);
  1231. AddClient.add(lblCelular);
  1232.  
  1233. JRadioButton rdbtnEstudiante = new JRadioButton("Estudiante");
  1234. rdbtnEstudiante.setBounds(168, 43, 127, 25);
  1235. AddClient.add(rdbtnEstudiante);
  1236.  
  1237. JRadioButton rdbtnProfesor = new JRadioButton("Profesor");
  1238. rdbtnProfesor.setBounds(168, 69, 127, 25);
  1239. AddClient.add(rdbtnProfesor);
  1240.  
  1241. textField_3 = new JTextField();
  1242. textField_3.setBounds(12, 195, 116, 22);
  1243. AddClient.add(textField_3);
  1244. textField_3.setColumns(10);
  1245.  
  1246. JButton btnAgregarCliente = new JButton("Agregar Cliente");
  1247. btnAgregarCliente.addMouseListener(new MouseAdapter() {
  1248. @Override
  1249. public void mouseClicked(MouseEvent e) {
  1250. int id_Cliente=Integer.parseInt(textField.getText());
  1251. String nombre=textField_2.getText();
  1252. String apellido=textField_1.getText();
  1253. float celular=Float.parseFloat((textField_3.getText()));
  1254. String cargo = null;
  1255. if(rdbtnEstudiante.isSelected() && rdbtnProfesor.isSelected()) {
  1256. JOptionPane.showMessageDialog(null, "Ha seleccionado ambas opciones, intente nuevamente");
  1257. }else if(rdbtnProfesor.isSelected()==false && rdbtnEstudiante.isSelected()==false ){
  1258. JOptionPane.showMessageDialog(null, "Seleccione un rol");
  1259. }else {
  1260. if(rdbtnEstudiante.isSelected()){
  1261. cargo="Estudiante";
  1262. }else {
  1263. cargo="Profesor";
  1264. }
  1265. JOptionPane.showMessageDialog(null, "Ha guardado un cliente satisfactoriamente");
  1266. }
  1267. Cliente c= new Cliente(id_Cliente, nombre, apellido, celular, cargo);
  1268. c.añadirCliente(stmt);
  1269.  
  1270. textField.setText("");
  1271. textField_1.setText("");
  1272. textField_2.setText("");
  1273. textField_3.setText("");
  1274. }
  1275. });
  1276. btnAgregarCliente.setBounds(168, 142, 127, 25);
  1277. AddClient.add(btnAgregarCliente);
  1278.  
  1279.  
  1280.  
  1281.  
  1282. JPanel AddEmpleado = new JPanel();
  1283. AddEmpleado.setBackground(new Color(192, 192, 192));
  1284. AddEmpleado.setBounds(0, 23, 497, 230);
  1285. frmAplicacionCooperativa.getContentPane().add(AddEmpleado);
  1286. AddEmpleado.setLayout(null);
  1287.  
  1288. lblCdula1 = new JLabel("C\u00E9dula");
  1289. lblCdula1.setForeground(new Color(0, 0, 0));
  1290. lblCdula1.setBackground(new Color(255, 255, 255));
  1291. lblCdula1.setBounds(12, 24, 56, 16);
  1292. AddEmpleado.add(lblCdula1);
  1293.  
  1294. textField1 = new JTextField();
  1295. textField1.setBounds(12, 43, 116, 22);
  1296. AddEmpleado.add(textField1);
  1297. textField1.setColumns(10);
  1298.  
  1299. textField_11 = new JTextField();
  1300. textField_11.setBounds(12, 143, 116, 22);
  1301. AddEmpleado.add(textField_11);
  1302. textField_11.setColumns(10);
  1303. AddEmpleado.setVisible(false);
  1304.  
  1305. textField_12 = new JTextField();
  1306. textField_12.setBounds(12, 91, 116, 22);
  1307. AddEmpleado.add(textField_12);
  1308. textField_12.setColumns(10);
  1309.  
  1310. lblNewLabel1 = new JLabel("Nombre");
  1311. lblNewLabel1.setBounds(12, 78, 56, 16);
  1312. AddEmpleado.add(lblNewLabel1);
  1313.  
  1314. lblApellido1 = new JLabel("Apellido");
  1315. lblApellido1.setBounds(12, 126, 56, 16);
  1316. AddEmpleado.add(lblApellido1);
  1317.  
  1318. JButton btnAgregarEmpleado = new JButton("Agregar Empleado");
  1319. btnAgregarEmpleado.setBounds(168, 142, 127, 25);
  1320. AddEmpleado.add(btnAgregarEmpleado);
  1321. btnAgregarEmpleado.addMouseListener(new MouseAdapter() {
  1322. @Override
  1323. public void mouseClicked(MouseEvent e) {
  1324. int id_Empleado=Integer.parseInt(textField1.getText());
  1325. String nombre=textField_12.getText();
  1326. String apellido=textField_11.getText();
  1327. Empleado c= new Empleado(id_Empleado, nombre, apellido);
  1328. c.añadirEmpleado(stmt);
  1329. JOptionPane.showMessageDialog(null, "Ha guardado un Empleado satisfactoriamente");
  1330.  
  1331. textField1.setText("");
  1332. textField_11.setText("");
  1333. textField_12.setText("");
  1334. }
  1335. });
  1336.  
  1337.  
  1338. JPanel ModifyEmpleado = new JPanel();
  1339. ModifyEmpleado.setBackground(new Color(192, 192, 192));
  1340. ModifyEmpleado.setBounds(0, 23, 497, 230);
  1341. frmAplicacionCooperativa.getContentPane().add(ModifyEmpleado);
  1342. ModifyEmpleado.setLayout(null);
  1343. ModifyEmpleado.setVisible(false);
  1344.  
  1345. lblquInformacinDesea1 = new JLabel("\u00BFQu\u00E9 informaci\u00F3n desea editar?");
  1346. lblquInformacinDesea1.setBounds(12, 92, 240, 16);
  1347. ModifyEmpleado.add(lblquInformacinDesea1);
  1348.  
  1349. lblIngreseLaCdula1 = new JLabel("Ingrese la c\u00E9dula del Empleado");
  1350. lblIngreseLaCdula1.setBounds(12, 29, 180, 16);
  1351. ModifyEmpleado.add(lblIngreseLaCdula1);
  1352.  
  1353. textField_15 = new JTextField();
  1354. textField_15.setBounds(12, 46, 116, 22);
  1355. ModifyEmpleado.add(textField_15);
  1356. textField_15.setColumns(10);
  1357.  
  1358. lblEscribaLaNueva1 = new JLabel("Escriba la nueva informaci\u00F3n");
  1359. lblEscribaLaNueva1.setBounds(12, 146, 180, 16);
  1360. ModifyEmpleado.add(lblEscribaLaNueva1);
  1361.  
  1362. ModifyOP1 = new JComboBox();
  1363. ModifyOP1.setBounds(12, 108, 90, 22);
  1364. ModifyEmpleado.add(ModifyOP1);
  1365. ModifyOP1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Opciones","Id_Empleado", "Nombre","Apellido"}));
  1366.  
  1367. textField_16 = new JTextField();
  1368. textField_16.setBounds(12, 168, 116, 22);
  1369. ModifyEmpleado.add(textField_16);
  1370. textField_16.setColumns(10);
  1371.  
  1372. btnModificar1 = new JButton("Modificar");
  1373. btnModificar1.addActionListener(new ActionListener() {
  1374. public void actionPerformed(ActionEvent e) {
  1375. int Id_Empleado=Integer.parseInt(textField_15.getText());
  1376. String ModifyOp="";
  1377. ModifyOp=ModifyOP1.getSelectedItem().toString();
  1378. String ModifyValue=textField_16.getText();
  1379. if(JOptionPane.showConfirmDialog(null, "¿Está seguro de modificar la/el"+ModifyOp+" a su Empleado identificado como: "+Id_Empleado+"?", "Confirmar", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.OK_OPTION) {
  1380. try {
  1381. if(ModifyOp.equals("Id_Empleado")) {
  1382. rs= stmt.executeQuery("SELECT * FROM empleado WHERE \"Id_Empleado\"="+Id_Empleado+"");
  1383. String Nombre="";
  1384. String Apellido="";
  1385.  
  1386. while(rs.next()) {
  1387. Nombre = rs.getString("Nombre");
  1388. Apellido = rs.getString("Apellido");
  1389. }
  1390. rs=stmt.executeQuery("insert into empleado values("+ModifyValue+",'"+Nombre+"','"+Apellido+"')");
  1391. rs=stmt.executeQuery("update VENTA set \"Id_Empleado\"="+ModifyValue+" where \"Id_Empleado\"="+Id_Empleado);
  1392. rs=stmt.executeQuery("update pedido set \"Id_Empleado\"="+ModifyValue+" where \"Id_Empleado\"="+Id_Empleado);
  1393. rs=stmt.executeQuery("delete from empleado WHERE \"Id_Empleado\"="+Id_Empleado+"");
  1394. JOptionPane.showMessageDialog(null, "Informacion cambiada satisfactoriamente");
  1395. }else {
  1396. System.out.println("UPDATE Empleado SET \""+ModifyOp+"\"='"+ModifyValue+"'"
  1397. + " WHERE \"Id_Empleado\"="+Id_Empleado+"");
  1398. rs=stmt.executeQuery("UPDATE Empleado SET \""+ModifyOp+"\"='"+ModifyValue+"'"
  1399. + " WHERE \"Id_Empleado\"="+Id_Empleado+"");
  1400. JOptionPane.showMessageDialog(null, "Informacion cambiada satisfactoriamente");
  1401. }
  1402. } catch (SQLException e1) {
  1403. // TODO Auto-generated catch block
  1404. e1.printStackTrace();
  1405. }
  1406. }else {
  1407.  
  1408. }
  1409. textField_15.setText("");
  1410. textField_16.setText("");
  1411. }
  1412. });
  1413. btnModificar1.setBounds(265, 88, 97, 25);
  1414. ModifyEmpleado.add(btnModificar1);
  1415.  
  1416. JPanel RemoveEmpleado = new JPanel();
  1417. RemoveEmpleado.setBounds(0, 23, 497, 230);
  1418. frmAplicacionCooperativa.getContentPane().add(RemoveEmpleado);
  1419. RemoveEmpleado.setBackground(new Color(192, 192, 192));
  1420. RemoveEmpleado.setLayout(null);
  1421.  
  1422. JLabel lblBuscarEmpleadoPor = new JLabel("Buscar Empleado por N\u00FAmero de C\u00E9dula");
  1423. lblBuscarEmpleadoPor.setBounds(12, 31, 247, 16);
  1424. RemoveEmpleado.add(lblBuscarEmpleadoPor);
  1425.  
  1426. textField_14 = new JTextField();
  1427. textField_14.setBounds(12, 60, 116, 22);
  1428. RemoveEmpleado.add(textField_14);
  1429. textField_14.setColumns(10);
  1430.  
  1431. JButton btnEliminar1 = new JButton("Eliminar ");
  1432. btnEliminar1.addActionListener(new ActionListener() {
  1433. public void actionPerformed(ActionEvent e) {
  1434. int tempIdVenta=0;
  1435. if(JOptionPane.showConfirmDialog(null, "¿Está seguro de borrar a su Empleado identificado como"+textField_14.getText()+"? Se pondrá triste :(", "Confirmar", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.OK_OPTION) {
  1436. try {
  1437. rs= stmt.executeQuery("SELECT \"Id_Venta\" FROM VENTA WHERE \"Id_Empleado\"="+textField_14.getText()+"");
  1438. while (rs.next()){
  1439. tempIdVenta=rs.getInt("Id_Venta");
  1440. }
  1441. rs=stmt.executeQuery("DELETE FROM DETALLE_VENTA WHERE \"Id_Venta\"="+tempIdVenta+"");
  1442. rs=stmt.executeQuery("DELETE FROM VENTA WHERE \"Id_Empleado\"="+textField_14.getText()+"");
  1443. rs=stmt.executeQuery("DELETE FROM Empleado WHERE \"Id_Empleado\"="+textField_14.getText()+"");
  1444. JOptionPane.showMessageDialog(null, "Empleado eliminado correctamente");
  1445. } catch (SQLException e1) {
  1446. // TODO Auto-generated catch block
  1447. e1.printStackTrace();
  1448. }
  1449. }else {
  1450. }
  1451. textField_14.setText("");
  1452. }
  1453. });
  1454. btnEliminar1.setBounds(12, 128, 97, 25);
  1455. RemoveEmpleado.add(btnEliminar1);
  1456.  
  1457.  
  1458. JPanel ViewEmpleado = new JPanel();
  1459. ViewEmpleado.setBackground(new Color(192, 192, 192));
  1460. ViewEmpleado.setBounds(0, 23, 497, 230);
  1461. frmAplicacionCooperativa.getContentPane().add(ViewEmpleado);
  1462. ViewEmpleado.setLayout(null);
  1463.  
  1464. textField_17 = new JTextField();
  1465. textField_17.setBounds(12, 30, 116, 22);
  1466. ViewEmpleado.add(textField_17);
  1467. textField_17.setColumns(10);
  1468.  
  1469.  
  1470. btnBuscar1 = new JButton("Buscar");
  1471. btnBuscar1.addActionListener(new ActionListener() {
  1472. public void actionPerformed(ActionEvent e) {
  1473. try {
  1474. rs = stmt.executeQuery("SELECT * FROM Empleado WHERE \"Id_Empleado\"="+textField_17.getText()+"");
  1475. } catch (SQLException e1) {
  1476. // TODO Auto-generated catch block
  1477. e1.printStackTrace();
  1478. }
  1479. try {
  1480. JTextArea textArea1 = new JTextArea();
  1481. textArea1.setBounds(12, 103, 408, 114);
  1482. ViewEmpleado.add(textArea1);
  1483. textArea1.setWrapStyleWord(true);
  1484. while (rs.next()){
  1485. int Id_Empleado = rs.getInt("Id_Empleado");
  1486. String Nombre = rs.getString("Nombre");
  1487. String Apellido = rs.getString("Apellido");
  1488. textArea1.setText(Id_Empleado+" "+Nombre+" "+Apellido);
  1489. }
  1490. } catch (SQLException e1) {
  1491. // TODO Auto-generated catch block
  1492. e1.printStackTrace();
  1493. }
  1494.  
  1495. }
  1496. });
  1497. btnBuscar1.setBounds(166, 29, 97, 25);
  1498. ViewEmpleado.add(btnBuscar1);
  1499. ViewEmpleado.setVisible(false);
  1500.  
  1501.  
  1502. lblIngreseLaCdula_11 = new JLabel("Ingrese la c\u00E9dula");
  1503. lblIngreseLaCdula_11.setBounds(12, 13, 116, 16);
  1504. ViewEmpleado.add(lblIngreseLaCdula_11);
  1505.  
  1506. lblId_Empleado = new JLabel("Id_Empleado");
  1507. lblId_Empleado.setBounds(12, 84, 84, 16);
  1508. ViewEmpleado.add(lblId_Empleado);
  1509.  
  1510. lblNombreEmpleado = new JLabel("Nombre");
  1511. lblNombreEmpleado.setBounds(106, 84, 56, 16);
  1512. ViewEmpleado.add(lblNombreEmpleado);
  1513.  
  1514. lblApellido_11 = new JLabel("Apellido");
  1515. lblApellido_11.setBounds(187, 84, 56, 16);
  1516. ViewEmpleado.add(lblApellido_11);
  1517.  
  1518.  
  1519.  
  1520.  
  1521. JPanel AddProveedor = new JPanel();
  1522. AddProveedor.setBackground(new Color(192, 192, 192));
  1523. AddProveedor.setBounds(0, 23, 497, 230);
  1524. frmAplicacionCooperativa.getContentPane().add(AddProveedor);
  1525. AddProveedor.setLayout(null);
  1526.  
  1527. JLabel lblCdula1Proveedor = new JLabel("C\u00E9dula");
  1528. lblCdula1Proveedor.setForeground(new Color(0, 0, 0));
  1529. lblCdula1Proveedor.setBackground(new Color(255, 255, 255));
  1530. lblCdula1Proveedor.setBounds(12, 24, 56, 16);
  1531. AddProveedor.add(lblCdula1Proveedor);
  1532.  
  1533. JTextField textField1Proveedor = new JTextField();
  1534. textField1Proveedor.setBounds(12, 43, 116, 22);
  1535. AddProveedor.add(textField1Proveedor);
  1536. textField1Proveedor.setColumns(10);
  1537.  
  1538. JTextField textField_11Proveedor = new JTextField();
  1539. textField_11Proveedor.setBounds(12, 143, 116, 22);
  1540. AddProveedor.add(textField_11Proveedor);
  1541. textField_11Proveedor.setColumns(10);
  1542. AddProveedor.setVisible(false);
  1543.  
  1544. JTextField textField_12Proveedor = new JTextField();
  1545. textField_12Proveedor.setBounds(12, 91, 116, 22);
  1546. AddProveedor.add(textField_12Proveedor);
  1547. textField_12Proveedor.setColumns(10);
  1548.  
  1549. JLabel lblNewLabel1Proveedor = new JLabel("Nombre");
  1550. lblNewLabel1Proveedor.setBounds(12, 78, 56, 16);
  1551. AddProveedor.add(lblNewLabel1Proveedor);
  1552.  
  1553. JLabel lblApellido1Proveedor = new JLabel("Telefono");
  1554. lblApellido1Proveedor.setBounds(12, 126, 56, 16);
  1555. AddProveedor.add(lblApellido1Proveedor);
  1556.  
  1557. JButton btnAgregarProveedor = new JButton("Agregar");
  1558. btnAgregarProveedor.addActionListener(new ActionListener() {
  1559. public void actionPerformed(ActionEvent arg0) {
  1560. float id_Proveedor=Float.parseFloat(textField1Proveedor.getText());
  1561. String nombre=textField_12Proveedor.getText();
  1562. String telefono=textField_11Proveedor.getText();
  1563. Proveedor c= new Proveedor(id_Proveedor, nombre,telefono);
  1564. c.añadirProveedor(stmt);
  1565. JOptionPane.showMessageDialog(null, "Ha guardado un Proveedor satisfactoriamente");
  1566.  
  1567. textField1Proveedor.setText("");
  1568. textField_11Proveedor.setText("");
  1569. textField_12Proveedor.setText("");
  1570. }
  1571. });
  1572. btnAgregarProveedor.setBounds(168, 142, 127, 25);
  1573. AddProveedor.add(btnAgregarProveedor);
  1574.  
  1575. JPanel RemoveProveedor = new JPanel();
  1576. RemoveProveedor.setBounds(0, 23, 497, 230);
  1577. frmAplicacionCooperativa.getContentPane().add(RemoveProveedor);
  1578. RemoveProveedor.setBackground(new Color(192, 192, 192));
  1579. RemoveProveedor.setLayout(null);
  1580.  
  1581. JLabel lblBuscarProveedorPor = new JLabel("Buscar Proveedor por N\u00FAmero de C\u00E9dula");
  1582. lblBuscarProveedorPor.setBounds(12, 31, 247, 16);
  1583. RemoveProveedor.add(lblBuscarProveedorPor);
  1584.  
  1585. JTextField textField_14Proveedor = new JTextField();
  1586. textField_14Proveedor.setBounds(12, 60, 116, 22);
  1587. RemoveProveedor.add(textField_14Proveedor);
  1588. textField_14Proveedor.setColumns(10);
  1589.  
  1590. JButton btnEliminarProveedor = new JButton("Eliminar ");
  1591. btnEliminarProveedor.addActionListener(new ActionListener() {
  1592. public void actionPerformed(ActionEvent e) {
  1593. int tempIdVenta=0;
  1594. if(JOptionPane.showConfirmDialog(null, "¿Está seguro de borrar a su Proveedor identificado como"+textField_14Proveedor.getText()+"? Se pondrá triste :(", "Confirmar", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.OK_OPTION) {
  1595. try {
  1596. rs= stmt.executeQuery("SELECT \"Id_Pedido\" FROM producto WHERE \"Id_Proveedor\"="+textField_14Proveedor.getText()+"");
  1597. while (rs.next()){
  1598. tempIdVenta=rs.getInt("Id_Pedido");
  1599. }
  1600. rs=stmt.executeQuery("DELETE FROM DETALLE_pedido WHERE \"Id_Pedido\"="+tempIdVenta+"");
  1601. rs=stmt.executeQuery("DELETE FROM Pedido WHERE \"Id_Proveedor\"="+textField_14Proveedor.getText()+"");
  1602. rs=stmt.executeQuery("DELETE FROM Proveedor WHERE \"Id_Proveedor\"="+textField_14Proveedor.getText()+"");
  1603. JOptionPane.showMessageDialog(null, "Proveedor eliminado correctamente");
  1604. } catch (SQLException e1) {
  1605. // TODO Auto-generated catch block
  1606. e1.printStackTrace();
  1607. }
  1608. }else {
  1609. }
  1610. textField_14Proveedor.setText("");
  1611. }
  1612. });
  1613. btnEliminarProveedor.setBounds(12, 128, 97, 25);
  1614. RemoveProveedor.add(btnEliminarProveedor);
  1615.  
  1616. JPanel ModifyProveedor = new JPanel();
  1617. ModifyProveedor.setBackground(new Color(192, 192, 192));
  1618. ModifyProveedor.setBounds(0, 23, 497, 230);
  1619. frmAplicacionCooperativa.getContentPane().add(ModifyProveedor);
  1620. ModifyProveedor.setLayout(null);
  1621. ModifyProveedor.setVisible(false);
  1622.  
  1623. JLabel lblquInformacinDeseaProveedor = new JLabel("\u00BFQu\u00E9 informaci\u00F3n desea editar?");
  1624. lblquInformacinDeseaProveedor.setBounds(12, 92, 240, 16);
  1625. ModifyProveedor.add(lblquInformacinDeseaProveedor);
  1626.  
  1627. JLabel lblIngreseLaCdula1Proveedor = new JLabel("Ingrese la c\u00E9dula del Proveedor");
  1628. lblIngreseLaCdula1Proveedor.setBounds(12, 29, 180, 16);
  1629. ModifyProveedor.add(lblIngreseLaCdula1Proveedor);
  1630.  
  1631. textField_15Proveedor = new JTextField();
  1632. textField_15Proveedor.setBounds(12, 46, 116, 22);
  1633. ModifyProveedor.add(textField_15Proveedor);
  1634. textField_15Proveedor.setColumns(10);
  1635.  
  1636. JLabel lblEscribaLaNueva1Proveedor = new JLabel("Escriba la nueva informaci\u00F3n");
  1637. lblEscribaLaNueva1Proveedor.setBounds(12, 146, 180, 16);
  1638. ModifyProveedor.add(lblEscribaLaNueva1Proveedor);
  1639.  
  1640. JComboBox ModifyOP1Proveedor = new JComboBox();
  1641. ModifyOP1Proveedor.setBounds(12, 108, 90, 22);
  1642. ModifyProveedor.add(ModifyOP1Proveedor);
  1643. ModifyOP1Proveedor.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Opciones","Id_Proveedor", "Nombre","Telefono"}));
  1644.  
  1645. JTextField textField_16Proveedor = new JTextField();
  1646. textField_16Proveedor.setBounds(12, 168, 116, 22);
  1647. ModifyProveedor.add(textField_16Proveedor);
  1648. textField_16Proveedor.setColumns(10);
  1649.  
  1650. JButton btnModificar1Proveedor = new JButton("Modificar");
  1651. btnModificar1Proveedor.addActionListener(new ActionListener() {
  1652. public void actionPerformed(ActionEvent e) {
  1653. int Id_Proveedor=Integer.parseInt(textField_15Proveedor.getText());
  1654. String ModifyOp="";
  1655. ModifyOp=ModifyOP1Proveedor.getSelectedItem().toString();
  1656. String ModifyValue=textField_16Proveedor.getText();
  1657. if(JOptionPane.showConfirmDialog(null, "¿Está seguro de modificar la/el"+ModifyOp+" a su Proveedor identificado como: "+Id_Proveedor+"?", "Confirmar", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.OK_OPTION) {
  1658. try {
  1659. if(ModifyOp.equals("Id_Proveedor")) {
  1660. rs= stmt.executeQuery("SELECT * FROM Proveedor WHERE \"Id_Proveedor\"="+Id_Proveedor+"");
  1661. String Nombre="";
  1662. float Apellido=0;
  1663.  
  1664. while(rs.next()) {
  1665. Nombre = rs.getString("Nombre");
  1666. Apellido = rs.getFloat("Telefono");
  1667. }
  1668. rs=stmt.executeQuery("insert into Proveedor values("+ModifyValue+",'"+Nombre+"',"+Apellido+")");
  1669. rs=stmt.executeQuery("update VENTA set \"Id_Proveedor\"="+ModifyValue+" where \"Id_Proveedor\"="+Id_Proveedor);
  1670. rs=stmt.executeQuery("update pedido set \"Id_Proveedor\"="+ModifyValue+" where \"Id_Proveedor\"="+Id_Proveedor);
  1671. rs=stmt.executeQuery("delete from Proveedor WHERE \"Id_Proveedor\"="+Id_Proveedor+"");
  1672. JOptionPane.showMessageDialog(null, "Informacion cambiada satisfactoriamente");
  1673. }else {
  1674. System.out.println("UPDATE Proveedor SET \""+ModifyOp+"\"='"+ModifyValue+"'"
  1675. + " WHERE \"Id_Proveedor\"="+Id_Proveedor+"");
  1676. rs=stmt.executeQuery("UPDATE Proveedor SET \""+ModifyOp+"\"='"+ModifyValue+"'"
  1677. + " WHERE \"Id_Proveedor\"="+Id_Proveedor+"");
  1678. JOptionPane.showMessageDialog(null, "Informacion cambiada satisfactoriamente");
  1679. }
  1680. } catch (SQLException e1) {
  1681. // TODO Auto-generated catch block
  1682. e1.printStackTrace();
  1683. }
  1684. }else {
  1685.  
  1686. }
  1687. textField_15Proveedor.setText("");
  1688. textField_16Proveedor.setText("");
  1689. }
  1690. });
  1691. btnModificar1Proveedor.setBounds(265, 88, 97, 25);
  1692. ModifyProveedor.add(btnModificar1Proveedor);
  1693. JPanel ViewProveedor = new JPanel();
  1694. ViewProveedor.setBackground(new Color(192, 192, 192));
  1695. ViewProveedor.setBounds(0, 23, 497, 230);
  1696. frmAplicacionCooperativa.getContentPane().add(ViewProveedor);
  1697. ViewProveedor.setLayout(null);
  1698.  
  1699. textField_Proveedor = new JTextField();
  1700. textField_Proveedor.setBounds(12, 30, 116, 22);
  1701. ViewProveedor.add(textField_Proveedor);
  1702. textField_Proveedor.setColumns(10);
  1703.  
  1704.  
  1705. JButton btnBuscarProveedor = new JButton("Buscar");
  1706. btnBuscarProveedor.addActionListener(new ActionListener() {
  1707. public void actionPerformed(ActionEvent e) {
  1708. try {
  1709. rs = stmt.executeQuery("SELECT * FROM Proveedor WHERE \"Id_Proveedor\"="+textField_Proveedor.getText()+"");
  1710. } catch (SQLException e1) {
  1711. // TODO Auto-generated catch block
  1712. e1.printStackTrace();
  1713. }
  1714. try {
  1715. JTextArea textAreaProveedor = new JTextArea();
  1716. textAreaProveedor.setBounds(12, 103, 408, 114);
  1717. ViewProveedor.add(textAreaProveedor);
  1718. textAreaProveedor.setWrapStyleWord(true);
  1719. while (rs.next()){
  1720. int Id_Proveedor = rs.getInt("Id_Proveedor");
  1721. String Nombre = rs.getString("Nombre");
  1722. float telefono = rs.getFloat("Telefono");
  1723. textAreaProveedor.setText(Id_Proveedor+" "+Nombre+" "+telefono);
  1724. }
  1725. } catch (SQLException e1) {
  1726. // TODO Auto-generated catch block
  1727. e1.printStackTrace();
  1728. }
  1729.  
  1730. }
  1731. });
  1732. btnBuscarProveedor.setBounds(166, 29, 97, 25);
  1733. ViewProveedor.add(btnBuscarProveedor);
  1734. ViewProveedor.setVisible(false);
  1735.  
  1736.  
  1737. JLabel lblIngreseLaCdulaProveedor = new JLabel("Ingrese la c\u00E9dula");
  1738. lblIngreseLaCdulaProveedor.setBounds(12, 13, 116, 16);
  1739. ViewProveedor.add(lblIngreseLaCdulaProveedor);
  1740.  
  1741. lblId_Proveedor = new JLabel("Id_Proveedor");
  1742. lblId_Proveedor.setBounds(12, 84, 84, 16);
  1743. ViewProveedor.add(lblId_Proveedor);
  1744.  
  1745. lblNombreProveedor = new JLabel("Nombre");
  1746. lblNombreProveedor.setBounds(106, 84, 56, 16);
  1747. ViewProveedor.add(lblNombreProveedor);
  1748.  
  1749. lblApellidoProveedor = new JLabel("Apellido");
  1750. lblApellidoProveedor.setBounds(187, 84, 56, 16);
  1751. ViewProveedor.add(lblApellidoProveedor);
  1752.  
  1753.  
  1754. JPanel RegistrarProducto = new JPanel();
  1755. RegistrarProducto.setBounds(0, 23, 497, 230);
  1756. frmAplicacionCooperativa.getContentPane().add(RegistrarProducto);
  1757. RegistrarProducto.setBackground(new Color(192, 192, 192));
  1758. RegistrarProducto.setLayout(null);
  1759. RegistrarProducto.setVisible(false);
  1760.  
  1761. Barcode = new JTextField();
  1762. Barcode.setBounds(12, 40, 116, 22);
  1763. RegistrarProducto.add(Barcode);
  1764. Barcode.setColumns(10);
  1765.  
  1766. JLabel lblIngreseCdigoDe = new JLabel("Ingrese c\u00F3digo de barras");
  1767. lblIngreseCdigoDe.setBounds(12, 24, 152, 16);
  1768. RegistrarProducto.add(lblIngreseCdigoDe);
  1769.  
  1770. textField_8 = new JTextField();
  1771. textField_8.addKeyListener(new KeyAdapter() {
  1772. @Override
  1773. public void keyTyped(KeyEvent arg0) {
  1774. if (textField_8.getText().length()==20) {
  1775. arg0.consume();
  1776. }
  1777. }
  1778. });
  1779. textField_8.setBounds(12, 81, 116, 22);
  1780. RegistrarProducto.add(textField_8);
  1781. textField_8.setColumns(10);
  1782.  
  1783.  
  1784. JLabel lblNombreDelProducto = new JLabel("Nombre del producto");
  1785. lblNombreDelProducto.setBounds(12, 65, 152, 16);
  1786. RegistrarProducto.add(lblNombreDelProducto);
  1787.  
  1788. textField_9 = new JTextField();
  1789. textField_9.setBounds(12, 122, 116, 22);
  1790. RegistrarProducto.add(textField_9);
  1791. textField_9.setColumns(10);
  1792.  
  1793. JLabel lblIngresePrecioDe = new JLabel("Precio de venta");
  1794. lblIngresePrecioDe.setBounds(12, 106, 116, 16);
  1795. RegistrarProducto.add(lblIngresePrecioDe);
  1796.  
  1797. textField_10 = new JTextField();
  1798. textField_10.setBounds(12, 173, 116, 22);
  1799. RegistrarProducto.add(textField_10);
  1800. textField_10.setColumns(10);
  1801.  
  1802. JLabel lblStockDisponible = new JLabel("Stock disponible");
  1803. lblStockDisponible.setBounds(12, 157, 116, 16);
  1804. RegistrarProducto.add(lblStockDisponible);
  1805.  
  1806. JButton btnRegistrar = new JButton("Registrar");
  1807. btnRegistrar.addActionListener(new ActionListener() {
  1808. public void actionPerformed(ActionEvent e) {
  1809. try {
  1810. float Id_Producto=Float.parseFloat(Barcode.getText());
  1811. String Nombre=textField_8.getText();
  1812. int Precio=Integer.parseInt(textField_9.getText());
  1813. int Stock=Integer.parseInt(textField_10.getText());
  1814. System.out.println("INSERT INTO PRODUCTO VALUES ("+Id_Producto+",'"+Nombre+"',"+Precio+","+Stock+")");
  1815. rs= stmt.executeQuery("INSERT INTO PRODUCTO VALUES ("+Id_Producto+",'"+Nombre+"',"+Precio+","+Stock+")");
  1816. JOptionPane.showMessageDialog(null, "Ha guardado un producto satisfactoriamente");
  1817. } catch (SQLException e1) {
  1818. // TODO Auto-generated catch block
  1819. e1.printStackTrace();
  1820. }
  1821.  
  1822. }
  1823. });
  1824. btnRegistrar.setBounds(208, 102, 97, 25);
  1825. RegistrarProducto.add(btnRegistrar);
  1826. /*
  1827. * End ModifyVenta
  1828. */
  1829.  
  1830.  
  1831. JPanel ViewProducto = new JPanel();
  1832. ViewProducto.setBackground(new Color(192, 192, 192));
  1833. ViewProducto.setBounds(0, 23, 497, 230);
  1834. frmAplicacionCooperativa.getContentPane().add(ViewProducto);
  1835. ViewProducto.setLayout(null);
  1836.  
  1837. textField_7Producto = new JTextField();
  1838. textField_7Producto.setBounds(10, 68, 116, 22);
  1839. ViewProducto.add(textField_7Producto);
  1840. textField_7Producto.setColumns(10);
  1841.  
  1842.  
  1843. lblIngreseLaCdula_1_1 = new JLabel("Ingrese la c\u00E9dula");
  1844. lblIngreseLaCdula_1_1.setBounds(22, 44, 116, 16);
  1845. ViewProducto.add(lblIngreseLaCdula_1_1);
  1846.  
  1847. lblId_Cliente_1 = new JLabel("Id_Producto");
  1848. lblId_Cliente_1.setBounds(10, 109, 56, 16);
  1849. ViewProducto.add(lblId_Cliente_1);
  1850.  
  1851. lblNombre_2 = new JLabel("Nombre");
  1852. lblNombre_2.setBounds(94, 110, 56, 16);
  1853. ViewProducto.add(lblNombre_2);
  1854.  
  1855. lblApellido_1_1 = new JLabel("Precio Unitario");
  1856. lblApellido_1_1.setBounds(166, 110, 97, 16);
  1857. ViewProducto.add(lblApellido_1_1);
  1858.  
  1859. lblCelular_1_1 = new JLabel("Stock");
  1860. lblCelular_1_1.setBounds(283, 109, 56, 16);
  1861. ViewProducto.add(lblCelular_1_1);
  1862.  
  1863.  
  1864. btnBuscarProducto = new JButton("Buscar");
  1865. btnBuscarProducto.setBounds(273, 73, 97, 25);
  1866. ViewProducto.add(btnBuscarProducto);
  1867. btnBuscarProducto.addActionListener(new ActionListener() {
  1868. public void actionPerformed(ActionEvent e) {
  1869. try {
  1870. rs = stmt.executeQuery("SELECT * FROM producto WHERE \"Id_Producto\"="+textField_7Producto.getText()+"");
  1871. } catch (SQLException e1) {
  1872. // TODO Auto-generated catch block
  1873. e1.printStackTrace();
  1874. }
  1875. try {
  1876. JTextArea textAreaProducto = new JTextArea();
  1877. textAreaProducto.setBounds(12, 103, 408, 114);
  1878. ViewProducto.add(textAreaProducto);
  1879. textAreaProducto.setWrapStyleWord(true);
  1880. while (rs.next()){
  1881. int Id_Producto = rs.getInt("Id_Producto");
  1882. String Nombre = rs.getString("Nombre");
  1883. int Apellido = rs.getInt("Precio_Unitario");
  1884. int Celular= rs.getInt("Stock");
  1885. textAreaProducto.setText(Id_Producto+" "+Nombre+" "+Apellido+" "+Celular);
  1886. }
  1887. } catch (SQLException e1) {
  1888. // TODO Auto-generated catch block
  1889. e1.printStackTrace();
  1890. }
  1891. textField_7Producto.setText("");
  1892. }
  1893. });
  1894.  
  1895. JPanel RemoveProducto = new JPanel();
  1896. RemoveProducto.setBounds(0, 23, 497, 230);
  1897. frmAplicacionCooperativa.getContentPane().add(RemoveProducto);
  1898. RemoveProducto.setBackground(new Color(192, 192, 192));
  1899. RemoveProducto.setLayout(null);
  1900.  
  1901. JLabel lblBuscarProductoPor = new JLabel("Buscar Producto por Codigo de barras\r\n");
  1902. lblBuscarProductoPor.setBounds(12, 31, 247, 16);
  1903. RemoveProducto.add(lblBuscarProductoPor);
  1904.  
  1905. JTextField textField_14Producto = new JTextField();
  1906. textField_14Producto.setBounds(12, 60, 116, 22);
  1907. RemoveProducto.add(textField_14Producto);
  1908. textField_14Producto.setColumns(10);
  1909.  
  1910. JButton btnEliminarProducto = new JButton("Eliminar ");
  1911. btnEliminarProducto.addActionListener(new ActionListener() {
  1912. public void actionPerformed(ActionEvent e) {
  1913. int tempIdVenta=0;
  1914. if(JOptionPane.showConfirmDialog(null, "¿Está seguro de borrar a su Producto identificado como"+textField_14Producto.getText()+"? Se pondrá triste :(", "Confirmar", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE)==JOptionPane.OK_OPTION) {
  1915. try {
  1916. rs= stmt.executeQuery("delete from detalle_venta WHERE \"Id_Producto\"="+textField_14Producto.getText()+"");
  1917. rs= stmt.executeQuery("delete from detalle_pedido WHERE \"Id_Producto\"="+textField_14Producto.getText()+"");
  1918. rs=stmt.executeQuery("DELETE FROM Producto WHERE \"Id_Producto\"="+textField_14Producto.getText()+"");
  1919. JOptionPane.showMessageDialog(null, "Producto eliminado correctamente");
  1920. } catch (SQLException e1) {
  1921. // TODO Auto-generated catch block
  1922. e1.printStackTrace();
  1923. }
  1924. }else {
  1925. }
  1926. textField_14Producto.setText("");
  1927. }
  1928. });
  1929. btnEliminarProducto.setBounds(12, 128, 97, 25);
  1930. RemoveProducto.add(btnEliminarProducto);
  1931.  
  1932. //Declaracion Diaria
  1933. JPanel DeclaracionDiaria = new JPanel();
  1934. DeclaracionDiaria.setBackground(new Color(192, 192, 192));
  1935. DeclaracionDiaria.setBounds(0, 23, 497, 274);
  1936. frmAplicacionCooperativa.getContentPane().add(DeclaracionDiaria);
  1937. DeclaracionDiaria.setLayout(null);
  1938.  
  1939. JCalendar calendarDeclaracionD = new JCalendar();
  1940. calendarDeclaracionD.setBounds(12, 51, 184, 155);
  1941. DeclaracionDiaria.add(calendarDeclaracionD);
  1942.  
  1943. JLabel lblSeleccioneLaFecha_2 = new JLabel("Seleccione la fecha de la cual");
  1944. lblSeleccioneLaFecha_2.setBounds(12, 13, 184, 16);
  1945. DeclaracionDiaria.add(lblSeleccioneLaFecha_2);
  1946.  
  1947. JLabel lblQuiereGenerarEl = new JLabel("Quiere generar el informe");
  1948. lblQuiereGenerarEl.setBounds(12, 29, 184, 16);
  1949. DeclaracionDiaria.add(lblQuiereGenerarEl);
  1950.  
  1951. JButton btnGenerarDeclaracion = new JButton("Generar");
  1952. btnGenerarDeclaracion.addActionListener(new ActionListener() {
  1953. public void actionPerformed(ActionEvent e) {
  1954. FileOutputStream archivoSalida = null;
  1955. String fecha=calendarDeclaracionD.getDayChooser().getDay()+"-"+((calendarDeclaracionD.getMonthChooser().getMonth())+1)+"-"+(calendarDeclaracionD.getYearChooser().getYear());
  1956. try {
  1957. int temp=0;
  1958. rs=stmt.executeQuery("SELECT COUNT(\"Id_Venta\") FROM VENTA WHERE \"FechaVenta\"=TO_DATE ('"+fecha+"','DD-MM-YYYY')");
  1959. if (rs.next()) {
  1960. temp=rs.getInt("COUNT(\"Id_Venta\")");
  1961. }
  1962. archivoSalida = new FileOutputStream("Informe"+fecha+"-"+temp+".txt");
  1963. rs=stmt.executeQuery("SELECT SUM(\"Valor_Venta\") FROM VENTA WHERE \"FechaVenta\"=TO_DATE ('"+fecha+"','DD-MM-YYYY')");
  1964. int VentaTotal=0;
  1965. if (rs.next()) {
  1966. VentaTotal=rs.getInt("SUM(\"Valor_Venta\")");
  1967. }
  1968. int PlataAGuardar=(VentaTotal*60)/100;
  1969. int GananciaNeta=VentaTotal-PlataAGuardar;
  1970. int GananciaTotal=GananciaNeta-80000-30000;
  1971.  
  1972. //T1 = Tabla Empleado T2= Tabla Venta
  1973. //INNER JOIN
  1974. rs=stmt.executeQuery("SELECT T1.\"Id_Cliente\",T1.\"Nombre\",T1.\"Apellido\",T2.\"Valor_Venta\",T2.\"Valor_Pagado\" FROM CLIENTE T1 INNER JOIN VENTA T2 ON T1.\"Id_Cliente\"=T2.\"Id_Cliente\" WHERE T2.\"FechaVenta\"=TO_DATE ('"+fecha+"','DD-MM-YYYY') AND \"Valor_Venta\"-\"Valor_Pagado\"!=0");
  1975. int contador=0;
  1976. String[] fiadosData=new String[5];
  1977. String tempf="";
  1978. String[] fiadosLista = new String[10]; //Mas de 10 fiados por el momento no tiene sentido
  1979.  
  1980. while(rs.next()) {
  1981. fiadosData[0]=rs.getString("Id_Cliente");
  1982. fiadosData[1]=rs.getString("Nombre");
  1983. fiadosData[2]=rs.getString("Apellido");
  1984. fiadosData[3]=rs.getString("Valor_Venta");
  1985. fiadosData[4]=rs.getString("Valor_Pagado");
  1986. tempf=fiadosData[0]+" "+fiadosData[1]+" "+fiadosData[2]+" "+fiadosData[3]+" "+fiadosData[4];
  1987. fiadosLista[contador]=tempf;
  1988. contador++;
  1989. }
  1990. PrintStream salida = new PrintStream(archivoSalida);
  1991. salida.println("--------------------------------------------------------------------------");
  1992. salida.println(" D E C L A R A C I O N D I A R I A ");
  1993. salida.println("--------------------------------------------------------------------------");
  1994. salida.println(" ");
  1995. salida.println(" INFORME "+fecha+"- Numero de ventas realizadas: "+temp );
  1996. salida.println(" VENTA DE LA FECHA "+fecha+": ");
  1997. salida.println(" ");
  1998. salida.println(" * SUELDOS = "+80000+" COP ");
  1999. salida.println(" * ARRIENDO = "+30000+" COP ");
  2000. salida.println(" * VENTA TOTAL = "+VentaTotal+" COP ");
  2001. salida.println(" * PLATA A GUARDAR = "+PlataAGuardar+" COP ");
  2002. salida.println(" * GANANCIA NETA = "+GananciaNeta+" COP ");
  2003. salida.println(" * GANANCIA TOTAL = "+GananciaTotal+" COP ");
  2004. salida.println(" ");
  2005. salida.println("--------------------------------------------------------------------------");
  2006. salida.println(" ");
  2007. salida.println(" F I A D O S D E L A F E C H A ");
  2008. salida.println(" ");
  2009. salida.println("--------------------------------------------------------------------------");
  2010. salida.println(" ");
  2011. salida.println(" Id_Cliente Nombre Apellido Valor_Venta Valor_Pagado ");
  2012. for (int i=0; i<contador; i++) {
  2013. salida.println(" "+fiadosLista[i] );
  2014. }
  2015. salida.println(" ");
  2016. salida.println("--------------------------------------------------------------------------");
  2017. salida.close();
  2018. JOptionPane.showMessageDialog(null, "Informe generado correctamente");
  2019. } catch (FileNotFoundException e1) {
  2020. // TODO Auto-generated catch block
  2021. e1.printStackTrace();
  2022. } catch (SQLException e1) {
  2023. // TODO Auto-generated catch block
  2024. e1.printStackTrace();
  2025. }
  2026.  
  2027.  
  2028.  
  2029. }
  2030. });
  2031. btnGenerarDeclaracion.setBounds(295, 110, 97, 25);
  2032. DeclaracionDiaria.add(btnGenerarDeclaracion);
  2033. //End - Declaracion Diaria
  2034.  
  2035. JComboBox Cliente = new JComboBox();
  2036. Cliente.setBounds(0, 2, 92, 19);
  2037. frmAplicacionCooperativa.getContentPane().add(Cliente);
  2038. Cliente.addActionListener(new ActionListener() {
  2039. public void actionPerformed(ActionEvent e) {
  2040.  
  2041. String opcion = "Seleccione una Opcion";
  2042. opcion= Cliente.getSelectedItem().toString();
  2043. switch(opcion) {
  2044. case "Cliente":
  2045. DeclaracionDiaria.setVisible(false);
  2046. ModifyVenta.setVisible(false);
  2047. MostrarVenta.setVisible(false);
  2048. AddVenta.setVisible(false);
  2049. RegistrarProducto.setVisible(false);
  2050. ModificarProducto.setVisible(false);
  2051. ViewProducto.setVisible(false);
  2052. RemoveProducto.setVisible(false);
  2053. AddProveedor.setVisible(false);
  2054. RemoveProveedor.setVisible(false);
  2055. ModifyProveedor.setVisible(false);
  2056. ViewProveedor.setVisible(false);
  2057. AddClient.setVisible(false);
  2058. RemoveClient.setVisible(false);
  2059. ModifyClient.setVisible(false);
  2060. ViewClient_1.setVisible(false);
  2061. AddEmpleado.setVisible(false);
  2062. RemoveEmpleado.setVisible(false);
  2063. ModifyEmpleado.setVisible(false);
  2064. ViewEmpleado.setVisible(false);
  2065. AddPedido.setVisible(false);
  2066. RemovePedido.setVisible(false);
  2067. ModifyPedido.setVisible(false);
  2068. ViewPedido.setVisible(false);
  2069. panel.setVisible(true);
  2070. break;
  2071. case "Añadir Cliente":
  2072. DeclaracionDiaria.setVisible(false);
  2073. ModifyVenta.setVisible(false);
  2074. MostrarVenta.setVisible(false);
  2075. AddVenta.setVisible(false);
  2076. RegistrarProducto.setVisible(false);
  2077. ModificarProducto.setVisible(false);
  2078. ViewProducto.setVisible(false);
  2079. RemoveProducto.setVisible(false);
  2080. AddProveedor.setVisible(false);
  2081. RemoveProveedor.setVisible(false);
  2082. ModifyProveedor.setVisible(false);
  2083. ViewProveedor.setVisible(false);
  2084. RemoveClient.setVisible(false);
  2085. ModifyClient.setVisible(false);
  2086. ViewClient_1.setVisible(false);
  2087. AddEmpleado.setVisible(false);
  2088. RemoveEmpleado.setVisible(false);
  2089. ModifyEmpleado.setVisible(false);
  2090. ViewEmpleado.setVisible(false);
  2091. AddPedido.setVisible(false);
  2092. RemovePedido.setVisible(false);
  2093. ModifyPedido.setVisible(false);
  2094. ViewPedido.setVisible(false);
  2095. panel.setVisible(false);
  2096. AddClient.setVisible(true);
  2097. break;
  2098. case "Remover Cliente":
  2099. DeclaracionDiaria.setVisible(false);
  2100. ModifyVenta.setVisible(false);
  2101. MostrarVenta.setVisible(false);
  2102. AddVenta.setVisible(false);
  2103. RegistrarProducto.setVisible(false);
  2104. ModificarProducto.setVisible(false);
  2105. ViewProducto.setVisible(false);
  2106. RemoveProducto.setVisible(false);
  2107. AddProveedor.setVisible(false);
  2108. RemoveProveedor.setVisible(false);
  2109. ModifyProveedor.setVisible(false);
  2110. ViewProveedor.setVisible(false);
  2111. ModifyClient.setVisible(false);
  2112. ViewClient_1.setVisible(false);
  2113. AddEmpleado.setVisible(false);
  2114. RemoveEmpleado.setVisible(false);
  2115. ModifyEmpleado.setVisible(false);
  2116. ViewEmpleado.setVisible(false);
  2117. AddPedido.setVisible(false);
  2118. RemovePedido.setVisible(false);
  2119. ModifyPedido.setVisible(false);
  2120. ViewPedido.setVisible(false);
  2121. panel.setVisible(false);
  2122. AddClient.setVisible(false);
  2123. RemoveClient.setVisible(true);
  2124. break;
  2125. case "Modificar Info":
  2126. DeclaracionDiaria.setVisible(false);
  2127. ModifyVenta.setVisible(false);
  2128. MostrarVenta.setVisible(false);
  2129. AddVenta.setVisible(false);
  2130. RegistrarProducto.setVisible(false);
  2131. ModificarProducto.setVisible(false);
  2132. ViewProducto.setVisible(false);
  2133. RemoveProducto.setVisible(false);
  2134. AddProveedor.setVisible(false);
  2135. RemoveProveedor.setVisible(false);
  2136. ModifyProveedor.setVisible(false);
  2137. ViewProveedor.setVisible(false);
  2138. ViewClient_1.setVisible(false);
  2139. AddEmpleado.setVisible(false);
  2140. RemoveEmpleado.setVisible(false);
  2141. ModifyEmpleado.setVisible(false);
  2142. ViewEmpleado.setVisible(false);
  2143. AddPedido.setVisible(false);
  2144. RemovePedido.setVisible(false);
  2145. ModifyPedido.setVisible(false);
  2146. ViewPedido.setVisible(false);
  2147. panel.setVisible(false);
  2148. AddClient.setVisible(false);
  2149. RemoveClient.setVisible(false);
  2150. ModifyClient.setVisible(true);
  2151. break;
  2152. case "Mostrar Cliente":
  2153. DeclaracionDiaria.setVisible(false);
  2154. ModifyVenta.setVisible(false);
  2155. MostrarVenta.setVisible(false);
  2156. AddVenta.setVisible(false);
  2157. RegistrarProducto.setVisible(false);
  2158. ModificarProducto.setVisible(false);
  2159. ViewProducto.setVisible(false);
  2160. RemoveProducto.setVisible(false);
  2161. AddProveedor.setVisible(false);
  2162. RemoveProveedor.setVisible(false);
  2163. ModifyProveedor.setVisible(false);
  2164. ViewProveedor.setVisible(false);
  2165. AddEmpleado.setVisible(false);
  2166. RemoveEmpleado.setVisible(false);
  2167. ModifyEmpleado.setVisible(false);
  2168. ViewEmpleado.setVisible(false);
  2169. AddPedido.setVisible(false);
  2170. RemovePedido.setVisible(false);
  2171. ModifyPedido.setVisible(false);
  2172. ViewPedido.setVisible(false);
  2173. panel.setVisible(false);
  2174. AddClient.setVisible(false);
  2175. RemoveClient.setVisible(false);
  2176. ModifyClient.setVisible(false);
  2177. ViewClient_1.setVisible(true);
  2178. break;
  2179. }
  2180. }
  2181. });
  2182. Cliente.setModel(new DefaultComboBoxModel(new String[] {"Cliente", "A\u00F1adir Cliente", "Remover Cliente", "Modificar Info", "Mostrar Cliente"}));
  2183.  
  2184. Venta = new JComboBox();
  2185. Venta.setBounds(91, 0, 83, 22);
  2186. frmAplicacionCooperativa.getContentPane().add(Venta);
  2187. Venta.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Venta","Registra una Venta","Consultar Ventas","Modificar Venta","Declaracion Diaria"}));
  2188. Venta.addActionListener(new ActionListener() {
  2189. public void actionPerformed(ActionEvent arg0) {
  2190. String Opcion="";
  2191. Opcion=Venta.getSelectedItem().toString();
  2192. switch(Opcion) {
  2193. case "Venta":
  2194. DeclaracionDiaria.setVisible(false);
  2195. ModifyVenta.setVisible(false);
  2196. MostrarVenta.setVisible(false);
  2197. ModificarProducto.setVisible(false);
  2198. ViewProducto.setVisible(false);
  2199. RemoveProducto.setVisible(false);
  2200. AddProveedor.setVisible(false);
  2201. RemoveProveedor.setVisible(false);
  2202. ModifyProveedor.setVisible(false);
  2203. ViewProveedor.setVisible(false);
  2204. AddEmpleado.setVisible(false);
  2205. RemoveEmpleado.setVisible(false);
  2206. ModifyEmpleado.setVisible(false);
  2207. ViewEmpleado.setVisible(false);
  2208. AddPedido.setVisible(false);
  2209. RemovePedido.setVisible(false);
  2210. ModifyPedido.setVisible(false);
  2211. ViewPedido.setVisible(false);
  2212. AddClient.setVisible(false);
  2213. RemoveClient.setVisible(false);
  2214. ModifyClient.setVisible(false);
  2215. ViewClient_1.setVisible(false);
  2216. RegistrarProducto.setVisible(false);
  2217. panel.setVisible(true);
  2218. AddVenta.setVisible(false);
  2219. break;
  2220. case "Registra una Venta":
  2221. DeclaracionDiaria.setVisible(false);
  2222. ModifyVenta.setVisible(false);
  2223. MostrarVenta.setVisible(false);
  2224. ModificarProducto.setVisible(false);
  2225. ViewProducto.setVisible(false);
  2226. RemoveProducto.setVisible(false);
  2227. AddProveedor.setVisible(false);
  2228. RemoveProveedor.setVisible(false);
  2229. ModifyProveedor.setVisible(false);
  2230. ViewProveedor.setVisible(false);
  2231. AddEmpleado.setVisible(false);
  2232. RemoveEmpleado.setVisible(false);
  2233. ModifyEmpleado.setVisible(false);
  2234. ViewEmpleado.setVisible(false);
  2235. AddPedido.setVisible(false);
  2236. RemovePedido.setVisible(false);
  2237. ModifyPedido.setVisible(false);
  2238. ViewPedido.setVisible(false);
  2239. AddClient.setVisible(false);
  2240. RemoveClient.setVisible(false);
  2241. ModifyClient.setVisible(false);
  2242. ViewClient_1.setVisible(false);
  2243. RegistrarProducto.setVisible(false);
  2244. panel.setVisible(false);
  2245. AddVenta.setVisible(true);
  2246. try {
  2247. modeloVentaP.clear();
  2248. rs=stmt.executeQuery("SELECT * FROM PRODUCTO where \"Stock\" <> 0");
  2249. while(rs.next()) {
  2250. String Id_Producto=rs.getString("Id_Producto");
  2251. String Nombre=rs.getString("Nombre");
  2252. int Precio_Unitario=rs.getInt("Precio_Unitario");
  2253. int Stock=rs.getInt("Stock");
  2254. modeloVentaP.addElement(Id_Producto+" "+Nombre+" "+Precio_Unitario+" "+Stock);
  2255. }
  2256. } catch (SQLException e1) {
  2257. // TODO Auto-generated catch block
  2258. e1.printStackTrace();
  2259. }
  2260. try {
  2261. modeloVenta.clear();
  2262. rs=stmt.executeQuery("SELECT * FROM empleado");
  2263. while(rs.next()) {
  2264. String Id_Empleado=rs.getString("Id_Empleado");
  2265. String Nombre=rs.getString("Nombre");
  2266. String apellido=rs.getString("Apellido");
  2267.  
  2268. modeloVenta.addElement(Id_Empleado+" "+Nombre+" "+apellido);
  2269. }
  2270. } catch (SQLException e1) {
  2271. // TODO Auto-generated catch block
  2272. e1.printStackTrace();
  2273. }
  2274. break;
  2275. case "Consultar Ventas":
  2276. DeclaracionDiaria.setVisible(false);
  2277. ModifyVenta.setVisible(false);
  2278. ModificarProducto.setVisible(false);
  2279. ViewProducto.setVisible(false);
  2280. RemoveProducto.setVisible(false);
  2281. AddProveedor.setVisible(false);
  2282. RemoveProveedor.setVisible(false);
  2283. ModifyProveedor.setVisible(false);
  2284. ViewProveedor.setVisible(false);
  2285. AddEmpleado.setVisible(false);
  2286. RemoveEmpleado.setVisible(false);
  2287. ModifyEmpleado.setVisible(false);
  2288. ViewEmpleado.setVisible(false);
  2289. AddPedido.setVisible(false);
  2290. RemovePedido.setVisible(false);
  2291. ModifyPedido.setVisible(false);
  2292. ViewPedido.setVisible(false);
  2293. AddClient.setVisible(false);
  2294. RemoveClient.setVisible(false);
  2295. ModifyClient.setVisible(false);
  2296. ViewClient_1.setVisible(false);
  2297. RegistrarProducto.setVisible(false);
  2298. panel.setVisible(false);
  2299. AddVenta.setVisible(false);
  2300. MostrarVenta.setVisible(true);
  2301. break;
  2302. case "Modificar Venta":
  2303. DeclaracionDiaria.setVisible(false);
  2304. ModificarProducto.setVisible(false);
  2305. ViewProducto.setVisible(false);
  2306. RemoveProducto.setVisible(false);
  2307. AddProveedor.setVisible(false);
  2308. RemoveProveedor.setVisible(false);
  2309. ModifyProveedor.setVisible(false);
  2310. ViewProveedor.setVisible(false);
  2311. AddEmpleado.setVisible(false);
  2312. RemoveEmpleado.setVisible(false);
  2313. ModifyEmpleado.setVisible(false);
  2314. ViewEmpleado.setVisible(false);
  2315. AddPedido.setVisible(false);
  2316. RemovePedido.setVisible(false);
  2317. ModifyPedido.setVisible(false);
  2318. ViewPedido.setVisible(false);
  2319. AddClient.setVisible(false);
  2320. RemoveClient.setVisible(false);
  2321. ModifyClient.setVisible(false);
  2322. ViewClient_1.setVisible(false);
  2323. RegistrarProducto.setVisible(false);
  2324. panel.setVisible(false);
  2325. AddVenta.setVisible(false);
  2326. MostrarVenta.setVisible(false);
  2327. ModifyVenta.setVisible(true);
  2328. break;
  2329. case "Declaracion Diaria":
  2330.  
  2331. ModificarProducto.setVisible(false);
  2332. ViewProducto.setVisible(false);
  2333. RemoveProducto.setVisible(false);
  2334. AddProveedor.setVisible(false);
  2335. RemoveProveedor.setVisible(false);
  2336. ModifyProveedor.setVisible(false);
  2337. ViewProveedor.setVisible(false);
  2338. AddEmpleado.setVisible(false);
  2339. RemoveEmpleado.setVisible(false);
  2340. ModifyEmpleado.setVisible(false);
  2341. ViewEmpleado.setVisible(false);
  2342. AddPedido.setVisible(false);
  2343. RemovePedido.setVisible(false);
  2344. ModifyPedido.setVisible(false);
  2345. ViewPedido.setVisible(false);
  2346. AddClient.setVisible(false);
  2347. RemoveClient.setVisible(false);
  2348. ModifyClient.setVisible(false);
  2349. ViewClient_1.setVisible(false);
  2350. RegistrarProducto.setVisible(false);
  2351. panel.setVisible(false);
  2352. AddVenta.setVisible(false);
  2353. MostrarVenta.setVisible(false);
  2354. ModifyVenta.setVisible(false);
  2355. DeclaracionDiaria.setVisible(true);
  2356. break;
  2357. }
  2358. }
  2359. });
  2360.  
  2361. Productos = new JComboBox();
  2362. Productos.setBounds(254, 0, 83, 22);
  2363. Productos.setModel(new DefaultComboBoxModel(new String[] {"Productos", "Registra Producto", "Elimina Producto", "Modifica Info", "Buscar Producto"}));
  2364. frmAplicacionCooperativa.getContentPane().add(Productos);
  2365. Productos.addActionListener(new ActionListener() {
  2366. public void actionPerformed(ActionEvent e) {
  2367. String opcion="";
  2368. opcion=Productos.getSelectedItem().toString();
  2369. switch(opcion) {
  2370. case "Producto":
  2371. DeclaracionDiaria.setVisible(false);
  2372. ModifyVenta.setVisible(false);
  2373. MostrarVenta.setVisible(false);
  2374. AddVenta.setVisible(false);
  2375. ModificarProducto.setVisible(false);
  2376. ViewProducto.setVisible(false);
  2377. RemoveProducto.setVisible(false);
  2378. AddProveedor.setVisible(false);
  2379. RemoveProveedor.setVisible(false);
  2380. ModifyProveedor.setVisible(false);
  2381. ViewProveedor.setVisible(false);
  2382. AddEmpleado.setVisible(false);
  2383. RemoveEmpleado.setVisible(false);
  2384. ModifyEmpleado.setVisible(false);
  2385. ViewEmpleado.setVisible(false);
  2386. AddPedido.setVisible(false);
  2387. RemovePedido.setVisible(false);
  2388. ModifyPedido.setVisible(false);
  2389. ViewPedido.setVisible(false);
  2390. AddClient.setVisible(false);
  2391. RemoveClient.setVisible(false);
  2392. ModifyClient.setVisible(false);
  2393. ViewClient_1.setVisible(false);
  2394. RegistrarProducto.setVisible(false);
  2395. panel.setVisible(true);
  2396. break;
  2397. case "Registra Producto":
  2398. DeclaracionDiaria.setVisible(false);
  2399. ModifyVenta.setVisible(false);
  2400. MostrarVenta.setVisible(false);
  2401. AddVenta.setVisible(false);
  2402. ModificarProducto.setVisible(false);
  2403. ViewProducto.setVisible(false);
  2404. RemoveProducto.setVisible(false);
  2405. AddProveedor.setVisible(false);
  2406. RemoveProveedor.setVisible(false);
  2407. ModifyProveedor.setVisible(false);
  2408. ViewProveedor.setVisible(false);
  2409. AddEmpleado.setVisible(false);
  2410. RemoveEmpleado.setVisible(false);
  2411. ModifyEmpleado.setVisible(false);
  2412. ViewEmpleado.setVisible(false);
  2413. AddPedido.setVisible(false);
  2414. RemovePedido.setVisible(false);
  2415. ModifyPedido.setVisible(false);
  2416. ViewPedido.setVisible(false);
  2417. panel.setVisible(false);
  2418. AddClient.setVisible(false);
  2419. RemoveClient.setVisible(false);
  2420. ModifyClient.setVisible(false);
  2421. ViewClient_1.setVisible(false);
  2422. RegistrarProducto.setVisible(true);
  2423. break;
  2424. case "Elimina Producto":
  2425. DeclaracionDiaria.setVisible(false);
  2426. ModifyVenta.setVisible(false);
  2427. MostrarVenta.setVisible(false);
  2428. AddVenta.setVisible(false);
  2429. ModificarProducto.setVisible(false);
  2430. ViewProducto.setVisible(false);
  2431. AddProveedor.setVisible(false);
  2432. RemoveProveedor.setVisible(false);
  2433. ModifyProveedor.setVisible(false);
  2434. ViewProveedor.setVisible(false);
  2435. AddEmpleado.setVisible(false);
  2436. RemoveEmpleado.setVisible(false);
  2437. ModifyEmpleado.setVisible(false);
  2438. ViewEmpleado.setVisible(false);
  2439. AddPedido.setVisible(false);
  2440. RemovePedido.setVisible(false);
  2441. ModifyPedido.setVisible(false);
  2442. ViewPedido.setVisible(false);
  2443. panel.setVisible(false);
  2444. AddClient.setVisible(false);
  2445. RemoveClient.setVisible(false);
  2446. ModifyClient.setVisible(false);
  2447. ViewClient_1.setVisible(false);
  2448. RegistrarProducto.setVisible(false);
  2449. RemoveProducto.setVisible(true);
  2450. break;
  2451. case "Modifica Info":
  2452. DeclaracionDiaria.setVisible(false);
  2453. ModifyVenta.setVisible(false);
  2454. MostrarVenta.setVisible(false);
  2455. AddVenta.setVisible(false);
  2456. ViewProducto.setVisible(false);
  2457. AddProveedor.setVisible(false);
  2458. RemoveProveedor.setVisible(false);
  2459. ModifyProveedor.setVisible(false);
  2460. ViewProveedor.setVisible(false);
  2461. AddEmpleado.setVisible(false);
  2462. RemoveEmpleado.setVisible(false);
  2463. ModifyEmpleado.setVisible(false);
  2464. ViewEmpleado.setVisible(false);
  2465. AddPedido.setVisible(false);
  2466. RemovePedido.setVisible(false);
  2467. ModifyPedido.setVisible(false);
  2468. ViewPedido.setVisible(false);
  2469. panel.setVisible(false);
  2470. AddClient.setVisible(false);
  2471. RemoveClient.setVisible(false);
  2472. ModifyClient.setVisible(false);
  2473. ViewClient_1.setVisible(false);
  2474. RegistrarProducto.setVisible(false);
  2475. RemoveProducto.setVisible(false);
  2476. ModificarProducto.setVisible(true);
  2477. try {
  2478. modelo.clear();
  2479. rs=stmt.executeQuery("SELECT * FROM PRODUCTO");
  2480. while(rs.next()) {
  2481. String Id_Producto=rs.getString("Id_Producto");
  2482. String Nombre=rs.getString("Nombre");
  2483. int Precio_Unitario=rs.getInt("Precio_Unitario");
  2484. int Stock=rs.getInt("Stock");
  2485. modelo.addElement(Id_Producto+" "+Nombre+" "+Precio_Unitario+" "+Stock);
  2486. }
  2487. } catch (SQLException e1) {
  2488. // TODO Auto-generated catch block
  2489. e1.printStackTrace();
  2490. }
  2491.  
  2492. break;
  2493. case "Buscar Producto":
  2494. DeclaracionDiaria.setVisible(false);
  2495. ModifyVenta.setVisible(false);
  2496. MostrarVenta.setVisible(false);
  2497. AddVenta.setVisible(false);
  2498. AddProveedor.setVisible(false);
  2499. RemoveProveedor.setVisible(false);
  2500. ModifyProveedor.setVisible(false);
  2501. ViewProveedor.setVisible(false);
  2502. AddEmpleado.setVisible(false);
  2503. RemoveEmpleado.setVisible(false);
  2504. ModifyEmpleado.setVisible(false);
  2505. ViewEmpleado.setVisible(false);
  2506. AddPedido.setVisible(false);
  2507. RemovePedido.setVisible(false);
  2508. ModifyPedido.setVisible(false);
  2509. ViewPedido.setVisible(false);
  2510. panel.setVisible(false);
  2511. AddClient.setVisible(false);
  2512. RemoveClient.setVisible(false);
  2513. ModifyClient.setVisible(false);
  2514. ViewClient_1.setVisible(false);
  2515. RegistrarProducto.setVisible(false);
  2516. RemoveProducto.setVisible(false);
  2517. ModificarProducto.setVisible(false);
  2518. ViewProducto.setVisible(true);
  2519. try {
  2520. modelo.clear();
  2521. rs=stmt.executeQuery("SELECT * FROM PRODUCTO");
  2522. while(rs.next()) {
  2523. String Id_Producto=rs.getString("Id_Producto");
  2524. String Nombre=rs.getString("Nombre");
  2525. int Precio_Unitario=rs.getInt("Precio_Unitario");
  2526. int Stock=rs.getInt("Stock");
  2527. modelo.addElement(Id_Producto+" "+Nombre+" "+Precio_Unitario+" "+Stock);
  2528. }
  2529. } catch (SQLException e1) {
  2530. // TODO Auto-generated catch block
  2531. e1.printStackTrace();
  2532. }
  2533. break;
  2534. }
  2535. }
  2536. });
  2537.  
  2538.  
  2539. JComboBox Proveedor = new JComboBox();
  2540. Proveedor.setModel(new DefaultComboBoxModel(new String[] {"Proveedor", "A\u00F1adir Proveedor", "Remover Proveedor", "Modificar Info", "Buscar Proveedor"}));
  2541. Proveedor.setBounds(414, 1, 83, 21);
  2542. frmAplicacionCooperativa.getContentPane().add(Proveedor);
  2543. Proveedor.addActionListener(new ActionListener() {
  2544. public void actionPerformed(ActionEvent e) {
  2545.  
  2546. String opcion = "Seleccione una Opcion";
  2547. opcion= Proveedor.getSelectedItem().toString();
  2548. switch(opcion) {
  2549. case "Proveedor":
  2550. DeclaracionDiaria.setVisible(false);
  2551. ModifyVenta.setVisible(false);
  2552. MostrarVenta.setVisible(false);
  2553. AddVenta.setVisible(false);
  2554. RegistrarProducto.setVisible(false);
  2555. ModificarProducto.setVisible(false);
  2556. ViewProducto.setVisible(false);
  2557. RemoveProducto.setVisible(false);
  2558. AddProveedor.setVisible(false);
  2559. RemoveProveedor.setVisible(false);
  2560. ModifyProveedor.setVisible(false);
  2561. ViewProveedor.setVisible(false);
  2562. AddClient.setVisible(false);
  2563. RemoveClient.setVisible(false);
  2564. ModifyClient.setVisible(false);
  2565. ViewClient_1.setVisible(false);
  2566. AddEmpleado.setVisible(false);
  2567. RemoveEmpleado.setVisible(false);
  2568. ModifyEmpleado.setVisible(false);
  2569. ViewEmpleado.setVisible(false);
  2570. AddPedido.setVisible(false);
  2571. RemovePedido.setVisible(false);
  2572. ModifyPedido.setVisible(false);
  2573. ViewPedido.setVisible(false);
  2574. panel.setVisible(true);
  2575. break;
  2576. case "Añadir Proveedor":
  2577. DeclaracionDiaria.setVisible(false);
  2578. ModifyVenta.setVisible(false);
  2579. MostrarVenta.setVisible(false);
  2580. AddVenta.setVisible(false);
  2581. RegistrarProducto.setVisible(false);
  2582. ModificarProducto.setVisible(false);
  2583. ViewProducto.setVisible(false);
  2584. RemoveProducto.setVisible(false);
  2585. RemoveProveedor.setVisible(false);
  2586. ModifyProveedor.setVisible(false);
  2587. ViewProveedor.setVisible(false);
  2588. AddClient.setVisible(false);
  2589. RemoveClient.setVisible(false);
  2590. ModifyClient.setVisible(false);
  2591. ViewClient_1.setVisible(false);
  2592. AddEmpleado.setVisible(false);
  2593. RemoveEmpleado.setVisible(false);
  2594. ModifyEmpleado.setVisible(false);
  2595. ViewEmpleado.setVisible(false);
  2596. AddPedido.setVisible(false);
  2597. RemovePedido.setVisible(false);
  2598. ModifyPedido.setVisible(false);
  2599. ViewPedido.setVisible(false);
  2600. panel.setVisible(false);
  2601. AddProveedor.setVisible(true);
  2602. break;
  2603. case "Remover Proveedor":
  2604. DeclaracionDiaria.setVisible(false);
  2605. ModifyVenta.setVisible(false);
  2606. MostrarVenta.setVisible(false);
  2607. AddVenta.setVisible(false);
  2608. RegistrarProducto.setVisible(false);
  2609. ModificarProducto.setVisible(false);
  2610. ViewProducto.setVisible(false);
  2611. RemoveProducto.setVisible(false);
  2612. ModifyProveedor.setVisible(false);
  2613. ViewProveedor.setVisible(false);
  2614. AddClient.setVisible(false);
  2615. RemoveClient.setVisible(false);
  2616. ModifyClient.setVisible(false);
  2617. ViewClient_1.setVisible(false);
  2618. AddEmpleado.setVisible(false);
  2619. RemoveEmpleado.setVisible(false);
  2620. ModifyEmpleado.setVisible(false);
  2621. ViewEmpleado.setVisible(false);
  2622. AddPedido.setVisible(false);
  2623. RemovePedido.setVisible(false);
  2624. ModifyPedido.setVisible(false);
  2625. ViewPedido.setVisible(false);
  2626. panel.setVisible(false);
  2627. AddProveedor.setVisible(false);
  2628. RemoveProveedor.setVisible(true);
  2629. break;
  2630. case "Modificar Info":
  2631. DeclaracionDiaria.setVisible(false);
  2632. ModifyVenta.setVisible(false);
  2633. MostrarVenta.setVisible(false);
  2634. AddVenta.setVisible(false);
  2635. RegistrarProducto.setVisible(false);
  2636. ModificarProducto.setVisible(false);
  2637. ViewProducto.setVisible(false);
  2638. RemoveProducto.setVisible(false);
  2639. ViewProveedor.setVisible(false);
  2640. AddClient.setVisible(false);
  2641. RemoveClient.setVisible(false);
  2642. ModifyClient.setVisible(false);
  2643. ViewClient_1.setVisible(false);
  2644. AddEmpleado.setVisible(false);
  2645. RemoveEmpleado.setVisible(false);
  2646. ModifyEmpleado.setVisible(false);
  2647. ViewEmpleado.setVisible(false);
  2648. AddPedido.setVisible(false);
  2649. RemovePedido.setVisible(false);
  2650. ModifyPedido.setVisible(false);
  2651. ViewPedido.setVisible(false);
  2652. panel.setVisible(false);
  2653. AddProveedor.setVisible(false);
  2654. RemoveProveedor.setVisible(false);
  2655. ModifyProveedor.setVisible(true);
  2656. break;
  2657. case "Buscar Proveedor":
  2658. DeclaracionDiaria.setVisible(false);
  2659. ModifyVenta.setVisible(false);
  2660. MostrarVenta.setVisible(false);
  2661. AddVenta.setVisible(false);
  2662. RegistrarProducto.setVisible(false);
  2663. ModificarProducto.setVisible(false);
  2664. ViewProducto.setVisible(false);
  2665. RemoveProducto.setVisible(false);
  2666. AddClient.setVisible(false);
  2667. RemoveClient.setVisible(false);
  2668. ModifyClient.setVisible(false);
  2669. ViewClient_1.setVisible(false);
  2670. AddEmpleado.setVisible(false);
  2671. RemoveEmpleado.setVisible(false);
  2672. ModifyEmpleado.setVisible(false);
  2673. ViewEmpleado.setVisible(false);
  2674. AddPedido.setVisible(false);
  2675. RemovePedido.setVisible(false);
  2676. ModifyPedido.setVisible(false);
  2677. ViewPedido.setVisible(false);
  2678. panel.setVisible(false);
  2679. AddProveedor.setVisible(false);
  2680. RemoveProveedor.setVisible(false);
  2681. ModifyProveedor.setVisible(false);
  2682. ViewProveedor.setVisible(true);
  2683. break;
  2684. }
  2685. }
  2686. });
  2687.  
  2688. JComboBox Empleado = new JComboBox();
  2689. Empleado.setModel(new DefaultComboBoxModel(new String[] {"Empleado", "A\u00F1adir Empleado", "Remover Empleado", "Modificar Info", "Buscar Empleado"}));
  2690. Empleado.setBounds(173, 1, 83, 21);
  2691. frmAplicacionCooperativa.getContentPane().add(Empleado);
  2692.  
  2693. JComboBox Pedido = new JComboBox();
  2694. Pedido.setBounds(336, 0, 83, 22);
  2695. Pedido.setModel(new DefaultComboBoxModel(new String[] {"Pedidos", "Hacer Pedido", "Modificar Pedido", "Eliminar Pedido", "Buscar Pedido"}));
  2696. frmAplicacionCooperativa.getContentPane().add(Pedido);
  2697. Pedido.addActionListener(new ActionListener() {
  2698. public void actionPerformed(ActionEvent e) {
  2699.  
  2700. String opcion = "Seleccione una Opcion";
  2701. opcion= Pedido.getSelectedItem().toString();
  2702. switch(opcion) {
  2703. case "Pedidos":
  2704. DeclaracionDiaria.setVisible(false);
  2705. ModifyVenta.setVisible(false);
  2706. MostrarVenta.setVisible(false);
  2707. AddVenta.setVisible(false);
  2708. AddPedido.setVisible(false);
  2709. RemovePedido.setVisible(false);
  2710. ModifyPedido.setVisible(false);
  2711. ViewPedido.setVisible(false);
  2712. RegistrarProducto.setVisible(false);
  2713. ModificarProducto.setVisible(false);
  2714. ViewProducto.setVisible(false);
  2715. RemoveProducto.setVisible(false);
  2716. AddProveedor.setVisible(false);
  2717. RemoveProveedor.setVisible(false);
  2718. ModifyProveedor.setVisible(false);
  2719. ViewProveedor.setVisible(false);
  2720. AddClient.setVisible(false);
  2721. RemoveClient.setVisible(false);
  2722. ModifyClient.setVisible(false);
  2723. ViewClient_1.setVisible(false);
  2724. AddEmpleado.setVisible(false);
  2725. RemoveEmpleado.setVisible(false);
  2726. ModifyEmpleado.setVisible(false);
  2727. ViewEmpleado.setVisible(false);
  2728. panel.setVisible(true);
  2729. break;
  2730. case "Hacer Pedido":
  2731. DeclaracionDiaria.setVisible(false);
  2732. ModifyVenta.setVisible(false);
  2733. MostrarVenta.setVisible(false);
  2734. AddVenta.setVisible(false);
  2735. panel.setVisible(false);
  2736. RemovePedido.setVisible(false);
  2737. ModifyPedido.setVisible(false);
  2738. ViewPedido.setVisible(false);
  2739. RegistrarProducto.setVisible(false);
  2740. ModificarProducto.setVisible(false);
  2741. ViewProducto.setVisible(false);
  2742. RemoveProducto.setVisible(false);
  2743. AddProveedor.setVisible(false);
  2744. RemoveProveedor.setVisible(false);
  2745. ModifyProveedor.setVisible(false);
  2746. ViewProveedor.setVisible(false);
  2747. AddClient.setVisible(false);
  2748. RemoveClient.setVisible(false);
  2749. ModifyClient.setVisible(false);
  2750. ViewClient_1.setVisible(false);
  2751. AddEmpleado.setVisible(false);
  2752. RemoveEmpleado.setVisible(false);
  2753. ModifyEmpleado.setVisible(false);
  2754. ViewEmpleado.setVisible(false);
  2755. AddPedido.setVisible(true);
  2756. try {
  2757. modeloPedido.clear();
  2758. rs=stmt.executeQuery("SELECT * FROM producto");
  2759. while(rs.next()) {
  2760. String Id_Producto=rs.getString("Id_Producto");
  2761. String Nombre=rs.getString("Nombre");
  2762. int Precio_Unitario=rs.getInt("Precio_Unitario");
  2763. int Stock=rs.getInt("Stock");
  2764. modeloPedido.addElement(Id_Producto+"-----"+Nombre+"-----"+Precio_Unitario+"-----"+Stock);
  2765. }
  2766. } catch (SQLException e1) {
  2767. // TODO Auto-generated catch block
  2768. e1.printStackTrace();
  2769. }
  2770. break;
  2771. case "Eliminar Pedido":
  2772. DeclaracionDiaria.setVisible(false);
  2773. ModifyVenta.setVisible(false);
  2774. MostrarVenta.setVisible(false);
  2775. AddVenta.setVisible(false);
  2776. panel.setVisible(false);
  2777. ModifyPedido.setVisible(false);
  2778. ViewPedido.setVisible(false);
  2779. RegistrarProducto.setVisible(false);
  2780. ModificarProducto.setVisible(false);
  2781. ViewProducto.setVisible(false);
  2782. RemoveProducto.setVisible(false);
  2783. AddProveedor.setVisible(false);
  2784. RemoveProveedor.setVisible(false);
  2785. ModifyProveedor.setVisible(false);
  2786. ViewProveedor.setVisible(false);
  2787. AddClient.setVisible(false);
  2788. RemoveClient.setVisible(false);
  2789. ModifyClient.setVisible(false);
  2790. ViewClient_1.setVisible(false);
  2791. AddEmpleado.setVisible(false);
  2792. RemoveEmpleado.setVisible(false);
  2793. ModifyEmpleado.setVisible(false);
  2794. ViewEmpleado.setVisible(false);
  2795. AddPedido.setVisible(false);
  2796. RemovePedido.setVisible(true);
  2797. break;
  2798. case "Modificar Pedido":
  2799. DeclaracionDiaria.setVisible(false);
  2800. ModifyVenta.setVisible(false);
  2801. MostrarVenta.setVisible(false);
  2802. AddVenta.setVisible(false);
  2803. panel.setVisible(false);
  2804. ViewPedido.setVisible(false);
  2805. RegistrarProducto.setVisible(false);
  2806. ModificarProducto.setVisible(false);
  2807. ViewProducto.setVisible(false);
  2808. RemoveProducto.setVisible(false);
  2809. AddProveedor.setVisible(false);
  2810. RemoveProveedor.setVisible(false);
  2811. ModifyProveedor.setVisible(false);
  2812. ViewProveedor.setVisible(false);
  2813. AddClient.setVisible(false);
  2814. RemoveClient.setVisible(false);
  2815. ModifyClient.setVisible(false);
  2816. ViewClient_1.setVisible(false);
  2817. AddEmpleado.setVisible(false);
  2818. RemoveEmpleado.setVisible(false);
  2819. ModifyEmpleado.setVisible(false);
  2820. ViewEmpleado.setVisible(false);
  2821. AddPedido.setVisible(false);
  2822. RemovePedido.setVisible(false);
  2823. ModifyPedido.setVisible(true);
  2824. break;
  2825. case "Buscar Pedido":
  2826. DeclaracionDiaria.setVisible(false);
  2827. ModifyVenta.setVisible(false);
  2828. MostrarVenta.setVisible(false);
  2829. System.out.println("aqui");
  2830. AddVenta.setVisible(false);
  2831. panel.setVisible(false);
  2832. RegistrarProducto.setVisible(false);
  2833. ModificarProducto.setVisible(false);
  2834. ViewProducto.setVisible(false);
  2835. RemoveProducto.setVisible(false);
  2836. AddProveedor.setVisible(false);
  2837. RemoveProveedor.setVisible(false);
  2838. ModifyProveedor.setVisible(false);
  2839. ViewProveedor.setVisible(false);
  2840. AddClient.setVisible(false);
  2841. RemoveClient.setVisible(false);
  2842. ModifyClient.setVisible(false);
  2843. ViewClient_1.setVisible(false);
  2844. AddEmpleado.setVisible(false);
  2845. RemoveEmpleado.setVisible(false);
  2846. ModifyEmpleado.setVisible(false);
  2847. ViewEmpleado.setVisible(false);
  2848. AddPedido.setVisible(false);
  2849. RemovePedido.setVisible(false);
  2850. ModifyPedido.setVisible(false);
  2851. ViewPedido.setVisible(true);
  2852. try {
  2853. modeloVerPedido.clear();
  2854. rs=stmt.executeQuery("SELECT a.\"Id_Pedido\",a.\"Fecha\",a.\"Valor_Pedido\",concat(b.\"Nombre\",b.\"Apellido\") \"Nombre Completo\",c.\"Nombre\" FROM Pedido a,empleado b,proveedor c where a.\"Id_Empleado\"=b.\"Id_Empleado\" and c.\"Id_Proveedor\"=a.\"Id_Proveedor\"");
  2855. System.out.println("asd");
  2856. while(rs.next()) {
  2857. String Id_Pedido=rs.getString("Id_Pedido");
  2858. Date fecha=rs.getDate("Fecha");
  2859. int Precio_Unitario=rs.getInt("Valor_Pedido");
  2860. String nombreEmpleado=rs.getString("Nombre Completo");
  2861. String nombreProveedor= rs.getString("Nombre");
  2862. modeloVerPedido.addElement(Id_Pedido+" "+fecha+" "+Precio_Unitario+" "+nombreEmpleado+" "+nombreProveedor);
  2863. }
  2864. } catch (SQLException e1) {
  2865. // TODO Auto-generated catch block
  2866. e1.printStackTrace();
  2867. }
  2868. break;
  2869. }
  2870. }
  2871. });
  2872. Empleado.addActionListener(new ActionListener() {
  2873. public void actionPerformed(ActionEvent e) {
  2874.  
  2875. String opcion = "Seleccione una Opcion";
  2876. opcion= Empleado.getSelectedItem().toString();
  2877. switch(opcion) {
  2878. case "Empleado":
  2879. DeclaracionDiaria.setVisible(false);
  2880. ModifyVenta.setVisible(false);
  2881. MostrarVenta.setVisible(false);
  2882. AddVenta.setVisible(false);
  2883. RegistrarProducto.setVisible(false);
  2884. ModificarProducto.setVisible(false);
  2885. ViewProducto.setVisible(false);
  2886. RemoveProducto.setVisible(false);
  2887. AddClient.setVisible(false);
  2888. RemoveClient.setVisible(false);
  2889. ModifyClient.setVisible(false);
  2890. ViewClient_1.setVisible(false);
  2891. AddEmpleado.setVisible(false);
  2892. RemoveEmpleado.setVisible(false);
  2893. ModifyEmpleado.setVisible(false);
  2894. ViewEmpleado.setVisible(false);
  2895. AddPedido.setVisible(false);
  2896. RemovePedido.setVisible(false);
  2897. ModifyPedido.setVisible(false);
  2898. ViewPedido.setVisible(false);
  2899. AddProveedor.setVisible(false);
  2900. RemoveProveedor.setVisible(false);
  2901. ModifyProveedor.setVisible(false);
  2902. ViewProveedor.setVisible(false);
  2903. panel.setVisible(true);
  2904. break;
  2905. case "Añadir Empleado":
  2906. DeclaracionDiaria.setVisible(false);
  2907. ModifyVenta.setVisible(false);
  2908. MostrarVenta.setVisible(false);
  2909. AddVenta.setVisible(false);
  2910. RegistrarProducto.setVisible(false);
  2911. ModificarProducto.setVisible(false);
  2912. ViewProducto.setVisible(false);
  2913. RemoveProducto.setVisible(false);
  2914. AddClient.setVisible(false);
  2915. RemoveClient.setVisible(false);
  2916. ModifyClient.setVisible(false);
  2917. ViewClient_1.setVisible(false);
  2918. RemoveEmpleado.setVisible(false);
  2919. ModifyEmpleado.setVisible(false);
  2920. ViewEmpleado.setVisible(false);
  2921. AddPedido.setVisible(false);
  2922. RemovePedido.setVisible(false);
  2923. ModifyPedido.setVisible(false);
  2924. ViewPedido.setVisible(false);
  2925. AddProveedor.setVisible(false);
  2926. RemoveProveedor.setVisible(false);
  2927. ModifyProveedor.setVisible(false);
  2928. ViewProveedor.setVisible(false);
  2929. panel.setVisible(false);
  2930. AddEmpleado.setVisible(true);
  2931. break;
  2932. case "Remover Empleado":
  2933. DeclaracionDiaria.setVisible(false);
  2934. ModifyVenta.setVisible(false);
  2935. MostrarVenta.setVisible(false);
  2936. AddVenta.setVisible(false);
  2937. RegistrarProducto.setVisible(false);
  2938. ModificarProducto.setVisible(false);
  2939. ViewProducto.setVisible(false);
  2940. RemoveProducto.setVisible(false);
  2941. AddClient.setVisible(false);
  2942. RemoveClient.setVisible(false);
  2943. ModifyClient.setVisible(false);
  2944. ViewClient_1.setVisible(false);
  2945. ModifyEmpleado.setVisible(false);
  2946. ViewEmpleado.setVisible(false);
  2947. AddPedido.setVisible(false);
  2948. RemovePedido.setVisible(false);
  2949. ModifyPedido.setVisible(false);
  2950. ViewPedido.setVisible(false);
  2951. AddProveedor.setVisible(false);
  2952. RemoveProveedor.setVisible(false);
  2953. ModifyProveedor.setVisible(false);
  2954. ViewProveedor.setVisible(false);
  2955. panel.setVisible(false);
  2956. AddEmpleado.setVisible(false);
  2957. RemoveEmpleado.setVisible(true);
  2958. break;
  2959. case "Modificar Info":
  2960. DeclaracionDiaria.setVisible(false);
  2961. ModifyVenta.setVisible(false);
  2962. MostrarVenta.setVisible(false);
  2963. AddVenta.setVisible(false);
  2964. RegistrarProducto.setVisible(false);
  2965. ModificarProducto.setVisible(false);
  2966. ViewProducto.setVisible(false);
  2967. RemoveProducto.setVisible(false);
  2968. AddClient.setVisible(false);
  2969. RemoveClient.setVisible(false);
  2970. ModifyClient.setVisible(false);
  2971. ViewClient_1.setVisible(false);
  2972. ViewEmpleado.setVisible(false);
  2973. AddPedido.setVisible(false);
  2974. RemovePedido.setVisible(false);
  2975. ModifyPedido.setVisible(false);
  2976. ViewPedido.setVisible(false);
  2977. AddProveedor.setVisible(false);
  2978. RemoveProveedor.setVisible(false);
  2979. ModifyProveedor.setVisible(false);
  2980. ViewProveedor.setVisible(false);
  2981. panel.setVisible(false);
  2982. AddEmpleado.setVisible(false);
  2983. RemoveEmpleado.setVisible(false);
  2984. ModifyEmpleado.setVisible(true);
  2985. break;
  2986. case "Buscar Empleado":
  2987. DeclaracionDiaria.setVisible(false);
  2988. ModifyVenta.setVisible(false);
  2989. MostrarVenta.setVisible(false);
  2990. AddVenta.setVisible(false);
  2991. RegistrarProducto.setVisible(false);
  2992. ModificarProducto.setVisible(false);
  2993. ViewProducto.setVisible(false);
  2994. RemoveProducto.setVisible(false);
  2995. AddClient.setVisible(false);
  2996. RemoveClient.setVisible(false);
  2997. ModifyClient.setVisible(false);
  2998. ViewClient_1.setVisible(false);
  2999. AddPedido.setVisible(false);
  3000. RemovePedido.setVisible(false);
  3001. ModifyPedido.setVisible(false);
  3002. ViewPedido.setVisible(false);
  3003. AddProveedor.setVisible(false);
  3004. RemoveProveedor.setVisible(false);
  3005. ModifyProveedor.setVisible(false);
  3006. ViewProveedor.setVisible(false);
  3007. panel.setVisible(false);
  3008. AddEmpleado.setVisible(false);
  3009. RemoveEmpleado.setVisible(false);
  3010. ModifyEmpleado.setVisible(false);
  3011. ViewEmpleado.setVisible(true);
  3012. break;
  3013. }
  3014. }
  3015. });
  3016. }
  3017. public static int countId(String tabla, Statement stmt, ResultSet rs) {
  3018. int count=0;
  3019. try {
  3020. if(tabla.equals("detalle_pedido")) {
  3021. rs = stmt.executeQuery("select count(\"Id_DetalleP\") as count from detalle_Pedido ");
  3022. while (rs.next()){
  3023. count = rs.getInt("count");
  3024. return count;
  3025. }
  3026.  
  3027. }else if(tabla.equals("detalle_venta")){
  3028. rs = stmt.executeQuery("select count(\"Id_DetalleVenta\") as count from detalle_venta ");
  3029. while (rs.next()){
  3030. count = rs.getInt("count");
  3031. return count;
  3032. }
  3033. }else if(tabla.equals("declaracion_diaria")){
  3034. rs = stmt.executeQuery("select count(\"Id_Declaracion\") as count from declaracion_diaria ");
  3035. while (rs.next()){
  3036. count = rs.getInt("count");
  3037. return count;
  3038. }
  3039. }else {
  3040.  
  3041. rs = stmt.executeQuery("select count(\"Id_"+ucFirst(tabla)+"\")as count from "+tabla+" ");
  3042. while (rs.next()){
  3043. count = rs.getInt("count");
  3044. return count;
  3045. }
  3046. }return 0;
  3047. }catch (Exception e) {
  3048. return 0;
  3049. }
  3050. }
  3051. public static String ucFirst(String str) {
  3052. if (str.isEmpty()) {
  3053. return str;
  3054. } else {
  3055. return Character.toUpperCase(str.charAt(0)) + str.substring(1);
  3056. }
  3057. }
  3058. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement