Пример #1
0
 @Override
 public void windowClosing(WindowEvent arg0) {
   if (buttonselected.equals("start")) {
     fromDateTxt.setText(cal.getSelectedDate());
   } else if (buttonselected.equals("end")) {
     toDateTxt.setText(cal.getSelectedDate());
   }
 }
 private void ok1() {
   if (lb_endorse.getText().isEmpty() || lb_endorse.getText().equals("0")) {
     return;
   }
   String date = DateType.datetime.format(dp_date.getDate());
   double qty = Double.parseDouble(lb_endorse.getText());
   if (callback != null) {
     callback.ok(new CloseDialog(this), new OutputData(qty, date));
   }
 }
Пример #3
0
 public void getBooking() {
   SimpleDateFormat formatter = new SimpleDateFormat();
   formatter.applyPattern("yyyy-MM-dd");
   Calendar date = Calendar.getInstance();
   date.setTime(calendar.getDate());
   date.set(Calendar.MONTH, date.get(Calendar.MONTH) - 1);
   String dataString = formatter.format(date.getTime());
   String[] columnNames = {"Ora", "Cognome", "Nome", "Prestazione", "Tel."};
   String query =
       "SELECT OraInizio, Cognome, Nome,  Descrizione, Telefono FROM prenotazione, cliente WHERE Id_Cliente = cliente.id AND prenotazione.GiornoInizio  ='"
           + dataString
           + "' ORDER BY OraInizio;";
   try {
     Vector<Object[]> data = SQLManager.executeQuery(query);
     populateTable(columnNames, data);
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Пример #4
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    try {
      for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        if ("Windows".equals(info.getName())) {
          UIManager.setLookAndFeel(info.getClassName());
          break;
        }
      }
    } catch (Exception e) {
    }

    frmReporteDeVentas = new JFrame();
    frmReporteDeVentas.setResizable(false);
    frmReporteDeVentas.setTitle("Reporte de Ventas");
    frmReporteDeVentas.setBounds(100, 100, 768, 543);
    frmReporteDeVentas.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frmReporteDeVentas.getContentPane().setLayout(null);

    JLabel lblNewLabel_1 = new JLabel(PedidoDTO.generarFechaForm());
    lblNewLabel_1.setBounds(10, 0, 200, 50);
    frmReporteDeVentas.getContentPane().add(lblNewLabel_1);

    JButton btnNewButton = new JButton("Cerrar");
    btnNewButton.setBounds(625, 472, 89, 23);
    btnNewButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            frmReporteDeVentas.dispose();
          }
        });
    frmReporteDeVentas.getContentPane().add(btnNewButton);

    JLabel label_1 = new JLabel("Ingresos:");
    label_1.setBounds(453, 55, 200, 50);
    label_1.setFont(new Font("Tahoma", Font.PLAIN, 15));
    frmReporteDeVentas.getContentPane().add(label_1);

    JSeparator separator = new JSeparator();
    separator.setBounds(36, 449, 709, 12);
    frmReporteDeVentas.getContentPane().add(separator);

    lblNewLabel_3 = new JLabel("0");
    lblNewLabel_3.setBounds(537, 55, 95, 50);
    lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 15));
    frmReporteDeVentas.getContentPane().add(lblNewLabel_3);

    JButton btnNewButton_1 = new JButton("Generar Contabilidad");
    btnNewButton_1.setBounds(36, 406, 166, 32);
    btnNewButton_1.setFont(new Font("Tahoma", Font.PLAIN, 13));
    btnNewButton_1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {

            mapA = new HashMap();
            mapA.put("Monday", "Sunday");
            mapA.put("Tuesday", "Monday");
            mapA.put("Wednesday", "Tuesday");
            mapA.put("Thursday", "Wednesday");
            mapA.put("Friday", "Thursday");
            mapA.put("Saturday", "Friday");
            mapA.put("Sunday", "Saturday");

            mapB = new HashMap();
            mapB.put("Monday", "Tuesday");
            mapB.put("Tuesday", "Wednesday");
            mapB.put("Wednesday", "Thursday");
            mapB.put("Thursday", "Friday");
            mapB.put("Friday", "Saturday");
            mapB.put("Saturday", "Sunday");
            mapB.put("Sunday", "Monday");

            ingreso = 0;
            limpiaTablaIngreso();

            if (rdbtnDiario.isSelected()) {
              SimpleDateFormat FormatoDia = new SimpleDateFormat("dd");
              SimpleDateFormat FormatoMes = new SimpleDateFormat("MM");
              // traer ingresos
              List<PedidoDTO> pedidos = new ArrayList<>();
              pedidos =
                  PedidoDAO.obtenerPedidosPorUnDia(
                      "2015"
                          + "-"
                          + FormatoMes.format(dayChooser.getDate())
                          + "-"
                          + FormatoDia.format(dayChooser.getDate()));

              for (int i = 0; i < pedidos.size(); i++) {

                double cantidad = pedidos.get(i).getTotal();
                int nombre = pedidos.get(i).getIdDia();
                String fecha = pedidos.get(i).getFecha();

                ingreso = ingreso + cantidad;

                lblNewLabel_3.setText(Double.toString(ingreso));

                Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)};
                modelIngresos.addRow(fila);
              }

            } else if (rdbtnSemanal.isSelected()) {

              SimpleDateFormat Formato = new SimpleDateFormat("yyyy-MM-dd");
              SimpleDateFormat FormatoDia = new SimpleDateFormat("dd");
              SimpleDateFormat FormatoMes = new SimpleDateFormat("MM");
              SimpleDateFormat FormatoAnio = new SimpleDateFormat("yyyy");

              int diaComienzoSemana = Integer.valueOf(FormatoDia.format(calendar.getDate()));
              int diaFinSemana = Integer.valueOf(FormatoDia.format(calendar.getDate()));

              Calendar calendario = Calendar.getInstance();
              calendario.set(
                  2015,
                  Integer.valueOf(FormatoMes.format(calendar.getDate())) - 1,
                  Integer.valueOf(FormatoDia.format(calendar.getDate())));
              Date date = calendario.getTime();
              String diaComienzoz =
                  new SimpleDateFormat("EEEE", Locale.ENGLISH).format(calendario.getTime());
              String diaFinz =
                  new SimpleDateFormat("EEEE", Locale.ENGLISH).format(calendario.getTime());

              int ultimoDiaMes = calendario.getActualMaximum(Calendar.DAY_OF_MONTH);

              if (!diaComienzoz.equals("Monday")) {
                while ("Monday" != diaComienzoz) {
                  diaComienzoz = (String) mapA.get(diaComienzoz);
                  if (diaComienzoSemana <= 1) {
                    diaComienzoSemana = 1;
                    break;
                  }

                  diaComienzoSemana--;
                }
              }

              int diaDesde = diaComienzoSemana;

              if (!diaFinz.equals("Sunday")) {
                while ("Sunday" != diaFinz) {
                  diaFinz = (String) mapB.get(diaFinz);
                  if (diaFinSemana >= ultimoDiaMes) {
                    diaFinSemana = ultimoDiaMes;
                    break;
                  }
                  diaFinSemana++;
                }
                // if(diaComienzoSemana == 1 && diaComienzoz == "Sunday"){
                //	diaFinSemana = 1;
                // }

              }

              int diaHasta = diaFinSemana;

              Calendar calendarioDesde = Calendar.getInstance();
              calendarioDesde.set(
                  2015, Integer.valueOf(FormatoMes.format(calendar.getDate())) - 1, diaDesde);

              Calendar calendarioHasta = Calendar.getInstance();
              calendarioHasta.set(
                  2015, Integer.valueOf(FormatoMes.format(calendar.getDate())) - 1, diaHasta);

              List<PedidoDTO> pedidos = new ArrayList<>();

              pedidos =
                  PedidoDAO.obtenerPedidosPorFecha(
                      Formato.format(calendarioDesde.getTime()),
                      Formato.format(calendarioHasta.getTime()));

              for (int i = 0; i < pedidos.size(); i++) {
                double cantidad = pedidos.get(i).getTotal();
                int nombre = pedidos.get(i).getIdDia();
                String fecha = pedidos.get(i).getFecha();

                ingreso = ingreso + cantidad;

                lblNewLabel_3.setText(Double.toString(ingreso));

                Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)};
                modelIngresos.addRow(fila);
              }

              // primer dia de la semana

              // ultimo dia de la semana

            } else {
              // traer ingresos
              List<PedidoDTO> pedidos = new ArrayList<>();

              String desde =
                  yearChooser.getYear() + "-" + (monthChooser.getMonth() + 1) + "-" + "01";

              SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
              try {
                Date fecha = dateFormat.parse(desde);
              } catch (ParseException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
              Calendar cal = Calendar.getInstance();
              cal.set(Calendar.MONTH, monthChooser.getMonth());
              Calendar.getInstance().getActualMaximum(Calendar.DAY_OF_MONTH);

              String hasta =
                  yearChooser.getYear()
                      + "-"
                      + (monthChooser.getMonth() + 1)
                      + "-"
                      + cal.getActualMaximum(Calendar.DAY_OF_MONTH);

              pedidos = PedidoDAO.obtenerPedidosPorFecha(desde, hasta);

              for (int i = 0; i < pedidos.size(); i++) {
                double cantidad = pedidos.get(i).getTotal();
                int nombre = pedidos.get(i).getIdDia();
                String fecha = pedidos.get(i).getFecha();

                ingreso = ingreso + cantidad;

                lblNewLabel_3.setText(Double.toString(ingreso));

                Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)};
                modelIngresos.addRow(fila);
              }
            }

            /*




            // traer ingresos
            List<PedidoDTO> pedidos = new ArrayList<>();
            pedidos = PedidoDAO.obtenerPedidosPorFecha(getFecha(dateChooser), getFecha(dateChooser_1));

            for (int i=0; i<pedidos.size();i++)
            {
            	System.out.print("i" + i);
            	double cantidad= pedidos.get(i).getTotal();
            	int nombre= pedidos.get(i).getIdPedido();
            	String fecha= pedidos.get(i).getFecha();

            	ingreso = ingreso + cantidad  ;

            	lblNewLabel_3.setText(Double.toString(ingreso));

            	Object[] fila = {String.valueOf(nombre), fecha, String.valueOf(cantidad)};
            	modelIngresos.addRow(fila);

            }

            System.out.print(ingreso);

            */

          }
        });
    frmReporteDeVentas.getContentPane().add(btnNewButton_1);

    modelIngresos =
        new DefaultTableModel(null, columnas) {
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        };
    modelEgresos =
        new DefaultTableModel(null, columnas2) {
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        };

    // Tabla a
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBackground(Color.WHITE);
    scrollPane.setBounds(453, 116, 235, 243);
    frmReporteDeVentas.getContentPane().add(scrollPane);

    modelIngresos =
        new DefaultTableModel(null, columnas) {
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        };

    table = new JTable(modelIngresos);
    table.setBounds(239, 114, 203, 200);
    frmReporteDeVentas.getContentPane().add(scrollPane);
    scrollPane.setViewportView(table);

    rdbtnDiario = new JRadioButton("Diario");
    rdbtnDiario.setSelected(true);
    rdbtnDiario.setBounds(36, 119, 73, 23);
    frmReporteDeVentas.getContentPane().add(rdbtnDiario);

    rdbtnSemanal = new JRadioButton("Semanal");
    rdbtnSemanal.setBounds(36, 224, 73, 32);
    frmReporteDeVentas.getContentPane().add(rdbtnSemanal);

    rdbtnMensual = new JRadioButton("Mensual");
    rdbtnMensual.setBounds(36, 336, 79, 23);
    frmReporteDeVentas.getContentPane().add(rdbtnMensual);

    ButtonGroup group = new ButtonGroup();
    group.add(rdbtnDiario);
    group.add(rdbtnSemanal);
    group.add(rdbtnMensual);

    monthChooser = new JMonthChooser();
    monthChooser.setBounds(147, 336, 99, 20);
    frmReporteDeVentas.getContentPane().add(monthChooser);

    yearChooser = new JYearChooser();
    yearChooser.setBounds(253, 336, 47, 20);
    frmReporteDeVentas.getContentPane().add(yearChooser);

    dayChooser = new JCalendar();
    dayChooser.getDayChooser().setBorder(new LineBorder(new Color(0, 0, 0)));
    dayChooser.getDayChooser().getDayPanel().setBackground(Color.WHITE);
    dayChooser.setBounds(143, 50, 184, 130);
    frmReporteDeVentas.getContentPane().add(dayChooser);

    calendar = new JCalendar();
    calendar.getDayChooser().setBorder(new LineBorder(new Color(0, 0, 0)));
    calendar.getDayChooser().getDayPanel().setBackground(Color.WHITE);
    calendar.setBounds(143, 190, 184, 130);
    frmReporteDeVentas.getContentPane().add(calendar);

    // calendar.setBackground(getForeground());

    this.frmReporteDeVentas.setVisible(true);
  }
