Handwritten Text Recognition for manuscripts and early printed texts
Manual tecnic sergi_subirats
1. 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:
3. 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
instalacio: http://www.youtube.com/watch?v=3GhqJyqr_4g
Un cop ja tenim tot aixo pasariem a programar l'aplicacio, iniciem el netbeans.
Crearem un nou projecte, anem a la pestanya “File---New Project...”:
Seleccionem aplicacion java:
4. Fiquem el nom a l'aplicacio i li diem que no volem clase main:
una volta li donem a finish ens apareix el seguent esquema de l'aplicació:
ara tenim que crear nous paquets, boto dret sobre “source packages”:
Creem 5 paquets nous amb els seguents noms:
5. Una volta creat aixo dintre del paquet datos crearem una nova clase java que sera en la que
accedirem a la base de dades:
El seu contingut sera el seguent:
package datos;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
public class dades {
private String user ="alumne";
private String password = "alumne";
private String db = "nova";
private String host = "localhost:3306/";
// String url = "jdbc:mysql://localhost:3306/testdb";
14. public login() {
}
public login (String usuari){
this.usuari = usuari;
}
public login(String usuari, String password, String tipus) {
this.usuari = usuari;
this.password = password;
this.tipus = tipus;
}
@Override
public String toString() {
return usuari;
}
public String getPassword() {
return password;
}
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:
15. 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:
16. Com podem veure s'ha solucionat un dels tres errors que teniem. Per poder solucionar els altres dos
falta crear clases que crearem a continuacio.
A continuacio al paquet persistencia crearem la seguent clase i els seguents fitxers xml:
Client.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="negoci.Client" table="CLIENT">
<id name="id" column="ID_CLIENT">
<generator class="identity" />
</id>
<property name="dni" />
<property name="nom" />
<property name="cognom" />
<property name="adreça" />
<property name="nomnode" />
<property name="numcompte" />
<property name="cuotamensual" />
<property name="telefon" />
<property name="email" />
<list name="productes" table="CLIENT_PRODUCTES" cascade="none" >
<key column="ID_CLIENT" />
<list-index column="ORDEN" />
<many-to-many class="negoci.Producte" column="ID_PRODUCTE" />
</list>
</class>
</hibernate-mapping>
HibernateUtil.java:
package persistencia;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
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()
{
18. Seguidament crearem un nou fitxer xml anomenat “hibernate.cfg.xml” al arrel del programa:
Com es pot veure es crear un nou paquet de forma automatica.
De moment el import de la classe Producte.java que ens esta donan error el comentarem:
Un cop tenim tot aixo passarem a la creacio dels formularis:
Per crear formularis cliquem amb el boto dret del ratoli sobre el paquet persistenica i seleccionem
l'opcio “ New----JFrame form...”:
Introduim el nom del formulari
19. 1- formulari: Formulari de login
Per crear el formulari farem servir el seguent: El formulari quedara de la seguent manera:
Per donar-li nom als controls clicarem amb el boto dret sobre ells i seleccionarem l'opcio
“Properties”:
20.
21. Anirem a la pestanya Code i a la segona opcio ficarem el nom:
22. Un cop tenim el formulari creat passarem a la part de codi:
package presentacio;
import datos.dades;
import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import negoci.Client;
import negoci.Usuari;
import negoci.login;
import org.hibernate.Query;
import org.hibernate.classic.Session;
import persistencia.HibernateUtil;
/**
*
23. * @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();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Usuari:");
jLabel2.setText("Password:");
btnok.setText("OK");
btnok.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnokActionPerformed(evt);
}
});
btnCancelar.setText("Cancelar");
btnCancelar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnCancelarActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
29. 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();
30. 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();
38. * @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();
39. 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();
40. 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();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btnatras.setText("atras");
btnatras.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnatrasActionPerformed(evt);
46. permisosClient = permisos;
this.nomusuari = nomusuari;
this.tipususuari = tipususuari;
}
public FormResumen() {
initComponents();
inicialitzaform();
recuperarclient();
cargarTabla();
minimproductes();
}
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(){
47. 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();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btnatras.setText("Atras");
btnatras.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnatrasActionPerformed(evt);
}
});
btnfinalitzar.setText("Finalitzar");
btnfinalitzar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnfinalitzarActionPerformed(evt);
}
});
tblresum.setModel(new javax.swing.table.DefaultTableModel(
49. Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
);
pack();
}// </editor-fold>
private void btnatrasActionPerformed(java.awt.event.ActionEvent evt) {
try {
FormProducte obj = new FormProducte();
obj.cargarPermisos(permisosClient, nomusuari, tipususuari);
this.setVisible(false);
obj.inicialitzaform();
obj.setVisible(true);
} catch (SQLException ex) {
Logger.getLogger(FormResumen.class.getName()).log(Level.SEVERE, null, ex);
}
}
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));
50. 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
}
5- formulari: Formulari per enviar correus
51.
52. codi:
package presentacio;
import java.util.ArrayList;
import negoci.Client;
import negoci.Usuari;
import negoci.login;
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)){
53. }
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();
jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jPanel1.setLayout(new java.awt.GridBagLayout());
jLabel1.setText("De :");
jLabel1.setAlignmentY(1.0F);
jPanel1.add(jLabel1, new java.awt.GridBagConstraints());
jLabel2.setText("Para :");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel1.add(jLabel2, gridBagConstraints);
jLabel3.setText("Asunto :");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
jPanel1.add(jLabel3, gridBagConstraints);