00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00070
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