importainteligente.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Tomeu Borras Riera                              *
00003  *   tborras@conetxia.com                                                  *
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 <QString>
00022 
00023 #include "importainteligente.h"
00024 #include "empresa.h"
00025 #include "funcaux.h"
00026 
00029 
00033 importainteligente::importainteligente(Empresa *emp) : QXmlDefaultHandler(), PEmpresaBase(emp) {
00034     _depura("importainteligente::importainteligente", 0);
00035     tag = "";
00036     data = "";
00037     _depura("END importainteligente::importainteligente", 0);
00038 }
00039 
00040 
00042 
00051 bool importainteligente::startElement(const QString&, const QString&, const QString& qName, const QXmlAttributes&) {
00052     _depura("importainteligente::startElement", 0);
00053     tag = qName;
00054     QString SQLQuery;
00055     if (tag == "ainteligente") {
00056         SQLQuery.sprintf("INSERT INTO ainteligente (descripcion) VALUES ('Elemento importado')\n");
00057         empresaBase()->begin();
00058         empresaBase()->ejecuta(SQLQuery);
00059         SQLQuery = "SELECT max(idainteligente) AS idainteligente FROM ainteligente";
00060         cursor2 *cur = empresaBase()->cargacursor(SQLQuery, "unquerymas");
00061         empresaBase()->commit();
00062         if (!cur->eof()) {
00063             tvalores["idainteligente"] = cur->valor("idainteligente");
00064         } // end if
00065         delete cur;
00066     } // end if
00067     if (tag == "binteligente") {
00068         SQLQuery.sprintf("INSERT INTO binteligente (idainteligente) VALUES (%s)\n", empresaBase()->sanearCadena(tvalores["idainteligente"]).toAscii().constData());
00069         empresaBase()->begin();
00070         empresaBase()->ejecuta(SQLQuery);
00071         SQLQuery = "SELECT max(idbinteligente) AS idbinteligente FROM binteligente";
00072         cursor2 *cur = empresaBase()->cargacursor(SQLQuery, "unquerymas");
00073         empresaBase()->commit();
00074         if (!cur->eof()) {
00075             tvalores["idbinteligente"] = cur->valor("idbinteligente");
00076         } // end if
00077         delete cur;
00078     } // end if
00079     _depura("END importainteligente::startElement", 0);
00080     return TRUE;
00081 }
00082 
00083 
00085 
00097 bool importainteligente::endElement(const QString&, const QString&, const QString& qName) {
00098     _depura("importainteligente::endElement", 0);
00099     QString SQLQuery;
00100     if (qName == "ainteligente") {
00101         SQLQuery.sprintf("UPDATE ainteligente SET descripcion = '%s' WHERE idainteligente = %s\n", tvalores["descripcion"].toAscii().constData(), tvalores["idainteligente"].toAscii().constData());
00102         empresaBase()->begin();
00103         empresaBase()->ejecuta(SQLQuery);
00104         empresaBase()->commit();
00105         SQLQuery.sprintf("UPDATE ainteligente SET comentariosasiento = '%s' WHERE idainteligente = %s\n", tvalores["comentariosasiento"].toAscii().constData(), tvalores["idainteligente"].toAscii().constData());
00106         empresaBase()->begin();
00107         empresaBase()->ejecuta(SQLQuery);
00108         empresaBase()->commit();
00109     } // end if
00110     if (qName == "binteligente") {
00111         SQLQuery.sprintf("UPDATE binteligente SET fecha = '%s' WHERE idbinteligente = %s\n", tvalores["fecha"].toAscii().constData(), tvalores["idbinteligente"].toAscii().constData());
00112         empresaBase()->begin();
00113         empresaBase()->ejecuta(SQLQuery);
00114         empresaBase()->commit();
00115         SQLQuery.sprintf("UPDATE binteligente SET conceptocontable = '%s' WHERE idbinteligente=%s\n", tvalores["conceptocontable"].toAscii().constData(), tvalores["idbinteligente"].toAscii().constData());
00116         empresaBase()->begin();
00117         empresaBase()->ejecuta(SQLQuery);
00118         empresaBase()->commit();
00119         SQLQuery.sprintf("UPDATE binteligente SET codcuenta = '%s' WHERE idbinteligente = %s\n", tvalores["codcuenta"].toAscii().constData(), tvalores["idbinteligente"].toAscii().constData());
00120         empresaBase()->begin();
00121         empresaBase()->ejecuta(SQLQuery);
00122         empresaBase()->commit();
00123         SQLQuery.sprintf("UPDATE binteligente SET descripcion = '%s' WHERE idbinteligente = %s\n", tvalores["descripcionb"].toAscii().constData(), tvalores["idbinteligente"].toAscii().constData());
00124         empresaBase()->begin();
00125         empresaBase()->ejecuta(SQLQuery);
00126         empresaBase()->commit();
00127         SQLQuery.sprintf("UPDATE binteligente SET debe = '%s' WHERE idbinteligente = %s\n", tvalores["debe"].toAscii().constData(), tvalores["idbinteligente"].toAscii().constData());
00128         empresaBase()->begin();
00129         empresaBase()->ejecuta(SQLQuery);
00130         empresaBase()->commit();
00131         SQLQuery.sprintf("UPDATE binteligente SET haber = '%s' WHERE idbinteligente = %s\n", tvalores["haber"].toAscii().constData(), tvalores["idbinteligente"].toAscii().constData());
00132         empresaBase()->begin();
00133         empresaBase()->ejecuta(SQLQuery);
00134         empresaBase()->commit();
00135         SQLQuery.sprintf("UPDATE binteligente SET contrapartida = '%s' WHERE idbinteligente = %s\n", tvalores["contrapartida"].toAscii().constData(), tvalores["idbinteligente"].toAscii().constData());
00136         empresaBase()->begin();
00137         empresaBase()->ejecuta(SQLQuery);
00138         empresaBase()->commit();
00139         SQLQuery.sprintf("UPDATE binteligente SET comentario = '%s' WHERE idbinteligente = %s\n", tvalores["comentario"].toAscii().constData(), tvalores["idbinteligente"].toAscii().constData());
00140         empresaBase()->begin();
00141         empresaBase()->ejecuta(SQLQuery);
00142         empresaBase()->commit();
00143         SQLQuery.sprintf("UPDATE binteligente SET canal = '%s' WHERE idbinteligente = %s\n", tvalores["canal"].toAscii().constData(), tvalores["idbinteligente"].toAscii().constData());
00144         empresaBase()->begin();
00145         empresaBase()->ejecuta(SQLQuery);
00146         empresaBase()->commit();
00147         SQLQuery.sprintf("UPDATE binteligente SET idc_coste = '%s' WHERE idbinteligente = %s\n", tvalores["idc_coste"].toAscii().constData(), tvalores["idbinteligente"].toAscii().constData());
00148         empresaBase()->begin();
00149         empresaBase()->ejecuta(SQLQuery);
00150         empresaBase()->commit();
00151         SQLQuery.sprintf("UPDATE binteligente SET marcaconciliacion = '%s' WHERE idbinteligente = %s\n", tvalores["marcaconciliacion"].toAscii().constData(), tvalores["idbinteligente"].toAscii().constData());
00152         empresaBase()->begin();
00153         empresaBase()->ejecuta(SQLQuery);
00154         empresaBase()->commit();
00155     } // end if
00156     tag = "";
00157     data = "";
00158     _depura("END importainteligente::endElement", 0);
00159     return TRUE;
00160 }
00161 
00162 
00164 
00170 bool importainteligente::characters(const QString& ch) {
00171     _depura("importainteligente::characters", 0);
00172     if (tag != "") {
00173         data = ch;
00174         tvalores[tag] = data;
00175     } // end if
00176     _depura("END importainteligente::characters", 0);
00177     return TRUE;
00178 }
00179 

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