Вы находитесь на странице: 1из 12

package optica;

import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.util.JRLoader;
import net.sf.jasperreports.view.JRViewer;

/**
*
* @author pcserver
*/
public class Menu extends javax.swing.JFrame {
Connection conn;
Conexion cn= new Conexion();
/**
* Creates new form Menu
*/
public Menu() {
initComponents();
/* escritorio.setBorder(new ImagenFondo());
this.setExtendedState(Menu.MAXIMIZED_BOTH);
conn= cn.getConnection();*/
//setIconImage(new
ImageIcon(getClass().getResource("/iconos/hebreo.png")).getImage());
}

/* public void cerrar(){


Object [] opciones ={"Si","Cancelar"};
int eleccion = JOptionPane.showOptionDialog(rootPane,"Segur@ que
Deseae Cerrara el Sistema Brakhot","Mensaje de Confirmacion",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE,null,opciones,"Aceptar");
if (eleccion == JOptionPane.YES_OPTION)
{
System.exit(0);
}
}*/
/**
* 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">
private void initComponents() {

escritorio = new javax.swing.JDesktopPane();


jMenuBar1 = new javax.swing.JMenuBar();
jMenu3 = new javax.swing.JMenu();
jMenuPaciente = new javax.swing.JMenu();
MPacienteNuevo = new javax.swing.JMenuItem();
MPacienteRConsulta = new javax.swing.JMenuItem();
jMenuStock = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuRStock = new javax.swing.JMenuItem();
jMenuFichaOftalmica = new javax.swing.JMenuItem();
jMenuSaludOcular = new javax.swing.JMenuItem();
jMenuHelp = new javax.swing.JMenu();
jMenuIayuda = new javax.swing.JMenuItem();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Men Principal \"Optica Brakhot\"");
setAlwaysOnTop(true);

javax.swing.GroupLayout escritorioLayout = new


javax.swing.GroupLayout(escritorio);
escritorio.setLayout(escritorioLayout);
escritorioLayout.setHorizontalGroup(

escritorioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGap(0, 537, Short.MAX_VALUE)
);
escritorioLayout.setVerticalGroup(

escritorioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI
NG)
.addGap(0, 343, Short.MAX_VALUE)
);

jMenu3.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/iconos/documents-peoples-
pen.png"))); // NOI18N
jMenu3.setText("Administrar");

jMenuPaciente.setText("Paciente");
jMenuPaciente.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuPacienteActionPerformed(evt);
}
});

MPacienteNuevo.setText("Nuevo");
MPacienteNuevo.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MPacienteNuevoActionPerformed(evt);
}
});
jMenuPaciente.add(MPacienteNuevo);

MPacienteRConsulta.setText("Buscar");
MPacienteRConsulta.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
MPacienteRConsultaActionPerformed(evt);
}
});
jMenuPaciente.add(MPacienteRConsulta);

jMenu3.add(jMenuPaciente);

jMenuStock.setText("Stock");
jMenuStock.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuStockActionPerformed(evt);
}
});
jMenu3.add(jMenuStock);

jMenuBar1.add(jMenu3);

jMenu2.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/iconos/document-spreadsheet-
stick.png"))); // NOI18N
jMenu2.setText("Reportes");

jMenuRStock.setText("Stock");
jMenuRStock.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuRStockActionPerformed(evt);
}
});
jMenu2.add(jMenuRStock);

jMenuFichaOftalmica.setText("Ficha Oftalmica");
jMenuFichaOftalmica.addActionListener(new
java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuFichaOftalmicaActionPerformed(evt);
}
});
jMenu2.add(jMenuFichaOftalmica);

jMenuSaludOcular.setText("Salud Ocular");
jMenuSaludOcular.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuSaludOcularActionPerformed(evt);
}
});
jMenu2.add(jMenuSaludOcular);

jMenuBar1.add(jMenu2);

jMenuHelp.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/iconos/Help.png"))); // NOI18N
jMenuHelp.setText("Ayuda");
jMenuHelp.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuHelpActionPerformed(evt);
}
});

jMenuIayuda.setText("Ayuda");
jMenuIayuda.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuIayudaActionPerformed(evt);
}
});
jMenuHelp.add(jMenuIayuda);

jMenuBar1.add(jMenuHelp);

setJMenuBar(jMenuBar1);

javax.swing.GroupLayout layout = new


javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(escritorio)
);
layout.setVerticalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(escritorio)
);

pack();
}// </editor-fold>

private void MPacienteRConsultaActionPerformed(java.awt.event.ActionEvent


evt) {
/* escritorio.removeAll();
escritorio.repaint();
FrmBuscarPaciente frmbuscarpaciente= new FrmBuscarPaciente();
escritorio.add(frmbuscarpaciente);
frmbuscarpaciente.setVisible(true);
frmbuscarpaciente.toFront();
*/
}

private void jMenuPacienteActionPerformed(java.awt.event.ActionEvent evt)


