Billing program for the appliance repair company Seoane.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Primera versión añadida al repositorio.

cyberslas 1956161d

+12002
Ayuda/Thumbs.db

This is a binary file and will not be displayed.

+21
Ayuda/ayuda.html
··· 1 + <html> 2 + <head> 3 + </head> 4 + <body> 5 + <h1>Ayuda Facturaci&oacute;n Seoane</h1> 6 + <h2>Configuraci&oacute;n de tama&ntilde;o de p&aacute;gina</h2> 7 + <p>Pasos a seguir par aconfigurar el tama�o de hoja personalizado para las facturas:</p> 8 + <ul> 9 + <li>Acceder al panel de control, y dentro de este a el men&uacute; de Impresoras y faxes.</li> 10 + <li><strong>Windows Vista: </strong>Hacer click derecho sobre un rincon vac�o de la pantalla. Acceder al men� <i>Ejecutar como administrador</i> y dentro de este a <i>Propiedades de servidor...</i></li> 11 + <li><strong>Windows XP: </strong>Hacer click en <i>Archivo</i> y dentro de este en <i>Propiedades de servidor...</i></li> 12 + <li>Aparecer� un men� como el siguiente:<br /><br /><img src="imagen01.jpg" /></li> 13 + <li>Hacer click sobre el cuadro de <i>Crear nuevo formulario</i></li> 14 + <li>Introducir las medidas adecuadas al tama�o del papel de la factura, y darle un nombre a el nuevo formulario (por ejempo "Factura Seoane").</li> 15 + <li>Click sobre <i>Guardar formulario</i></li> 16 + <li>Aceptar</li> 17 + </ul> 18 + <p>Una vez realizados los pasos anteriores, en el men� de configuraci�n de la impresora (Dentro del men� de <i>Imprimir</i>, en <i>Preferencias</i> -> <i>Papel/Calidad</i> -> <i>Avanzadas...</i>), estar� disponible el nuevo tama�o de papel.</p> 19 + <p><img src="imagen02.jpg" /></p> 20 + </body> 21 + </html>
Ayuda/imagen01.jpg

This is a binary file and will not be displayed.

Ayuda/imagen02.jpg

This is a binary file and will not be displayed.

+1283
Datos/AccesoADatos.cpp
··· 1 + #include "AccesoADatos.h" 2 + #include "utils.h" 3 + #include "../Negocio/Factura.h" 4 + #include "../Negocio/Cliente.h" 5 + #include "../Negocio/Presupuesto.h" 6 + #include "../Negocio/Articulo.h" 7 + #include <cstdio> 8 + #include <string> 9 + #include <list> 10 + #include <iostream> 11 + #include <QtSql> 12 + #include <QString> 13 + #include <QtGui> 14 + 15 + using namespace std; 16 + 17 + AccesoADatos::AccesoADatos() 18 + { 19 + db = QSqlDatabase::addDatabase("QSQLITE"); 20 + db.setDatabaseName("./Datos/seoane.s3db"); 21 + bool ok = db.open(); 22 + if (ok) { 23 + cout << "[Debug]Base de datos abierta correctamente." << endl; 24 + } else { 25 + cout << "[ERROR]Base de datos abierta incorrectamente." << endl; 26 + QMessageBox::information(0,"Error","Error al acceder a la base de datos."); 27 + qDebug()<< db.lastError(); 28 + } 29 + } 30 + 31 + AccesoADatos::~AccesoADatos() 32 + { 33 + cout << "[Debug]Destruimos el acceso a datos." << endl; 34 + db.close(); 35 + cout << "[Debug]Acceso a datos destruida." << endl; 36 + } 37 + //METODOS PARA INSERTAR EN LA BD 38 + bool AccesoADatos::insertaFactura(Factura factura){ 39 + db.transaction(); 40 + //insert into facturas(n_factura, fecha, aparato, marca, modelo,n_fabricacion,lugar_reparacion,id_cliente); 41 + string query="insert into Facturas(n_factura, fecha, aparato, marca, modelo,n_fabricacion,lugar_reparacion,id_cliente,averia,trabajo_realizado,tiempo_empleado,fecha_terminacion,observaciones,precio_materiales,precio_mano_obra,precio_desplazamiento,precio_transporte,iva) values (";// 42 + if(factura.getn_factura()==-1) 43 + query.append("NULL, "); 44 + else { 45 + query.append(itoa(factura.getn_factura())); 46 + query.append(", "); 47 + } 48 + if(factura.getfecha() == "") 49 + query.append("NULL, "); 50 + else { 51 + query.append("\""); 52 + query.append( factura.getfecha() + "\", "); 53 + } 54 + if(factura.getaparato()== "") 55 + query.append("NULL, "); 56 + else { 57 + query.append("\""); 58 + query.append(factura.getaparato() + "\", "); 59 + } 60 + 61 + 62 + if(factura.getmarca()== "") 63 + query.append("NULL, "); 64 + else { 65 + query.append("\""); 66 + query.append(factura.getmarca() + "\", "); 67 + } 68 + if(factura.getmodelo()== "") 69 + query.append("NULL, "); 70 + else { 71 + query.append("\""); 72 + query.append(factura.getmodelo() + "\", "); 73 + } 74 + if(factura.getn_fabricacion()== -1) 75 + query.append("NULL, "); 76 + else { 77 + query.append(itoa(factura.getn_fabricacion())); 78 + query.append(", "); 79 + } 80 + if(factura.getlugar_reparacion()== 0) 81 + query.append("NULL, "); 82 + else { 83 + bool lr = *factura.getlugar_reparacion(); 84 + if (lr) query.append("1, "); 85 + else query.append("0, "); 86 + } 87 + 88 + 89 + if(factura.getcliente() == 0) 90 + query.append("NULL, "); 91 + else { 92 + query.append(itoa(factura.getcliente()->getid())); 93 + query.append(", "); 94 + } 95 + if(factura.getaveria() == "") { 96 + query.append("NULL, "); 97 + } else { 98 + query.append("\""); 99 + query.append(factura.getaveria() + "\", "); 100 + 101 + } 102 + if(factura.gettrabajo_realizado() == "") { 103 + query.append("NULL, "); 104 + } else { 105 + query.append("\""); 106 + query.append(factura.gettrabajo_realizado() + "\", "); 107 + } 108 + if(factura.gettiempo_empleado() == "") { 109 + query.append("NULL, "); 110 + } else { 111 + query.append("\""); 112 + query.append(factura.gettiempo_empleado() + "\", "); 113 + } 114 + if(factura.getfecha_terminacion() == "") { 115 + query.append("NULL, "); 116 + } else { 117 + query.append("\""); 118 + query.append(factura.getfecha_terminacion() + "\", "); 119 + } 120 + if(factura.getobservaciones() == "") { 121 + query.append("NULL, "); 122 + } else { 123 + query.append("\""); 124 + query.append(factura.getobservaciones() + "\", "); 125 + } 126 + if(factura.getprecio_materiales() == -1.) { 127 + query.append("NULL, "); 128 + } else { 129 + query.append(ftoa(factura.getprecio_materiales())); 130 + query.append(", "); 131 + } 132 + if(factura.getprecio_mano_obra() == -1.) { 133 + query.append("NULL, "); 134 + } else { 135 + query.append(ftoa(factura.getprecio_mano_obra())); 136 + query.append(", "); 137 + } 138 + if(factura.getprecio_desplazamiento() == -1.) { 139 + query.append("NULL, "); 140 + } else { 141 + query.append(ftoa(factura.getprecio_desplazamiento())); 142 + query.append(", "); 143 + } 144 + if(factura.getprecio_transporte() == -1.) { 145 + query.append("NULL, "); 146 + } else { 147 + query.append(ftoa(factura.getprecio_transporte())); 148 + query.append(", "); 149 + } 150 + query.append(ftoa(factura.getiva())); 151 + query.append(");"); 152 + 153 + cout << query << endl; 154 + QSqlQuery qquery; 155 + bool ok = qquery.exec(query.c_str()); 156 + 157 + list<LineaArticulo> l = factura.getlista_articulos(); 158 + list<LineaArticulo>::iterator iter; 159 + for(iter=l.begin(); iter!=l.end();iter++) { 160 + query = " insert into Facturas_Articulos(id_factura, id_articulo, cantidad) values("; 161 + query.append(itoa(factura.getid())); 162 + query.append(", "); 163 + query.append(itoa(iter->getarticulo().getid())); 164 + query.append(", "); 165 + query.append(itoa(iter->getcantidad())); 166 + query.append(");"); 167 + ok = ok && qquery.exec(query.c_str()); 168 + } 169 + ok = ok && db.commit(); 170 + return ok; 171 + } 172 + 173 + ///////////////////////////////// 174 + bool AccesoADatos::insertaCliente(Cliente cliente){ 175 + db.transaction(); 176 + //insert into cliente(codigo,nombre,apellidos,direccion,nif,poblacion) values ("; 177 + string query="insert into Clientes(codigo,nombre,apellidos,direccion,nif,poblacion) values(";// 178 + 179 + if(cliente.getcodigo() == 0) 180 + query.append("NULL, "); 181 + else { 182 + query.append(itoa(cliente.getcodigo())); 183 + query.append(", "); 184 + } 185 + 186 + if(cliente.getnombre() == "") 187 + query.append("NULL, "); 188 + else { 189 + query.append("\""); 190 + query.append(cliente.getnombre() + "\", "); 191 + } 192 + 193 + if(cliente.getapellidos() == "") 194 + query.append("NULL, "); 195 + else { 196 + query.append("\""); 197 + query.append(cliente.getapellidos() + "\", "); 198 + } 199 + 200 + if(cliente.getdireccion()=="") 201 + query.append("NULL, "); 202 + else { 203 + query.append("\""); 204 + query.append(cliente.getdireccion() + "\", " ); 205 + } 206 + 207 + if(cliente.getnif()=="") 208 + query.append("NULL, "); 209 + else { 210 + query.append("\""); 211 + query.append( cliente.getnif() + "\", "); 212 + } 213 + if(cliente.getpoblacion()=="") 214 + query.append("NULL);"); 215 + else { 216 + query.append("\""); 217 + query.append( cliente.getpoblacion() + "\");"); 218 + } 219 + 220 + cout << "[Debug]" << query << endl; 221 + QSqlQuery qquery; 222 + bool ok = qquery.exec(query.c_str()); 223 + 224 + list<int> lista = cliente.gettelefonos(); 225 + list<int>::iterator it; 226 + for (it = lista.begin(); it != lista.end(); it++){ 227 + string queryTelefonos="insert into Telefonos(id_cliente,numero) values("; 228 + queryTelefonos.append(itoa(dameIdCliente())); 229 + queryTelefonos.append(", "); 230 + queryTelefonos.append(itoa(*it)); 231 + queryTelefonos.append(");"); 232 + cout << "[Debug]" << queryTelefonos << endl; 233 + QSqlQuery qqueryt; 234 + ok = ok && qqueryt.exec(queryTelefonos.c_str()); 235 + } 236 + ok = ok && db.commit(); 237 + return ok; 238 + } 239 + 240 + ///////////////////////////////////////////////// 241 + bool AccesoADatos::insertaPresupuesto(Presupuesto presupuesto){ 242 + db.transaction(); 243 + //insert into Presupuesto(aceptado,id_cliente,factura,n_factura,fecha,aparato,marca,modelo,n_fabricacion,lugar_reparacion); 244 + string query="insert into Presupuestos(aceptado,id_cliente,id_factura,n_factura,fecha,aparato,marca,modelo,n_fabricacion,lugar_reparacion,averia,trabajo_realizado,tiempo_empleado,fecha_terminacion,observaciones,precio_materiales,precio_mano_obra,precio_desplazamiento,precio_transporte,iva) values ("; 245 + 246 + if(presupuesto.getaceptado()==0) 247 + query.append("NULL, "); 248 + else { 249 + bool a = *presupuesto.getaceptado(); 250 + if (a) query.append("1, "); 251 + else query.append("0, "); 252 + } 253 + 254 + if(presupuesto.getcliente()==0) 255 + query.append("NULL, "); 256 + else { 257 + query.append(itoa(presupuesto.getcliente()->getid())); 258 + query.append(", "); 259 + } 260 + 261 + if(presupuesto.getfactura()==0) 262 + query.append("NULL, "); 263 + else { 264 + query.append(itoa(presupuesto.getfactura()->getid())); 265 + query.append(", "); 266 + } 267 + 268 + if(presupuesto.getn_factura()==-1) 269 + query.append("NULL, "); 270 + else { 271 + query.append(itoa(presupuesto.getn_factura())); 272 + query.append(", "); 273 + } 274 + 275 + if(presupuesto.getfecha()=="") 276 + query.append("NULL, "); 277 + else { 278 + query.append("\""); 279 + query.append(presupuesto.getfecha() + "\", "); 280 + } 281 + 282 + if(presupuesto.getaparato()=="") 283 + query.append("NULL, "); 284 + else { 285 + query.append("\""); 286 + query.append(presupuesto.getaparato() + "\", "); 287 + } 288 + 289 + if(presupuesto.getmarca()=="") 290 + query.append("NULL, "); 291 + else { 292 + query.append("\""); 293 + query.append(presupuesto.getmarca() + "\", "); 294 + } 295 + 296 + if(presupuesto.getmodelo()=="") 297 + query.append("NULL, "); 298 + else { 299 + query.append("\""); 300 + query.append(presupuesto.getmodelo() + "\", "); 301 + } 302 + 303 + if(presupuesto.getn_fabricacion()==-1) 304 + query.append("NULL, "); 305 + else { 306 + query.append(itoa(presupuesto.getn_fabricacion())); 307 + query.append(", "); 308 + } 309 + 310 + if(presupuesto.getlugar_reparacion()==0) 311 + query.append("NULL, "); 312 + else { 313 + bool lr = presupuesto.getlugar_reparacion(); 314 + if (lr) query.append("1, "); 315 + else query.append("0, "); 316 + } 317 + if(presupuesto.getaveria() == "") { 318 + query.append("NULL, "); 319 + } else { 320 + query.append("\""); 321 + query.append(presupuesto.getaveria() + "\", "); 322 + 323 + } 324 + if(presupuesto.gettrabajo_realizado() == "") { 325 + query.append("NULL, "); 326 + } else { 327 + query.append("\""); 328 + query.append(presupuesto.gettrabajo_realizado() + "\", "); 329 + } 330 + if(presupuesto.gettiempo_empleado() == "") { 331 + query.append("NULL, "); 332 + } else { 333 + query.append("\""); 334 + query.append(presupuesto.gettiempo_empleado() + "\", "); 335 + } 336 + if(presupuesto.getfecha_terminacion() == "") { 337 + query.append("NULL, "); 338 + } else { 339 + query.append("\""); 340 + query.append(presupuesto.getfecha_terminacion() + "\", "); 341 + } 342 + if(presupuesto.getobservaciones() == "") { 343 + query.append("NULL, "); 344 + } else { 345 + query.append("\""); 346 + query.append(presupuesto.getobservaciones() + "\", "); 347 + } 348 + if(presupuesto.getprecio_materiales() == -1.) { 349 + query.append("NULL, "); 350 + } else { 351 + query.append(ftoa(presupuesto.getprecio_materiales())); 352 + query.append(", "); 353 + } 354 + if(presupuesto.getprecio_mano_obra() == -1.) { 355 + query.append("NULL, "); 356 + } else { 357 + query.append(ftoa(presupuesto.getprecio_mano_obra())); 358 + query.append(", "); 359 + } 360 + if(presupuesto.getprecio_desplazamiento() == -1.) { 361 + query.append("NULL, "); 362 + } else { 363 + query.append(ftoa(presupuesto.getprecio_desplazamiento())); 364 + query.append(", "); 365 + } 366 + if(presupuesto.getprecio_transporte() == -1.) { 367 + query.append("NULL, "); 368 + } else { 369 + query.append(ftoa(presupuesto.getprecio_transporte())); 370 + query.append(", "); 371 + } 372 + query.append(ftoa(presupuesto.getiva())); 373 + query.append(");"); 374 + QSqlQuery qquery; 375 + //QMessageBox::information(0,"Aviso",query.c_str()); 376 + bool ok = qquery.exec(query.c_str()); 377 + 378 + list<LineaArticulo> l = presupuesto.getlista_articulos(); 379 + list<LineaArticulo>::iterator iter; 380 + for(iter=l.begin(); iter!=l.end();iter++) { 381 + query = " insert into Presupuestos_Articulos(id_presupuesto, id_articulo, cantidad) values("; 382 + query.append(itoa(presupuesto.getid())); 383 + query.append(", "); 384 + query.append(itoa(iter->getarticulo().getid())); 385 + query.append(", "); 386 + query.append(itoa(iter->getcantidad())); 387 + query.append(");"); 388 + ok = ok && qquery.exec(query.c_str()); 389 + } 390 + ok = ok && db.commit(); 391 + return ok; 392 + } 393 + bool AccesoADatos::insertaArticulo(Articulo articulo){ 394 + 395 + //insert into Articulos(codigo,descripcion,caja,existencias,existencias_minimas,pvp,precio_coste,descuento); 396 + string query="insert into Articulos(codigo,descripcion,caja,existencias,existencias_minimas,pvp,precio_coste,descuento,historico) values ("; 397 + 398 + if(articulo.getcodigo() == -1) 399 + query.append("NULL, "); 400 + else { 401 + query.append(itoa(articulo.getcodigo())); 402 + query.append(", "); 403 + } 404 + 405 + if(articulo.getdescripcion() =="") 406 + query.append("NULL, "); 407 + else { 408 + query.append("\""); 409 + query.append(articulo.getdescripcion() + "\", "); 410 + } 411 + if(articulo.getcaja() == "" ) 412 + query.append("NULL, "); 413 + else { 414 + query.append("\""); 415 + query.append(articulo.getcaja() + "\", "); 416 + } 417 + if(articulo.getexistencias() == -1) 418 + query.append("NULL, "); 419 + else { 420 + query.append(itoa(articulo.getexistencias())); 421 + query.append(", "); 422 + } 423 + 424 + if(articulo.getexistencias_minimas() == -1) 425 + query.append("NULL, "); 426 + else { 427 + query.append(itoa(articulo.getexistencias_minimas())); 428 + query.append(", "); 429 + } 430 + if(articulo.getpvp() ==-1.) 431 + query.append("NULL, "); 432 + else { 433 + query.append(ftoa(articulo.getpvp())); 434 + query.append(", "); 435 + } 436 + 437 + if(articulo.getprecio_coste() == -1.) 438 + query.append("NULL, "); 439 + else { 440 + query.append(ftoa(articulo.getprecio_coste())); 441 + query.append(", "); 442 + 443 + } 444 + 445 + if(articulo.getdescuento() == -1) 446 + query.append("NULL, "); 447 + else { 448 + query.append(itoa(articulo.getdescuento())); 449 + query.append(", "); 450 + } 451 + 452 + if (articulo.gethistorico()) { 453 + query.append("1);"); 454 + } else { 455 + query.append("0);"); 456 + } 457 + 458 + cout << "[Debug]" << query << endl; 459 + QSqlQuery qquery; 460 + bool ok = qquery.exec(query.c_str()); 461 + if (!ok) { 462 + qDebug() << qquery.lastError (); 463 + return false; 464 + } 465 + return true; 466 + 467 + 468 + } 469 + //METODOS PARA LISTAR 470 + 471 + list <Factura> AccesoADatos::listaFacturas() { 472 + string squery = "select * from Facturas order by n_factura desc;"; 473 + list <Factura> lista_facturas; 474 + QSqlQuery query; 475 + bool ok = query.exec(squery.c_str()); 476 + if (!ok) { 477 + qDebug() << query.lastError (); 478 + return lista_facturas; 479 + } 480 + while (query.next()) { 481 + Factura *f = new Factura(); 482 + f->setid(query.value(0).toInt()); 483 + f->setn_factura(query.value(1).toInt()); 484 + f->setfecha(query.value(2).toString().toStdString()); 485 + f->setaparato(query.value(3).toString().toStdString()); 486 + f->setmarca(query.value(4).toString().toStdString()); 487 + f->setmodelo(query.value(5).toString().toStdString()); 488 + f->setn_fabricacion(query.value(6).toInt()); 489 + 490 + if (!query.value(7).isNull()) { 491 + bool *b = new bool; 492 + *b = query.value(7).toBool(); 493 + f->setlugar_reparacion(b); 494 + } 495 + f->setcliente(0); 496 + f->setaveria(query.value(9).toString().toStdString()); 497 + f->settrabajo_realizado(query.value(10).toString().toStdString()); 498 + f->settiempo_empleado(query.value(11).toString().toStdString()); 499 + f->setfecha_terminacion(query.value(12).toString().toStdString()); 500 + f->setobservaciones(query.value(13).toString().toStdString()); 501 + f->setprecio_materiales(query.value(14).toDouble()); 502 + f->setprecio_mano_obra(query.value(15).toDouble()); 503 + f->setprecio_desplazamiento(query.value(16).toDouble()); 504 + f->setprecio_transporte(query.value(17).toDouble()); 505 + f->setiva(query.value(18).toDouble()); 506 + 507 + lista_facturas.push_back(*f); 508 + } 509 + return lista_facturas; 510 + } 511 + 512 + list <Cliente> AccesoADatos::listaClientes() { 513 + string squery = "select * from Clientes;"; 514 + list <Cliente> lista_clientes; 515 + QSqlQuery query; 516 + bool ok = query.exec(squery.c_str()); 517 + if (!ok) { 518 + qDebug() << query.lastError (); 519 + return lista_clientes; 520 + } 521 + while (query.next()) { 522 + Cliente *c = new Cliente(); 523 + c->setid(query.value(0).toInt()); 524 + c->setcodigo(query.value(1).toInt()); 525 + c->setnombre(query.value(2).toString().toStdString()); 526 + c->setapellidos(query.value(3).toString().toStdString()); 527 + c->setdireccion(query.value(4).toString().toStdString()); 528 + c->setnif(query.value(5).toString().toStdString()); 529 + c->setpoblacion(query.value(6).toString().toStdString()); 530 + c->sethistorico(query.value(7).toBool()); 531 + 532 + list<int> lista_telefonos; 533 + string tquery = "select numero from Telefonos where id_cliente="; 534 + tquery.append(itoa(c->getid())); 535 + tquery.append(";"); 536 + QSqlQuery queryt; 537 + queryt.exec(tquery.c_str()); 538 + while (queryt.next()) { 539 + lista_telefonos.push_back(queryt.value(0).toInt()); 540 + } 541 + 542 + c->settelefonos(lista_telefonos); 543 + 544 + lista_clientes.push_back(*c); 545 + } 546 + 547 + 548 + return lista_clientes; 549 + } 550 + 551 + list <Presupuesto> AccesoADatos::listaPresupuestos() { 552 + string squery = "select * from Presupuestos;"; 553 + list <Presupuesto> lista_presupuestos; 554 + QSqlQuery query; 555 + bool ok = query.exec(squery.c_str()); 556 + if (!ok) { 557 + qDebug() << query.lastError (); 558 + return lista_presupuestos; 559 + } 560 + while (query.next()) { 561 + Presupuesto *p = new Presupuesto(); 562 + p->setid(query.value(0).toInt()); 563 + p->setaceptado(query.value(1).toBool());// ATENCION!!! 564 + p->setcliente(0); 565 + p->setfactura(0); 566 + p->setn_factura(query.value(4).toInt()); 567 + p->setfecha(query.value(5).toString().toStdString()); 568 + p->setaparato(query.value(6).toString().toStdString()); 569 + p->setmarca(query.value(7).toString().toStdString()); 570 + p->setmodelo(query.value(8).toString().toStdString()); 571 + p->setn_fabricacion(query.value(9).toInt()); 572 + if (!query.value(10).isNull()) { 573 + bool *b = new bool; 574 + *b = query.value(10).toBool(); 575 + p->setlugar_reparacion(b); 576 + } 577 + p->setaveria(query.value(11).toString().toStdString()); 578 + p->settrabajo_realizado(query.value(12).toString().toStdString()); 579 + p->settiempo_empleado(query.value(13).toString().toStdString()); 580 + p->setfecha_terminacion(query.value(14).toString().toStdString()); 581 + p->setobservaciones(query.value(15).toString().toStdString()); 582 + p->setprecio_materiales(query.value(16).toDouble()); 583 + p->setprecio_mano_obra(query.value(17).toDouble()); 584 + p->setprecio_desplazamiento(query.value(18).toDouble()); 585 + p->setprecio_transporte(query.value(19).toDouble()); 586 + p->setiva(query.value(20).toDouble()); 587 + lista_presupuestos.push_back(*p); 588 + } 589 + return lista_presupuestos; 590 + } 591 + 592 + list <Articulo> AccesoADatos::listaArticulos() { 593 + string squery = "select * from Articulos;"; 594 + list <Articulo> lista_articulos; 595 + QSqlQuery query; 596 + bool ok = query.exec(squery.c_str()); 597 + if (!ok) { 598 + qDebug() << query.lastError (); 599 + return lista_articulos; 600 + } 601 + while (query.next()) { 602 + Articulo *a = new Articulo(); 603 + a->setid(query.value(0).toInt()); 604 + a->setcodigo(query.value(1).toInt()); 605 + a->setdescripcion(query.value(2).toString().toStdString()); 606 + a->setcaja(query.value(3).toString().toStdString()); 607 + a->setexistencias(query.value(4).toInt()); 608 + a->setexistencias_minimas(query.value(5).toInt()); 609 + a->setpvp(query.value(6).toDouble());//ATENCION!! 610 + a->setprecio_coste(query.value(7).toDouble()); //ATENCION!! 611 + a->setdescuento(query.value(8).toInt()); 612 + a->sethistorico(query.value(9).toBool()); 613 + 614 + lista_articulos.push_back(*a); 615 + } 616 + return lista_articulos; 617 + } 618 + 619 + //METODOS DE ENLAZADO 620 + 621 + //Esta funcion dado un id de factura devuelve el id de cliente aociado 622 + int AccesoADatos::enlazaCliente(int idf) { 623 + string q("select id_cliente from Facturas where rowid="); 624 + q.append(itoa(idf)); 625 + q.append(";"); 626 + QSqlQuery query; 627 + bool ok = query.exec(q.c_str()); 628 + if (!ok) { 629 + qDebug() << query.lastError (); 630 + } 631 + if (query.next()) 632 + return query.value(0).toInt(); 633 + return -1; 634 + } 635 + 636 + //Esta funcion dado un id de presupuesto devuelve el id de la factura aociada 637 + int AccesoADatos::enlazaFactura(int idp) { 638 + string q("select id_factura from Presupuestos where rowid="); 639 + q.append(itoa(idp)); 640 + q.append(";"); 641 + QSqlQuery query; 642 + bool ok = query.exec(q.c_str()); 643 + if (!ok) { 644 + qDebug() << query.lastError (); 645 + } 646 + if (query.next()) 647 + return query.value(0).toInt(); 648 + return -1; 649 + } 650 + 651 + int AccesoADatos::enlazaClienteP(int idp) { 652 + string q("select id_cliente from Presupuestos where rowid="); 653 + q.append(itoa(idp)); 654 + q.append(";"); 655 + QSqlQuery query; 656 + bool ok = query.exec(q.c_str()); 657 + if (!ok) { 658 + qDebug() << query.lastError (); 659 + } 660 + if (query.next()) 661 + return query.value(0).toInt(); 662 + return -1; 663 + } 664 + 665 + int AccesoADatos::getCantidadArticuloFactura(Factura *f, Articulo *a) { 666 + string q("select cantidad from Facturas_Articulos where id_factura="); 667 + q.append(itoa(f->getid())); 668 + q.append(" and id_articulo="); 669 + q.append(itoa(a->getid())); 670 + q.append(";"); 671 + QSqlQuery query; 672 + bool ok = query.exec(q.c_str()); 673 + if (!ok) { 674 + qDebug() << query.lastError (); 675 + } 676 + if (query.next()) 677 + return query.value(0).toInt(); 678 + return -1; 679 + } 680 + list<int> AccesoADatos::getListaIdArticulos(Factura *f) { 681 + list<int> l; 682 + string q("select id_articulo from Facturas_Articulos where id_factura="); 683 + q.append(itoa(f->getid())); 684 + q.append(";"); 685 + QSqlQuery query; 686 + bool ok = query.exec(q.c_str()); 687 + if (!ok) { 688 + qDebug() << query.lastError (); 689 + } 690 + while (query.next()) { 691 + l.push_back(query.value(0).toInt()); 692 + } 693 + return l; 694 + } 695 + /* Devuelve pares (n� telf, id cliente) */ 696 + list<pair<int, int> > AccesoADatos::getListaTelefonos() { 697 + list<pair<int, int> > l; 698 + string q("select * from Telefonos T where (select id from Clientes C where T.id_cliente = C.id and C.historico=0);"); 699 + QSqlQuery query; 700 + bool ok = query.exec(q.c_str()); 701 + if (!ok) { 702 + qDebug() << query.lastError (); 703 + } 704 + while (query.next()) { 705 + l.push_back(pair<int, int>(query.value(1).toInt(), query.value(2).toInt())); 706 + } 707 + return l; 708 + } 709 + 710 + //METODOS PARA ACTUALIZAR 711 + bool AccesoADatos::actualizaFactura(Factura factura) { 712 + db.transaction(); 713 + string query="update Facturas set ";// 714 + if(factura.getn_factura()==-1) 715 + query.append("n_factura=NULL, "); 716 + else { 717 + string c("n_factura="); 718 + c.append(itoa(factura.getn_factura())); 719 + query.append(c + ", "); 720 + } 721 + if(factura.getfecha() == "") 722 + query.append("fecha=NULL, "); 723 + else 724 + query.append("fecha=\""+factura.getfecha() + "\", "); 725 + 726 + if(factura.getaparato()== "") 727 + query.append("aparato=NULL, "); 728 + else 729 + query.append("aparato=\""+factura.getaparato() + "\", "); 730 + 731 + if(factura.getmarca()== "") 732 + query.append("marca=NULL, "); 733 + else 734 + query.append("marca=\""+factura.getmarca() + "\", "); 735 + 736 + if(factura.getmodelo()== "") 737 + query.append("modelo=NULL, "); 738 + else 739 + query.append("modelo=\""+factura.getmodelo() + "\", "); 740 + 741 + if(factura.getn_fabricacion()== -1) 742 + query.append("n_fabricacion=NULL, "); 743 + else { 744 + string c("n_fabricacion="); 745 + c.append(itoa(factura.getn_fabricacion())); 746 + query.append( c + ", "); 747 + } 748 + if(factura.getlugar_reparacion()== 0) 749 + query.append("lugar_reparacion=NULL, "); 750 + else { 751 + bool lr = *factura.getlugar_reparacion(); 752 + if (lr) query.append("lugar_reparacion=1, "); 753 + else query.append("lugar_reparacion=0, "); 754 + } 755 + 756 + 757 + if(factura.getcliente() == 0) 758 + query.append("id_cliente=NULL, "); 759 + else { 760 + string c("id_cliente="); 761 + c.append(itoa(factura.getcliente()->getid())); 762 + query.append(c + ", "); 763 + } 764 + if(factura.getaveria() == "") { 765 + query.append("averia=NULL, "); 766 + } else { 767 + query.append("averia=\""); 768 + query.append(factura.getaveria() + "\", "); 769 + 770 + } 771 + if(factura.gettrabajo_realizado() == "") { 772 + query.append("trabajo_realizado=NULL, "); 773 + } else { 774 + query.append("trabajo_realizado=\""); 775 + query.append(factura.gettrabajo_realizado() + "\", "); 776 + } 777 + if(factura.gettiempo_empleado() == "") { 778 + query.append("tiempo_empleado=NULL, "); 779 + } else { 780 + query.append("tiempo_empleado=\""); 781 + query.append(factura.gettiempo_empleado() + "\", "); 782 + } 783 + if(factura.getfecha_terminacion() == "") { 784 + query.append("fecha_terminacion=NULL, "); 785 + } else { 786 + query.append("fecha_terminacion=\""); 787 + query.append(factura.getfecha_terminacion() + "\", "); 788 + } 789 + if(factura.getobservaciones() == "") { 790 + query.append("observaciones=NULL, "); 791 + } else { 792 + query.append("observaciones=\""); 793 + query.append(factura.getobservaciones() + "\", "); 794 + } 795 + if(factura.getprecio_materiales() == -1.) { 796 + query.append("precio_materiales=NULL, "); 797 + } else { 798 + query.append("precio_materiales="); 799 + query.append(ftoa(factura.getprecio_materiales())); 800 + query.append(", "); 801 + } 802 + if(factura.getprecio_mano_obra() == -1.) { 803 + query.append("precio_mano_obra=NULL, "); 804 + } else { 805 + query.append("precio_mano_obra="); 806 + query.append(ftoa(factura.getprecio_mano_obra())); 807 + query.append(", "); 808 + } 809 + if(factura.getprecio_desplazamiento() == -1.) { 810 + query.append("precio_desplazamiento=NULL, "); 811 + } else { 812 + query.append("precio_desplazamiento="); 813 + query.append(ftoa(factura.getprecio_desplazamiento())); 814 + query.append(", "); } 815 + if(factura.getprecio_transporte() == -1.) { 816 + query.append("precio_transporte=NULL "); 817 + } else { 818 + query.append("precio_transporte="); 819 + query.append(ftoa(factura.getprecio_transporte())); 820 + query.append(" "); 821 + } 822 + query.append("where rowid="); 823 + query.append(itoa(factura.getid())); 824 + query.append(";"); 825 + 826 + QSqlQuery qquery; 827 + bool ok = qquery.exec(query.c_str()); 828 + 829 + 830 + query = " delete from Facturas_Articulos where id_factura="; 831 + query.append(itoa(factura.getid())); 832 + query.append(";"); 833 + ok = ok && qquery.exec(query.c_str()); 834 + 835 + 836 + list<LineaArticulo> l = factura.getlista_articulos(); 837 + list<LineaArticulo>::iterator iter; 838 + for(iter=l.begin(); iter!=l.end();iter++) { 839 + query = " insert into Facturas_Articulos(id_factura, id_articulo, cantidad) values("; 840 + query.append(itoa(factura.getid())); 841 + query.append(", "); 842 + query.append(itoa(iter->getarticulo().getid())); 843 + query.append(", "); 844 + query.append(itoa(iter->getcantidad())); 845 + query.append(");"); 846 + ok = ok && qquery.exec(query.c_str()); 847 + } 848 + ok = ok && db.commit(); 849 + return ok; 850 + } 851 + 852 + 853 + bool AccesoADatos::actualizaPresupuesto(Presupuesto presupuesto) { 854 + db.transaction(); 855 + QSqlQuery qquery; 856 + 857 + string query="update Presupuestos set ";// 858 + if(presupuesto.getn_factura()==-1) 859 + query.append("n_factura=NULL, "); 860 + else { 861 + string c("n_factura="); 862 + c.append(itoa(presupuesto.getn_factura())); 863 + query.append(c + ", "); 864 + } 865 + if(presupuesto.getfecha() == "") 866 + query.append("fecha=NULL, "); 867 + else 868 + query.append("fecha=\""+ presupuesto.getfecha() + "\", "); 869 + 870 + if(presupuesto.getaparato()== "") 871 + query.append("aparato=NULL, "); 872 + else 873 + query.append("aparato=\"" + presupuesto.getaparato() + "\", "); 874 + 875 + if(presupuesto.getmarca()== "") 876 + query.append("marca=NULL, "); 877 + else 878 + query.append("marca=\"" + presupuesto.getmarca() + "\", "); 879 + 880 + if(presupuesto.getmodelo()== "") 881 + query.append("modelo=NULL, "); 882 + else 883 + query.append("modelo=\"" + presupuesto.getmodelo() + "\", "); 884 + 885 + if(presupuesto.getn_fabricacion()== -1) 886 + query.append("n_fabricacion=NULL, "); 887 + else { 888 + string c("n_fabricacion="); 889 + c.append(itoa(presupuesto.getn_fabricacion())); 890 + query.append( c + ", "); 891 + } 892 + if(presupuesto.getlugar_reparacion()== 0) 893 + query.append("lugar_reparacion=NULL, "); 894 + else { 895 + bool lr = *presupuesto.getlugar_reparacion(); 896 + if (lr) query.append("lugar_reparacion=1, "); 897 + else query.append("lugar_reparacion=0, "); 898 + } 899 + 900 + if(presupuesto.getaceptado()== 0) 901 + query.append("aceptado=NULL, "); 902 + else { 903 + bool lr = *presupuesto.getaceptado(); 904 + if (lr) query.append("aceptado=1, "); 905 + else query.append("aceptado=0, "); 906 + } 907 + if(presupuesto.getcliente() == 0) 908 + query.append("id_cliente=NULL, "); 909 + else { 910 + string c("id_cliente="); 911 + c.append(itoa(presupuesto.getcliente()->getid())); 912 + query.append(c + ", "); 913 + } 914 + 915 + 916 + if(presupuesto.getfactura() == 0) 917 + query.append("id_factura=NULL, "); 918 + else { 919 + string c("id_factura="); 920 + c.append(itoa(presupuesto.getfactura()->getid())); 921 + query.append(", "); 922 + } 923 + if(presupuesto.getaveria() == "") { 924 + query.append("averia=NULL, "); 925 + } else { 926 + query.append("averia=\""); 927 + query.append(presupuesto.getaveria() + "\", "); 928 + 929 + } 930 + if(presupuesto.gettrabajo_realizado() == "") { 931 + query.append("trabajo_realizado=NULL, "); 932 + } else { 933 + query.append("trabajo_realizado=\""); 934 + query.append(presupuesto.gettrabajo_realizado() + "\", "); 935 + } 936 + if(presupuesto.gettiempo_empleado() == "") { 937 + query.append("tiempo_empleado=NULL, "); 938 + } else { 939 + query.append("tiempo_empleado=\""); 940 + query.append(presupuesto.gettiempo_empleado() + "\", "); 941 + } 942 + if(presupuesto.getfecha_terminacion() == "") { 943 + query.append("fecha_terminacion=NULL, "); 944 + } else { 945 + query.append("fecha_terminacion=\""); 946 + query.append(presupuesto.getfecha_terminacion() + "\", "); 947 + } 948 + if(presupuesto.getobservaciones() == "") { 949 + query.append("observaciones=NULL, "); 950 + } else { 951 + query.append("observaciones=\""); 952 + query.append(presupuesto.getobservaciones() + "\", "); 953 + } 954 + if(presupuesto.getprecio_materiales() == -1.) { 955 + query.append("precio_materiales=NULL, "); 956 + } else { 957 + query.append("precio_materiales="); 958 + query.append(ftoa(presupuesto.getprecio_materiales())); 959 + query.append(", "); 960 + } 961 + if(presupuesto.getprecio_mano_obra() == -1.) { 962 + query.append("precio_mano_obra=NULL, "); 963 + } else { 964 + query.append("precio_mano_obra="); 965 + query.append(ftoa(presupuesto.getprecio_mano_obra())); 966 + query.append(", "); 967 + } 968 + if(presupuesto.getprecio_desplazamiento() == -1.) { 969 + query.append("precio_desplazamiento=NULL, "); 970 + } else { 971 + query.append("precio_desplazamiento="); 972 + query.append(ftoa(presupuesto.getprecio_desplazamiento())); 973 + query.append(", "); } 974 + if(presupuesto.getprecio_transporte() == -1.) { 975 + query.append("precio_transporte=NULL "); 976 + } else { 977 + query.append("precio_transporte="); 978 + query.append(ftoa(presupuesto.getprecio_transporte())); 979 + query.append(" "); 980 + } 981 + query.append("where rowid="); 982 + query.append(itoa(presupuesto.getid())); 983 + query.append(";"); 984 + //QMessageBox::information(0,"Aviso",query.c_str()); 985 + bool ok = qquery.exec(query.c_str()); 986 + if (!ok) { 987 + qDebug() << qquery.lastError() << endl; 988 + } 989 + 990 + 991 + query = " delete from Presupuestos_Articulos where id_presupuesto="; 992 + query.append(itoa(presupuesto.getid())); 993 + query.append(";"); 994 + ok = ok && qquery.exec(query.c_str()); 995 + if (!ok) { 996 + qDebug() << qquery.lastError() << endl; 997 + } 998 + 999 + list<LineaArticulo> l = presupuesto.getlista_articulos(); 1000 + list<LineaArticulo>::iterator iter; 1001 + for(iter=l.begin(); iter!=l.end();iter++) { 1002 + query = " insert into Presupuestos_Articulos(id_presupuesto, id_articulo, cantidad) values("; 1003 + query.append(itoa(presupuesto.getid())); 1004 + query.append(", "); 1005 + query.append(itoa(iter->getarticulo().getid())); 1006 + query.append(", "); 1007 + query.append(itoa(iter->getcantidad())); 1008 + query.append(");"); 1009 + ok = ok && qquery.exec(query.c_str()); 1010 + if (!ok) { 1011 + qDebug() << qquery.lastError() << endl; 1012 + } 1013 + } 1014 + ok = ok && db.commit(); 1015 + return ok ; 1016 + } 1017 + 1018 + 1019 + 1020 + bool AccesoADatos::actualizaArticulo(Articulo articulo) { 1021 + db.transaction(); 1022 + string query("update Articulos set historico=1 where historico=0 and rowid="); 1023 + query.append(itoa(articulo.getid())); 1024 + query.append(";"); 1025 + 1026 + QSqlQuery qquery; 1027 + bool ok = qquery.exec(query.c_str()); 1028 + 1029 + query = " insert into Articulos(codigo,descripcion,caja,existencias,existencias_minimas,pvp,precio_coste,descuento) values ("; 1030 + if(articulo.getcodigo() == -1) 1031 + query.append("NULL, "); 1032 + else { 1033 + query.append(itoa(articulo.getcodigo())); 1034 + query.append(", "); 1035 + } 1036 + if(articulo.getdescripcion() =="") 1037 + query.append("NULL, "); 1038 + else { 1039 + query.append("\""); 1040 + query.append(articulo.getdescripcion() + "\", "); 1041 + } 1042 + if(articulo.getcaja() == "" ) 1043 + query.append("NULL, "); 1044 + else { 1045 + query.append("\""); 1046 + query.append(articulo.getcaja() + "\", "); 1047 + } 1048 + if(articulo.getexistencias() == -1) 1049 + query.append("NULL, "); 1050 + else { 1051 + query.append(itoa(articulo.getexistencias())); 1052 + query.append(", "); 1053 + } 1054 + if(articulo.getexistencias_minimas() == -1) 1055 + query.append("NULL, "); 1056 + else { 1057 + query.append(itoa(articulo.getexistencias_minimas())); 1058 + query.append(", "); 1059 + } 1060 + if(articulo.getpvp() ==-1.) 1061 + query.append("NULL, "); 1062 + else { 1063 + query.append(ftoa(articulo.getpvp())); 1064 + query.append(", "); 1065 + } 1066 + if(articulo.getprecio_coste() == -1.) 1067 + query.append("NULL, "); 1068 + else { 1069 + query.append(ftoa(articulo.getprecio_coste())); 1070 + query.append(", "); 1071 + } 1072 + if(articulo.getdescuento() == -1) 1073 + query.append("NULL);"); 1074 + else { 1075 + query.append(itoa(articulo.getdescuento())); 1076 + query.append(");"); 1077 + } 1078 + ok = ok && qquery.exec(query.c_str()); 1079 + ok = ok && db.commit(); 1080 + return ok; 1081 + } 1082 + 1083 + 1084 + bool AccesoADatos::actualizaCliente(Cliente cliente) { 1085 + db.transaction(); 1086 + string query("update Clientes set historico=1 where historico=0 and rowid="); 1087 + query.append(itoa(cliente.getid())); 1088 + query.append("; "); 1089 + QSqlQuery qquery; 1090 + bool ok = qquery.exec(query.c_str()); 1091 + 1092 + query="insert into Clientes(codigo,nombre,apellidos,direccion,nif,poblacion) values("; 1093 + if(cliente.getcodigo() == 0) 1094 + query.append("NULL, "); 1095 + else { 1096 + query.append(itoa(cliente.getcodigo())); 1097 + query.append(", "); 1098 + } 1099 + if(cliente.getnombre() == "") 1100 + query.append("NULL, "); 1101 + else { 1102 + query.append("\""); 1103 + query.append(cliente.getnombre() + "\", "); 1104 + } 1105 + if(cliente.getapellidos() == "") 1106 + query.append("NULL, "); 1107 + else { 1108 + query.append("\""); 1109 + query.append(cliente.getapellidos() + "\", "); 1110 + } 1111 + if(cliente.getdireccion()=="") 1112 + query.append("NULL, "); 1113 + else { 1114 + query.append("\""); 1115 + query.append(cliente.getdireccion() + "\", " ); 1116 + } 1117 + if(cliente.getnif()=="") 1118 + query.append("NULL, "); 1119 + else { 1120 + query.append("\""); 1121 + query.append( cliente.getnif() + "\", "); 1122 + } 1123 + if(cliente.getpoblacion()=="") 1124 + query.append("NULL);"); 1125 + else { 1126 + query.append("\""); 1127 + query.append( cliente.getpoblacion() + "\");"); 1128 + } 1129 + 1130 + list<int> lista = cliente.gettelefonos(); 1131 + list<int>::iterator it; 1132 + for (it = lista.begin(); it != lista.end(); it++){ 1133 + string queryTelefonos="insert into Telefonos(id_cliente,numero) values("; 1134 + queryTelefonos.append(itoa(dameIdCliente())); 1135 + queryTelefonos.append(", "); 1136 + queryTelefonos.append(itoa(*it)); 1137 + queryTelefonos.append(");"); 1138 + cout << "[Debug]" << queryTelefonos << endl; 1139 + QSqlQuery qqueryt; 1140 + ok = ok && qqueryt.exec(queryTelefonos.c_str()); 1141 + } 1142 + 1143 + ok = ok && qquery.exec(query.c_str()); 1144 + ok = ok && db.commit(); 1145 + return ok; 1146 + } 1147 + 1148 + 1149 + 1150 + 1151 + 1152 + //FALTA COMPROBAR QUE LA BD NO SE QUEDE EN UN ESTADO INCONSISTENTE 1153 + //METODOS PARA ELIMINAR DE LA BD 1154 + bool AccesoADatos::eliminarFactura(Factura f) { 1155 + string q("delete from Facturas where rowid="); 1156 + q.append(itoa(f.getid())); 1157 + q.append(";"); 1158 + QSqlQuery query; 1159 + bool ok = query.exec(q.c_str()); 1160 + if (!ok) { 1161 + qDebug() << query.lastError (); 1162 + return false; 1163 + } 1164 + return true; 1165 + } 1166 + 1167 + 1168 + bool AccesoADatos::eliminarPresupuesto(Presupuesto p) { 1169 + string q("delete from Presupuestos where rowid="); 1170 + q.append(itoa(p.getid())); 1171 + q.append(";"); 1172 + QSqlQuery query; 1173 + bool ok = query.exec(q.c_str()); 1174 + if (!ok) { 1175 + qDebug() << query.lastError (); 1176 + return false; 1177 + } 1178 + return true; 1179 + } 1180 + 1181 + bool AccesoADatos::eliminarCliente(Cliente c) { 1182 + // Borrar un cliente solo es marcarlo como historico. 1183 + string q("update Clientes set historico=1 where historico=0 and rowid="); 1184 + q.append(itoa(c.getid())); 1185 + q.append(";"); 1186 + QSqlQuery query; 1187 + bool ok = query.exec(q.c_str()); 1188 + if (!ok) { 1189 + qDebug() << query.lastError (); 1190 + return false; 1191 + } 1192 + return true; 1193 + } 1194 + 1195 + bool AccesoADatos::eliminarArticulo(Articulo a) { 1196 + // Borrar un articulo solo es marcarlo como historico. 1197 + string q("update Articulos set historico=1 where historico=0 and rowid="); 1198 + q.append(itoa(a.getid())); 1199 + q.append(";"); 1200 + QSqlQuery query; 1201 + bool ok = query.exec(q.c_str()); 1202 + if (!ok) { 1203 + qDebug() << query.lastError (); 1204 + return false; 1205 + } 1206 + return true; 1207 + } 1208 + 1209 + //METODOS "DAME" 1210 + int AccesoADatos::dameIdArticulo() { 1211 + string q("select seq from sqlite_sequence where name=\"Articulos\";"); 1212 + QSqlQuery query; 1213 + bool ok = query.exec(q.c_str()); 1214 + if (!ok) { 1215 + qDebug() << query.lastError (); 1216 + return -1; 1217 + } 1218 + if (query.next()) 1219 + return query.value(0).toInt() + 1; 1220 + return 1; 1221 + } 1222 + int AccesoADatos::dameIdCliente() { 1223 + string q("select seq from sqlite_sequence where name=\"Clientes\";"); 1224 + QSqlQuery query; 1225 + bool ok = query.exec(q.c_str()); 1226 + if (!ok) { 1227 + qDebug() << query.lastError (); 1228 + return -1; 1229 + } 1230 + if (query.next()) 1231 + return query.value(0).toInt() + 1; 1232 + return 1; 1233 + } 1234 + int AccesoADatos::dameIdFactura() { 1235 + string q("select seq from sqlite_sequence where name=\"Facturas\";"); 1236 + QSqlQuery query; 1237 + bool ok = query.exec(q.c_str()); 1238 + if (!ok) { 1239 + qDebug() << query.lastError (); 1240 + return -1; 1241 + } 1242 + if (query.next()) 1243 + return query.value(0).toInt() + 1; 1244 + return 1; 1245 + } 1246 + int AccesoADatos::dameIdPresupuesto() { 1247 + string q("select seq from sqlite_sequence where name=\"Presupuestos\";"); 1248 + QSqlQuery query; 1249 + bool ok = query.exec(q.c_str()); 1250 + if (!ok) { 1251 + qDebug() << query.lastError (); 1252 + return -1; 1253 + } 1254 + if (query.next()) 1255 + return query.value(0).toInt() + 1; 1256 + return 1; 1257 + } 1258 + 1259 + bool AccesoADatos::cambiarIva(int v) { 1260 + string q("update Iva set valor="); 1261 + q.append(QString::number(v,10).toStdString().c_str()); 1262 + q.append(";"); 1263 + QSqlQuery query; 1264 + bool ok = query.exec(q.c_str()); 1265 + if (!ok) { 1266 + qDebug() << query.lastError (); 1267 + return false; 1268 + } 1269 + return true; 1270 + } 1271 + 1272 + int AccesoADatos::obtenerIva() { 1273 + string q("select valor from Iva;"); 1274 + QSqlQuery query; 1275 + bool ok = query.exec(q.c_str()); 1276 + if (!ok) { 1277 + qDebug() << query.lastError (); 1278 + return -1; 1279 + } 1280 + if (query.next()) 1281 + return query.value(0).toInt(); 1282 + return -1; 1283 + }
+54
Datos/AccesoADatos.h
··· 1 + #ifndef ACCESOADATOS_H_ 2 + #define ACCESOADATOS_H_ 3 + #include "../Negocio/Factura.h" 4 + #include "../Negocio/Articulo.h" 5 + #include "../Negocio/Cliente.h" 6 + #include "../Negocio/Presupuesto.h" 7 + #include <list> 8 + #include <QtSql> 9 + 10 + class AccesoADatos 11 + { 12 + 13 + private: 14 + QSqlDatabase db; //puntero a base de datos 15 + 16 + public: 17 + AccesoADatos(); 18 + virtual ~AccesoADatos(); 19 + bool insertaFactura(Factura factura); 20 + bool insertaCliente(Cliente cliente); 21 + bool insertaArticulo(Articulo articulo); 22 + bool insertaPresupuesto(Presupuesto presupuesto); 23 + list <Factura> listaFacturas(); 24 + list <Cliente> listaClientes(); 25 + list <Articulo> listaArticulos(); 26 + list <Presupuesto> listaPresupuestos(); 27 + int enlazaCliente(int idf); 28 + int enlazaFactura(int idp); 29 + int enlazaClienteP(int idp); 30 + bool actualizaFactura(Factura f); 31 + int getCantidadArticuloFactura(Factura *f, Articulo *a); 32 + list<int> getListaIdArticulos(Factura *f); 33 + bool actualizaPresupuesto(Presupuesto p); 34 + bool actualizaArticulo(Articulo a); 35 + bool actualizaCliente(Cliente c); 36 + bool eliminarFactura(Factura f); 37 + bool eliminarPresupuesto(Presupuesto p); 38 + bool eliminarArticulo(Articulo a); 39 + bool eliminarCliente(Cliente c); 40 + 41 + //Devuelve el identificador siguiente del máximo 42 + int dameIdFactura(); 43 + int dameIdCliente(); 44 + int dameIdPresupuesto(); 45 + int dameIdArticulo(); 46 + 47 + bool cambiarIva(int v); 48 + int obtenerIva(); 49 + 50 + list <pair<int, int> > getListaTelefonos(); 51 + 52 + }; 53 + 54 + #endif /*ACCESOADATOS_H_*/
+31
Datos/CriterioBusqueda.cpp
··· 1 + #include "CriterioBusqueda.h" 2 + 3 + #include <QDate> 4 + #include <QString> 5 + 6 + CriterioBusqueda::CriterioBusqueda() 7 + { 8 + fechaFin = 0; 9 + fechaInicio = 0; 10 + numero = 0; 11 + cliente = 0; 12 + nombreCliente = 0; 13 + direccionCliente = 0; 14 + codigoCliente = 0; 15 + codigoArticulo =0; 16 + descripcionArticulo = 0; 17 + telefono = 0; 18 + } 19 + 20 + CriterioBusqueda::CriterioBusqueda(QDate *fi, QDate *ff, QString *c, int *n, int *t) : 21 + fechaInicio(fi), 22 + fechaFin(ff), 23 + cliente(c), 24 + numero(n), 25 + telefono(t) 26 + { 27 + } 28 + 29 + CriterioBusqueda::~CriterioBusqueda() 30 + { 31 + }
+29
Datos/CriterioBusqueda.h
··· 1 + #ifndef CRITERIOBUSQUEDA_H_ 2 + #define CRITERIOBUSQUEDA_H_ 3 + 4 + #include <QDate> 5 + #include <QString> 6 + 7 + class CriterioBusqueda 8 + { 9 + public: 10 + CriterioBusqueda(); 11 + CriterioBusqueda(QDate *fi, QDate *ff, QString *c, int *n, int *t); 12 + virtual ~CriterioBusqueda(); 13 + 14 + QDate *fechaInicio; 15 + QDate *fechaFin; 16 + QString *cliente; 17 + int *numero; 18 + int *telefono; 19 + 20 + QString *nombreCliente; 21 + QString *direccionCliente; 22 + int *codigoCliente; 23 + 24 + QString *descripcionArticulo; 25 + int *codigoArticulo; 26 + 27 + }; 28 + 29 + #endif /*CRITERIOBUSQUEDA_H_*/
Datos/seoane.s3db

This is a binary file and will not be displayed.

+130
Datos/seoane.sql
··· 1 + CREATE TABLE [Articulos] ( 2 + [id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 3 + [codigo] INTEGER NOT NULL, 4 + [descripcion] TEXT NULL, 5 + [caja] TEXT NULL, 6 + [existencias] INTEGER NULL, 7 + [existencias_minimas] INTEGER NULL, 8 + [pvp] REAL NULL, 9 + [precio_coste] REAL NULL, 10 + [descuento] REAL NULL, 11 + [historico] BOOLEAN NOT NULL DEFAULT 0 12 + ); 13 + CREATE TABLE [Calles] ( 14 + [id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 15 + [nombre] TEXT NOT NULL, 16 + [cp] INTEGER NULL 17 + ); 18 + CREATE TABLE [Clientes] ( 19 + [id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 20 + [codigo] INTEGER NULL, 21 + [nombre] TEXT NOT NULL, 22 + [apellidos] TEXT NOT NULL, 23 + [direccion] TEXT NULL, 24 + [nif] TEXT NULL, 25 + [poblacion] TEXT NULL, 26 + [historico] BOOLEAN NOT NULL DEFAULT 0 27 + ); 28 + CREATE TABLE [Clientes_Callles] ( 29 + [id_cliente] INTEGER NULL, 30 + [id_calle] INTEGER NULL, 31 + PRIMARY KEY ([id_cliente],[id_calle]) 32 + ); 33 + CREATE TABLE [Facturas] ( 34 + [id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 35 + [n_factura] INTEGER UNIQUE NULL, 36 + [fecha] DATE NULL, 37 + [aparato] TEXT NULL, 38 + [marca] TEXT NULL, 39 + [modelo] TEXT NULL, 40 + [n_fabricacion] TEXT NULL, 41 + [lugar_reparacion] BOOLEAN NULL, 42 + [id_cliente] INTEGER NOT NULL, 43 + [averia] TEXT NULL, 44 + [trabajo_realizado] TEXT NULL, 45 + [tiempo_empleado] TEXT NULL, 46 + [fecha_terminacion] DATE NULL, 47 + [observaciones] TEXT NULL, 48 + [precio_materiales] REAL NULL, 49 + [precio_mano_obra] REAL NULL, 50 + [precio_desplazamiento] REAL NULL, 51 + [precio_transporte] REAL NULL, 52 + [iva] REAL NOT NULL 53 + ); 54 + CREATE TABLE [Facturas_Articulos] ( 55 + [id_factura] INTEGER NULL, 56 + [id_articulo] INTEGER NULL, 57 + [cantidad] INTEGER NULL, 58 + PRIMARY KEY ([id_factura],[id_articulo]) 59 + ); 60 + CREATE TABLE [Iva] ( [valor] INTEGER PRYMARY KEY); 61 + CREATE TABLE [Presupuestos] ( 62 + [id] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, 63 + [aceptado] BOOLEAN NOT NULL, 64 + [id_cliente] INTEGER NULL, 65 + [id_factura] INTEGER NULL, 66 + [n_factura] INTEGER UNIQUE NULL, 67 + [fecha] DATE NULL, 68 + [aparato] TEXT NULL, 69 + [marca] TEXT NULL, 70 + [modelo] TEXT NULL, 71 + [n_fabricacion] TEXT NULL, 72 + [lugar_reparacion] BOOLEAN NULL, 73 + [averia] TEXT NULL, 74 + [trabajo_realizado] TEXT NULL, 75 + [tiempo_empleado] TEXT NULL, 76 + [fecha_terminacion] DATE NULL, 77 + [observaciones] TEXT NULL, 78 + [precio_materiales] REAL NULL, 79 + [precio_mano_obra] REAL NULL, 80 + [precio_desplazamiento] REAL NULL, 81 + [precio_transporte] REAL NULL, 82 + [iva] REAL NOT NULL 83 + ); 84 + CREATE TABLE [Presupuestos_Articulos] ( 85 + [id_presupuesto] INTEGER NULL, 86 + [id_articulo] INTEGER NULL, 87 + [cantidad] INTEGER NULL, 88 + PRIMARY KEY ([id_presupuesto],[id_articulo]) 89 + ); 90 + CREATE TABLE [Telefonos] ( 91 + [id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, 92 + [numero] INTEGER NOT NULL, 93 + [id_cliente] INTEGER NOT NULL 94 + ); 95 + CREATE TRIGGER Unicidad_Articulos_Insert 96 + BEFORE INSERT ON Articulos 97 + FOR EACH ROW 98 + BEGIN 99 + SELECT CASE 100 + WHEN (NEW.codigo IN (SELECT codigo FROM Articulos WHERE historico=0)) 101 + THEN raise(abort,"Violacion de unicidad en Articulos al insertar.") 102 + END; 103 + END; 104 + CREATE TRIGGER Unicidad_Articulos_Update 105 + AFTER UPDATE ON Articulos 106 + FOR EACH ROW 107 + BEGIN 108 + SELECT CASE 109 + WHEN (NEW.codigo IN (SELECT codigo FROM Articulos WHERE historico=0)) 110 + THEN raise(abort,"Violacion de unicidad en Articulos al actualizar.") 111 + END; 112 + END; 113 + CREATE TRIGGER Unicidad_Clientes_Insert 114 + BEFORE INSERT ON Clientes 115 + FOR EACH ROW 116 + BEGIN 117 + SELECT CASE 118 + WHEN (NEW.codigo IN (SELECT codigo FROM Clientes WHERE historico=0)) 119 + THEN raise(abort,"Violacion de unicidad en Clientes al insertar.") 120 + END; 121 + END; 122 + CREATE TRIGGER Unicidad_Clientes_Update 123 + AFTER UPDATE ON Clientes 124 + FOR EACH ROW 125 + BEGIN 126 + SELECT CASE 127 + WHEN (NEW.codigo IN (SELECT codigo FROM Clientes WHERE historico=0)) 128 + THEN raise(abort,"Violacion de unicidad en Clientes al actualizar.") 129 + END; 130 + END;
+14
Datos/utils.cpp
··· 1 + #include "utils.h" 2 + #include <cstdio> 3 + 4 + char *itoa(int i) { 5 + char *a = new char[1024]; 6 + sprintf(a,"%d",i); 7 + return a; 8 + 9 + } 10 + char *ftoa(float f) { 11 + char *a = new char[1024]; 12 + sprintf(a,"%f",f); 13 + return a; 14 + }
+7
Datos/utils.h
··· 1 + #ifndef UTILS_H_ 2 + #define UTILS_H_ 3 + 4 + char *itoa(int i); 5 + char *ftoa(float f); 6 + 7 + #endif /*UTILS_H_*/
+39
Gui/BuscarArticuloDialog.cpp
··· 1 + #include "BuscarArticuloDialog.h" 2 + #include "ListarArticulos.h" 3 + 4 + BuscarArticuloDialog::BuscarArticuloDialog(CapaNegocio *cn, QWidget *parent) 5 + : QDialog(parent) 6 + { 7 + padre = (QWorkspace *)parent; 8 + ui.setupUi(this); 9 + capaNegocio = cn; 10 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/BArticulo.PNG"))); 11 + } 12 + 13 + BuscarArticuloDialog::~BuscarArticuloDialog() 14 + { 15 + 16 + } 17 + 18 + void BuscarArticuloDialog::accept() { 19 + CriterioBusqueda *cb = new CriterioBusqueda(); 20 + 21 + if (ui.lineEdit->text() != tr("")) { 22 + cb->codigoArticulo = new int; 23 + *cb->codigoArticulo = ui.lineEdit->text().toInt(); 24 + } 25 + if (ui.lineEdit_2->text() != tr("")) 26 + cb->descripcionArticulo = new QString(ui.lineEdit_2->text()); 27 + 28 + ListarArticulos *lf = new ListarArticulos(capaNegocio, padre , cb); 29 + padre->addWindow(lf); 30 + lf->show(); 31 + 32 + this->close(); 33 + } 34 + 35 + 36 + void BuscarArticuloDialog::resizeEvent(QResizeEvent *event) { 37 + setFixedSize(event->size()); 38 + } 39 +
+27
Gui/BuscarArticuloDialog.h
··· 1 + #ifndef BUSCARARTICULODIALOG_H 2 + #define BUSCARARTICULODIALOG_H 3 + 4 + #include <QtGui> 5 + #include "ui_BuscarArticuloDialog.h" 6 + #include "../Negocio/CapaNegocio.h" 7 + 8 + class BuscarArticuloDialog : public QDialog 9 + { 10 + Q_OBJECT 11 + 12 + public: 13 + BuscarArticuloDialog(CapaNegocio *cn, QWidget *parent = 0); 14 + ~BuscarArticuloDialog(); 15 + private slots: 16 + void accept(); 17 + 18 + private: 19 + Ui::BuscarArticuloDialogClass ui; 20 + CapaNegocio *capaNegocio; 21 + QWorkspace *padre; 22 + 23 + protected: 24 + void resizeEvent(QResizeEvent *event); 25 + }; 26 + 27 + #endif // BUSCARARTICULODIALOG_H
+118
Gui/BuscarArticuloDialog.ui
··· 1 + <ui version="4.0" > 2 + <class>BuscarArticuloDialogClass</class> 3 + <widget class="QDialog" name="BuscarArticuloDialogClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>400</width> 9 + <height>121</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>Buscar Articulo</string> 14 + </property> 15 + <property name="windowIcon" > 16 + <iconset>images/BArticulo.PNG</iconset> 17 + </property> 18 + <widget class="QWidget" name="gridLayout" > 19 + <property name="geometry" > 20 + <rect> 21 + <x>11</x> 22 + <y>10</y> 23 + <width>381</width> 24 + <height>101</height> 25 + </rect> 26 + </property> 27 + <layout class="QGridLayout" > 28 + <item row="0" column="0" > 29 + <widget class="QLabel" name="label" > 30 + <property name="text" > 31 + <string>Codigo</string> 32 + </property> 33 + </widget> 34 + </item> 35 + <item row="1" column="0" > 36 + <widget class="QLabel" name="label_2" > 37 + <property name="text" > 38 + <string>Descripcion</string> 39 + </property> 40 + </widget> 41 + </item> 42 + <item row="0" column="1" > 43 + <widget class="QLineEdit" name="lineEdit" /> 44 + </item> 45 + <item row="1" column="1" > 46 + <widget class="QLineEdit" name="lineEdit_2" /> 47 + </item> 48 + <item row="2" column="1" > 49 + <layout class="QHBoxLayout" > 50 + <item> 51 + <spacer> 52 + <property name="orientation" > 53 + <enum>Qt::Horizontal</enum> 54 + </property> 55 + <property name="sizeHint" > 56 + <size> 57 + <width>40</width> 58 + <height>20</height> 59 + </size> 60 + </property> 61 + </spacer> 62 + </item> 63 + <item> 64 + <widget class="QPushButton" name="pushButton" > 65 + <property name="text" > 66 + <string>Buscar</string> 67 + </property> 68 + </widget> 69 + </item> 70 + <item> 71 + <widget class="QPushButton" name="pushButton_2" > 72 + <property name="text" > 73 + <string>Cancelar</string> 74 + </property> 75 + </widget> 76 + </item> 77 + </layout> 78 + </item> 79 + </layout> 80 + </widget> 81 + </widget> 82 + <layoutdefault spacing="6" margin="11" /> 83 + <resources/> 84 + <connections> 85 + <connection> 86 + <sender>pushButton</sender> 87 + <signal>clicked()</signal> 88 + <receiver>BuscarArticuloDialogClass</receiver> 89 + <slot>accept()</slot> 90 + <hints> 91 + <hint type="sourcelabel" > 92 + <x>263</x> 93 + <y>94</y> 94 + </hint> 95 + <hint type="destinationlabel" > 96 + <x>201</x> 97 + <y>89</y> 98 + </hint> 99 + </hints> 100 + </connection> 101 + <connection> 102 + <sender>pushButton_2</sender> 103 + <signal>clicked()</signal> 104 + <receiver>BuscarArticuloDialogClass</receiver> 105 + <slot>reject()</slot> 106 + <hints> 107 + <hint type="sourcelabel" > 108 + <x>333</x> 109 + <y>92</y> 110 + </hint> 111 + <hint type="destinationlabel" > 112 + <x>310</x> 113 + <y>69</y> 114 + </hint> 115 + </hints> 116 + </connection> 117 + </connections> 118 + </ui>
+43
Gui/BuscarClienteDialog.cpp
··· 1 + #include "BuscarClienteDialog.h" 2 + #include "ListarClientes.h" 3 + 4 + BuscarClienteDialog::BuscarClienteDialog(CapaNegocio *cn, QWidget *parent) 5 + : QDialog(parent) 6 + { 7 + padre = (QWorkspace *)parent; 8 + ui.setupUi(this); 9 + capaNegocio = cn; 10 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/BCliente.PNG"))); 11 + } 12 + 13 + BuscarClienteDialog::~BuscarClienteDialog() 14 + { 15 + 16 + } 17 + 18 + void BuscarClienteDialog::accept() { 19 + CriterioBusqueda *cb = new CriterioBusqueda(); 20 + 21 + if (ui.lineEdit_3->text() != tr("")) 22 + cb->nombreCliente = new QString(ui.lineEdit_3->text()); 23 + if (ui.lineEdit_2->text() != tr("")) { 24 + cb->codigoCliente = new int; 25 + *cb->codigoCliente = ui.lineEdit_2->text().toInt(); 26 + } 27 + if (ui.lineEdit->text() != tr("")) 28 + cb->direccionCliente = new QString(ui.lineEdit->text()); 29 + if (ui.lineEdit_4->text() != tr("")) { 30 + cb->telefono = new int; 31 + *cb->telefono = ui.lineEdit_4->text().toInt(); 32 + } 33 + 34 + ListarClientes *lf = new ListarClientes(capaNegocio, padre , cb); 35 + padre->addWindow(lf); 36 + lf->show(); 37 + 38 + this->close(); 39 + } 40 + 41 + void BuscarClienteDialog::resizeEvent(QResizeEvent *event) { 42 + setFixedSize(event->size()); 43 + }
+27
Gui/BuscarClienteDialog.h
··· 1 + #ifndef BUSCARCLIENTEDIALOG_H 2 + #define BUSCARCLIENTEDIALOG_H 3 + 4 + #include <QtGui> 5 + #include "ui_BuscarClienteDialog.h" 6 + #include "../Negocio/CapaNegocio.h" 7 + 8 + class BuscarClienteDialog : public QDialog 9 + { 10 + Q_OBJECT 11 + 12 + public: 13 + BuscarClienteDialog(CapaNegocio *cn, QWidget *parent = 0); 14 + ~BuscarClienteDialog(); 15 + 16 + private slots: 17 + void accept(); 18 + 19 + private: 20 + Ui::BuscarClienteDialogClass ui; 21 + CapaNegocio *capaNegocio; 22 + QWorkspace *padre; 23 + protected: 24 + void resizeEvent(QResizeEvent *event); 25 + }; 26 + 27 + #endif // BUSCARCLIENTEDIALOG_H
+138
Gui/BuscarClienteDialog.ui
··· 1 + <ui version="4.0" > 2 + <class>BuscarClienteDialogClass</class> 3 + <widget class="QDialog" name="BuscarClienteDialogClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>401</width> 9 + <height>171</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>Buscar Cliente</string> 14 + </property> 15 + <property name="windowIcon" > 16 + <iconset>images/BCliente.PNG</iconset> 17 + </property> 18 + <widget class="QWidget" name="gridLayout" > 19 + <property name="geometry" > 20 + <rect> 21 + <x>10</x> 22 + <y>10</y> 23 + <width>381</width> 24 + <height>151</height> 25 + </rect> 26 + </property> 27 + <layout class="QGridLayout" > 28 + <item row="0" column="0" > 29 + <widget class="QLabel" name="label" > 30 + <property name="text" > 31 + <string>Nombre</string> 32 + </property> 33 + </widget> 34 + </item> 35 + <item row="1" column="0" > 36 + <widget class="QLabel" name="label_2" > 37 + <property name="text" > 38 + <string>Codigo</string> 39 + </property> 40 + </widget> 41 + </item> 42 + <item row="2" column="0" > 43 + <widget class="QLabel" name="label_3" > 44 + <property name="text" > 45 + <string>Direccion</string> 46 + </property> 47 + </widget> 48 + </item> 49 + <item row="0" column="1" > 50 + <widget class="QLineEdit" name="lineEdit_3" /> 51 + </item> 52 + <item row="1" column="1" > 53 + <widget class="QLineEdit" name="lineEdit_2" /> 54 + </item> 55 + <item row="2" column="1" > 56 + <widget class="QLineEdit" name="lineEdit" /> 57 + </item> 58 + <item row="3" column="1" > 59 + <widget class="QLineEdit" name="lineEdit_4" /> 60 + </item> 61 + <item row="4" column="1" > 62 + <layout class="QHBoxLayout" > 63 + <item> 64 + <spacer> 65 + <property name="orientation" > 66 + <enum>Qt::Horizontal</enum> 67 + </property> 68 + <property name="sizeHint" > 69 + <size> 70 + <width>40</width> 71 + <height>20</height> 72 + </size> 73 + </property> 74 + </spacer> 75 + </item> 76 + <item> 77 + <widget class="QPushButton" name="pushButton" > 78 + <property name="text" > 79 + <string>Buscar</string> 80 + </property> 81 + </widget> 82 + </item> 83 + <item> 84 + <widget class="QPushButton" name="pushButton_2" > 85 + <property name="text" > 86 + <string>Cancelar</string> 87 + </property> 88 + </widget> 89 + </item> 90 + </layout> 91 + </item> 92 + <item row="3" column="0" > 93 + <widget class="QLabel" name="label_4" > 94 + <property name="text" > 95 + <string>Teléfono</string> 96 + </property> 97 + </widget> 98 + </item> 99 + </layout> 100 + </widget> 101 + </widget> 102 + <layoutdefault spacing="6" margin="11" /> 103 + <resources/> 104 + <connections> 105 + <connection> 106 + <sender>pushButton</sender> 107 + <signal>clicked()</signal> 108 + <receiver>BuscarClienteDialogClass</receiver> 109 + <slot>accept()</slot> 110 + <hints> 111 + <hint type="sourcelabel" > 112 + <x>271</x> 113 + <y>132</y> 114 + </hint> 115 + <hint type="destinationlabel" > 116 + <x>192</x> 117 + <y>115</y> 118 + </hint> 119 + </hints> 120 + </connection> 121 + <connection> 122 + <sender>pushButton_2</sender> 123 + <signal>clicked()</signal> 124 + <receiver>BuscarClienteDialogClass</receiver> 125 + <slot>reject()</slot> 126 + <hints> 127 + <hint type="sourcelabel" > 128 + <x>332</x> 129 + <y>131</y> 130 + </hint> 131 + <hint type="destinationlabel" > 132 + <x>315</x> 133 + <y>114</y> 134 + </hint> 135 + </hints> 136 + </connection> 137 + </connections> 138 + </ui>
+53
Gui/BuscarFacturaDialog.cpp
··· 1 + #include "BuscarFacturaDialog.h" 2 + #include "../Datos/CriterioBusqueda.h" 3 + #include "../Negocio/CapaNegocio.h" 4 + #include "ListarFacturas.h" 5 + #include <iostream> 6 + using namespace std; 7 + 8 + BuscarFacturaDialog::BuscarFacturaDialog(CapaNegocio *cn, QWidget *parent) 9 + : QDialog(parent) 10 + { 11 + padre = (QWorkspace *)parent; 12 + ui.setupUi(this); 13 + capaNegocio = cn; 14 + setWindowTitle(tr("Buscar Factura")); 15 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/BFactura.PNG"))); 16 + ui.checkBoxAl->setText(""); 17 + ui.checkBoxDel->setText(""); 18 + ui.dateEdit->setEnabled(false); 19 + ui.dateEdit_2->setEnabled(false); 20 + 21 + QDate hoy = QDate::currentDate(); 22 + ui.dateEdit->setDate(hoy); 23 + ui.dateEdit_2->setDate(hoy); 24 + } 25 + 26 + BuscarFacturaDialog::~BuscarFacturaDialog() 27 + { 28 + 29 + } 30 + 31 + void BuscarFacturaDialog::accept() { 32 + CriterioBusqueda *cb = new CriterioBusqueda(); 33 + 34 + if (ui.lineEdit_2->text() != tr("")) 35 + cb->cliente = new QString(ui.lineEdit_2->text()); 36 + if (ui.lineEdit->text() != tr("")) { 37 + cb->numero = new int; 38 + *cb->numero = ui.lineEdit->text().toInt(); 39 + } 40 + if (ui.checkBoxAl->isChecked()) 41 + cb->fechaFin = new QDate(ui.dateEdit_2->date()); 42 + if (ui.checkBoxDel->isChecked()) 43 + cb->fechaInicio = new QDate(ui.dateEdit->date()); 44 + 45 + ListarFacturas *lf = new ListarFacturas(capaNegocio, padre , cb); 46 + padre->addWindow(lf); 47 + lf->show(); 48 + 49 + this->close(); 50 + } 51 + void BuscarFacturaDialog::resizeEvent(QResizeEvent *event) { 52 + setFixedSize(event->size()); 53 + }
+29
Gui/BuscarFacturaDialog.h
··· 1 + #ifndef BUSCARFACTURADIALOG_H 2 + #define BUSCARFACTURADIALOG_H 3 + 4 + #include <QtGui/QDialog> 5 + #include <QtGui> 6 + #include "../Negocio/CapaNegocio.h" 7 + #include "ui_BuscarFacturaDialog.h" 8 + 9 + class BuscarFacturaDialog : public QDialog 10 + { 11 + Q_OBJECT 12 + 13 + public: 14 + BuscarFacturaDialog(CapaNegocio *cn, QWidget *parent = 0); 15 + ~BuscarFacturaDialog(); 16 + 17 + private slots: 18 + void accept(); 19 + 20 + private: 21 + Ui::BuscarFacturaDialogClass ui; 22 + CapaNegocio *capaNegocio; 23 + QWorkspace *padre; 24 + 25 + protected: 26 + void resizeEvent(QResizeEvent *event); 27 + }; 28 + 29 + #endif // BUSCARFACTURADIALOG_H
+216
Gui/BuscarFacturaDialog.ui
··· 1 + <ui version="4.0" > 2 + <class>BuscarFacturaDialogClass</class> 3 + <widget class="QDialog" name="BuscarFacturaDialogClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>585</width> 9 + <height>115</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>BuscarFacturaDialog</string> 14 + </property> 15 + <property name="windowIcon" > 16 + <iconset>images/BFactura.PNG</iconset> 17 + </property> 18 + <widget class="QWidget" name="gridLayout" > 19 + <property name="geometry" > 20 + <rect> 21 + <x>10</x> 22 + <y>10</y> 23 + <width>567</width> 24 + <height>95</height> 25 + </rect> 26 + </property> 27 + <layout class="QGridLayout" > 28 + <item rowspan="2" row="1" column="0" > 29 + <widget class="QLabel" name="label_3" > 30 + <property name="text" > 31 + <string>Fecha:</string> 32 + </property> 33 + </widget> 34 + </item> 35 + <item rowspan="2" row="1" column="1" > 36 + <widget class="QLabel" name="label_4" > 37 + <property name="text" > 38 + <string>Del</string> 39 + </property> 40 + <property name="alignment" > 41 + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 42 + </property> 43 + </widget> 44 + </item> 45 + <item rowspan="2" row="1" column="5" > 46 + <widget class="QLabel" name="label_6" > 47 + <property name="text" > 48 + <string>al</string> 49 + </property> 50 + <property name="alignment" > 51 + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 52 + </property> 53 + </widget> 54 + </item> 55 + <item rowspan="2" row="1" column="2" colspan="2" > 56 + <widget class="QDateEdit" name="dateEdit" > 57 + <property name="displayFormat" > 58 + <string>dd/MM/yyyy</string> 59 + </property> 60 + <property name="calendarPopup" > 61 + <bool>true</bool> 62 + </property> 63 + <property name="date" > 64 + <date> 65 + <year>2007</year> 66 + <month>1</month> 67 + <day>2</day> 68 + </date> 69 + </property> 70 + </widget> 71 + </item> 72 + <item rowspan="2" row="1" column="6" colspan="2" > 73 + <widget class="QDateEdit" name="dateEdit_2" > 74 + <property name="displayFormat" > 75 + <string>dd/MM/yyyy</string> 76 + </property> 77 + <property name="calendarPopup" > 78 + <bool>true</bool> 79 + </property> 80 + </widget> 81 + </item> 82 + <item row="0" column="0" > 83 + <widget class="QLabel" name="label" > 84 + <property name="text" > 85 + <string>Número</string> 86 + </property> 87 + </widget> 88 + </item> 89 + <item row="0" column="1" colspan="3" > 90 + <widget class="QLineEdit" name="lineEdit" /> 91 + </item> 92 + <item row="0" column="5" colspan="4" > 93 + <widget class="QLineEdit" name="lineEdit_2" /> 94 + </item> 95 + <item rowspan="2" row="1" column="4" > 96 + <widget class="QCheckBox" name="checkBoxDel" > 97 + <property name="text" > 98 + <string>CheckBox</string> 99 + </property> 100 + </widget> 101 + </item> 102 + <item rowspan="2" row="1" column="8" > 103 + <widget class="QCheckBox" name="checkBoxAl" > 104 + <property name="text" > 105 + <string>CheckBox</string> 106 + </property> 107 + </widget> 108 + </item> 109 + <item row="3" column="0" colspan="5" > 110 + <spacer> 111 + <property name="orientation" > 112 + <enum>Qt::Horizontal</enum> 113 + </property> 114 + <property name="sizeHint" > 115 + <size> 116 + <width>40</width> 117 + <height>20</height> 118 + </size> 119 + </property> 120 + </spacer> 121 + </item> 122 + <item row="3" column="5" colspan="2" > 123 + <widget class="QPushButton" name="pushButton" > 124 + <property name="text" > 125 + <string>Buscar</string> 126 + </property> 127 + </widget> 128 + </item> 129 + <item row="3" column="7" colspan="2" > 130 + <widget class="QPushButton" name="pushButton_2" > 131 + <property name="text" > 132 + <string>Cancelar</string> 133 + </property> 134 + </widget> 135 + </item> 136 + 137 + <item row="0" column="4" > 138 + <widget class="QLabel" name="label_2" > 139 + <property name="text" > 140 + <string>Cliente</string> 141 + </property> 142 + </widget> 143 + </item> 144 + 145 + </layout> 146 + </widget> 147 + </widget> 148 + <layoutdefault spacing="6" margin="11" /> 149 + <resources/> 150 + <connections> 151 + <connection> 152 + <sender>pushButton_2</sender> 153 + <signal>clicked()</signal> 154 + <receiver>BuscarFacturaDialogClass</receiver> 155 + <slot>reject()</slot> 156 + <hints> 157 + <hint type="sourcelabel" > 158 + <x>503</x> 159 + <y>143</y> 160 + </hint> 161 + <hint type="destinationlabel" > 162 + <x>505</x> 163 + <y>157</y> 164 + </hint> 165 + </hints> 166 + </connection> 167 + <connection> 168 + <sender>pushButton</sender> 169 + <signal>clicked()</signal> 170 + <receiver>BuscarFacturaDialogClass</receiver> 171 + <slot>accept()</slot> 172 + <hints> 173 + <hint type="sourcelabel" > 174 + <x>426</x> 175 + <y>153</y> 176 + </hint> 177 + <hint type="destinationlabel" > 178 + <x>429</x> 179 + <y>156</y> 180 + </hint> 181 + </hints> 182 + </connection> 183 + <connection> 184 + <sender>checkBoxAl</sender> 185 + <signal>clicked(bool)</signal> 186 + <receiver>dateEdit_2</receiver> 187 + <slot>setEnabled(bool)</slot> 188 + <hints> 189 + <hint type="sourcelabel" > 190 + <x>542</x> 191 + <y>99</y> 192 + </hint> 193 + <hint type="destinationlabel" > 194 + <x>411</x> 195 + <y>94</y> 196 + </hint> 197 + </hints> 198 + </connection> 199 + <connection> 200 + <sender>checkBoxDel</sender> 201 + <signal>clicked(bool)</signal> 202 + <receiver>dateEdit</receiver> 203 + <slot>setEnabled(bool)</slot> 204 + <hints> 205 + <hint type="sourcelabel" > 206 + <x>262</x> 207 + <y>96</y> 208 + </hint> 209 + <hint type="destinationlabel" > 210 + <x>185</x> 211 + <y>100</y> 212 + </hint> 213 + </hints> 214 + </connection> 215 + </connections> 216 + </ui>
+53
Gui/BuscarPresupuestoDialog.cpp
··· 1 + #include "BuscarPresupuestoDialog.h" 2 + #include "../Datos/CriterioBusqueda.h" 3 + #include "../Negocio/CapaNegocio.h" 4 + #include "ListarPresupuestos.h" 5 + #include <iostream> 6 + using namespace std; 7 + 8 + BuscarPresupuestoDialog::BuscarPresupuestoDialog(CapaNegocio *cn, QWidget *parent) 9 + : QDialog(parent) 10 + { 11 + padre = (QWorkspace *)parent; 12 + ui.setupUi(this); 13 + capaNegocio = cn; 14 + setWindowTitle(tr("Buscar Presupuesto")); 15 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/BPresupuesto.PNG"))); 16 + ui.checkBoxAl->setText(""); 17 + ui.checkBoxDel->setText(""); 18 + ui.dateEdit->setEnabled(false); 19 + ui.dateEdit_2->setEnabled(false); 20 + 21 + QDate hoy = QDate::currentDate(); 22 + ui.dateEdit->setDate(hoy); 23 + ui.dateEdit_2->setDate(hoy); 24 + } 25 + 26 + BuscarPresupuestoDialog::~BuscarPresupuestoDialog() 27 + { 28 + 29 + } 30 + 31 + void BuscarPresupuestoDialog::accept() { 32 + CriterioBusqueda *cb = new CriterioBusqueda(); 33 + 34 + if (ui.lineEdit_2->text() != tr("")) 35 + cb->cliente = new QString(ui.lineEdit_2->text()); 36 + if (ui.lineEdit->text() != tr("")) { 37 + cb->numero = new int; 38 + *cb->numero = ui.lineEdit->text().toInt(); 39 + } 40 + if (ui.checkBoxAl->isChecked()) 41 + cb->fechaFin = new QDate(ui.dateEdit_2->date()); 42 + if (ui.checkBoxDel->isChecked()) 43 + cb->fechaInicio = new QDate(ui.dateEdit->date()); 44 + 45 + ListarPresupuestos *lf = new ListarPresupuestos(capaNegocio, padre , cb); 46 + padre->addWindow(lf); 47 + lf->show(); 48 + 49 + this->close(); 50 + } 51 + void BuscarPresupuestoDialog::resizeEvent(QResizeEvent *event) { 52 + setFixedSize(event->size()); 53 + }
+29
Gui/BuscarPresupuestoDialog.h
··· 1 + #ifndef BUSCARPRESUPUESTODIALOG_H 2 + #define BUSCARPRESUPUESTODIALOG_H 3 + 4 + #include <QtGui/QDialog> 5 + #include <QtGui> 6 + #include "../Negocio/CapaNegocio.h" 7 + #include "ui_BuscarPresupuestoDialog.h" 8 + 9 + class BuscarPresupuestoDialog : public QDialog 10 + { 11 + Q_OBJECT 12 + 13 + public: 14 + BuscarPresupuestoDialog(CapaNegocio *cn, QWidget *parent = 0); 15 + ~BuscarPresupuestoDialog(); 16 + 17 + private slots: 18 + void accept(); 19 + 20 + private: 21 + Ui::BuscarPresupuestoDialogClass ui; 22 + CapaNegocio *capaNegocio; 23 + QWorkspace *padre; 24 + 25 + protected: 26 + void resizeEvent(QResizeEvent *event); 27 + }; 28 + 29 + #endif // BUSCARPRESUPUESTODIALOG_H
+214
Gui/BuscarPresupuestoDialog.ui
··· 1 + <ui version="4.0" > 2 + <class>BuscarPresupuestoDialogClass</class> 3 + <widget class="QDialog" name="BuscarPresupuestoDialogClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>585</width> 9 + <height>115</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>BuscarFacturaDialog</string> 14 + </property> 15 + <property name="windowIcon" > 16 + <iconset>images/BPresupuesto.PNG</iconset> 17 + </property> 18 + <widget class="QWidget" name="gridLayout" > 19 + <property name="geometry" > 20 + <rect> 21 + <x>10</x> 22 + <y>10</y> 23 + <width>567</width> 24 + <height>95</height> 25 + </rect> 26 + </property> 27 + <layout class="QGridLayout" > 28 + <item rowspan="2" row="1" column="0" > 29 + <widget class="QLabel" name="label_3" > 30 + <property name="text" > 31 + <string>Fecha:</string> 32 + </property> 33 + </widget> 34 + </item> 35 + <item rowspan="2" row="1" column="1" > 36 + <widget class="QLabel" name="label_4" > 37 + <property name="text" > 38 + <string>Del</string> 39 + </property> 40 + <property name="alignment" > 41 + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 42 + </property> 43 + </widget> 44 + </item> 45 + <item rowspan="2" row="1" column="5" > 46 + <widget class="QLabel" name="label_6" > 47 + <property name="text" > 48 + <string>al</string> 49 + </property> 50 + <property name="alignment" > 51 + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> 52 + </property> 53 + </widget> 54 + </item> 55 + <item rowspan="2" row="1" column="2" colspan="2" > 56 + <widget class="QDateEdit" name="dateEdit" > 57 + <property name="displayFormat" > 58 + <string>dd/MM/yyyy</string> 59 + </property> 60 + <property name="calendarPopup" > 61 + <bool>true</bool> 62 + </property> 63 + <property name="date" > 64 + <date> 65 + <year>2007</year> 66 + <month>1</month> 67 + <day>2</day> 68 + </date> 69 + </property> 70 + </widget> 71 + </item> 72 + <item rowspan="2" row="1" column="6" colspan="2" > 73 + <widget class="QDateEdit" name="dateEdit_2" > 74 + <property name="displayFormat" > 75 + <string>dd/MM/yyyy</string> 76 + </property> 77 + <property name="calendarPopup" > 78 + <bool>true</bool> 79 + </property> 80 + </widget> 81 + </item> 82 + <item row="0" column="0" > 83 + <widget class="QLabel" name="label" > 84 + <property name="text" > 85 + <string>Número</string> 86 + </property> 87 + </widget> 88 + </item> 89 + <item row="0" column="1" colspan="3" > 90 + <widget class="QLineEdit" name="lineEdit" /> 91 + </item> 92 + <item row="3" column="0" colspan="5" > 93 + <spacer> 94 + <property name="orientation" > 95 + <enum>Qt::Horizontal</enum> 96 + </property> 97 + <property name="sizeHint" > 98 + <size> 99 + <width>40</width> 100 + <height>20</height> 101 + </size> 102 + </property> 103 + </spacer> 104 + </item> 105 + <item row="3" column="5" colspan="2" > 106 + <widget class="QPushButton" name="pushButton" > 107 + <property name="text" > 108 + <string>Buscar</string> 109 + </property> 110 + </widget> 111 + </item> 112 + <item row="3" column="7" colspan="2" > 113 + <widget class="QPushButton" name="pushButton_2" > 114 + <property name="text" > 115 + <string>Cancelar</string> 116 + </property> 117 + </widget> 118 + </item> 119 + <item rowspan="2" row="1" column="4" > 120 + <widget class="QCheckBox" name="checkBoxDel" > 121 + <property name="text" > 122 + <string>CheckBox</string> 123 + </property> 124 + </widget> 125 + </item> 126 + <item rowspan="2" row="1" column="8" > 127 + <widget class="QCheckBox" name="checkBoxAl" > 128 + <property name="text" > 129 + <string>CheckBox</string> 130 + </property> 131 + </widget> 132 + </item> 133 + <item row="0" column="4" > 134 + <widget class="QLabel" name="label_2" > 135 + <property name="text" > 136 + <string>Cliente</string> 137 + </property> 138 + </widget> 139 + </item> 140 + <item row="0" column="5" colspan="4" > 141 + <widget class="QLineEdit" name="lineEdit_2" /> 142 + </item> 143 + </layout> 144 + </widget> 145 + </widget> 146 + <layoutdefault spacing="6" margin="11" /> 147 + <resources/> 148 + <connections> 149 + <connection> 150 + <sender>pushButton_2</sender> 151 + <signal>clicked()</signal> 152 + <receiver>BuscarPresupuestoDialogClass</receiver> 153 + <slot>reject()</slot> 154 + <hints> 155 + <hint type="sourcelabel" > 156 + <x>503</x> 157 + <y>143</y> 158 + </hint> 159 + <hint type="destinationlabel" > 160 + <x>505</x> 161 + <y>157</y> 162 + </hint> 163 + </hints> 164 + </connection> 165 + <connection> 166 + <sender>pushButton</sender> 167 + <signal>clicked()</signal> 168 + <receiver>BuscarPresupuestoDialogClass</receiver> 169 + <slot>accept()</slot> 170 + <hints> 171 + <hint type="sourcelabel" > 172 + <x>426</x> 173 + <y>153</y> 174 + </hint> 175 + <hint type="destinationlabel" > 176 + <x>429</x> 177 + <y>156</y> 178 + </hint> 179 + </hints> 180 + </connection> 181 + <connection> 182 + <sender>checkBoxAl</sender> 183 + <signal>clicked(bool)</signal> 184 + <receiver>dateEdit_2</receiver> 185 + <slot>setEnabled(bool)</slot> 186 + <hints> 187 + <hint type="sourcelabel" > 188 + <x>542</x> 189 + <y>99</y> 190 + </hint> 191 + <hint type="destinationlabel" > 192 + <x>411</x> 193 + <y>94</y> 194 + </hint> 195 + </hints> 196 + </connection> 197 + <connection> 198 + <sender>checkBoxDel</sender> 199 + <signal>clicked(bool)</signal> 200 + <receiver>dateEdit</receiver> 201 + <slot>setEnabled(bool)</slot> 202 + <hints> 203 + <hint type="sourcelabel" > 204 + <x>262</x> 205 + <y>96</y> 206 + </hint> 207 + <hint type="destinationlabel" > 208 + <x>185</x> 209 + <y>100</y> 210 + </hint> 211 + </hints> 212 + </connection> 213 + </connections> 214 + </ui>
+26
Gui/CambiarIvaDialog.cpp
··· 1 + #include "CambiarIvaDialog.h" 2 + #include "../Negocio/CapaNegocio.h" 3 + #include <QtGui> 4 + 5 + CambiarIvaDialog::CambiarIvaDialog(CapaNegocio * const cn, QWidget *parent) 6 + : QDialog(parent) 7 + { 8 + ui.setupUi(this); 9 + setWindowTitle(tr("Cambiar IVA")); 10 + capaNegocio = cn; 11 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/Configuracion.PNG"))); 12 + connect(ui.pushButton, SIGNAL(clicked()), this , SLOT(cambiarValor())); 13 + ui.spinBox->setValue(capaNegocio->obtenerIva()); 14 + } 15 + 16 + CambiarIvaDialog::~CambiarIvaDialog() 17 + { 18 + 19 + } 20 + 21 + void CambiarIvaDialog::cambiarValor() { 22 + int nuevo_valor = ui.spinBox->value(); 23 + if (!capaNegocio->cambiarIva(nuevo_valor)) 24 + QMessageBox::critical(this, tr("Error"), 25 + tr("El IVA no ha podido ser cambiado.")); 26 + }
+24
Gui/CambiarIvaDialog.h
··· 1 + #ifndef CAMBIARIVADIALOG_H 2 + #define CAMBIARIVADIALOG_H 3 + 4 + #include <QtGui/QDialog> 5 + #include "ui_CambiarIvaDialog.h" 6 + #include "../Negocio/CapaNegocio.h" 7 + 8 + class CambiarIvaDialog : public QDialog 9 + { 10 + Q_OBJECT 11 + 12 + public: 13 + CambiarIvaDialog(CapaNegocio * const cn, QWidget *parent = 0); 14 + ~CambiarIvaDialog(); 15 + 16 + private slots: 17 + void cambiarValor(); 18 + 19 + private: 20 + Ui::CambiarIvaDialogClass ui; 21 + CapaNegocio *capaNegocio; 22 + }; 23 + 24 + #endif // CAMBIARIVADIALOG_H
+91
Gui/CambiarIvaDialog.ui
··· 1 + <ui version="4.0" > 2 + <class>CambiarIvaDialogClass</class> 3 + <widget class="QDialog" name="CambiarIvaDialogClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>261</width> 9 + <height>120</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>CambiarIvaDialog</string> 14 + </property> 15 + <property name="windowIcon" > 16 + <iconset>images/configuracion.PNG</iconset> 17 + </property> 18 + <widget class="QWidget" name="gridLayout" > 19 + <property name="geometry" > 20 + <rect> 21 + <x>10</x> 22 + <y>10</y> 23 + <width>241</width> 24 + <height>101</height> 25 + </rect> 26 + </property> 27 + <layout class="QGridLayout" > 28 + <item row="1" column="0" > 29 + <widget class="QPushButton" name="pushButton" > 30 + <property name="text" > 31 + <string>Aceptar</string> 32 + </property> 33 + </widget> 34 + </item> 35 + <item row="1" column="1" > 36 + <widget class="QPushButton" name="pushButton_2" > 37 + <property name="text" > 38 + <string>Cancelar</string> 39 + </property> 40 + </widget> 41 + </item> 42 + <item row="0" column="0" > 43 + <widget class="QLabel" name="label" > 44 + <property name="text" > 45 + <string>Nuevo IVA:</string> 46 + </property> 47 + </widget> 48 + </item> 49 + <item row="0" column="1" > 50 + <widget class="QSpinBox" name="spinBox" /> 51 + </item> 52 + </layout> 53 + </widget> 54 + </widget> 55 + <layoutdefault spacing="6" margin="11" /> 56 + <resources/> 57 + <connections> 58 + <connection> 59 + <sender>pushButton</sender> 60 + <signal>clicked()</signal> 61 + <receiver>CambiarIvaDialogClass</receiver> 62 + <slot>accept()</slot> 63 + <hints> 64 + <hint type="sourcelabel" > 65 + <x>55</x> 66 + <y>83</y> 67 + </hint> 68 + <hint type="destinationlabel" > 69 + <x>41</x> 70 + <y>56</y> 71 + </hint> 72 + </hints> 73 + </connection> 74 + <connection> 75 + <sender>pushButton_2</sender> 76 + <signal>clicked()</signal> 77 + <receiver>CambiarIvaDialogClass</receiver> 78 + <slot>reject()</slot> 79 + <hints> 80 + <hint type="sourcelabel" > 81 + <x>180</x> 82 + <y>81</y> 83 + </hint> 84 + <hint type="destinationlabel" > 85 + <x>152</x> 86 + <y>59</y> 87 + </hint> 88 + </hints> 89 + </connection> 90 + </connections> 91 + </ui>
+76
Gui/ConfigurarImpresora.cpp
··· 1 + #include "ConfigurarImpresora.h" 2 + #include <fstream> 3 + #include <iostream> 4 + #include <string> 5 + #include <QtGui> 6 + #include <cstdlib> 7 + 8 + using namespace std; 9 + 10 + ConfigurarImpresora::ConfigurarImpresora(QWidget *parent) 11 + : QWidget(parent) 12 + { 13 + ui.setupUi(this); 14 + 15 + connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(GuardarCambios())); 16 + 17 + listaOpciones << "LPT1"; 18 + listaOpciones << "LPT2"; 19 + listaOpciones << "LPT3"; 20 + listaOpciones << "COM1"; 21 + listaOpciones << "COM2"; 22 + listaOpciones << "COM3"; 23 + listaOpciones << "COM4"; 24 + listaOpciones << "USB001"; 25 + listaOpciones << "XPSPort"; 26 + 27 + ui.comboBox->addItems(listaOpciones); 28 + 29 + fstream fileConfig; 30 + fileConfig.open("Gui/printer.cfg", fstream::in); 31 + if (fileConfig.fail()) { 32 + QMessageBox::critical(this, "Error", "Error al abrir el archivo de configuraci�n de impresoras."); 33 + return ; 34 + } 35 + string name, value; 36 + while (!fileConfig.eof()) { 37 + fileConfig >> name >> value; 38 + if (name == "Manual") { 39 + if (value == "true") { 40 + ui.checkBox->setCheckState(Qt::Checked); 41 + } else if (value == "false") { 42 + ui.checkBox->setCheckState(Qt::Unchecked); 43 + } else { 44 + ui.checkBox->setCheckState(Qt::Unchecked); 45 + } 46 + } else if (name == "Puerto") { 47 + int index = listaOpciones.indexOf(QString(value.c_str())); 48 + ui.comboBox->setCurrentIndex(index); 49 + } else if (name == "Largo") { 50 + ui.spinBox->setValue(atoi(value.c_str())); 51 + } else if (name == "Ancho") { 52 + ui.spinBox_2->setValue(atoi(value.c_str())); 53 + } 54 + } 55 + fileConfig.close(); 56 + } 57 + 58 + ConfigurarImpresora::~ConfigurarImpresora() 59 + { 60 + 61 + } 62 + /* Guarda los cambios de configuracion. */ 63 + void ConfigurarImpresora::GuardarCambios () { 64 + fstream fileConfig; 65 + fileConfig.open("Gui/printer.cfg", fstream::out); 66 + if (ui.checkBox->isChecked()) { 67 + fileConfig << "Manual\ttrue" << endl; 68 + } else { 69 + fileConfig << "Manual\tfalse" << endl; 70 + } 71 + fileConfig << "Puerto\t" << ui.comboBox->currentText().toStdString() << endl; 72 + fileConfig << "Largo\t" << ui.spinBox->value() << endl; 73 + fileConfig << "Ancho\t" << ui.spinBox_2->value() << endl; 74 + fileConfig.close(); 75 + this->close(); 76 + }
+23
Gui/ConfigurarImpresora.h
··· 1 + #ifndef CONFIGURARIMPRESORA_H 2 + #define CONFIGURARIMPRESORA_H 3 + 4 + #include <QtGui/QWidget> 5 + #include "ui_ConfigurarImpresora.h" 6 + 7 + class ConfigurarImpresora : public QWidget 8 + { 9 + Q_OBJECT 10 + 11 + public: 12 + ConfigurarImpresora(QWidget *parent = 0); 13 + ~ConfigurarImpresora(); 14 + 15 + private slots: 16 + void GuardarCambios(); 17 + 18 + private: 19 + Ui::ConfigurarImpresoraClass ui; 20 + QStringList listaOpciones; 21 + }; 22 + 23 + #endif // CONFIGURARIMPRESORA_H
+220
Gui/ConfigurarImpresora.ui
··· 1 + <ui version="4.0" > 2 + <class>ConfigurarImpresoraClass</class> 3 + <widget class="QWidget" name="ConfigurarImpresoraClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>349</width> 9 + <height>220</height> 10 + </rect> 11 + </property> 12 + <property name="sizePolicy" > 13 + <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > 14 + <horstretch>0</horstretch> 15 + <verstretch>0</verstretch> 16 + </sizepolicy> 17 + </property> 18 + <property name="minimumSize" > 19 + <size> 20 + <width>349</width> 21 + <height>220</height> 22 + </size> 23 + </property> 24 + <property name="maximumSize" > 25 + <size> 26 + <width>349</width> 27 + <height>220</height> 28 + </size> 29 + </property> 30 + <property name="windowTitle" > 31 + <string>Configurar Impresora</string> 32 + </property> 33 + <widget class="QWidget" name="gridLayout" > 34 + <property name="geometry" > 35 + <rect> 36 + <x>10</x> 37 + <y>10</y> 38 + <width>331</width> 39 + <height>201</height> 40 + </rect> 41 + </property> 42 + <layout class="QGridLayout" > 43 + <item row="1" column="0" > 44 + <widget class="QLabel" name="label" > 45 + <property name="text" > 46 + <string>Puerto de la impresora</string> 47 + </property> 48 + </widget> 49 + </item> 50 + <item row="1" column="1" > 51 + <widget class="QComboBox" name="comboBox" /> 52 + </item> 53 + <item row="0" column="0" > 54 + <widget class="QCheckBox" name="checkBox" > 55 + <property name="text" > 56 + <string>Habilitar configuración manual</string> 57 + </property> 58 + <property name="checked" > 59 + <bool>true</bool> 60 + </property> 61 + <property name="tristate" > 62 + <bool>false</bool> 63 + </property> 64 + </widget> 65 + </item> 66 + <item row="4" column="1" > 67 + <widget class="QDialogButtonBox" name="buttonBox" > 68 + <property name="standardButtons" > 69 + <set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> 70 + </property> 71 + </widget> 72 + </item> 73 + <item row="2" column="1" > 74 + <widget class="QSpinBox" name="spinBox" > 75 + <property name="maximum" > 76 + <number>999</number> 77 + </property> 78 + </widget> 79 + </item> 80 + <item row="2" column="0" > 81 + <widget class="QLabel" name="label_2" > 82 + <property name="text" > 83 + <string>Largo</string> 84 + </property> 85 + </widget> 86 + </item> 87 + <item row="3" column="0" > 88 + <widget class="QLabel" name="label_3" > 89 + <property name="text" > 90 + <string>Ancho</string> 91 + </property> 92 + </widget> 93 + </item> 94 + <item row="3" column="1" > 95 + <widget class="QSpinBox" name="spinBox_2" > 96 + <property name="maximum" > 97 + <number>999</number> 98 + </property> 99 + </widget> 100 + </item> 101 + </layout> 102 + </widget> 103 + </widget> 104 + <layoutdefault spacing="6" margin="11" /> 105 + <resources/> 106 + <connections> 107 + <connection> 108 + <sender>checkBox</sender> 109 + <signal>toggled(bool)</signal> 110 + <receiver>comboBox</receiver> 111 + <slot>setEnabled(bool)</slot> 112 + <hints> 113 + <hint type="sourcelabel" > 114 + <x>72</x> 115 + <y>31</y> 116 + </hint> 117 + <hint type="destinationlabel" > 118 + <x>214</x> 119 + <y>62</y> 120 + </hint> 121 + </hints> 122 + </connection> 123 + <connection> 124 + <sender>checkBox</sender> 125 + <signal>toggled(bool)</signal> 126 + <receiver>label</receiver> 127 + <slot>setEnabled(bool)</slot> 128 + <hints> 129 + <hint type="sourcelabel" > 130 + <x>102</x> 131 + <y>37</y> 132 + </hint> 133 + <hint type="destinationlabel" > 134 + <x>77</x> 135 + <y>72</y> 136 + </hint> 137 + </hints> 138 + </connection> 139 + <connection> 140 + <sender>checkBox</sender> 141 + <signal>toggled(bool)</signal> 142 + <receiver>spinBox</receiver> 143 + <slot>setEnabled(bool)</slot> 144 + <hints> 145 + <hint type="sourcelabel" > 146 + <x>98</x> 147 + <y>27</y> 148 + </hint> 149 + <hint type="destinationlabel" > 150 + <x>197</x> 151 + <y>110</y> 152 + </hint> 153 + </hints> 154 + </connection> 155 + <connection> 156 + <sender>checkBox</sender> 157 + <signal>toggled(bool)</signal> 158 + <receiver>label_2</receiver> 159 + <slot>setEnabled(bool)</slot> 160 + <hints> 161 + <hint type="sourcelabel" > 162 + <x>50</x> 163 + <y>29</y> 164 + </hint> 165 + <hint type="destinationlabel" > 166 + <x>35</x> 167 + <y>113</y> 168 + </hint> 169 + </hints> 170 + </connection> 171 + <connection> 172 + <sender>checkBox</sender> 173 + <signal>toggled(bool)</signal> 174 + <receiver>label_3</receiver> 175 + <slot>setEnabled(bool)</slot> 176 + <hints> 177 + <hint type="sourcelabel" > 178 + <x>177</x> 179 + <y>41</y> 180 + </hint> 181 + <hint type="destinationlabel" > 182 + <x>177</x> 183 + <y>149</y> 184 + </hint> 185 + </hints> 186 + </connection> 187 + <connection> 188 + <sender>checkBox</sender> 189 + <signal>toggled(bool)</signal> 190 + <receiver>spinBox_2</receiver> 191 + <slot>setEnabled(bool)</slot> 192 + <hints> 193 + <hint type="sourcelabel" > 194 + <x>136</x> 195 + <y>34</y> 196 + </hint> 197 + <hint type="destinationlabel" > 198 + <x>222</x> 199 + <y>144</y> 200 + </hint> 201 + </hints> 202 + </connection> 203 + <connection> 204 + <sender>buttonBox</sender> 205 + <signal>rejected()</signal> 206 + <receiver>ConfigurarImpresoraClass</receiver> 207 + <slot>close()</slot> 208 + <hints> 209 + <hint type="sourcelabel" > 210 + <x>271</x> 211 + <y>188</y> 212 + </hint> 213 + <hint type="destinationlabel" > 214 + <x>318</x> 215 + <y>142</y> 216 + </hint> 217 + </hints> 218 + </connection> 219 + </connections> 220 + </ui>
+180
Gui/ListarArticulos.cpp
··· 1 + #include "ListarArticulos.h" 2 + #include "NuevoArticuloDialog.h" 3 + #include <QtGui> 4 + #include <QString> 5 + #include <list> 6 + #include "../Negocio/Articulo.h" 7 + #include "../Negocio/CapaNegocio.h" 8 + #include <iostream> 9 + using namespace std; 10 + 11 + ListarArticulos::ListarArticulos(CapaNegocio * const cn, QWidget *parent, CriterioBusqueda *cb) 12 + : QWidget(parent) 13 + { 14 + ui.setupUi(this); 15 + setWindowTitle(tr("Listado de Articulos")); 16 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/LArticulo.PNG"))); 17 + ui.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); 18 + ui.tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); 19 + ui.pushButton_3->setText(tr("Mostrar")); 20 + 21 + connect(ui.pushButton_3, SIGNAL(clicked()), this, SLOT(mostrar())); 22 + connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(borrar())); 23 + connect(ui.tableWidget, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(mostrar())); 24 + 25 + padre = (QWorkspace *) parent; 26 + 27 + capaNegocio = cn; 28 + list<Articulo> lista_aux = capaNegocio->getArticulos(); 29 + this->cb = cb; 30 + 31 + if (cb != 0) { 32 + if (cb->codigoArticulo) { 33 + list<Articulo>::iterator it; 34 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 35 + if (it->getcodigo() != *cb->codigoArticulo) { 36 + it = lista_aux.erase(it); 37 + }else { 38 + it++; 39 + } 40 + } 41 + } 42 + if (cb->descripcionArticulo) { 43 + QRegExp rx((tr("*") + *cb->descripcionArticulo) + "*"); 44 + rx.setCaseSensitivity(Qt::CaseInsensitive); 45 + rx.setPatternSyntax(QRegExp::Wildcard); 46 + list<Articulo>::iterator it; 47 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 48 + QString nombre(it->getdescripcion().c_str()); 49 + if (!rx.exactMatch(nombre)) { 50 + it = lista_aux.erase(it); 51 + } else { 52 + it++; 53 + } 54 + } 55 + } 56 + } 57 + lista = lista_aux; 58 + int n_elem = lista.size(); 59 + cout << "[Debug]Numero de articulos: " << n_elem << endl; 60 + list<Articulo>::iterator i; 61 + i = lista.begin(); 62 + for (int row = 0; row < n_elem; row++) { 63 + addRow(); 64 + ui.tableWidget->item(row, 0)->setText(QString::number(i->getcodigo())); 65 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(i->getdescripcion())); 66 + ui.tableWidget->item(row, 2)->setText(QString::number(i->getpvp())); 67 + i++; 68 + } 69 + 70 + 71 + } 72 + 73 + ListarArticulos::~ListarArticulos() 74 + { 75 + 76 + } 77 + void ListarArticulos::resizeEvent(QResizeEvent *event) { 78 + ui.gridLayout->setGeometry(QRect(0, 0, event->size().width(), event->size().height())); 79 + } 80 + 81 + void ListarArticulos::addRow(){ 82 + int row = ui.tableWidget->rowCount(); 83 + ui.tableWidget->insertRow(row); 84 + 85 + QTableWidgetItem *item0 = new QTableWidgetItem; 86 + item0->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 87 + ui.tableWidget->setItem(row, 0, item0); 88 + 89 + QTableWidgetItem *item1 = new QTableWidgetItem; 90 + item1->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 91 + ui.tableWidget->setItem(row, 1, item1); 92 + 93 + QTableWidgetItem *item2 = new QTableWidgetItem; 94 + item2->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 95 + ui.tableWidget->setItem(row, 2, item2); 96 + 97 + } 98 + void ListarArticulos::mostrar() { 99 + int row = ui.tableWidget->currentRow(); 100 + int cod; 101 + 102 + if (row == -1) { 103 + QString mes = tr("No se selecciono ninguna fila."); 104 + QMessageBox::information(this, tr("Atencion"),mes); 105 + 106 + } else { 107 + cod = ui.tableWidget->item(row, 0)->text().toInt(); 108 + QString mes = tr("Ahora se editara el articulo de la fila: %1.").arg(row); 109 + //QMessageBox::information(this, tr("Atencion"), mes); 110 + QDialog *edit = new NuevoArticuloDialog(capaNegocio,this,capaNegocio->getArticuloCodigo(cod)); 111 + padre->addWindow(edit); 112 + edit->show(); 113 + } 114 + } 115 + 116 + void ListarArticulos::actualizar() { 117 + list<Articulo> lista_aux = capaNegocio->getArticulos(); 118 + if (cb != 0) { 119 + if (cb->codigoArticulo) { 120 + list<Articulo>::iterator it; 121 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 122 + if (it->getcodigo() != *cb->codigoArticulo) { 123 + it = lista_aux.erase(it); 124 + }else { 125 + it++; 126 + } 127 + } 128 + } 129 + if (cb->descripcionArticulo) { 130 + QRegExp rx((tr("*") + *cb->descripcionArticulo) + "*"); 131 + rx.setCaseSensitivity(Qt::CaseInsensitive); 132 + rx.setPatternSyntax(QRegExp::Wildcard); 133 + list<Articulo>::iterator it; 134 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 135 + QString nombre(it->getdescripcion().c_str()); 136 + if (!rx.exactMatch(nombre)) { 137 + it = lista_aux.erase(it); 138 + } else { 139 + it++; 140 + } 141 + } 142 + } 143 + } 144 + lista = lista_aux; 145 + int n_elem = lista.size(); 146 + int n_row = ui.tableWidget->rowCount(); 147 + cout << "[Debug]Numero de articulos: " << n_elem << endl; 148 + list<Articulo>::iterator i; 149 + i = lista.begin(); 150 + for (int row = 0; row < n_row; row++) { 151 + ui.tableWidget->item(row, 0)->setText(QString::number(i->getcodigo())); 152 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(i->getdescripcion())); 153 + ui.tableWidget->item(row, 2)->setText(QString::number(i->getpvp())); 154 + i++; 155 + } 156 + for (int row = n_row; row < n_elem; row++) { 157 + addRow(); 158 + ui.tableWidget->item(row, 0)->setText(QString::number(i->getcodigo())); 159 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(i->getdescripcion())); 160 + ui.tableWidget->item(row, 2)->setText(QString::number(i->getpvp())); 161 + i++; 162 + } 163 + } 164 + void ListarArticulos::borrar() { 165 + int row = ui.tableWidget->currentRow(); 166 + int cod = ui.tableWidget->item(row, 0)->text().toInt(); 167 + if (QMessageBox::question(this, tr("Borrar Articulo"), tr("Seguro que desea borrar el articulo de codigo %1?").arg(cod),tr("No"),tr("Si")) == 1) { 168 + QString mes = tr("Ahora se borrara el articulo de la fila: %1.").arg(row); 169 + //QMessageBox::information(this, tr("Atencion"), mes); 170 + if (capaNegocio->borrarArticulo(capaNegocio->getArticuloCodigo(cod))) { 171 + //QMessageBox::information(this, tr("Atencion"), tr("Borrado correcto.")); 172 + ui.tableWidget->removeRow(row); 173 + } else { 174 + QMessageBox::warning(this, tr("Atencion"), tr("Error al borrar.")); 175 + } 176 + } else { 177 + //QString mes = tr("No se borrara el articulo de la fila: %1.").arg(row); 178 + //QMessageBox::information(this, tr("Atencion"), mes); 179 + } 180 + }
+35
Gui/ListarArticulos.h
··· 1 + #ifndef LISTARARTICULOS_H 2 + #define LISTARARTICULOS_H 3 + 4 + #include <QtGui> 5 + #include "../Negocio/CapaNegocio.h" 6 + #include <list> 7 + #include "ui_ListarArticulos.h" 8 + #include "../Datos/CriterioBusqueda.h" 9 + 10 + class ListarArticulos : public QWidget 11 + { 12 + Q_OBJECT 13 + 14 + public: 15 + ListarArticulos(CapaNegocio * const cn, QWidget *parent = 0, CriterioBusqueda* cb =0); 16 + ~ListarArticulos(); 17 + void addRow(); 18 + void actualizar(); 19 + 20 + private slots: 21 + void mostrar(); 22 + void borrar(); 23 + 24 + private: 25 + Ui::ListarArticulosClass ui; 26 + CapaNegocio *capaNegocio; 27 + QWorkspace *padre; 28 + list<Articulo> lista; 29 + CriterioBusqueda *cb; 30 + 31 + protected: 32 + void resizeEvent(QResizeEvent *event); 33 + }; 34 + 35 + #endif // LISTARARTICULOS_H
+95
Gui/ListarArticulos.ui
··· 1 + <ui version="4.0" > 2 + <class>ListarArticulosClass</class> 3 + <widget class="QWidget" name="ListarArticulosClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>400</width> 9 + <height>300</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>ListarArticulos</string> 14 + </property> 15 + <property name="windowIcon" > 16 + <iconset>images/LArticulo.PNG</iconset> 17 + </property> 18 + <widget class="QWidget" name="gridLayout" > 19 + <property name="geometry" > 20 + <rect> 21 + <x>10</x> 22 + <y>10</y> 23 + <width>381</width> 24 + <height>281</height> 25 + </rect> 26 + </property> 27 + <layout class="QGridLayout" > 28 + <item rowspan="2" row="0" column="0" > 29 + <widget class="QTableWidget" name="tableWidget" > 30 + <column> 31 + <property name="text" > 32 + <string>Codigo</string> 33 + </property> 34 + </column> 35 + <column> 36 + <property name="text" > 37 + <string>Descripcion</string> 38 + </property> 39 + </column> 40 + <column> 41 + <property name="text" > 42 + <string>Precio</string> 43 + </property> 44 + </column> 45 + </widget> 46 + </item> 47 + <item row="2" column="0" > 48 + <layout class="QHBoxLayout" > 49 + <item> 50 + <widget class="QPushButton" name="pushButton_3" > 51 + <property name="text" > 52 + <string>Mostrar</string> 53 + </property> 54 + </widget> 55 + </item> 56 + <item> 57 + <widget class="QPushButton" name="pushButton" > 58 + <property name="text" > 59 + <string>Borrar</string> 60 + </property> 61 + </widget> 62 + </item> 63 + <item> 64 + <widget class="QPushButton" name="pushButton_2" > 65 + <property name="text" > 66 + <string>Cancelar</string> 67 + </property> 68 + </widget> 69 + </item> 70 + </layout> 71 + </item> 72 + </layout> 73 + </widget> 74 + </widget> 75 + <layoutdefault spacing="6" margin="11" /> 76 + <resources/> 77 + <connections> 78 + <connection> 79 + <sender>pushButton_2</sender> 80 + <signal>clicked()</signal> 81 + <receiver>ListarArticulosClass</receiver> 82 + <slot>close()</slot> 83 + <hints> 84 + <hint type="sourcelabel" > 85 + <x>330</x> 86 + <y>275</y> 87 + </hint> 88 + <hint type="destinationlabel" > 89 + <x>344</x> 90 + <y>295</y> 91 + </hint> 92 + </hints> 93 + </connection> 94 + </connections> 95 + </ui>
+261
Gui/ListarClientes.cpp
··· 1 + #include "ListarClientes.h" 2 + #include <list> 3 + #include "../Negocio/Cliente.h" 4 + #include "../Negocio/CapaNegocio.h" 5 + #include "NuevoClienteDialog.h" 6 + #include <QtGui> 7 + #include <QString> 8 + #include <iostream> 9 + #include <QMutex> 10 + using namespace std; 11 + 12 + ListarClientes::ListarClientes(CapaNegocio * const cn, QWidget *parent, CriterioBusqueda* cb) 13 + : QWidget(parent) 14 + { 15 + ui.setupUi(this); 16 + setWindowTitle(tr("Listado de Clientes")); 17 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/LCliente.PNG"))); 18 + ui.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); 19 + ui.tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); 20 + 21 + ui.pushButton_3->setText(tr("Mostrar")); 22 + ui.pushButton_2->setText(tr("Borrar")); 23 + ui.pushButton->setText(tr("Cancelar")); 24 + 25 + connect(ui.pushButton_3, SIGNAL(clicked()), this, SLOT(mostrar())); 26 + connect(ui.pushButton_2, SIGNAL(clicked()), this, SLOT(borrar())); 27 + connect(ui.tableWidget, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(mostrar())); 28 + 29 + padre = (QWorkspace *) parent; 30 + 31 + capaNegocio = cn; 32 + 33 + list<Cliente> lista_aux = capaNegocio->getClientes(); 34 + this->cb = cb; 35 + 36 + if (cb != 0) { 37 + if (cb->telefono) { 38 + list<pair<int, int> > l = capaNegocio->getListaTelefonos(); 39 + cout << "Numero de telefonos: " << l.size() << endl; 40 + list<Cliente> lc; 41 + list<pair<int, int> >::iterator it; 42 + for (it = l.begin(); it != l.end();) { 43 + if (it->first != *cb->telefono) { 44 + it = l.erase(it); 45 + } else { 46 + it++; 47 + } 48 + } 49 + for (it = l.begin(); it != l.end();it++) { 50 + Cliente *c = capaNegocio->getClienteId(it->second); 51 + lc.push_back(*c); 52 + } 53 + lista_aux = lc; 54 + } 55 + if (cb->nombreCliente) { 56 + QRegExp rx((tr("*") + *(cb->nombreCliente)) + "*"); 57 + rx.setPatternSyntax(QRegExp::Wildcard); 58 + rx.setCaseSensitivity(Qt::CaseInsensitive); 59 + list<Cliente>::iterator it; 60 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 61 + QString nombre(((it->getnombre() + " ") + it->getapellidos()).c_str()); 62 + if (!rx.exactMatch(nombre)) { 63 + it = lista_aux.erase(it); 64 + } else { 65 + it++; 66 + } 67 + } 68 + } 69 + if (cb->codigoCliente){ 70 + list<Cliente>::iterator it; 71 + for (it = lista_aux.begin(); it != lista_aux.end();) { 72 + if (it->getcodigo() != *cb->codigoCliente) { 73 + it = lista_aux.erase(it); 74 + } else { 75 + it++; 76 + } 77 + } 78 + } 79 + if (cb->direccionCliente) { 80 + QRegExp rx((tr("*") + *cb->direccionCliente) + "*"); 81 + rx.setPatternSyntax(QRegExp::Wildcard); 82 + rx.setCaseSensitivity(Qt::CaseInsensitive); 83 + list<Cliente>::iterator it; 84 + for (it = lista_aux.begin(); it != lista_aux.end();) { 85 + QString nombre(it->getdireccion().c_str()); 86 + if (!rx.exactMatch(nombre)) { 87 + it = lista_aux.erase(it); 88 + } else { 89 + it++; 90 + } 91 + } 92 + } 93 + } 94 + 95 + lista = lista_aux; 96 + 97 + int n_elem = lista.size(); 98 + cout << "[Debug]Numero de clientes: " << n_elem << endl; 99 + list<Cliente>::iterator i; 100 + i = lista.begin(); 101 + for (int row = 0; row < n_elem; row++) { 102 + addRow(); 103 + ui.tableWidget->item(row, 0)->setText(QString::number(i->getcodigo())); 104 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(i->getnombre())); 105 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString(i->getapellidos())); 106 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString(i->getnif())); 107 + i++; 108 + } 109 + } 110 + 111 + ListarClientes::~ListarClientes() 112 + { 113 + 114 + } 115 + 116 + void ListarClientes::addRow(){ 117 + int row = ui.tableWidget->rowCount(); 118 + ui.tableWidget->insertRow(row); 119 + 120 + QTableWidgetItem *item0 = new QTableWidgetItem; 121 + item0->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 122 + ui.tableWidget->setItem(row, 0, item0); 123 + 124 + QTableWidgetItem *item1 = new QTableWidgetItem; 125 + item1->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 126 + ui.tableWidget->setItem(row, 1, item1); 127 + 128 + QTableWidgetItem *item2 = new QTableWidgetItem; 129 + item2->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 130 + ui.tableWidget->setItem(row, 2, item2); 131 + 132 + QTableWidgetItem *item3 = new QTableWidgetItem; 133 + item3->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 134 + ui.tableWidget->setItem(row, 3, item3); 135 + 136 + } 137 + 138 + void ListarClientes::resizeEvent(QResizeEvent *event) { 139 + ui.gridLayout->setGeometry(QRect(0, 0, event->size().width(), event->size().height())); 140 + } 141 + void ListarClientes::mostrar() { 142 + int row = ui.tableWidget->currentRow(); 143 + int cod; 144 + 145 + if (row == -1) { 146 + QString mes = tr("No se selecciono ninguna fila."); 147 + QMessageBox::information(this, tr("Atencion"),mes); 148 + 149 + } else { 150 + cod = ui.tableWidget->item(row, 0)->text().toInt(); 151 + QString mes = tr("Ahora se editara el cliente de la fila: %1.").arg(row); 152 + //QMessageBox::information(this, tr("Atencion"), mes); 153 + QDialog *edit = new NuevoClienteDialog(capaNegocio, this, capaNegocio->getClienteCodigo(cod)); 154 + padre->addWindow(edit); 155 + edit->show(); 156 + } 157 + } 158 + void ListarClientes::actualizar() { 159 + 160 + list<Cliente> lista_aux = capaNegocio->getClientes(); 161 + if (cb != 0) { 162 + if (cb->telefono) { 163 + list<pair<int, int> > l = capaNegocio->getListaTelefonos(); 164 + cout << "Numero de telefonos: " << l.size() << endl; 165 + list<Cliente> lc; 166 + list<pair<int, int> >::iterator it; 167 + for (it = l.begin(); it != l.end();) { 168 + if (it->first != *cb->telefono) { 169 + it = l.erase(it); 170 + } else { 171 + it++; 172 + } 173 + } 174 + for (it = l.begin(); it != l.end();it++) { 175 + Cliente *c = capaNegocio->getClienteId(it->second); 176 + lc.push_back(*c); 177 + } 178 + lista_aux = lc; 179 + } 180 + if (cb->nombreCliente) { 181 + QRegExp rx((tr("*") + *(cb->nombreCliente)) + "*"); 182 + rx.setPatternSyntax(QRegExp::Wildcard); 183 + rx.setCaseSensitivity(Qt::CaseInsensitive); 184 + list<Cliente>::iterator it; 185 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 186 + QString nombre(((it->getnombre() + " ") + it->getapellidos()).c_str()); 187 + if (!rx.exactMatch(nombre)) { 188 + it = lista_aux.erase(it); 189 + } else { 190 + it++; 191 + } 192 + } 193 + } 194 + if (cb->codigoCliente){ 195 + list<Cliente>::iterator it; 196 + for (it = lista_aux.begin(); it != lista_aux.end();) { 197 + if (it->getcodigo() != *cb->codigoCliente) { 198 + it = lista_aux.erase(it); 199 + } else { 200 + it++; 201 + } 202 + } 203 + } 204 + if (cb->direccionCliente) { 205 + QRegExp rx((tr("*") + *cb->direccionCliente) + "*"); 206 + rx.setPatternSyntax(QRegExp::Wildcard); 207 + rx.setCaseSensitivity(Qt::CaseInsensitive); 208 + list<Cliente>::iterator it; 209 + for (it = lista_aux.begin(); it != lista_aux.end();) { 210 + QString nombre(it->getdireccion().c_str()); 211 + if (!rx.exactMatch(nombre)) { 212 + it = lista_aux.erase(it); 213 + } else { 214 + it++; 215 + } 216 + } 217 + } 218 + } 219 + lista = lista_aux; 220 + 221 + int n_elem = lista.size(); 222 + int n_row = ui.tableWidget->rowCount(); 223 + cout << "[Debug]Numero de clientes: " << n_elem << endl; 224 + list<Cliente>::iterator i; 225 + i = lista.begin(); 226 + for (int row = 0; row < n_row; row++) { 227 + ui.tableWidget->item(row, 0)->setText(QString::number(i->getcodigo())); 228 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(i->getnombre())); 229 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString(i->getapellidos())); 230 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString(i->getnif())); 231 + i++; 232 + } 233 + for (int row = n_row; row < n_elem; row++) { 234 + addRow(); 235 + ui.tableWidget->item(row, 0)->setText(QString::number(i->getcodigo())); 236 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(i->getnombre())); 237 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString(i->getapellidos())); 238 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString(i->getnif())); 239 + i++; 240 + } 241 + 242 + 243 + } 244 + void ListarClientes::borrar() { 245 + int row = ui.tableWidget->currentRow(); 246 + int cod = ui.tableWidget->item(row, 0)->text().toInt(); 247 + if (QMessageBox::question(this, tr("Borrar Cliente"), tr("Seguro que desea borrar el cliente de codigo %1?").arg(cod),tr("No"),tr("Si")) == 1) { 248 + QString mes = tr("Ahora se borrara el articulo de la fila: %1.").arg(row); 249 + //QMessageBox::information(this, tr("Atencion"), mes); 250 + if (capaNegocio->borrarCliente(capaNegocio->getClienteCodigo(cod))) { 251 + //QMessageBox::information(this, tr("Atencion"), tr("Borrado correcto.")); 252 + ui.tableWidget->removeRow(row); 253 + } else { 254 + QMessageBox::warning(this, tr("Atencion"), tr("Error al borrar.")); 255 + } 256 + } else { 257 + //QString mes = tr("No se borrara el cliente de la fila: %1.").arg(row); 258 + //QMessageBox::information(this, tr("Atencion"), mes); 259 + } 260 + } 261 +
+35
Gui/ListarClientes.h
··· 1 + #ifndef LISTARCLIENTES_H 2 + #define LISTARCLIENTES_H 3 + 4 + #include <QtGui> 5 + #include "ui_ListarClientes.h" 6 + #include <list> 7 + #include "../Negocio/CapaNegocio.h" 8 + #include "../Datos/CriterioBusqueda.h" 9 + 10 + class ListarClientes : public QWidget 11 + { 12 + Q_OBJECT 13 + 14 + public: 15 + ListarClientes(CapaNegocio * const cn, QWidget *parent = 0, CriterioBusqueda* cb = 0); 16 + ~ListarClientes(); 17 + void addRow(); 18 + void actualizar(); 19 + 20 + private slots: 21 + void mostrar(); 22 + void borrar(); 23 + 24 + private: 25 + Ui::ListarClientesClass ui; 26 + CapaNegocio *capaNegocio; 27 + QWorkspace *padre; 28 + list<Cliente> lista; 29 + CriterioBusqueda *cb; 30 + 31 + protected: 32 + void resizeEvent(QResizeEvent *event); 33 + }; 34 + 35 + #endif // LISTARCLIENTES_H
+106
Gui/ListarClientes.ui
··· 1 + <ui version="4.0" > 2 + <class>ListarClientesClass</class> 3 + <widget class="QWidget" name="ListarClientesClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>401</width> 9 + <height>302</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>ListarClientes</string> 14 + </property> 15 + <property name="windowIcon" > 16 + <iconset>images/LCliente.PNG</iconset> 17 + </property> 18 + <widget class="QWidget" name="gridLayout" > 19 + <property name="geometry" > 20 + <rect> 21 + <x>10</x> 22 + <y>10</y> 23 + <width>381</width> 24 + <height>281</height> 25 + </rect> 26 + </property> 27 + <layout class="QGridLayout" > 28 + <item row="0" column="0" colspan="4" > 29 + <widget class="QTableWidget" name="tableWidget" > 30 + <property name="alternatingRowColors" > 31 + <bool>true</bool> 32 + </property> 33 + <property name="sortingEnabled" > 34 + <bool>false</bool> 35 + </property> 36 + <column> 37 + <property name="text" > 38 + <string>Código</string> 39 + </property> 40 + </column> 41 + <column> 42 + <property name="text" > 43 + <string>Nombre</string> 44 + </property> 45 + </column> 46 + <column> 47 + <property name="text" > 48 + <string>Apellidos</string> 49 + </property> 50 + </column> 51 + <column> 52 + <property name="text" > 53 + <string>NIF</string> 54 + </property> 55 + </column> 56 + </widget> 57 + </item> 58 + <item rowspan="2" row="1" column="0" colspan="4" > 59 + <layout class="QHBoxLayout" > 60 + <item> 61 + <widget class="QPushButton" name="pushButton_3" > 62 + <property name="text" > 63 + <string/> 64 + </property> 65 + </widget> 66 + </item> 67 + <item> 68 + <widget class="QPushButton" name="pushButton_2" > 69 + <property name="text" > 70 + <string>PushButton</string> 71 + </property> 72 + </widget> 73 + </item> 74 + <item> 75 + <widget class="QPushButton" name="pushButton" > 76 + <property name="text" > 77 + <string>PushButton</string> 78 + </property> 79 + </widget> 80 + </item> 81 + </layout> 82 + </item> 83 + </layout> 84 + </widget> 85 + </widget> 86 + <layoutdefault spacing="6" margin="11" /> 87 + <resources/> 88 + <connections> 89 + <connection> 90 + <sender>pushButton</sender> 91 + <signal>clicked()</signal> 92 + <receiver>ListarClientesClass</receiver> 93 + <slot>close()</slot> 94 + <hints> 95 + <hint type="sourcelabel" > 96 + <x>335</x> 97 + <y>269</y> 98 + </hint> 99 + <hint type="destinationlabel" > 100 + <x>350</x> 101 + <y>294</y> 102 + </hint> 103 + </hints> 104 + </connection> 105 + </connections> 106 + </ui>
+316
Gui/ListarFacturas.cpp
··· 1 + #include "ListarFacturas.h" 2 + #include <list> 3 + #include <../Negocio/Factura.h> 4 + #include <../Negocio/Cliente.h> 5 + #include "../Negocio/CapaNegocio.h" 6 + #include "../Gui/NuevaFacturaDialog.h" 7 + #include <../Datos/utils.h> 8 + #include <QtGui> 9 + #include <QString> 10 + #include <iostream> 11 + 12 + using namespace std; 13 + 14 + ListarFacturas::ListarFacturas(CapaNegocio * const cn, QWidget *parent, CriterioBusqueda* cb) 15 + : QWidget(parent) 16 + { 17 + ui.setupUi(this); 18 + ui.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); 19 + ui.tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); 20 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/LFactura.PNG"))); 21 + ui.editarButton->setText(tr("Mostrar")); 22 + setWindowTitle(tr("Listado de Facturas")); 23 + 24 + connect(ui.tableWidget, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(mostrar())); 25 + connect(ui.borrarButton, SIGNAL(clicked()), this, SLOT(borrar())); 26 + 27 + padre = (QWorkspace *) parent; 28 + 29 + capaNegocio = cn; 30 + list<Factura> lista_aux = capaNegocio->getFacturas(); 31 + this->cb = cb; 32 + if (cb != 0) { 33 + if (cb->numero) { 34 + list<Factura>::iterator it; 35 + 36 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 37 + if (it->getn_factura() != *cb->numero) { 38 + it = lista_aux.erase(it); 39 + }else { 40 + it++; 41 + } 42 + } 43 + } 44 + if (cb->cliente) { 45 + QRegExp rx((tr("*") + *cb->cliente) + "*"); 46 + rx.setPatternSyntax(QRegExp::Wildcard); 47 + rx.setCaseSensitivity(Qt::CaseInsensitive); 48 + list<Factura>::iterator it; 49 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 50 + Cliente c = *it->getcliente(); 51 + QString nombre(((c.getnombre() + " ") + c.getapellidos()).c_str()); 52 + if (!rx.exactMatch(nombre)) { 53 + it = lista_aux.erase(it); 54 + } else { 55 + it++; 56 + } 57 + } 58 + } 59 + if (cb->fechaFin && cb->fechaInicio) { 60 + list<Factura>::iterator it; 61 + for (it = lista_aux.begin(); it != lista_aux.end();) { 62 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 63 + if (!(f <= *(cb->fechaFin) && f >= *(cb->fechaInicio))) { 64 + it = lista_aux.erase(it); 65 + } else { 66 + it++; 67 + } 68 + } 69 + } else if (cb->fechaFin) { 70 + 71 + list<Factura>::iterator it; 72 + for (it = lista_aux.begin(); it != lista_aux.end();) { 73 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 74 + if (!(f <= *(cb->fechaFin))) { 75 + it = lista_aux.erase(it); 76 + }else { 77 + it++; 78 + } 79 + } 80 + } else if (cb->fechaInicio) { 81 + list<Factura>::iterator it; 82 + for (it = lista_aux.begin(); it != lista_aux.end();) { 83 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 84 + cout << f.toString("dd/MM/yyyy").toStdString() << endl; 85 + if (!(f >= *(cb->fechaInicio))) { 86 + it = lista_aux.erase(it); 87 + } else { 88 + it++; 89 + } 90 + } 91 + } 92 + } 93 + 94 + lista = lista_aux; 95 + 96 + int n_elem = lista.size(); 97 + cout << "[Debug]Numero de facturas: " << n_elem << endl; 98 + list<Factura>::iterator i; 99 + i = lista.begin(); 100 + for (int row = 0; row < n_elem; row++) { 101 + addRow(); 102 + if ( i->getn_factura() < 100000) { 103 + ui.tableWidget->item(row, 0)->setText(tr("0%1").arg(i->getn_factura())); 104 + } else { 105 + ui.tableWidget->item(row, 0)->setText(QString::number(i->getn_factura())); 106 + } 107 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(i->getfecha())); 108 + if (i->getcliente()) { 109 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString(i->getcliente()->getnombre())); 110 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString(i->getcliente()->getapellidos())); 111 + } else { 112 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString("-")); 113 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString("-")); 114 + } 115 + ui.tableWidget->item(row, 4)->setText(QString::fromStdString(i->getaparato())); 116 + ui.tableWidget->item(row, 5)->setText(QString::fromStdString(i->getmarca())); 117 + i++; 118 + } 119 + /*Conectar SIGNALS y SLOTS*/ 120 + connect(ui.editarButton, SIGNAL(clicked()), this, SLOT(mostrar())); 121 + } 122 + 123 + ListarFacturas::~ListarFacturas() 124 + { 125 + 126 + } 127 + 128 + void ListarFacturas::addRow(){ 129 + int row = ui.tableWidget->rowCount(); 130 + ui.tableWidget->insertRow(row); 131 + 132 + QTableWidgetItem *item0 = new QTableWidgetItem; 133 + item0->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 134 + ui.tableWidget->setItem(row, 0, item0); 135 + 136 + QTableWidgetItem *item1 = new QTableWidgetItem; 137 + item1->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 138 + ui.tableWidget->setItem(row, 1, item1); 139 + 140 + QTableWidgetItem *item2 = new QTableWidgetItem; 141 + item2->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 142 + ui.tableWidget->setItem(row, 2, item2); 143 + 144 + QTableWidgetItem *item3 = new QTableWidgetItem; 145 + item3->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 146 + ui.tableWidget->setItem(row, 3, item3); 147 + 148 + QTableWidgetItem *item4 = new QTableWidgetItem; 149 + item4->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 150 + ui.tableWidget->setItem(row, 4, item4); 151 + 152 + QTableWidgetItem *item5 = new QTableWidgetItem; 153 + item5->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 154 + ui.tableWidget->setItem(row, 5, item5); 155 + } 156 + 157 + void ListarFacturas::resizeEvent(QResizeEvent *event) { 158 + ui.gridLayout->setGeometry(QRect(0, 0, event->size().width(), event->size().height())); 159 + } 160 + void ListarFacturas::mostrar() { 161 + int row = ui.tableWidget->currentRow(); 162 + int cod; 163 + if (row == -1) { 164 + QString mes = tr("No se selecciono ninguna fila."); 165 + QMessageBox::warning(this, tr("Atencion"),mes); 166 + 167 + } else { 168 + cod = ui.tableWidget->item(row, 0)->text().toInt(); 169 + QString mes = tr("Ahora se editara la factura de la fila: %1.").arg(row); 170 + //QMessageBox::information(this, tr("Atencion"), mes); 171 + NuevaFacturaDialog *nfd = new NuevaFacturaDialog(capaNegocio, this, capaNegocio->getFacturaNumero(cod)); 172 + padre->addWindow(nfd); 173 + nfd->show(); 174 + } 175 + } 176 + void ListarFacturas::actualizar() { 177 + list<Factura> lista_aux = capaNegocio->getFacturas(); 178 + if (cb != 0) { 179 + if (cb->numero) { 180 + list<Factura>::iterator it; 181 + 182 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 183 + if (it->getn_factura() != *cb->numero) { 184 + it = lista_aux.erase(it); 185 + }else { 186 + it++; 187 + } 188 + } 189 + } 190 + if (cb->cliente) { 191 + QRegExp rx((tr("*") + *cb->cliente) + "*"); 192 + rx.setPatternSyntax(QRegExp::Wildcard); 193 + rx.setCaseSensitivity(Qt::CaseInsensitive); 194 + list<Factura>::iterator it; 195 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 196 + Cliente c = *it->getcliente(); 197 + QString nombre(((c.getnombre() + " ") + c.getapellidos()).c_str()); 198 + if (!rx.exactMatch(nombre)) { 199 + it = lista_aux.erase(it); 200 + } else { 201 + it++; 202 + } 203 + } 204 + } 205 + if (cb->fechaFin && cb->fechaInicio) { 206 + list<Factura>::iterator it; 207 + for (it = lista_aux.begin(); it != lista_aux.end();) { 208 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 209 + if (!(f <= *(cb->fechaFin) && f >= *(cb->fechaInicio))) { 210 + it = lista_aux.erase(it); 211 + } else { 212 + it++; 213 + } 214 + } 215 + } else if (cb->fechaFin) { 216 + 217 + list<Factura>::iterator it; 218 + for (it = lista_aux.begin(); it != lista_aux.end();) { 219 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 220 + if (!(f <= *(cb->fechaFin))) { 221 + it = lista_aux.erase(it); 222 + }else { 223 + it++; 224 + } 225 + } 226 + } else if (cb->fechaInicio) { 227 + list<Factura>::iterator it; 228 + for (it = lista_aux.begin(); it != lista_aux.end();) { 229 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 230 + cout << f.toString("dd/MM/yyyy").toStdString() << endl; 231 + if (!(f >= *(cb->fechaInicio))) { 232 + it = lista_aux.erase(it); 233 + } else { 234 + it++; 235 + } 236 + } 237 + } 238 + } 239 + 240 + lista = lista_aux; 241 + list<Factura>::iterator it; 242 + it = lista.begin(); 243 + int n_elem = lista.size(); 244 + int n_row = ui.tableWidget->rowCount(); 245 + for (int row = 0; row < n_row; row++, it++) { 246 + if ( it->getn_factura() < 100000) { 247 + ui.tableWidget->item(row, 0)->setText(tr("0%1").arg(it->getn_factura())); 248 + } else { 249 + ui.tableWidget->item(row, 0)->setText(QString::number(it->getn_factura())); 250 + } 251 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(it->getfecha())); 252 + if (it->getcliente()) { 253 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString(it->getcliente()->getnombre())); 254 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString(it->getcliente()->getapellidos())); 255 + } else { 256 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString("-")); 257 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString("-")); 258 + } 259 + ui.tableWidget->item(row, 4)->setText(QString::fromStdString(it->getaparato())); 260 + ui.tableWidget->item(row, 5)->setText(QString::fromStdString(it->getmarca())); 261 + } 262 + for (int row = n_row; row < n_elem; row++) { 263 + addRow(); 264 + if ( it->getn_factura() < 100000) { 265 + ui.tableWidget->item(row, 0)->setText(tr("0%1").arg(it->getn_factura())); 266 + } else { 267 + ui.tableWidget->item(row, 0)->setText(QString::number(it->getn_factura())); 268 + } 269 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(it->getfecha())); 270 + if (it->getcliente()) { 271 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString(it->getcliente()->getnombre())); 272 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString(it->getcliente()->getapellidos())); 273 + } else { 274 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString("-")); 275 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString("-")); 276 + } 277 + ui.tableWidget->item(row, 4)->setText(QString::fromStdString(it->getaparato())); 278 + ui.tableWidget->item(row, 5)->setText(QString::fromStdString(it->getmarca())); 279 + it++; 280 + } 281 + /*int row = ui.tableWidget->currentRow(); 282 + QMessageBox::information(this, "Aviso", tr("%1").arg(row)); 283 + int cod = ui.tableWidget->item(row, 0)->text().toInt(); 284 + Factura *f = capaNegocio->getFacturaNumero(cod); 285 + ui.tableWidget->item(row, 0)->setText(QString::number(f->getn_factura())); 286 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(f->getfecha())); 287 + if (f->getcliente()) { 288 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString(f->getcliente()->getnombre())); 289 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString(f->getcliente()->getapellidos())); 290 + } else { 291 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString("-")); 292 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString("-")); 293 + } 294 + ui.tableWidget->item(row, 4)->setText(QString::fromStdString(f->getaparato())); 295 + ui.tableWidget->item(row, 5)->setText(QString::fromStdString(f->getmarca())); 296 + */ 297 + 298 + } 299 + void ListarFacturas::borrar() { 300 + int row = ui.tableWidget->currentRow(); 301 + int cod = ui.tableWidget->item(row, 0)->text().toInt(); 302 + if (QMessageBox::question(this, tr("Borrar Factura"), tr("Seguro que desea borrar la factura de numero %1?").arg(cod),tr("No"),tr("Si")) == 1) { 303 + QString mes = tr("Ahora se borrara la factura de la fila: %1.").arg(row); 304 + //QMessageBox::information(this, tr("Atencion"), mes); 305 + if (capaNegocio->borrarFactura(capaNegocio->getFacturaNumero(cod))) { 306 + //QMessageBox::information(this, tr("Atencion"), tr("Borrado correcto.")); 307 + ui.tableWidget->removeRow(row); 308 + } else { 309 + QMessageBox::warning(this, tr("Atencion"), tr("Error al borrar.")); 310 + } 311 + } else { 312 + //QString mes = tr("No se borrara la factura de la fila: %1.").arg(row); 313 + //QMessageBox::information(this, tr("Atencion"), mes); 314 + } 315 + } 316 +
+37
Gui/ListarFacturas.h
··· 1 + #ifndef LISTARFACTURAS_H 2 + #define LISTARFACTURAS_H 3 + 4 + #include <QtGui> 5 + #include <list> 6 + #include "../Negocio/CapaNegocio.h" 7 + #include "../Datos/CriterioBusqueda.h" 8 + #include "ui_ListarFacturas.h" 9 + 10 + 11 + class ListarFacturas : public QWidget 12 + { 13 + Q_OBJECT 14 + 15 + public: 16 + ListarFacturas(CapaNegocio * const cn, QWidget *parent = 0, CriterioBusqueda* cb = 0); 17 + ~ListarFacturas(); 18 + void addRow(); 19 + void actualizar(); 20 + 21 + private slots: 22 + void mostrar(); 23 + void borrar(); 24 + 25 + private: 26 + Ui::ListarFacturasClass ui; 27 + CapaNegocio *capaNegocio; 28 + QWorkspace *padre; 29 + list<Factura> lista; 30 + CriterioBusqueda *cb; 31 + 32 + protected: 33 + void resizeEvent(QResizeEvent *event); 34 + 35 + }; 36 + 37 + #endif // LISTARFACTURAS_H
+119
Gui/ListarFacturas.ui
··· 1 + <ui version="4.0" > 2 + <class>ListarFacturasClass</class> 3 + <widget class="QWidget" name="ListarFacturasClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>497</width> 9 + <height>348</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>ListarFacturas</string> 14 + </property> 15 + <property name="windowIcon" > 16 + <iconset>images/LFacturas.PNG</iconset> 17 + </property> 18 + <property name="sizeGripEnabled" stdset="0" > 19 + <bool>true</bool> 20 + </property> 21 + <widget class="QWidget" name="gridLayout" > 22 + <property name="geometry" > 23 + <rect> 24 + <x>20</x> 25 + <y>20</y> 26 + <width>461</width> 27 + <height>311</height> 28 + </rect> 29 + </property> 30 + <layout class="QGridLayout" > 31 + <item row="0" column="0" > 32 + <widget class="QTableWidget" name="tableWidget" > 33 + <property name="alternatingRowColors" > 34 + <bool>true</bool> 35 + </property> 36 + <property name="selectionMode" > 37 + <enum>QAbstractItemView::SingleSelection</enum> 38 + </property> 39 + <column> 40 + <property name="text" > 41 + <string>Numero</string> 42 + </property> 43 + </column> 44 + <column> 45 + <property name="text" > 46 + <string>Fecha</string> 47 + </property> 48 + </column> 49 + <column> 50 + <property name="text" > 51 + <string>Nombre</string> 52 + </property> 53 + </column> 54 + <column> 55 + <property name="text" > 56 + <string>Apellidos</string> 57 + </property> 58 + </column> 59 + <column> 60 + <property name="text" > 61 + <string>Aparato</string> 62 + </property> 63 + </column> 64 + <column> 65 + <property name="text" > 66 + <string>Marca</string> 67 + </property> 68 + </column> 69 + </widget> 70 + </item> 71 + <item row="1" column="0" > 72 + <layout class="QHBoxLayout" > 73 + <item> 74 + <widget class="QPushButton" name="editarButton" > 75 + <property name="text" > 76 + <string>Editar</string> 77 + </property> 78 + </widget> 79 + </item> 80 + <item> 81 + <widget class="QPushButton" name="borrarButton" > 82 + <property name="text" > 83 + <string>Borrar</string> 84 + </property> 85 + </widget> 86 + </item> 87 + <item> 88 + <widget class="QPushButton" name="cancelarButton" > 89 + <property name="text" > 90 + <string>Cancelar</string> 91 + </property> 92 + </widget> 93 + </item> 94 + </layout> 95 + </item> 96 + </layout> 97 + </widget> 98 + </widget> 99 + <layoutdefault spacing="6" margin="11" /> 100 + <resources/> 101 + <connections> 102 + <connection> 103 + <sender>cancelarButton</sender> 104 + <signal>clicked()</signal> 105 + <receiver>ListarFacturasClass</receiver> 106 + <slot>close()</slot> 107 + <hints> 108 + <hint type="sourcelabel" > 109 + <x>407</x> 110 + <y>312</y> 111 + </hint> 112 + <hint type="destinationlabel" > 113 + <x>416</x> 114 + <y>337</y> 115 + </hint> 116 + </hints> 117 + </connection> 118 + </connections> 119 + </ui>
+275
Gui/ListarPresupuestos.cpp
··· 1 + #include "ListarPresupuestos.h" 2 + #include "../Negocio/CapaNegocio.h" 3 + #include <QtGui> 4 + #include <QString> 5 + #include "NuevoPresupuestoDialog.h" 6 + #include "../Negocio/Presupuesto.h" 7 + #include "../Datos/CriterioBusqueda.h" 8 + 9 + ListarPresupuestos::ListarPresupuestos(CapaNegocio * const cn, QWidget *parent, CriterioBusqueda *cb) 10 + : QWidget(parent) 11 + { 12 + ui.setupUi(this); 13 + setWindowTitle(tr("Listar Presupuestos")); 14 + 15 + padre = (QWorkspace *) parent; 16 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/LPresupuesto.PNG"))); 17 + capaNegocio = cn; 18 + connect(ui.pushButton_2, SIGNAL(clicked()), this, SLOT(mostrar())); 19 + connect(ui.pushButton_3, SIGNAL(clicked()), this, SLOT(borrar())); 20 + connect(ui.tableWidget, SIGNAL(cellDoubleClicked(int,int)), this, SLOT(mostrar())); 21 + 22 + list<Presupuesto> lista_aux = capaNegocio->getPresupuestos(); 23 + this->cb = cb; 24 + if (cb != 0) { 25 + if (cb->numero) { 26 + list<Presupuesto>::iterator it; 27 + 28 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 29 + if (it->getn_factura() != *cb->numero) { 30 + it = lista_aux.erase(it); 31 + }else { 32 + it++; 33 + } 34 + } 35 + } 36 + if (cb->cliente) { 37 + QRegExp rx((tr("*") + *cb->cliente) + "*"); 38 + rx.setPatternSyntax(QRegExp::Wildcard); 39 + rx.setCaseSensitivity(Qt::CaseInsensitive); 40 + list<Presupuesto>::iterator it; 41 + for (it = lista_aux.begin(); it != lista_aux.end(); ) { 42 + Cliente c = *it->getcliente(); 43 + QString nombre(((c.getnombre() + " ") + c.getapellidos()).c_str()); 44 + if (!rx.exactMatch(nombre)) { 45 + it = lista_aux.erase(it); 46 + } else { 47 + it++; 48 + } 49 + } 50 + } 51 + if (cb->fechaFin && cb->fechaInicio) { 52 + list<Presupuesto>::iterator it; 53 + for (it = lista_aux.begin(); it != lista_aux.end();) { 54 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 55 + if (!(f <= *(cb->fechaFin) && f >= *(cb->fechaInicio))) { 56 + it = lista_aux.erase(it); 57 + } else { 58 + it++; 59 + } 60 + } 61 + } else if (cb->fechaFin) { 62 + 63 + list<Presupuesto>::iterator it; 64 + for (it = lista_aux.begin(); it != lista_aux.end();) { 65 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 66 + if (!(f <= *(cb->fechaFin))) { 67 + it = lista_aux.erase(it); 68 + }else { 69 + it++; 70 + } 71 + } 72 + } else if (cb->fechaInicio) { 73 + list<Presupuesto>::iterator it; 74 + for (it = lista_aux.begin(); it != lista_aux.end();) { 75 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 76 + cout << f.toString("dd/MM/yyyy").toStdString() << endl; 77 + if (!(f >= *(cb->fechaInicio))) { 78 + it = lista_aux.erase(it); 79 + } else { 80 + it++; 81 + } 82 + } 83 + } 84 + } 85 + lista = lista_aux; 86 + 87 + int n_elem = lista.size(); 88 + cout << "[Debug]Numero de presupuestos: " << n_elem << endl; 89 + list<Presupuesto>::iterator i; 90 + i = lista.begin(); 91 + for (int row = 0; row < n_elem; row++) { 92 + addRow(); 93 + ui.tableWidget->item(row, 0)->setText(QString::number(i->getn_factura())); 94 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(i->getfecha())); 95 + if (i->getcliente()) { 96 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString(i->getcliente()->getnombre())); 97 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString(i->getcliente()->getapellidos())); 98 + } else { 99 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString("-")); 100 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString("-")); 101 + } 102 + ui.tableWidget->item(row, 4)->setText(QString::fromStdString(i->getaparato())); 103 + ui.tableWidget->item(row, 5)->setText(QString::fromStdString(i->getmarca())); 104 + i++; 105 + } 106 + connect(ui.pushButton_2, SIGNAL(clicked), this, SLOT(mostrar())); 107 + } 108 + 109 + ListarPresupuestos::~ListarPresupuestos() 110 + { 111 + 112 + } 113 + 114 + void ListarPresupuestos::actualizar() { 115 + 116 + list<Presupuesto> lista_aux = capaNegocio->getPresupuestos(); 117 + if (cb != 0) { 118 + if (cb->numero) { 119 + list<Presupuesto>::iterator it; 120 + for (it = lista_aux.begin(); it != lista_aux.end();) { 121 + if (it->getn_factura() != *cb->numero) { 122 + it = lista_aux.erase(it); 123 + } else { 124 + it++; 125 + } 126 + } 127 + } 128 + if (cb->cliente) { 129 + QRegExp rx((tr("*") + *cb->cliente) + "*"); 130 + rx.setPatternSyntax(QRegExp::Wildcard); 131 + rx.setCaseSensitivity(Qt::CaseInsensitive); 132 + list<Presupuesto>::iterator it; 133 + for (it = lista_aux.begin(); it != lista_aux.end();) { 134 + Cliente c = *it->getcliente(); 135 + QString nombre(((c.getnombre() + " ") + c.getapellidos()).c_str()); 136 + if (!rx.exactMatch(nombre)) { 137 + it = lista_aux.erase(it); 138 + } else { 139 + it++; 140 + } 141 + } 142 + } 143 + if (cb->fechaFin && cb->fechaInicio) { 144 + list<Presupuesto>::iterator it; 145 + for (it = lista_aux.begin(); it != lista_aux.end();) { 146 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 147 + if (!(f <= *(cb->fechaFin) && f >= *(cb->fechaInicio))) { 148 + it = lista_aux.erase(it); 149 + } else { 150 + it++; 151 + } 152 + } 153 + } else if (cb->fechaFin) { 154 + 155 + list<Presupuesto>::iterator it; 156 + for (it = lista_aux.begin(); it != lista_aux.end();) { 157 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 158 + if (!(f <= *(cb->fechaFin))) { 159 + it = lista_aux.erase(it); 160 + } else { 161 + it++; 162 + } 163 + } 164 + } else if (cb->fechaInicio) { 165 + list<Presupuesto>::iterator it; 166 + for (it = lista_aux.begin(); it != lista_aux.end();) { 167 + QDate f = QDate::fromString(it->getfecha().c_str(), "dd/MM/yyyy"); 168 + cout << f.toString("dd/MM/yyyy").toStdString() << endl; 169 + if (!(f >= *(cb->fechaInicio))) { 170 + it = lista_aux.erase(it); 171 + } else { 172 + it++; 173 + } 174 + } 175 + } 176 + } 177 + lista = lista_aux; 178 + list<Presupuesto>::iterator it; 179 + it = lista.begin(); 180 + int n_elem = lista.size(); 181 + int n_row = ui.tableWidget->rowCount(); 182 + for (int row = 0; row < n_row; row++, it++) { 183 + ui.tableWidget->item(row, 0)->setText(QString::number(it->getn_factura())); 184 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(it->getfecha())); 185 + if (it->getcliente()) { 186 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString(it->getcliente()->getnombre())); 187 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString(it->getcliente()->getapellidos())); 188 + } else { 189 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString("-")); 190 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString("-")); 191 + } 192 + ui.tableWidget->item(row, 4)->setText(QString::fromStdString(it->getaparato())); 193 + ui.tableWidget->item(row, 5)->setText(QString::fromStdString(it->getmarca())); 194 + } 195 + for (int row = n_row; row < n_elem; row++) { 196 + addRow(); 197 + ui.tableWidget->item(row, 0)->setText(QString::number(it->getn_factura())); 198 + ui.tableWidget->item(row, 1)->setText(QString::fromStdString(it->getfecha())); 199 + if (it->getcliente()) { 200 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString(it->getcliente()->getnombre())); 201 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString(it->getcliente()->getapellidos())); 202 + } else { 203 + ui.tableWidget->item(row, 2)->setText(QString::fromStdString("-")); 204 + ui.tableWidget->item(row, 3)->setText(QString::fromStdString("-")); 205 + } 206 + ui.tableWidget->item(row, 4)->setText(QString::fromStdString(it->getaparato())); 207 + ui.tableWidget->item(row, 5)->setText(QString::fromStdString(it->getmarca())); 208 + it++; 209 + } 210 + 211 + } 212 + 213 + void ListarPresupuestos::addRow(){ 214 + int row = ui.tableWidget->rowCount(); 215 + ui.tableWidget->insertRow(row); 216 + 217 + QTableWidgetItem *item0 = new QTableWidgetItem; 218 + item0->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 219 + ui.tableWidget->setItem(row, 0, item0); 220 + 221 + QTableWidgetItem *item1 = new QTableWidgetItem; 222 + item1->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 223 + ui.tableWidget->setItem(row, 1, item1); 224 + 225 + QTableWidgetItem *item2 = new QTableWidgetItem; 226 + item2->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 227 + ui.tableWidget->setItem(row, 2, item2); 228 + 229 + QTableWidgetItem *item3 = new QTableWidgetItem; 230 + item3->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 231 + ui.tableWidget->setItem(row, 3, item3); 232 + 233 + QTableWidgetItem *item4 = new QTableWidgetItem; 234 + item4->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 235 + ui.tableWidget->setItem(row, 4, item4); 236 + 237 + QTableWidgetItem *item5 = new QTableWidgetItem; 238 + item5->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 239 + ui.tableWidget->setItem(row, 5, item5); 240 + } 241 + 242 + void ListarPresupuestos::resizeEvent(QResizeEvent *event) { 243 + ui.gridLayout->setGeometry(QRect(0, 0, event->size().width(), event->size().height())); 244 + } 245 + void ListarPresupuestos::mostrar() { 246 + int row = ui.tableWidget->currentRow(); 247 + int cod; 248 + if (row == -1) { 249 + QString mes = tr("No se selecciono ninguna fila."); 250 + QMessageBox::warning(this, tr("Atencion"),mes); 251 + 252 + } else { 253 + cod = ui.tableWidget->item(row, 0)->text().toInt(); 254 + NuevoPresupuestoDialog *nfd = new NuevoPresupuestoDialog(capaNegocio, this, capaNegocio->getPresupuestoNumero(cod)); 255 + padre->addWindow(nfd); 256 + nfd->show(); 257 + } 258 + } 259 + void ListarPresupuestos::borrar() { 260 + int row = ui.tableWidget->currentRow(); 261 + int cod = ui.tableWidget->item(row, 0)->text().toInt(); 262 + if (QMessageBox::question(this, tr("Borrar Presupuesto"), tr("Seguro que desea borrar el presupuesto de nuemero %1?").arg(cod),tr("No"),tr("Si")) == 1) { 263 + QString mes = tr("Ahora se borrara el presupuesto de la fila: %1.").arg(row); 264 + //QMessageBox::information(this, tr("Atencion"), mes); 265 + if (capaNegocio->borrarPresupuesto(capaNegocio->getPresupuestoNumero(cod))) { 266 + //QMessageBox::information(this, tr("Atencion"), tr("Borrado correcto.")); 267 + ui.tableWidget->removeRow(row); 268 + } else { 269 + QMessageBox::warning(this, tr("Atencion"), tr("Error al borrar.")); 270 + } 271 + } else { 272 + //QString mes = tr("No se borrara el presupuesto de la fila: %1.").arg(row); 273 + //QMessageBox::information(this, tr("Atencion"), mes); 274 + } 275 + }
+33
Gui/ListarPresupuestos.h
··· 1 + #ifndef LISTARPRESUPUESTOS_H 2 + #define LISTARPRESUPUESTOS_H 3 + 4 + #include <QtGui> 5 + #include "../Negocio/CapaNegocio.h" 6 + #include "ui_ListarPresupuestos.h" 7 + #include "../Datos/CriterioBusqueda.h" 8 + 9 + class ListarPresupuestos : public QWidget 10 + { 11 + Q_OBJECT 12 + 13 + public: 14 + ListarPresupuestos(CapaNegocio * const cn, QWidget *parent = 0, CriterioBusqueda *cb = 0); 15 + ~ListarPresupuestos(); 16 + void addRow(); 17 + void actualizar(); 18 + 19 + private slots: 20 + void mostrar(); 21 + void borrar(); 22 + 23 + private: 24 + Ui::ListarPresupuestosClass ui; 25 + CapaNegocio *capaNegocio; 26 + QWorkspace *padre; 27 + list<Presupuesto> lista; 28 + CriterioBusqueda *cb; 29 + protected: 30 + void resizeEvent(QResizeEvent *event); 31 + }; 32 + 33 + #endif // LISTARPRESUPUESTOS_H
+113
Gui/ListarPresupuestos.ui
··· 1 + <ui version="4.0" > 2 + <class>ListarPresupuestosClass</class> 3 + <widget class="QWidget" name="ListarPresupuestosClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>400</width> 9 + <height>300</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>ListarPresupuestos</string> 14 + </property> 15 + <property name="windowIcon" > 16 + <iconset>images/LPresupuesto.PNG</iconset> 17 + </property> 18 + <widget class="QWidget" name="gridLayout" > 19 + <property name="geometry" > 20 + <rect> 21 + <x>10</x> 22 + <y>10</y> 23 + <width>381</width> 24 + <height>281</height> 25 + </rect> 26 + </property> 27 + <layout class="QGridLayout" > 28 + <item row="0" column="0" > 29 + <widget class="QTableWidget" name="tableWidget" > 30 + <property name="selectionBehavior" > 31 + <enum>QAbstractItemView::SelectRows</enum> 32 + </property> 33 + <column> 34 + <property name="text" > 35 + <string>Número</string> 36 + </property> 37 + </column> 38 + <column> 39 + <property name="text" > 40 + <string>Fecha</string> 41 + </property> 42 + </column> 43 + <column> 44 + <property name="text" > 45 + <string>Nombre</string> 46 + </property> 47 + </column> 48 + <column> 49 + <property name="text" > 50 + <string>Apellidos</string> 51 + </property> 52 + </column> 53 + <column> 54 + <property name="text" > 55 + <string>Aparato</string> 56 + </property> 57 + </column> 58 + <column> 59 + <property name="text" > 60 + <string>Marca</string> 61 + </property> 62 + </column> 63 + </widget> 64 + </item> 65 + <item row="1" column="0" > 66 + <layout class="QHBoxLayout" > 67 + <item> 68 + <widget class="QPushButton" name="pushButton_2" > 69 + <property name="text" > 70 + <string>Editar</string> 71 + </property> 72 + </widget> 73 + </item> 74 + <item> 75 + <widget class="QPushButton" name="pushButton_3" > 76 + <property name="text" > 77 + <string>Borrar</string> 78 + </property> 79 + </widget> 80 + </item> 81 + <item> 82 + <widget class="QPushButton" name="pushButton" > 83 + <property name="text" > 84 + <string>Cancelar</string> 85 + </property> 86 + </widget> 87 + </item> 88 + </layout> 89 + </item> 90 + </layout> 91 + </widget> 92 + </widget> 93 + <layoutdefault spacing="6" margin="11" /> 94 + <resources/> 95 + <connections> 96 + <connection> 97 + <sender>pushButton</sender> 98 + <signal>clicked()</signal> 99 + <receiver>ListarPresupuestosClass</receiver> 100 + <slot>close()</slot> 101 + <hints> 102 + <hint type="sourcelabel" > 103 + <x>326</x> 104 + <y>265</y> 105 + </hint> 106 + <hint type="destinationlabel" > 107 + <x>332</x> 108 + <y>294</y> 109 + </hint> 110 + </hints> 111 + </connection> 112 + </connections> 113 + </ui>
+429
Gui/MainWindow.cpp
··· 1 + #include "MainWindow.h" 2 + #include "../Negocio/Factura.h" 3 + #include "NuevoClienteDialog.h" 4 + #include "NuevoArticuloDialog.h" 5 + #include "NuevaFacturaDialog.h" 6 + #include "NuevoPresupuestoDialog.h" 7 + #include "ListarClientes.h" 8 + #include "BuscarFacturaDialog.h" 9 + #include "CambiarIvaDialog.h" 10 + #include <QtGui> 11 + #include "ListarFacturas.h" 12 + #include "ListarPresupuestos.h" 13 + #include "ListarArticulos.h" 14 + #include <list> 15 + #include <iostream> 16 + #include <QThread> 17 + #include "BuscarClienteDialog.h" 18 + #include "BuscarArticuloDialog.h" 19 + #include "BuscarPresupuestoDialog.h" 20 + #include "ConfigurarImpresora.h" 21 + #include <QTextDocument> 22 + #include "VisorAyuda.h" 23 + #include "imprimirsobrecliente.h" 24 + 25 + using namespace std; 26 + /* 27 + template<class A, class B> class Conversion { 28 + typedef char S_True; 29 + class S_False {char dummy[2];} 30 + static A CrearInstancia(); 31 + static S_True Test(B);static S_False Test(�); 32 + public: 33 + enum { 34 + existe = ( sizeof(Test(CrearInstancia())) == sizeof(S_True) ) 35 + }; 36 + }; 37 + */ 38 + void MainThread::setPadre(QWorkspace* parent) { 39 + mw = parent; 40 + } 41 + void MainThread::run() { 42 + while (true) { 43 + usleep(500000); 44 + /** 45 + * Actualizador de listados abiertos. 46 + */ 47 + QWidgetList windows = mw->windowList(); 48 + if (windows.isEmpty()) continue; 49 + 50 + for (int i = 0; i < windows.size(); ++i) { 51 + QWidget * child = windows.at(i); 52 + ListarArticulos *la = dynamic_cast<ListarArticulos *>( child ); 53 + if (la != 0) { 54 + /*El hijo es de tipo Listar Articulos. */ 55 + la->actualizar(); 56 + } 57 + ListarFacturas *lf = dynamic_cast<ListarFacturas *>( child ); 58 + if (lf != 0) { 59 + /*El hijo es de tipo Listar Facturas. */ 60 + lf->actualizar(); 61 + } 62 + ListarPresupuestos *lp = dynamic_cast<ListarPresupuestos *>(child); 63 + if (lp != 0) { 64 + /*El hijo es de tipo Listar Presupuestos. */ 65 + lp->actualizar(); 66 + } 67 + ListarClientes *lc = dynamic_cast<ListarClientes *>(child); 68 + if (lc != 0) { 69 + /*El hijo es de tipo Listar Clientes*/ 70 + lc->actualizar(); 71 + } 72 + } 73 + } 74 + } 75 + 76 + 77 + MainWindow::MainWindow(CapaNegocio * const cn, QMainWindow *parent) : QMainWindow(parent) 78 + { 79 + workspace = new QWorkspace; 80 + 81 + setWindowIcon(QIcon("Gui/images/icono.ico")); 82 + workspace->setBackground(QBrush(QImage("Gui/images/textura.png"))); 83 + setCentralWidget(workspace); 84 + 85 + capaNegocio = cn; 86 + 87 + windowMapper = new QSignalMapper(this); 88 + connect(windowMapper, SIGNAL(mapped(QWidget *)), workspace, SLOT(setActiveWindow(QWidget *))); 89 + 90 + connect(workspace, SIGNAL(windowActivated(QWidget *)), this, SLOT(updateMenus())); 91 + 92 + createActions(); 93 + createMenus(); 94 + createToolBar(); 95 + createStatusBar(); 96 + 97 + actualizador = new MainThread(); 98 + actualizador->setPadre(workspace); 99 + actualizador->start(); 100 + 101 + setWindowTitle(tr("Seoane")); 102 + } 103 + 104 + MainWindow::~MainWindow() 105 + { 106 + actualizador->quit(); 107 + } 108 + //Acciones del menu facturas 109 + void MainWindow::listarFacturas() { 110 + ListarFacturas *lf = new ListarFacturas(capaNegocio, workspace); 111 + workspace->addWindow(lf); 112 + lf->show(); 113 + statusBar()->showMessage(tr("Total Facturas: %1").arg(capaNegocio->getTotalFacturas())); 114 + } 115 + void MainWindow::nuevaFactura() { 116 + NuevaFacturaDialog *nfd = new NuevaFacturaDialog(capaNegocio, workspace); 117 + workspace->addWindow(nfd); 118 + nfd->show(); 119 + statusBar()->showMessage(tr("Nueva factura.")); 120 + } 121 + 122 + void MainWindow::buscarFactura() { 123 + BuscarFacturaDialog *bfd = new BuscarFacturaDialog(capaNegocio, workspace); 124 + workspace->addWindow(bfd); 125 + bfd->show(); 126 + } 127 + 128 + //Acciones del menu presupuestos 129 + void MainWindow::listarPresupuestos() { 130 + ListarPresupuestos *lp = new ListarPresupuestos(capaNegocio, workspace); 131 + workspace->addWindow(lp); 132 + lp->show(); 133 + statusBar()->showMessage(tr("Total Presupuestos: %1").arg(capaNegocio->getTotalPresupuestos())); 134 + } 135 + 136 + 137 + void MainWindow::buscarPresupuestos() { 138 + BuscarPresupuestoDialog *bfd = new BuscarPresupuestoDialog(capaNegocio, workspace); 139 + workspace->addWindow(bfd); 140 + bfd->show(); 141 + } 142 + 143 + 144 + void MainWindow::nuevoPresupuestos() { 145 + NuevoPresupuestoDialog *nfd = new NuevoPresupuestoDialog(capaNegocio, workspace); 146 + workspace->addWindow(nfd); 147 + nfd->show(); 148 + statusBar()->showMessage(tr("Nuevo presupuesto.")); 149 + } 150 + 151 + 152 + //Acciones del menu articulos 153 + void MainWindow::altaArticulos() { 154 + NuevoArticuloDialog *aad = new NuevoArticuloDialog(capaNegocio,workspace); 155 + workspace->addWindow(aad); 156 + aad->show(); 157 + } 158 + 159 + void MainWindow::buscarArticulos() { 160 + BuscarArticuloDialog* bcd = new BuscarArticuloDialog(capaNegocio,workspace); 161 + workspace->addWindow(bcd); 162 + bcd->show(); 163 + } 164 + 165 + void MainWindow::listarArticulos() { 166 + ListarArticulos *la = new ListarArticulos(capaNegocio, workspace); 167 + workspace->addWindow(la); 168 + la->show(); 169 + statusBar()->showMessage(tr("Total Articulos: %1").arg(capaNegocio->getTotalArticulos())); 170 + } 171 + 172 + //Acciones del menu clientes 173 + void MainWindow::nuevoCliente(){ 174 + NuevoClienteDialog *ncd = new NuevoClienteDialog(capaNegocio,workspace); 175 + workspace->addWindow(ncd); 176 + ncd->show(); 177 + } 178 + void MainWindow::buscarCliente(){ 179 + BuscarClienteDialog* bcd = new BuscarClienteDialog(capaNegocio,workspace); 180 + workspace->addWindow(bcd); 181 + bcd->show(); 182 + } 183 + void MainWindow::listarCliente(){ 184 + ListarClientes *lc = new ListarClientes(capaNegocio, workspace); 185 + workspace->addWindow(lc); 186 + lc->show(); 187 + statusBar()->showMessage(tr("Total Clientes: %1").arg(capaNegocio->getTotalClientes())); 188 + } 189 + 190 + void MainWindow::imprimirClientes(){ 191 + ImprimirSobreCliente *isc = new ImprimirSobreCliente(workspace, capaNegocio ); 192 + workspace->addWindow(isc); 193 + isc->show(); 194 + statusBar()->showMessage(tr("Imprimir Sobre Clientes: ")); 195 + } 196 + 197 + //Acciones del menu ayuda 198 + void MainWindow::acercaDeAyuda() { 199 + QMessageBox::about(this, tr("Acerca de Seoane Facturaci�n"), 200 + tr("<h2>Seoane v1.0.4-beta</h2>" 201 + "<p>Copyright &copy; 2007 Maite Simon & Marcos Gabarda</p>" 202 + "<h5><i>Programa bajo licencia GPL 3.0</i></h5>")); 203 + } 204 + void MainWindow::ayudaAyuda() { 205 + VisorAyuda *va = new VisorAyuda(this); 206 + workspace->addWindow(va); 207 + va->show(); 208 + } 209 + void MainWindow::cambiarIva() { 210 + CambiarIvaDialog *civa = new CambiarIvaDialog(capaNegocio, this); 211 + workspace->addWindow(civa); 212 + civa->show(); 213 + } 214 + 215 + void MainWindow::configurarImpresora() { 216 + ConfigurarImpresora *ci = new ConfigurarImpresora(this); 217 + workspace->addWindow(ci); 218 + ci->show(); 219 + } 220 + 221 + void MainWindow::createActions() { 222 + 223 + //menu facturas 224 + listarFacturasAction = new QAction(tr("&Listar"), this); 225 + listarFacturasAction->setIcon(QIcon(QString::fromUtf8("Gui/images/LFactura.PNG"))); 226 + connect(listarFacturasAction, SIGNAL(triggered()), this, SLOT(listarFacturas())); 227 + 228 + nuevaFacturaAction = new QAction(tr("&Nueva"), this); 229 + nuevaFacturaAction->setIcon(QIcon(QString::fromUtf8("Gui/images/NFactura.PNG"))); 230 + connect(nuevaFacturaAction, SIGNAL(triggered()), this, SLOT(nuevaFactura())); 231 + 232 + buscarFacturaAction = new QAction(tr("&Buscar"), this); 233 + buscarFacturaAction->setIcon(QIcon(QString::fromUtf8("Gui/images/BFactura.PNG"))); 234 + connect(buscarFacturaAction, SIGNAL(triggered()), this, SLOT(buscarFactura())); 235 + 236 + 237 + //menu presupuestos 238 + listarPresupuestosAction = new QAction(tr("&Listar"), this); 239 + listarPresupuestosAction->setIcon(QIcon(QString::fromUtf8("Gui/images/LPresupuesto.PNG"))); 240 + connect(listarPresupuestosAction, SIGNAL(triggered()), this, SLOT(listarPresupuestos())); 241 + 242 + nuevoPresupuestosAction = new QAction(tr("&Nuevo"), this); 243 + nuevoPresupuestosAction->setIcon(QIcon(QString::fromUtf8("Gui/images/NPresupuesto.PNG"))); 244 + connect(nuevoPresupuestosAction, SIGNAL(triggered()), this, SLOT(nuevoPresupuestos())); 245 + 246 + buscarPresupuestosAction = new QAction(tr("&Buscar"), this); 247 + buscarPresupuestosAction->setIcon(QIcon(QString::fromUtf8("Gui/images/BPresupuesto.PNG"))); 248 + connect(buscarPresupuestosAction, SIGNAL(triggered()), this, SLOT(buscarPresupuestos())); 249 + 250 + //menu articulos 251 + 252 + altaArticulosAction = new QAction(tr("&Alta"), this); 253 + altaArticulosAction->setIcon(QIcon(QString::fromUtf8("Gui/images/NArticulo.PNG"))); 254 + connect(altaArticulosAction, SIGNAL(triggered()), this, SLOT(altaArticulos())); 255 + 256 + buscarArticulosAction = new QAction(tr("&Buscar"), this); 257 + buscarArticulosAction->setIcon(QIcon(QString::fromUtf8("Gui/images/BArticulo.PNG"))); 258 + connect(buscarArticulosAction, SIGNAL(triggered()), this, SLOT(buscarArticulos())); 259 + 260 + listarArticulosAction = new QAction(tr("&Listar"), this); 261 + listarArticulosAction->setIcon(QIcon(QString::fromUtf8("Gui/images/LArticulo.PNG"))); 262 + connect(listarArticulosAction, SIGNAL(triggered()), this, SLOT(listarArticulos())); 263 + 264 + //menu clientes 265 + nuevoClienteAction = new QAction(tr("&Nuevo"), this); 266 + nuevoClienteAction->setIcon(QIcon(QString::fromUtf8("Gui/images/NCliente.png"))); 267 + connect(nuevoClienteAction, SIGNAL(triggered()), this, SLOT(nuevoCliente())); 268 + 269 + buscarClienteAction = new QAction(tr("&Buscar"), this); 270 + buscarClienteAction->setIcon(QIcon(QString::fromUtf8("Gui/images/BCliente.png"))); 271 + connect(buscarClienteAction, SIGNAL(triggered()), this, SLOT(buscarCliente())); 272 + 273 + listarClienteAction = new QAction(tr("&Listar"), this); 274 + listarClienteAction->setIcon(QIcon(QString::fromUtf8("Gui/images/LCliente.png"))); 275 + connect(listarClienteAction, SIGNAL(triggered()), this, SLOT(listarCliente())); 276 + 277 + imprimirClienteAction = new QAction(tr("&Imprimir"), this); 278 + imprimirClienteAction->setIcon(QIcon(QString::fromUtf8("Gui/images/LCliente.png"))); 279 + connect(imprimirClienteAction, SIGNAL(triggered()), this, SLOT(imprimirClientes())); 280 + 281 + //menu ayuda 282 + acercaDeAyudaAction = new QAction(tr("&Acera de"), this); 283 + connect(acercaDeAyudaAction, SIGNAL(triggered()), this, SLOT(acercaDeAyuda())); 284 + 285 + ayudaAyudaAction = new QAction(tr("&Ayuda"), this); 286 + connect(ayudaAyudaAction, SIGNAL(triggered()), this, SLOT(ayudaAyuda())); 287 + 288 + //Menu ventanas 289 + closeAction = new QAction(tr("&Cerrar"), this); 290 + closeAction->setShortcut(tr("Ctrl+F4")); 291 + closeAction->setStatusTip(tr("Cierra la ventana activa.")); 292 + connect(closeAction, SIGNAL(triggered()), workspace, SLOT(closeActiveWindow())); 293 + 294 + closeAllAction = new QAction(tr("Cerrar &Todo"), this); 295 + closeAllAction->setStatusTip(tr("Cierra todas las ventanas.")); 296 + connect(closeAllAction, SIGNAL(triggered()), workspace, SLOT(closeAllWindows())); 297 + 298 + tileAction = new QAction(tr("&Tile"), this); 299 + tileAction->setStatusTip(tr("Organiza las ventanas por valdosas.")); 300 + connect(tileAction, SIGNAL(triggered()), workspace, SLOT(tile())); 301 + 302 + cascadeAction = new QAction(tr("&Cascada"), this); 303 + cascadeAction->setStatusTip(tr("Organiza las ventanas en cascada.")); 304 + connect(cascadeAction, SIGNAL(triggered()), workspace, SLOT(cascade())); 305 + 306 + nextAction = new QAction(tr("&Siguiente"), this); 307 + nextAction->setStatusTip(tr("Se mueve a la siguiente ventana.")); 308 + connect(nextAction, SIGNAL(triggered()), workspace, SLOT(activateNextWindow())); 309 + 310 + previousAction = new QAction(tr("&Anterior"), this); 311 + previousAction->setStatusTip(tr("Se mueve a la ventana anterior.")); 312 + connect(previousAction, SIGNAL(triggered()), workspace, SLOT(activatePreviousWindow())); 313 + 314 + cambiarIvaAction = new QAction(tr("Cambiar IVA"), this); 315 + connect(cambiarIvaAction, SIGNAL(triggered()), this, SLOT(cambiarIva())); 316 + 317 + //configurarImpresoraAction = new QAction(tr("Configurar Impresora"), this); 318 + //connect(configurarImpresoraAction, SIGNAL(triggered()), this, SLOT(configurarImpresora())); 319 + 320 + } 321 + 322 + void MainWindow::createMenus() { 323 + facturasMenu = menuBar()->addMenu(tr("&Facturas")); 324 + presupuestosMenu = menuBar()->addMenu(tr("&Presupuestos")); 325 + articulosMenu=menuBar()->addMenu(tr("&Articulos")); 326 + clientesMenu=menuBar()->addMenu(tr("&Clientes")); 327 + windowMenu=menuBar()->addMenu(tr("&Ventanas")); 328 + configMenu=menuBar()->addMenu(tr("Con&figuracion")); 329 + ayudaMenu=menuBar()->addMenu(tr("&Ayuda")); 330 + 331 + //crea el menu facturas 332 + facturasMenu->addAction(listarFacturasAction); 333 + facturasMenu->addAction(nuevaFacturaAction); 334 + facturasMenu->addAction(buscarFacturaAction); 335 + 336 + //crea menu presupuestos 337 + presupuestosMenu->addAction(listarPresupuestosAction); 338 + presupuestosMenu->addAction(nuevoPresupuestosAction); 339 + presupuestosMenu->addAction(buscarPresupuestosAction); 340 + 341 + //crea el menu articulo 342 + articulosMenu->addAction(altaArticulosAction); 343 + articulosMenu->addAction(buscarArticulosAction); 344 + articulosMenu->addAction(listarArticulosAction); 345 + 346 + //Crea el menu clientes 347 + clientesMenu->addAction(nuevoClienteAction); 348 + clientesMenu->addAction(buscarClienteAction); 349 + clientesMenu->addAction(listarClienteAction); 350 + clientesMenu->addAction(imprimirClienteAction); 351 + 352 + //crea el menu ayuda 353 + ayudaMenu->addAction(acercaDeAyudaAction); 354 + ayudaMenu->addAction(ayudaAyudaAction); 355 + 356 + //crea el menu vantanas 357 + windowMenu->addAction(closeAction); 358 + windowMenu->addAction(closeAllAction); 359 + windowMenu->addSeparator(); 360 + windowMenu->addAction(tileAction); 361 + windowMenu->addAction(cascadeAction); 362 + windowMenu->addSeparator(); 363 + windowMenu->addAction(nextAction); 364 + windowMenu->addAction(previousAction); 365 + 366 + configMenu->addAction(cambiarIvaAction); 367 + //configMenu->addAction(configurarImpresoraAction); 368 + 369 + } 370 + 371 + void MainWindow::createToolBar() { 372 + 373 + facturaToolBar = addToolBar(tr("Facturas")); 374 + facturaToolBar->addAction(nuevaFacturaAction); 375 + facturaToolBar->addAction(buscarFacturaAction); 376 + facturaToolBar->addAction(listarFacturasAction); 377 + 378 + presupuestoToolBar = addToolBar(tr("Presupuestos")); 379 + presupuestoToolBar->addAction(nuevoPresupuestosAction); 380 + presupuestoToolBar->addAction(buscarPresupuestosAction); 381 + presupuestoToolBar->addAction(listarPresupuestosAction); 382 + 383 + clienteToolBar = addToolBar(tr("Clientes")); 384 + clienteToolBar->addAction(nuevoClienteAction); 385 + clienteToolBar->addAction(buscarClienteAction); 386 + clienteToolBar->addAction(listarClienteAction); 387 + 388 + articuloToolBar = addToolBar(tr("Articulos")); 389 + articuloToolBar->addAction(altaArticulosAction); 390 + articuloToolBar->addAction(buscarArticulosAction); 391 + articuloToolBar->addAction(listarArticulosAction); 392 + 393 + } 394 + 395 + void MainWindow::updateMenus() { 396 + 397 + windowMenu->clear(); 398 + windowMenu->addAction(closeAction); 399 + windowMenu->addAction(closeAllAction); 400 + windowMenu->addSeparator(); 401 + windowMenu->addAction(tileAction); 402 + windowMenu->addAction(cascadeAction); 403 + windowMenu->addSeparator(); 404 + windowMenu->addAction(nextAction); 405 + windowMenu->addAction(previousAction); 406 + 407 + QWidgetList windows = workspace->windowList(); 408 + 409 + if (!windows.isEmpty()) windowMenu->addSeparator(); 410 + 411 + for (int i = 0; i < windows.size(); ++i) { 412 + QWidget *child = windows.at(i); 413 + QString text; 414 + if (i < 9) { 415 + text = tr("&%1 %2").arg(i + 1).arg(child->windowTitle()); 416 + } else { 417 + text = tr("%1 %2").arg(i + 1).arg(child->windowTitle()); 418 + } 419 + QAction *action = windowMenu->addAction(text); 420 + action->setCheckable(true); 421 + action->setChecked(child == workspace->activeWindow()); 422 + connect(action, SIGNAL(triggered()), windowMapper, SLOT(map())); 423 + windowMapper->setMapping(action, windows.at(i)); 424 + } 425 + } 426 + void MainWindow::createStatusBar() 427 + { 428 + statusBar()->showMessage(tr("Listo")); 429 + }
+127
Gui/MainWindow.h
··· 1 + #ifndef MAINWINDOW_H_ 2 + #define MAINWINDOW_H_ 3 + 4 + #include "../Negocio/Factura.h" 5 + #include "../Negocio/CapaNegocio.h" 6 + #include <QtGui> 7 + #include <list> 8 + 9 + class MainThread; 10 + 11 + class MainWindow : public QMainWindow 12 + { 13 + Q_OBJECT 14 + public: 15 + MainWindow(CapaNegocio * const cn, QMainWindow *parent = 0); 16 + virtual ~MainWindow(); 17 + 18 + private slots: 19 + 20 + //menu ventana 21 + void updateMenus(); //Actualiza las ventanas abiertas 22 + 23 + //menu facturas 24 + void listarFacturas(); 25 + void nuevaFactura(); 26 + void buscarFactura(); 27 + 28 + //menu presupuestos 29 + void listarPresupuestos(); 30 + void nuevoPresupuestos(); 31 + void buscarPresupuestos(); 32 + 33 + //menu articulos 34 + void altaArticulos(); 35 + void buscarArticulos(); 36 + void listarArticulos(); 37 + 38 + //menu clientes 39 + void nuevoCliente(); 40 + void buscarCliente(); 41 + void listarCliente(); 42 + 43 + void imprimirClientes(); 44 + 45 + //menu ayuda 46 + void acercaDeAyuda(); 47 + void ayudaAyuda(); 48 + 49 + void cambiarIva(); 50 + void configurarImpresora(); 51 + 52 + private: 53 + 54 + MainThread *actualizador; 55 + 56 + QWorkspace *workspace; 57 + QSignalMapper *windowMapper; 58 + 59 + //menus 60 + QMenu *facturasMenu; 61 + QMenu *presupuestosMenu; 62 + QMenu *articulosMenu; 63 + QMenu *ayudaMenu; 64 + QMenu *clientesMenu; 65 + QMenu *windowMenu; 66 + QMenu *configMenu; 67 + 68 + QToolBar *clienteToolBar; 69 + QToolBar *articuloToolBar; 70 + QToolBar *facturaToolBar; 71 + QToolBar *presupuestoToolBar; 72 + 73 + //acciones del menu facturas 74 + QAction *listarFacturasAction; 75 + QAction *nuevaFacturaAction; 76 + QAction *buscarFacturaAction; 77 + 78 + //acciones del menu presupuestos 79 + QAction *listarPresupuestosAction; 80 + QAction *buscarPresupuestosAction; 81 + QAction *nuevoPresupuestosAction; 82 + 83 + //acciones del menu articulos 84 + QAction *altaArticulosAction; 85 + QAction *buscarArticulosAction; 86 + QAction *listarArticulosAction; 87 + 88 + //acciones del menu clientes 89 + QAction *nuevoClienteAction; 90 + QAction *buscarClienteAction; 91 + QAction *listarClienteAction; 92 + QAction *imprimirClienteAction; 93 + 94 + //acciones del menu ayuda 95 + QAction *acercaDeAyudaAction; 96 + QAction *ayudaAyudaAction; 97 + 98 + //acciones del menu ventana 99 + QAction *closeAction; 100 + QAction *closeAllAction; 101 + QAction *tileAction; 102 + QAction *cascadeAction; 103 + QAction *nextAction; 104 + QAction *previousAction; 105 + 106 + QAction *cambiarIvaAction; 107 + QAction *configurarImpresoraAction; 108 + 109 + CapaNegocio *capaNegocio; 110 + 111 + void createMenus(); 112 + void createActions(); 113 + void createToolBar(); 114 + void createStatusBar(); 115 + 116 + }; 117 + 118 + class MainThread : public QThread { 119 + private: 120 + QWorkspace *mw; 121 + public: 122 + void run(); 123 + void setPadre(QWorkspace *parent); 124 + }; 125 + 126 + 127 + #endif /*MAINWINDOW_H_*/
+988
Gui/NuevaFacturaDialog.cpp
··· 1 + #include "NuevaFacturaDialog.h" 2 + #include "NuevoClienteDialog.h" 3 + #include <QRegExp> 4 + #include <list> 5 + #include <iostream> 6 + #include <QtGui> 7 + #include <QThread> 8 + #include <QMutex> 9 + #include "PrintWindow.h" 10 + #include "../Negocio/Articulo.h" 11 + 12 + using namespace std; 13 + 14 + QMutex mutex; 15 + 16 + void ActualizadorThread::setPadre(NuevaFacturaDialog* parent) { 17 + nfd = parent; 18 + } 19 + void ActualizadorThread::run() { 20 + while (true) { 21 + usleep(10000); 22 + nfd->actualizaPrecios(); 23 + } 24 + } 25 + 26 + NuevaFacturaDialog::NuevaFacturaDialog(CapaNegocio * const cn, QWidget *parent, Factura *f, bool dePresupuesto) 27 + : QDialog(parent) 28 + { 29 + this->dePresupuesto = dePresupuesto; 30 + ui.setupUi(this); 31 + capaNegocio = cn; 32 + lClientes = capaNegocio->getClientes(); 33 + lArticulos = capaNegocio->getArticulos(); 34 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/NFactura.PNG"))); 35 + 36 + cliente = 0; 37 + padre = 0; 38 + nuevaFactura = new Factura(); 39 + 40 + //ui.lineEdit_7->installEventFilter(this); 41 + //ui.lineEdit_8->installEventFilter(this); 42 + //ui.lineEdit_9->installEventFilter(this); 43 + 44 + ui.tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers); 45 + 46 + ui.lineEdit_11->setText(tr("%1").arg(capaNegocio->obtenerIva())); 47 + QDate hoy = QDate::currentDate(); 48 + ui.dateEdit->setDate(hoy); 49 + ui.dateEdit_2->setDate(hoy); 50 + ui.lineEdit_10->setEnabled(false); 51 + ui.lineEdit_12->setEnabled(false); 52 + int num = capaNegocio->getUltimoCodigoFactura(); 53 + if (num < 100000) { 54 + ui.lineEdit_4->setText(tr("0%1").arg(num)); 55 + } else { 56 + ui.lineEdit_4->setText(tr("%1").arg(num)); 57 + } 58 + 59 + int cod = capaNegocio->getUltimoCodigoCliente(); 60 + ui.codigoEdit->setText(QString::number(cod)); 61 + 62 + connect(ui.pushButton_3, SIGNAL(clicked()), this, SLOT(anyadirLineaArticulo())); 63 + connect(ui.pushButton_2, SIGNAL(clicked()), this, SLOT(borrarArticulo())); 64 + connect(ui.pushButton_7, SIGNAL(clicked()), this, SLOT(limpiar())); 65 + connect(ui.pushButton_6, SIGNAL(clicked()), this, SLOT(nuevoTelefono())); 66 + connect(ui.pushButton_8, SIGNAL(clicked()), this, SLOT(borrarTelefono())); 67 + connect(ui.checkBox_2, SIGNAL(clicked()), this, SLOT(cambiarEstadoDomicilio())); 68 + connect(ui.checkBox_3, SIGNAL(clicked()), this, SLOT(cambiarEstadoTaller())); 69 + connect(ui.pushButton_4, SIGNAL(clicked()), this, SLOT(imprimir())); 70 + 71 + if (f != 0) { 72 + *nuevaFactura = *f; 73 + padre = (ListarFacturas *)parent; 74 + setWindowTitle(tr("Editar Factura")); 75 + cliente = new Cliente(); 76 + if (f->getcliente() != 0) { 77 + *cliente = *(f->getcliente()); 78 + ui.nombreEdit->setText(cliente->getnombre().c_str()); 79 + ui.nombreEdit->setEnabled(false); 80 + ui.lineEdit_13->setText(cliente->getapellidos().c_str()); 81 + ui.lineEdit_13->setEnabled(false); 82 + ui.codigoEdit->setText(tr("%1").arg(cliente->getcodigo())); 83 + ui.codigoEdit->setEnabled(false); 84 + QString direccion; 85 + direccion.append(cliente->getdireccion().c_str()); 86 + QTextDocument *direccionCompleta = new QTextDocument(direccion); 87 + ui.direccionEdit->setDocument(direccionCompleta); 88 + ui.direccionEdit->setEnabled(false); 89 + ui.lineEdit_14->setText(cliente->getpoblacion().c_str()); 90 + ui.lineEdit_14->setEnabled(false); 91 + ui.nifEdit->setText(cliente->getnif().c_str()); 92 + ui.nifEdit->setEnabled(false); 93 + ui.pushButton_6->setEnabled(false); 94 + ui.pushButton_8->setEnabled(false); 95 + list<int> lista_telefonos = cliente->gettelefonos(); 96 + list<int>::iterator it2; 97 + int row; 98 + for (it2 = lista_telefonos.begin(), row = 0; it2 != lista_telefonos.end(); it2++, row++) { 99 + addRowTelefono(); 100 + ui.tabla->item(row, 0)->setText(tr("%1").arg(*it2)); 101 + } 102 + ui.tabla->setEnabled(false); 103 + } else { 104 + ui.nombreEdit->setEnabled(false); 105 + ui.lineEdit_13->setEnabled(false); 106 + ui.codigoEdit->setEnabled(false); 107 + ui.pushButton_6->setEnabled(false); 108 + ui.direccionEdit->setEnabled(false); 109 + ui.lineEdit_14->setEnabled(false); 110 + ui.nifEdit->setEnabled(false); 111 + ui.tabla->setEnabled(false); 112 + } 113 + if (f->getn_factura() < 100000) { 114 + ui.lineEdit_4->setText(tr("0%1").arg(f->getn_factura())); 115 + } else { 116 + ui.lineEdit_4->setText(tr("%1").arg(f->getn_factura())); 117 + } 118 + if (f->getfecha()!= "") { 119 + ui.checkBox->setChecked(true); 120 + ui.dateEdit->setEnabled(true); 121 + QDate fecha = QDate::fromString(f->getfecha().c_str(), "dd/MM/yyyy"); 122 + ui.dateEdit->setDate(fecha); 123 + } 124 + if (f->getfecha_terminacion()!= "") { 125 + ui.checkBox_4->setChecked(true); 126 + ui.dateEdit_2->setEnabled(true); 127 + QDate fecha = QDate::fromString(f->getfecha_terminacion().c_str(), "dd/MM/yyyy"); 128 + ui.dateEdit_2->setDate(fecha); 129 + } 130 + ui.lineEdit_15->setText(f->getobservaciones().c_str()); 131 + ui.lineEdit->setText(f->getaparato().c_str()); 132 + ui.lineEdit_2->setText(f->getmarca().c_str()); 133 + ui.lineEdit_3->setText(f->getmodelo().c_str()); 134 + 135 + if (f->getlugar_reparacion() != 0) 136 + if (*(f->getlugar_reparacion())) { 137 + ui.checkBox_2->setChecked(true); 138 + ui.checkBox_3->setChecked(false); 139 + } else { 140 + ui.checkBox_2->setChecked(false); 141 + ui.checkBox_3->setChecked(true); 142 + } 143 + else { 144 + ui.checkBox_2->setChecked(false); 145 + ui.checkBox_3->setChecked(false); 146 + } 147 + QString averia; 148 + averia.append(f->getaveria().c_str()); 149 + QTextDocument *averiaC = new QTextDocument(averia); 150 + ui.textEdit->setDocument(averiaC); 151 + QString trabajo; 152 + trabajo.append(f->gettrabajo_realizado().c_str()); 153 + QTextDocument *trabajoC = new QTextDocument(trabajo); 154 + ui.textEdit_2->setDocument(trabajoC); 155 + ui.lineEdit_5->setText(f->gettiempo_empleado().c_str()); 156 + ui.lineEdit_6->setText(tr("%1").arg(f->getMateriales())); 157 + ui.lineEdit_7->setText(tr("%1").arg(f->getprecio_mano_obra())); 158 + ui.lineEdit_8->setText(tr("%1").arg(f->getprecio_desplazamiento())); 159 + ui.lineEdit_9->setText(tr("%1").arg(f->getprecio_transporte())); 160 + ui.lineEdit_10->setText(tr("%1").arg(f->getSubTotal())); 161 + ui.lineEdit_11->setText(tr("%1").arg(f->getiva())); 162 + ui.lineEdit_12->setText(tr("%1").arg(f->getTotal())); 163 + 164 + list<LineaArticulo> lista = f->getlista_articulos(); 165 + list<LineaArticulo>::iterator it; 166 + for (it = lista.begin(); it != lista.end(); it++) { 167 + int row = ui.tableWidget->rowCount(); 168 + int cantidad = it->getcantidad(); 169 + addRow(); 170 + ui.tableWidget->item(row, 0)->setText(tr("%1").arg(it->getarticulo().getcodigo())); 171 + ui.tableWidget->item(row, 1)->setText(it->getarticulo().getdescripcion().c_str()); 172 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad)); 173 + ui.tableWidget->item(row, 3)->setText(tr("%1").arg(it->getarticulo().getpvp())); 174 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(it->getarticulo().getpvp() * (double)cantidad)); 175 + } 176 + if (!dePresupuesto) { 177 + ui.pushButton_7->setText(tr("Modificar")); 178 + connect(ui.pushButton_5, SIGNAL(clicked()), this, SLOT(editar())); 179 + } else { 180 + connect(ui.pushButton_5, SIGNAL(clicked()), this, SLOT(guardar())); 181 + } 182 + } else { 183 + connect(ui.pushButton_5, SIGNAL(clicked()), this, SLOT(guardar())); 184 + } 185 + 186 + // Cosas de hilos 187 + actualizador = new ActualizadorThread(); 188 + actualizador->setPadre(this); 189 + actualizador->start(); 190 + } 191 + 192 + NuevaFacturaDialog::~NuevaFacturaDialog() 193 + { 194 + actualizador->quit(); 195 + } 196 + 197 + void NuevaFacturaDialog::buscarCliente() { 198 + QString nombreParcial = (ui.nombreEdit->text() + "*" ) + ui.lineEdit_13->text(); 199 + QRegExp rx(nombreParcial + "*"); 200 + rx.setPatternSyntax(QRegExp::Wildcard); 201 + rx.setCaseSensitivity(Qt::CaseInsensitive); 202 + 203 + list<Cliente> lClientesEncontrados; 204 + list<Cliente>::iterator it; 205 + 206 + for (it = lClientes.begin(); it != lClientes.end(); it++) { 207 + QString nombre(((it->getnombre() + " ") + it->getapellidos()).c_str()); 208 + if (rx.exactMatch(nombre)) { 209 + lClientesEncontrados.push_back(*it); 210 + } 211 + } 212 + 213 + if (lClientesEncontrados.size() == 1) { 214 + 215 + cliente = new Cliente(); 216 + *cliente = lClientesEncontrados.front(); 217 + ui.nombreEdit->setText(cliente->getnombre().c_str()); 218 + ui.lineEdit_13->setText(cliente->getapellidos().c_str()); 219 + ui.codigoEdit->setText(tr("%1").arg(cliente->getcodigo())); 220 + QString direccion; 221 + direccion.append(cliente->getdireccion().c_str()); 222 + QTextDocument *direccionCompleta = new QTextDocument(direccion); 223 + ui.direccionEdit->setDocument(direccionCompleta); 224 + ui.lineEdit_14->setText(cliente->getpoblacion().c_str()); 225 + ui.nifEdit->setText(cliente->getnif().c_str()); 226 + while (ui.tabla->rowCount() > 0) { 227 + ui.tabla->removeRow(0); 228 + } 229 + list<int> lista_telefonos = cliente->gettelefonos(); 230 + list<int>::iterator it; 231 + int row; 232 + for (it = lista_telefonos.begin(), row = 0; it != lista_telefonos.end(); it++, row++) { 233 + addRowTelefono(); 234 + ui.tabla->item(row, 0)->setText(tr("%1").arg(*it)); 235 + } 236 + cambiarCliente(); 237 + } 238 + 239 + } 240 + 241 + void NuevaFacturaDialog::buscarArticulo() { 242 + 243 + QString nombreParcial = ui.descripcionEdit->text(); 244 + QRegExp rx(nombreParcial + "*"); 245 + rx.setPatternSyntax(QRegExp::Wildcard); 246 + rx.setCaseSensitivity(Qt::CaseInsensitive); 247 + 248 + list<Articulo> lArticulosEncontrados; 249 + list<Articulo>::iterator it; 250 + 251 + if (ui.referenciaEdit->hasFocus()) { 252 + for (it = lArticulos.begin(); it != lArticulos.end(); it++) { 253 + if (ui.referenciaEdit->text().toInt() == it->getcodigo()) { 254 + lArticulosEncontrados.push_back(*it); 255 + } 256 + } 257 + } else { 258 + for (it = lArticulos.begin(); it != lArticulos.end(); it++) { 259 + QString nombre((it->getdescripcion()).c_str()); 260 + if (rx.exactMatch(nombre)) { 261 + lArticulosEncontrados.push_back(*it); 262 + } 263 + } 264 + } 265 + 266 + if (lArticulosEncontrados.size() == 1) { 267 + articuloActual = lArticulosEncontrados.front(); 268 + ui.descripcionEdit->setText(articuloActual.getdescripcion().c_str()); 269 + ui.referenciaEdit->setText(tr("%1").arg(articuloActual.getcodigo())); 270 + ui.pvpEdit->setText(tr("%1").arg(articuloActual.getpvp() - articuloActual.getpvp()*(articuloActual.getdescuento() / 100.0))); 271 + ui.cantidadEdit->setValue(1); 272 + } 273 + 274 + } 275 + 276 + void NuevaFacturaDialog::addRow(){ 277 + int row = ui.tableWidget->rowCount(); 278 + ui.tableWidget->insertRow(row); 279 + 280 + QTableWidgetItem *item0 = new QTableWidgetItem; 281 + item0->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 282 + ui.tableWidget->setItem(row, 0, item0); 283 + 284 + QTableWidgetItem *item1 = new QTableWidgetItem; 285 + item1->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 286 + ui.tableWidget->setItem(row, 1, item1); 287 + 288 + QTableWidgetItem *item2 = new QTableWidgetItem; 289 + item2->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 290 + ui.tableWidget->setItem(row, 2, item2); 291 + 292 + QTableWidgetItem *item3 = new QTableWidgetItem; 293 + item3->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 294 + ui.tableWidget->setItem(row, 3, item3); 295 + 296 + QTableWidgetItem *item4 = new QTableWidgetItem; 297 + item4->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 298 + ui.tableWidget->setItem(row, 4, item4); 299 + } 300 + 301 + void NuevaFacturaDialog::anyadirLineaArticulo() { 302 + 303 + int cantidadPrev = ui.cantidadEdit->value(); 304 + buscarArticulo(); 305 + ui.cantidadEdit->setValue(cantidadPrev); 306 + 307 + if (articuloActual.getcodigo() != -1) { 308 + /** 309 + * Caso para un art�culo de la base de datos. 310 + */ 311 + int row = ui.tableWidget->rowCount(); 312 + int cantidad = ui.cantidadEdit->value(); 313 + 314 + list<pair<pair<string, double>, int> >::iterator it; 315 + for (it = lArticuloFila.begin(); it != lArticuloFila.end(); it++) { 316 + if (articuloActual.getdescripcion() == it->first.first && articuloActual.getpvp() == it->first.second) { 317 + break; 318 + } 319 + } 320 + 321 + if (it == lArticuloFila.end()) { 322 + // No encuentra 323 + addRow(); 324 + ui.tableWidget->item(row, 0)->setText(ui.referenciaEdit->text()); 325 + ui.tableWidget->item(row, 1)->setText(ui.descripcionEdit->text()); 326 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad)); 327 + ui.tableWidget->item(row, 3)->setText(ui.pvpEdit->text()); 328 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(ui.pvpEdit->text().toDouble() * (double)cantidad)); 329 + pair <string, double> tmp(articuloActual.getdescripcion(), articuloActual.getpvp()); 330 + lArticuloFila.push_back(pair<pair<string, double>, int>(tmp, row)); 331 + nuevaFactura->addArticulo(articuloActual, cantidad); 332 + } else { 333 + // Encuentra 334 + row = it->second; 335 + int cantidad_prev = ui.tableWidget->item(row, 2)->text().toInt(); 336 + nuevaFactura->modificarArticulo(articuloActual, cantidad_prev + cantidad); 337 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad_prev + cantidad)); 338 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(ui.pvpEdit->text().toDouble() * (double)(cantidad_prev + cantidad))); 339 + actualizaPrecios(); 340 + } 341 + 342 + actualizaPrecios(); 343 + } else if (ui.referenciaEdit->text() == "" && ui.pvpEdit->text() != "") { 344 + /** 345 + * Caso para un articulo temporal, que tendr� que guardarse en la base de datos para poder recuperar la factura, 346 + * pero con un c�digo de 0 igual que el resto. Esto supone un problema a la hora de la b�squeda, esto supondr� un 347 + */ 348 + bool ok; 349 + ui.pvpEdit->text().toDouble(&ok); 350 + if(!ok){ 351 + QMessageBox::information(this, tr("Atencion"), 352 + tr("El precio ha de ser numerico")); 353 + } else { 354 + int cantidad = ui.cantidadEdit->value(); 355 + 356 + list<pair<pair<string, double>, int> >::iterator it; 357 + for (it = lArticuloFila.begin(); it != lArticuloFila.end(); it++) { 358 + if (ui.descripcionEdit->text().toStdString() == it->first.first && ui.pvpEdit->text().toDouble() == it->first.second) { 359 + break; 360 + } 361 + } 362 + 363 + if (it == lArticuloFila.end()) { 364 + // No encuentra 365 + // Nuevo art�culo 366 + Articulo *a_tmp = capaNegocio->getArticuloDescripcionPvp(ui.descripcionEdit->text().toStdString(), ui.pvpEdit->text().toDouble()); 367 + 368 + Articulo a; 369 + a.setcodigo(0); //C�digo generico de art�culos temporales. 370 + a.setdescripcion(ui.descripcionEdit->text().toStdString()); 371 + a.setpvp(ui.pvpEdit->text().toDouble()); 372 + a.sethistorico(true); 373 + 374 + if (a_tmp != 0) { 375 + int row = ui.tableWidget->rowCount(); 376 + addRow(); 377 + ui.tableWidget->item(row, 0)->setText("0"); 378 + ui.tableWidget->item(row, 1)->setText(ui.descripcionEdit->text()); 379 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad)); 380 + ui.tableWidget->item(row, 3)->setText(ui.pvpEdit->text()); 381 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(ui.pvpEdit->text().toDouble() * (double)cantidad)); 382 + pair <string, double> tmp(a_tmp->getdescripcion(), a_tmp->getpvp()); 383 + lArticuloFila.push_back(pair<pair<string, double>, int>(tmp, row)); 384 + nuevaFactura->addArticulo(*a_tmp,cantidad); 385 + actualizaPrecios(); 386 + } else { 387 + if (capaNegocio->nuevoArticulo(&a)) { 388 + int row = ui.tableWidget->rowCount(); 389 + addRow(); 390 + ui.tableWidget->item(row, 0)->setText("0"); 391 + ui.tableWidget->item(row, 1)->setText(ui.descripcionEdit->text()); 392 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad)); 393 + ui.tableWidget->item(row, 3)->setText(tr("%1").arg(a.getpvp(), 0, 'f', 2)); 394 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(a.getpvp() * (double)cantidad, 0, 'f', 2)); 395 + pair <string, double> tmp(a.getdescripcion(), a.getpvp()); 396 + lArticuloFila.push_back(pair<pair<string, double>, int>(tmp, row)); 397 + nuevaFactura->addArticulo(a,cantidad); 398 + actualizaPrecios(); 399 + } else { 400 + QMessageBox::warning(this, "Aviso", "Fallo al guardar el nuevo articulo."); 401 + } 402 + } 403 + } else { 404 + // Encuentra 405 + Articulo *a_tmp = capaNegocio->getArticuloDescripcionPvp(ui.descripcionEdit->text().toStdString(), ui.pvpEdit->text().toDouble()); 406 + cout << "[Debug]" << a_tmp->getid() << endl; 407 + int row = it->second; 408 + int cantidad_prev = ui.tableWidget->item(row, 2)->text().toInt(); 409 + nuevaFactura->modificarArticulo(*a_tmp, cantidad_prev + cantidad); 410 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad_prev + cantidad)); 411 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(ui.pvpEdit->text().toDouble() * (double)(cantidad_prev + cantidad))); 412 + actualizaPrecios(); 413 + } 414 + 415 + } 416 + } else { 417 + QMessageBox::warning(this, "Aviso", "Articulo no encontrado."); 418 + } 419 + Articulo aux; 420 + articuloActual = aux; 421 + } 422 + 423 + void NuevaFacturaDialog::keyPressEvent(QKeyEvent* event) { 424 + //mutex.lock(); 425 + if ((ui.nombreEdit->hasFocus() || ui.lineEdit_13->hasFocus()) && (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) 426 + buscarCliente(); 427 + else if ((ui.descripcionEdit->hasFocus() || ui.referenciaEdit->hasFocus() ) && (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) 428 + buscarArticulo(); 429 + } 430 + void NuevaFacturaDialog::keyReleaseEvent(QKeyEvent* event) { 431 + //mutex.unlock(); 432 + } 433 + 434 + void NuevaFacturaDialog::borrarArticulo() { 435 + int row = ui.tableWidget->currentRow(); 436 + if (row < 0) { 437 + QMessageBox::warning(this, tr("Aviso"), tr("Ha de haber una fila seleccionada.")); 438 + return; 439 + } 440 + 441 + string des = ui.tableWidget->item(row, 1)->text().toStdString(); 442 + double pvp = ui.tableWidget->item(row, 3)->text().toDouble(); 443 + int cod = ui.tableWidget->item(row, 0)->text().toInt(); 444 + 445 + cout << "[Debug]Borrando el articulo de descripcion: " << des << endl; 446 + 447 + Articulo *a; 448 + if ( cod == 0 ) 449 + a = capaNegocio->getArticuloDescripcionPvp(des, pvp); 450 + else 451 + a = capaNegocio->getArticuloCodigo(cod); 452 + 453 + if (a == 0) { 454 + cout << "[Debug]Articulo no encontrado en la CapaNegocio" << endl; 455 + } 456 + 457 + list<pair<pair<string, double>, int> >::iterator it; 458 + for (it = lArticuloFila.begin(); it != lArticuloFila.end(); it++) { 459 + if (a->getdescripcion() == it->first.first && a->getpvp() == it->first.second) { 460 + break; 461 + } 462 + } 463 + lArticuloFila.erase(it); 464 + 465 + if (!nuevaFactura->eliminarArticulo(*a)) 466 + cout << "[Debug]No se borra el articulo de la factura." << a->getid() << endl; 467 + 468 + ui.tableWidget->removeRow(row); 469 + 470 + actualizaPrecios(); 471 + } 472 + 473 + void NuevaFacturaDialog::actualizaPrecios() { 474 + mutex.lock(); 475 + double materiales = nuevaFactura->getMateriales(); 476 + double mano_obra = ui.lineEdit_7->text().toDouble(); 477 + double desplazamiento = ui.lineEdit_8->text().toDouble(); 478 + double transporte = ui.lineEdit_9->text().toDouble(); 479 + double subtotal = materiales + mano_obra + desplazamiento + transporte; 480 + double total = subtotal + (ui.lineEdit_11->text().toDouble() / 100.0 )*subtotal; 481 + 482 + ui.lineEdit_10->setText(tr("%1").arg(subtotal, 0, 'f', 2)); 483 + ui.lineEdit_6->setText(tr("%1").arg(materiales, 0, 'f', 2)); 484 + ui.lineEdit_12->setText(tr("%1").arg(total, 0, 'f', 2)); 485 + mutex.unlock(); 486 + } 487 + 488 + bool NuevaFacturaDialog::comprobarDatos () { 489 + bool flag = true; 490 + if (cliente == 0) { 491 + if(ui.nombreEdit->text()==""){ 492 + QMessageBox::information(this, tr("Atencion"), 493 + tr("El campo nombre es necesario")); 494 + flag=false; 495 + } 496 + if(ui.lineEdit_13->text()==""){ 497 + QMessageBox::information(this, tr("Atencion"), 498 + tr("El campo apellido es necesario")); 499 + flag=false; 500 + } 501 + bool ok; 502 + ui.codigoEdit->text().toInt(&ok); 503 + if(!ok){ 504 + QMessageBox::information(this, tr("Atencion"), 505 + tr("El campo codigo ha de ser numerico")); 506 + flag=false; 507 + } 508 + int rows = ui.tabla->rowCount(); 509 + for (int i = 0; i < rows; i++) { 510 + ui.tabla->item(i,0)->text().toInt(&ok); 511 + if(!ok && ui.tabla->item(i,0)->text()!=""){ 512 + QMessageBox::information(this, tr("Atenci�n"), 513 + tr("Hay un tel�fono incorrecto.")); 514 + flag=false; 515 + } 516 + } 517 + } 518 + bool ok; 519 + ui.lineEdit_4->text().toInt(&ok); 520 + if(!ok && ui.lineEdit_4->text() != ""){ 521 + QMessageBox::information(this, tr("Atencion"), 522 + tr("El campo codigo ha de ser numerico")); 523 + flag=false; 524 + } 525 + ui.lineEdit_5->text().toDouble(&ok); 526 + if(!ok && ui.lineEdit_5->text() != ""){ 527 + QMessageBox::information(this, tr("Atencion"), 528 + tr("El tiempo empleado ha de ser numerico")); 529 + flag=false; 530 + } 531 + ui.lineEdit_7->text().toDouble(&ok); 532 + if(!ok && ui.lineEdit_7->text() != ""){ 533 + QMessageBox::information(this, tr("Atencion"), 534 + tr("La mano de obra ha de ser numerica")); 535 + flag=false; 536 + } 537 + ui.lineEdit_8->text().toDouble(&ok); 538 + if(!ok && ui.lineEdit_8->text() != ""){ 539 + QMessageBox::information(this, tr("Atencion"), 540 + tr("El desplazamiento ha de ser numerico")); 541 + flag=false; 542 + } 543 + ui.lineEdit_9->text().toDouble(&ok); 544 + if(!ok && ui.lineEdit_9->text() != ""){ 545 + QMessageBox::information(this, tr("Atencion"), 546 + tr("El transporte ha de ser numerico")); 547 + flag=false; 548 + } 549 + if (nuevaFactura->getn_factura() == -1 && ui.lineEdit_4->text() != "" && capaNegocio->getFacturaNumero(ui.lineEdit_4->text().toInt()) != 0 ) { 550 + QMessageBox::information(this, tr("Atenci�n"), 551 + tr("N� de factura repetido.")); 552 + flag=false; 553 + } 554 + return flag; 555 + } 556 + 557 + bool NuevaFacturaDialog::guardarSinSalir() { 558 + 559 + bool clienteOk; 560 + 561 + if (comprobarDatos()) { 562 + 563 + nuevaFactura->setaparato(ui.lineEdit->text().toStdString()); 564 + nuevaFactura->setaveria(ui.textEdit->document()->toPlainText().toStdString()); 565 + 566 + if (ui.checkBox->isChecked()) { 567 + nuevaFactura->setfecha(ui.dateEdit->text().toStdString()); 568 + } else { 569 + nuevaFactura->setfecha(tr("").toStdString()); 570 + } 571 + 572 + //nuevaFactura->setfecha_terminacion(ui.lineEdit_->text()); 573 + if (ui.checkBox_4->isChecked()) { 574 + nuevaFactura->setfecha_terminacion(ui.dateEdit_2->text().toStdString()); 575 + } else { 576 + nuevaFactura->setfecha_terminacion(tr("").toStdString()); 577 + } 578 + 579 + if (!ui.checkBox_2->isChecked() && !ui.checkBox_3->isChecked()) 580 + nuevaFactura->setlugar_reparacion(0); 581 + else { 582 + bool *s = new bool; 583 + *s = ui.checkBox_2->isChecked(); 584 + nuevaFactura->setlugar_reparacion(s); 585 + } 586 + 587 + nuevaFactura->setmarca(ui.lineEdit_2->text().toStdString()); 588 + nuevaFactura->setmodelo(ui.lineEdit_3->text().toStdString()); 589 + 590 + //nuevaFactura->setn_fabricacion(ui.lineEdit_->text()); 591 + 592 + if (ui.lineEdit_4->text() == "") { 593 + nuevaFactura->setn_factura(-1); 594 + } else { 595 + nuevaFactura->setn_factura(ui.lineEdit_4->text().toInt()); 596 + } 597 + 598 + nuevaFactura->setiva(ui.lineEdit_11->text().toInt()); 599 + 600 + nuevaFactura->setobservaciones(ui.textEdit->document()->toPlainText().toStdString()); 601 + nuevaFactura->setprecio_desplazamiento(ui.lineEdit_8->text().toDouble()); 602 + nuevaFactura->setprecio_mano_obra(ui.lineEdit_7->text().toDouble()); 603 + nuevaFactura->setprecio_materiales(ui.lineEdit_6->text().toDouble()); 604 + nuevaFactura->setprecio_transporte(ui.lineEdit_9->text().toDouble()); 605 + 606 + nuevaFactura->settiempo_empleado(ui.lineEdit_5->text().toStdString()); 607 + nuevaFactura->settrabajo_realizado(ui.textEdit_2->document()->toPlainText().toStdString()); 608 + 609 + if (cliente == 0) { 610 + cliente = new Cliente(); 611 + cliente->setnombre(ui.nombreEdit->text().toStdString()); 612 + cliente->setapellidos(ui.lineEdit_13->text().toStdString()); 613 + cliente->setcodigo(ui.codigoEdit->text().toInt()); 614 + cliente->setdireccion(ui.direccionEdit->document()->toPlainText().toStdString()); 615 + cliente->setpoblacion(ui.lineEdit_14->text().toStdString()); 616 + cliente->setnif(ui.nifEdit->text().toStdString()); 617 + clienteOk = capaNegocio->nuevoCliente(cliente); 618 + } else { 619 + clienteOk = true; 620 + } 621 + 622 + if (clienteOk) 623 + nuevaFactura->setcliente(cliente); 624 + else 625 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar el nuevo cliente.")); 626 + 627 + if (capaNegocio->nuevaFactura(nuevaFactura) && clienteOk) { 628 + if (padre != 0) 629 + padre->actualizar(); 630 + return true; 631 + //this->accept(); 632 + } else 633 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar la factura.")); 634 + } 635 + return false; 636 + } 637 + 638 + void NuevaFacturaDialog::guardar() { 639 + 640 + bool clienteOk; 641 + 642 + if (comprobarDatos()) { 643 + 644 + nuevaFactura->setaparato(ui.lineEdit->text().toStdString()); 645 + nuevaFactura->setaveria(ui.textEdit->document()->toPlainText().toStdString()); 646 + 647 + if (ui.checkBox->isChecked()) { 648 + nuevaFactura->setfecha(ui.dateEdit->text().toStdString()); 649 + } else { 650 + nuevaFactura->setfecha(tr("").toStdString()); 651 + } 652 + if (ui.checkBox_4->isChecked()) { 653 + nuevaFactura->setfecha_terminacion(ui.dateEdit_2->text().toStdString()); 654 + } else { 655 + nuevaFactura->setfecha_terminacion(tr("").toStdString()); 656 + } 657 + 658 + //nuevaFactura->setfecha_terminacion(ui.lineEdit_->text()); 659 + 660 + if (!ui.checkBox_2->isChecked() && !ui.checkBox_3->isChecked()) 661 + nuevaFactura->setlugar_reparacion(0); 662 + else { 663 + bool *s = new bool; 664 + *s = ui.checkBox_2->isChecked(); 665 + nuevaFactura->setlugar_reparacion(s); 666 + } 667 + 668 + nuevaFactura->setmarca(ui.lineEdit_2->text().toStdString()); 669 + nuevaFactura->setmodelo(ui.lineEdit_3->text().toStdString()); 670 + 671 + //nuevaFactura->setn_fabricacion(ui.lineEdit_->text()); 672 + 673 + if (ui.lineEdit_4->text() == "") { 674 + nuevaFactura->setn_factura(-1); 675 + } else { 676 + nuevaFactura->setn_factura(ui.lineEdit_4->text().toInt()); 677 + } 678 + 679 + nuevaFactura->setiva(ui.lineEdit_11->text().toInt()); 680 + nuevaFactura->setobservaciones(ui.lineEdit_15->text().toStdString()); 681 + nuevaFactura->setprecio_desplazamiento(ui.lineEdit_8->text().toDouble()); 682 + nuevaFactura->setprecio_mano_obra(ui.lineEdit_7->text().toDouble()); 683 + nuevaFactura->setprecio_materiales(ui.lineEdit_6->text().toDouble()); 684 + nuevaFactura->setprecio_transporte(ui.lineEdit_9->text().toDouble()); 685 + 686 + nuevaFactura->settiempo_empleado(ui.lineEdit_5->text().toStdString()); 687 + nuevaFactura->settrabajo_realizado(ui.textEdit_2->document()->toPlainText().toStdString()); 688 + 689 + if (cliente == 0) { 690 + cliente = new Cliente(); 691 + cliente->setnombre(ui.nombreEdit->text().toStdString()); 692 + cliente->setapellidos(ui.lineEdit_13->text().toStdString()); 693 + cliente->setcodigo(ui.codigoEdit->text().toInt()); 694 + cliente->setdireccion(ui.direccionEdit->document()->toPlainText().toStdString()); 695 + cliente->setpoblacion(ui.lineEdit_14->text().toStdString()); 696 + cliente->setnif(ui.nifEdit->text().toStdString()); 697 + /** 698 + * Guardar los tel�fonos. 699 + */ 700 + list<int> telefonos; 701 + int rows = ui.tabla->rowCount(); 702 + for (int i = 0; i < rows; i++) { 703 + telefonos.push_back(ui.tabla->item(i, 0)->text().toInt()); 704 + } 705 + cliente->settelefonos(telefonos); 706 + clienteOk = capaNegocio->nuevoCliente(cliente); 707 + } else { 708 + clienteOk = true; 709 + } 710 + 711 + if (clienteOk) 712 + nuevaFactura->setcliente(cliente); 713 + else 714 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar el nuevo cliente.")); 715 + 716 + if (capaNegocio->nuevaFactura(nuevaFactura) && clienteOk) { 717 + if (padre != 0 && !dePresupuesto) 718 + padre->actualizar(); 719 + this->accept(); 720 + } else 721 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar la factura.")); 722 + } 723 + } 724 + 725 + void NuevaFacturaDialog::editar() { 726 + 727 + bool clienteOk; 728 + 729 + if (comprobarDatos()) { 730 + 731 + nuevaFactura->setaparato(ui.lineEdit->text().toStdString()); 732 + nuevaFactura->setaveria(ui.textEdit->document()->toPlainText().toStdString()); 733 + 734 + if (ui.checkBox->isChecked()) { 735 + nuevaFactura->setfecha(ui.dateEdit->text().toStdString()); 736 + } else { 737 + nuevaFactura->setfecha(tr("").toStdString()); 738 + } 739 + 740 + //nuevaFactura->setfecha_terminacion(ui.lineEdit_->text()); 741 + 742 + if (!ui.checkBox_2->isChecked() && !ui.checkBox_3->isChecked()) 743 + nuevaFactura->setlugar_reparacion(0); 744 + else { 745 + bool *s = new bool; 746 + *s = ui.checkBox_2->isChecked(); 747 + nuevaFactura->setlugar_reparacion(s); 748 + } 749 + if (ui.checkBox_4->isChecked()) { 750 + nuevaFactura->setfecha_terminacion(ui.dateEdit_2->text().toStdString()); 751 + } else { 752 + nuevaFactura->setfecha_terminacion(tr("").toStdString()); 753 + } 754 + nuevaFactura->setmarca(ui.lineEdit_2->text().toStdString()); 755 + nuevaFactura->setmodelo(ui.lineEdit_3->text().toStdString()); 756 + 757 + //nuevaFactura->setn_fabricacion(ui.lineEdit_->text()); 758 + 759 + if (ui.lineEdit_4->text() == "") { 760 + nuevaFactura->setn_factura(-1); 761 + } else { 762 + nuevaFactura->setn_factura(ui.lineEdit_4->text().toInt()); 763 + } 764 + 765 + nuevaFactura->setobservaciones(ui.lineEdit_15->text().toStdString()); 766 + nuevaFactura->setprecio_desplazamiento(ui.lineEdit_8->text().toDouble()); 767 + nuevaFactura->setprecio_mano_obra(ui.lineEdit_7->text().toDouble()); 768 + nuevaFactura->setprecio_materiales(ui.lineEdit_6->text().toDouble()); 769 + nuevaFactura->setprecio_transporte(ui.lineEdit_9->text().toDouble()); 770 + 771 + nuevaFactura->settiempo_empleado(ui.lineEdit_5->text().toStdString()); 772 + nuevaFactura->settrabajo_realizado(ui.textEdit_2->document()->toPlainText().toStdString()); 773 + 774 + if (cliente == 0) { 775 + cliente = new Cliente(); 776 + cliente->setnombre(ui.nombreEdit->text().toStdString()); 777 + cliente->setapellidos(ui.lineEdit_13->text().toStdString()); 778 + cliente->setcodigo(ui.codigoEdit->text().toInt()); 779 + cliente->setdireccion(ui.direccionEdit->document()->toPlainText().toStdString()); 780 + cliente->setpoblacion(ui.lineEdit_14->text().toStdString()); 781 + cliente->setnif(ui.nifEdit->text().toStdString()); 782 + list<int> lista_telefonos; 783 + for (int i = 0; i < ui.tabla->rowCount(); i++) { 784 + lista_telefonos.push_back(ui.tabla->item(i,0)->text().toInt()); 785 + } 786 + cliente->settelefonos(lista_telefonos); 787 + clienteOk = capaNegocio->nuevoCliente(cliente); 788 + } else { 789 + clienteOk = true; 790 + } 791 + 792 + if (clienteOk) 793 + nuevaFactura->setcliente(cliente); 794 + else 795 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar el nuevo cliente.")); 796 + 797 + if (capaNegocio->modificarFactura(nuevaFactura) && clienteOk) { 798 + if (padre != 0) 799 + padre->actualizar(); 800 + this->accept(); 801 + } else 802 + QMessageBox::critical(this, tr("Error"), tr("No se pudo editar la factura.")); 803 + } 804 + } 805 + 806 + 807 + bool NuevaFacturaDialog::editarSinSalir() { 808 + 809 + bool clienteOk; 810 + 811 + if (comprobarDatos()) { 812 + 813 + nuevaFactura->setaparato(ui.lineEdit->text().toStdString()); 814 + nuevaFactura->setaveria(ui.textEdit->document()->toPlainText().toStdString()); 815 + 816 + if (ui.checkBox->isChecked()) { 817 + nuevaFactura->setfecha(ui.dateEdit->text().toStdString()); 818 + } else { 819 + nuevaFactura->setfecha(tr("").toStdString()); 820 + } 821 + 822 + //nuevaFactura->setfecha_terminacion(ui.lineEdit_->text()); 823 + 824 + if (!ui.checkBox_2->isChecked() && !ui.checkBox_3->isChecked()) 825 + nuevaFactura->setlugar_reparacion(0); 826 + else { 827 + bool *s = new bool; 828 + *s = ui.checkBox_2->isChecked(); 829 + nuevaFactura->setlugar_reparacion(s); 830 + } 831 + 832 + nuevaFactura->setmarca(ui.lineEdit_2->text().toStdString()); 833 + nuevaFactura->setmodelo(ui.lineEdit_3->text().toStdString()); 834 + 835 + //nuevaFactura->setn_fabricacion(ui.lineEdit_->text()); 836 + 837 + if (ui.lineEdit_4->text() == "") { 838 + nuevaFactura->setn_factura(-1); 839 + } else { 840 + nuevaFactura->setn_factura(ui.lineEdit_4->text().toInt()); 841 + } 842 + 843 + nuevaFactura->setiva(ui.lineEdit_11->text().toInt()); 844 + nuevaFactura->setobservaciones(ui.textEdit->document()->toPlainText().toStdString()); 845 + nuevaFactura->setprecio_desplazamiento(ui.lineEdit_8->text().toDouble()); 846 + nuevaFactura->setprecio_mano_obra(ui.lineEdit_7->text().toDouble()); 847 + nuevaFactura->setprecio_materiales(ui.lineEdit_6->text().toDouble()); 848 + nuevaFactura->setprecio_transporte(ui.lineEdit_9->text().toDouble()); 849 + 850 + nuevaFactura->settiempo_empleado(ui.lineEdit_5->text().toStdString()); 851 + nuevaFactura->settrabajo_realizado(ui.textEdit_2->document()->toPlainText().toStdString()); 852 + 853 + if (cliente == 0) { 854 + cliente = new Cliente(); 855 + cliente->setnombre(ui.nombreEdit->text().toStdString()); 856 + cliente->setapellidos(ui.lineEdit_13->text().toStdString()); 857 + cliente->setcodigo(ui.codigoEdit->text().toInt()); 858 + cliente->setdireccion(ui.direccionEdit->document()->toPlainText().toStdString()); 859 + cliente->setpoblacion(ui.lineEdit_14->text().toStdString()); 860 + cliente->setnif(ui.nifEdit->text().toStdString()); 861 + list<int> lista_telefonos; 862 + for (int i = 0; i < ui.tabla->rowCount(); i++) { 863 + lista_telefonos.push_back(ui.tabla->item(i,0)->text().toInt()); 864 + } 865 + cliente->settelefonos(lista_telefonos); 866 + clienteOk = capaNegocio->nuevoCliente(cliente); 867 + } else { 868 + clienteOk = true; 869 + } 870 + 871 + if (clienteOk) 872 + nuevaFactura->setcliente(cliente); 873 + else 874 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar el nuevo cliente.")); 875 + 876 + if (capaNegocio->modificarFactura(nuevaFactura) && clienteOk) { 877 + if (padre != 0) 878 + padre->actualizar(); 879 + return true; 880 + //this->accept(); 881 + } else 882 + QMessageBox::critical(this, tr("Error"), tr("No se pudo editar la factura.")); 883 + } 884 + return false; 885 + } 886 + 887 + void NuevaFacturaDialog::addRowTelefono(){ 888 + int row = ui.tabla->rowCount(); 889 + ui.tabla->insertRow(row); 890 + 891 + QTableWidgetItem *item0 = new QTableWidgetItem; 892 + item0->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 893 + ui.tabla->setItem(row, 0, item0); 894 + 895 + } 896 + 897 + void NuevaFacturaDialog::nuevoTelefono () { 898 + int row = ui.tabla->currentRow(); 899 + if (row == -1) { 900 + addRowTelefono(); 901 + ui.tabla->setCurrentCell(0,0); 902 + } else if (ui.tabla->item(row,0)->text() != "") { 903 + addRowTelefono(); 904 + ui.tabla->setCurrentCell(row + 1,0); 905 + } 906 + } 907 + 908 + void NuevaFacturaDialog::borrarTelefono() { 909 + int row = ui.tabla->currentRow(); 910 + if (row == -1) 911 + QMessageBox::warning(this, "Aviso", "No se ha seleccionado ningun telefono."); 912 + else 913 + ui.tabla->removeRow(row); 914 + 915 + } 916 + 917 + // Invierte el estado de "habilitado" de los campos de cliente 918 + void NuevaFacturaDialog::cambiarCliente() { 919 + ui.nombreEdit->setEnabled(!ui.nombreEdit->isEnabled()); 920 + ui.lineEdit_13->setEnabled(!ui.lineEdit_13->isEnabled()); 921 + ui.codigoEdit->setEnabled(!ui.codigoEdit->isEnabled()); 922 + ui.direccionEdit->setEnabled(!ui.direccionEdit->isEnabled()); 923 + ui.lineEdit_14->setEnabled(!ui.lineEdit_14->isEnabled()); 924 + ui.nifEdit->setEnabled(!ui.nifEdit->isEnabled()); 925 + ui.tabla->setEnabled(!ui.tabla->isEnabled()); 926 + ui.pushButton_6->setEnabled(!ui.pushButton_6->isEnabled()); 927 + ui.pushButton_8->setEnabled(!ui.pushButton_8->isEnabled()); 928 + } 929 + 930 + void NuevaFacturaDialog::limpiar() { 931 + if (ui.nombreEdit->text() != "" ) { 932 + cambiarCliente(); 933 + } 934 + ui.nombreEdit->setText(""); 935 + ui.lineEdit_13->setText(""); 936 + ui.codigoEdit->setText(""); 937 + QString direccion; 938 + direccion.append(""); 939 + QTextDocument *direccionCompleta = new QTextDocument(direccion); 940 + ui.direccionEdit->setDocument(direccionCompleta); 941 + ui.lineEdit_14->setText(""); 942 + ui.nifEdit->setText(""); 943 + cliente = 0; 944 + while (ui.tabla->rowCount() > 0) { 945 + ui.tabla->removeRow(0); 946 + } 947 + 948 + int cod = capaNegocio->getUltimoCodigoCliente(); 949 + ui.codigoEdit->setText(QString::number(cod)); 950 + } 951 + 952 + void NuevaFacturaDialog::cambiarEstadoDomicilio() { 953 + if (ui.checkBox_2->isChecked()) { 954 + if (ui.checkBox_3->isChecked()) { 955 + ui.checkBox_3->setChecked(false); 956 + } 957 + } 958 + } 959 + 960 + void NuevaFacturaDialog::cambiarEstadoTaller() { 961 + if (ui.checkBox_3->isChecked()) { 962 + if (ui.checkBox_2->isChecked()) { 963 + ui.checkBox_2->setChecked(false); 964 + } 965 + } 966 + } 967 + 968 + void NuevaFacturaDialog::imprimir() { 969 + if (nuevaFactura->getid() == -1) { 970 + if (QMessageBox::question(this, tr("Imprimir Factura"), tr("Antes de imprimir es necesario guardar la factura.\n �Desea realmente guardarla?"),tr("Si"),tr("No")) == 0) { 971 + if(guardarSinSalir()) { 972 + PrintWindow* pq = new PrintWindow(*nuevaFactura); 973 + pq->printFactura(); 974 + this->accept(); 975 + } 976 + } 977 + } else { 978 + if (QMessageBox::question(this, tr("Imprimir Factura"), tr("Antes de imprimir es necesario guardar la factura.\n �Desea realmente guardarla?"),tr("Si"),tr("No")) == 0) { 979 + if(editarSinSalir()) { 980 + PrintWindow* pq = new PrintWindow(*nuevaFactura); 981 + pq->printFactura(); 982 + this->accept(); 983 + } 984 + } 985 + } 986 + 987 + } 988 +
+75
Gui/NuevaFacturaDialog.h
··· 1 + #ifndef NUEVAFACTURADIALOG_H 2 + #define NUEVAFACTURADIALOG_H 3 + 4 + #include <QtGui/QDialog> 5 + #include "ui_NuevaFacturaDialog.h" 6 + #include "../Negocio/CapaNegocio.h" 7 + #include "../Negocio/Factura.h" 8 + #include "../Gui/ListarFacturas.h" 9 + 10 + class ActualizadorThread; 11 + 12 + class NuevaFacturaDialog : public QDialog 13 + { 14 + Q_OBJECT 15 + 16 + public: 17 + NuevaFacturaDialog(CapaNegocio * const cn, QWidget *parent = 0, Factura *f = 0, bool dePresupuesto = false); 18 + ~NuevaFacturaDialog(); 19 + 20 + void addRow(); 21 + void addRowTelefono(); 22 + void actualizaPrecios(); 23 + void buscarCliente(); 24 + void buscarArticulo(); 25 + 26 + private: 27 + Ui::NuevaFacturaDialogClass ui; 28 + CapaNegocio *capaNegocio; 29 + 30 + list<Cliente> lClientes; 31 + list<Articulo> lArticulos; 32 + list<pair<pair<string, double>, int> > lArticuloFila; 33 + 34 + bool comprobarDatos(); 35 + void cambiarCliente(); 36 + 37 + Factura *nuevaFactura; 38 + Cliente *cliente; 39 + ListarFacturas *padre; 40 + 41 + Articulo articuloActual; 42 + 43 + ActualizadorThread *actualizador; 44 + 45 + bool dePresupuesto; 46 + 47 + private slots: 48 + 49 + void anyadirLineaArticulo(); 50 + void borrarArticulo(); 51 + void guardar(); 52 + void editar(); 53 + void limpiar(); 54 + void nuevoTelefono(); 55 + void borrarTelefono(); 56 + void cambiarEstadoDomicilio(); 57 + void cambiarEstadoTaller(); 58 + void imprimir(); 59 + bool guardarSinSalir(); 60 + bool editarSinSalir(); 61 + 62 + protected: 63 + void keyPressEvent(QKeyEvent* event); 64 + void keyReleaseEvent(QKeyEvent* event); 65 + }; 66 + 67 + class ActualizadorThread : public QThread { 68 + private: 69 + NuevaFacturaDialog *nfd; 70 + public: 71 + void run(); 72 + void setPadre(NuevaFacturaDialog *parent); 73 + }; 74 + 75 + #endif // NUEVAFACTURADIALOG_H
+690
Gui/NuevaFacturaDialog.ui
··· 1 + <ui version="4.0" > 2 + <class>NuevaFacturaDialogClass</class> 3 + <widget class="QDialog" name="NuevaFacturaDialogClass" > 4 + <property name="enabled" > 5 + <bool>true</bool> 6 + </property> 7 + <property name="geometry" > 8 + <rect> 9 + <x>0</x> 10 + <y>0</y> 11 + <width>971</width> 12 + <height>540</height> 13 + </rect> 14 + </property> 15 + <property name="windowTitle" > 16 + <string>Nueva Factura</string> 17 + </property> 18 + <property name="windowIcon" > 19 + <iconset>images/NFactura.PNG</iconset> 20 + </property> 21 + <property name="sizeGripEnabled" > 22 + <bool>true</bool> 23 + </property> 24 + <widget class="QGroupBox" name="groupBox" > 25 + <property name="geometry" > 26 + <rect> 27 + <x>10</x> 28 + <y>10</y> 29 + <width>311</width> 30 + <height>311</height> 31 + </rect> 32 + </property> 33 + <property name="title" > 34 + <string>Cliente</string> 35 + </property> 36 + <widget class="QWidget" name="gridLayout" > 37 + <property name="geometry" > 38 + <rect> 39 + <x>10</x> 40 + <y>20</y> 41 + <width>291</width> 42 + <height>285</height> 43 + </rect> 44 + </property> 45 + <layout class="QGridLayout" > 46 + <item row="0" column="0" > 47 + <widget class="QLabel" name="label" > 48 + <property name="text" > 49 + <string>Codigo:</string> 50 + </property> 51 + </widget> 52 + </item> 53 + <item row="1" column="0" > 54 + <widget class="QLabel" name="label_2" > 55 + <property name="text" > 56 + <string>Nombre:</string> 57 + </property> 58 + </widget> 59 + </item> 60 + <item row="3" column="0" > 61 + <widget class="QLabel" name="label_3" > 62 + <property name="text" > 63 + <string>Direccion:</string> 64 + </property> 65 + </widget> 66 + </item> 67 + <item row="6" column="0" > 68 + <widget class="QLabel" name="label_4" > 69 + <property name="text" > 70 + <string>NIF:</string> 71 + </property> 72 + </widget> 73 + </item> 74 + <item row="0" column="1" colspan="4" > 75 + <widget class="QLineEdit" name="codigoEdit" /> 76 + </item> 77 + <item row="1" column="1" colspan="4" > 78 + <widget class="QLineEdit" name="nombreEdit" /> 79 + </item> 80 + <item row="2" column="1" colspan="4" > 81 + <widget class="QLineEdit" name="lineEdit_13" /> 82 + </item> 83 + <item row="3" column="1" colspan="4" > 84 + <widget class="QTextEdit" name="direccionEdit" > 85 + <property name="tabChangesFocus" > 86 + <bool>true</bool> 87 + </property> 88 + </widget> 89 + </item> 90 + <item row="4" column="1" colspan="3" > 91 + <widget class="QTableWidget" name="tabla" > 92 + <column> 93 + <property name="text" > 94 + <string>Telefonos</string> 95 + </property> 96 + </column> 97 + </widget> 98 + </item> 99 + <item row="4" column="4" > 100 + <layout class="QVBoxLayout" > 101 + <item> 102 + <widget class="QPushButton" name="pushButton_6" > 103 + <property name="text" > 104 + <string>Añadir</string> 105 + </property> 106 + </widget> 107 + </item> 108 + <item> 109 + <widget class="QPushButton" name="pushButton_8" > 110 + <property name="text" > 111 + <string>Borrar</string> 112 + </property> 113 + </widget> 114 + </item> 115 + </layout> 116 + </item> 117 + <item row="5" column="1" colspan="4" > 118 + <widget class="QLineEdit" name="lineEdit_14" /> 119 + </item> 120 + <item row="6" column="1" colspan="3" > 121 + <widget class="QLineEdit" name="nifEdit" /> 122 + </item> 123 + <item row="2" column="0" > 124 + <widget class="QLabel" name="label_31" > 125 + <property name="text" > 126 + <string>Apellidos:</string> 127 + </property> 128 + </widget> 129 + </item> 130 + <item row="5" column="0" > 131 + <widget class="QLabel" name="label_32" > 132 + <property name="text" > 133 + <string>Poblacion:</string> 134 + </property> 135 + </widget> 136 + </item> 137 + <item row="6" column="4" > 138 + <widget class="QPushButton" name="pushButton_7" > 139 + <property name="text" > 140 + <string>Limpiar</string> 141 + </property> 142 + </widget> 143 + </item> 144 + </layout> 145 + </widget> 146 + </widget> 147 + <widget class="QWidget" name="gridLayout_2" > 148 + <property name="geometry" > 149 + <rect> 150 + <x>10</x> 151 + <y>330</y> 152 + <width>311</width> 153 + <height>201</height> 154 + </rect> 155 + </property> 156 + <layout class="QGridLayout" > 157 + <item row="0" column="1" colspan="2" > 158 + <widget class="QLineEdit" name="lineEdit_4" /> 159 + </item> 160 + <item row="1" column="0" > 161 + <widget class="QCheckBox" name="checkBox" > 162 + <property name="text" > 163 + <string>Fecha</string> 164 + </property> 165 + </widget> 166 + </item> 167 + <item row="1" column="1" colspan="2" > 168 + <widget class="QDateEdit" name="dateEdit" > 169 + <property name="enabled" > 170 + <bool>false</bool> 171 + </property> 172 + <property name="displayFormat" > 173 + <string>dd/MM/yyyy</string> 174 + </property> 175 + <property name="calendarPopup" > 176 + <bool>true</bool> 177 + </property> 178 + </widget> 179 + </item> 180 + <item row="2" column="0" > 181 + <widget class="QLabel" name="label_5" > 182 + <property name="text" > 183 + <string>Aparato</string> 184 + </property> 185 + </widget> 186 + </item> 187 + <item row="2" column="1" colspan="2" > 188 + <widget class="QLineEdit" name="lineEdit" /> 189 + </item> 190 + <item row="3" column="0" > 191 + <widget class="QLabel" name="label_6" > 192 + <property name="text" > 193 + <string>Marca</string> 194 + </property> 195 + </widget> 196 + </item> 197 + <item row="3" column="1" colspan="2" > 198 + <widget class="QLineEdit" name="lineEdit_2" /> 199 + </item> 200 + <item row="4" column="0" > 201 + <widget class="QLabel" name="label_7" > 202 + <property name="text" > 203 + <string>Modelo</string> 204 + </property> 205 + </widget> 206 + </item> 207 + <item row="4" column="1" colspan="2" > 208 + <widget class="QLineEdit" name="lineEdit_3" /> 209 + </item> 210 + <item row="5" column="0" > 211 + <widget class="QLabel" name="label_8" > 212 + <property name="text" > 213 + <string>Lugar de Reparacion</string> 214 + </property> 215 + </widget> 216 + </item> 217 + <item row="0" column="0" > 218 + <widget class="QLabel" name="label_10" > 219 + <property name="text" > 220 + <string>Nº Factura</string> 221 + </property> 222 + </widget> 223 + </item> 224 + <item row="5" column="1" > 225 + <widget class="QCheckBox" name="checkBox_2" > 226 + <property name="text" > 227 + <string>Domicilio</string> 228 + </property> 229 + </widget> 230 + </item> 231 + <item row="5" column="2" > 232 + <widget class="QCheckBox" name="checkBox_3" > 233 + <property name="text" > 234 + <string>Taller</string> 235 + </property> 236 + </widget> 237 + </item> 238 + </layout> 239 + </widget> 240 + <widget class="QWidget" name="verticalLayout" > 241 + <property name="geometry" > 242 + <rect> 243 + <x>330</x> 244 + <y>20</y> 245 + <width>421</width> 246 + <height>121</height> 247 + </rect> 248 + </property> 249 + <layout class="QVBoxLayout" > 250 + <item> 251 + <widget class="QLabel" name="label_9" > 252 + <property name="text" > 253 + <string>Averia observada por el cliente:</string> 254 + </property> 255 + </widget> 256 + </item> 257 + <item> 258 + <widget class="QTextEdit" name="textEdit" > 259 + <property name="tabChangesFocus" > 260 + <bool>true</bool> 261 + </property> 262 + </widget> 263 + </item> 264 + </layout> 265 + </widget> 266 + <widget class="QTableWidget" name="tableWidget" > 267 + <property name="enabled" > 268 + <bool>true</bool> 269 + </property> 270 + <property name="geometry" > 271 + <rect> 272 + <x>330</x> 273 + <y>240</y> 274 + <width>421</width> 275 + <height>211</height> 276 + </rect> 277 + </property> 278 + <property name="alternatingRowColors" > 279 + <bool>true</bool> 280 + </property> 281 + <property name="selectionMode" > 282 + <enum>QAbstractItemView::SingleSelection</enum> 283 + </property> 284 + <property name="selectionBehavior" > 285 + <enum>QAbstractItemView::SelectRows</enum> 286 + </property> 287 + <property name="rowCount" > 288 + <number>0</number> 289 + </property> 290 + <column> 291 + <property name="text" > 292 + <string>Referencia</string> 293 + </property> 294 + </column> 295 + <column> 296 + <property name="text" > 297 + <string>Denominación</string> 298 + </property> 299 + </column> 300 + <column> 301 + <property name="text" > 302 + <string>Cantidad</string> 303 + </property> 304 + </column> 305 + <column> 306 + <property name="text" > 307 + <string>Precio Unit.</string> 308 + </property> 309 + </column> 310 + <column> 311 + <property name="text" > 312 + <string>Total</string> 313 + </property> 314 + </column> 315 + </widget> 316 + <widget class="QWidget" name="gridLayout_4" > 317 + <property name="geometry" > 318 + <rect> 319 + <x>330</x> 320 + <y>150</y> 321 + <width>421</width> 322 + <height>80</height> 323 + </rect> 324 + </property> 325 + <layout class="QGridLayout" > 326 + <item row="0" column="0" > 327 + <widget class="QLabel" name="label_21" > 328 + <property name="text" > 329 + <string>Referencia</string> 330 + </property> 331 + </widget> 332 + </item> 333 + <item row="1" column="0" > 334 + <widget class="QLabel" name="label_22" > 335 + <property name="text" > 336 + <string>Denominacion</string> 337 + </property> 338 + </widget> 339 + </item> 340 + <item row="0" column="1" > 341 + <widget class="QLineEdit" name="referenciaEdit" /> 342 + </item> 343 + <item row="1" column="1" > 344 + <widget class="QLineEdit" name="descripcionEdit" /> 345 + </item> 346 + <item row="0" column="2" > 347 + <widget class="QLabel" name="label_29" > 348 + <property name="text" > 349 + <string>Cantidad</string> 350 + </property> 351 + </widget> 352 + </item> 353 + <item row="1" column="2" > 354 + <widget class="QLabel" name="label_30" > 355 + <property name="text" > 356 + <string>Precio Unitario</string> 357 + </property> 358 + </widget> 359 + </item> 360 + <item row="0" column="3" > 361 + <widget class="QSpinBox" name="cantidadEdit" > 362 + <property name="value" > 363 + <number>1</number> 364 + </property> 365 + </widget> 366 + </item> 367 + <item row="1" column="3" > 368 + <widget class="QLineEdit" name="pvpEdit" > 369 + <property name="enabled" > 370 + <bool>true</bool> 371 + </property> 372 + </widget> 373 + </item> 374 + <item row="0" column="4" colspan="2" > 375 + <widget class="QPushButton" name="pushButton_3" > 376 + <property name="text" > 377 + <string>Añadir</string> 378 + </property> 379 + </widget> 380 + </item> 381 + <item row="1" column="4" colspan="2" > 382 + <widget class="QPushButton" name="pushButton_2" > 383 + <property name="text" > 384 + <string>Borrar</string> 385 + </property> 386 + </widget> 387 + </item> 388 + </layout> 389 + </widget> 390 + <widget class="QWidget" name="verticalLayout_2" > 391 + <property name="geometry" > 392 + <rect> 393 + <x>760</x> 394 + <y>20</y> 395 + <width>201</width> 396 + <height>211</height> 397 + </rect> 398 + </property> 399 + <layout class="QVBoxLayout" > 400 + <item> 401 + <widget class="QLabel" name="label_11" > 402 + <property name="text" > 403 + <string>Trabajo realizado:</string> 404 + </property> 405 + </widget> 406 + </item> 407 + <item> 408 + <widget class="QTextEdit" name="textEdit_2" > 409 + <property name="tabChangesFocus" > 410 + <bool>true</bool> 411 + </property> 412 + </widget> 413 + </item> 414 + <item> 415 + <widget class="QLabel" name="label_12" > 416 + <property name="text" > 417 + <string>Tiempo empleado:</string> 418 + </property> 419 + </widget> 420 + </item> 421 + <item> 422 + <widget class="QLineEdit" name="lineEdit_5" /> 423 + </item> 424 + </layout> 425 + </widget> 426 + <widget class="QWidget" name="gridLayout_3" > 427 + <property name="geometry" > 428 + <rect> 429 + <x>760</x> 430 + <y>240</y> 431 + <width>201</width> 432 + <height>205</height> 433 + </rect> 434 + </property> 435 + <layout class="QGridLayout" > 436 + <item row="0" column="0" > 437 + <widget class="QLabel" name="label_13" > 438 + <property name="text" > 439 + <string>Materiales</string> 440 + </property> 441 + </widget> 442 + </item> 443 + <item row="1" column="0" > 444 + <widget class="QLabel" name="label_14" > 445 + <property name="text" > 446 + <string>Mano de Obra</string> 447 + </property> 448 + </widget> 449 + </item> 450 + <item row="0" column="1" > 451 + <widget class="QLineEdit" name="lineEdit_6" > 452 + <property name="enabled" > 453 + <bool>false</bool> 454 + </property> 455 + </widget> 456 + </item> 457 + <item row="1" column="1" > 458 + <widget class="QLineEdit" name="lineEdit_7" /> 459 + </item> 460 + <item row="2" column="0" > 461 + <widget class="QLabel" name="label_15" > 462 + <property name="text" > 463 + <string>Desplazamiento</string> 464 + </property> 465 + </widget> 466 + </item> 467 + <item row="3" column="0" > 468 + <widget class="QLabel" name="label_16" > 469 + <property name="text" > 470 + <string>Transporte</string> 471 + </property> 472 + </widget> 473 + </item> 474 + <item row="4" column="0" > 475 + <widget class="QLabel" name="label_17" > 476 + <property name="text" > 477 + <string>Subtotal</string> 478 + </property> 479 + </widget> 480 + </item> 481 + <item row="5" column="0" > 482 + <widget class="QLabel" name="label_18" > 483 + <property name="text" > 484 + <string>IVA</string> 485 + </property> 486 + </widget> 487 + </item> 488 + <item row="6" column="0" > 489 + <widget class="QLabel" name="label_19" > 490 + <property name="text" > 491 + <string>TOTAL</string> 492 + </property> 493 + </widget> 494 + </item> 495 + <item row="2" column="1" > 496 + <widget class="QLineEdit" name="lineEdit_8" /> 497 + </item> 498 + <item row="3" column="1" > 499 + <widget class="QLineEdit" name="lineEdit_9" /> 500 + </item> 501 + <item row="4" column="1" > 502 + <widget class="QLineEdit" name="lineEdit_10" /> 503 + </item> 504 + <item row="5" column="1" > 505 + <widget class="QLineEdit" name="lineEdit_11" > 506 + <property name="enabled" > 507 + <bool>false</bool> 508 + </property> 509 + </widget> 510 + </item> 511 + <item row="6" column="1" > 512 + <widget class="QLineEdit" name="lineEdit_12" /> 513 + </item> 514 + <item row="0" column="2" > 515 + <widget class="QLabel" name="label_20" > 516 + <property name="text" > 517 + <string>€</string> 518 + </property> 519 + </widget> 520 + </item> 521 + <item row="1" column="2" > 522 + <widget class="QLabel" name="label_23" > 523 + <property name="text" > 524 + <string>€</string> 525 + </property> 526 + </widget> 527 + </item> 528 + <item row="2" column="2" > 529 + <widget class="QLabel" name="label_24" > 530 + <property name="text" > 531 + <string>€</string> 532 + </property> 533 + </widget> 534 + </item> 535 + <item row="3" column="2" > 536 + <widget class="QLabel" name="label_25" > 537 + <property name="text" > 538 + <string>€</string> 539 + </property> 540 + </widget> 541 + </item> 542 + <item row="4" column="2" > 543 + <widget class="QLabel" name="label_26" > 544 + <property name="text" > 545 + <string>€</string> 546 + </property> 547 + </widget> 548 + </item> 549 + <item row="6" column="2" > 550 + <widget class="QLabel" name="label_28" > 551 + <property name="text" > 552 + <string>€</string> 553 + </property> 554 + </widget> 555 + </item> 556 + <item row="5" column="2" > 557 + <widget class="QLabel" name="label_27" > 558 + <property name="text" > 559 + <string>%</string> 560 + </property> 561 + </widget> 562 + </item> 563 + </layout> 564 + </widget> 565 + <widget class="QWidget" name="horizontalLayout_2" > 566 + <property name="geometry" > 567 + <rect> 568 + <x>330</x> 569 + <y>450</y> 570 + <width>631</width> 571 + <height>41</height> 572 + </rect> 573 + </property> 574 + <layout class="QHBoxLayout" > 575 + <item> 576 + <widget class="QLabel" name="label_33" > 577 + <property name="text" > 578 + <string>Observaciones</string> 579 + </property> 580 + </widget> 581 + </item> 582 + <item> 583 + <widget class="QLineEdit" name="lineEdit_15" /> 584 + </item> 585 + <item> 586 + <widget class="QCheckBox" name="checkBox_4" > 587 + <property name="text" > 588 + <string>Fecha Terminación</string> 589 + </property> 590 + </widget> 591 + </item> 592 + <item> 593 + <widget class="QDateEdit" name="dateEdit_2" > 594 + <property name="enabled" > 595 + <bool>false</bool> 596 + </property> 597 + <property name="calendarPopup" > 598 + <bool>true</bool> 599 + </property> 600 + </widget> 601 + </item> 602 + </layout> 603 + </widget> 604 + <widget class="QWidget" name="horizontalLayout" > 605 + <property name="geometry" > 606 + <rect> 607 + <x>490</x> 608 + <y>490</y> 609 + <width>471</width> 610 + <height>41</height> 611 + </rect> 612 + </property> 613 + <layout class="QHBoxLayout" > 614 + <item> 615 + <widget class="QPushButton" name="pushButton_5" > 616 + <property name="text" > 617 + <string>&amp;Guardar</string> 618 + </property> 619 + </widget> 620 + </item> 621 + <item> 622 + <widget class="QPushButton" name="pushButton_4" > 623 + <property name="text" > 624 + <string>&amp;Imprimir</string> 625 + </property> 626 + </widget> 627 + </item> 628 + <item> 629 + <widget class="QPushButton" name="pushButton" > 630 + <property name="text" > 631 + <string>&amp;Cancelar</string> 632 + </property> 633 + </widget> 634 + </item> 635 + </layout> 636 + </widget> 637 + </widget> 638 + <layoutdefault spacing="6" margin="11" /> 639 + <resources/> 640 + <connections> 641 + <connection> 642 + <sender>checkBox</sender> 643 + <signal>clicked(bool)</signal> 644 + <receiver>dateEdit</receiver> 645 + <slot>setEnabled(bool)</slot> 646 + <hints> 647 + <hint type="sourcelabel" > 648 + <x>109</x> 649 + <y>389</y> 650 + </hint> 651 + <hint type="destinationlabel" > 652 + <x>319</x> 653 + <y>390</y> 654 + </hint> 655 + </hints> 656 + </connection> 657 + <connection> 658 + <sender>pushButton</sender> 659 + <signal>clicked()</signal> 660 + <receiver>NuevaFacturaDialogClass</receiver> 661 + <slot>reject()</slot> 662 + <hints> 663 + <hint type="sourcelabel" > 664 + <x>959</x> 665 + <y>498</y> 666 + </hint> 667 + <hint type="destinationlabel" > 668 + <x>761</x> 669 + <y>316</y> 670 + </hint> 671 + </hints> 672 + </connection> 673 + <connection> 674 + <sender>checkBox_4</sender> 675 + <signal>clicked(bool)</signal> 676 + <receiver>dateEdit_2</receiver> 677 + <slot>setEnabled(bool)</slot> 678 + <hints> 679 + <hint type="sourcelabel" > 680 + <x>827</x> 681 + <y>472</y> 682 + </hint> 683 + <hint type="destinationlabel" > 684 + <x>912</x> 685 + <y>468</y> 686 + </hint> 687 + </hints> 688 + </connection> 689 + </connections> 690 + </ui>
+136
Gui/NuevoArticuloDialog.cpp
··· 1 + #include "NuevoArticuloDialog.h" 2 + #include "../Negocio/CapaNegocio.h" 3 + #include "../Negocio/Articulo.h" 4 + 5 + #include <QtGui> 6 + 7 + NuevoArticuloDialog::NuevoArticuloDialog(CapaNegocio * const cn,QWidget *parent, Articulo *a) 8 + : QDialog(parent) 9 + { 10 + padre = (ListarArticulos*) parent; 11 + capaNegocio = cn; 12 + ui.setupUi(this); 13 + setWindowTitle(tr("Nuevo Articulo")); 14 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/NArticulo.PNG"))); 15 + connect(ui.guardarButton, SIGNAL(clicked()), this, SLOT(guardar())); 16 + articulo = a; 17 + if (articulo) { 18 + ui.lineEdit->setText(tr("%1").arg(a->getcodigo())); 19 + ui.lineEdit_2->setText(a->getdescripcion().c_str()); 20 + ui.lineEdit_3->setText(a->getcaja().c_str()); 21 + ui.lineEdit_8->setText(tr("%1").arg(a->getdescuento())); 22 + ui.lineEdit_4->setText(tr("%1").arg(a->getexistencias())); 23 + ui.lineEdit_5->setText(tr("%1").arg(a->getexistencias_minimas())); 24 + ui.lineEdit_6->setText(tr("%1").arg(a->getpvp())); 25 + ui.lineEdit_7->setText(tr("%1").arg(a->getprecio_coste())); 26 + setWindowTitle(tr("Editar Articulo")); 27 + } 28 + } 29 + 30 + NuevoArticuloDialog::~NuevoArticuloDialog() 31 + { 32 + 33 + } 34 + 35 + bool NuevoArticuloDialog::comprobarDatos(){ 36 + //comprobar 37 + bool estado=true; 38 + if(ui.lineEdit->text()==""){ 39 + QMessageBox::information(this, tr("Atencion"), 40 + tr("El campo codigo es necesario")); 41 + estado=false; 42 + } 43 + 44 + bool ok; 45 + ui.lineEdit->text().toInt(&ok); 46 + if(!ok && ui.lineEdit->text() != ""){ 47 + QMessageBox::information(this, tr("Atencion"), 48 + tr("El campo codigo ha de ser numerico")); 49 + estado=false; 50 + } 51 + 52 + ui.lineEdit_8->text().toInt(&ok); 53 + if(!ok && ui.lineEdit_8->text() != ""){ 54 + QMessageBox::information(this, tr("Atencion"), 55 + tr("El campo descuento ha de ser numerico")); 56 + estado=false; 57 + } 58 + if (!articulo && ui.lineEdit->text() != "" && capaNegocio->getArticuloCodigo(ui.lineEdit->text().toInt()) != 0 ) { 59 + QMessageBox::information(this, tr("Atenci�n"), 60 + tr("C�digo repetido.")); 61 + estado=false; 62 + } 63 + ui.lineEdit_4->text().toInt(&ok); 64 + if(!ok && ui.lineEdit_4->text() != ""){ 65 + QMessageBox::information(this, tr("Atencion"), 66 + tr("El campo existencias ha de ser numerico")); 67 + estado=false; 68 + } 69 + 70 + ui.lineEdit_5->text().toInt(&ok); 71 + if(!ok && ui.lineEdit_5->text() != ""){ 72 + QMessageBox::information(this, tr("Atencion"), 73 + tr("El campo existencias minimas ha de ser numerico")); 74 + estado=false; 75 + } 76 + 77 + ui.lineEdit_6->text().toDouble(&ok); 78 + if(!ok && ui.lineEdit_6->text() != ""){ 79 + QMessageBox::information(this, tr("Atencion"), 80 + tr("El campo PVP ha de ser numerico")); 81 + estado=false; 82 + } 83 + 84 + ui.lineEdit_7->text().toDouble(&ok); 85 + if(!ok && ui.lineEdit_7->text() != ""){ 86 + QMessageBox::information(this, tr("Atencion"), 87 + tr("El campo precio de coste ha de ser numerico")); 88 + estado=false; 89 + } 90 + 91 + return estado; 92 + } 93 + void NuevoArticuloDialog::guardar() { 94 + if(!articulo && comprobarDatos()){ 95 + Articulo a; 96 + a.setcodigo(ui.lineEdit->text().toInt()); 97 + a.setdescripcion(ui.lineEdit_2->text().toStdString()); 98 + a.setcaja(ui.lineEdit_3->text().toStdString()); 99 + a.setdescuento(ui.lineEdit_8->text().toInt()); 100 + a.setexistencias(ui.lineEdit_4->text().toInt()); 101 + a.setexistencias_minimas(ui.lineEdit_5->text().toInt()); 102 + a.setpvp(ui.lineEdit_6->text().toDouble()); 103 + a.setprecio_coste(ui.lineEdit_7->text().toDouble()); 104 + 105 + if (capaNegocio->nuevoArticulo(&a)) { 106 + QMessageBox::information(this, tr("Atencion"), 107 + tr("Articulo guardado.")); 108 + this->close(); 109 + } else { 110 + QMessageBox::warning(this, tr("Error"), 111 + tr("Error al guardar.")); 112 + } 113 + } else if (articulo && comprobarDatos()) { 114 + Articulo a; 115 + a = *articulo; 116 + a.setcodigo(ui.lineEdit->text().toInt()); 117 + a.setdescripcion(ui.lineEdit_2->text().toStdString()); 118 + a.setcaja(ui.lineEdit_3->text().toStdString()); 119 + a.setdescuento(ui.lineEdit_8->text().toInt()); 120 + a.setexistencias(ui.lineEdit_4->text().toInt()); 121 + a.setexistencias_minimas(ui.lineEdit_5->text().toInt()); 122 + a.setpvp(ui.lineEdit_6->text().toDouble()); 123 + a.setprecio_coste(ui.lineEdit_7->text().toDouble()); 124 + 125 + if (capaNegocio->modificarArticulo(&a)) { 126 + //QMessageBox::information(this, tr("Atencion"), 127 + // tr("Articulo editado.")); 128 + padre->actualizar(); 129 + this->close(); 130 + } else { 131 + QMessageBox::warning(this, tr("Error"), 132 + tr("Error al editar.")); 133 + } 134 + } 135 + } 136 +
+28
Gui/NuevoArticuloDialog.h
··· 1 + #ifndef NUEVOARTICULODIALOG_H 2 + #define NUEVOARTICULODIALOG_H 3 + 4 + #include <QtGui/QWidget> 5 + #include "ui_NuevoArticuloDialog.h" 6 + #include "ListarArticulos.h" 7 + #include "../Negocio/CapaNegocio.h" 8 + 9 + class NuevoArticuloDialog : public QDialog 10 + { 11 + Q_OBJECT 12 + 13 + public: 14 + NuevoArticuloDialog(CapaNegocio * const cn,QWidget *parent = 0, Articulo *a=0); 15 + ~NuevoArticuloDialog(); 16 + 17 + private slots: 18 + void guardar(); 19 + 20 + private: 21 + Ui::AltaArticuloDialogClass ui; 22 + bool comprobarDatos(); 23 + CapaNegocio *capaNegocio; 24 + Articulo *articulo; 25 + ListarArticulos *padre; 26 + }; 27 + 28 + #endif // ALTAARTICULODIALOG_H
+175
Gui/NuevoArticuloDialog.ui
··· 1 + <ui version="4.0" > 2 + <class>AltaArticuloDialogClass</class> 3 + <widget class="QDialog" name="AltaArticuloDialogClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>450</width> 9 + <height>420</height> 10 + </rect> 11 + </property> 12 + <property name="font" > 13 + <font> 14 + <weight>75</weight> 15 + <bold>true</bold> 16 + </font> 17 + </property> 18 + <property name="windowTitle" > 19 + <string>Alta Articulo</string> 20 + </property> 21 + <property name="windowIcon" > 22 + <iconset>images/NArticulo.PNG</iconset> 23 + </property> 24 + <widget class="QWidget" name="gridLayout" > 25 + <property name="geometry" > 26 + <rect> 27 + <x>10</x> 28 + <y>10</y> 29 + <width>431</width> 30 + <height>181</height> 31 + </rect> 32 + </property> 33 + <layout class="QGridLayout" > 34 + <item row="0" column="0" > 35 + <widget class="QLabel" name="label" > 36 + <property name="text" > 37 + <string>Codigo</string> 38 + </property> 39 + </widget> 40 + </item> 41 + <item row="0" column="1" > 42 + <widget class="QLineEdit" name="lineEdit" /> 43 + </item> 44 + <item row="1" column="0" > 45 + <widget class="QLabel" name="label_2" > 46 + <property name="text" > 47 + <string>Descripcion</string> 48 + </property> 49 + </widget> 50 + </item> 51 + <item row="1" column="1" > 52 + <widget class="QLineEdit" name="lineEdit_2" /> 53 + </item> 54 + <item row="2" column="0" > 55 + <widget class="QLabel" name="label_3" > 56 + <property name="text" > 57 + <string>Caja</string> 58 + </property> 59 + </widget> 60 + </item> 61 + <item row="2" column="1" > 62 + <widget class="QLineEdit" name="lineEdit_3" /> 63 + </item> 64 + <item row="3" column="0" > 65 + <widget class="QLabel" name="label_8" > 66 + <property name="text" > 67 + <string>Descuento</string> 68 + </property> 69 + </widget> 70 + </item> 71 + <item row="3" column="1" > 72 + <widget class="QLineEdit" name="lineEdit_8" /> 73 + </item> 74 + </layout> 75 + </widget> 76 + <widget class="QWidget" name="gridLayout_2" > 77 + <property name="geometry" > 78 + <rect> 79 + <x>10</x> 80 + <y>190</y> 81 + <width>431</width> 82 + <height>161</height> 83 + </rect> 84 + </property> 85 + <layout class="QGridLayout" > 86 + <item row="0" column="0" > 87 + <widget class="QLabel" name="label_4" > 88 + <property name="text" > 89 + <string>Existencias</string> 90 + </property> 91 + </widget> 92 + </item> 93 + <item row="0" column="1" > 94 + <widget class="QLineEdit" name="lineEdit_4" /> 95 + </item> 96 + <item row="0" column="2" > 97 + <widget class="QLabel" name="label_5" > 98 + <property name="text" > 99 + <string>Existencias minimas</string> 100 + </property> 101 + </widget> 102 + </item> 103 + <item row="0" column="3" > 104 + <widget class="QLineEdit" name="lineEdit_5" /> 105 + </item> 106 + <item row="1" column="0" > 107 + <widget class="QLabel" name="label_6" > 108 + <property name="text" > 109 + <string>PVP</string> 110 + </property> 111 + </widget> 112 + </item> 113 + <item row="1" column="1" > 114 + <widget class="QLineEdit" name="lineEdit_6" /> 115 + </item> 116 + <item row="1" column="2" > 117 + <widget class="QLabel" name="label_7" > 118 + <property name="text" > 119 + <string>Precio Coste</string> 120 + </property> 121 + </widget> 122 + </item> 123 + <item row="1" column="3" > 124 + <widget class="QLineEdit" name="lineEdit_7" /> 125 + </item> 126 + </layout> 127 + </widget> 128 + <widget class="QWidget" name="horizontalLayout" > 129 + <property name="geometry" > 130 + <rect> 131 + <x>190</x> 132 + <y>350</y> 133 + <width>251</width> 134 + <height>61</height> 135 + </rect> 136 + </property> 137 + <layout class="QHBoxLayout" > 138 + <item> 139 + <widget class="QPushButton" name="cancelarButton" > 140 + <property name="text" > 141 + <string>Cancelar</string> 142 + </property> 143 + </widget> 144 + </item> 145 + <item> 146 + <widget class="QPushButton" name="guardarButton" > 147 + <property name="text" > 148 + <string>Guardar</string> 149 + </property> 150 + </widget> 151 + </item> 152 + </layout> 153 + </widget> 154 + </widget> 155 + <layoutdefault spacing="6" margin="11" /> 156 + <resources/> 157 + <connections> 158 + <connection> 159 + <sender>cancelarButton</sender> 160 + <signal>clicked()</signal> 161 + <receiver>AltaArticuloDialogClass</receiver> 162 + <slot>close()</slot> 163 + <hints> 164 + <hint type="sourcelabel" > 165 + <x>320</x> 166 + <y>329</y> 167 + </hint> 168 + <hint type="destinationlabel" > 169 + <x>246</x> 170 + <y>329</y> 171 + </hint> 172 + </hints> 173 + </connection> 174 + </connections> 175 + </ui>
+178
Gui/NuevoClienteDialog.cpp
··· 1 + #include "NuevoClienteDialog.h" 2 + #include "../Negocio/CapaNegocio.h" 3 + #include "../Negocio/Cliente.h" 4 + #include <QtGui> 5 + #include <string> 6 + 7 + NuevoClienteDialog::NuevoClienteDialog(CapaNegocio * const cn, QWidget *parent, Cliente *c) 8 + : QDialog(parent) 9 + { 10 + padre = (ListarClientes *)parent; 11 + capaNegocio = cn; 12 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/NCliente.PNG"))); 13 + ui.setupUi(this); 14 + connect(ui.guardarButton, SIGNAL(clicked()), this, SLOT(guardar())); 15 + connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(nuevoTelefono())); 16 + connect(ui.pushButton_2, SIGNAL(clicked()), this, SLOT(borrarTelefono())); 17 + cliente = c; 18 + 19 + int cod = capaNegocio->getUltimoCodigoCliente(); 20 + ui.lineEdit_4->setText(QString::number(cod)); 21 + 22 + if (cliente) { 23 + ui.lineEdit_4->setText(tr("%1").arg(c->getcodigo())); 24 + ui.lineEdit_5->setText(c->getnif().c_str()); 25 + ui.lineEdit->setText(c->getnombre().c_str()); 26 + ui.lineEdit_2->setText(c->getapellidos().c_str()); 27 + ui.lineEdit_3->setText(c->getdireccion().c_str()); 28 + ui.lineEdit_6->setText(c->getpoblacion().c_str()); 29 + setWindowTitle(tr("Editar Cliente")); 30 + list<int> lista_telefonos = c->gettelefonos(); 31 + list<int>::iterator it; 32 + int row; 33 + for (it = lista_telefonos.begin(), row = 0; it != lista_telefonos.end(); it++, row++) { 34 + addRow(); 35 + ui.tabla->item(row, 0)->setText(tr("%1").arg(*it)); 36 + } 37 + } else { 38 + //addRow(); 39 + } 40 + 41 + } 42 + 43 + NuevoClienteDialog::~NuevoClienteDialog() 44 + { 45 + 46 + } 47 + bool NuevoClienteDialog::comprobarDatos(){ 48 + bool estado=true; 49 + if(ui.lineEdit->text()==""){ 50 + QMessageBox::information(this, tr("Atenci�n"), 51 + tr("El campo nombre es necesario")); 52 + estado=false; 53 + } 54 + if(ui.lineEdit_2->text()==""){ 55 + QMessageBox::information(this, tr("Atenci�n"), 56 + tr("El campo apellido es necesario")); 57 + estado=false; 58 + } 59 + /*if(ui.lineEdit_5->text()==""){ 60 + QMessageBox::information(this, tr("Atenci�n"), 61 + tr("El campo NIF es necesario")); 62 + estado=false; 63 + }*/ 64 + if (!cliente && ui.lineEdit_4->text() != "" && capaNegocio->getClienteCodigo(ui.lineEdit_4->text().toInt()) != 0 ) { 65 + QMessageBox::information(this, tr("Atenci�n"), 66 + tr("C�digo repetido.")); 67 + estado=false; 68 + } 69 + bool ok; 70 + ui.lineEdit_4->text().toInt(&ok); 71 + if(!ok){ 72 + QMessageBox::information(this, tr("Atenci�n"), 73 + tr("El campo codigo ha de ser numerico")); 74 + estado=false; 75 + } 76 + int rows = ui.tabla->rowCount(); 77 + for (int i = 0; i < rows; i++) { 78 + ui.tabla->item(i,0)->text().toInt(&ok); 79 + if(!ok){ 80 + QMessageBox::information(this, tr("Atenci�n"), 81 + tr("Hay un tel�fono demasiado largo.")); 82 + estado=false; 83 + } 84 + } 85 + return estado; 86 + } 87 + void NuevoClienteDialog::guardar() { 88 + if(!cliente && comprobarDatos()){ 89 + Cliente c; 90 + c.setnombre(ui.lineEdit->text().toStdString()); 91 + c.setapellidos(ui.lineEdit_2->text().toStdString()); 92 + c.setcodigo(ui.lineEdit_4->text().toInt()); 93 + c.setnif(ui.lineEdit_5->text().toStdString()); 94 + c.setdireccion(ui.lineEdit_3->text().toStdString()); 95 + c.setpoblacion(ui.lineEdit_6->text().toStdString()); 96 + 97 + list<int> lista_telefonos; 98 + for (int i = 0; i < ui.tabla->rowCount(); i++) { 99 + lista_telefonos.push_back(ui.tabla->item(i,0)->text().toInt()); 100 + } 101 + c.settelefonos(lista_telefonos); 102 + 103 + if (capaNegocio->nuevoCliente(&c)) { 104 + //QMessageBox::information(this, tr("Atencion"), 105 + // tr("Cliente guardado.")); 106 + this->close(); 107 + } else { 108 + QMessageBox::warning(this, tr("Error"), 109 + tr("Error al guardar.")); 110 + } 111 + } else if (cliente && comprobarDatos()) { 112 + Cliente c; 113 + c = *cliente; 114 + c.setnombre(ui.lineEdit->text().toStdString()); 115 + c.setapellidos(ui.lineEdit_2->text().toStdString()); 116 + c.setcodigo(ui.lineEdit_4->text().toInt()); 117 + c.setnif(ui.lineEdit_5->text().toStdString()); 118 + c.setdireccion(ui.lineEdit_3->text().toStdString()); 119 + c.setpoblacion(ui.lineEdit_6->text().toStdString()); 120 + 121 + list<int> lista_telefonos; 122 + for (int i = 0; i < ui.tabla->rowCount(); i++) { 123 + lista_telefonos.push_back(ui.tabla->item(i,0)->text().toInt()); 124 + } 125 + c.settelefonos(lista_telefonos); 126 + 127 + if (capaNegocio->modificarCliente(&c)) { 128 + //QMessageBox::information(this, tr("Atencion"), 129 + // tr("Cliente editado.")); 130 + //padre->actualizar(); 131 + this->close(); 132 + } else { 133 + QMessageBox::warning(this, tr("Error"), 134 + tr("Error al editar.")); 135 + } 136 + } 137 + } 138 + 139 + void NuevoClienteDialog::addRow(){ 140 + int row = ui.tabla->rowCount(); 141 + ui.tabla->insertRow(row); 142 + 143 + QTableWidgetItem *item0 = new QTableWidgetItem; 144 + item0->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 145 + ui.tabla->setItem(row, 0, item0); 146 + 147 + } 148 + 149 + void NuevoClienteDialog::nuevoTelefono () { 150 + int row = ui.tabla->currentRow(); 151 + if (row == -1) { 152 + addRow(); 153 + ui.tabla->setCurrentCell(0,0); 154 + } else if (ui.tabla->item(row,0)->text() != "") { 155 + addRow(); 156 + ui.tabla->setCurrentCell(row + 1,0); 157 + } 158 + } 159 + 160 + void NuevoClienteDialog::borrarTelefono() { 161 + int row = ui.tabla->currentRow(); 162 + if (row == -1) 163 + QMessageBox::warning(this, "Aviso", "No se ha seleccionado ningun telefono."); 164 + else 165 + ui.tabla->removeRow(row); 166 + } 167 + 168 + void NuevoClienteDialog::resizeEvent(QResizeEvent *event) { 169 + ui.gridLayout->setGeometry(QRect(10, 0, event->size().width() - 40, event->size().height())); 170 + } 171 + 172 + void NuevoClienteDialog::keyPressEvent(QKeyEvent* event) { 173 + if ((event->key() == Qt::Key_Down) && ui.tabla->item(ui.tabla->currentRow(),0)->text() != "") { 174 + addRow(); 175 + ui.tabla->setCurrentCell(ui.tabla->rowCount() - 1,0); 176 + } 177 + } 178 +
+38
Gui/NuevoClienteDialog.h
··· 1 + #ifndef NUEVOCLIENTEDIALOG_H 2 + #define NUEVOCLIENTEDIALOG_H 3 + 4 + #include <QtGui/QDialog> 5 + #include "ui_NuevoClienteDialog.h" 6 + #include "../Negocio/CapaNegocio.h" 7 + #include "ListarClientes.h" 8 + #include <list> 9 + 10 + class NuevoClienteDialog : public QDialog 11 + { 12 + Q_OBJECT 13 + 14 + public: 15 + NuevoClienteDialog(CapaNegocio * const cn, QWidget *parent = 0, Cliente *c = 0); 16 + ~NuevoClienteDialog(); 17 + void addRow(); 18 + 19 + private slots: 20 + 21 + void guardar(); 22 + void nuevoTelefono(); 23 + void borrarTelefono(); 24 + 25 + protected: 26 + //Redefinicion del manejador del evento de cambio de tamanyo 27 + void resizeEvent(QResizeEvent *event); 28 + void keyPressEvent(QKeyEvent* event); 29 + 30 + private: 31 + Ui::NuevoClienteDialogClass ui; 32 + CapaNegocio *capaNegocio; 33 + Cliente *cliente; 34 + ListarClientes *padre; 35 + bool comprobarDatos(); 36 + }; 37 + 38 + #endif // NUEVOCLIENTEDIALOG_H
+169
Gui/NuevoClienteDialog.ui
··· 1 + <ui version="4.0" > 2 + <class>NuevoClienteDialogClass</class> 3 + <widget class="QDialog" name="NuevoClienteDialogClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>397</width> 9 + <height>301</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>Nuevo Cliente</string> 14 + </property> 15 + <property name="windowIcon" > 16 + <iconset>images/NCliente.PNG</iconset> 17 + </property> 18 + <widget class="QWidget" name="gridLayout" > 19 + <property name="geometry" > 20 + <rect> 21 + <x>10</x> 22 + <y>10</y> 23 + <width>371</width> 24 + <height>271</height> 25 + </rect> 26 + </property> 27 + <layout class="QGridLayout" > 28 + <item row="1" column="0" > 29 + <widget class="QLabel" name="label_2" > 30 + <property name="text" > 31 + <string>Nombre</string> 32 + </property> 33 + </widget> 34 + </item> 35 + <item row="2" column="0" > 36 + <widget class="QLabel" name="label" > 37 + <property name="text" > 38 + <string>Apellidos</string> 39 + </property> 40 + </widget> 41 + </item> 42 + <item row="0" column="1" > 43 + <widget class="QLineEdit" name="lineEdit_4" /> 44 + </item> 45 + <item row="0" column="3" colspan="2" > 46 + <widget class="QLineEdit" name="lineEdit_5" /> 47 + </item> 48 + <item row="1" column="1" colspan="4" > 49 + <widget class="QLineEdit" name="lineEdit" /> 50 + </item> 51 + <item row="2" column="1" colspan="4" > 52 + <widget class="QLineEdit" name="lineEdit_2" /> 53 + </item> 54 + <item row="0" column="0" > 55 + <widget class="QLabel" name="label_4" > 56 + <property name="text" > 57 + <string>Codigo</string> 58 + </property> 59 + </widget> 60 + </item> 61 + <item row="3" column="0" > 62 + <widget class="QLabel" name="label_3" > 63 + <property name="text" > 64 + <string>Direccion</string> 65 + </property> 66 + </widget> 67 + </item> 68 + <item row="3" column="1" colspan="4" > 69 + <widget class="QLineEdit" name="lineEdit_3" /> 70 + </item> 71 + <item row="4" column="1" colspan="4" > 72 + <widget class="QLineEdit" name="lineEdit_6" /> 73 + </item> 74 + <item row="5" column="4" > 75 + <widget class="QPushButton" name="pushButton" > 76 + <property name="text" > 77 + <string>Añadir</string> 78 + </property> 79 + </widget> 80 + </item> 81 + 82 + <item rowspan="0" row="7" column="0" colspan="2" > 83 + <widget class="QTableWidget" name="tableWidget" /> 84 + </item> 85 + <item rowspan="3" row="5" column="0" colspan="4" > 86 + <widget class="QTableWidget" name="tabla" > 87 + <column> 88 + <property name="text" > 89 + <string>Telefono</string> 90 + </property> 91 + </column> 92 + </widget> 93 + </item> 94 + <item row="6" column="4" > 95 + <widget class="QPushButton" name="pushButton_2" > 96 + <property name="text" > 97 + <string>Borrar</string> 98 + </property> 99 + </widget> 100 + </item> 101 + <item row="0" column="2" > 102 + <widget class="QLabel" name="label_5" > 103 + <property name="text" > 104 + <string>NIF</string> 105 + </property> 106 + </widget> 107 + </item> 108 + <item row="8" column="0" colspan="5" > 109 + <layout class="QHBoxLayout" > 110 + <item> 111 + <spacer> 112 + <property name="orientation" > 113 + <enum>Qt::Horizontal</enum> 114 + </property> 115 + <property name="sizeHint" > 116 + <size> 117 + <width>40</width> 118 + <height>20</height> 119 + </size> 120 + </property> 121 + </spacer> 122 + </item> 123 + <item> 124 + <widget class="QPushButton" name="cancelarButton" > 125 + <property name="text" > 126 + <string>&amp;Cancelar</string> 127 + </property> 128 + </widget> 129 + </item> 130 + <item> 131 + <widget class="QPushButton" name="guardarButton" > 132 + <property name="text" > 133 + <string>&amp;Guardar</string> 134 + </property> 135 + </widget> 136 + </item> 137 + </layout> 138 + </item> 139 + <item row="4" column="0" > 140 + <widget class="QLabel" name="label_6" > 141 + <property name="text" > 142 + <string>Poblacion</string> 143 + </property> 144 + </widget> 145 + </item> 146 + </layout> 147 + </widget> 148 + </widget> 149 + <layoutdefault spacing="6" margin="11" /> 150 + <resources/> 151 + <connections> 152 + <connection> 153 + <sender>cancelarButton</sender> 154 + <signal>clicked()</signal> 155 + <receiver>NuevoClienteDialogClass</receiver> 156 + <slot>close()</slot> 157 + <hints> 158 + <hint type="sourcelabel" > 159 + <x>264</x> 160 + <y>270</y> 161 + </hint> 162 + <hint type="destinationlabel" > 163 + <x>189</x> 164 + <y>273</y> 165 + </hint> 166 + </hints> 167 + </connection> 168 + </connections> 169 + </ui>
+24
Gui/NuevoOperarioDialog.ui
··· 1 + <ui version="4.0" > 2 + <author></author> 3 + <comment></comment> 4 + <exportmacro></exportmacro> 5 + <class>Form</class> 6 + <widget class="QWidget" name="Form" > 7 + <property name="objectName" > 8 + <string notr="true" >Form</string> 9 + </property> 10 + <property name="geometry" > 11 + <rect> 12 + <x>0</x> 13 + <y>0</y> 14 + <width>400</width> 15 + <height>300</height> 16 + </rect> 17 + </property> 18 + <property name="windowTitle" > 19 + <string>Form</string> 20 + </property> 21 + </widget> 22 + <pixmapfunction></pixmapfunction> 23 + <connections/> 24 + </ui>
+1042
Gui/NuevoPresupuestoDialog.cpp
··· 1 + #include "NuevoPresupuestoDialog.h" 2 + #include "NuevaFacturaDialog.h" 3 + #include "NuevoClienteDialog.h" 4 + #include <QRegExp> 5 + #include <list> 6 + #include <iostream> 7 + #include <QtGui> 8 + #include "PrintWindow.h" 9 + 10 + using namespace std; 11 + 12 + QMutex mutex2; 13 + 14 + void ActualizadorPreThread::setPadre(NuevoPresupuestoDialog* parent) { 15 + nfd = parent; 16 + } 17 + void ActualizadorPreThread::run() { 18 + while (true) { 19 + usleep(10000); 20 + nfd->actualizaPrecios(); 21 + } 22 + } 23 + 24 + NuevoPresupuestoDialog::NuevoPresupuestoDialog(CapaNegocio * const cn, QWidget *parent, Presupuesto *f) 25 + : QDialog(parent) 26 + { 27 + 28 + cerr << "XD" << endl; 29 + 30 + ui.setupUi(this); 31 + capaNegocio = cn; 32 + lClientes = capaNegocio->getClientes(); 33 + lArticulos = capaNegocio->getArticulos(); 34 + setWindowIcon(QIcon(QString::fromUtf8("Gui/images/NPresupuesto.PNG"))); 35 + 36 + cliente = 0; 37 + padre = 0; 38 + workspace = parent; 39 + nuevoPresupuesto = new Presupuesto(); 40 + 41 + ui.lineEdit_11->setText(tr("%1").arg(capaNegocio->obtenerIva())); 42 + QDate hoy = QDate::currentDate(); 43 + ui.dateEdit->setDate(hoy); 44 + ui.lineEdit_10->setEnabled(false); 45 + ui.lineEdit_12->setEnabled(false); 46 + 47 + ui.lineEdit_4->setText(tr("%1").arg(capaNegocio->getUltimoCodigoPresupuesto())); 48 + 49 + connect(ui.pushButton_3, SIGNAL(clicked()), this, SLOT(anyadirLineaArticulo())); 50 + connect(ui.pushButton_2, SIGNAL(clicked()), this, SLOT(borrarArticulo())); 51 + connect(ui.pushButton_7, SIGNAL(clicked()), this, SLOT(limpiar())); 52 + connect(ui.pushButton_6, SIGNAL(clicked()), this, SLOT(nuevoTelefono())); 53 + connect(ui.pushButton_8, SIGNAL(clicked()), this, SLOT(borrarTelefono())); 54 + connect(ui.pushButton_9, SIGNAL(clicked()), this, SLOT(crearFactura())); 55 + connect(ui.checkBox_2, SIGNAL(clicked()), this, SLOT(cambiarEstadoDomicilio())); 56 + connect(ui.checkBox_3, SIGNAL(clicked()), this, SLOT(cambiarEstadoTaller())); 57 + connect(ui.pushButton_4, SIGNAL(clicked()), this, SLOT(imprimir())); 58 + 59 + cerr << "XD" << endl; 60 + 61 + int cod = capaNegocio->getUltimoCodigoCliente(); 62 + ui.codigoEdit->setText(QString::number(cod)); 63 + 64 + cerr << "XD" << endl; 65 + cerr << "XD" << endl; 66 + cerr << "XD" << endl; 67 + 68 + if (f != 0) { 69 + *nuevoPresupuesto = *f; 70 + padre = (ListarPresupuestos *)parent; 71 + setWindowTitle(tr("Editar Presupuesto xD")); 72 + cliente = new Cliente(); 73 + *cliente = *(f->getcliente()); 74 + ui.nombreEdit->setText(cliente->getnombre().c_str()); 75 + ui.nombreEdit->setEnabled(false); 76 + ui.lineEdit_13->setText(cliente->getapellidos().c_str()); 77 + ui.lineEdit_13->setEnabled(false); 78 + ui.codigoEdit->setText(tr("%1").arg(cliente->getcodigo())); 79 + ui.codigoEdit->setEnabled(false); 80 + ui.pushButton_6->setEnabled(false); 81 + QString direccion; 82 + direccion.append(cliente->getdireccion().c_str()); 83 + QTextDocument *direccionCompleta = new QTextDocument(direccion); 84 + ui.direccionEdit->setDocument(direccionCompleta); 85 + ui.direccionEdit->setEnabled(false); 86 + ui.lineEdit_14->setText(cliente->getpoblacion().c_str()); 87 + ui.lineEdit_14->setEnabled(false); 88 + ui.nifEdit->setText(cliente->getnif().c_str()); 89 + ui.nifEdit->setEnabled(false); 90 + ui.lineEdit_11->setText(tr("%1").arg(f->getiva())); 91 + list<int> lista_telefonos = cliente->gettelefonos(); 92 + list<int>::iterator it2; 93 + int row; 94 + for (it2 = lista_telefonos.begin(), row = 0; it2 != lista_telefonos.end(); it2++, row++) { 95 + addRowTelefono(); 96 + ui.tabla->item(row, 0)->setText(tr("%1").arg(*it2)); 97 + } 98 + ui.tabla->setEnabled(false); 99 + 100 + 101 + ui.lineEdit_4->setText(tr("%1").arg(f->getn_factura())); 102 + if (f->getfecha()!= "") { 103 + ui.checkBox->setChecked(true); 104 + ui.dateEdit->setEnabled(true); 105 + QDate fecha = QDate::fromString(f->getfecha().c_str(), "dd/MM/yyyy"); 106 + ui.dateEdit->setDate(fecha); 107 + } 108 + ui.lineEdit->setText(f->getaparato().c_str()); 109 + ui.lineEdit_2->setText(f->getmarca().c_str()); 110 + ui.lineEdit_3->setText(f->getmodelo().c_str()); 111 + 112 + if (f->getlugar_reparacion() != 0) 113 + if (*(f->getlugar_reparacion())) { 114 + ui.checkBox_2->setChecked(true); 115 + ui.checkBox_3->setChecked(false); 116 + } else { 117 + ui.checkBox_2->setChecked(false); 118 + ui.checkBox_3->setChecked(true); 119 + } 120 + else { 121 + ui.checkBox_2->setChecked(false); 122 + ui.checkBox_3->setChecked(false); 123 + } 124 + QString averia; 125 + averia.append(f->getaveria().c_str()); 126 + QTextDocument *averiaC = new QTextDocument(averia); 127 + ui.textEdit->setDocument(averiaC); 128 + QString trabajo; 129 + trabajo.append(f->gettrabajo_realizado().c_str()); 130 + QTextDocument *trabajoC = new QTextDocument(trabajo); 131 + ui.textEdit_2->setDocument(trabajoC); 132 + ui.lineEdit_5->setText(f->gettiempo_empleado().c_str()); 133 + ui.lineEdit_6->setText(tr("%1").arg(f->getMateriales())); 134 + ui.lineEdit_7->setText(tr("%1").arg(f->getprecio_mano_obra())); 135 + ui.lineEdit_8->setText(tr("%1").arg(f->getprecio_desplazamiento())); 136 + ui.lineEdit_9->setText(tr("%1").arg(f->getprecio_transporte())); 137 + ui.lineEdit_10->setText(tr("%1").arg(f->getSubTotal())); 138 + ui.lineEdit_11->setText(tr("%1").arg(f->getiva())); 139 + ui.lineEdit_12->setText(tr("%1").arg(f->getTotal())); 140 + 141 + if (f->getfecha_terminacion()!= "") { 142 + ui.checkBox_4->setChecked(true); 143 + ui.dateEdit_2->setEnabled(true); 144 + QDate fecha = QDate::fromString(f->getfecha_terminacion().c_str(), "dd/MM/yyyy"); 145 + ui.dateEdit_2->setDate(fecha); 146 + } 147 + ui.lineEdit_15->setText(f->getobservaciones().c_str()); 148 + 149 + list<LineaArticulo> lista = f->getlista_articulos(); 150 + list<LineaArticulo>::iterator it; 151 + for (it = lista.begin(); it != lista.end(); it++) { 152 + int row = ui.tableWidget->rowCount(); 153 + int cantidad = it->getcantidad(); 154 + addRow(); 155 + ui.tableWidget->item(row, 0)->setText(tr("%1").arg(it->getarticulo().getcodigo())); 156 + ui.tableWidget->item(row, 1)->setText(it->getarticulo().getdescripcion().c_str()); 157 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad)); 158 + ui.tableWidget->item(row, 3)->setText(tr("%1").arg(it->getarticulo().getpvp())); 159 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(it->getarticulo().getpvp() * (double)cantidad)); 160 + } 161 + ui.pushButton_7->setText(tr("Modificar")); 162 + connect(ui.pushButton_5, SIGNAL(clicked()), this, SLOT(editar())); 163 + } else { 164 + connect(ui.pushButton_5, SIGNAL(clicked()), this, SLOT(guardar())); 165 + } 166 + 167 + // Cosas de hilos 168 + actualizador = new ActualizadorPreThread(); 169 + actualizador->setPadre(this); 170 + actualizador->start(); 171 + } 172 + 173 + NuevoPresupuestoDialog::~NuevoPresupuestoDialog() 174 + { 175 + actualizador->quit(); 176 + } 177 + 178 + void NuevoPresupuestoDialog::buscarCliente() { 179 + QString nombreParcial = (ui.nombreEdit->text() + "*" ) + ui.lineEdit_13->text(); 180 + QRegExp rx(nombreParcial + "*"); 181 + rx.setPatternSyntax(QRegExp::Wildcard); 182 + rx.setCaseSensitivity(Qt::CaseInsensitive); 183 + 184 + list<Cliente> lClientesEncontrados; 185 + list<Cliente>::iterator it; 186 + 187 + for (it = lClientes.begin(); it != lClientes.end(); it++) { 188 + QString nombre(((it->getnombre() + " ") + it->getapellidos()).c_str()); 189 + if (rx.exactMatch(nombre)) { 190 + lClientesEncontrados.push_back(*it); 191 + } 192 + } 193 + 194 + if (lClientesEncontrados.size() == 1) { 195 + cambiarCliente(); 196 + cliente = new Cliente(); 197 + *cliente = lClientesEncontrados.front(); 198 + ui.nombreEdit->setText(cliente->getnombre().c_str()); 199 + ui.lineEdit_13->setText(cliente->getapellidos().c_str()); 200 + ui.codigoEdit->setText(tr("%1").arg(cliente->getcodigo())); 201 + QString direccion; 202 + direccion.append(cliente->getdireccion().c_str()); 203 + QTextDocument *direccionCompleta = new QTextDocument(direccion); 204 + ui.direccionEdit->setDocument(direccionCompleta); 205 + ui.lineEdit_14->setText(cliente->getpoblacion().c_str()); 206 + ui.nifEdit->setText(cliente->getnif().c_str()); 207 + while (ui.tabla->rowCount() > 0) { 208 + ui.tabla->removeRow(0); 209 + } 210 + list<int> lista_telefonos = cliente->gettelefonos(); 211 + list<int>::iterator it; 212 + int row; 213 + for (it = lista_telefonos.begin(), row = 0; it != lista_telefonos.end(); it++, row++) { 214 + addRowTelefono(); 215 + ui.tabla->item(row, 0)->setText(tr("%1").arg(*it)); 216 + } 217 + 218 + } 219 + 220 + } 221 + 222 + void NuevoPresupuestoDialog::buscarArticulo() { 223 + 224 + QString nombreParcial = ui.descripcionEdit->text(); 225 + QRegExp rx(nombreParcial + "*"); 226 + rx.setPatternSyntax(QRegExp::Wildcard); 227 + rx.setCaseSensitivity(Qt::CaseInsensitive); 228 + 229 + list<Articulo> lArticulosEncontrados; 230 + list<Articulo>::iterator it; 231 + 232 + if (ui.referenciaEdit->hasFocus()) { 233 + for (it = lArticulos.begin(); it != lArticulos.end(); it++) { 234 + if (ui.referenciaEdit->text().toInt() == it->getcodigo()) { 235 + lArticulosEncontrados.push_back(*it); 236 + } 237 + } 238 + } else { 239 + for (it = lArticulos.begin(); it != lArticulos.end(); it++) { 240 + QString nombre((it->getdescripcion()).c_str()); 241 + if (rx.exactMatch(nombre)) { 242 + lArticulosEncontrados.push_back(*it); 243 + } 244 + } 245 + } 246 + 247 + if (lArticulosEncontrados.size() == 1) { 248 + articuloActual = lArticulosEncontrados.front(); 249 + ui.descripcionEdit->setText(articuloActual.getdescripcion().c_str()); 250 + ui.referenciaEdit->setText(tr("%1").arg(articuloActual.getcodigo())); 251 + ui.pvpEdit->setText(tr("%1").arg(articuloActual.getpvp() - articuloActual.getpvp()*(articuloActual.getdescuento() / 100.0))); 252 + ui.cantidadEdit->setValue(1); 253 + } 254 + 255 + } 256 + 257 + void NuevoPresupuestoDialog::addRow(){ 258 + int row = ui.tableWidget->rowCount(); 259 + ui.tableWidget->insertRow(row); 260 + 261 + QTableWidgetItem *item0 = new QTableWidgetItem; 262 + item0->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 263 + ui.tableWidget->setItem(row, 0, item0); 264 + 265 + QTableWidgetItem *item1 = new QTableWidgetItem; 266 + item1->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 267 + ui.tableWidget->setItem(row, 1, item1); 268 + 269 + QTableWidgetItem *item2 = new QTableWidgetItem; 270 + item2->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 271 + ui.tableWidget->setItem(row, 2, item2); 272 + 273 + QTableWidgetItem *item3 = new QTableWidgetItem; 274 + item3->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 275 + ui.tableWidget->setItem(row, 3, item3); 276 + 277 + QTableWidgetItem *item4 = new QTableWidgetItem; 278 + item4->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 279 + ui.tableWidget->setItem(row, 4, item4); 280 + } 281 + 282 + void NuevoPresupuestoDialog::anyadirLineaArticulo() { 283 + 284 + int cantidadPrev = ui.cantidadEdit->value(); 285 + buscarArticulo(); 286 + ui.cantidadEdit->setValue(cantidadPrev); 287 + 288 + if (articuloActual.getcodigo() != -1) { 289 + /** 290 + * Caso para un art�culo de la base de datos. 291 + */ 292 + int row = ui.tableWidget->rowCount(); 293 + int cantidad = ui.cantidadEdit->value(); 294 + 295 + list<pair<pair<string, double>, int> >::iterator it; 296 + for (it = lArticuloFila.begin(); it != lArticuloFila.end(); it++) { 297 + if (articuloActual.getdescripcion() == it->first.first && articuloActual.getpvp() == it->first.second) { 298 + break; 299 + } 300 + } 301 + 302 + if (it == lArticuloFila.end()) { 303 + // No encuentra 304 + addRow(); 305 + ui.tableWidget->item(row, 0)->setText(ui.referenciaEdit->text()); 306 + ui.tableWidget->item(row, 1)->setText(ui.descripcionEdit->text()); 307 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad)); 308 + ui.tableWidget->item(row, 3)->setText(ui.pvpEdit->text()); 309 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(ui.pvpEdit->text().toDouble() * (double)cantidad)); 310 + pair <string, double> tmp(articuloActual.getdescripcion(), articuloActual.getpvp()); 311 + lArticuloFila.push_back(pair<pair<string, double>, int>(tmp, row)); 312 + nuevoPresupuesto->addArticulo(articuloActual, cantidad); 313 + } else { 314 + // Encuentra 315 + row = it->second; 316 + int cantidad_prev = ui.tableWidget->item(row, 2)->text().toInt(); 317 + nuevoPresupuesto->modificarArticulo(articuloActual, cantidad_prev + cantidad); 318 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad_prev + cantidad)); 319 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(ui.pvpEdit->text().toDouble() * (double)(cantidad_prev + cantidad))); 320 + actualizaPrecios(); 321 + } 322 + 323 + actualizaPrecios(); 324 + } else if (ui.referenciaEdit->text() == "" && ui.pvpEdit->text() != "") { 325 + /** 326 + * Caso para un articulo temporal, que tendr� que guardarse en la base de datos para poder recuperar la factura, 327 + * pero con un c�digo de 0 igual que el resto. Esto supone un problema a la hora de la b�squeda, esto supondr� un 328 + */ 329 + bool ok; 330 + ui.pvpEdit->text().toDouble(&ok); 331 + if(!ok){ 332 + QMessageBox::information(this, tr("Atencion"), 333 + tr("El precio ha de ser numerico")); 334 + } else { 335 + int cantidad = ui.cantidadEdit->value(); 336 + 337 + list<pair<pair<string, double>, int> >::iterator it; 338 + for (it = lArticuloFila.begin(); it != lArticuloFila.end(); it++) { 339 + if (ui.descripcionEdit->text().toStdString() == it->first.first && ui.pvpEdit->text().toDouble() == it->first.second) { 340 + break; 341 + } 342 + } 343 + 344 + if (it == lArticuloFila.end()) { 345 + // No encuentra 346 + // Nuevo art�culo 347 + Articulo *a_tmp = capaNegocio->getArticuloDescripcionPvp(ui.descripcionEdit->text().toStdString(), ui.pvpEdit->text().toDouble()); 348 + 349 + Articulo a; 350 + a.setcodigo(0); //C�digo generico de art�culos temporales. 351 + a.setdescripcion(ui.descripcionEdit->text().toStdString()); 352 + a.setpvp(ui.pvpEdit->text().toDouble()); 353 + a.sethistorico(true); 354 + 355 + if (a_tmp != 0) { 356 + int row = ui.tableWidget->rowCount(); 357 + addRow(); 358 + ui.tableWidget->item(row, 0)->setText("0"); 359 + ui.tableWidget->item(row, 1)->setText(ui.descripcionEdit->text()); 360 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad)); 361 + ui.tableWidget->item(row, 3)->setText(ui.pvpEdit->text()); 362 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(ui.pvpEdit->text().toDouble() * (double)cantidad)); 363 + pair <string, double> tmp(a_tmp->getdescripcion(), a_tmp->getpvp()); 364 + lArticuloFila.push_back(pair<pair<string, double>, int>(tmp, row)); 365 + nuevoPresupuesto->addArticulo(*a_tmp,cantidad); 366 + actualizaPrecios(); 367 + } else { 368 + if (capaNegocio->nuevoArticulo(&a)) { 369 + int row = ui.tableWidget->rowCount(); 370 + addRow(); 371 + ui.tableWidget->item(row, 0)->setText("0"); 372 + ui.tableWidget->item(row, 1)->setText(ui.descripcionEdit->text()); 373 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad)); 374 + ui.tableWidget->item(row, 3)->setText(ui.pvpEdit->text()); 375 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(ui.pvpEdit->text().toDouble() * (double)cantidad)); 376 + pair <string, double> tmp(a.getdescripcion(), a.getpvp()); 377 + lArticuloFila.push_back(pair<pair<string, double>, int>(tmp, row)); 378 + nuevoPresupuesto->addArticulo(a,cantidad); 379 + actualizaPrecios(); 380 + } else { 381 + QMessageBox::warning(this, "Aviso", "Fallo al guardar el nuevo articulo."); 382 + } 383 + } 384 + } else { 385 + // Encuentra 386 + Articulo *a_tmp = capaNegocio->getArticuloDescripcionPvp(ui.descripcionEdit->text().toStdString(), ui.pvpEdit->text().toDouble()); 387 + cout << "[Debug]" << a_tmp->getid() << endl; 388 + int row = it->second; 389 + int cantidad_prev = ui.tableWidget->item(row, 2)->text().toInt(); 390 + nuevoPresupuesto->modificarArticulo(*a_tmp, cantidad_prev + cantidad); 391 + ui.tableWidget->item(row, 2)->setText(tr("%1").arg(cantidad_prev + cantidad)); 392 + ui.tableWidget->item(row, 4)->setText(tr("%1").arg(ui.pvpEdit->text().toDouble() * (double)(cantidad_prev + cantidad))); 393 + actualizaPrecios(); 394 + } 395 + 396 + } 397 + } else { 398 + QMessageBox::warning(this, "Aviso", "Articulo no encontrado."); 399 + } 400 + Articulo aux; 401 + articuloActual = aux; 402 + } 403 + 404 + void NuevoPresupuestoDialog::keyPressEvent(QKeyEvent* event) { 405 + if ((ui.nombreEdit->hasFocus() || ui.lineEdit_13->hasFocus()) && (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) 406 + buscarCliente(); 407 + else if ((ui.descripcionEdit->hasFocus() || ui.referenciaEdit->hasFocus() ) && (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) 408 + buscarArticulo(); 409 + } 410 + 411 + void NuevoPresupuestoDialog::borrarArticulo() { 412 + int row = ui.tableWidget->currentRow(); 413 + if (row < 0) { 414 + QMessageBox::warning(this, tr("Aviso"), tr("Ha de haber una fila seleccionada.")); 415 + return; 416 + } 417 + 418 + string des = ui.tableWidget->item(row, 1)->text().toStdString(); 419 + double pvp = ui.tableWidget->item(row, 3)->text().toDouble(); 420 + int cod = ui.tableWidget->item(row, 0)->text().toInt(); 421 + 422 + cout << "[Debug]Borrando el articulo de descripcion: " << des << endl; 423 + 424 + Articulo *a; 425 + if ( cod == 0 ) 426 + a = capaNegocio->getArticuloDescripcionPvp(des, pvp); 427 + else 428 + a = capaNegocio->getArticuloCodigo(cod); 429 + 430 + if (a == 0) { 431 + cout << "[Debug]Articulo no encontrado en la CapaNegocio" << endl; 432 + } 433 + 434 + list<pair<pair<string, double>, int> >::iterator it; 435 + for (it = lArticuloFila.begin(); it != lArticuloFila.end(); it++) { 436 + if (a->getdescripcion() == it->first.first && a->getpvp() == it->first.second) { 437 + break; 438 + } 439 + } 440 + lArticuloFila.erase(it); 441 + 442 + if (!nuevoPresupuesto->eliminarArticulo(*a)) 443 + cout << "[Debug]No se borra el articulo de la factura." << a->getid() << endl; 444 + 445 + ui.tableWidget->removeRow(row); 446 + 447 + actualizaPrecios(); 448 + } 449 + 450 + void NuevoPresupuestoDialog::actualizaPrecios() { 451 + mutex2.lock(); 452 + double materiales = nuevoPresupuesto->getMateriales(); 453 + double mano_obra = ui.lineEdit_7->text().toDouble(); 454 + double desplazamiento = ui.lineEdit_8->text().toDouble(); 455 + double transporte = ui.lineEdit_9->text().toDouble(); 456 + double subtotal = materiales + mano_obra + desplazamiento + transporte; 457 + double total = subtotal + (ui.lineEdit_11->text().toDouble() / 100.0 )*subtotal; 458 + 459 + ui.lineEdit_10->setText(tr("%1").arg(subtotal, 0, 'f', 2)); 460 + ui.lineEdit_6->setText(tr("%1").arg(materiales)); 461 + ui.lineEdit_12->setText(tr("%1").arg(total, 0, 'f', 2)); 462 + mutex2.unlock(); 463 + } 464 + bool NuevoPresupuestoDialog::comprobarDatos () { 465 + bool flag = true; 466 + if (cliente == 0) { 467 + if(ui.nombreEdit->text()==""){ 468 + QMessageBox::information(this, tr("Atencion"), 469 + tr("El campo nombre es necesario")); 470 + flag=false; 471 + } 472 + if(ui.lineEdit_13->text()==""){ 473 + QMessageBox::information(this, tr("Atencion"), 474 + tr("El campo apellido es necesario")); 475 + flag=false; 476 + } 477 + bool ok; 478 + ui.codigoEdit->text().toInt(&ok); 479 + if(!ok){ 480 + QMessageBox::information(this, tr("Atencion"), 481 + tr("El campo codigo ha de ser num�rico")); 482 + flag=false; 483 + } 484 + } 485 + bool ok; 486 + ui.lineEdit_4->text().toInt(&ok); 487 + if(!ok && ui.lineEdit_4->text() != ""){ 488 + QMessageBox::information(this, tr("Atencion"), 489 + tr("El campo codigo ha de ser num�rico")); 490 + flag=false; 491 + } 492 + ui.lineEdit_5->text().toDouble(&ok); 493 + if(!ok && ui.lineEdit_5->text() != ""){ 494 + QMessageBox::information(this, tr("Atencion"), 495 + tr("El tiempo empleado ha de ser numerico")); 496 + flag=false; 497 + } 498 + ui.lineEdit_7->text().toDouble(&ok); 499 + if(!ok && ui.lineEdit_7->text() != ""){ 500 + QMessageBox::information(this, tr("Atencion"), 501 + tr("La mano de obra ha de ser num�rica")); 502 + flag=false; 503 + } 504 + ui.lineEdit_8->text().toDouble(&ok); 505 + if(!ok && ui.lineEdit_8->text() != ""){ 506 + QMessageBox::information(this, tr("Atencion"), 507 + tr("El desplazamiento ha de ser num�rico")); 508 + flag=false; 509 + } 510 + ui.lineEdit_9->text().toDouble(&ok); 511 + if(!ok && ui.lineEdit_9->text() != ""){ 512 + QMessageBox::information(this, tr("Atencion"), 513 + tr("El transporte ha de ser num�rico")); 514 + flag=false; 515 + } 516 + if (nuevoPresupuesto->getn_factura() == -1 && ui.lineEdit_4->text() != "" && capaNegocio->getPresupuestoNumero(ui.lineEdit_4->text().toInt()) != 0 ) { 517 + QMessageBox::information(this, tr("Atenci�n"), 518 + tr("N� de presupuesto repetido.")); 519 + flag=false; 520 + } 521 + return flag; 522 + } 523 + 524 + void NuevoPresupuestoDialog::guardar() { 525 + 526 + bool clienteOk; 527 + 528 + if (comprobarDatos()) { 529 + 530 + nuevoPresupuesto->setaparato(ui.lineEdit->text().toStdString()); 531 + nuevoPresupuesto->setaveria(ui.textEdit->document()->toPlainText().toStdString()); 532 + 533 + if (ui.checkBox->isChecked()) { 534 + nuevoPresupuesto->setfecha(ui.dateEdit->text().toStdString()); 535 + } else { 536 + nuevoPresupuesto->setfecha(tr("").toStdString()); 537 + } 538 + if (ui.checkBox_4->isChecked()) { 539 + nuevoPresupuesto->setfecha_terminacion(ui.dateEdit_2->text().toStdString()); 540 + } else { 541 + nuevoPresupuesto->setfecha_terminacion(tr("").toStdString()); 542 + } 543 + //nuevoPresupuesto->setfecha_terminacion(ui.lineEdit_->text()); 544 + if (!ui.checkBox_2->isChecked() && !ui.checkBox_3->isChecked()) 545 + nuevoPresupuesto->setlugar_reparacion(0); 546 + else { 547 + bool *s = new bool; 548 + *s = ui.checkBox_2->isChecked(); 549 + nuevoPresupuesto->setlugar_reparacion(s); 550 + } 551 + nuevoPresupuesto->setmarca(ui.lineEdit_2->text().toStdString()); 552 + nuevoPresupuesto->setmodelo(ui.lineEdit_3->text().toStdString()); 553 + nuevoPresupuesto->setiva(ui.lineEdit_11->text().toDouble()); 554 + //nuevoPresupuesto->setn_fabricacion(ui.lineEdit_->text()); 555 + 556 + if (ui.lineEdit_4->text() == "") { 557 + nuevoPresupuesto->setn_factura(-1); 558 + } else { 559 + nuevoPresupuesto->setn_factura(ui.lineEdit_4->text().toInt()); 560 + } 561 + 562 + nuevoPresupuesto->setobservaciones(ui.lineEdit_15->text().toStdString()); 563 + nuevoPresupuesto->setprecio_desplazamiento(ui.lineEdit_8->text().toDouble()); 564 + nuevoPresupuesto->setprecio_mano_obra(ui.lineEdit_7->text().toDouble()); 565 + nuevoPresupuesto->setprecio_materiales(ui.lineEdit_6->text().toDouble()); 566 + nuevoPresupuesto->setprecio_transporte(ui.lineEdit_9->text().toDouble()); 567 + 568 + nuevoPresupuesto->settiempo_empleado(ui.lineEdit_5->text().toStdString()); 569 + nuevoPresupuesto->settrabajo_realizado(ui.textEdit_2->document()->toPlainText().toStdString()); 570 + 571 + nuevoPresupuesto->setaceptado(false); 572 + 573 + if (cliente == 0) { 574 + cliente = new Cliente(); 575 + cliente->setnombre(ui.nombreEdit->text().toStdString()); 576 + cliente->setapellidos(ui.lineEdit_13->text().toStdString()); 577 + cliente->setcodigo(ui.codigoEdit->text().toInt()); 578 + cliente->setdireccion(ui.direccionEdit->document()->toPlainText().toStdString()); 579 + cliente->setpoblacion(ui.lineEdit_14->text().toStdString()); 580 + cliente->setnif(ui.nifEdit->text().toStdString()); 581 + /** 582 + * Guardar los tel�fonos. 583 + */ 584 + list<int> telefonos; 585 + int rows = ui.tabla->rowCount(); 586 + for (int i = 0; i < rows; i++) { 587 + telefonos.push_back(ui.tabla->item(i, 0)->text().toInt()); 588 + } 589 + cliente->settelefonos(telefonos); 590 + clienteOk = capaNegocio->nuevoCliente(cliente); 591 + } else { 592 + clienteOk = true; 593 + } 594 + 595 + if (clienteOk) 596 + nuevoPresupuesto->setcliente(cliente); 597 + else 598 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar el nuevo cliente.")); 599 + 600 + if (capaNegocio->nuevoPresupuesto(nuevoPresupuesto) && clienteOk) { 601 + if (padre != 0) 602 + padre->actualizar(); 603 + this->accept(); 604 + } else 605 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar el presupuesto.")); 606 + } 607 + } 608 + 609 + bool NuevoPresupuestoDialog::guardarSinSalir() { 610 + 611 + bool clienteOk; 612 + 613 + if (comprobarDatos()) { 614 + 615 + nuevoPresupuesto->setaparato(ui.lineEdit->text().toStdString()); 616 + nuevoPresupuesto->setaveria(ui.textEdit->document()->toPlainText().toStdString()); 617 + 618 + if (ui.checkBox->isChecked()) { 619 + nuevoPresupuesto->setfecha(ui.dateEdit->text().toStdString()); 620 + } else { 621 + nuevoPresupuesto->setfecha(tr("").toStdString()); 622 + } 623 + if (ui.checkBox_4->isChecked()) { 624 + nuevoPresupuesto->setfecha_terminacion(ui.dateEdit_2->text().toStdString()); 625 + } else { 626 + nuevoPresupuesto->setfecha_terminacion(tr("").toStdString()); 627 + } 628 + //nuevoPresupuesto->setfecha_terminacion(ui.lineEdit_->text()); 629 + if (!ui.checkBox_2->isChecked() && !ui.checkBox_3->isChecked()) 630 + nuevoPresupuesto->setlugar_reparacion(0); 631 + else { 632 + bool *s = new bool; 633 + *s = ui.checkBox_2->isChecked(); 634 + nuevoPresupuesto->setlugar_reparacion(s); 635 + } 636 + nuevoPresupuesto->setmarca(ui.lineEdit_2->text().toStdString()); 637 + nuevoPresupuesto->setmodelo(ui.lineEdit_3->text().toStdString()); 638 + nuevoPresupuesto->setiva(ui.lineEdit_11->text().toDouble()); 639 + //nuevoPresupuesto->setn_fabricacion(ui.lineEdit_->text()); 640 + 641 + if (ui.lineEdit_4->text() == "") { 642 + nuevoPresupuesto->setn_factura(-1); 643 + } else { 644 + nuevoPresupuesto->setn_factura(ui.lineEdit_4->text().toInt()); 645 + } 646 + 647 + nuevoPresupuesto->setobservaciones(ui.lineEdit_15->text().toStdString()); 648 + nuevoPresupuesto->setprecio_desplazamiento(ui.lineEdit_8->text().toDouble()); 649 + nuevoPresupuesto->setprecio_mano_obra(ui.lineEdit_7->text().toDouble()); 650 + nuevoPresupuesto->setprecio_materiales(ui.lineEdit_6->text().toDouble()); 651 + nuevoPresupuesto->setprecio_transporte(ui.lineEdit_9->text().toDouble()); 652 + 653 + nuevoPresupuesto->settiempo_empleado(ui.lineEdit_5->text().toStdString()); 654 + nuevoPresupuesto->settrabajo_realizado(ui.textEdit_2->document()->toPlainText().toStdString()); 655 + 656 + nuevoPresupuesto->setaceptado(false); 657 + 658 + if (cliente == 0) { 659 + cliente = new Cliente(); 660 + cliente->setnombre(ui.nombreEdit->text().toStdString()); 661 + cliente->setapellidos(ui.lineEdit_13->text().toStdString()); 662 + cliente->setcodigo(ui.codigoEdit->text().toInt()); 663 + cliente->setdireccion(ui.direccionEdit->document()->toPlainText().toStdString()); 664 + cliente->setpoblacion(ui.lineEdit_14->text().toStdString()); 665 + cliente->setnif(ui.nifEdit->text().toStdString()); 666 + clienteOk = capaNegocio->nuevoCliente(cliente); 667 + } else { 668 + clienteOk = true; 669 + } 670 + 671 + if (clienteOk) 672 + nuevoPresupuesto->setcliente(cliente); 673 + else 674 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar el nuevo cliente.")); 675 + 676 + if (capaNegocio->nuevoPresupuesto(nuevoPresupuesto) && clienteOk) { 677 + if (padre != 0) 678 + padre->actualizar(); 679 + return true; 680 + //this->accept(); 681 + } else 682 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar el presupuesto.")); 683 + } 684 + return false; 685 + } 686 + 687 + void NuevoPresupuestoDialog::editar() { 688 + 689 + bool clienteOk; 690 + 691 + if (comprobarDatos()) { 692 + 693 + nuevoPresupuesto->setaparato(ui.lineEdit->text().toStdString()); 694 + nuevoPresupuesto->setaveria(ui.textEdit->document()->toPlainText().toStdString()); 695 + 696 + if (ui.checkBox->isChecked()) { 697 + nuevoPresupuesto->setfecha(ui.dateEdit->text().toStdString()); 698 + } else { 699 + nuevoPresupuesto->setfecha(tr("").toStdString()); 700 + } 701 + 702 + //nuevoPresupuesto->setfecha_terminacion(ui.lineEdit_->text()); 703 + 704 + if (!ui.checkBox_2->isChecked() && !ui.checkBox_3->isChecked()) 705 + nuevoPresupuesto->setlugar_reparacion(0); 706 + else { 707 + bool *s = new bool; 708 + *s = ui.checkBox_2->isChecked(); 709 + nuevoPresupuesto->setlugar_reparacion(s); 710 + } 711 + nuevoPresupuesto->setmarca(ui.lineEdit_2->text().toStdString()); 712 + nuevoPresupuesto->setmodelo(ui.lineEdit_3->text().toStdString()); 713 + if (ui.checkBox_4->isChecked()) { 714 + nuevoPresupuesto->setfecha_terminacion(ui.dateEdit_2->text().toStdString()); 715 + } else { 716 + nuevoPresupuesto->setfecha_terminacion(tr("").toStdString()); 717 + } 718 + //nuevoPresupuesto->setn_fabricacion(ui.lineEdit_->text()); 719 + 720 + if (ui.lineEdit_4->text() == "") { 721 + nuevoPresupuesto->setn_factura(-1); 722 + } else { 723 + nuevoPresupuesto->setn_factura(ui.lineEdit_4->text().toInt()); 724 + } 725 + 726 + nuevoPresupuesto->setobservaciones(ui.lineEdit_15->text().toStdString()); 727 + nuevoPresupuesto->setprecio_desplazamiento(ui.lineEdit_8->text().toDouble()); 728 + nuevoPresupuesto->setprecio_mano_obra(ui.lineEdit_7->text().toDouble()); 729 + nuevoPresupuesto->setprecio_materiales(ui.lineEdit_6->text().toDouble()); 730 + nuevoPresupuesto->setprecio_transporte(ui.lineEdit_9->text().toDouble()); 731 + 732 + nuevoPresupuesto->settiempo_empleado(ui.lineEdit_5->text().toStdString()); 733 + nuevoPresupuesto->settrabajo_realizado(ui.textEdit_2->document()->toPlainText().toStdString()); 734 + 735 + nuevoPresupuesto->setaceptado(false); 736 + 737 + if (cliente == 0) { 738 + cliente = new Cliente(); 739 + cliente->setnombre(ui.nombreEdit->text().toStdString()); 740 + cliente->setapellidos(ui.lineEdit_13->text().toStdString()); 741 + cliente->setcodigo(ui.codigoEdit->text().toInt()); 742 + cliente->setdireccion(ui.direccionEdit->document()->toPlainText().toStdString()); 743 + cliente->setpoblacion(ui.lineEdit_14->text().toStdString()); 744 + cliente->setnif(ui.nifEdit->text().toStdString()); 745 + list<int> lista_telefonos; 746 + for (int i = 0; i < ui.tabla->rowCount(); i++) { 747 + lista_telefonos.push_back(ui.tabla->item(i,0)->text().toInt()); 748 + } 749 + cliente->settelefonos(lista_telefonos); 750 + clienteOk = capaNegocio->nuevoCliente(cliente); 751 + } else { 752 + clienteOk = true; 753 + } 754 + 755 + if (clienteOk) 756 + nuevoPresupuesto->setcliente(cliente); 757 + else 758 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar el nuevo cliente.")); 759 + 760 + if (capaNegocio->modificarPresupuesto(nuevoPresupuesto) && clienteOk) { 761 + if (padre != 0) 762 + padre->actualizar(); 763 + this->accept(); 764 + } else 765 + QMessageBox::critical(this, tr("Error"), tr("No se pudo editar el presupuesto.")); 766 + } 767 + } 768 + 769 + bool NuevoPresupuestoDialog::editarSinSalir() { 770 + 771 + bool clienteOk; 772 + 773 + if (comprobarDatos()) { 774 + 775 + nuevoPresupuesto->setaparato(ui.lineEdit->text().toStdString()); 776 + nuevoPresupuesto->setaveria(ui.textEdit->document()->toPlainText().toStdString()); 777 + 778 + if (ui.checkBox->isChecked()) { 779 + nuevoPresupuesto->setfecha(ui.dateEdit->text().toStdString()); 780 + } else { 781 + nuevoPresupuesto->setfecha(tr("").toStdString()); 782 + } 783 + 784 + //nuevoPresupuesto->setfecha_terminacion(ui.lineEdit_->text()); 785 + 786 + if (!ui.checkBox_2->isChecked() && !ui.checkBox_3->isChecked()) 787 + nuevoPresupuesto->setlugar_reparacion(0); 788 + else { 789 + bool *s = new bool; 790 + *s = ui.checkBox_2->isChecked(); 791 + nuevoPresupuesto->setlugar_reparacion(s); 792 + } 793 + nuevoPresupuesto->setmarca(ui.lineEdit_2->text().toStdString()); 794 + nuevoPresupuesto->setmodelo(ui.lineEdit_3->text().toStdString()); 795 + if (ui.checkBox_4->isChecked()) { 796 + nuevoPresupuesto->setfecha_terminacion(ui.dateEdit_2->text().toStdString()); 797 + } else { 798 + nuevoPresupuesto->setfecha_terminacion(tr("").toStdString()); 799 + } 800 + //nuevoPresupuesto->setn_fabricacion(ui.lineEdit_->text()); 801 + 802 + if (ui.lineEdit_4->text() == "") { 803 + nuevoPresupuesto->setn_factura(-1); 804 + } else { 805 + nuevoPresupuesto->setn_factura(ui.lineEdit_4->text().toInt()); 806 + } 807 + 808 + nuevoPresupuesto->setobservaciones(ui.lineEdit_15->text().toStdString()); 809 + nuevoPresupuesto->setprecio_desplazamiento(ui.lineEdit_8->text().toDouble()); 810 + nuevoPresupuesto->setprecio_mano_obra(ui.lineEdit_7->text().toDouble()); 811 + nuevoPresupuesto->setprecio_materiales(ui.lineEdit_6->text().toDouble()); 812 + nuevoPresupuesto->setprecio_transporte(ui.lineEdit_9->text().toDouble()); 813 + 814 + nuevoPresupuesto->settiempo_empleado(ui.lineEdit_5->text().toStdString()); 815 + nuevoPresupuesto->settrabajo_realizado(ui.textEdit_2->document()->toPlainText().toStdString()); 816 + 817 + nuevoPresupuesto->setaceptado(false); 818 + 819 + if (cliente == 0) { 820 + cliente = new Cliente(); 821 + cliente->setnombre(ui.nombreEdit->text().toStdString()); 822 + cliente->setapellidos(ui.lineEdit_13->text().toStdString()); 823 + cliente->setcodigo(ui.codigoEdit->text().toInt()); 824 + cliente->setdireccion(ui.direccionEdit->document()->toPlainText().toStdString()); 825 + cliente->setpoblacion(ui.lineEdit_14->text().toStdString()); 826 + cliente->setnif(ui.nifEdit->text().toStdString()); 827 + list<int> lista_telefonos; 828 + for (int i = 0; i < ui.tabla->rowCount(); i++) { 829 + lista_telefonos.push_back(ui.tabla->item(i,0)->text().toInt()); 830 + } 831 + cliente->settelefonos(lista_telefonos); 832 + clienteOk = capaNegocio->nuevoCliente(cliente); 833 + } else { 834 + clienteOk = true; 835 + } 836 + 837 + if (clienteOk) 838 + nuevoPresupuesto->setcliente(cliente); 839 + else 840 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar el nuevo cliente.")); 841 + 842 + if (capaNegocio->modificarPresupuesto(nuevoPresupuesto) && clienteOk) { 843 + if (padre != 0) 844 + padre->actualizar(); 845 + //this->accept(); 846 + return true; 847 + } else 848 + QMessageBox::critical(this, tr("Error"), tr("No se pudo editar el presupuesto.")); 849 + } 850 + return false; 851 + } 852 + 853 + void NuevoPresupuestoDialog::addRowTelefono(){ 854 + int row = ui.tabla->rowCount(); 855 + ui.tabla->insertRow(row); 856 + 857 + QTableWidgetItem *item0 = new QTableWidgetItem; 858 + item0->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); 859 + ui.tabla->setItem(row, 0, item0); 860 + 861 + } 862 + 863 + void NuevoPresupuestoDialog::nuevoTelefono () { 864 + int row = ui.tabla->currentRow(); 865 + if (row == -1) { 866 + addRowTelefono(); 867 + ui.tabla->setCurrentCell(0,0); 868 + } else if (ui.tabla->item(row,0)->text() != "") { 869 + addRowTelefono(); 870 + ui.tabla->setCurrentCell(row + 1,0); 871 + } 872 + } 873 + 874 + void NuevoPresupuestoDialog::borrarTelefono() { 875 + int row = ui.tabla->currentRow(); 876 + if (row == -1) 877 + QMessageBox::warning(this, "Aviso", "No se ha seleccionado ningun telefono."); 878 + else 879 + ui.tabla->removeRow(row); 880 + 881 + } 882 + 883 + // Invierte el estado de "habilitado" de los campos de cliente 884 + void NuevoPresupuestoDialog::cambiarCliente() { 885 + ui.nombreEdit->setEnabled(!ui.nombreEdit->isEnabled()); 886 + ui.lineEdit_13->setEnabled(!ui.lineEdit_13->isEnabled()); 887 + ui.codigoEdit->setEnabled(!ui.codigoEdit->isEnabled()); 888 + ui.direccionEdit->setEnabled(!ui.direccionEdit->isEnabled()); 889 + ui.lineEdit_14->setEnabled(!ui.lineEdit_14->isEnabled()); 890 + ui.nifEdit->setEnabled(!ui.nifEdit->isEnabled()); 891 + ui.tabla->setEnabled(!ui.tabla->isEnabled()); 892 + ui.pushButton_6->setEnabled(!ui.pushButton_6->isEnabled()); 893 + ui.pushButton_8->setEnabled(!ui.pushButton_8->isEnabled()); 894 + } 895 + 896 + 897 + void NuevoPresupuestoDialog::limpiar() { 898 + if (ui.nombreEdit->text() != "" ) { 899 + cambiarCliente(); 900 + } 901 + ui.nombreEdit->setText(""); 902 + ui.lineEdit_13->setText(""); 903 + ui.codigoEdit->setText(""); 904 + QString direccion; 905 + direccion.append(""); 906 + QTextDocument *direccionCompleta = new QTextDocument(direccion); 907 + ui.direccionEdit->setDocument(direccionCompleta); 908 + ui.lineEdit_14->setText(""); 909 + ui.nifEdit->setText(""); 910 + cliente = 0; 911 + while (ui.tabla->rowCount() > 0) { 912 + ui.tabla->removeRow(0); 913 + } 914 + 915 + int cod = capaNegocio->getUltimoCodigoCliente(); 916 + ui.codigoEdit->setText(QString::number(cod)); 917 + } 918 + 919 + void NuevoPresupuestoDialog::crearFactura() { 920 + Factura *nuevaFactura = new Factura(); 921 + bool clienteOk; 922 + 923 + if (comprobarDatos()) { 924 + 925 + nuevoPresupuesto->setaparato(ui.lineEdit->text().toStdString()); 926 + nuevoPresupuesto->setaveria(ui.textEdit->document()->toPlainText().toStdString()); 927 + 928 + if (ui.checkBox->isChecked()) { 929 + nuevoPresupuesto->setfecha(ui.dateEdit->text().toStdString()); 930 + } else { 931 + nuevoPresupuesto->setfecha(tr("").toStdString()); 932 + } 933 + 934 + //nuevoPresupuesto->setfecha_terminacion(ui.lineEdit_->text()); 935 + 936 + /*if (ui.lineEdit_4->text() == "") { 937 + nuevoPresupuesto->setn_factura(-1); 938 + } else { 939 + nuevoPresupuesto->setn_factura(ui.lineEdit_4->text().toInt()); 940 + }*/ 941 + 942 + nuevoPresupuesto->setn_factura(capaNegocio->getUltimoCodigoFactura()); 943 + 944 + nuevoPresupuesto->setmarca(ui.lineEdit_2->text().toStdString()); 945 + nuevoPresupuesto->setmodelo(ui.lineEdit_3->text().toStdString()); 946 + 947 + //nuevoPresupuesto->setn_fabricacion(ui.lineEdit_->text()); 948 + 949 + nuevoPresupuesto->setobservaciones(ui.textEdit->document()->toPlainText().toStdString()); 950 + nuevoPresupuesto->setprecio_desplazamiento(ui.lineEdit_8->text().toDouble()); 951 + nuevoPresupuesto->setprecio_mano_obra(ui.lineEdit_7->text().toDouble()); 952 + nuevoPresupuesto->setprecio_materiales(ui.lineEdit_6->text().toDouble()); 953 + nuevoPresupuesto->setprecio_transporte(ui.lineEdit_9->text().toDouble()); 954 + 955 + nuevoPresupuesto->settiempo_empleado(ui.lineEdit_5->text().toStdString()); 956 + nuevoPresupuesto->settrabajo_realizado(ui.textEdit_2->document()->toPlainText().toStdString()); 957 + 958 + nuevoPresupuesto->setiva(ui.lineEdit_11->text().toDouble()); 959 + 960 + if (cliente == 0) { 961 + cliente = new Cliente(); 962 + cliente->setnombre(ui.nombreEdit->text().toStdString()); 963 + cliente->setapellidos(ui.lineEdit_13->text().toStdString()); 964 + cliente->setcodigo(ui.codigoEdit->text().toInt()); 965 + cliente->setdireccion(ui.direccionEdit->document()->toPlainText().toStdString()); 966 + cliente->setpoblacion(ui.lineEdit_14->text().toStdString()); 967 + cliente->setnif(ui.nifEdit->text().toStdString()); 968 + clienteOk = capaNegocio->nuevoCliente(cliente); 969 + } else { 970 + clienteOk = true; 971 + } 972 + 973 + if (clienteOk) 974 + nuevoPresupuesto->setcliente(cliente); 975 + else { 976 + QMessageBox::critical(this, tr("Error"), tr("No se pudo guardar el nuevo cliente.")); 977 + return; 978 + } 979 + nuevaFactura->setn_factura(nuevoPresupuesto->getn_factura()); 980 + nuevaFactura->setaparato(nuevoPresupuesto->getaparato()); 981 + nuevaFactura->setaveria(nuevoPresupuesto->getaveria()); 982 + nuevaFactura->setcliente(nuevoPresupuesto->getcliente()); 983 + nuevaFactura->setfecha(nuevoPresupuesto->getfecha()); 984 + nuevaFactura->setlista_articulos(nuevoPresupuesto->getlista_articulos()); 985 + nuevaFactura->setlugar_reparacion(nuevoPresupuesto->getlugar_reparacion()); 986 + nuevaFactura->setmarca(nuevoPresupuesto->getmarca()); 987 + nuevaFactura->setmodelo(nuevoPresupuesto->getmodelo()); 988 + nuevaFactura->setn_fabricacion(nuevoPresupuesto->getn_fabricacion()); 989 + nuevaFactura->setobservaciones(nuevoPresupuesto->getobservaciones()); 990 + nuevaFactura->setprecio_desplazamiento(nuevoPresupuesto->getprecio_desplazamiento()); 991 + nuevaFactura->setprecio_mano_obra(nuevoPresupuesto->getprecio_mano_obra()); 992 + nuevaFactura->setprecio_materiales(nuevoPresupuesto->getprecio_materiales()); 993 + nuevaFactura->setprecio_transporte(nuevoPresupuesto->getprecio_transporte()); 994 + nuevaFactura->settrabajo_realizado(nuevoPresupuesto->gettrabajo_realizado()); 995 + nuevaFactura->setiva(nuevoPresupuesto->getiva()); 996 + nuevaFactura->settiempo_empleado(nuevoPresupuesto->gettiempo_empleado()); 997 + NuevaFacturaDialog *nfd; 998 + if (padre != 0) 999 + nfd = new NuevaFacturaDialog(capaNegocio,padre, nuevaFactura, true); 1000 + else 1001 + nfd = new NuevaFacturaDialog(capaNegocio,workspace, nuevaFactura, true); 1002 + nfd->show(); 1003 + } 1004 + 1005 + } 1006 + 1007 + void NuevoPresupuestoDialog::cambiarEstadoDomicilio() { 1008 + if (ui.checkBox_2->isChecked()) { 1009 + if (ui.checkBox_3->isChecked()) { 1010 + ui.checkBox_3->setChecked(false); 1011 + } 1012 + } 1013 + } 1014 + 1015 + void NuevoPresupuestoDialog::cambiarEstadoTaller() { 1016 + if (ui.checkBox_3->isChecked()) { 1017 + if (ui.checkBox_2->isChecked()) { 1018 + ui.checkBox_2->setChecked(false); 1019 + } 1020 + } 1021 + } 1022 + 1023 + void NuevoPresupuestoDialog::imprimir() { 1024 + if (nuevoPresupuesto == 0) { 1025 + if (QMessageBox::question(this, tr("Imprimir Presupuesto"), tr("Antes de imprimir es necesario guardar el presupuesto.\n �Desea realmente guardarlo?"),tr("Si"),tr("No")) == 0) { 1026 + if (guardarSinSalir()) { 1027 + PrintWindow* pq = new PrintWindow(*nuevoPresupuesto); 1028 + pq->printPresupuesto(); 1029 + this->accept(); 1030 + } 1031 + } 1032 + } else { 1033 + if (QMessageBox::question(this, tr("Imprimir Presupuesto"), tr("Antes de imprimir es necesario guardar el presupuesto.\n �Desea realmente guardarlo?"),tr("Si"),tr("No")) == 0) { 1034 + if(editarSinSalir()) { 1035 + PrintWindow* pq = new PrintWindow(*nuevoPresupuesto); 1036 + pq->printPresupuesto(); 1037 + this->accept(); 1038 + } 1039 + } 1040 + } 1041 + 1042 + }
+78
Gui/NuevoPresupuestoDialog.h
··· 1 + #ifndef NUEVOPRESUPUESTODIALOG_H 2 + #define NUEVOPRESUPUESTODIALOG_H 3 + 4 + #include <QtGui/QDialog> 5 + #include "ui_NuevoPresupuestoDialog.h" 6 + #include "../Negocio/CapaNegocio.h" 7 + #include "../Negocio/Presupuesto.h" 8 + #include "../Gui/ListarPresupuestos.h" 9 + 10 + class ActualizadorPreThread; 11 + 12 + class NuevoPresupuestoDialog : public QDialog 13 + { 14 + Q_OBJECT 15 + 16 + public: 17 + NuevoPresupuestoDialog(CapaNegocio * const cn, QWidget *parent = 0, Presupuesto *f = 0); 18 + ~NuevoPresupuestoDialog(); 19 + 20 + void addRow(); 21 + void addRowTelefono(); 22 + void actualizaPrecios(); 23 + //void actualizar(); 24 + 25 + private: 26 + Ui::NuevoPresupuestoDialogClass ui; 27 + CapaNegocio *capaNegocio; 28 + QWidget *workspace; 29 + 30 + list<Cliente> lClientes; 31 + list<Articulo> lArticulos; 32 + list<pair<pair<string, double>, int> > lArticuloFila; 33 + 34 + void buscarCliente(); 35 + void buscarArticulo(); 36 + void cambiarCliente(); 37 + bool comprobarDatos(); 38 + 39 + 40 + Presupuesto *nuevoPresupuesto; 41 + Cliente *cliente; 42 + ListarPresupuestos *padre; 43 + 44 + ActualizadorPreThread *actualizador; 45 + 46 + Articulo articuloActual; 47 + 48 + private slots: 49 + 50 + void anyadirLineaArticulo(); 51 + void borrarArticulo(); 52 + void guardar(); 53 + void editar(); 54 + void limpiar(); 55 + void nuevoTelefono(); 56 + void borrarTelefono(); 57 + void crearFactura(); 58 + void cambiarEstadoDomicilio(); 59 + void cambiarEstadoTaller(); 60 + 61 + void imprimir(); 62 + bool guardarSinSalir(); 63 + bool editarSinSalir(); 64 + 65 + protected: 66 + void keyPressEvent(QKeyEvent* event); 67 + 68 + }; 69 + 70 + class ActualizadorPreThread : public QThread { 71 + private: 72 + NuevoPresupuestoDialog *nfd; 73 + public: 74 + void run(); 75 + void setPadre(NuevoPresupuestoDialog *parent); 76 + }; 77 + 78 + #endif // NUEVOPRESUPUESTODIALOG_H
+701
Gui/NuevoPresupuestoDialog.ui
··· 1 + <ui version="4.0" > 2 + <class>NuevoPresupuestoDialogClass</class> 3 + <widget class="QDialog" name="NuevoPresupuestoDialogClass" > 4 + <property name="enabled" > 5 + <bool>true</bool> 6 + </property> 7 + <property name="geometry" > 8 + <rect> 9 + <x>0</x> 10 + <y>0</y> 11 + <width>970</width> 12 + <height>540</height> 13 + </rect> 14 + </property> 15 + <property name="windowTitle" > 16 + <string>Nuevo Presupuesto</string> 17 + </property> 18 + <property name="windowIcon" > 19 + <iconset>images/NPresupuesto.PNG</iconset> 20 + </property> 21 + <property name="sizeGripEnabled" > 22 + <bool>true</bool> 23 + </property> 24 + <widget class="QGroupBox" name="groupBox" > 25 + <property name="geometry" > 26 + <rect> 27 + <x>10</x> 28 + <y>10</y> 29 + <width>311</width> 30 + <height>311</height> 31 + </rect> 32 + </property> 33 + <property name="title" > 34 + <string>Cliente</string> 35 + </property> 36 + <widget class="QWidget" name="gridLayout" > 37 + <property name="geometry" > 38 + <rect> 39 + <x>10</x> 40 + <y>20</y> 41 + <width>291</width> 42 + <height>285</height> 43 + </rect> 44 + </property> 45 + <layout class="QGridLayout" > 46 + <item row="0" column="0" > 47 + <widget class="QLabel" name="label" > 48 + <property name="text" > 49 + <string>Codigo:</string> 50 + </property> 51 + </widget> 52 + </item> 53 + <item row="1" column="0" > 54 + <widget class="QLabel" name="label_2" > 55 + <property name="text" > 56 + <string>Nombre:</string> 57 + </property> 58 + </widget> 59 + </item> 60 + <item row="3" column="0" > 61 + <widget class="QLabel" name="label_3" > 62 + <property name="text" > 63 + <string>Direccion:</string> 64 + </property> 65 + </widget> 66 + </item> 67 + <item row="6" column="0" > 68 + <widget class="QLabel" name="label_4" > 69 + <property name="text" > 70 + <string>NIF:</string> 71 + </property> 72 + </widget> 73 + </item> 74 + <item row="0" column="1" colspan="4" > 75 + <widget class="QLineEdit" name="codigoEdit" /> 76 + </item> 77 + <item row="1" column="1" colspan="4" > 78 + <widget class="QLineEdit" name="nombreEdit" /> 79 + </item> 80 + <item row="2" column="1" colspan="4" > 81 + <widget class="QLineEdit" name="lineEdit_13" /> 82 + </item> 83 + <item row="3" column="1" colspan="4" > 84 + <widget class="QTextEdit" name="direccionEdit" > 85 + <property name="tabChangesFocus" > 86 + <bool>true</bool> 87 + </property> 88 + </widget> 89 + </item> 90 + <item row="4" column="1" colspan="3" > 91 + <widget class="QTableWidget" name="tabla" > 92 + <column> 93 + <property name="text" > 94 + <string>Telefonos</string> 95 + </property> 96 + </column> 97 + </widget> 98 + </item> 99 + <item row="4" column="4" > 100 + <layout class="QVBoxLayout" > 101 + <item> 102 + <widget class="QPushButton" name="pushButton_6" > 103 + <property name="text" > 104 + <string>Añadir</string> 105 + </property> 106 + </widget> 107 + </item> 108 + <item> 109 + <widget class="QPushButton" name="pushButton_8" > 110 + <property name="text" > 111 + <string>Borrar</string> 112 + </property> 113 + </widget> 114 + </item> 115 + </layout> 116 + </item> 117 + <item row="5" column="1" colspan="4" > 118 + <widget class="QLineEdit" name="lineEdit_14" /> 119 + </item> 120 + <item row="6" column="1" colspan="3" > 121 + <widget class="QLineEdit" name="nifEdit" /> 122 + </item> 123 + <item row="2" column="0" > 124 + <widget class="QLabel" name="label_31" > 125 + <property name="text" > 126 + <string>Apellidos:</string> 127 + </property> 128 + </widget> 129 + </item> 130 + <item row="5" column="0" > 131 + <widget class="QLabel" name="label_32" > 132 + <property name="text" > 133 + <string>Poblacion:</string> 134 + </property> 135 + </widget> 136 + </item> 137 + <item row="6" column="4" > 138 + <widget class="QPushButton" name="pushButton_7" > 139 + <property name="text" > 140 + <string>Limpiar</string> 141 + </property> 142 + </widget> 143 + </item> 144 + </layout> 145 + </widget> 146 + </widget> 147 + <widget class="QWidget" name="gridLayout_2" > 148 + <property name="geometry" > 149 + <rect> 150 + <x>10</x> 151 + <y>330</y> 152 + <width>311</width> 153 + <height>201</height> 154 + </rect> 155 + </property> 156 + <layout class="QGridLayout" > 157 + <item row="1" column="1" colspan="2" > 158 + <widget class="QDateEdit" name="dateEdit" > 159 + <property name="enabled" > 160 + <bool>false</bool> 161 + </property> 162 + <property name="displayFormat" > 163 + <string>dd/MM/yyyy</string> 164 + </property> 165 + <property name="calendarPopup" > 166 + <bool>true</bool> 167 + </property> 168 + </widget> 169 + </item> 170 + <item row="1" column="0" > 171 + <widget class="QCheckBox" name="checkBox" > 172 + <property name="text" > 173 + <string>Fecha</string> 174 + </property> 175 + </widget> 176 + </item> 177 + <item row="2" column="0" > 178 + <widget class="QLabel" name="label_5" > 179 + <property name="text" > 180 + <string>Aparato</string> 181 + </property> 182 + </widget> 183 + </item> 184 + <item row="2" column="1" colspan="2" > 185 + <widget class="QLineEdit" name="lineEdit" /> 186 + </item> 187 + <item row="3" column="0" > 188 + <widget class="QLabel" name="label_6" > 189 + <property name="text" > 190 + <string>Marca</string> 191 + </property> 192 + </widget> 193 + </item> 194 + <item row="3" column="1" colspan="2" > 195 + <widget class="QLineEdit" name="lineEdit_2" /> 196 + </item> 197 + <item row="4" column="0" > 198 + <widget class="QLabel" name="label_7" > 199 + <property name="text" > 200 + <string>Modelo</string> 201 + </property> 202 + </widget> 203 + </item> 204 + <item row="4" column="1" colspan="2" > 205 + <widget class="QLineEdit" name="lineEdit_3" /> 206 + </item> 207 + <item row="5" column="0" > 208 + <widget class="QLabel" name="label_8" > 209 + <property name="text" > 210 + <string>Lugar de Reparacion</string> 211 + </property> 212 + </widget> 213 + </item> 214 + <item row="0" column="0" > 215 + <widget class="QLabel" name="label_10" > 216 + <property name="text" > 217 + <string>Nº Presupuesto</string> 218 + </property> 219 + </widget> 220 + </item> 221 + <item row="0" column="1" colspan="2" > 222 + <widget class="QLineEdit" name="lineEdit_4" > 223 + <property name="enabled" > 224 + <bool>false</bool> 225 + </property> 226 + </widget> 227 + </item> 228 + <item row="5" column="1" > 229 + <widget class="QCheckBox" name="checkBox_2" > 230 + <property name="text" > 231 + <string>Domicilio</string> 232 + </property> 233 + </widget> 234 + </item> 235 + <item row="5" column="2" > 236 + <widget class="QCheckBox" name="checkBox_3" > 237 + <property name="text" > 238 + <string>Taller</string> 239 + </property> 240 + </widget> 241 + </item> 242 + </layout> 243 + </widget> 244 + <widget class="QWidget" name="verticalLayout" > 245 + <property name="geometry" > 246 + <rect> 247 + <x>330</x> 248 + <y>20</y> 249 + <width>421</width> 250 + <height>121</height> 251 + </rect> 252 + </property> 253 + <layout class="QVBoxLayout" > 254 + <item> 255 + <widget class="QLabel" name="label_9" > 256 + <property name="text" > 257 + <string>Averia observada por el cliente:</string> 258 + </property> 259 + </widget> 260 + </item> 261 + <item> 262 + <widget class="QTextEdit" name="textEdit" > 263 + <property name="tabChangesFocus" > 264 + <bool>true</bool> 265 + </property> 266 + </widget> 267 + </item> 268 + </layout> 269 + </widget> 270 + <widget class="QWidget" name="gridLayout_4" > 271 + <property name="geometry" > 272 + <rect> 273 + <x>330</x> 274 + <y>150</y> 275 + <width>421</width> 276 + <height>80</height> 277 + </rect> 278 + </property> 279 + <layout class="QGridLayout" > 280 + <item row="0" column="0" > 281 + <widget class="QLabel" name="label_21" > 282 + <property name="text" > 283 + <string>Referencia</string> 284 + </property> 285 + </widget> 286 + </item> 287 + <item row="1" column="0" > 288 + <widget class="QLabel" name="label_22" > 289 + <property name="text" > 290 + <string>Denominacion</string> 291 + </property> 292 + </widget> 293 + </item> 294 + <item row="0" column="1" > 295 + <widget class="QLineEdit" name="referenciaEdit" /> 296 + </item> 297 + <item row="1" column="1" > 298 + <widget class="QLineEdit" name="descripcionEdit" /> 299 + </item> 300 + <item row="0" column="2" > 301 + <widget class="QLabel" name="label_29" > 302 + <property name="text" > 303 + <string>Cantidad</string> 304 + </property> 305 + </widget> 306 + </item> 307 + <item row="1" column="2" > 308 + <widget class="QLabel" name="label_30" > 309 + <property name="text" > 310 + <string>Precio Unitario</string> 311 + </property> 312 + </widget> 313 + </item> 314 + <item row="0" column="3" > 315 + <widget class="QSpinBox" name="cantidadEdit" > 316 + <property name="value" > 317 + <number>1</number> 318 + </property> 319 + </widget> 320 + </item> 321 + <item row="1" column="3" > 322 + <widget class="QLineEdit" name="pvpEdit" > 323 + <property name="enabled" > 324 + <bool>true</bool> 325 + </property> 326 + </widget> 327 + </item> 328 + <item row="0" column="4" colspan="2" > 329 + <widget class="QPushButton" name="pushButton_3" > 330 + <property name="text" > 331 + <string>Añadir</string> 332 + </property> 333 + </widget> 334 + </item> 335 + <item row="1" column="4" colspan="2" > 336 + <widget class="QPushButton" name="pushButton_2" > 337 + <property name="text" > 338 + <string>Borrar</string> 339 + </property> 340 + </widget> 341 + </item> 342 + </layout> 343 + </widget> 344 + <widget class="QTableWidget" name="tableWidget" > 345 + <property name="enabled" > 346 + <bool>true</bool> 347 + </property> 348 + <property name="geometry" > 349 + <rect> 350 + <x>330</x> 351 + <y>240</y> 352 + <width>421</width> 353 + <height>211</height> 354 + </rect> 355 + </property> 356 + <property name="alternatingRowColors" > 357 + <bool>true</bool> 358 + </property> 359 + <property name="selectionMode" > 360 + <enum>QAbstractItemView::SingleSelection</enum> 361 + </property> 362 + <property name="selectionBehavior" > 363 + <enum>QAbstractItemView::SelectRows</enum> 364 + </property> 365 + <property name="rowCount" > 366 + <number>0</number> 367 + </property> 368 + <column> 369 + <property name="text" > 370 + <string>Referencia</string> 371 + </property> 372 + </column> 373 + <column> 374 + <property name="text" > 375 + <string>Denominación</string> 376 + </property> 377 + </column> 378 + <column> 379 + <property name="text" > 380 + <string>Cantidad</string> 381 + </property> 382 + </column> 383 + <column> 384 + <property name="text" > 385 + <string>Precio Unit.</string> 386 + </property> 387 + </column> 388 + <column> 389 + <property name="text" > 390 + <string>Total</string> 391 + </property> 392 + </column> 393 + </widget> 394 + <widget class="QWidget" name="verticalLayout_2" > 395 + <property name="geometry" > 396 + <rect> 397 + <x>760</x> 398 + <y>20</y> 399 + <width>201</width> 400 + <height>211</height> 401 + </rect> 402 + </property> 403 + <layout class="QVBoxLayout" > 404 + <item> 405 + <widget class="QLabel" name="label_11" > 406 + <property name="text" > 407 + <string>Trabajo ha realizar:</string> 408 + </property> 409 + </widget> 410 + </item> 411 + <item> 412 + <widget class="QTextEdit" name="textEdit_2" > 413 + <property name="tabChangesFocus" > 414 + <bool>true</bool> 415 + </property> 416 + </widget> 417 + </item> 418 + <item> 419 + <widget class="QLabel" name="label_12" > 420 + <property name="text" > 421 + <string>Tiempo empleado:</string> 422 + </property> 423 + </widget> 424 + </item> 425 + <item> 426 + <widget class="QLineEdit" name="lineEdit_5" /> 427 + </item> 428 + </layout> 429 + </widget> 430 + <widget class="QWidget" name="gridLayout_3" > 431 + <property name="geometry" > 432 + <rect> 433 + <x>760</x> 434 + <y>240</y> 435 + <width>201</width> 436 + <height>205</height> 437 + </rect> 438 + </property> 439 + <layout class="QGridLayout" > 440 + <item row="0" column="0" > 441 + <widget class="QLabel" name="label_13" > 442 + <property name="text" > 443 + <string>Materiales</string> 444 + </property> 445 + </widget> 446 + </item> 447 + <item row="1" column="0" > 448 + <widget class="QLabel" name="label_14" > 449 + <property name="text" > 450 + <string>Mano de Obra</string> 451 + </property> 452 + </widget> 453 + </item> 454 + <item row="0" column="1" > 455 + <widget class="QLineEdit" name="lineEdit_6" > 456 + <property name="enabled" > 457 + <bool>false</bool> 458 + </property> 459 + </widget> 460 + </item> 461 + <item row="1" column="1" > 462 + <widget class="QLineEdit" name="lineEdit_7" /> 463 + </item> 464 + <item row="2" column="0" > 465 + <widget class="QLabel" name="label_15" > 466 + <property name="text" > 467 + <string>Desplazamiento</string> 468 + </property> 469 + </widget> 470 + </item> 471 + <item row="3" column="0" > 472 + <widget class="QLabel" name="label_16" > 473 + <property name="text" > 474 + <string>Transporte</string> 475 + </property> 476 + </widget> 477 + </item> 478 + <item row="4" column="0" > 479 + <widget class="QLabel" name="label_17" > 480 + <property name="text" > 481 + <string>Subtotal</string> 482 + </property> 483 + </widget> 484 + </item> 485 + <item row="5" column="0" > 486 + <widget class="QLabel" name="label_18" > 487 + <property name="text" > 488 + <string>IVA</string> 489 + </property> 490 + </widget> 491 + </item> 492 + <item row="6" column="0" > 493 + <widget class="QLabel" name="label_19" > 494 + <property name="text" > 495 + <string>TOTAL</string> 496 + </property> 497 + </widget> 498 + </item> 499 + <item row="2" column="1" > 500 + <widget class="QLineEdit" name="lineEdit_8" /> 501 + </item> 502 + <item row="3" column="1" > 503 + <widget class="QLineEdit" name="lineEdit_9" /> 504 + </item> 505 + <item row="4" column="1" > 506 + <widget class="QLineEdit" name="lineEdit_10" /> 507 + </item> 508 + <item row="5" column="1" > 509 + <widget class="QLineEdit" name="lineEdit_11" > 510 + <property name="enabled" > 511 + <bool>false</bool> 512 + </property> 513 + </widget> 514 + </item> 515 + <item row="6" column="1" > 516 + <widget class="QLineEdit" name="lineEdit_12" /> 517 + </item> 518 + <item row="0" column="2" > 519 + <widget class="QLabel" name="label_20" > 520 + <property name="text" > 521 + <string>€</string> 522 + </property> 523 + </widget> 524 + </item> 525 + <item row="1" column="2" > 526 + <widget class="QLabel" name="label_23" > 527 + <property name="text" > 528 + <string>€</string> 529 + </property> 530 + </widget> 531 + </item> 532 + <item row="2" column="2" > 533 + <widget class="QLabel" name="label_24" > 534 + <property name="text" > 535 + <string>€</string> 536 + </property> 537 + </widget> 538 + </item> 539 + <item row="3" column="2" > 540 + <widget class="QLabel" name="label_25" > 541 + <property name="text" > 542 + <string>€</string> 543 + </property> 544 + </widget> 545 + </item> 546 + <item row="4" column="2" > 547 + <widget class="QLabel" name="label_26" > 548 + <property name="text" > 549 + <string>€</string> 550 + </property> 551 + </widget> 552 + </item> 553 + <item row="6" column="2" > 554 + <widget class="QLabel" name="label_28" > 555 + <property name="text" > 556 + <string>€</string> 557 + </property> 558 + </widget> 559 + </item> 560 + <item row="5" column="2" > 561 + <widget class="QLabel" name="label_27" > 562 + <property name="text" > 563 + <string>%</string> 564 + </property> 565 + </widget> 566 + </item> 567 + </layout> 568 + </widget> 569 + <widget class="QWidget" name="horizontalLayout_2" > 570 + <property name="geometry" > 571 + <rect> 572 + <x>330</x> 573 + <y>450</y> 574 + <width>631</width> 575 + <height>41</height> 576 + </rect> 577 + </property> 578 + <layout class="QHBoxLayout" > 579 + <item> 580 + <widget class="QLabel" name="label_33" > 581 + <property name="text" > 582 + <string>Observaciones</string> 583 + </property> 584 + </widget> 585 + </item> 586 + <item> 587 + <widget class="QLineEdit" name="lineEdit_15" /> 588 + </item> 589 + <item> 590 + <widget class="QCheckBox" name="checkBox_4" > 591 + <property name="text" > 592 + <string>Fecha Terminación</string> 593 + </property> 594 + </widget> 595 + </item> 596 + <item> 597 + <widget class="QDateEdit" name="dateEdit_2" > 598 + <property name="enabled" > 599 + <bool>false</bool> 600 + </property> 601 + <property name="calendarPopup" > 602 + <bool>true</bool> 603 + </property> 604 + </widget> 605 + </item> 606 + </layout> 607 + </widget> 608 + <widget class="QWidget" name="horizontalLayout" > 609 + <property name="geometry" > 610 + <rect> 611 + <x>330</x> 612 + <y>490</y> 613 + <width>631</width> 614 + <height>41</height> 615 + </rect> 616 + </property> 617 + <layout class="QHBoxLayout" > 618 + <item> 619 + <widget class="QPushButton" name="pushButton_9" > 620 + <property name="text" > 621 + <string>Crear Factura</string> 622 + </property> 623 + </widget> 624 + </item> 625 + <item> 626 + <widget class="QPushButton" name="pushButton_5" > 627 + <property name="text" > 628 + <string>&amp;Guardar</string> 629 + </property> 630 + </widget> 631 + </item> 632 + <item> 633 + <widget class="QPushButton" name="pushButton_4" > 634 + <property name="text" > 635 + <string>&amp;Imprimir</string> 636 + </property> 637 + </widget> 638 + </item> 639 + <item> 640 + <widget class="QPushButton" name="pushButton" > 641 + <property name="text" > 642 + <string>&amp;Cancelar</string> 643 + </property> 644 + </widget> 645 + </item> 646 + </layout> 647 + </widget> 648 + </widget> 649 + <layoutdefault spacing="6" margin="11" /> 650 + <resources/> 651 + <connections> 652 + <connection> 653 + <sender>checkBox</sender> 654 + <signal>clicked(bool)</signal> 655 + <receiver>dateEdit</receiver> 656 + <slot>setEnabled(bool)</slot> 657 + <hints> 658 + <hint type="sourcelabel" > 659 + <x>109</x> 660 + <y>389</y> 661 + </hint> 662 + <hint type="destinationlabel" > 663 + <x>319</x> 664 + <y>390</y> 665 + </hint> 666 + </hints> 667 + </connection> 668 + <connection> 669 + <sender>pushButton</sender> 670 + <signal>clicked()</signal> 671 + <receiver>NuevoPresupuestoDialogClass</receiver> 672 + <slot>reject()</slot> 673 + <hints> 674 + <hint type="sourcelabel" > 675 + <x>959</x> 676 + <y>498</y> 677 + </hint> 678 + <hint type="destinationlabel" > 679 + <x>806</x> 680 + <y>452</y> 681 + </hint> 682 + </hints> 683 + </connection> 684 + <connection> 685 + <sender>checkBox_4</sender> 686 + <signal>clicked(bool)</signal> 687 + <receiver>dateEdit_2</receiver> 688 + <slot>setEnabled(bool)</slot> 689 + <hints> 690 + <hint type="sourcelabel" > 691 + <x>779</x> 692 + <y>470</y> 693 + </hint> 694 + <hint type="destinationlabel" > 695 + <x>896</x> 696 + <y>468</y> 697 + </hint> 698 + </hints> 699 + </connection> 700 + </connections> 701 + </ui>
+350
Gui/PrintWindow.cpp
··· 1 + #include "PrintWindow.h" 2 + #include <QPrinter> 3 + #include <QPainter> 4 + #include <QTextDocument> 5 + #include <QString> 6 + #include <QPrintDialog> 7 + #include <QtGui> 8 + #include "../Negocio/Factura.h" 9 + #include <iostream> 10 + #include <string> 11 + #include <list> 12 + #include <cstdlib> 13 + #include <fstream> 14 + #include "../Negocio/LineaArticulo.h" 15 + 16 + using namespace std; 17 + 18 + PrintWindow::PrintWindow() { 19 + 20 + } 21 + 22 + PrintWindow::PrintWindow(const Factura &f) 23 + { 24 + printer.setPageSize(QPrinter::A4); 25 + printer.setOrientation(QPrinter::Portrait); 26 + printer.setPaperSource(QPrinter::Tractor); 27 + factura = f; 28 + fstream fileConfig; 29 + fileConfig.open("Gui/printer.cfg", fstream::in); 30 + if (fileConfig.fail()) { 31 + return ; 32 + } 33 + string name, value; 34 + while (!fileConfig.eof()) { 35 + fileConfig >> name >> value; 36 + if (name == "Manual") { 37 + if (value == "true") { 38 + manual = true; 39 + } else if (value == "false") { 40 + manual = false; 41 + } else { 42 + manual = false; 43 + } 44 + } else if (name == "Puerto") { 45 + puerto = QString(value.c_str()); 46 + } else if (name == "Largo") { 47 + largo = atoi(value.c_str()); 48 + } else if (name == "Ancho") { 49 + largo = atoi(value.c_str()); 50 + } 51 + } 52 + fileConfig.close(); 53 + } 54 + 55 + PrintWindow::PrintWindow(const Presupuesto &f) 56 + { 57 + printer.setPageSize(QPrinter::A4); 58 + printer.setOrientation(QPrinter::Portrait); 59 + printer.setPaperSource(QPrinter::Tractor); 60 + presupuesto = f; 61 + } 62 + 63 + PrintWindow::~PrintWindow() 64 + { 65 + } 66 + 67 + QString PrintWindow::cuadroPresupuestoCliente() { 68 + QString cadenaCliente; 69 + Cliente *c = presupuesto.getcliente(); 70 + cadenaCliente += c->getapellidos().c_str(); 71 + cadenaCliente += ", "; 72 + cadenaCliente += c->getnombre().c_str(); 73 + cadenaCliente += "\n"; 74 + cadenaCliente += c->getdireccion().c_str(); 75 + cadenaCliente += "\n"; 76 + cadenaCliente += c->getpoblacion().c_str(); 77 + cadenaCliente += "\n"; 78 + cadenaCliente += "DNI: "; 79 + cadenaCliente += c->getnif().c_str(); 80 + cadenaCliente += "\n"; 81 + list<int> lTelefonos = c->gettelefonos(); 82 + list<int>::iterator it; 83 + int i = 1; 84 + for (it = lTelefonos.begin(); it != lTelefonos.end(); it++, i++) { 85 + cadenaCliente += "Tel. "; 86 + cadenaCliente += QString::number(i,10).toStdString().c_str(); 87 + cadenaCliente += ": "; 88 + cadenaCliente += QString::number(*it,10).toStdString().c_str(); 89 + if (i%3 == 0) 90 + cadenaCliente += "\n"; 91 + else 92 + cadenaCliente += "\t"; 93 + } 94 + return cadenaCliente; 95 + } 96 + 97 + QString PrintWindow::cuadroFacturaCliente() { 98 + QString cadenaCliente; 99 + Cliente *c = factura.getcliente(); 100 + cadenaCliente += c->getapellidos().c_str(); 101 + cadenaCliente += ", "; 102 + cadenaCliente += c->getnombre().c_str(); 103 + cadenaCliente += "\n"; 104 + cadenaCliente += c->getdireccion().c_str(); 105 + cadenaCliente += "\n"; 106 + cadenaCliente += c->getpoblacion().c_str(); 107 + cadenaCliente += "\n"; 108 + cadenaCliente += "DNI: "; 109 + cadenaCliente += c->getnif().c_str(); 110 + cadenaCliente += "\n"; 111 + list<int> lTelefonos = c->gettelefonos(); 112 + list<int>::iterator it; 113 + int i = 1; 114 + for (it = lTelefonos.begin(); it != lTelefonos.end(); it++, i++) { 115 + cadenaCliente += "Tel. "; 116 + cadenaCliente += QString::number(i,10).toStdString().c_str(); 117 + cadenaCliente += ": "; 118 + cadenaCliente += QString::number(*it,10).toStdString().c_str(); 119 + if (i%3 == 0) 120 + cadenaCliente += "\n"; 121 + else 122 + cadenaCliente += "\t"; 123 + } 124 + return cadenaCliente; 125 + } 126 + 127 + 128 + QString PrintWindow::cuadroClienteSobre(Cliente *c) { 129 + QString cadenaCliente; 130 + 131 + cadenaCliente += c->getapellidos().c_str(); 132 + cadenaCliente += ", "; 133 + cadenaCliente += c->getnombre().c_str(); 134 + cadenaCliente += "\n"; 135 + cadenaCliente += c->getdireccion().c_str(); 136 + cadenaCliente += "\n"; 137 + cadenaCliente += c->getpoblacion().c_str(); 138 + cadenaCliente += "\n"; 139 + 140 + 141 + return cadenaCliente; 142 + } 143 + 144 + 145 + 146 + void PrintWindow::printFactura() { 147 + if (!manual) { 148 + QString html = cuadroFacturaCliente(); 149 + QPrintDialog printDialog(&printer, 0); 150 + if (printDialog.exec()) { 151 + QPainter painter(&printer); 152 + //QImage fondo("Gui/images/factura.png"); 153 + //if (fondo.isNull()) { 154 + //cout << "Error al abrir la imgen." << endl; 155 + // } 156 + //painter.drawImage(0,0,fondo); 157 + //QRect rect = painter.boundingRect(400,66,100,100,Qt::AlignLeft | Qt::TextWordWrap, html); 158 + painter.setFont(QFont("Arial", 10)); 159 + painter.drawText(370, 66, 400, 100, Qt::AlignLeft 160 + | Qt::TextWordWrap, html); 161 + int y = 230; 162 + int x = 0; 163 + int incx = 115; 164 + painter.drawText(x, y, 100, 33, Qt::AlignLeft | Qt::TextWordWrap, 165 + QString("%1").arg(factura.getn_factura())); 166 + painter.drawText(x + incx, y, 100, 33, Qt::AlignLeft 167 + | Qt::TextWordWrap, QString(factura.getfecha().c_str())); 168 + painter.drawText(x + incx*2 + 15, y, 100, 33, Qt::AlignLeft 169 + | Qt::TextWordWrap, QString(factura.getaparato().c_str())); 170 + painter.drawText(x + incx*3 + 35, y, 100, 33, Qt::AlignLeft 171 + | Qt::TextWordWrap, QString(factura.getmarca().c_str())); 172 + painter.drawText(x + incx*4 + 55, y, 100, 33, Qt::AlignLeft 173 + | Qt::TextWordWrap, QString(factura.getmodelo().c_str())); 174 + painter.drawText(x + incx*5 + 70, y, 100, 33, Qt::AlignLeft 175 + | Qt::TextWordWrap, QString("%1").arg(factura.getn_fabricacion())); 176 + if (factura.getlugar_reparacion() != 0) { 177 + bool lugar = *factura.getlugar_reparacion(); 178 + if (lugar) { 179 + painter.drawText(68, 185, 100, 100, Qt::AlignLeft 180 + | Qt::TextWordWrap, QString("X")); 181 + } else { 182 + painter.drawText(128, 185, 100, 100, Qt::AlignLeft 183 + | Qt::TextWordWrap, QString("X")); 184 + } 185 + } 186 + painter.drawText(180, 265, 600, 17, Qt::AlignLeft 187 + | Qt::TextWordWrap, QString(factura.getaveria().c_str())); 188 + list<LineaArticulo> l = factura.getlista_articulos(); 189 + list<LineaArticulo>::iterator it; 190 + x = 0; 191 + y = 315; 192 + int i = 0; 193 + for (it = l.begin(); it != l.end() && i < 12; it++, i++) { 194 + painter.drawText(x, y, 100, 33, Qt::AlignLeft 195 + | Qt::TextWordWrap, QString("%1").arg(it->getarticulo().getcodigo())); 196 + painter.drawText(x + 145, y, 350, 33, Qt::AlignLeft 197 + | Qt::TextWordWrap, QString(it->getarticulo().getdescripcion().c_str())); 198 + painter.drawText(x + 510, y, 100, 33, Qt::AlignLeft 199 + | Qt::TextWordWrap, QString("%1").arg(it->getcantidad())); 200 + painter.drawText(x + 580, y, 100, 33, Qt::AlignLeft 201 + | Qt::TextWordWrap, QString("%1").arg(it->getarticulo().getpvp() - it->getarticulo().getpvp()*it->getarticulo().getdescuento())); 202 + painter.drawText(x + 670, y, 100, 33, Qt::AlignLeft 203 + | Qt::TextWordWrap, QString("%1").arg(it->getpreciototal())); 204 + y += 17; 205 + } 206 + painter.drawText(480, 502, 100, 33, Qt::AlignLeft 207 + | Qt::TextWordWrap, QString(factura.gettiempo_empleado().c_str())); 208 + painter.drawText(0, 519, 550, 119, Qt::AlignLeft 209 + | Qt::TextWordWrap, QString(factura.gettrabajo_realizado().c_str())); 210 + painter.drawText(670, 502, 100, 33, Qt::AlignLeft 211 + | Qt::TextWordWrap, QString("%1").arg(factura.getMateriales())); 212 + painter.drawText(670, 519, 100, 33, Qt::AlignLeft 213 + | Qt::TextWordWrap, QString("%1").arg(factura.getprecio_mano_obra())); 214 + painter.drawText(670, 536, 100, 33, Qt::AlignLeft 215 + | Qt::TextWordWrap, QString("%1").arg(factura.getprecio_desplazamiento())); 216 + painter.drawText(670, 553, 100, 33, Qt::AlignLeft 217 + | Qt::TextWordWrap, QString("%1").arg(factura.getprecio_transporte())); 218 + painter.drawText(670, 570, 100, 33, Qt::AlignLeft 219 + | Qt::TextWordWrap, QString("%1").arg(factura.getSubTotal())); 220 + painter.drawText(670, 587, 100, 33, Qt::AlignLeft 221 + | Qt::TextWordWrap, QString("%1").arg(factura.getiva())); 222 + painter.drawText(670, 604, 100, 33, Qt::AlignLeft 223 + | Qt::TextWordWrap, QString("%1").arg(factura.getTotal())); 224 + painter.drawText(470, 630, 100, 33, Qt::AlignLeft 225 + | Qt::TextWordWrap, QString(factura.getfecha_terminacion().c_str())); 226 + painter.drawText(0, 664, 550, 33, Qt::AlignLeft 227 + | Qt::TextWordWrap, QString(factura.getobservaciones().c_str())); 228 + } 229 + } else { 230 + ofstream printer; 231 + printer.open(puerto.toStdString().c_str()); 232 + printer << "Hola mundo\f" << endl; 233 + printer.close(); 234 + } 235 + } 236 + 237 + void PrintWindow::printPresupuesto() { 238 + if (!manual) { 239 + QString html = cuadroPresupuestoCliente(); 240 + QPrintDialog printDialog(&printer, 0); 241 + if (printDialog.exec()) { 242 + QPainter painter(&printer); 243 + //QImage fondo("Gui/images/factura.png"); 244 + // if (fondo.isNull()) { 245 + // cout << "Error al abrir la imgen." << endl; 246 + // } 247 + // painter.drawImage(0,0,fondo); 248 + //QRect rect = painter.boundingRect(400,66,100,100,Qt::AlignLeft | Qt::TextWordWrap, html); 249 + painter.setFont(QFont("Arial", 10)); 250 + painter.drawText(370, 66, 400, 100, Qt::AlignLeft 251 + | Qt::TextWordWrap, html); 252 + int y = 230; 253 + int x = 0; 254 + int incx = 115; 255 + painter.drawText(x, y, 100, 33, Qt::AlignLeft | Qt::TextWordWrap, 256 + QString("%1").arg(presupuesto.getn_factura())); 257 + painter.drawText(x + incx, y, 100, 33, Qt::AlignLeft 258 + | Qt::TextWordWrap, QString(presupuesto.getfecha().c_str())); 259 + painter.drawText(x + incx*2 + 15, y, 100, 33, Qt::AlignLeft 260 + | Qt::TextWordWrap, QString(presupuesto.getaparato().c_str())); 261 + painter.drawText(x + incx*3 + 35, y, 100, 33, Qt::AlignLeft 262 + | Qt::TextWordWrap, QString(presupuesto.getmarca().c_str())); 263 + painter.drawText(x + incx*4 + 55, y, 100, 33, Qt::AlignLeft 264 + | Qt::TextWordWrap, QString(presupuesto.getmodelo().c_str())); 265 + painter.drawText(x + incx*5 + 70, y, 100, 33, Qt::AlignLeft 266 + | Qt::TextWordWrap, QString("%1").arg(presupuesto.getn_fabricacion())); 267 + if (presupuesto.getlugar_reparacion() != 0) { 268 + bool lugar = *presupuesto.getlugar_reparacion(); 269 + if (lugar) { 270 + painter.drawText(68, 185, 100, 100, Qt::AlignLeft 271 + | Qt::TextWordWrap, QString("X")); 272 + } else { 273 + painter.drawText(128, 185, 100, 100, Qt::AlignLeft 274 + | Qt::TextWordWrap, QString("X")); 275 + } 276 + } 277 + painter.drawText(180, 265, 600, 17, Qt::AlignLeft 278 + | Qt::TextWordWrap, QString(presupuesto.getaveria().c_str())); 279 + list<LineaArticulo> l = presupuesto.getlista_articulos(); 280 + list<LineaArticulo>::iterator it; 281 + x = 0; 282 + y = 315; 283 + int i = 0; 284 + for (it = l.begin(); it != l.end() && i < 12; it++, i++) { 285 + painter.drawText(x, y, 100, 33, Qt::AlignLeft 286 + | Qt::TextWordWrap, QString("%1").arg(it->getarticulo().getcodigo())); 287 + painter.drawText(x + 145, y, 350, 33, Qt::AlignLeft 288 + | Qt::TextWordWrap, QString(it->getarticulo().getdescripcion().c_str())); 289 + painter.drawText(x + 510, y, 100, 33, Qt::AlignLeft 290 + | Qt::TextWordWrap, QString("%1").arg(it->getcantidad())); 291 + painter.drawText(x + 580, y, 100, 33, Qt::AlignLeft 292 + | Qt::TextWordWrap, QString("%1").arg(it->getarticulo().getpvp() - it->getarticulo().getpvp()*it->getarticulo().getdescuento())); 293 + painter.drawText(x + 670, y, 100, 33, Qt::AlignLeft 294 + | Qt::TextWordWrap, QString("%1").arg(it->getpreciototal())); 295 + y += 17; 296 + } 297 + painter.drawText(480, 502, 100, 33, Qt::AlignLeft 298 + | Qt::TextWordWrap, QString(presupuesto.gettiempo_empleado().c_str())); 299 + painter.drawText(0, 519, 550, 119, Qt::AlignLeft 300 + | Qt::TextWordWrap, 301 + QString(presupuesto.gettrabajo_realizado().c_str())); 302 + painter.drawText(670, 502, 100, 33, Qt::AlignLeft 303 + | Qt::TextWordWrap, QString("%1").arg(presupuesto.getMateriales())); 304 + painter.drawText(670, 519, 100, 33, Qt::AlignLeft 305 + | Qt::TextWordWrap, QString("%1").arg(presupuesto.getprecio_mano_obra())); 306 + painter.drawText(670, 536, 100, 33, Qt::AlignLeft 307 + | Qt::TextWordWrap, QString("%1").arg(presupuesto.getprecio_desplazamiento())); 308 + painter.drawText(670, 553, 100, 33, Qt::AlignLeft 309 + | Qt::TextWordWrap, QString("%1").arg(presupuesto.getprecio_transporte())); 310 + painter.drawText(670, 570, 100, 33, Qt::AlignLeft 311 + | Qt::TextWordWrap, QString("%1").arg(presupuesto.getSubTotal())); 312 + painter.drawText(670, 588, 100, 33, Qt::AlignLeft 313 + | Qt::TextWordWrap, QString("%1").arg(presupuesto.getiva())); 314 + painter.drawText(670, 605, 100, 33, Qt::AlignLeft 315 + | Qt::TextWordWrap, QString("%1").arg(presupuesto.getTotal())); 316 + painter.drawText(480, 630, 100, 33, Qt::AlignLeft 317 + | Qt::TextWordWrap, QString(presupuesto.getfecha_terminacion().c_str())); 318 + painter.drawText(0, 664, 550, 33, Qt::AlignLeft 319 + | Qt::TextWordWrap, QString(presupuesto.getobservaciones().c_str())); 320 + 321 + 322 + } 323 + } else { 324 + 325 + } 326 + } 327 + 328 + 329 + void PrintWindow::printListaClientes(list<Cliente> lClientes){ 330 + 331 + printer.setPageSize(QPrinter::Letter); 332 + printer.setOrientation(QPrinter::Landscape); 333 + printer.setPaperSource(QPrinter::Auto); 334 + 335 + QPrintDialog printDialog(&printer, 0); 336 + QPainter painter(&printer); 337 + 338 + list<Cliente>::iterator it; 339 + if (printDialog.exec()) { 340 + for(it = lClientes.begin(); it!= lClientes.end(); it++){ 341 + Cliente c = *it; 342 + QString html = cuadroClienteSobre(&c); 343 + 344 + //painter.begin(); 345 + painter.drawText(0, 0, 500, 500, Qt::AlignLeft | Qt::TextWordWrap, html); 346 + //painter.end(); 347 + } 348 + } 349 + 350 + }
+34
Gui/PrintWindow.h
··· 1 + #ifndef PRINTWINDOW_H_ 2 + #define PRINTWINDOW_H_ 3 + #include <QString> 4 + #include "../Negocio/Factura.h" 5 + #include <QPrinter> 6 + #include "../Negocio/Presupuesto.h" 7 + 8 + 9 + class PrintWindow 10 + { 11 + public: 12 + PrintWindow (); 13 + PrintWindow(const Factura &f); 14 + PrintWindow(const Presupuesto &f); 15 + virtual ~PrintWindow(); 16 + void printFactura(); 17 + void printPresupuesto(); 18 + void printListaClientes(list<Cliente> l); 19 + private: 20 + QString cuadroFacturaCliente(); 21 + QString cuadroPresupuestoCliente(); 22 + QString cuadroClienteSobre(Cliente *c); 23 + 24 + QPrinter printer; 25 + Factura factura; 26 + Presupuesto presupuesto; 27 + bool manual; 28 + QString puerto; 29 + int largo; 30 + int ancho; 31 + }; 32 + 33 + #endif /*PRINTWINDOW_H_*/ 34 +
+17
Gui/VisorAyuda.cpp
··· 1 + #include "VisorAyuda.h" 2 + 3 + VisorAyuda::VisorAyuda(QWidget *parent) 4 + : QWidget(parent) 5 + { 6 + ui.setupUi(this); 7 + ui.textBrowser->setSource(QUrl("Ayuda/ayuda.html")); 8 + } 9 + 10 + VisorAyuda::~VisorAyuda() 11 + { 12 + 13 + } 14 + 15 + void VisorAyuda::resizeEvent(QResizeEvent *event) { 16 + ui.gridLayout->setGeometry(QRect(0, 0, event->size().width(), event->size().height())); 17 + }
+21
Gui/VisorAyuda.h
··· 1 + #ifndef VISORAYUDA_H 2 + #define VISORAYUDA_H 3 + 4 + #include <QtGui> 5 + #include "ui_VisorAyuda.h" 6 + 7 + class VisorAyuda : public QWidget 8 + { 9 + Q_OBJECT 10 + 11 + public: 12 + VisorAyuda(QWidget *parent = 0); 13 + ~VisorAyuda(); 14 + 15 + private: 16 + Ui::VisorAyudaClass ui; 17 + protected: 18 + void resizeEvent(QResizeEvent *event); 19 + }; 20 + 21 + #endif // VISORAYUDA_H
+71
Gui/VisorAyuda.ui
··· 1 + <ui version="4.0" > 2 + <class>VisorAyudaClass</class> 3 + <widget class="QWidget" name="VisorAyudaClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>565</width> 9 + <height>503</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>VisorAyuda</string> 14 + </property> 15 + <widget class="QWidget" name="gridLayout" > 16 + <property name="geometry" > 17 + <rect> 18 + <x>10</x> 19 + <y>10</y> 20 + <width>541</width> 21 + <height>481</height> 22 + </rect> 23 + </property> 24 + <layout class="QGridLayout" > 25 + <item row="2" column="1" > 26 + <widget class="QPushButton" name="pushButton" > 27 + <property name="text" > 28 + <string>&amp;Aceptar</string> 29 + </property> 30 + </widget> 31 + </item> 32 + <item row="2" column="0" > 33 + <spacer> 34 + <property name="orientation" > 35 + <enum>Qt::Horizontal</enum> 36 + </property> 37 + <property name="sizeHint" > 38 + <size> 39 + <width>40</width> 40 + <height>20</height> 41 + </size> 42 + </property> 43 + </spacer> 44 + </item> 45 + <item rowspan="2" row="0" column="0" colspan="2" > 46 + <widget class="QTextBrowser" name="textBrowser" /> 47 + </item> 48 + </layout> 49 + </widget> 50 + </widget> 51 + <layoutdefault spacing="6" margin="11" /> 52 + <resources/> 53 + <connections> 54 + <connection> 55 + <sender>pushButton</sender> 56 + <signal>clicked()</signal> 57 + <receiver>VisorAyudaClass</receiver> 58 + <slot>close()</slot> 59 + <hints> 60 + <hint type="sourcelabel" > 61 + <x>352</x> 62 + <y>270</y> 63 + </hint> 64 + <hint type="destinationlabel" > 65 + <x>348</x> 66 + <y>295</y> 67 + </hint> 68 + </hints> 69 + </connection> 70 + </connections> 71 + </ui>
Gui/images/1388.png.ico

This is a binary file and will not be displayed.

Gui/images/14248.ico

This is a binary file and will not be displayed.

Gui/images/14248.png

This is a binary file and will not be displayed.

Gui/images/2389.ico

This is a binary file and will not be displayed.

Gui/images/2389.png

This is a binary file and will not be displayed.

Gui/images/Acceso directo a Gui.lnk

This is a binary file and will not be displayed.

Gui/images/BArticulo.PNG

This is a binary file and will not be displayed.

Gui/images/BCliente.PNG

This is a binary file and will not be displayed.

Gui/images/BFactura.PNG

This is a binary file and will not be displayed.

Gui/images/BPresupuesto.PNG

This is a binary file and will not be displayed.

Gui/images/LArticulo.PNG

This is a binary file and will not be displayed.

Gui/images/LCliente.PNG

This is a binary file and will not be displayed.

Gui/images/LFactura.PNG

This is a binary file and will not be displayed.

Gui/images/LPresupuesto.PNG

This is a binary file and will not be displayed.

Gui/images/NArticulo.PNG

This is a binary file and will not be displayed.

Gui/images/NCliente.PNG

This is a binary file and will not be displayed.

Gui/images/NFactura.PNG

This is a binary file and will not be displayed.

Gui/images/NPresupuesto.PNG

This is a binary file and will not be displayed.

Gui/images/Thumbs.db

This is a binary file and will not be displayed.

Gui/images/configuracion.PNG

This is a binary file and will not be displayed.

Gui/images/factura.jpg

This is a binary file and will not be displayed.

Gui/images/factura.png

This is a binary file and will not be displayed.

Gui/images/icono.ico

This is a binary file and will not be displayed.

Gui/images/icono.png

This is a binary file and will not be displayed.

Gui/images/inicio.PNG

This is a binary file and will not be displayed.

Gui/images/splash.png

This is a binary file and will not be displayed.

Gui/images/textura.png

This is a binary file and will not be displayed.

Gui/images/textura_madera.png

This is a binary file and will not be displayed.

+46
Gui/imprimirsobrecliente.cpp
··· 1 + #include "imprimirsobrecliente.h" 2 + #include "../Negocio/CapaNegocio.h" 3 + #include <list> 4 + #include "../Negocio/Cliente.h" 5 + #include "PrintWindow.h" 6 + #include <QtGui> 7 + 8 + ImprimirSobreCliente::ImprimirSobreCliente(QWidget *parent, CapaNegocio *cn) 9 + : QWidget(parent) 10 + { 11 + ui.setupUi(this); 12 + capaNegocio = cn; 13 + connect(ui.pushButton, SIGNAL(clicked()), this, SLOT(aceptar())); 14 + } 15 + 16 + ImprimirSobreCliente::~ImprimirSobreCliente() 17 + { 18 + 19 + } 20 + 21 + void ImprimirSobreCliente::aceptar(){ 22 + 23 + if(ui.lineEdit->text() == ""){ 24 + QMessageBox::warning(this, "Aviso", "Debe especificar el rango del numero de clientes."); 25 + } 26 + else if(ui.lineEdit_2->text() == ""){ 27 + QMessageBox::warning(this, "Aviso", "Debe especificar el rango del numero de clientes."); 28 + } 29 + 30 + int del, al; 31 + del = ui.lineEdit->text().toInt(); 32 + al = ui.lineEdit_2->text().toInt(); 33 + 34 + list<Cliente> l= capaNegocio->getClientesRango(del, al); 35 + 36 + if(l.size() == 0){ 37 + QMessageBox::warning(this, "Aviso", "No hay clientes en el rango."); 38 + return; 39 + } 40 + else{ 41 + PrintWindow* pq = new PrintWindow(); 42 + pq->printListaClientes(l); 43 + this->close(); 44 + } 45 + 46 + }
+30
Gui/imprimirsobrecliente.h
··· 1 + #ifndef IMPRIMIRSOBRECLIENTE_H 2 + #define IMPRIMIRSOBRECLIENTE_H 3 + 4 + #include <QtGui/QWidget> 5 + #include "ui_imprimirsobrecliente.h" 6 + #include "../Negocio/CapaNegocio.h" 7 + #include <list> 8 + #include "../Negocio/Cliente.h" 9 + 10 + 11 + 12 + class ImprimirSobreCliente : public QWidget 13 + { 14 + Q_OBJECT 15 + 16 + public: 17 + ImprimirSobreCliente(QWidget *parent = 0,CapaNegocio *cn = 0); 18 + ~ImprimirSobreCliente(); 19 + 20 + public slots: 21 + void aceptar(); 22 + 23 + private: 24 + Ui::ImprimirSobreClienteClass ui; 25 + CapaNegocio *capaNegocio; 26 + 27 + 28 + }; 29 + 30 + #endif // IMPRIMIRSOBRECLIENTE_H
+99
Gui/imprimirsobrecliente.ui
··· 1 + <ui version="4.0" > 2 + <class>ImprimirSobreClienteClass</class> 3 + <widget class="QWidget" name="ImprimirSobreClienteClass" > 4 + <property name="geometry" > 5 + <rect> 6 + <x>0</x> 7 + <y>0</y> 8 + <width>469</width> 9 + <height>123</height> 10 + </rect> 11 + </property> 12 + <property name="windowTitle" > 13 + <string>ImprimirSobreCliente</string> 14 + </property> 15 + <widget class="QWidget" name="gridLayout" > 16 + <property name="geometry" > 17 + <rect> 18 + <x>10</x> 19 + <y>10</y> 20 + <width>451</width> 21 + <height>101</height> 22 + </rect> 23 + </property> 24 + <layout class="QGridLayout" > 25 + <item row="0" column="2" > 26 + <widget class="QLabel" name="label" > 27 + <property name="text" > 28 + <string>Al</string> 29 + </property> 30 + </widget> 31 + </item> 32 + <item row="0" column="0" > 33 + <widget class="QLabel" name="label_2" > 34 + <property name="text" > 35 + <string>Del</string> 36 + </property> 37 + </widget> 38 + </item> 39 + <item row="0" column="1" > 40 + <widget class="QLineEdit" name="lineEdit" /> 41 + </item> 42 + <item row="0" column="3" > 43 + <widget class="QLineEdit" name="lineEdit_2" /> 44 + </item> 45 + <item row="1" column="0" colspan="4" > 46 + <layout class="QHBoxLayout" > 47 + <item> 48 + <spacer> 49 + <property name="orientation" > 50 + <enum>Qt::Horizontal</enum> 51 + </property> 52 + <property name="sizeHint" > 53 + <size> 54 + <width>40</width> 55 + <height>20</height> 56 + </size> 57 + </property> 58 + </spacer> 59 + </item> 60 + <item> 61 + <widget class="QPushButton" name="pushButton" > 62 + <property name="text" > 63 + <string>Aceptar</string> 64 + </property> 65 + </widget> 66 + </item> 67 + <item> 68 + <widget class="QPushButton" name="pushButton_2" > 69 + <property name="text" > 70 + <string>Cancelar</string> 71 + </property> 72 + </widget> 73 + </item> 74 + </layout> 75 + </item> 76 + </layout> 77 + </widget> 78 + </widget> 79 + <layoutdefault spacing="6" margin="11" /> 80 + <resources/> 81 + <connections> 82 + <connection> 83 + <sender>pushButton_2</sender> 84 + <signal>clicked()</signal> 85 + <receiver>ImprimirSobreClienteClass</receiver> 86 + <slot>close()</slot> 87 + <hints> 88 + <hint type="sourcelabel" > 89 + <x>414</x> 90 + <y>82</y> 91 + </hint> 92 + <hint type="destinationlabel" > 93 + <x>462</x> 94 + <y>71</y> 95 + </hint> 96 + </hints> 97 + </connection> 98 + </connections> 99 + </ui>
+39
Gui/main.cpp
··· 1 + #include "../Negocio/CapaNegocio.h" 2 + #include "../Negocio/Articulo.h" 3 + #include "../Negocio/Cliente.h" 4 + #include "../Negocio/Factura.h" 5 + #include "../Negocio/Presupuesto.h" 6 + #include "../Gui/MainWindow.h" 7 + 8 + #include <iostream> 9 + #include <string> 10 + #include <list> 11 + #include <QApplication> 12 + 13 + using namespace std; 14 + 15 + /****ATRIBUTO GLOBAL PARA SOLO TRABAJAR CON UNA INSTANCIA DE LA CAPA DE NEGOCIO****/ 16 + CapaNegocio * const capaNegocio = new CapaNegocio; 17 + 18 + int main(int argc, char* argv[]){ 19 + 20 + QApplication app(argc, argv); 21 + 22 + app.setWindowIcon(QIcon("Gui/images/icono.ico")); 23 + 24 + QSplashScreen *splash = new QSplashScreen; 25 + splash->setPixmap(QPixmap("Gui/images/splash.png")); 26 + splash->show(); 27 + 28 + Qt::Alignment bottomRight = Qt::AlignRight | Qt::AlignBottom; 29 + 30 + splash->showMessage(QObject::tr("Cargando..."), bottomRight, Qt::black); 31 + capaNegocio->inicializar(); 32 + MainWindow main(capaNegocio); 33 + main.showMaximized(); 34 + 35 + splash->finish(&main); 36 + delete splash; 37 + 38 + return app.exec(); 39 + }
+4
Gui/printer.cfg
··· 1 + Manual false 2 + Puerto XPSPort 3 + Largo 202 4 + Ancho 212
+117
Negocio/Articulo.cpp
··· 1 + #include "Articulo.h" 2 + #include <string> 3 + using namespace std; 4 + Articulo::Articulo() 5 + { 6 + codigo = -1; 7 + existencias = -1; 8 + existencias_minimas = -1; 9 + descuento = 0; 10 + pvp = -1.; 11 + precio_coste = -1.; 12 + descripcion = ""; 13 + caja = ""; 14 + historico = false; 15 + } 16 + 17 + Articulo::~Articulo() 18 + { 19 + } 20 + 21 + //metodos get 22 + int Articulo::getid(){ 23 + return id; 24 + } 25 + 26 + int Articulo::getcodigo(){ 27 + return codigo; 28 + } 29 + 30 + string Articulo::getdescripcion(){ 31 + return descripcion; 32 + } 33 + 34 + string Articulo::getcaja(){ 35 + return caja; 36 + } 37 + 38 + int Articulo::getexistencias(){ 39 + return existencias; 40 + } 41 + 42 + int Articulo::getexistencias_minimas(){ 43 + return existencias_minimas; 44 + } 45 + 46 + double Articulo::getpvp(){ 47 + return pvp; 48 + } 49 + 50 + double Articulo::getprecio_coste(){ 51 + return precio_coste; 52 + } 53 + 54 + int Articulo::getdescuento(){ 55 + return descuento; 56 + } 57 + bool Articulo::gethistorico() { 58 + return historico; 59 + } 60 + 61 + //metodos set 62 + 63 + void Articulo::setid(int iden){ 64 + id=iden; 65 + } 66 + 67 + 68 + void Articulo::setcodigo(int cod){ 69 + codigo=cod; 70 + } 71 + 72 + void Articulo::setdescripcion(string descr){ 73 + descripcion=descr; 74 + } 75 + 76 + void Articulo::setcaja(string caj){ 77 + caja=caj; 78 + } 79 + void Articulo::setexistencias(int exis){ 80 + existencias=exis; 81 + } 82 + 83 + void Articulo::setexistencias_minimas(int exis_min){ 84 + existencias_minimas=exis_min; 85 + } 86 + 87 + void Articulo::setpvp(double pvppub){ 88 + pvp=pvppub; 89 + } 90 + 91 + void Articulo::setprecio_coste(double precio_cos){ 92 + precio_coste=precio_cos; 93 + } 94 + 95 + void Articulo::setdescuento(int desc){ 96 + descuento=desc; 97 + } 98 + 99 + void Articulo::sethistorico(bool h) { 100 + historico = h; 101 + } 102 + 103 + Articulo Articulo::operator=(Articulo a) { 104 + if (this != &a) { 105 + this->id = a.getid(); 106 + this->caja = a.getcaja(); 107 + this->codigo = a.getcodigo(); 108 + this->descripcion = a.getdescripcion(); 109 + this->descuento = a.getdescuento(); 110 + this->existencias = a.getexistencias(); 111 + this->existencias_minimas = a.getexistencias_minimas(); 112 + this->historico = a.gethistorico(); 113 + this->precio_coste = a.getprecio_coste(); 114 + this->pvp = a.getpvp(); 115 + } 116 + return *this; 117 + }
+54
Negocio/Articulo.h
··· 1 + #ifndef ARTICULO_H_ 2 + #define ARTICULO_H_ 3 + #include <string> 4 + using namespace std; 5 + 6 + class Articulo 7 + { 8 + 9 + private: 10 + int id; 11 + int codigo; 12 + string descripcion; 13 + string caja; 14 + int existencias; 15 + int existencias_minimas; 16 + double pvp; 17 + double precio_coste; 18 + int descuento; 19 + bool historico; 20 + 21 + public: 22 + Articulo(); 23 + virtual ~Articulo(); 24 + 25 + //metodos get 26 + int getid(); 27 + int getcodigo(); 28 + string getdescripcion(); 29 + string getcaja(); 30 + int getexistencias(); 31 + int getexistencias_minimas(); 32 + double getpvp(); 33 + double getprecio_coste(); 34 + int getdescuento(); 35 + bool gethistorico(); 36 + 37 + //metodos set 38 + void setid(int id); 39 + void setcodigo(int codigo); 40 + void setdescripcion(string descripcion); 41 + void setcaja(string caja); 42 + void setexistencias(int existencias); 43 + void setexistencias_minimas(int existencias_minimas); 44 + void setpvp(double pvp); 45 + void setprecio_coste(double precio_coste); 46 + void setdescuento(int descuento); 47 + void sethistorico(bool h); 48 + 49 + //sobrecarga de operador igual 50 + Articulo operator=(Articulo a); 51 + 52 + }; 53 + 54 + #endif /*ARTICULO_H_*/
+508
Negocio/CapaNegocio.cpp
··· 1 + #include <list> 2 + #include "Factura.h" 3 + #include "CapaNegocio.h" 4 + #include <iostream> 5 + using namespace std; 6 + 7 + CapaNegocio::CapaNegocio() 8 + { 9 + 10 + } 11 + 12 + void CapaNegocio::inicializar() { 13 + 14 + accesoADatos = new AccesoADatos(); 15 + cout << "[Debug]Capa de acceso a datos inicializada correctamente." << endl; 16 + cout << "[Debug]Cargando capa de negocio..." << endl; 17 + listaFacturas = accesoADatos->listaFacturas(); 18 + listaClientes = accesoADatos->listaClientes(); 19 + listaPresupuestos = accesoADatos->listaPresupuestos(); 20 + listaArticulos = accesoADatos->listaArticulos(); 21 + 22 + list<Factura>::iterator iteri; 23 + for (iteri=listaFacturas.begin(); iteri != listaFacturas.end(); iteri++) { 24 + //ENLAZAMOS LOS CLIENTES A LAS FACTURAS 25 + int idcliente = accesoADatos->enlazaCliente((*iteri).getid()); 26 + list<Cliente>::iterator iterj; 27 + for (iterj=listaClientes.begin(); iterj != listaClientes.end(); iterj++) { 28 + if ((*iterj).getid() == idcliente) { 29 + (*iteri).setcliente(&(*iterj)); 30 + } 31 + } 32 + //RELLENAMOS LA FACTURA CON SUS ARTICULOS 33 + list<int> l = accesoADatos->getListaIdArticulos(&(*iteri)); 34 + list<int>::iterator iterInt; 35 + for (iterInt=l.begin(); iterInt != l.end(); iterInt++) { 36 + Articulo *a = getArticuloId(*iterInt); 37 + iteri->addArticulo(*a, accesoADatos->getCantidadArticuloFactura(&(*iteri),a)); 38 + } 39 + } 40 + 41 + list<Presupuesto>::iterator iteri2; 42 + for (iteri2=listaPresupuestos.begin(); iteri2 != listaPresupuestos.end(); iteri2++) { 43 + int idcliente = accesoADatos->enlazaClienteP((*iteri2).getid()); 44 + list<Cliente>::iterator iterj; 45 + for (iterj=listaClientes.begin(); iterj != listaClientes.end(); iterj++) { 46 + if ((*iterj).getid() == idcliente) { 47 + (*iteri2).setcliente(&(*iterj)); 48 + } 49 + } 50 + } 51 + //Para enlazar presupuestos con facturas 52 + list<Presupuesto>::iterator iteri3; 53 + for (iteri3=listaPresupuestos.begin(); iteri3 != listaPresupuestos.end(); iteri3++) { 54 + int idfactura = accesoADatos->enlazaFactura((*iteri3).getid()); 55 + list<Factura>::iterator iterj; 56 + for (iterj=listaFacturas.begin(); iterj != listaFacturas.end(); iterj++) { 57 + if ((*iterj).getid() == idfactura) { 58 + (*iteri3).setfactura(&(*iterj)); 59 + } 60 + } 61 + } 62 + cout << "[Debug]Capa de negocio cargada." << endl; 63 + } 64 + 65 + CapaNegocio::~CapaNegocio() 66 + { 67 + cout << "[Debug]Destrimos la capa de negocio." << endl; 68 + delete accesoADatos; 69 + cout << "[Debug]Capa de negocio destruida." << endl; 70 + } 71 + 72 + bool CapaNegocio::nuevaFactura(Factura *f) { 73 + int nuevoId = accesoADatos->dameIdFactura(); 74 + if (nuevoId == -1) return false; 75 + f->setid(nuevoId); 76 + if ( accesoADatos->insertaFactura(*f) ) { // Insertamos en la base de datos. 77 + listaFacturas.push_back(*f); //Si ha habido éxito, se inserta en memoria. 78 + return true; 79 + } 80 + return false; 81 + } 82 + bool CapaNegocio::nuevoCliente(Cliente *c) { 83 + int nuevoId = accesoADatos->dameIdCliente(); 84 + if (nuevoId == -1) return false; 85 + c->setid(nuevoId); 86 + if ( accesoADatos->insertaCliente(*c) ) { 87 + listaClientes.push_back(*c); 88 + return true; 89 + } 90 + return false; 91 + } 92 + bool CapaNegocio::nuevoArticulo(Articulo *a) { 93 + int nuevoId = accesoADatos->dameIdArticulo(); 94 + if (nuevoId == -1) return false; 95 + a->setid(nuevoId); 96 + if ( accesoADatos->insertaArticulo(*a) ) { 97 + listaArticulos.push_back(*a); 98 + return true; 99 + } 100 + return false; 101 + } 102 + bool CapaNegocio::nuevoPresupuesto(Presupuesto *p) { 103 + int nuevoId = accesoADatos->dameIdPresupuesto(); 104 + if (nuevoId == -1) return false; 105 + p->setid(nuevoId); 106 + if ( accesoADatos->insertaPresupuesto(*p) ) { 107 + listaPresupuestos.push_back(*p); 108 + return true; 109 + } 110 + return false; 111 + } 112 + 113 + list<Articulo> CapaNegocio::getArticulos() { 114 + list<Articulo> lista; 115 + list<Articulo>::iterator i; 116 + for(i = listaArticulos.begin(); i != listaArticulos.end(); i++) { 117 + if (!i->gethistorico() && i->getcodigo() != 0) 118 + lista.push_back((*i)); 119 + } 120 + return lista; 121 + } 122 + Articulo* CapaNegocio::getArticuloId(int id) { 123 + Articulo *a = new Articulo; 124 + list<Articulo>::iterator i; 125 + for (i = listaArticulos.begin(); i != listaArticulos.end(); i++) { 126 + if(i->getid() == id) { 127 + *a = *i; 128 + return a; 129 + } 130 + } 131 + return 0; 132 + } 133 + Articulo* CapaNegocio::getArticuloCodigo(int cod) { 134 + Articulo *a = new Articulo; 135 + list<Articulo>::iterator i; 136 + for (i = listaArticulos.begin(); i != listaArticulos.end(); i++) { 137 + if(i->getcodigo() == cod && !i->gethistorico()) { 138 + *a = *i; 139 + return a; 140 + } 141 + } 142 + return 0; 143 + } 144 + 145 + Articulo* CapaNegocio::getArticuloDescripcionPvp(string des, double pvp) { 146 + Articulo *a = new Articulo; 147 + list<Articulo>::iterator i; 148 + for (i = listaArticulos.begin(); i != listaArticulos.end(); i++) { 149 + if(i->getdescripcion() == des && i->getpvp() == pvp) { 150 + *a = *i; 151 + return a; 152 + } 153 + } 154 + return 0; 155 + } 156 + 157 + list<Factura> CapaNegocio::getFacturas() { 158 + list<Factura> l = listaFacturas; 159 + return l; 160 + } 161 + Factura* CapaNegocio::getFacturaId(int id) { 162 + Factura *f = new Factura(); 163 + list<Factura>::iterator i; 164 + for (i = listaFacturas.begin(); i != listaFacturas.end(); i++) { 165 + if(i->getid() == id) { 166 + *f = *i; 167 + return f; 168 + } 169 + } 170 + return 0; 171 + } 172 + Factura *CapaNegocio::getFacturaNumero(int n) { 173 + Factura *f = new Factura(); 174 + list<Factura>::iterator i; 175 + for (i = listaFacturas.begin(); i != listaFacturas.end(); i++) { 176 + if(i->getn_factura() == n) { 177 + *f = *i; 178 + return f; 179 + } 180 + } 181 + return 0; 182 + } 183 + list<Cliente> CapaNegocio::getClientes() { 184 + list<Cliente> lista; 185 + list<Cliente>::iterator i; 186 + for(i = listaClientes.begin(); i != listaClientes.end(); i++) { 187 + if (!i->gethistorico()) 188 + lista.push_back((*i)); 189 + } 190 + return lista; 191 + } 192 + Cliente *CapaNegocio::getClienteId(int id) { 193 + Cliente *c = new Cliente; 194 + list<Cliente>::iterator i; 195 + for (i = listaClientes.begin(); i != listaClientes.end(); i++) { 196 + if(i->getid() == id) { 197 + *c = *i; 198 + return c; 199 + } 200 + } 201 + return 0; 202 + } 203 + Cliente *CapaNegocio::getClienteCodigo(int cod) { 204 + Cliente *c = new Cliente; 205 + list<Cliente>::iterator i; 206 + for (i = listaClientes.begin(); i != listaClientes.end(); i++) { 207 + if(i->getcodigo() == cod && !i->gethistorico()) { 208 + *c = *i; 209 + return c; 210 + } 211 + } 212 + return 0; 213 + } 214 + list<Presupuesto> CapaNegocio::getPresupuestos() { 215 + list<Presupuesto> l = listaPresupuestos; 216 + return l; 217 + } 218 + Presupuesto* CapaNegocio::getPresupuestoId(int id) { 219 + Presupuesto *p = new Presupuesto(); 220 + list<Presupuesto>::iterator i; 221 + for (i = listaPresupuestos.begin(); i != listaPresupuestos.end(); i++) { 222 + if(i->getid() == id) { 223 + *p = *i; 224 + return p; 225 + } 226 + } 227 + return 0; 228 + } 229 + Presupuesto* CapaNegocio::getPresupuestoNumero(int n) { 230 + Presupuesto *p = new Presupuesto(); 231 + list<Presupuesto>::iterator i; 232 + for (i = listaPresupuestos.begin(); i != listaPresupuestos.end(); i++) { 233 + if(i->getn_factura() == n) { 234 + *p = *i; 235 + return p; 236 + } 237 + } 238 + return 0; 239 + } 240 + 241 + list<pair<int, int> > CapaNegocio::getListaTelefonos() { 242 + return accesoADatos->getListaTelefonos(); 243 + } 244 + 245 + void CapaNegocio::verClientes() { 246 + list<Cliente>::iterator i; 247 + cout << "[Debug]Lista de clientes en memoria:" << endl; 248 + for (i = listaClientes.begin(); i != listaClientes.end(); i++) { 249 + cout << (*i).getid() << " | " << (*i).getnombre() << " | " << (*i).getapellidos() <<endl; 250 + } 251 + list<Cliente> l = accesoADatos->listaClientes(); 252 + cout << "[Debug]Lista de clientes en bd:" << endl; 253 + for (i = l.begin(); i != l.end(); i++) { 254 + cout << (*i).getid() << " | " << (*i).getnombre() << " | " << (*i).getapellidos() <<endl; 255 + } 256 + } 257 + 258 + void CapaNegocio::verFacturas() { 259 + list<Factura>::iterator i; 260 + cout << "[Debug]Lista de facturas en memoria:" << endl; 261 + for (i = listaFacturas.begin(); i != listaFacturas.end(); i++) { 262 + cout << (*i).getid() << " | " << (*i).getaparato() << " | "<< i->getfecha() << endl; 263 + } 264 + list<Factura> l = accesoADatos->listaFacturas(); 265 + cout << "[Debug]Lista de facturas en bd:" << endl; 266 + for (i = l.begin(); i != l.end(); i++) { 267 + cout << (*i).getid() << " | " << (*i).getaparato() << " | "<< i->getfecha() << endl; 268 + } 269 + } 270 + 271 + void CapaNegocio::verArticulos() { 272 + list<Articulo>::iterator i; 273 + cout << "[Debug]Lista de articulos en memoria:" << endl; 274 + for (i = listaArticulos.begin(); i != listaArticulos.end(); i++) { 275 + cout << (*i).getid() << " | " << (*i).getdescripcion() <<endl; 276 + } 277 + list<Articulo> l = accesoADatos->listaArticulos(); 278 + cout << "[Debug]Lista de articulos en bd:" << endl; 279 + for (i = l.begin(); i != l.end(); i++) { 280 + cout << (*i).getid() << " | " << (*i).getdescripcion() <<endl; 281 + } 282 + 283 + 284 + } 285 + void CapaNegocio::verPresupuestos() { 286 + list<Presupuesto>::iterator i; 287 + cout << "[Debug]Lista de presupuestos en memoria:" << endl; 288 + for (i = listaPresupuestos.begin(); i != listaPresupuestos.end(); i++) { 289 + cout << (*i).getid() << " | " << (*i).getaparato() <<endl; 290 + } 291 + list<Presupuesto> l = accesoADatos->listaPresupuestos(); 292 + cout << "[Debug]Lista de presupuestos en bd:" << endl; 293 + for (i = l.begin(); i != l.end(); i++) { 294 + cout << (*i).getid() << " | " << (*i).getaparato() <<endl; 295 + } 296 + 297 + } 298 + 299 + bool CapaNegocio::modificarFactura(Factura *f) { 300 + if (accesoADatos->actualizaFactura(*f)) { 301 + list<Factura>::iterator i; 302 + for (i = listaFacturas.begin(); i != listaFacturas.end(); i++) { 303 + if(i->getid() == f->getid()) break; 304 + } 305 + if (i == listaFacturas.end()) { 306 + return nuevaFactura(f); 307 + } 308 + list<Factura>::iterator newpos = listaFacturas.erase(i); 309 + listaFacturas.insert(newpos,*f); 310 + return true; 311 + } 312 + return false; 313 + } 314 + 315 + bool CapaNegocio::modificarPresupuesto(Presupuesto *p) { 316 + if (accesoADatos->actualizaPresupuesto(*p)) { 317 + list<Presupuesto>::iterator i; 318 + for (i = listaPresupuestos.begin(); i != listaPresupuestos.end(); i++) { 319 + if(i->getid() == p->getid()) break; 320 + } 321 + if (i == listaPresupuestos.end()) { 322 + return nuevoPresupuesto(p); 323 + } 324 + list<Presupuesto>::iterator newpos = listaPresupuestos.erase(i); 325 + listaPresupuestos.insert(newpos,*p); 326 + return true; 327 + } 328 + return false; 329 + 330 + } 331 + 332 + bool CapaNegocio::modificarCliente(Cliente *c) { 333 + int nuevoId = accesoADatos->dameIdCliente(); 334 + if (nuevoId == -1) return false; 335 + if (accesoADatos->actualizaCliente(*c)) { 336 + list<Cliente>::iterator i; 337 + for (i = listaClientes.begin(); i != listaClientes.end(); i++) { 338 + if(i->getid() == c->getid()) break; 339 + } 340 + if (i == listaClientes.end()) { 341 + return nuevoCliente(c); 342 + } 343 + //list<Cliente>::iterator newpos = listaClientes.erase(i); 344 + i->sethistorico(true); 345 + c->setid(nuevoId); 346 + listaClientes.push_back(*c); 347 + return true; 348 + } 349 + return false; 350 + 351 + } 352 + 353 + bool CapaNegocio::modificarArticulo(Articulo *a) { 354 + int nuevoId = accesoADatos->dameIdArticulo(); 355 + if (nuevoId == -1) return false; 356 + if (accesoADatos->actualizaArticulo(*a)) { 357 + list<Articulo>::iterator i; 358 + for (i = listaArticulos.begin(); i != listaArticulos.end(); i++) { 359 + if(i->getid() == a->getid()) break; 360 + } 361 + if (i == listaArticulos.end()) { 362 + return nuevoArticulo(a); 363 + } 364 + //list<Articulo>::iterator newpos = listaArticulos.erase(i); 365 + i->sethistorico(true); 366 + a->setid(nuevoId); 367 + listaArticulos.push_back(*a); 368 + return true; 369 + } 370 + return false; 371 + 372 + } 373 + 374 + bool CapaNegocio::borrarFactura(Factura *f) { 375 + if (accesoADatos->eliminarFactura(*f)) { 376 + list<Factura>::iterator i; 377 + for (i = listaFacturas.begin(); i != listaFacturas.end(); i++) { 378 + if(i->getid() == f->getid()) break; 379 + } 380 + listaFacturas.erase(i); 381 + return true; 382 + } 383 + return false; 384 + } 385 + 386 + bool CapaNegocio::borrarPresupuesto(Presupuesto *p) { 387 + if (accesoADatos->eliminarPresupuesto(*p)) { 388 + list<Presupuesto>::iterator i; 389 + for (i = listaPresupuestos.begin(); i != listaPresupuestos.end(); i++) { 390 + if(i->getid() == p->getid()) break; 391 + } 392 + listaPresupuestos.erase(i); 393 + return true; 394 + } 395 + return false; 396 + } 397 + 398 + bool CapaNegocio::borrarCliente(Cliente *c) { 399 + if (accesoADatos->eliminarCliente(*c)) { 400 + list<Cliente>::iterator i; 401 + for (i = listaClientes.begin(); i != listaClientes.end(); i++) { 402 + if(i->getid() == c->getid()) break; 403 + } 404 + //listaClientes.erase(i); 405 + i->sethistorico(true); 406 + return true; 407 + } 408 + return false; 409 + 410 + } 411 + 412 + bool CapaNegocio::borrarArticulo(Articulo *a) { 413 + if (accesoADatos->eliminarArticulo(*a)) { 414 + list<Articulo>::iterator i; 415 + for (i = listaArticulos.begin(); i != listaArticulos.end(); i++) { 416 + if(i->getid() == a->getid()) break; 417 + } 418 + //listaArticulos.erase(i); 419 + i->sethistorico(true); 420 + return true; 421 + } 422 + return false; 423 + 424 + } 425 + 426 + int CapaNegocio::getTotalArticulos() { 427 + list<Articulo>::iterator i; 428 + int c = 0; 429 + for (i = listaArticulos.begin(); i != listaArticulos.end(); i++) 430 + if (i->gethistorico() == false) c++; 431 + return c; 432 + } 433 + int CapaNegocio::getTotalClientes() { 434 + list<Cliente>::iterator i; 435 + int c = 0; 436 + for (i = listaClientes.begin(); i != listaClientes.end(); i++) 437 + if (i->gethistorico() == false) c++; 438 + return c; 439 + } 440 + int CapaNegocio::getTotalFacturas() { 441 + return listaFacturas.size(); 442 + } 443 + int CapaNegocio::getTotalPresupuestos() { 444 + return listaPresupuestos.size(); 445 + } 446 + 447 + bool CapaNegocio::cambiarIva(int v) { 448 + if (accesoADatos->cambiarIva(v)) 449 + return true; 450 + return false; 451 + } 452 + 453 + int CapaNegocio::obtenerIva() { 454 + return accesoADatos->obtenerIva(); 455 + } 456 + 457 + int CapaNegocio::getUltimoCodigoFactura() { 458 + int anyo = QDate().currentDate().toString("yy").toInt(); 459 + list<Factura>::iterator it = listaFacturas.begin(); 460 + int max = 0; 461 + for (;it != listaFacturas.end(); it++) { 462 + if ((it->getn_factura() / 10000) == anyo ) { 463 + if (it->getn_factura() > max) 464 + max = it->getn_factura(); 465 + } 466 + } 467 + return anyo*10000 + (max % 10000) + 1; 468 + } 469 + int CapaNegocio::getUltimoCodigoCliente() { 470 + list<Cliente>::iterator it = listaClientes.begin(); 471 + int max = 0; 472 + for (;it != listaClientes.end(); it++) { 473 + if (it->gethistorico() == false && it->getcodigo() > max) { 474 + max = it->getcodigo(); 475 + } 476 + } 477 + return max + 1; 478 + } 479 + int CapaNegocio::getUltimoCodigoPresupuesto() { 480 + list<Presupuesto>::iterator it = listaPresupuestos.begin(); 481 + int max = 0; 482 + for (;it != listaPresupuestos.end(); it++) { 483 + if (it->getn_factura() > max) { 484 + max = it->getn_factura(); 485 + } 486 + } 487 + return max + 1; 488 + } 489 + 490 + list<Cliente> CapaNegocio::getClientesRango(int del, int al){ 491 + 492 + list<Cliente> l; 493 + 494 + if(del < 0 || al < 0 ){ 495 + return l; 496 + } 497 + 498 + 499 + list<Cliente>::iterator it; 500 + 501 + for(it = listaClientes.begin(); it != listaClientes.end(); it++){ 502 + int n = it->getcodigo(); 503 + if(n >= del && n <= al){ 504 + l.push_back(*it); 505 + } 506 + } 507 + return l; 508 + }
+73
Negocio/CapaNegocio.h
··· 1 + #ifndef CAPANEGOCIO_H_ 2 + #define CAPANEGOCIO_H_ 3 + #include "../Datos/AccesoADatos.h" 4 + #include "Factura.h" 5 + #include "Cliente.h" 6 + #include "Presupuesto.h" 7 + #include "Articulo.h" 8 + #include <list> 9 + 10 + class CapaNegocio 11 + { 12 + AccesoADatos* accesoADatos; 13 + list <Factura> listaFacturas; 14 + list <Cliente> listaClientes; 15 + list <Presupuesto> listaPresupuestos; 16 + list <Articulo> listaArticulos; 17 + public: 18 + CapaNegocio(); 19 + 20 + void inicializar(); 21 + 22 + bool modificarFactura(Factura *f); 23 + bool modificarCliente(Cliente *f); 24 + bool modificarPresupuesto(Presupuesto *p); 25 + bool modificarArticulo(Articulo *a); 26 + 27 + bool borrarFactura(Factura *f); 28 + bool borrarPresupuesto(Presupuesto *p); 29 + bool borrarCliente(Cliente *c); 30 + bool borrarArticulo(Articulo *a); 31 + 32 + bool nuevaFactura(Factura *f); 33 + bool nuevoCliente(Cliente *c); 34 + bool nuevoPresupuesto(Presupuesto *p); 35 + bool nuevoArticulo(Articulo *a); 36 + 37 + list<Articulo> getArticulos(); 38 + Articulo *getArticuloId(int id); 39 + Articulo *getArticuloCodigo(int cod); 40 + Articulo *getArticuloDescripcionPvp(string des, double pvp); 41 + int getTotalArticulos(); 42 + list<Factura> getFacturas(); 43 + Factura *getFacturaId(int id); 44 + Factura *getFacturaNumero(int n); 45 + int getTotalFacturas(); 46 + list<Cliente> getClientes(); 47 + Cliente *getClienteId(int id); 48 + Cliente *getClienteCodigo(int cod); 49 + int getTotalClientes(); 50 + list<Presupuesto> getPresupuestos(); 51 + Presupuesto *getPresupuestoId(int id); 52 + Presupuesto *getPresupuestoNumero(int n); 53 + int getTotalPresupuestos(); 54 + 55 + void verClientes(); 56 + void verFacturas(); 57 + void verArticulos(); 58 + void verPresupuestos(); 59 + 60 + bool cambiarIva(int v); 61 + int obtenerIva(); 62 + 63 + list<pair<int, int> > getListaTelefonos(); 64 + int getUltimoCodigoFactura(); 65 + int getUltimoCodigoCliente(); 66 + int getUltimoCodigoPresupuesto(); 67 + 68 + list<Cliente> getClientesRango(int del, int al); 69 + 70 + virtual ~CapaNegocio(); 71 + }; 72 + 73 + #endif /*CAPANEGOCIO_H_*/
+111
Negocio/Cliente.cpp
··· 1 + #include "Cliente.h" 2 + #include <string> 3 + using namespace std; 4 + 5 + Cliente::Cliente() 6 + { 7 + nombre = ""; 8 + apellidos=""; 9 + direccion=""; 10 + poblacion=""; 11 + nif=""; 12 + codigo = -1; 13 + historico = false; 14 + } 15 + 16 + Cliente::~Cliente() 17 + { 18 + } 19 + //metodos get 20 + 21 + int Cliente::getid(){ 22 + return id; 23 + } 24 + 25 + int Cliente::getcodigo(){ 26 + return codigo; 27 + } 28 + 29 + string Cliente::getnombre(){ 30 + return nombre; 31 + } 32 + 33 + string Cliente::getapellidos(){ 34 + return apellidos; 35 + } 36 + 37 + string Cliente::getdireccion(){ 38 + return direccion; 39 + } 40 + 41 + string Cliente::getnif(){ 42 + return nif; 43 + } 44 + 45 + string Cliente::getpoblacion(){ 46 + return poblacion; 47 + } 48 + 49 + bool Cliente::gethistorico() { 50 + return historico; 51 + } 52 + 53 + list<int> Cliente::gettelefonos() { 54 + return telefonos; 55 + } 56 + 57 + //metodos set 58 + 59 + void Cliente::setid(int ident){ 60 + id=ident; 61 + } 62 + 63 + void Cliente::setcodigo(int cod){ 64 + codigo=cod; 65 + } 66 + 67 + void Cliente::setnombre(string nom){ 68 + nombre=nom; 69 + } 70 + 71 + void Cliente::setapellidos(string apell){ 72 + apellidos=apell; 73 + } 74 + 75 + void Cliente::setdireccion(string dir){ 76 + direccion=dir; 77 + } 78 + 79 + void Cliente::setnif(string ni){ 80 + nif=ni; 81 + } 82 + 83 + void Cliente::setpoblacion(string pob){ 84 + poblacion=pob; 85 + } 86 + 87 + void Cliente::sethistorico(bool h) { 88 + historico = h; 89 + } 90 + 91 + void Cliente::settelefonos(list<int> t) { 92 + telefonos = t; 93 + } 94 + 95 + //sobrecarga del operador = 96 + 97 + Cliente Cliente::operator=(Cliente c){ 98 + 99 + if (this != &c) { 100 + this->id = c.getid(); 101 + this->codigo = c.getcodigo(); 102 + this->nombre = c.getnombre(); 103 + this->apellidos = c.getapellidos(); 104 + this->direccion = c.getdireccion(); 105 + this->nif = c.getnif(); 106 + this->poblacion = c.getpoblacion(); 107 + this->historico = c.gethistorico(); 108 + this->telefonos = c.gettelefonos(); 109 + } 110 + return *this; 111 + }
+51
Negocio/Cliente.h
··· 1 + #ifndef CLIENTE_H_ 2 + #define CLIENTE_H_ 3 + #include <string> 4 + #include <list> 5 + using namespace std; 6 + 7 + class Cliente 8 + { 9 + private: 10 + int id; 11 + int codigo; 12 + string nombre; 13 + string apellidos; 14 + string direccion; 15 + string nif; 16 + string poblacion; 17 + bool historico; 18 + list<int> telefonos; 19 + 20 + public: 21 + Cliente(); 22 + virtual ~Cliente(); 23 + 24 + //metodos get 25 + int getid(); 26 + int getcodigo(); 27 + string getnombre(); 28 + string getapellidos(); 29 + string getdireccion(); 30 + string getnif(); 31 + string getpoblacion(); 32 + bool gethistorico(); 33 + list<int> gettelefonos(); 34 + 35 + //metodos set 36 + void setid(int id); 37 + void setcodigo(int codigo); 38 + void setnombre(string nombre); 39 + void setapellidos(string apellidos); 40 + void setdireccion(string direccion); 41 + void setnif(string nif); 42 + void setpoblacion(string poblacion); 43 + void sethistorico(bool h); 44 + void settelefonos(list<int> t); 45 + 46 + //sobrecarga de operador igual 47 + Cliente operator=(Cliente c); 48 + 49 + }; 50 + 51 + #endif /*CLIENTE_H_*/
+263
Negocio/Factura.cpp
··· 1 + #include "Factura.h" 2 + #include "Articulo.h" 3 + #include <string> 4 + #include <list> 5 + #include <iostream> 6 + 7 + using namespace std; 8 + 9 + Factura::Factura() 10 + { 11 + // Para que el puntero no este sin inicializar 12 + n_factura = -1; 13 + n_fabricacion = -1; 14 + cliente = 0; 15 + lugar_reparacion = 0; 16 + aparato = ""; 17 + fecha =""; 18 + marca = ""; 19 + modelo = ""; 20 + averia = ""; 21 + trabajo_realizado = ""; 22 + tiempo_empleado = ""; 23 + fecha_terminacion = ""; 24 + observaciones = ""; 25 + precio_materiales = 0.; 26 + precio_mano_obra = 0.; 27 + precio_desplazamiento = 0.; 28 + precio_transporte = 0.; 29 + 30 + 31 + } 32 + 33 + Factura::~Factura() 34 + { 35 + //if(lugar_reparacion) delete lugar_reparacion; 36 + } 37 + 38 + 39 + int Factura::getid(){ 40 + return id; 41 + } 42 + 43 + int Factura::getn_factura(){ 44 + return n_factura; 45 + } 46 + 47 + string Factura::getfecha(){ 48 + return fecha; 49 + } 50 + 51 + string Factura::getaparato(){ 52 + return aparato; 53 + } 54 + 55 + string Factura::getmarca(){ 56 + return marca; 57 + } 58 + 59 + string Factura::getmodelo(){ 60 + return modelo; 61 + } 62 + 63 + int Factura::getn_fabricacion(){ 64 + return n_fabricacion; 65 + } 66 + 67 + bool *Factura::getlugar_reparacion(){ 68 + return lugar_reparacion; 69 + } 70 + 71 + Cliente *Factura::getcliente(){ 72 + return cliente; 73 + } 74 + list<LineaArticulo> Factura::getlista_articulos() { 75 + return lista_articulos; 76 + } 77 + string Factura::getaveria() { 78 + return averia; 79 + } 80 + string Factura::gettrabajo_realizado() { 81 + return trabajo_realizado; 82 + } 83 + string Factura::gettiempo_empleado() { 84 + return tiempo_empleado; 85 + } 86 + string Factura::getfecha_terminacion() { 87 + return fecha_terminacion; 88 + } 89 + string Factura::getobservaciones() { 90 + return observaciones; 91 + } 92 + double Factura::getprecio_materiales() { 93 + return precio_materiales; 94 + } 95 + double Factura::getprecio_mano_obra() { 96 + return precio_mano_obra; 97 + } 98 + double Factura::getprecio_desplazamiento() { 99 + return precio_desplazamiento; 100 + } 101 + double Factura::getprecio_transporte() { 102 + return precio_transporte; 103 + } 104 + double Factura::getiva() { 105 + return iva; 106 + } 107 + //Metodos set 108 + void Factura::setid(int iden){ 109 + id=iden; 110 + } 111 + 112 + void Factura::setn_factura(int n_fact){ 113 + n_factura=n_fact; 114 + } 115 + 116 + void Factura::setfecha(string fec){ 117 + fecha=fec; 118 + } 119 + 120 + void Factura::setaparato(string aparat){ 121 + aparato=aparat; 122 + } 123 + 124 + void Factura::setmarca(string marc){ 125 + marca=marc; 126 + } 127 + 128 + void Factura::setmodelo(string mod){ 129 + modelo=mod; 130 + } 131 + 132 + void Factura::setn_fabricacion(int n_fabric){ 133 + n_fabricacion=n_fabric; 134 + } 135 + 136 + void Factura::setlugar_reparacion(bool *lugar){ 137 + lugar_reparacion=lugar; 138 + } 139 + 140 + void Factura::setcliente(Cliente *cli){ 141 + cliente=cli; 142 + } 143 + void Factura::setlista_articulos(list<LineaArticulo> l) { 144 + lista_articulos = l; 145 + } 146 + void Factura::setaveria(string a) { 147 + averia = a; 148 + } 149 + void Factura::settrabajo_realizado(string t) { 150 + trabajo_realizado = t; 151 + } 152 + void Factura::settiempo_empleado(string t) { 153 + tiempo_empleado = t; 154 + } 155 + void Factura::setfecha_terminacion(string f) { 156 + fecha_terminacion = f; 157 + } 158 + void Factura::setobservaciones(string o) { 159 + observaciones = o; 160 + } 161 + void Factura::setprecio_materiales(double p) { 162 + precio_materiales = p; 163 + } 164 + void Factura::setprecio_mano_obra(double p) { 165 + precio_mano_obra = p; 166 + } 167 + void Factura::setprecio_desplazamiento(double p) { 168 + precio_desplazamiento = p; 169 + } 170 + void Factura::setprecio_transporte(double p) { 171 + precio_transporte = p; 172 + } 173 + 174 + void Factura::addArticulo(LineaArticulo la) { 175 + lista_articulos.push_back(la); 176 + } 177 + 178 + void Factura::setiva(double i) { 179 + iva = i; 180 + } 181 + void Factura::addArticulo(Articulo a, int c) { 182 + LineaArticulo la; 183 + la.setarticulo(a); 184 + la.setcantidad(c); 185 + lista_articulos.push_back(la); 186 + } 187 + bool Factura::eliminarArticulo(Articulo a) { 188 + list<LineaArticulo>::iterator i; 189 + for (i=lista_articulos.begin(); i != lista_articulos.end(); i++) { 190 + cout << (*i).getarticulo().getid()<< endl; 191 + if ((*i).getarticulo().getid() == a.getid()) { 192 + lista_articulos.erase(i); 193 + return true; 194 + } 195 + } 196 + return false; 197 + } 198 + 199 + bool Factura::modificarArticulo(Articulo a, int c) { 200 + list<LineaArticulo>::iterator i; 201 + for (i=lista_articulos.begin(); i != lista_articulos.end(); i++) { 202 + if ((*i).getarticulo().getid() == a.getid()) { 203 + (*i).setarticulo(a); 204 + (*i).setcantidad(c); 205 + return true; 206 + } 207 + } 208 + return false; 209 + } 210 + bool Factura::modificarArticulo(LineaArticulo la) { 211 + list<LineaArticulo>::iterator i; 212 + for (i=lista_articulos.begin(); i != lista_articulos.end(); i++) { 213 + if ((*i).getarticulo().getid() == la.getarticulo().getid()) { 214 + list<LineaArticulo>::iterator newpos = lista_articulos.erase(i); 215 + lista_articulos.insert(newpos,la); 216 + return true; 217 + } 218 + } 219 + return false; 220 + 221 + } 222 + //sobrecarga del operador = 223 + Factura Factura::operator=(Factura f){ 224 + if (&f != this) { 225 + id = f.getid(); 226 + n_factura = f.getn_factura(); 227 + fecha = f.getfecha(); 228 + aparato = f.getaparato(); 229 + marca = f.getmarca(); 230 + modelo = f.getmodelo(); 231 + n_fabricacion = f.getn_fabricacion(); 232 + setlugar_reparacion(f.getlugar_reparacion()); 233 + cliente = f.getcliente(); 234 + lista_articulos = f.getlista_articulos(); 235 + averia = f.getaveria(); 236 + trabajo_realizado = f.gettrabajo_realizado(); 237 + tiempo_empleado = f.gettiempo_empleado(); 238 + fecha_terminacion = f.getfecha_terminacion(); 239 + observaciones = f.getobservaciones(); 240 + precio_materiales = f.getprecio_materiales(); 241 + precio_mano_obra = f.getprecio_mano_obra(); 242 + precio_desplazamiento = f.getprecio_desplazamiento(); 243 + precio_transporte = f.getprecio_transporte(); 244 + iva = f.getiva(); 245 + } 246 + return (*this); 247 + } 248 + double Factura::getMateriales () { 249 + double s = 0.0; 250 + list<LineaArticulo>::iterator i; 251 + for (i=lista_articulos.begin(); i != lista_articulos.end(); i++) { 252 + s += i->getpreciototal(); 253 + } 254 + return s; 255 + } 256 + double Factura::getSubTotal(){ 257 + return getMateriales() + getprecio_mano_obra() + getprecio_desplazamiento() + getprecio_transporte(); 258 + } 259 + double Factura::getTotal(){ 260 + double total = getSubTotal(); 261 + return total + (iva / 100.0) * total; 262 + } 263 +
+99
Negocio/Factura.h
··· 1 + #ifndef FACTURA_H_ 2 + #define FACTURA_H_ 3 + #include "Cliente.h" 4 + #include "LineaArticulo.h" 5 + #include "Articulo.h" 6 + #include <string> 7 + #include <list> 8 + 9 + using namespace std; 10 + 11 + class Factura 12 + { 13 + 14 + private: 15 + int id; 16 + int n_factura; 17 + string fecha; 18 + string aparato; 19 + string marca; 20 + string modelo; 21 + int n_fabricacion; 22 + bool *lugar_reparacion; 23 + Cliente *cliente; 24 + list <LineaArticulo> lista_articulos; 25 + string averia; 26 + string trabajo_realizado; 27 + string tiempo_empleado; 28 + string fecha_terminacion; 29 + string observaciones; 30 + double precio_materiales; 31 + double precio_mano_obra; 32 + double precio_desplazamiento; 33 + double precio_transporte; 34 + int iva; 35 + 36 + public: 37 + Factura(); 38 + virtual ~Factura(); 39 + 40 + //metodos get 41 + int getid(); 42 + int getn_factura(); 43 + string getfecha(); 44 + string getaparato(); 45 + string getmarca(); 46 + string getmodelo(); 47 + int getn_fabricacion(); 48 + bool *getlugar_reparacion(); 49 + Cliente *getcliente(); 50 + list<LineaArticulo> getlista_articulos(); 51 + string getaveria(); 52 + string gettrabajo_realizado(); 53 + string gettiempo_empleado(); 54 + string getfecha_terminacion(); 55 + string getobservaciones(); 56 + double getprecio_materiales(); 57 + double getprecio_mano_obra(); 58 + double getprecio_desplazamiento(); 59 + double getprecio_transporte(); 60 + double getiva(); 61 + 62 + //metodos set 63 + void setid(int id); 64 + void setn_factura(int n_factura); 65 + void setfecha(string fecha); 66 + void setaparato(string aparato); 67 + void setmarca(string marca); 68 + void setmodelo(string modelo); 69 + void setn_fabricacion(int n_fabricacion); 70 + void setlugar_reparacion(bool *lugar_reparacion); 71 + void setcliente(Cliente *cliente); 72 + void setlista_articulos(list <LineaArticulo> l); 73 + void setaveria(string a); 74 + void settrabajo_realizado(string t); 75 + void settiempo_empleado(string t); 76 + void setfecha_terminacion(string f); 77 + void setobservaciones(string o); 78 + void setprecio_materiales(double p); 79 + void setprecio_mano_obra(double p); 80 + void setprecio_desplazamiento(double p); 81 + void setprecio_transporte(double p); 82 + void setiva(double i); 83 + 84 + //metodos para la lista de articulos 85 + void addArticulo(LineaArticulo la); 86 + void addArticulo(Articulo a, int c); 87 + bool eliminarArticulo(Articulo a); 88 + bool modificarArticulo(Articulo a, int c); 89 + bool modificarArticulo(LineaArticulo la); 90 + 91 + double getMateriales (); 92 + double getSubTotal(); 93 + double getTotal(); 94 + 95 + //sobrecrga del operador = 96 + Factura operator=(Factura f); 97 + }; 98 + 99 + #endif
+33
Negocio/LineaArticulo.cpp
··· 1 + #include "LineaArticulo.h" 2 + #include <iostream> 3 + 4 + using namespace std; 5 + 6 + LineaArticulo::LineaArticulo() 7 + { 8 + cantidad = 0; 9 + } 10 + 11 + LineaArticulo::~LineaArticulo() 12 + { 13 + } 14 + 15 + int LineaArticulo::getcantidad() { 16 + return cantidad; 17 + } 18 + Articulo LineaArticulo::getarticulo() { 19 + return articulo; 20 + } 21 + double LineaArticulo::getpreciototal() { 22 + if (articulo.getid() != -1) { 23 + return (articulo.getpvp() -(articulo.getpvp())*(articulo.getdescuento()/100.0))*cantidad ; 24 + } 25 + return 0; 26 + } 27 + 28 + void LineaArticulo::setcantidad(int c) { 29 + cantidad = c; 30 + } 31 + void LineaArticulo::setarticulo(Articulo a){ 32 + articulo = a; 33 + }
+23
Negocio/LineaArticulo.h
··· 1 + #ifndef LINEAARTICULO_H_ 2 + #define LINEAARTICULO_H_ 3 + #include "Articulo.h" 4 + 5 + class LineaArticulo 6 + { 7 + private: 8 + int cantidad; 9 + Articulo articulo; 10 + public: 11 + LineaArticulo(); 12 + virtual ~LineaArticulo(); 13 + 14 + int getcantidad(); 15 + Articulo getarticulo(); 16 + double getpreciototal(); 17 + 18 + void setcantidad(int c); 19 + void setarticulo(Articulo a); 20 + 21 + }; 22 + 23 + #endif /*LINEAARTICULO_H_*/
+277
Negocio/Presupuesto.cpp
··· 1 + #include "Presupuesto.h" 2 + #include <string> 3 + 4 + Presupuesto::Presupuesto() 5 + { 6 + n_factura = -1; 7 + n_fabricacion = -1; 8 + fecha = ""; 9 + aparato = ""; 10 + marca = ""; 11 + modelo = ""; 12 + aceptado = 0; 13 + lugar_reparacion = 0; 14 + cliente = 0; 15 + factura = 0; 16 + averia = ""; 17 + trabajo_realizado = ""; 18 + tiempo_empleado = ""; 19 + fecha_terminacion = ""; 20 + observaciones = ""; 21 + precio_materiales = 0.; 22 + precio_mano_obra = 0.; 23 + precio_desplazamiento = 0.; 24 + precio_transporte = 0.; 25 + } 26 + 27 + Presupuesto::~Presupuesto() 28 + { 29 + //if(aceptado) delete aceptado; 30 + //if(lugar_reparacion) delete lugar_reparacion; 31 + } 32 + 33 + //Metodos get 34 + 35 + int Presupuesto::getid(){ 36 + return id; 37 + } 38 + 39 + bool* Presupuesto::getaceptado(){ 40 + return aceptado; 41 + } 42 + 43 + Cliente* Presupuesto::getcliente(){ 44 + return cliente; 45 + } 46 + 47 + Factura* Presupuesto::getfactura(){ 48 + return factura; 49 + } 50 + 51 + int Presupuesto::getn_factura(){ 52 + return n_factura; 53 + } 54 + 55 + string Presupuesto::getfecha(){ 56 + return fecha; 57 + } 58 + 59 + string Presupuesto::getaparato(){ 60 + return aparato; 61 + } 62 + 63 + string Presupuesto::getmarca(){ 64 + return marca; 65 + } 66 + 67 + string Presupuesto::getmodelo(){ 68 + return modelo; 69 + } 70 + 71 + int Presupuesto::getn_fabricacion(){ 72 + return n_fabricacion; 73 + } 74 + 75 + bool *Presupuesto::getlugar_reparacion(){ 76 + return lugar_reparacion; 77 + } 78 + list<LineaArticulo> Presupuesto::getlista_articulos() { 79 + return lista_articulos; 80 + } 81 + string Presupuesto::getaveria() { 82 + return averia; 83 + } 84 + string Presupuesto::gettrabajo_realizado() { 85 + return trabajo_realizado; 86 + } 87 + string Presupuesto::gettiempo_empleado() { 88 + return tiempo_empleado; 89 + } 90 + string Presupuesto::getfecha_terminacion() { 91 + return fecha_terminacion; 92 + } 93 + string Presupuesto::getobservaciones() { 94 + return observaciones; 95 + } 96 + double Presupuesto::getprecio_materiales() { 97 + return precio_materiales; 98 + } 99 + double Presupuesto::getprecio_mano_obra() { 100 + return precio_mano_obra; 101 + } 102 + double Presupuesto::getprecio_desplazamiento() { 103 + return precio_desplazamiento; 104 + } 105 + double Presupuesto::getprecio_transporte() { 106 + return precio_transporte; 107 + } 108 + double Presupuesto::getiva() { 109 + return iva; 110 + } 111 + //Metodos set 112 + void Presupuesto::setid(int iden){ 113 + id=iden; 114 + } 115 + 116 + void Presupuesto::setaceptado(bool acep){ 117 + if(!aceptado) aceptado = new bool; 118 + *aceptado=acep; 119 + } 120 + 121 + void Presupuesto::setcliente(Cliente *c){ 122 + cliente=c; 123 + } 124 + 125 + void Presupuesto::setfactura(Factura *fact){ 126 + factura=fact; 127 + } 128 + 129 + void Presupuesto::setn_factura(int n_fact){ 130 + n_factura=n_fact; 131 + } 132 + 133 + void Presupuesto::setfecha(string fech){ 134 + fecha=fech; 135 + } 136 + 137 + void Presupuesto::setaparato(string apar){ 138 + aparato=apar; 139 + } 140 + 141 + void Presupuesto::setmarca(string marc){ 142 + marca=marc; 143 + } 144 + 145 + void Presupuesto::setmodelo(string mod){ 146 + modelo=mod; 147 + } 148 + 149 + void Presupuesto::setn_fabricacion(int n_fab){ 150 + n_fabricacion=n_fab; 151 + } 152 + 153 + void Presupuesto::setlugar_reparacion(bool *lugar){ 154 + lugar_reparacion=lugar; 155 + } 156 + 157 + void Presupuesto::setlista_articulos(list<LineaArticulo> l) { 158 + lista_articulos = l; 159 + } 160 + void Presupuesto::setaveria(string a) { 161 + averia = a; 162 + } 163 + void Presupuesto::settrabajo_realizado(string t) { 164 + trabajo_realizado = t; 165 + } 166 + void Presupuesto::settiempo_empleado(string t) { 167 + tiempo_empleado = t; 168 + } 169 + void Presupuesto::setfecha_terminacion(string f) { 170 + fecha_terminacion = f; 171 + } 172 + void Presupuesto::setobservaciones(string o) { 173 + observaciones = o; 174 + } 175 + void Presupuesto::setprecio_materiales(double p) { 176 + precio_materiales = p; 177 + } 178 + void Presupuesto::setprecio_mano_obra(double p) { 179 + precio_mano_obra = p; 180 + } 181 + void Presupuesto::setprecio_desplazamiento(double p) { 182 + precio_desplazamiento = p; 183 + } 184 + void Presupuesto::setprecio_transporte(double p) { 185 + precio_transporte = p; 186 + } 187 + void Presupuesto::setiva(double i) { 188 + iva = i; 189 + } 190 + void Presupuesto::addArticulo(LineaArticulo la) { 191 + lista_articulos.push_back(la); 192 + } 193 + void Presupuesto::addArticulo(Articulo a, int c) { 194 + LineaArticulo la; 195 + la.setarticulo(a); 196 + la.setcantidad(c); 197 + lista_articulos.push_back(la); 198 + } 199 + bool Presupuesto::eliminarArticulo(Articulo a) { 200 + list<LineaArticulo>::iterator i; 201 + for (i=lista_articulos.begin(); i != lista_articulos.end(); i++) { 202 + if ((*i).getarticulo().getid() == a.getid()) { 203 + lista_articulos.erase(i); 204 + return true; 205 + } 206 + } 207 + return false; 208 + } 209 + 210 + bool Presupuesto::modificarArticulo(Articulo a, int c) { 211 + list<LineaArticulo>::iterator i; 212 + for (i=lista_articulos.begin(); i != lista_articulos.end(); i++) { 213 + if ((*i).getarticulo().getid() == a.getid()) { 214 + (*i).setarticulo(a); 215 + (*i).setcantidad(c); 216 + return true; 217 + } 218 + } 219 + return false; 220 + } 221 + bool Presupuesto::modificarArticulo(LineaArticulo la) { 222 + list<LineaArticulo>::iterator i; 223 + for (i=lista_articulos.begin(); i != lista_articulos.end(); i++) { 224 + if ((*i).getarticulo().getid() == la.getarticulo().getid()) { 225 + list<LineaArticulo>::iterator newpos = lista_articulos.erase(i); 226 + lista_articulos.insert(newpos,la); 227 + return true; 228 + } 229 + } 230 + return false; 231 + 232 + } 233 + //sobrecarga del operador = 234 + Presupuesto Presupuesto::operator=(Presupuesto p){ 235 + if (&p != this) { 236 + id = p.getid(); 237 + n_factura = p.getn_factura(); 238 + fecha = p.getfecha(); 239 + aparato = p.getaparato(); 240 + marca =p.getmarca(); 241 + modelo = p.getmodelo(); 242 + n_fabricacion = p.getn_fabricacion(); 243 + setlugar_reparacion(p.getlugar_reparacion()); 244 + setcliente(p.getcliente()); 245 + lista_articulos = p.getlista_articulos(); 246 + setaceptado(p.getaceptado()); 247 + setfactura(p.getfactura()); 248 + setiva(p.getiva()); 249 + averia = p.getaveria(); 250 + trabajo_realizado = p.gettrabajo_realizado(); 251 + tiempo_empleado = p.gettiempo_empleado(); 252 + fecha_terminacion = p.getfecha_terminacion(); 253 + observaciones = p.getobservaciones(); 254 + precio_materiales = p.getprecio_materiales(); 255 + precio_mano_obra = p.getprecio_mano_obra(); 256 + precio_desplazamiento = p.getprecio_desplazamiento(); 257 + precio_transporte = p.getprecio_transporte(); 258 + 259 + } 260 + return (*this); 261 + } 262 + double Presupuesto::getMateriales () { 263 + double s = 0.0; 264 + list<LineaArticulo>::iterator i; 265 + for (i=lista_articulos.begin(); i != lista_articulos.end(); i++) { 266 + s += i->getpreciototal(); 267 + } 268 + return s; 269 + } 270 + double Presupuesto::getSubTotal(){ 271 + return getMateriales() + getprecio_mano_obra() + getprecio_desplazamiento() + getprecio_transporte(); 272 + } 273 + double Presupuesto::getTotal(){ 274 + double total = getSubTotal(); 275 + return total + (iva / 100.0) * total; 276 + } 277 +
+106
Negocio/Presupuesto.h
··· 1 + #ifndef PRESUPUESTO_H_ 2 + #define PRESUPUESTO_H_ 3 + #include "Factura.h" 4 + #include <iostream> 5 + #include <string> 6 + 7 + using namespace std; 8 + 9 + class Presupuesto 10 + { 11 + 12 + private: 13 + int id; 14 + bool *aceptado; 15 + Cliente* cliente; 16 + Factura* factura; 17 + int n_factura; 18 + string fecha; 19 + string aparato; 20 + string marca; 21 + string modelo; 22 + int n_fabricacion; 23 + bool *lugar_reparacion; 24 + list <LineaArticulo> lista_articulos; 25 + string averia; 26 + string trabajo_realizado; 27 + string tiempo_empleado; 28 + string fecha_terminacion; 29 + string observaciones; 30 + double precio_materiales; 31 + double precio_mano_obra; 32 + double precio_desplazamiento; 33 + double precio_transporte; 34 + double iva; 35 + 36 + public: 37 + Presupuesto(); 38 + virtual ~Presupuesto(); 39 + 40 + //Metodos get 41 + int getid(); 42 + bool *getaceptado(); 43 + Cliente* getcliente(); 44 + Factura* getfactura(); 45 + int getn_factura(); 46 + string getfecha(); 47 + string getaparato(); 48 + string getmarca(); 49 + string getmodelo(); 50 + int getn_fabricacion(); 51 + bool *getlugar_reparacion(); 52 + list<LineaArticulo> getlista_articulos(); 53 + string getaveria(); 54 + string gettrabajo_realizado(); 55 + string gettiempo_empleado(); 56 + string getfecha_terminacion(); 57 + string getobservaciones(); 58 + double getprecio_materiales(); 59 + double getprecio_mano_obra(); 60 + double getprecio_desplazamiento(); 61 + double getprecio_transporte(); 62 + double getiva(); 63 + 64 + //Metodos set 65 + 66 + void setid(int id); 67 + void setaceptado(bool aceptado); 68 + void setcliente(Cliente* cliente); 69 + void setfactura(Factura* factura); 70 + void setn_factura(int n_factura); 71 + void setfecha(string fecha); 72 + void setaparato(string aparato); 73 + void setmarca(string marca); 74 + void setmodelo(string modelo); 75 + void setn_fabricacion(int n_fabricacion); 76 + void setlugar_reparacion(bool *lugar_reparacion); 77 + void setlista_articulos(list <LineaArticulo> l); 78 + void setaveria(string a); 79 + void settrabajo_realizado(string t); 80 + void settiempo_empleado(string t); 81 + void setfecha_terminacion(string f); 82 + void setobservaciones(string o); 83 + void setprecio_materiales(double p); 84 + void setprecio_mano_obra(double p); 85 + void setprecio_desplazamiento(double p); 86 + void setprecio_transporte(double p); 87 + void setiva(double i); 88 + 89 + //metodos para la lista de articulos 90 + void addArticulo(LineaArticulo la); 91 + void addArticulo(Articulo a, int c); 92 + bool eliminarArticulo(Articulo a); 93 + bool modificarArticulo(Articulo a, int c); 94 + bool modificarArticulo(LineaArticulo la); 95 + 96 + 97 + 98 + double getMateriales (); 99 + double getSubTotal(); 100 + double getTotal(); 101 + 102 + //sobrecrga del operador = 103 + Presupuesto operator=(Presupuesto p); 104 + }; 105 + 106 + #endif /*PRESUPUESTO_H_*/
+78
Seoane.pro
··· 1 + TEMPLATE = app 2 + TARGET = seoane 3 + QT += core \ 4 + gui \ 5 + sql 6 + HEADERS += Negocio/Articulo.h \ 7 + Negocio/CapaNegocio.h \ 8 + Negocio/Cliente.h \ 9 + Negocio/Factura.h \ 10 + Negocio/LineaArticulo.h \ 11 + Negocio/Presupuesto.h \ 12 + Gui/BuscarArticuloDialog.h \ 13 + Gui/BuscarClienteDialog.h \ 14 + Gui/BuscarFacturaDialog.h \ 15 + Gui/BuscarPresupuestoDialog.h \ 16 + Gui/CambiarIvaDialog.h \ 17 + Gui/ConfigurarImpresora.h \ 18 + Gui/ListarArticulos.h \ 19 + Gui/ListarClientes.h \ 20 + Gui/ListarFacturas.h \ 21 + Gui/ListarPresupuestos.h \ 22 + Gui/MainWindow.h \ 23 + Gui/NuevaFacturaDialog.h \ 24 + Gui/NuevoArticuloDialog.h \ 25 + Gui/NuevoClienteDialog.h \ 26 + Gui/NuevoPresupuestoDialog.h \ 27 + Gui/PrintWindow.h \ 28 + Gui/VisorAyuda.h \ 29 + Gui/imprimirsobrecliente.h \ 30 + Datos/AccesoADatos.h \ 31 + Datos/CriterioBusqueda.h \ 32 + Datos/utils.h 33 + SOURCES += Negocio/Articulo.cpp \ 34 + Negocio/CapaNegocio.cpp \ 35 + Negocio/Cliente.cpp \ 36 + Negocio/Factura.cpp \ 37 + Negocio/LineaArticulo.cpp \ 38 + Negocio/Presupuesto.cpp \ 39 + Gui/BuscarArticuloDialog.cpp \ 40 + Gui/BuscarClienteDialog.cpp \ 41 + Gui/BuscarFacturaDialog.cpp \ 42 + Gui/BuscarPresupuestoDialog.cpp \ 43 + Gui/CambiarIvaDialog.cpp \ 44 + Gui/ConfigurarImpresora.cpp \ 45 + Gui/ListarArticulos.cpp \ 46 + Gui/ListarClientes.cpp \ 47 + Gui/ListarFacturas.cpp \ 48 + Gui/ListarPresupuestos.cpp \ 49 + Gui/MainWindow.cpp \ 50 + Gui/NuevaFacturaDialog.cpp \ 51 + Gui/NuevoArticuloDialog.cpp \ 52 + Gui/NuevoClienteDialog.cpp \ 53 + Gui/NuevoPresupuestoDialog.cpp \ 54 + Gui/PrintWindow.cpp \ 55 + Gui/VisorAyuda.cpp \ 56 + Gui/imprimirsobrecliente.cpp \ 57 + Gui/main.cpp \ 58 + Datos/AccesoADatos.cpp \ 59 + Datos/CriterioBusqueda.cpp \ 60 + Datos/utils.cpp 61 + FORMS += Gui/BuscarArticuloDialog.ui \ 62 + Gui/BuscarClienteDialog.ui \ 63 + Gui/BuscarFacturaDialog.ui \ 64 + Gui/BuscarPresupuestoDialog.ui \ 65 + Gui/CambiarIvaDialog.ui \ 66 + Gui/ConfigurarImpresora.ui \ 67 + Gui/ListarArticulos.ui \ 68 + Gui/ListarClientes.ui \ 69 + Gui/ListarFacturas.ui \ 70 + Gui/ListarPresupuestos.ui \ 71 + Gui/NuevaFacturaDialog.ui \ 72 + Gui/NuevoArticuloDialog.ui \ 73 + Gui/NuevoClienteDialog.ui \ 74 + Gui/NuevoOperarioDialog.ui \ 75 + Gui/NuevoPresupuestoDialog.ui \ 76 + Gui/VisorAyuda.ui \ 77 + Gui/imprimirsobrecliente.ui 78 + RESOURCES +=