/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * jfrmVerDomicializacion.java
 *
 * Created on 11-dic-2009, 14:24:12
 */

package BBUVAJAVA;

import java.util.ArrayList;
import java.util.Iterator;
import javax.swing.JFrame;

/**
 *
 * @author Agustin
 */
public class jfrmVerDomicializacion extends javax.swing.JFrame {
Sucursal auxsuc;
     JFrame auxjf;
    /** Creates new form jfrmVerDomicializacion */
    public jfrmVerDomicializacion(Sucursal suc, JFrame ppal) {
        initComponents();
        auxsuc=suc;
        auxjf=ppal;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jtext = new javax.swing.JTextArea();
        jbtnCancelar = new javax.swing.JButton();
        jtxtCadenaBusqueda = new javax.swing.JTextField();
        jbtnVerDom = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setText("Ver domicializaciones");

        jtext.setColumns(20);
        jtext.setEditable(false);
        jtext.setRows(5);
        jScrollPane1.setViewportView(jtext);

        jbtnCancelar.setText("Salir");
        jbtnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnCancelarActionPerformed(evt);
            }
        });

        jbtnVerDom.setText("Ver Domicializaciones");
        jbtnVerDom.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbtnVerDomActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(139, 139, 139)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(174, 174, 174)
                        .addComponent(jbtnCancelar))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jtxtCadenaBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(jbtnVerDom))
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(45, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jtxtCadenaBusqueda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbtnVerDom))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 173, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(jbtnCancelar)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jbtnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnCancelarActionPerformed
        auxjf.setEnabled(true);
        this.dispose();
}//GEN-LAST:event_jbtnCancelarActionPerformed

    private void jbtnVerDomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnVerDomActionPerformed
        Cliente acCli=auxsuc.devuelveCliente(jtxtCadenaBusqueda.getText());
        if(acCli==null){
            jtext.setText("No se ha encontrado el cliente");
        }
        else{
            String dom="";
        ArrayList<Domicializacion> a=acCli.getMDomicializacion();
        if(a==null){
        Iterator iterador = a.listIterator();
        while( iterador.hasNext() ) {
            Domicializacion d = (Domicializacion) iterador.next();
            dom=d.getNombreCliente()+" "+d.getConcepto()+" "+d.getFecha()+" "+d.getCantidad()+" "+d.getNumeroProducto()+"\n";
        }
        }
        else{
            dom="No hay domicializaciones";
        }
        jtext.setText(dom);
        }
}//GEN-LAST:event_jbtnVerDomActionPerformed

    /**
    * @param args the command line arguments
    */
    /*public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
    public void run() {
    new jfrmVerDomicializacion().setVisible(true);
    }
    });
    }*/

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JButton jbtnCancelar;
    private javax.swing.JButton jbtnVerDom;
    private javax.swing.JTextArea jtext;
    private javax.swing.JTextField jtxtCadenaBusqueda;
    // End of variables declaration//GEN-END:variables

}
