Error saving my Sales record

0

I'm making a sales system but on the Sales screen when I give it the save option I get an error and it does not save me. I'm new to this, the error you get is:

private String accion = "guardar";
    public static int idusuario;

    void ocultar_columnas() {
        listadoventa.getColumnModel().getColumn(0).setMaxWidth(0);
        listadoventa.getColumnModel().getColumn(0).setMinWidth(0);
        listadoventa.getColumnModel().getColumn(0).setPreferredWidth(0);

        listadoventa.getColumnModel().getColumn(1).setMaxWidth(0);
        listadoventa.getColumnModel().getColumn(1).setMinWidth(0);
        listadoventa.getColumnModel().getColumn(1).setPreferredWidth(0);

        listadoventa.getColumnModel().getColumn(3).setMaxWidth(0);
        listadoventa.getColumnModel().getColumn(3).setMinWidth(0);
        listadoventa.getColumnModel().getColumn(3).setPreferredWidth(0);

        listadoventa.getColumnModel().getColumn(5).setMaxWidth(0);
        listadoventa.getColumnModel().getColumn(5).setMinWidth(0);
        listadoventa.getColumnModel().getColumn(5).setPreferredWidth(0);

            }

    void inhabilitar() {
        idventas.setVisible(false);
        idservicios.setVisible(false);
        idempleado.setVisible(false);
        idempleado.setVisible(false);


        numero.setEnabled(false);
        empleado.setEnabled(false);
        tipo_venta.setEnabled(false);

        Fecha_venta.setEnabled(false);
        fecha_ingreso.setEnabled(false);
        fecha_salida.setEnabled(false);

        costo_servicio.setEnabled(false);
        observacion.setEnabled(false);
        estado.setEnabled(false);

        guardar.setEnabled(false);
        cancelar.setEnabled(false);
        eliminar.setEnabled(false);
        buscarservicio.setEnabled(false);
        buscarcliente.setEnabled(false);

        idventas.setText("");
        idservicios.setText("");
        numero.setText("");
        idempleado.setText("");
        empleado.setText("");
        observacion.setText("");
        costo_servicio.setText("");

    }

    void habilitar() {
        idventas.setVisible(false);
        idservicios.setVisible(false);
        idempleado.setVisible(false);
        idempleado.setVisible(false);

        numero.setEnabled(false);
        empleado.setEnabled(false);
        empleado.setEnabled(false);
        tipo_venta.setEnabled(true);

        Fecha_venta.setEnabled(true);
        fecha_ingreso.setEnabled(true);
        fecha_salida.setEnabled(true);

        costo_servicio.setEnabled(true);
        observacion.setEnabled(true);
        estado.setEnabled(true);

        guardar.setEnabled(true);
        cancelar.setEnabled(true);
        eliminar.setEnabled(true);
        buscarservicio.setEnabled(true);
        buscarcliente.setEnabled(true);

        idventas.setText("");
        idservicios.setText("");
        numero.setText("");
        idempleado.setText("");
        empleado.setText("");
        observacion.setText("");
        costo_servicio.setText("");

    }

    void mostrar(String buscar) {
        try {
            DefaultTableModel modelo;
            venta func = new venta();
            modelo = func.mostrar(buscar);

            listadoventa.setModel(modelo);
            ocultar_columnas();
            ventas.setText("Total Registros " + Integer.toString(func.venta));

        } catch (Exception e) {
            JOptionPane.showConfirmDialog(rootPane, e);
        }
    }