Пример #5
0
 public void setDate2(Date date2) {
   jDateChooser2.setDate(date2);
   jCalendar1.setDate(date2);
 }
Пример #6
0
 public void setDate1(Date date1) {
   jDateChooser1.setDate(date1);
   jCalendar1.setDate(date1);
 }
Пример #7
0
  public Cuentascobrar() throws SQLException {

    jFrame = new JFrame("Cuentas por Cobrar");
    jFrame.setDefaultCloseOperation(jFrame.DISPOSE_ON_CLOSE);
    jFrame.setSize(800, 600);
    jFrame.setLocationRelativeTo(null);
    jFrame.setIconImage(new ImageIcon(getClass().getResource("../imagenes/rana.jpg")).getImage());

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    System.out.println("X:" + screenSize.width + " Y:" + screenSize.height);
    int x = (screenSize.width / 2) - (jFrame.getSize().width / 2);
    int y = (screenSize.height / 2) - (jFrame.getSize().height / 2);
    System.out.println("X:" + x + "Y" + y);
    jFrame.setLocation(x, y);

    JPanel jPanel = new JPanel();
    jPanel.setLayout(null);

    JCalendar calendar = new JCalendar();
    calendar.setBounds(15, 340, 325, 200);

    String columnNames[] = {"ID Cliente", "ID Producto", "Tipo de Documento", "Fecha", "Importe"};
    String tablaContent[][] = {{}};
    model = new DefaultTableModel(tablaContent, columnNames);

    jTable = new JTable(model);
    jTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    TableColumn columna1 = jTable.getColumn("Tipo de Documento");
    columna1.setMinWidth(150);

    TableColumn columna2 = jTable.getColumn("ID Cliente");
    columna2.setMinWidth(130);

    TableColumn columna3 = jTable.getColumn("ID Producto");
    columna3.setMinWidth(160);

    TableColumn columna4 = jTable.getColumn("Importe");
    columna4.setMinWidth(85);

    JScrollPane jScrollpane = new JScrollPane(jTable);
    jScrollpane.setBounds(90, 110, 603, 200);

    JLabel cc = new JLabel("Cuentas por Cobrar");
    cc.setBounds(15, 15, 120, 20);
    jPanel.add(cc);

    text = new JTextField();
    text.setBounds(80, 50, 200, 20);
    text.addKeyListener(
        new KeyListener() {

          @Override
          public void keyTyped(KeyEvent ke) {
            char car = ke.getKeyChar();
            if ((car < 'A' || car > 'Z')
                && (car < 'a' || car > 'z')
                && (car != (char) KeyEvent.VK_SPACE)) {
              ke.consume();
            }
            if (text.getText().length() + 1 > 60) {
              JOptionPane.showMessageDialog(
                  null,
                  "Sobrepasa el Nivel de Caracteres",
                  "Advertencia",
                  JOptionPane.WARNING_MESSAGE);
              text.setText("");
            }
          }

          @Override
          public void keyPressed(KeyEvent ke) {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of
            // generated methods, choose Tools | Templates.
          }

          @Override
          public void keyReleased(KeyEvent ke) {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of
            // generated methods, choose Tools | Templates.
          }
        });
    JTextField textfa = new JTextField("");
    textfa.setBounds(360, 50, 180, 20);
    textfa.addKeyListener(
        new KeyListener() {

          @Override
          public void keyTyped(KeyEvent ke) {
            char car = ke.getKeyChar();
            if ((car < 'a' || car > 'z') && (car < 'A' || car > 'Z')) {
              ke.consume();
            }
          }

          @Override
          public void keyPressed(KeyEvent ke) {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of
            // generated methods, choose Tools | Templates.
          }

          @Override
          public void keyReleased(KeyEvent ke) {
            // throw new UnsupportedOperationException("Not supported yet."); //To change body of
            // generated methods, choose Tools | Templates.
          }
        });
    jPanel.add(textfa);

    JLabel fecha = new JLabel("Fecha");
    cliente = new JRadioButton("Cliente", false);
    ButtonGroup grupo1 = new ButtonGroup();

    grupo1.add(cliente);
    cliente.setSelected(true);
    textfa.setEditable(false);
    cliente.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (cliente.getModel().isSelected()) {

              textfa.setEditable(false);
              text.setEditable(true);
              textfa.setText("");
              calendar.setVisible(false);
            }
          }
        });

    fecha.setBounds(290, 50, 70, 20);
    jPanel.add(text);
    cliente.setBounds(5, 50, 70, 20);
    jPanel.add(cliente);

    JLabel lable1 = new JLabel("Saldo Total Liquidado");
    lable1.setBounds(360, 380, 190, 20);
    jPanel.add(lable1);

    JLabel text1 = new JLabel();
    text1.setBounds(500, 380, 90, 20);
    jPanel.add(text1);

    JLabel IT = new JLabel("Importe Total");
    IT.setBounds(360, 420, 120, 20);
    jPanel.add(IT);

    JLabel IT1 = new JLabel();
    IT1.setBounds(500, 420, 90, 20);
    jPanel.add(IT1);

    JCheckBox box = new JCheckBox();
    box.setBounds(10, 50, 20, 20);
    jPanel.add(box);
    JButton boton1 = new JButton("Buscar");
    boton1.setBounds(580, 45, 150, 30);
    boton1.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            try {
              if (cliente.isSelected()) {
                st = DataBaseManager.getConexion().createStatement();
                rs =
                    st.executeQuery(
                        "select v.ID_CLIENTE,\n"
                            + "        v.ID_PRODUCTO,\n"
                            + "        v.FECHA,\n"
                            + "        v.CATIDAD_PROD,\n"
                            + "        v.SUBTOTAL,\n"
                            + "        v.TOTAL \n"
                            + "from VENTAS v join CLIENTES c on(v.ID_CLIENTE=c.ID_CLIENTE) and c.NOMBRE='"
                            + text.getText()
                            + "'");
                if (rs.next()) {
                  Object datos[] = {
                    rs.getString(1),
                    rs.getString(2),
                    rs.getString(3),
                    rs.getString(4),
                    rs.getString(5),
                    rs.getString(6)
                  };
                  model.addRow(datos);
                }
              } else {
                Statement st = DataBaseManager.getConnection().createStatement();
                ResultSet rs =
                    st.executeQuery(
                        "select (ID_CLIENTE,ID_PRODUCTO,FECHA,CANTIDAD_PROD,SUBTOTAL,TOTAL) from VENTAS");
              }

              //                throw new UnsupportedOperationException("Not supported yet."); //To
              // change body of generated methods, choose Tools | Templates.
            } catch (SQLException ex) {
              Logger.getLogger(Cuentascobrar.class.getName()).log(Level.SEVERE, null, ex);
            }
          }
        });

    ///// CALENDARIO
    calendar.setVisible(false);
    JButton calen = new JButton("Cal");
    calen.setBounds(540, 50, 20, 20);
    calen.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            text.setEditable(false);
            text.setText("");
            calendar.setVisible(true);
            año = Integer.toString(calendar.getCalendar().get(java.util.Calendar.YEAR));
            mes = Integer.toString(calendar.getCalendar().get(java.util.Calendar.MONTH) + 1);
            dia = Integer.toString(calendar.getCalendar().get(java.util.Calendar.DATE));
            fechaCal = dia + "/" + mes + "/" + año;
            textfa.setText(fechaCal);
          }
        });
    boton1.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            if (textfa.getText().isEmpty() && text.getText().isEmpty()) {
              JOptionPane.showMessageDialog(
                  null, "Campo vacio", "Advertencia", JOptionPane.WARNING_MESSAGE);
            } else {
              if (text.getText().length() == 0 && textfa.getText().length() > 0) {
                año = Integer.toString(calendar.getCalendar().get(java.util.Calendar.YEAR));
                mes = Integer.toString(calendar.getCalendar().get(java.util.Calendar.MONTH) + 1);
                dia = Integer.toString(calendar.getCalendar().get(java.util.Calendar.DATE));
                fechaCal = dia + "/" + mes + "/" + año;
                textfa.setText(fechaCal);
              }
            }
          }
        });

    JButton boton6 = new JButton("Regresar");
    boton6.setBounds(580, 485, 150, 30);
    boton6.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            Reportes es = new Reportes();
            jFrame.dispose();
          }
        });
    jPanel.add(boton6);

    JMenuBar jMenuBar = new JMenuBar();
    JMenu jMenu = new JMenu("Inicio");
    JMenu jMenu2 = new JMenu("Reportes");
    JMenu jMenu3 = new JMenu("Ayuda");

    jMenuBar.add(jMenu);
    jMenuBar.add(jMenu2);
    jMenuBar.add(jMenu3);

    JMenuItem jMenuItem2 = new JMenuItem("Reporte PDF");
    jMenuItem2.addActionListener(new MenuListener(jFrame));
    jMenuItem2.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {

            selector = new JFileChooser();
            int op = selector.showSaveDialog(Cuentascobrar.this);
            if (op == JFileChooser.APPROVE_OPTION) {
              try {
                OutputStream archivo = new FileOutputStream(selector.getSelectedFile() + ".pdf");
                Document doc = new Document();
                PdfWriter writer = PdfWriter.getInstance(doc, archivo);
                writer.setInitialLeading(16);
                Rectangle rct = new Rectangle(80, 104, 500, 688);
                writer.setBoxSize("art", rct);
                HeaderFooter event = new HeaderFooter();
                writer.setPageEvent(event);

                doc.open();
                doc.add(new Paragraph("Cuentas por Cobrar"));
                doc.add(new Paragraph(" "));
                Paragraph parrafo3 = new Paragraph("Fecha: 25/5/42");
                parrafo3.setAlignment(2); // el 1 es para centrar
                doc.add(parrafo3);
                doc.add(new Paragraph(" "));
                doc.add(new Paragraph(" "));
                doc.add(new Paragraph(" "));
                Paragraph parrafo2 = new Paragraph("Cliente: ");
                parrafo2.setAlignment(1); // el 1 es para centrar
                doc.add(parrafo2);
                doc.add(new Paragraph(" "));
                doc.add(new Paragraph(" "));
                doc.add(new Paragraph(" "));

                String nombres[] = {
                  "ID CLIENTE", "ID PRODUCTO", "Tipo de documento", "Fecha", "Importe"
                };
                PdfPTable pdfPTable = new PdfPTable(nombres.length);
                for (int i = 0; i < jTable.getRowCount(); i++) {
                  for (int j = 0; j < jTable.getColumnCount(); j++) {
                    pdfPTable.addCell(jTable.getValueAt(i, j).toString());
                  }
                }
                PdfPCell cell = new PdfPCell(new Phrase());
                pdfPTable.addCell(cell);

                for (int i = 0; i < nombres.length; i++) {
                  cell = new PdfPCell(new Phrase(nombres[i]));
                  pdfPTable.addCell(cell);
                }
                doc.add(new Paragraph(" "));
                doc.add(new Paragraph(" "));

                Paragraph parrafo4 = new Paragraph("Importe Total Liquidado: " + rs.getString(5));
                parrafo4.setAlignment(2); // el 1 es para centrar
                doc.add(parrafo4);

                Paragraph parrafo5 = new Paragraph("Importe Total: " + rs.getString(6));
                parrafo5.setAlignment(2); // el 1 es para centrar
                doc.add(parrafo5);

                doc.add(new Paragraph(" "));
                doc.add(new Paragraph(" "));

                doc.add(pdfPTable);
                doc.close();
                archivo.close();
                Runtime.getRuntime().exec("cmd /c start " + selector.getSelectedFile() + ".pdf");

              } catch (Exception ex) {
                System.out.println(ex.getMessage());
              }
            }
          }
        });

    JMenuItem jMenuItem3 = new JMenuItem("Salir");
    jMenuItem3.addActionListener(new MenuListener(jFrame));
    jMenuItem3.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            VentanaGeneral es = new VentanaGeneral();
            jFrame.dispose();
          }
        });

    JMenuItem jMenuItem7 = new JMenuItem("Acerca De");
    jMenuItem7.addActionListener(new MenuListener(jFrame));

    jMenu.add(jMenuItem3);
    jMenu2.add(jMenuItem2);
    jMenu3.add(jMenuItem7);
    jPanel.add(fecha);
    jPanel.add(boton1);
    jPanel.add(calen);
    jPanel.add(calendar);
    jPanel.add(jScrollpane);
    jFrame.setJMenuBar(jMenuBar);
    jFrame.add(jPanel);
    jFrame.setVisible(true);
  }
