postgresiface2.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2003 by Tomeu Borras Riera                              *
00003  *   tborras@conetxia.com                                                  *
00004  *   http://www.iglues.org                                                 *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  *   This program is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU General Public License for more details.                          *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU General Public License     *
00017  *   along with this program; if not, write to the                         *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00020  ***************************************************************************/
00021 
00025 #ifndef POSTGRESIFACE2_H
00026 #define POSTGRESIFACE2_H
00027 
00028 #include <QString>
00029 #include <QHash>
00030 
00031 #ifdef DISTRO_DEBIAN
00032     #include <postgresql/libpq-fe.h>
00033 #elif DISTRO_DEBIAN_8_0
00034     #include <postgresql/8.0/libpq-fe.h>
00035 #elif  DISTRO_RED_HAT
00036     #include <pgsql/libpq-fe.h>
00037 #elif  DISTRO_GENTOO
00038     #include <postgresql/pgsql/libpq-fe.h>
00039 #elif  DISTRO_NO_SE_QUE
00040     #include <no_se_que/pgsql/libpq-fe.h>
00041 #else
00042     #include <libpq-fe.h>
00043 #endif
00044 
00045 #include "configuracion.h"
00046 
00047 
00049 
00051 class cursor2 {
00052 private:
00054     QString nomcursor;
00056     PGresult *result;
00058     PGconn *conn;
00061     int registroactual;
00063     int nregistros;
00065     int ncampos;
00066     bool m_error;
00067     QString m_query;
00068     QHash<QString, int> m_campos;
00069 //      QList<QString, int>m_campos;
00070 //    QMap<QString, int> m_campos;
00071 public:
00073     cursor2(QString nombre, PGconn *conn1, QString SQLQuery);
00075     ~cursor2();
00077     int numregistros();
00079     QString valor(int posicion, int registro = -1);
00080     bool error();
00081     QString query();
00082 
00083 public:
00085     QString valor(const QString &campo, int registro = -1);
00087     int siguienteregistro();
00089     int registroanterior();
00091     int primerregistro();
00093     int ultimoregistro();
00095     int regactual();
00097     void cerrar();
00099     QString nomcampo(int);
00101     int numcampo(const QString &);
00103     int numcampos();
00105     bool eof();
00107     bool bof();
00109     bool esultimoregistro();
00111     bool esprimerregistro();
00112 };
00113 
00114 
00115 class postgresiface2 {
00116 private:
00117     QString pghost; 
00118     QString pgport; 
00119     QString pgoptions; 
00120     QString pgtty; 
00121     QString dbName; 
00122     int nFields; 
00123     PGconn *conn; 
00124     int open; 
00125     bool m_transaccion; 
00126 
00127 private:
00129     int formatofecha();
00130 
00131 public:
00133     postgresiface2();
00135     ~postgresiface2();
00137     int inicializa(QString nomdb);
00139     int begin();
00141     void commit();
00143     void rollback();
00145     cursor2 *cargacursor(QString query, QString nomcursor = "", int limit = 0, int offset = 0);
00147     int ejecuta(QString);
00148     int nuevoborrador(int idcuenta, int idasiento, QString concepto, QString descripcion, float debe, float haber, QString fecha, int idcontrapartida, int idtipoiva, int idccoste, int idcanal);
00149     int modificaborrador(int idborrador, int idcuenta, float idebe, float ihaber, QString concepto, QString fecha, int contrapartida, int idtipoiva, int idccoste, int idcanal);
00150     cursor2 *cargacuenta(int idcuenta, QString ccuenta = "");
00151     cursor2 *cargaasiento(int idasiento);
00152     cursor2 *cargaapuntes(int tidasiento);
00153     cursor2 *cargaborradores(int tidasiento);
00154     cursor2 *cargacuentas(int padre);
00155     cursor2 *cargagrupos();
00156     cursor2 *cargasaldoscuentafecha(int, QString);
00157     cursor2 *cargaapuntesctafecha(int, QString, QString);
00158     cursor2 *cargacuentascodigo(int, QString, QString);
00159     cursor2 *cargaasientosfecha(QString, QString);
00160     int cierraasiento(int idasiento);
00161     int borrarasiento(int idasiento);
00162     int borrarborrador(int idborrador);
00163     int abreasiento(int idasiento);
00164     int borrarcuenta(int idcuenta);
00165     int modificacuenta(int idcuenta, QString desccuenta, QString codigo, bool cimputacion, bool cbloqueada, int idgrupo, bool cactivo, QString, QString, QString, QString, QString, QString, QString, QString, QString, int, bool, bool);
00166     int nuevacuenta(QString desccuenta, QString codigo, int padre, int idgrupo, QString, QString, QString, QString, QString, QString, QString, QString, QString, int, bool, bool);
00168     cursor2 *cargaempresas();
00170     static QString sanearCadena(QString cadena);
00171     void terminar();
00172     QString propiedadempresa(QString);
00174     QString searchParent(QString);
00176     QString nameDB();
00178     bool has_table_privilege(QString tabla, QString permiso);
00179 };
00180 
00181 #endif
00182 

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