00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef DBRECORD_H
00023 #define DBRECORD_H
00024
00025 #include <QString>
00026 #include <QList>
00027
00028 #include "postgresiface2.h"
00029 #include "funcaux.h"
00030
00031
00032 class DBCampo {
00033 public:
00034 enum dbtype {DBint = 1, DBvarchar = 2, DBdate = 3, DBnumeric = 4, DBboolean = 5};
00035 enum dbrestrict {DBNothing = 0, DBNotNull = 1, DBPrimaryKey = 2,
00036 DBNoSave = 4, DBAuto = 8, DBDupPrimaryKey = 16, DBRequired = 32, DBNoLoad = 64};
00037
00038 private:
00039 QString m_nomcampo;
00040 QString m_valorcampo;
00041 QString m_nompresentacion;
00042 int m_restrict;
00043 dbtype m_tipo;
00044 postgresiface2 *m_conexionbase;
00046 QString m_valorcampoorig;
00047
00048 public:
00049 bool cambiado();
00050 void resetCambio();
00051 DBCampo(postgresiface2 *com, QString nom, dbtype typ, int res, QString nomp = "");
00052 virtual ~DBCampo();
00053 postgresiface2 *conexionbase();
00054 void setconexionbase(postgresiface2 *comp);
00055 dbtype tipo();
00056 virtual int set(QString val);
00057 int restrictcampo();
00058 QString nomcampo();
00059 QString nompresentacion();
00060 QString valorcampo();
00061 QString valorcampoprep(int &error);
00062 };
00063
00064
00065 class DBRecord {
00066 protected:
00067 QList<DBCampo *> m_lista;
00068 postgresiface2 *m_conexionbase;
00069 QString m_tablename;
00070 QString m_campoid;
00071 bool m_nuevoCampo;
00072
00073 public:
00074 DBRecord(postgresiface2 *);
00075 virtual ~DBRecord();
00076 void setconexionbase(postgresiface2 *comp);
00077 postgresiface2 *conexionbase();
00078 int DBload(cursor2 *);
00079 virtual int DBsave(QString &id);
00080 virtual int setDBvalue(QString, QString);
00081 QString DBvalue(QString);
00082 bool exists(QString);
00083 QString DBvalueprep(QString);
00084 void setDBTableName(QString nom);
00085 void setNuevo(bool n);
00086 QString tableName();
00087 QString campoId();
00088 void setDBCampoId(QString nom);
00089 int addDBCampo(QString, DBCampo::dbtype, int, QString);
00090 void DBclear();
00091 QList<DBCampo *> *lista();
00092 virtual int borrar();
00093 virtual int guardar();
00094 virtual void vaciar();
00095 virtual void imprimir();
00096 virtual int cargar(QString);
00097 };
00098
00099 #endif
00100