Package ManejoVentanas

Source Code of ManejoVentanas.VentanaCargarDispProfesores

/*
* VentanaCargarSalones.java
*
* Created on 3 de agosto de 2007, 10:19 AM
*/

package ManejoVentanas;

import GeneracionHorarios.Curso;
import GeneracionHorarios.Dia;
import GeneracionHorarios.EstructuraProfesor;
import ManejoArchivos.ArchivoDispProfesor;
import ManejoBD.*;
import java.io.IOException;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
*
* @author  Fernando
*/
public class VentanaCargarDispProfesores extends javax.swing.JDialog {
    private EstructuraProfesor estProfesor;
    /** Creates new form VentanaCargarSalones */
    public VentanaCargarDispProfesores(VentanaPrincipal parent,EstructuraProfesor estProfesor) {
        super(parent, true);
        initComponents();
        this.estProfesor=estProfesor;       
        txtRuta.setText("C:\\Archivos_IA\\Disponibilidad Profesores.txt");
        setVisible(true);
    }
   
    /** 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.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        fchRuta = new javax.swing.JFileChooser();
        lblIndicaciones = new javax.swing.JLabel();
        txtRuta = new javax.swing.JTextField();
        btnExaminar = new javax.swing.JButton();
        btnAceptar = new javax.swing.JButton();
        btnCancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Leer Ruta");
        setModal(true);
        getAccessibleContext().setAccessibleParent(null);
        lblIndicaciones.setText("Ingrese la ruta en donde se encuentra el archivo:");

        btnExaminar.setText("Examinar...");
        btnExaminar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnExaminarMouseClicked(evt);
            }
        });

        btnAceptar.setText("Aceptar");
        btnAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarActionPerformed(evt);
            }
        });

        btnCancelar.setText("Cancelar");
        btnCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarActionPerformed(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.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtRuta, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)
                            .addComponent(lblIndicaciones, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 248, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(btnAceptar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 64, Short.MAX_VALUE)
                        .addComponent(btnCancelar)
                        .addGap(18, 18, 18)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnExaminar, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lblIndicaciones, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtRuta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnExaminar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnCancelar, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnAceptar))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed
        ArchivoDispProfesor archDispProf=null;
        try {
            //Cargamos los cursos en la BD
            AccesoBD.conexionODBC("horariosBD");
           
       
            archDispProf = new ArchivoDispProfesor(txtRuta.getText());
            Dia diaLibre;
            int i;
            while (true){
                try{
                    diaLibre = archDispProf.leer();
                } catch(IOException ex){
                    break;
                }
                DiaBD.agregarDia(diaLibre);
                if (diaLibre.getNombreDia().equals("LUNES"))
                    i=0;
                else
                    if (diaLibre.getNombreDia().equals("MARTES"))
                        i=1;
                    else
                        if (diaLibre.getNombreDia().equals("MIERCOLES"))
                            i=2;
                        else
                            if (diaLibre.getNombreDia().equals("JUEVES"))
                            i=3;
                            else
                                if (diaLibre.getNombreDia().equals("VIERNES"))
                                i=4;
                                else
                                    i=5;   
           
                estProfesor.modificarDisponibilidad(diaLibre,i,1);
                AccesoBD.conn.commit();
            }
            JOptionPane.showMessageDialog(this,"El archivo se cargo correctamente");
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this,"Error en la carga de archivo : " + ex);
        } finally {
            try {
                if (archDispProf!=null) archDispProf.finLectura();
                AccesoBD.desconexion();
            } catch (Exception ex) {}
            dispose();
        }
    }//GEN-LAST:event_btnAceptarActionPerformed

    private void btnCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarActionPerformed
        dispose();
    }//GEN-LAST:event_btnCancelarActionPerformed

    private void btnExaminarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnExaminarMouseClicked
        int result  = fchRuta.showOpenDialog(VentanaCargarDispProfesores.this);
        if (result == fchRuta.APPROVE_OPTION){
            txtRuta.setText(fchRuta.getSelectedFile().getAbsolutePath());
        }
    }//GEN-LAST:event_btnExaminarMouseClicked
   
    /**
     * @param args the command line arguments
     */
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAceptar;
    private javax.swing.JButton btnCancelar;
    private javax.swing.JButton btnExaminar;
    private javax.swing.JFileChooser fchRuta;
    private javax.swing.JLabel lblIndicaciones;
    private javax.swing.JTextField txtRuta;
    // End of variables declaration//GEN-END:variables
}
TOP

Related Classes of ManejoVentanas.VentanaCargarDispProfesores

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.