Пример #8
0
  /** Create the frame */
  public MainUI(BookingAgent agent) {
    super();
    setTitle("Centro " + BookingAgent.CENTRO.getNome() + " - " + BookingAgent.CENTRO.getTelefono());
    initializeLookAndFeels();
    getContentPane().setLayout(new BorderLayout());
    setBounds(100, 100, 550, 512);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JSplitPane splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerLocation(300);
    getContentPane().add(splitPane, BorderLayout.CENTER);

    final JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.setSize(413, 299);
    panel.setMinimumSize(new Dimension(200, 200));
    splitPane.setLeftComponent(panel);

    final JPanel panel_1 = new JPanel();
    panel_1.setLayout(new BorderLayout());
    splitPane.setRightComponent(panel_1);

    final JPanel panel_2 = new JPanel();
    panel_1.add(panel_2, BorderLayout.NORTH);

    final JLabel lbl_prenotazioni = new JLabel();
    lbl_prenotazioni.setName("lbl_prenotazioni");
    lbl_prenotazioni.setText("Prenotazioni del");
    panel_2.add(lbl_prenotazioni);

    lbl_data = new JLabel();
    lbl_data.setName("lbl_data");
    panel_2.add(lbl_data);

    scrollPane = new JScrollPane();
    scrollPane.setName("sp_tabella");
    panel_1.add(scrollPane, BorderLayout.CENTER);

    /*table = new JTable(){
          public boolean isCellEditable(int rowIndex, int colIndex) {
              return false;   //Disallow the editing of any cell
            }
          };
    table.setMaximumSize(new Dimension(150, 150));
    table.setEditingRow(0);
    table.setEditingColumn(0);
    table.setName("tbl_prenotazioni");*/
    // inizializza la tabella
    initialize_table();
    scrollPane.setViewportView(table);

    calendar = new JCalendar();
    calendar.setMaximumSize(new Dimension(500, 400));
    calendar.setName("calendar");
    panel.add(calendar);
    calendar.setDecorationBackgroundVisible(true);
    calendar.setDecorationBordersVisible(false);
    calendar.setBorder(new MatteBorder(0, 0, 0, 0, Color.black));
    calendar.setWeekOfYearVisible(false);
    calendar.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent evt) {
            // System.out.println(evt.getPropertyName());
            setSelectedDate(calendar.getDate());
            getBooking();
          }
        });

    final JToolBar toolBar = new JToolBar();
    getContentPane().add(toolBar, BorderLayout.NORTH);
    //
  }