本文整理汇总了C++中QSqlQuery::record方法的典型用法代码示例。如果您正苦于以下问题:C++ QSqlQuery::record方法的具体用法?C++ QSqlQuery::record怎么用?C++ QSqlQuery::record使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSqlQuery
的用法示例。
在下文中一共展示了QSqlQuery::record方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPersonXComputers
PersonXComputers DbManager::getPersonXComputers(QString pid)
{
db.open();
QSqlQuery qry;
QVector<Computer> comps;
QVector<QString> cids;
PersonXComputers pxc;
qry.exec("PRAGMA foreign_keys=ON");
qry.exec("SELECT cID "
"FROM ComputersXPersons "
"WHERE pID = " + pid);
int i_cid = qry.record().indexOf("cID");
while(qry.next())
{
cids.push_back(qry.value(i_cid).toString());
}
for(int i = 0; i < cids.size(); i++)
{
comps.push_back(findComputers("WHERE cID = " + cids[i]).first());
}
db.close();
pxc.setPerson(findPersons("WHERE pID = " + pid).first());
pxc.setComputers(comps);
return pxc;
}
示例2: rise
bool interface::rise()
{
if(id_db == 0) return false;
QSqlQuery query = nd::connection::instance()->select(QString("SELECT * FROM %1 WHERE id = %2").arg(this->tablename()).arg(id_db), (t_onFallback ? nd::connection::fallbackdb() : nd::connection::maindb()));
if(query.next()) {
t_valid = true;
for(int i = 0; i < fieldsCount(); i++) {
t_valid = t_valid && setFieldValue(i, query.record().field(fieldName(i)).value().toString());
};
return t_valid && nd::interface::update(query.record());
} else {
t_valid = false;
return t_valid;
};
}
示例3: updateHistory
void ScreenshotManager::updateHistory(const QString &fileName, const QString &url, const QString &deleteHash)
{
if (!mSettings->value("/options/history", true).toBool() || url.isEmpty()) {
return;
}
if (!mHistoryInitialized) {
initHistory();
}
QSqlQuery query;
query.prepare("SELECT fileName FROM history WHERE URL IS NOT EMPTY AND fileName = ?");
query.addBindValue(fileName);
query.exec();
if (query.record().count() > 0) {
QSqlQuery updateQuery;
updateQuery.prepare("UPDATE history SET URL = ?, deleteURL = ?, time = ? WHERE fileName = ?");
updateQuery.addBindValue(url);
updateQuery.addBindValue("https://imgur.com/delete/" + deleteHash);
updateQuery.addBindValue(QDateTime::currentMSecsSinceEpoch());
updateQuery.addBindValue(fileName);
updateQuery.exec();
} else {
saveHistory(fileName, url, deleteHash);
}
}
示例4: rekvizytyPostachalnyka
//--------------------utech--------------------utech--------------------utech--------------------
QString USkladZbutRozrah::rekvizytyPostachalnyka(int PostachId)
{
QSqlQuery query;
QString str;
query.exec("SELECT * FROM orginfo WHERE id="+QString::number(PostachId));
query.next();
QSqlRecord rec = query.record();
QString Edrpoy = rec.value("Edrpoy").toString();
QString PovnaNazvaPidpr = rec.value("PovnaNazvaPidpr").toString();
QString Adresa = rec.value("Adresa").toString();
QString Bank = rec.value("Bank").toString();
QString MFO = rec.value("MFO").toString();
QString BankRahunok = rec.value("BankRahunok").toString();
QString Podatok = rec.value("Podatok").toString();
QString IPN = rec.value("IPN").toString();
QString SvidPDVNum = rec.value("SvidPDVNum").toString();
QString TelefonDurekt = rec.value("TelefonDurekt").toString();
QString Fax = rec.value("Fax").toString();
QString Email = rec.value("Email").toString();
str += PovnaNazvaPidpr + "\n";
str += "ЄДРПОУ " + Edrpoy + ";\n";
str += "Адреса: " + Adresa + ";\n";
str += "Банк: " + Bank + ", МФО " + MFO + ", р/р " + BankRahunok + ";\n";
if (_podatokType == 1){
str += "Платник податку на прибуток на загальних підставах\n";
str += "ІПН " + IPN + ", № свід. ПДВ " + SvidPDVNum + ";\n";
}
if (TelefonDurekt.size() > 0)
str += "Тел." + TelefonDurekt + ", ";
if (Fax.size() > 0)
str += "Факс." + Fax + ", ";
if (Email.size() > 0)
str += "Е-пошта." + Email + ", ";
return str;
}
示例5: on_but_vnesti_dolg_clicked
void MainForm::on_but_vnesti_dolg_clicked()
{
QSqlQuery sql;
sql.prepare("SELECT MAX(OPLATI_CLIENTS) AS number "
"FROM OPLATI_CLIENTS");
sql.exec();
QSqlRecord record = sql.record();
sql.next();
int Number = sql.value(record.indexOf("number")).toInt();
Number++;
double summ = ui->dolg_client->text().toDouble();
double summa_Oplati = QInputDialog::getDouble(this,"Введите сумму ","Сумма:",summ,0,99999999,2,0,0);
sql.prepare("INSERT INTO OPLATI_CLIENTS(NUMBER,DATE,TYPE_OPERACII,ID_CLIENT,SUMMA_K_OPL,SUMMA_OPL) "
"VALUES(:NUMBER,:DATE,:TYPE_OPERACII,:ID_CLIENT,:SUMMA_K_OPL,:SUMMA_OPL) ");
sql.bindValue(":NUMBER",Number);
sql.bindValue(":DATE",QDate::currentDate().toString("dd.MM.yyyy"));
sql.bindValue(":TYPE_OPERACII",n_PL_DOLG);
sql.bindValue(":ID_CLIENT",ID_Client);
sql.bindValue(":SUMMA_K_OPL",0);
sql.bindValue(":SUMMA_OPL",summa_Oplati);
sql.exec();
UpdateClients(ID_Client);
}
示例6: getDaten
/*!
* \param schueler Schüler.
* \param datum Änderungsdatum.
* \return bestimmte Schülerdaten.
*/
Daten* Datenbank::getDaten(Schueler* schueler, QDateTime datum)
{
QSqlQuery query;
query.prepare("SELECT * FROM h_daten WHERE schuelerid = :schuelerid AND datum = :datum");
query.bindValue(":schuelerid", (schueler->getSchuelerID()));
query.bindValue(":datum", datum);
query.exec();
query.first();
Daten *daten = new Daten();
QSqlRecord record = query.record();
daten->setDatenID(query.value(record.indexOf("datenid")).toInt());
daten->setSchuelerID(query.value(record.indexOf("schuelerid")).toInt());
daten->setOrganisatorID(query.value(record.indexOf("organisatorid")).toInt());
daten->setDatum(query.value(record.indexOf("datum")).toDateTime());
daten->setNeuerName(query.value(record.indexOf("neuername")).toString());
daten->setStrHnr(query.value(record.indexOf("strhnr")).toString());
daten->setPLZ(query.value(record.indexOf("plz")).toString());
daten->setOrt(query.value(record.indexOf("ort")).toString());
daten->setLand(query.value(record.indexOf("land")).toString());
daten->setTelefon(query.value(record.indexOf("telefon")).toString());
daten->setEmail(query.value(record.indexOf("email")).toString());
daten->setKommentar(query.value(record.indexOf("kommentar")).toString());
daten->setAenderungen(query.value(record.indexOf("aenderungen")).toString());
return daten;
}
示例7: on_btn_AddFood_clicked
void AdminWindow::on_btn_AddFood_clicked()
{
addFood* newFood = new addFood();
newFood->setWindowModality(Qt::ApplicationModal);
QStringList allCatagoriesList;
/**/
QSqlQuery *query = new QSqlQuery();
query->prepare("SELECT * FROM Catagories");
bool result = query->exec();
if(result == true){
while(query->next())
{
QString name = query->record().value("name").toString();
allCatagoriesList.append(name);
}
}
newFood->setCatagoryList(allCatagoriesList);
delete query;
connect(newFood, SIGNAL(signal_foodAdded(Food*)), this, SLOT(onFoodAddedSignalRecieved(Food*)));
newFood->show();
}
示例8: ProjBegin
QDateTime ProjBegin(unsigned int aProjId)
{
QSqlQuery query;
query.exec("SELECT date_begin FROM project WHERE proj_id = " + QString::number(aProjId));
query.next();
return QDateTime::fromString(query.record().value(0).toString(), Qt::ISODate);
}
示例9: on_btn_UserWiseTransaction_clicked
void AdminWindow::on_btn_UserWiseTransaction_clicked()
{
QVector<QString> allUserName;
UserWiseTransaction *a = new UserWiseTransaction();
a->setWindowModality(Qt::ApplicationModal);
a->show();
//
QSqlQuery q;
q.prepare("SELECT * FROM Users");
bool r = q.exec();
if(r)
{
while(q.next())
{
allUserName.push_back(q.record().value("name").toString());
}
}
connect(this, SIGNAL(signal_AdminPanelUserWiseTransButtonClicked(QVector<QString>)), a, SLOT(onSignalAdminPanelUserWiseButtonRecieved(QVector<QString>)), Qt::UniqueConnection);
connect(a, SIGNAL(signal_onUserSelectedForTransaction(QString)), this, SLOT(onUserSelectedForTransactionRecieved(QString)));
emit signal_AdminPanelUserWiseTransButtonClicked(allUserName);
//
}
示例10: onFoodEdited
void AdminWindow::onFoodEdited(Food *food)
{ qDebug()<<"Editing Food Name: "<<food->getName();
QStringList allCatagoriesList;
UpdateFood* newCatagory = new UpdateFood();
newCatagory->setWindowModality(Qt::ApplicationModal);
/**/
QSqlQuery *query = new QSqlQuery();
query->prepare("SELECT * FROM Catagories");
bool result = query->exec();
if(result == true){
while(query->next())
{
QString name = query->record().value("name").toString();
allCatagoriesList.append(name);
}
}
newCatagory->setCatagoryList(allCatagoriesList);
newCatagory->setPrevFood(food);
delete query;
connect(newCatagory, SIGNAL(UpdateFoodButtonClicked(Food*, Food*)), this, SLOT(onUpdateFoodButtonClicked(Food*, Food*)));
newCatagory->show();
}
示例11: readDB
QString DataBase::readDB(QString path){
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName(path);
if (!db.open()) {
qDebug() << "Unable to execute db - exiting";
return "";
}
QSqlQuery query;
if (!query.exec("SELECT * FROM lesson;")) {
qDebug() << "Unable to execute query - exiting";
return "";
}
//Reading of the data
QSqlRecord rec = query.record();
QString nameLessonFile;
while (query.next()){
nameLessonFile = query.value(rec.indexOf("lessonName")).toString();
break;
}
if(!nameLessonFile.isEmpty())
saveLessonFilePath.insert(nameLessonFile,path);
return nameLessonFile;
}
示例12: replaceCacheRecordByServerRecord
QDateTime Database::replaceCacheRecordByServerRecord(const QSqlDatabase& dbCache, const QString& table, const QSqlQuery& queryMaster)
{
QDateTime updated;
QSqlRecord record = queryMaster.record();
int fieldUpdated = record.indexOf("updated");
if (fieldUpdated == -1)
{
fieldUpdated = record.indexOf("created");
}
Q_ASSERT(fieldUpdated > -1);
updated = record.value(fieldUpdated).toDateTime();
int n = record.count();
if (n > 1)
{
QString sql = QString("REPLACE INTO %1 (").arg(table);
bool first = true;
for (int i = 0; i < n; i++)
{
if (first)
first = false;
else
sql += ", ";
sql += record.fieldName(i);
}
sql += ") VALUES (";
first = true;
for (int i = 0; i < n; i++)
{
if (first)
first = false;
else
sql += ", ";
sql += "?";
}
sql += ")";
QSqlQuery queryCache(dbCache);
queryCache.setForwardOnly(true);
queryCache.prepare(sql);
for (int i = 0; i < n; i++)
{
QVariant v(record.value(i));
if (v.type() == QVariant::DateTime)
queryCache.bindValue(i, datetimeToString(v.toDateTime()));
else
queryCache.bindValue(i, v);
}
if (!queryCache.exec())
throw DatabaseException(queryCache);
}
return updated;
}
示例13: getComputerXPersons
ComputerXPersons DbManager::getComputerXPersons(QString cid)
{
db.open();
QSqlQuery qry;
QVector<Person> pers;
QVector<QString> pids;
ComputerXPersons cxp;
qry.exec("PRAGMA foreign_keys=ON");
qry.exec("SELECT pID "
"FROM ComputersXPersons "
"WHERE cID = " + cid);
int i_pid = qry.record().indexOf("pID");
while(qry.next())
{
pids.push_back(qry.value(i_pid).toString());
}
for(int i = 0; i < pids.size(); i++)
{
pers.push_back(findPersons("WHERE pID = " + pids[i]).first());
}
db.close();
cxp.setComputer(findComputers("WHERE cID = " + cid).first());
cxp.setPersons(pers);
return cxp;
}
示例14: QDialog
Login::Login(Configuracion *m_config,QWidget *parent) :
QDialog(parent),
ui(new Ui::Login)
{
this->setWindowFlags(Qt::Dialog|Qt::CustomizeWindowHint|Qt::WindowTitleHint);
ui->setupUi(this);
//--------------------------------------------
// Conexiones
//--------------------------------------------
connect(ui->btnEmpresa,SIGNAL(clicked()),this,SLOT(btnEmpresa_clicked()));
connect(ui->Crearconfiguracin,SIGNAL(clicked()),this,SLOT(Crearconfiguracion_clicked()));
// TODO - Rellenar en base a fichero de empresas BD terra.
// Relleno combo empresas
QSqlQuery *QryEmpresas = new QSqlQuery(QSqlDatabase::database("terra"));
QryEmpresas->prepare("Select * from empresas");
if(QryEmpresas->exec()) {
while (QryEmpresas->next()) {
QSqlRecord rEmpresa = QryEmpresas->record();
ui->cboEmpresa->addItem(rEmpresa.field("nombre").value().toString());
}
}
this->ui->lineUsuario->setFocus();
}
示例15: AddRevenue
/**
* @brief Database::AddRevenue
* Add amount to revenue attribute in stadiums table
* @param id stadiums id
* @param revenue of the stadium
* @return
*/
bool Database::AddRevenue(int id, double revenue)
{
QSqlQuery query;
query.prepare("select revenue from stadiums where id = :id");
query.bindValue(":id", id);
if(query.exec()){
if(query.next()){
double originalRev = query.record().field("revenue").value().toDouble();
query.clear();
query.prepare("update stadiums set revenue = :newRev where id = :id");
double newRev = originalRev + revenue;
query.bindValue(":newRev", newRev);
query.bindValue(":id", id);
return query.exec();
}
else
{
qDebug() << query.lastError().text();
return false;
}
}
else
{
qDebug() << query.lastError().text();
return false;
}
}