Manual Tecnic Primerament instalarem el sistema operatiu (windows). Per veure el manual d'instalacio ho podem veure a les seguents pagina webs segons la versio: – windows 7: http://www.softzone.es/manuales-software-2/instalar-windows-7-manual-de- instalacion-de-windows-7/ – Windows xp: http://www.configurarequipos.com/doc317.html – windows 8: http://www.softzone.es/manual-instalacion-windows-8-instalar-windows-8- paso-a-paso/ Un cop tenim el sistema operatiu instalat passarem a instalar el xamp, ens descarguem el instalador desde la pagina web: xamp Un cop descargat l'executem i seguim els pasos de la instalacio. Creacio de la base de dades: anem a: http://localhost/phpmyadmin/ a la pantalla que ens ha aparegut fem clic a l'opcio “base de datos”. Aqui introduim el nom que li volem dona a la nostra base de datos i li donem a crear: Un cop creada la seleccionem i creem les taules: aqui es poden veure les taules que tenim que crear:
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Manual Tecnic
Primerament instalarem el sistema operatiu (windows). Per veure el manual d'instalacio ho podem veure a les seguents pagina webs segons la versio:
– windows 7: http://www.softzone.es/manuales-software-2/instalar-windows-7-manual-de-instalacion-de-windows-7/
– Windows xp: http://www.configurarequipos.com/doc317.html – windows 8: http://www.softzone.es/manual-instalacion-windows-8-instalar-windows-8-
paso-a-paso/
Un cop tenim el sistema operatiu instalat passarem a instalar el xamp, ens descarguem el instalador desde la pagina web: xampUn cop descargat l'executem i seguim els pasos de la instalacio.
Creacio de la base de dades:
anem a: http://localhost/phpmyadmin/
a la pantalla que ens ha aparegut fem clic a l'opcio “base de datos”.
Aqui introduim el nom que li volem dona a la nostra base de datos i li donem a crear:
Un cop creada la seleccionem i creem les taules:
aqui es poden veure les taules que tenim que crear:
Taula client_productes: aquesta taula es creada automaticament.
Taula producte:
Taula usuari:
Instalacio del IDE de programacio (Netbeans):El descargarem desde la seguent pagina web: http://www.oracle.com/technetwork/java/javase/downloads/jdk-7-netbeans-download-432126.html?ssSourceSiteId=otnes
public void setPassword(String password) { this.password = password; }
public String getUsuari() { return usuari; }
public void setUsuari(String usuari) { this.usuari = usuari; }
public String getTipus() { return tipus; }
public void setTipus(String tipus) { this.tipus = tipus; }
Una volta tenim totes aquestes clases copiades veurem que ens apareix un error a la clase Producte.java:
Si l'obrim i veiem el error podrem veure que es perque ens fa falta una llibreria (hibernate):
Per poder afegir aquesta llibreria primerament ens la tenim que descarga desde la seguent pagina web: https://skydrive.live.com/#cid=D30581FF3CFC09DF&id=D30581FF3CFC09DF%21136
Descomprimim el fitxer que acabem de descarga.
Una volta descomprimit anem al netbeans i on posa libraries cliquem amb el boto dret i li donem a add Jar/Folder:
Busquem la carpeta que acabem de descomprimir i obrim tots els jar que hi ham:
public class HibernateUtil { private static final SessionFactory sessionFactory; static{ try { sessionFactory = new Configuration().configure().buildSessionFactory(); } catch (HibernateException he) { System.err.println("Ocurrió un error en la inicialización de la SessionFactory: " + he); throw new ExceptionInInitializerError(he); } } public static SessionFactory getSessionFactory(){
* @author Administrador */public class FormLogin extends javax.swing.JFrame {public boolean correcte = false; /** * Creates new form forlogin */ public FormLogin() { initComponents(); inicialitzarform(); cargarbox(); } public void inicialitzarform(){ this.setTitle("Login"); this.setSize(330, 200); this.setLocationRelativeTo(null); this.setResizable(false); this.setVisible(true); }
private void cargarbox (){ Usuari prova = new Usuari(); ArrayList<login> lista = prova.recuperarlogin(); for (int x=0;x<lista.size();x++){ login obj = new login(lista.get(x).getUsuari()); cmblogin.addItem(obj); } } /** * 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() {
jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); btnok = new javax.swing.JButton(); btnCancelar = new javax.swing.JButton(); txtpassword = new javax.swing.JPasswordField(); cmblogin = new javax.swing.JComboBox(); lblerror = new javax.swing.JLabel();
/** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(FormLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(FormLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(FormLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
public void cargarTablaClients(){ DefaultTableModel modelo = new DefaultTableModel(){ @Override public boolean isCellEditable (int row, int column) {
return false;}
}; Session st = HibernateUtil.getSessionFactory().openSession(); List<Client> lista = (List<Client>)st.createQuery("From Client").list(); modelo.addColumn("id"); modelo.addColumn("DNI"); modelo.addColumn("Nom"); modelo.addColumn("Cognoms"); modelo.addColumn("Adreça"); modelo.addColumn("nom_node"); modelo.addColumn("num_compte"); modelo.addColumn("cuota_mensual"); modelo.addColumn("Telefon"); modelo.addColumn("Email"); modelo.setRowCount(lista.size()); int i = 0; for(Client x : lista){ modelo.setValueAt(x.getId(), i, 0); modelo.setValueAt(x.getDni(), i, 1); modelo.setValueAt(x.getNom(), i, 2); modelo.setValueAt(x.getCognom(), i, 3); modelo.setValueAt(x.getAdreça(), i, 4); modelo.setValueAt(x.getNomnode(), i, 5); modelo.setValueAt(x.getNumcompte(), i, 6); modelo.setValueAt(x.getCuotamensual(), i, 7); modelo.setValueAt(x.getTelefon(), i, 8); modelo.setValueAt(x.getEmail(), i, 9); i++; } tblclients.setModel(modelo); tblclients.getColumnModel().getColumn(0).setMaxWidth(0); tblclients.getColumnModel().getColumn(0).setMinWidth(0); tblclients.getColumnModel().getColumn(0).setPreferredWidth(0); tblclients.getColumnModel().getColumn(0).setResizable(false); st.close(); }
public void eliminaclient(){ int fila = tblclients.getSelectedRow(); Session sesion = HibernateUtil.getSessionFactory().openSession(); sesion.beginTransaction(); Client obj=null; int id =(Integer) tblclients.getValueAt(fila, 0); obj = (Client) sesion.get(Client.class, id); sesion.delete(obj); sesion.getTransaction().commit(); sesion.close(); cargarTablaClients(); } public void rellenavalors(){ Client obj = new Client();
int columna=1; int fila = this.tblclients.getSelectedRow(); //fila seleccionada txtdni.setText(tblclients.getValueAt(fila, columna++).toString()); txtnom.setText(tblclients.getValueAt(fila, columna++).toString()); txtcognoms.setText(tblclients.getValueAt(fila, columna++).toString()); txtadreça.setText(tblclients.getValueAt(fila, columna++).toString()); txtnomnode.setText(tblclients.getValueAt(fila, columna++).toString()); txtnumcompte.setText(tblclients.getValueAt(fila, columna++).toString()); txtcuota.setText(tblclients.getValueAt(fila, columna++).toString()); txttelefon.setText(tblclients.getValueAt(fila, columna++).toString()); txtemail.setText(tblclients.getValueAt(fila, columna++).toString()); } public void limpia (){ txtdni.setText(""); txtnom.setText(""); txtcognoms.setText(""); txtadreça.setText(""); txtnomnode.setText(""); txtnumcompte.setText(""); txtcuota.setText(""); txttelefon.setText(""); txtemail.setText(""); } /** * 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() {
grupSexe = new javax.swing.ButtonGroup(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel8 = new javax.swing.JLabel(); jLabel9 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); txtdni = new javax.swing.JTextField(); txtnom = new javax.swing.JTextField(); txtcognoms = new javax.swing.JTextField(); txtadreça = new javax.swing.JTextField(); txtcuota = new javax.swing.JTextField(); txtnomnode = new javax.swing.JTextField(); txtemail = new javax.swing.JTextField(); txttelefon = new javax.swing.JTextField(); btncancelar = new javax.swing.JButton(); btnseguent = new javax.swing.JButton(); btneliminar = new javax.swing.JButton(); jScrollPane3 = new javax.swing.JScrollPane(); tblclients = new javax.swing.JTable(); btnafegir = new javax.swing.JButton(); jLabel5 = new javax.swing.JLabel(); txtnumcompte = new javax.swing.JTextField(); txtusuari = new javax.swing.JLabel(); txttipus = new javax.swing.JTextField(); btnsessio = new javax.swing.JButton(); jLabel11 = new javax.swing.JLabel(); btncorreu = new javax.swing.JButton();
/** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */
* @author Administrador */public class FormProducte extends javax.swing.JFrame { static public Client client = FormClient.client1; static public Client client1 = client; static public Producte producte = new Producte(); static public List<Producte> lista = new ArrayList<>(); static public List<Producte> lista1 = new ArrayList<>(); private login permisosClient; private String nomusuari; private String tipususuari; private String rutafoto = "fotosproductes/"; /** * Creates new form FormProducte */ public FormProducte(login permisos,String nomusuari, String tipususuari) { permisosClient = permisos; this.nomusuari = nomusuari; this.tipususuari = tipususuari; initComponents(); inicialitzaform(); btneliminar.setEnabled(false); } public FormProducte() { this.setTitle("Formulari producte"); initComponents(); inicialitzaform(); btneliminar.setEnabled(false); }
public void inicialitzaform (){ setResizable(false); setSize(700, 550); setLocationRelativeTo(null); cargarTabla(); setVisible(true); } public void cargarTabla(){ DefaultTableModel modelo = new DefaultTableModel(){ @Override public Class getColumnClass(int columnIndex) {
if (columnIndex == 5 ) {return Boolean.class;
}else {
return super.getColumnClass (columnIndex);}
} public boolean isCellEditable (int row, int column) { if(column==5){ return true; }
return false;}
}; Session st = HibernateUtil.getSessionFactory().openSession(); lista = (List<Producte>)st.createQuery("From Producte").list();
modelo.addColumn("id"); modelo.addColumn("codi"); modelo.addColumn("nom"); modelo.addColumn("preu"); modelo.addColumn("foto"); modelo.addColumn("compra"); modelo.setRowCount(lista.size()); int i = 0; for(Producte x : lista){ modelo.setValueAt(x.getId(), i, 0); modelo.setValueAt(x.getCodi(), i, 1); modelo.setValueAt(x.getNom(), i, 2); modelo.setValueAt(x.getPreu(), i, 3); modelo.setValueAt(x.getFoto(), i, 4); if (lista1.isEmpty()){ modelo.setValueAt(x.isCompra(), i, 5); } else{ for (Producte y : lista1){ if(x.getCodi() == null ? y.getCodi() == null : x.getCodi().equals(y.getCodi())){ modelo.setValueAt(true, i, 5); } } } i++; } this.tblproductes.setModel(modelo); tblproductes.getColumnModel().getColumn(0).setMaxWidth(0); tblproductes.getColumnModel().getColumn(0).setMinWidth(0); tblproductes.getColumnModel().getColumn(0).setPreferredWidth(0); tblproductes.getColumnModel().getColumn(0).setResizable(false); st.close(); } public void cargarPermisos(login permisos, String nomusuari, String tipususuari) throws SQLException{ FormClient obj = new FormClient(); obj.txtusuari.setText(nomusuari); this.nomusuari = nomusuari; this.tipususuari = tipususuari; permisosClient = permisos; if ("administrador".equals(tipususuari)){ btnafegir.setVisible(true); btneliminar.setVisible(true); } else{ btnafegir.setVisible(false); btneliminar.setVisible(false); txtcodi.setVisible(false); txtfoto.setVisible(false); txtnom.setVisible(false); txtpreu.setVisible(false); lblcodi.setVisible(false); lblfoto.setVisible(false); lblnom.setVisible(false); lblpreu.setVisible(false); } }
public void eliminaProducte(){ int fila = tblproductes.getSelectedRow(); Session sesion = HibernateUtil.getSessionFactory().openSession();
sesion.beginTransaction(); System.out.println(fila); Producte obj=null; int id =(Integer) tblproductes.getValueAt(fila, 0); obj = (Producte) sesion.get(Producte.class, id); sesion.delete(obj); sesion.getTransaction().commit(); sesion.close(); cargarTabla(); } public void limpia (){ txtcodi.setText(""); txtnom.setText(""); txtpreu.setText(""); txtfoto.setText(""); } public void afegirproducte(){ producte.setCodi(txtcodi.getText()); producte.setNom(txtnom.getText()); producte.setFoto(txtfoto.getText()); producte.setPreu(Float.parseFloat(txtpreu.getText())); producte.setCompra(false); } public void rellenavalors(){ Producte obj = new Producte(); int columna=1; int fila = this.tblproductes.getSelectedRow(); //fila seleccionada txtcodi.setText(tblproductes.getValueAt(fila, columna++).toString()); txtnom.setText(tblproductes.getValueAt(fila, columna++).toString()); txtpreu.setText(tblproductes.getValueAt(fila, columna++).toString()); txtfoto.setText(tblproductes.getValueAt(fila, columna++).toString()); } /** * 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() {
jPanel1 = new javax.swing.JPanel(); btnatras = new javax.swing.JButton(); btnseguent = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); tblproductes = new javax.swing.JTable(); btneliminar = new javax.swing.JButton(); btnafegir = new javax.swing.JButton(); lblcodi = new javax.swing.JLabel(); lblnom = new javax.swing.JLabel(); lblpreu = new javax.swing.JLabel(); lblfoto = new javax.swing.JLabel(); txtcodi = new javax.swing.JTextField(); txtnom = new javax.swing.JTextField(); txtpreu = new javax.swing.JTextField(); txtfoto = new javax.swing.JTextField(); lblimagen = new javax.swing.JLabel();
public void inicialitzaform (){ setResizable(false); setSize(700, 550); setLocationRelativeTo(null); setVisible(true); } public void minimproductes(){ if (lista.isEmpty()){ btnfinalitzar.setEnabled(false); btnCrearPDF.setEnabled(false); lbldescripcio.setText("Has de seleccionar minim un producte"); } else{ btnfinalitzar.setEnabled(true); btnCrearPDF.setEnabled(true); mostrarpreu(); } } public void mostrarpreu (){ suma = 0; for(Producte x : lista){ suma=x.getPreu() + suma; } Producte obj = new Producte(); lbldescripcio.setText("Preu total: " +obj.Redondear(suma)+"€"); IVA = suma * 16 / 100; preutotal = IVA + hora + suma; } public void recuperarclient(){ txtresum.setText("\t"+"\t"+"DADES DEL CLIENT \n \n"); txtresum.append("NOM: "); txtresum.append(client.getNom()+"\n"); txtresum.append("COGNOMS: "); txtresum.append(client.getCognom()+"\n"); txtresum.append("DNI: "); txtresum.append(client.getDni()+"\n"); txtresum.append("DIRECCIO: "); txtresum.append(client.getAdreça()+"\n"); txtresum.append("NOM DEL NODE: "); txtresum.append(client.getNomnode()+"\n"); txtresum.append("NUMERO DE COMPTE: "); txtresum.append(client.getNumcompte()+"\n"); txtresum.append("CUOTA MENSUAL: "); txtresum.append(client.getCuotamensual()+"\n"); txtresum.append("EMAIL: "); txtresum.append(client.getEmail()+"\n"); txtresum.append("TELEFON: "); txtresum.append(client.getTelefon()+"\n"); } public void cargarTabla(){ DefaultTableModel modelo = new DefaultTableModel(){
public boolean isCellEditable (int row, int column) {return false;
} }; Producte producte = new Producte(); modelo.addColumn("codi"); modelo.addColumn("nom"); modelo.addColumn("preu"); modelo.setRowCount(lista.size()); int i = 0; for(Producte x : lista){ modelo.setValueAt(x.getCodi(), i, 0); modelo.setValueAt(x.getNom(), i, 1); modelo.setValueAt(x.getPreu(), i, 2); i++; } this.tblresum.setModel(modelo); } public void guardarproductes(){ for (Producte x : lista){ client.afegirclient(x); } Session sesion = HibernateUtil.getSessionFactory().openSession(); sesion.beginTransaction(); sesion.save(client); sesion.getTransaction().commit(); sesion.close(); } /** * 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() {
jPanel1 = new javax.swing.JPanel(); btnatras = new javax.swing.JButton(); btnfinalitzar = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); tblresum = new javax.swing.JTable(); jScrollPane2 = new javax.swing.JScrollPane(); txtresum = new javax.swing.JTextArea(); lbldescripcio = new javax.swing.JLabel(); btnCrearPDF = new javax.swing.JButton();
private void btnfinalitzarActionPerformed(java.awt.event.ActionEvent evt) { CrearPDF obj = new CrearPDF(); Producte pro = new Producte(); int factura = JOptionPane.showConfirmDialog(null, "Desea crear factura","sortir",JOptionPane.YES_NO_OPTION); if ( factura == 0) { //arrodonim els valors a dos decimals com a molt String preu = String.valueOf(pro.Redondear(preutotal)); String iva = String.valueOf(pro.Redondear(IVA)); String hores = String.valueOf(pro.Redondear(hora)); String Total = String.valueOf(pro.Redondear(suma)); obj.crear_PDF("Factura", "Sergi Subirats Cugat", "Factura", "", "Nom: "+client.getNom()+"\n"+ "Cognoms: "+client.getCognom()+"\n"+ "DNI: "+client.getDni()+"\n"+ "Adreça: "+client.getAdreça()+"\n"+ "Nom del node: "+client.getNomnode()+"\n"+ "Numero de compte: "+client.getNumcompte()+"\n"+ "Cuota mensual: "+client.getCuotamensual()+"\n"+ "Telefon: "+client.getTelefon()+"\n"+ "Email: "+client.getEmail()+"\n" , "Total: "+preu+"€", "FACTURA"+"\n \n", "Import IVA: "+iva+"€", "Preu/hora: "+hores+"€", "Import Total : "+Total+"€", "NOTA: Aqui falta suma el import del cabletjat segons els metros gastats" ); } int eleccion = JOptionPane.showConfirmDialog(null, "Desea Guardar los datos i finalizar?","sortir",JOptionPane.YES_NO_OPTION); if ( eleccion == 0) { guardarproductes(); System.exit(0); } }
private void btnCrearPDFActionPerformed(java.awt.event.ActionEvent evt) { CrearPDF obj = new CrearPDF(); Producte pro = new Producte(); //arrodonim els valors a dos decimals com a molt String preu = String.valueOf(pro.Redondear(preutotal)); String iva = String.valueOf(pro.Redondear(IVA)); String hores = String.valueOf(pro.Redondear(hora));
String Total = String.valueOf(pro.Redondear(suma)); obj.crear_PDF("Presupost", "Sergi Subirats Cugat", "Presupost", "", "Nom: "+client.getNom()+"\n"+ "Cognoms: "+client.getCognom()+"\n"+ "DNI: "+client.getDni()+"\n"+ "Adreça: "+client.getAdreça()+"\n"+ "Nom del node: "+client.getNomnode()+"\n"+ "Numero de compte: "+client.getNumcompte()+"\n"+ "Cuota mensual: "+client.getCuotamensual()+"\n"+ "Telefon: "+client.getTelefon()+"\n"+ "Email: "+client.getEmail()+"\n" , "Total: "+preu+"€", "PRESUPOST"+"\n \n", "Import IVA: "+iva+"€", "Preu/hora: "+hores+"€", "Import Total : "+Total+"€", "NOTA: Aqui falta suma el import del cabletjat segons els metros gastats" ); }
/** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(FormResumen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(FormResumen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(FormResumen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(FormResumen.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold>
/* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new FormResumen().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JButton btnCrearPDF; private javax.swing.JButton btnatras; private javax.swing.JButton btnfinalitzar; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JLabel lbldescripcio; private javax.swing.JTable tblresum; private javax.swing.JTextArea txtresum; // End of variables declaration }
public class FormEmail extends javax.swing.JFrame {
Funcions.Email mail = new Funcions.Email();
/** Creates new form interfaz */ public FormEmail() { initComponents(); this.setTitle("Enviar Correo"); inicialitzaform(); } public void inicialitzaform (){ setResizable(false); setSize(470, 400); setLocationRelativeTo(null); cargarbox(); } private void cargarbox (){ Client prova = new Client(); ArrayList<Client> lista = prova.recuperarclient(); for (int x=0;x<lista.size();x++){ cmbusuari.addItem(lista.get(x).getEmail()); } } public void cargarpara(){ String prova = cmbusuari.getSelectedItem().toString(); if (txtTO.getText().equals("")){ txtTO.setText(prova); } if (txtTO.getText().contains(prova)){
} else{ txtTO.setText(txtTO.getText()+", "+prova); } if (chbtodos.isSelected()==true){ Client client = new Client(); ArrayList<Client> lista = client.recuperarclient(); for (int x=0;x<lista.size();x++){ if (txtTO.getText().equals("")){ txtTO.setText(lista.get(x).getEmail()); } if (txtTO.getText().contains(lista.get(x).getEmail())){ } else{ txtTO.setText(txtTO.getText()+", "+(lista.get(x).getEmail())); } } } }
/** 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() { java.awt.GridBagConstraints gridBagConstraints;
jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); txtFROM = new javax.swing.JTextField(); txtTO = new javax.swing.JTextField(); txtSUBJECT = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); txtPWD = new javax.swing.JPasswordField(); jPanel2 = new javax.swing.JPanel(); jScrollPane1 = new javax.swing.JScrollPane(); txtMESSAGE = new javax.swing.JTextArea(); cmdSEND = new javax.swing.JButton(); cmbusuari = new javax.swing.JComboBox(); btninsertar = new javax.swing.JButton(); chbtodos = new javax.swing.JCheckBox();