private void agregarActionPerformed(java.awt.event.ActionEvent evt) {                                        
        habilitar();
        guardar.setText("Guardar");
        accion = "guardar";
    }                                       

    private void guardarActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        if (idservicios.getText().length() == 0) {
            JOptionPane.showConfirmDialog(rootPane, "seleccione numero del servicio");
            idservicios.requestFocus();
            return;
        }

        if (idempleado.getText().length() == 0) {
            JOptionPane.showConfirmDialog(rootPane, "seleccione el cliente");
            idempleado.requestFocus();
            return;
        }



        if (costo_servicio.getText().length() == 0) {
            JOptionPane.showConfirmDialog(rootPane, "ingrese costo ");
            costo_servicio.requestFocus();
            return;
        }

        if (observacion.getText().length() == 0) {
            JOptionPane.showConfirmDialog(rootPane, "ingrese observacion");
            observacion.requestFocus();
            return;
        }

        Ventas dts = new Ventas();
        venta func = new venta();

        dts.setIdservicios(Integer.parseInt(idservicios.getText()));
        dts.setIdcliente(Integer.parseInt(idempleado.getText()));
        dts.setIdempleado(Integer.parseInt(idempleado.getText()));
        dts.setIdempleado(idusuario);

        int seleccionado = tipo_venta.getSelectedIndex();
        dts.setTipo_venta((String) tipo_venta.getItemAt(seleccionado));

        Calendar cal;
        int d, m, a;
        cal = Fecha_venta.getCalendar();
        d = cal.get(Calendar.DAY_OF_MONTH);
        m = cal.get(Calendar.MONTH);
        a = cal.get(Calendar.YEAR) - 1900;
        dts.setFecha_venta(new Date(a, m, d));

        cal = fecha_ingreso.getCalendar();
        d = cal.get(Calendar.DAY_OF_MONTH);
        m = cal.get(Calendar.MONTH);
        a = cal.get(Calendar.YEAR) - 1900;
        dts.setFecha_ingreso(new Date(a, m, d));

        cal = fecha_salida.getCalendar();
        d = cal.get(Calendar.DAY_OF_MONTH);
        m = cal.get(Calendar.MONTH);
        a = cal.get(Calendar.YEAR) - 1900;
        dts.setFecha_salida(new Date(a, m, d));

        dts.setCosto_servicio(Double.parseDouble(costo_servicio.getText()));

        dts.setObservacion(observacion.getText());

        seleccionado = estado.getSelectedIndex();
        dts.setEstado((String) estado.getItemAt(seleccionado));

        if (accion.equals("guardar")) {
            if (func.insertar(dts)) {
                JOptionPane.showMessageDialog(rootPane, "se registro satisfactoriamente");
                mostrar("");
                inhabilitar();

            }

        } else if (accion.equals("editar")) {
            dts.setIdventas(Integer.parseInt(idventas.getText()));
            dts.setIdempleado(Integer.parseInt(idempleado.getText()));


            if (func.editar(dts)) {
                JOptionPane.showMessageDialog(rootPane, "se Edito satisfactoriamente");
                mostrar("");
                inhabilitar();
            }
        }
    }                   
private void listadoventaMouseClicked(java.awt.event.MouseEvent evt) {                                          
        guardar.setText("editar");
        habilitar();
        eliminar.setEnabled(true);
        accion = "editar";

        int fila = listadoventa.rowAtPoint(evt.getPoint());

        idventas.setText(listadoventa.getValueAt(fila, 0).toString());
        idservicios.setText(listadoventa.getValueAt(fila, 1).toString());
        numero.setText(listadoventa.getValueAt(fila, 2).toString());
        idempleado.setText(listadoventa.getValueAt(fila, 3).toString());
        empleado.setText(listadoventa.getValueAt(fila, 4).toString());
        idempleado.setText(listadoventa.getValueAt(fila, 5).toString());
        empleado.setText(listadoventa.getValueAt(fila, 6).toString());
        tipo_venta.setSelectedItem(listadoventa.getValueAt(fila, 7).toString());
        Fecha_venta.setDate(Date.valueOf(listadoventa.getValueAt(fila, 8).toString()));
        fecha_ingreso.setDate(Date.valueOf(listadoventa.getValueAt(fila, 9).toString()));
        fecha_salida.setDate(Date.valueOf(listadoventa.getValueAt(fila, 10).toString()));
        costo_servicio.setText(listadoventa.getValueAt(fila, 11).toString());
        observacion.setText(listadoventa.getValueAt(fila, 12).toString());
        estado.setSelectedItem(listadoventa.getValueAt(fila, 13).toString());

    }               
private void eliminarActionPerformed(java.awt.event.ActionEvent evt) {                                         

          if (!idventas.getText().equals("")) {
            int confirmacion = JOptionPane.showConfirmDialog(rootPane, "Desea Eliminar venta?", "Confirmar", 2);

            if (confirmacion == 0) {
                venta func = new venta();
                Ventas dts = new Ventas();

                dts.setIdventas(Integer.parseInt(idventas.getText()));
                func.eliminar(dts);
                mostrar("");
                inhabilitar();

            }

        }

    } 
    
asked by Yusmary Valerio 12.09.2018 в 04:29
source

0 answers