contratoslist.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by J. M. Estopa Rey                                *
00003  *   pepma@telefonica.net                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include <QLineEdit>
00022 #include <QTextStream>
00023 #include <QFileDialog>
00024 #include <QCheckBox>
00025 #include <QMessageBox>
00026 
00027 #include "contratoslist.h"
00028 #include "company.h"
00029 #include "funcaux.h"
00030 #include "pgimportfiles.h"
00031 #include "informereferencia.h"
00032 #include "plugins.h"
00033 #include "contratoview.h"
00034 
00035 
00047 ContratosList::ContratosList(Company *comp, QWidget *parent, Qt::WFlags flag, edmode editmode)
00048         : Listado(comp, parent, flag), pgimportfiles(comp) {
00049     _depura("ContratosList::ContratosList", 0);
00050     setAttribute(Qt::WA_DeleteOnClose);
00051     setupUi(this);
00053     int res = g_plugins->lanza("ContratosList_ContratosList", this);
00054     if (res != 0)
00055         return;
00056 
00057     mui_list->setEmpresaBase(comp);
00058     mui_idcliente->setEmpresaBase(comp);
00059     mdb_idcontrato = "";
00060     mdb_nomcontrato = "";
00061     m_modo = editmode;
00062     hideBusqueda();
00064     if (m_modo == EditMode) {
00065         empresaBase()->meteWindow(windowTitle(), this);
00066     } else {
00067         setWindowTitle(tr("Selector de contratos"));
00068         mui_editar->setHidden(TRUE);
00069         mui_crear->setHidden(TRUE);
00070         mui_borrar->setHidden(TRUE);
00071         mui_imprimir->setHidden(TRUE);
00072     } // end if
00073     presenta();
00074     trataPermisos("contrato");
00075     _depura("END ContratosList::ContratosList", 0);
00076 }
00077 
00078 
00083 ContratosList::~ContratosList() {
00084     _depura("ContratosList::~ContratosList", 0);
00085     empresaBase()->sacaWindow(this);
00086     _depura("END ContratosList::~ContratosList", 0);
00087 }
00088 
00089 
00092 
00093 
00095 void ContratosList::presenta() {
00096     _depura("ContratosList::presenta", 0);
00097     QString where;
00098 
00099     if (mui_idcliente->idcliente() != "") {
00100         where = " AND contrato.idcliente = "+mui_idcliente->idcliente();
00101     } // end if
00102 
00103     mui_list->cargar("SELECT * FROM contrato NATURAL LEFT JOIN cliente  WHERE nomcontrato LIKE '%" + m_findClient->text() + "%' "+where+" ORDER BY nomcontrato");
00104     _depura("END ContratosList::presenta", 0);
00105 }
00106 
00107 
00117 void ContratosList::editar(int row) {
00118 
00119     _depura("ContratosList::editar", 0);
00120     mdb_idcontrato = mui_list->DBvalue("idcontrato", row);
00121     mdb_refcontrato = mui_list->DBvalue("refcontrato", row);
00122     mdb_nomcontrato = mui_list->DBvalue("nomcontrato", row);
00123     if (m_modo == 0) {
00124         ContratoView *prov = new ContratoView((Company *)empresaBase());
00125         if (prov->cargar(mdb_idcontrato)) {
00126             delete prov;
00127             return;
00128         } // end if
00129         empresaBase()->m_pWorkspace->addWindow(prov);
00130         prov->show();
00131     } else {
00132         emit(selected(mdb_idcontrato));
00133     } // end if
00134     _depura("END ContratosList::editar", 0);
00135 
00136 }
00137 
00138 
00145 void ContratosList::on_mui_editar_clicked() {
00146     _depura("ContratosList::on_mui_editar_clicked", 0);
00147     if (mui_list->currentRow() < 0) {
00148         _depura("Debe seleccionar un elemento", 2);
00149         return;
00150     } // end if
00151     editar(mui_list->currentRow());
00152     _depura("END ContratosList::on_mui_editar_clicked", 0);
00153 }
00154 
00155 
00161 void ContratosList::on_mui_imprimir_clicked() {
00162     _depura("ContratosList::on_mui_imprimir_clicked", 0);
00163     mui_list->imprimirPDF(tr("Listado de Contratos"));
00164     _depura("ContratosList::on_mui_imprimir_clicked", 0);
00165 }
00166 
00167 
00168 
00169 
00176 void ContratosList::on_mui_borrar_clicked() {
00177     _depura("ContratosList::on_mui_borrar_clicked", 0);
00178     try {
00179 /*
00180         QString idcontrato = mui_list->DBvalue("idcontrato");
00181         ClienteView *cli = empresaBase()->newClienteView();
00182         if (cli->cargar(idcontrato)) {
00183             delete cli;
00184             throw -1;
00185         } // end if
00186         cli->on_mui_borrar_clicked();
00187         delete cli;
00188         presenta();
00189 */
00190     } catch (...) {
00191         mensajeInfo(tr("Error al borrar un contrato"));
00192     } // end try
00193     _depura("END:ContratosList::on_mui_borrar_clicked", 0);
00194 }
00195 
00196 
00198 
00200 void ContratosList::selectMode() {
00201     _depura("ContratosList::selectMode", 0);
00202     m_modo = SelectMode;
00203     _depura("END ContratosList::selectMode", 0);
00204 }
00205 
00207 
00209 void ContratosList::editMode() {
00210     _depura("ContratosList::editMode", 0);
00211     m_modo = EditMode;
00212     _depura("END ContratosList::editMode", 0);
00213 }
00214 
00216 
00219 QString ContratosList::idcontrato() {
00220     _depura("ContratosList::idcontrato", 0);
00221     _depura("END ContratosList::idcontrato", 0);
00222     return mdb_idcontrato;
00223 }
00224 
00226 
00229 QString ContratosList::nomcontrato() {
00230     _depura("ContratosList::nomcontrato", 0);
00231     _depura("END ContratosList::nomcontrato", 0);
00232     return mdb_nomcontrato;
00233 }
00234 
00235 
00237 
00240 QString ContratosList::refcontrato() {
00241     _depura("ContratosList::refcontrato", 0);
00242     _depura("END ContratosList::refcontrato", 0);
00243     return mdb_refcontrato;
00244 }
00245 
00246 
00248 
00250 void ContratosList::hideBotonera() {
00251     _depura("ContratosList::hideBotonera", 0);
00252     m_botonera->hide();
00253     _depura("END ContratosList::hideBotonera", 0);
00254 }
00255 
00256 
00258 
00260 void ContratosList::showBotonera() {
00261     _depura("ContratosList::showBotonera", 0);
00262     m_botonera->show();
00263     _depura("END ContratosList::showBotonera", 0);
00264 }
00265 
00266 
00268 
00270 void ContratosList::hideBusqueda() {
00271     _depura("ContratosList::hideBusqueda", 0);
00272     m_busqueda->hide();
00273     _depura("END ContratosList::hideBusqueda", 0);
00274 }
00275 
00276 
00278 
00280 void ContratosList::showBusqueda() {
00281     _depura("ContratosList::showBusqueda", 0);
00282     m_busqueda->show();
00283     _depura("END ContratosList::showBusqueda", 0);
00284 }
00285 
00286 
00288 
00291 void ContratosList::on_m_filtro_textChanged(const QString &text) {
00292     _depura("ContratosList::on_m_filtro_textChanged", 0);
00293     if (text.size() >= 3) {
00294         on_mui_actualizar_clicked();
00295     } // end if
00296     _depura("END ContratosList::on_m_filtro_textChanged", 0);
00297 }
00298 
00300 
00302 void ContratosList::on_mui_list_itemDoubleClicked(QTableWidgetItem *) {
00303     _depura("ContratosList::on_mui_list_itemDoubleClicked", 0);
00304     on_mui_editar_clicked();
00305     _depura("END ContratosList::on_mui_list_itemDoubleClicked", 0);
00306 }
00307 
00309 
00311 void ContratosList::on_mui_crear_clicked() {
00312         _depura("ContratosList::on_mui_crear_clicked", 0);
00313         ContratoView *prov = new ContratoView((Company *) empresaBase());
00314         prov->cargar("0");
00315         empresaBase()->m_pWorkspace->addWindow(prov);
00316         prov->show();
00317         _depura("END ContratosList::on_mui_crear_clicked", 0);
00318 }
00319 
00320 
00322 
00324 void ContratosList::on_mui_actualizar_clicked() {
00325     _depura("ContratosList::on_mui_actualizar_clicked", 0);
00326     presenta();
00327     _depura("END ContratosList::on_mui_actualizar_clicked", 0);
00328 }
00329 
00331 
00334 void ContratosList::on_mui_configurar_toggled(bool checked) {
00335     _depura("ContratosList::on_mui_configurar_toggled", 0);
00336     if (checked) {
00337         mui_list->showConfig();
00338     } else {
00339         mui_list->hideConfig();
00340     } // end if
00341     _depura("END ContratosList::on_mui_configurar_toggled", 0);
00342 }
00343 
00344 
00345 
00349 
00355 ContratosListSubform::ContratosListSubform(QWidget *parent, const char *) : SubForm2Bf(parent) {
00356     _depura("ContratosListSubform::ContratosListSubform", 0);
00357     setDBTableName("contrato");
00358     setDBCampoId("idcontrato");
00359     addSHeader("idcontrato", DBCampo::DBint, DBCampo::DBNotNull | DBCampo::DBPrimaryKey, SHeader::DBNoView | SHeader::DBNoWrite, tr("ID contrato"));
00360     addSHeader("codcliente", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Codigo"));
00361     addSHeader("cifcliente", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("C.I.F."));
00362     addSHeader("refcontrato", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Referencia"));
00363     addSHeader("nomcontrato", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Nombre de contrato"));
00364     addSHeader("nomcliente", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Nombre alternativo del contrato"));
00365     addSHeader("fincontrato", DBCampo::DBdate, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Fecha de alta del contrato"));
00366     addSHeader("ffincontrato", DBCampo::DBdate, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Fecha de baja del contrato"));
00367     addSHeader("periodicidadcontrato", DBCampo::DBvarchar, DBCampo::DBNoSave, SHeader::DBNone | SHeader::DBNoWrite, tr("Fecha de baja del contrato"));
00368     setinsercion(FALSE);
00369     setDelete(FALSE);
00370     setSortingEnabled(TRUE);
00371     _depura("END ContratosListSubform::ContratosListSubform", 0);
00372 }
00373 
00374 
00376 
00378 ContratosListSubform::~ContratosListSubform() {
00379     _depura("ContratosListSubform::~ContratosListSubform", 0);
00380     _depura("END ContratosListSubform::~ContratosListSubform", 0);
00381 }

Generated on Sat Dec 15 00:01:06 2007 for BulmaGes by  doxygen 1.5.1