{

private void MPacienteNuevoActionPerformed(java.awt.event.ActionEvent


evt) {
/* escritorio.removeAll();
escritorio.repaint();
FrmPaciente frmpaciente= new FrmPaciente();
escritorio.add(frmpaciente);
frmpaciente.setVisible(true);
frmpaciente.toFront(); */
}

private void jMenuStockActionPerformed(java.awt.event.ActionEvent evt) {


/* escritorio.removeAll();
escritorio.repaint();
FrmStock frmstock= new FrmStock();
escritorio.add(frmstock);
frmstock.setVisible(true);
frmstock.toFront();
*/
}

private void jMenuSaludOcularActionPerformed(java.awt.event.ActionEvent


evt) {
/* String noHistorial = JOptionPane.showInputDialog(this,"Ingrese el Nmero
de Historial");
if (noHistorial!=null){
if(!"".equals(noHistorial.trim())){
try{
JInternalFrame reporte = new JInternalFrame();
reporte.setSize(900,700);
reporte.setClosable(true);
reporte.setIconifiable(true);
reporte.setTitle("Reporte Salud Ocular Segn Nmero de
Historial");
JasperReport dirReporte = (JasperReport)
JRLoader.loadObject(System.getProperty("user.dir")
+"\\src\\reportes\\ReporteSaludOcular.jasper");
Map parametros = new HashMap();
parametros.put("NoHistorial", Integer.parseInt(noHistorial));
JasperPrint mostrarReporte =
JasperFillManager.fillReport(dirReporte,parametros,conn);
JRViewer jv = new JRViewer(mostrarReporte);
reporte.getContentPane().add(jv);
escritorio.add(reporte);
reporte.setVisible(true);
reporte.toFront();
//JasperViewer.viewReport(mostrarRecibo);
} catch (NumberFormatException | JRException ex) {
JOptionPane.showMessageDialog(null,"Historial No
Valido","Error...",JOptionPane.ERROR_MESSAGE);
}
}
else{
JOptionPane.showMessageDialog(null,"Historial No
Valido","Error...",JOptionPane.ERROR_MESSAGE);
}
}
*/
}

private void
jMenuFichaOftalmicaActionPerformed(java.awt.event.ActionEvent evt) {
/* String noHistorial = JOptionPane.showInputDialog(this,"Ingrese el Nmero
de Historial");
if (noHistorial!=null){
if(!"".equals(noHistorial.trim())){
try{
JInternalFrame reporte = new JInternalFrame();
reporte.setSize(900,700);
reporte.setClosable(true);
reporte.setIconifiable(true);
reporte.setTitle("Reporte Ficha Oftalmologica Segn Nmero de
Historial");

JasperReport dirReporte = (JasperReport)


JRLoader.loadObject(System.getProperty("user.dir")
+"\\src\\reportes\\ReporteHistorial.jasper");
Map parametros = new HashMap();
parametros.put("P_NoHistorial", Integer.parseInt(noHistorial));
JasperPrint mostrarReporte =
JasperFillManager.fillReport(dirReporte,parametros,conn);
JRViewer jv = new JRViewer(mostrarReporte);
reporte.getContentPane().add(jv);
escritorio.add(reporte);
reporte.setVisible(true);
reporte.toFront();
//JasperViewer.viewReport(mostrarRecibo);
} catch (NumberFormatException | JRException ex) {
JOptionPane.showMessageDialog(null,"Historial No
Valido","Error...",JOptionPane.ERROR_MESSAGE);
}
}
else{
JOptionPane.showMessageDialog(null,"Historial No
Valido","Error...",JOptionPane.ERROR_MESSAGE);
}
}
*/
}

private void jMenuRStockActionPerformed(java.awt.event.ActionEvent evt) {


/* try{
JInternalFrame reporte = new JInternalFrame();
reporte.setSize(900,700);
reporte.setClosable(true);
reporte.setIconifiable(true);
reporte.setTitle("Reporte Productos En Stock");

JasperReport dirReporte = (JasperReport)


JRLoader.loadObject(System.getProperty("user.dir")
+"\\src\\reportes\\ReporteStock.jasper");
//Map parametros = new HashMap();
//parametros.put("P_NoHistorial", noHistorial);
JasperPrint mostrarReporte =
JasperFillManager.fillReport(dirReporte,null,conn);
JRViewer jv = new JRViewer(mostrarReporte);
reporte.getContentPane().add(jv);
escritorio.add(reporte);
reporte.setVisible(true);
reporte.toFront();
//JasperViewer.viewReport(mostrarRecibo);
}catch (JRException ex) {
JOptionPane.showMessageDialog(null,"Error al genera
reporte","Error...",JOptionPane.ERROR_MESSAGE);
}
*/
}

private void jMenuHelpActionPerformed(java.awt.event.ActionEvent evt) {


}

private void jMenuIayudaActionPerformed(java.awt.event.ActionEvent evt) {


/* //escritorio.removeAll();
//escritorio.repaint();
Ayuda ayuda= new Ayuda();
escritorio.add(ayuda);
ayuda.setVisible(true);
ayuda.toFront();
*/
}

Вам также может понравиться