#include <QtGui>
#include <QtSql>
#include "legis.h"
legis::legis()
{
connect( Search, SIGNAL( clicked() ), this, SLOT( search() ) );
connect( First, SIGNAL( clicked() ), this, SLOT( first() ) );
connect( Prev, SIGNAL( clicked() ), this, SLOT( prev() ) );
connect( Next, SIGNAL( clicked() ), this, SLOT( next() ) );
connect( Last, SIGNAL( clicked() ), this, SLOT( last() ) );
}
void legis::search()
{
QSqlDatabase db;
QString str, str_1, str_2, str_3, field, value;
int num;
db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setDatabaseName("jur");
db.setUserName("antonio");
db.setPassword("");
db.open();
if(db.isOpen()){
QMessageBox::information( this, "result", "connected" );
}
else {
QMessageBox::information( this, "result", "failed" );
}
field = fields->currentText();
value = exp->text();
QSqlQuery query("SELECT *FROM legis WHERE " + field + " LIKE '%" + value + "%'", db);
query.next();
str = query.value(0).toString();
ord-> setText(str);
str_1 = query.value(1).toString();
dip-> setText(str_1);
str_2 = query.value(2).toString();
sum-> setText(str_2);
str_3 = query.value(3).toString();
not-> setText(str_3);
num = query.size( );
reg-> setText(QString("%L1").arg(num));
}
void legis::first()
{
query.first();
}
void legis:
rev()
{
query.previous();
}
void legis::next()
{
query.next();
}
void legis::last()
{
query.last();
}
Bookmarks