QVector<InternalPaymentItem *> ClinicInternalPayment::selectFromDB(QDate startDate, QDate endDate) { QVector<InternalPaymentItem *> result; if(myDB::connectDB()) { QString strClumn = "ChinicReceipt"; QVector<QString> Receipt = getDistinctFromDB(strClumn , strClinicChargeDetails); QSqlQueryModel *sqlModel = new QSqlTableModel; for(int i=0;i<Receipt.size();i++) { InternalPaymentItem *item = new InternalPaymentItem; item->m_strName = Receipt.at(i); QString startTime = startDate.toString("yyyy-MM-dd") + "T00:00:00"; QString endTime = endDate.toString("yyyy-MM-dd") + "T23:59:59"; sqlModel->setQuery("Select * from " + strClinicChargeDetails + " where "+ strClumn + "= \'" + item->m_strName + "\' and chargeid in (select id from cliniccharge where time between \'" + startTime + "\' and \'" + endTime + "\')"); for(int j = 0;j<sqlModel->rowCount();j++) { int nCount = sqlModel->record(j).value("ChargeItemCount").toInt(); double nPrice = sqlModel->record(j).value("ChargeItemPrice").toDouble(); item->m_dDueIncome += nCount*nPrice; } result.append(item); } } return result; }
/*! qso number sent for last qso in log */ int Log::lastNr() const { QSqlQueryModel m; #if QT_VERSION < 0x050000 m.setQuery("SELECT * FROM log where valid='true'", db); #else m.setQuery("SELECT * FROM log where valid=1", db); #endif while (m.canFetchMore()) { m.fetchMore(); } if (m.rowCount()) { QByteArray snt[MAX_EXCH_FIELDS]; snt[0] = m.record(m.rowCount() - 1).value(SQL_COL_SNT1).toByteArray(); snt[1] = m.record(m.rowCount() - 1).value(SQL_COL_SNT2).toByteArray(); snt[2] = m.record(m.rowCount() - 1).value(SQL_COL_SNT3).toByteArray(); snt[3] = m.record(m.rowCount() - 1).value(SQL_COL_SNT4).toByteArray(); bool ok = false; int nr = snt[nrField].toInt(&ok, 10); if (!ok) nr = 0; return(nr); } else { return(0); } }
void Gconsignaciones::CargarDasignar(){ QSqlQueryModel idunicomodel; QString selec="SELECT Id_pro, cantidad, Pconsig FROM Producto where (nombre='"+ui->productocomboBox2->currentText()+"')"; idunicomodel.setQuery(selec); int id_pro=idunicomodel.record(0).value("Id_pro").toInt(); int cantidad=idunicomodel.record(0).value("cantidad").toInt(); double precio=idunicomodel.record(0).value("Pconsig").toDouble(); ui->costo2spinbox->setValue(precio); ui->cantidad2->setRange(1, cantidad); ui->id2spinbox->setValue(id_pro); }
void SingleWeatherParamWidget::onAirportChanged(QString apCode, QString pName){ //清空 QList<int> keyList = editHash.keys(); for(int key : keyList){ QList<QLineEdit *> editList = editHash[key]; for(QLineEdit *edit : editList){ edit->setText(""); } } //赋值 currentApCode = apCode; currentPName = pName; weatherParamSetupList.clear(); QString queryStr = QString("select * from weatherparamsetup where code = '%1' and planename = '%2' order by paramid") .arg(currentApCode) .arg(currentPName); QSqlQueryModel *plainModel = pgDb->queryModel(queryStr); int rowCount = plainModel->rowCount(); for(int i = 0;i < rowCount;i++){ WeatherParamSetup weatherParamSetup; weatherParamSetup.setCode(plainModel->record(i).value(0).toString()); weatherParamSetup.setPlaneName(plainModel->record(i).value(1).toString()); weatherParamSetup.setParamid(plainModel->record(i).value(2).toInt()); weatherParamSetup.setLimits(plainModel->record(i).value(3).toString()); bool isExist = false; for(WeatherParam weatherParam : weatherParamList){ if(weatherParam.id() == weatherParamSetup.paramid()){ isExist = true; break; } } if(isExist){ weatherParamSetupList.append(weatherParamSetup); } } delete plainModel; for(WeatherParamSetup weatherParamSetup : weatherParamSetupList){ int key = weatherParamSetup.paramid(); QString limitJson = weatherParamSetup.limits(); QList<QString> valueList = this->getDataFromJson(limitJson); QList<QLineEdit *> editList = editHash[key]; int valueCount = valueList.count(); int editCount = editList.count(); for(int i = 0;i < editCount;i++){ QLineEdit *edit = editList[i]; if(valueCount != editCount){ edit->setText(""); }else{ edit->setText(valueList[i]); } } } }
void shift_work::init_data() { QString date1 = ui->label_7->text(); QString date2 = ui->label_8->text(); QSqlQueryModel model; model.setQuery(QString("select count(a.ch_tableno), ifnull(sum(a.int_person), 0)from cey_u_table a , cey_u_checkout_master b where a.ch_payno =b.ch_payno and b.ch_state ='Y' and(b.vch_operID ='%1')and(b.dt_operdate >= '%2' and b.dt_operdate <='%3' )").arg(n_func::gs_operid).arg(date1).arg(date2)); taishu = model.record(0).value(0).toString(); renshu = model.record(0).value(1).toString(); model.clear(); model.setQuery(QString("Select ifnull(sum(num_cost), 0), ifnull(sum(num_discount), 0), ifnull(sum(num_present), 0), ifnull(sum(num_service), 0), ifnull(sum(num_lowcost), 0), ifnull(sum(num_blotout), 0), ifnull(sum (ifnull( num_free ,0)) , 0 ),ifnull(sum(num_cost), 0 )+ ifnull(sum(num_rate), 0 )- ifnull(sum(num_discount), 0)-ifnull(sum(num_present), 0)+ifnull(sum(num_service), 0)+ ifnull(sum(num_lowcost), 0)-ifnull(sum(num_blotout), 0)-ifnull(sum (ifnull(num_free,0 )) , 0 ),ifnull(sum(num_rate), 0)from cey_u_checkout_master where ch_state ='Y' and(vch_operID ='%1')and(dt_operdate >= '%2' and dt_operdate <= '%3' )").arg(n_func::gs_operid).arg(date1).arg(date2)); xiaofei = QString().sprintf("%0.2f",model.record(0).value(0).toFloat()); zhekou = QString().sprintf("%0.2f",model.record(0).value(1).toFloat()); zengsong = QString().sprintf("%0.2f",model.record(0).value(2).toFloat()); fuwufei = QString().sprintf("%0.2f",model.record(0).value(3).toFloat()); dixiao = QString().sprintf("%0.2f",model.record(0).value(4).toFloat()); moling = QString().sprintf("%0.2f",model.record(0).value(5).toFloat()); miandan = QString().sprintf("%0.2f",model.record(0).value(6).toFloat()); yingshou = QString().sprintf("%0.2f",model.record(0).value(7).toFloat()); shuishou = QString().sprintf("%0.2f",model.record(0).value(8).toFloat()); // model.clear(); // model.setQuery(QString("Select ifnull(sum(num_deposit), 0) from t_m_deposit where(vch_operID ='%1')and(dt_operdate >= '%2' and dt_operdate <= '%3')").arg(n_func::gs_operid).arg(date1).arg(date2)); // kafue = QString().sprintf("%0.2f",model.record(0).value(0).toFloat());//充值金额 // qDebug() << model.query().lastQuery(); // model.clear(); // model.setQuery(QString("Select ifnull(sum(num_realamount), 0) from t_m_deposit where(vch_operID ='%1')and(dt_operdate >= '%2' and dt_operdate <= '%3' )").arg(n_func::gs_operid).arg(date1).arg(date2)); // kafue_realamount = QString().sprintf("%0.2f",model.record(0).value(0).toFloat());//充值实收 // qDebug() << model.query().lastQuery(); }
void shift_work::init_table() { QString date1 = ui->label_7->text(); QString date2 = ui->label_8->text(); QSqlQueryModel model; QSettings conf(public_sql::settings_ini_dir_file, QSettings::IniFormat); model_top = new QStandardItemModel(); model_rfb = new QStandardItemModel(); model_top->setHorizontalHeaderLabels(QStringList()<<tr("收款方式")<<tr("收款次数")<<tr("收款金额")<<tr("面额")); model_rfb->setHorizontalHeaderLabels(QStringList()<<tr("会员卡操作方式")<<tr("操作次数")<<tr("金额")); ui->tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);ui->tableView->setModel(model_top); ui->tableView_2->setEditTriggers(QAbstractItemView::NoEditTriggers);ui->tableView_2->setModel(model_rfb); #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) ui->tableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); ui->tableView_2->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); #else ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch); ui->tableView_2->horizontalHeader()->setResizeMode(QHeaderView::Stretch); #endif model.setQuery(QString("Select a.ch_paymodeno , count( a.ch_paymodeno), sum( a.num_realamount), sum( a.num_face),IFNULL(c.vch_paymodename,a.ch_paymodeno) , IFNULL(c.ch_faceflag,'N') from cey_u_checkout_detail a , cey_u_checkout_master b ,cey_bt_paymode c where (c.ch_paymodeno =a.ch_paymodeno)and( a.ch_payno =b.ch_payno)and(b.ch_state ='Y') and(b.vch_operID ='%1')and(b.dt_operdate >= '%2' and b.dt_operdate <= '%3')Group by a.ch_paymodeno ,c.vch_paymodename , c.ch_faceflag having sum( a.num_realamount)> 0 or sum( a.num_payamount)> 0 Order by a.ch_paymodeno ,c.vch_paymodename , c.ch_faceflag").arg(n_func::gs_operid).arg(date1).arg(date2)); for(int i = 0; i < model.rowCount(); i++) { int row = model_top->rowCount(); model_top->setRowCount(row + 1); model_top->setItem(row,0,new QStandardItem(model.record(i).value(4).toString())); model_top->setItem(row,1,new QStandardItem(model.record(i).value(1).toString())); model_top->setItem(row,2,new QStandardItem(QString().sprintf("%0.2f",model.record(i).value(2).toFloat()))); model_top->setItem(row,3,new QStandardItem(QString().sprintf("%0.2f",model.record(i).value(3).toFloat()))); } model.setQuery(QString("select sum(num_deposit),count(*) from t_m_deposit where ch_deposit_mode='1' and dt_operdate >= '%1' and dt_operdate <= '%2' ") .arg(date1).arg(date2)); model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("充值")<< new QStandardItem(model.record(0).value(1).toString())<< new QStandardItem(kafue=model.record(0).value(0).toString())); model.setQuery(QString("select sum(num_realamount),count(*) from t_m_deposit where ch_deposit_mode='1' and dt_operdate >= '%1' and dt_operdate <= '%2' ") .arg(date1).arg(date2)); model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("充值实收")<< new QStandardItem(model.record(0).value(1).toString())<< new QStandardItem(kafue_realamount=model.record(0).value(0).toString())); model.setQuery(QString("select sum(num_deposit),count(*) from t_m_deposit where ch_deposit_mode='8' and dt_operdate >= '%1' and dt_operdate <= '%2' ") .arg(date1).arg(date2)); model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("取款")<< new QStandardItem(model.record(0).value(1).toString())<< new QStandardItem(card_fetch=model.record(0).value(0).toString())); model.setQuery(QString("select sum(num_deposit),count(*) from t_m_deposit where ch_deposit_mode='5' and dt_operdate >= '%1' and dt_operdate <= '%2' ") .arg(date1).arg(date2)); model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("退卡")<< new QStandardItem(model.record(0).value(1).toString())<< new QStandardItem(card_back=model.record(0).value(0).toString())); if(conf.value("w_sys_manage_cloudsync_basedataset/yun_start",false).toBool()){ w_sys_manage_cloudsync::member_r_f_b_info mrfb=w_sys_manage_cloudsync::get_yun_member_r_f_b(n_func::gs_operid, date1, date2); model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("充值(云)")<< new QStandardItem("")<< new QStandardItem(card_recharge_yun=mrfb.rechargeAmount)); model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("充值实收(云)")<< new QStandardItem("")<< new QStandardItem(card_recharge_realamount_yun=mrfb.realRechargeAmount)); model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("取款(云)")<< new QStandardItem("")<< new QStandardItem(card_fetch_yun=mrfb.withdrawalAmount)); model_rfb->appendRow(QList<QStandardItem *>()<<new QStandardItem("退卡(云)")<< new QStandardItem("")<< new QStandardItem(card_back_yun=mrfb.backCardAmount)); } }
bool DataBank::checkExists(unsigned int i) { bool bit = false; bool ok = false; if(!database.open()){ qDebug()<<"database database is error"; }else{ qDebug()<<"database database is ok"; } /*查询数据库中的所有表名*/ QSqlQueryModel model; model.setQuery("select name from sqlite_master where type='table'",database); for(int j = 0; j < model.rowCount(); ++j){ QString name = model.record(j).value("name").toString(); if((unsigned int)name.mid(5,2).toInt(&ok ,10) == i){ bit = true; } } database.close(); return bit; }
//Eventname, der aktiviert wurde, mit remove-pBtn löschen //inklusive der an diesem Event beteiligten Teilnehmern. void MainWindow::on_pBtn_remove_Event_clicked() { QSqlQueryModel *model = (QSqlQueryModel*)ui->listView->model(); QSqlRecord record = model->record(ui->listView->currentIndex().row()); QSqlField field_ID = record.field("ID"); QSqlField field_EventName = record.field("EventName"); QMessageBox msg; msg.setText("Achtung es werden auch alle Teilnehmer, \n die zu diesem Event gehören, gelöscht! \n\n Soll das Event: \n \" " +field_EventName.value().toString()+ "\"\n unwiederruflich gelöscht werden?"); msg.setWindowTitle("Eintrag entfernen"); msg.setStandardButtons(QMessageBox::Yes | QMessageBox::No); msg.setIcon(QMessageBox::Critical); msg.setButtonText(QMessageBox::Yes, "Ja"); msg.setButtonText(QMessageBox::No, "Nein"); msg.setDefaultButton(QMessageBox::No); if (msg.exec() == QMessageBox::Yes) { DBank a; QString ID = field_ID.value().toString(); a.removeEvent(ID); qDebug()<< field_ID.value().toString(); updateListView(); } else { qDebug()<<"EventName-Eintrag wird nicht gelöscht."; } }
/*! Reimplemented to export the Qt::DecorationRole. */ QVariant MetaListViewPart::ProxyModel::data(const QModelIndex & index, int role) const { if ( index.isValid() and (role == Qt::DecorationRole or role == Qt::DisplayRole) ) { QSqlQueryModel *m = qobject_cast<QSqlQueryModel*>(sourceModel()); Q_ASSERT(m); QModelIndex sourceIndex = mapToSource(index); Q_ASSERT(sourceIndex.isValid()); switch(role) { case Qt::DecorationRole: { QString icon = m->record(sourceIndex.row()).value("icon").toString(); return !icon.isEmpty() ? QIcon(icon) : KIcon("wine"); break; } case Qt::DisplayRole: { return ( sourceIndex.row() == m_metaListViewPart->m_defaultRow ) ? sourceIndex.data(role).toString().prepend("* ") : sourceIndex.data(role); break; } default: Q_ASSERT(false); } } return QSortFilterProxyModel::data(index, role); }
void FrmTarifas::cargarDatosTarifa(QModelIndex indice) { QSqlQueryModel* modelo = (QSqlQueryModel*)ui->listaTarifa->model(); QString tarifa = modelo->record(indice.row()).value("descripcion").toString(); QSqlQuery qTarifa(Configuracion_global->groupDB); qTarifa.prepare("select * from codigotarifa where descripcion ='"+tarifa+"'"); if(qTarifa.exec()){ qTarifa.next(); ui->txtCodTarifa->setText(qTarifa.record().field("codigo_tarifa").value().toString()); ui->txtDescTarifa->setText(qTarifa.record().field("descripcion").value().toString()); ui->txtPais->setText(Configuracion_global->Devolver_pais(qTarifa.record().field("id_pais").value().toInt())); ui->txtMoneda->setText(Configuracion_global->Devolver_moneda(qTarifa.record().field("id_monedas").value().toInt())); this->id_tarifa = qTarifa.record().field("id").value().toInt(); this->id_pais = qTarifa.record().field("id_pais").value().toInt(); this->id_moneda = qTarifa.record().field("id_monedas").value().toInt(); this->cod_divisa = Configuracion_global->Devolver_codDivisa(this->id_moneda); this->codigoTarifa = qTarifa.record().field("codigo_tarifa").value().toString(); this->margen = ui->spinMargen->value(); this->pvpDivisa = qTarifa.record().field("pvp").value().toDouble(); this->margen_min = ui->spinmargen_minimo->value(); if (Configuracion_global->divisa_local != ui->txtMoneda->text()) Configuracion_global->getCambio(Configuracion_global->cod_divisa_local,this->cod_divisa); else asignarcambiodivisa(1); } calcular_precio(ui->spinMargen->value()); }
void pandasoft::Principal() { ui->error->hide(); ui->error0->hide(); ui->usuario->setStyleSheet("background-color: none;"); ui->clave->setStyleSheet("background-color: none;"); if(ui->usuario->text().isEmpty()||ui->clave->text().isEmpty()){ if(ui->usuario->text().isEmpty()){ ui->error->show(); ui->usuario->setStyleSheet("background-color: red;"); } if(ui->clave->text().isEmpty()){ ui->error->show(); ui->clave->setStyleSheet("background-color: red;"); } } else { QSqlQueryModel model; QString consulta="select Nombre, Ap, Am, Rol from Usuario where (Nombre='"+ui->usuario->text()+"' and Contrasena='"+ui->clave->text()+"' )"; model.setQuery(consulta); if(model.record(0).value("Rol").toString()==""){ ui->error0->show(); }else{ QString rol = model.record(0).value("Rol").toString(); rolusu=rol; QString usuario = model.record(0).value("Nombre").toString()+" "+model.record(0).value("Ap").toString()+" "+model.record(0).value("Am").toString(); this->setWindowTitle("Principal"); ui->pandasoftstackedWidget->setCurrentIndex(1); ui->menubar->show(); if(rolusu=="1"){ ui->menuMenu_Gerente->setEnabled(false); ui->cabecera->setText("Bienvenido Usuario: "+usuario+" Rol : Jefe de Almacen"); }else{ ui->cabecera->setText("Bienvenido Usuario: "+usuario+" Rol : Gerente"); } } ui->alertalista->setEnabled(false); QString alerta="select Nombre from Producto where Cantidad<Lim_stock"; model.setQuery(alerta); ui->alertalista->setText(model.record(0).value("Nombre").toString()); } }
void LazyWord::RestoreConfig_color() //Get the configuration of color from the database { QSqlQueryModel GetTheLastconfig; GetTheLastconfig.setQuery("select * from LastConfig;"); QSqlRecord Lastconfig_Record = GetTheLastconfig.record(0); colorselect = Lastconfig_Record.value("Color").toString(); }
void MultiWeatherParamWidget::initData(){ //初始化DB pgDb = new PgDataBase; //多要素 QString queryStr = QString("select * from weatherparam where choose_type = 1 and limit_type <> 0 order by id"); QSqlQueryModel *plainModel = pgDb->queryModel(queryStr); int rowCount = plainModel->rowCount(); for(int i = 0;i < rowCount;i++){ WeatherParam weatherParam; weatherParam.setId(plainModel->record(i).value(0).toInt()); weatherParam.setName(plainModel->record(i).value(1).toString()); weatherParam.setChoose_type(plainModel->record(i).value(2).toInt()); weatherParam.setLimit_type(plainModel->record(i).value(3).toInt()); weatherParamList.append(weatherParam); } delete plainModel; }
void DataBank::tableMake(LONG64 ideep,UNINT32 imaterial,UNINT32 iacreage,UNINT32 ieffect,UNINT32 iry ,UNINT32 iovc,UNINT32 ishape) { bool ok = false; QString sql = QString("select * from '%1'"); QString name = ""; if(imaterial == 0){ name = "cust"; }else{ name = "crst"; } name.append(QString::number(ishape,10)); sql.arg(name); if(!database.open()){ qDebug()<<"spark database is error"; }else{ qDebug()<<"spark database is ok"; } QSqlQueryModel model; model.setQuery(sql,database); for(int i = 0; i < model.rowCount(); ++i){ int id = model.record(i).value("h_area").toInt(); QString name = model.record(i).value("no").toString(); qDebug() << id << name; } /* QSqlQuery query(database); query.prepare("select * from cust0 where h_area > :value1 and l_area < :value2 and cnf = 0"); query.bindValue(":value1" ,2); query.bindValue(":value2" ,2); b = query.exec(); if(!b){ qDebug()<<"table is error"; }else{ qDebug()<<"table is ok"; while(query.next()){ qDebug()<<query.value(S_OFS).toString()<<query.value(PP).toString(); } } */ database.close(); }
void PringKvitok::SetDb(db *mdb) { myDB = mdb; ui->comboBox_groups->addItem("Выбрать все", "s_all"); ui->comboBox_groups->addItem("Снять все", "d_all"); QSqlQueryModel *groups = myDB->Query("SELECT * FROM groups WHERE id > 2"); for(int i = 0; i < groups->rowCount(); i++){ ui->comboBox_groups->addItem(groups->record(i).value("name").toString(), groups->record(i).value("id").toString()); } childsCheckBox_map.clear(); QString sql = "SELECT t0.id, t0.group_id, t0.fio, t1.name AS group_name, t0.ls FROM childs t0"; sql += " LEFT OUTER JOIN groups t1 ON t0.group_id = t1.id"; QSqlQueryModel *childs = myDB->Query(sql); for(int i = 0; i < childs->rowCount(); i++){ QString childs_id = childs->record(i).value("id").toString(); ui->tW->insertRow(ui->tW->rowCount()); ui->tW->setItem(ui->tW->rowCount() - 1, 1,new QTableWidgetItem(childs->record(i).value("fio").toString())); ui->tW->setItem(ui->tW->rowCount() - 1, 2,new QTableWidgetItem(childs->record(i).value("group_name").toString())); ui->tW->setItem(ui->tW->rowCount() - 1, 3,new QTableWidgetItem(childs_id)); ui->tW->setItem(ui->tW->rowCount() - 1, 4,new QTableWidgetItem(childs->record(i).value("group_id").toString())); ui->tW->setItem(ui->tW->rowCount() - 1, 5,new QTableWidgetItem(childs->record(i).value("ls").toString())); QCheckBox *cb = new QCheckBox(); cb->setText(childs_id); connect(cb , SIGNAL( toggled(bool) ), this, SLOT( on_childs_toggled(bool)) ); childsCheckBox_map[childs_id] = cb; ui->tW->setCellWidget(ui->tW->rowCount() - 1, 0, cb); } delete groups; delete childs; }
WineConfiguration WineConfigurationsModel::configurationByModelRow(int row) const { // we use another model here because the QSqlRelation hides the // field "wineinstallation" from the original model QSqlQueryModel qmodel; qmodel.setQuery("SELECT wineprefix, wineinstallation FROM wine_configurations"); QSqlRecord record = qmodel.record(row); return configurationFromRecord(record); }
void discount_dispose::on_pushButton_13_clicked()//确定 { this->close(); if(n_func::gs_operid != "0000") { QSqlQueryModel model; model.setQuery(QString("Select int_discount from cey_sys_operator where vch_operID ='%1' and ch_flag = 'Y' ").arg(n_func::gs_operid)); int operdis = model.record(0).value(0).toInt(); if(operdis > ui->lineEdit->text().toInt()) { if(0==lds_messagebox::warning(this, tr("消息提示"),tr("指定操作员没有该折扣权限!"),tr("确认"),tr("取消"))) { power_oper oper; /*oper.exec();*/backheader::static_dialogexec(oper, tr("权限核实")); if(oper.btn_t_f == true) { if(oper.operid != "0000") { model.clear(); model.setQuery(QString("Select int_discount from cey_sys_operator where vch_operID ='%1' and ch_flag = 'Y' ").arg(oper.operid)); int zhe = model.record(0).value(0).toInt(); if(zhe > ui->lineEdit->text().toInt()) { ; lds_messagebox::warning(this, tr("消息提示"),tr("指定操作员没有该折扣权限!")); return; } } } else { return; } } else { return; } } } zhekouzhi = ui->lineEdit->text().toFloat(); btn_t_f = true; }
Activity::Activity(QString courseID, QString activityName) { dbManager db; QSqlQueryModel* model = db.getActivityInfo(courseID, activityName); if (model != NULL) { activityID = model->record(0).value("activityID").toInt(); //actName = activityName; //actType = model->record(0).value("activityType").toString(); //dueDate = model->record(0).value("dueDateTime").toString(); //dueTime = model->record(0).value("dueDateTime").toString(); //pathToStdSubm = model->record(0).value("dueDateTime").toString(); //pathToSolnFile = model->record(0).value("dueDateTime").toString(); //actLanguage = model->record(0).value("dueDateTime").toString(); //bonusDays = model->record(0).value("dueDateTime").toString(); //penaltyDays = model->record(0).value("dueDateTime").toString(); //bonusPercentPerDay = model->record(0).value("dueDateTime").toString(); //penaltyPercentPerDay = model->record(0).value("dueDateTime").toString(); //rubric = model->record(0).value("dueDateTime").toString(); rubricChanged = false; delete model; } model = db.getRubric(QString::number(activityID)); if (model != NULL) { //int itemNum; //QString itemDescription; //int itemGrade; rubricItem_t rubricItem; rubric.clearRubric(); int rowcount = model->rowCount(); for (int i=0; i<rowcount; i++) { rubricItem.itemDescription = model->record(i).value("rubricItemText").toString(); rubricItem.itemNum = model->record(i).value("rubricItemNumber").toInt(); rubricItem.itemGrade = model->record(i).value("rubricItemValue").toInt(); rubricItem.itemID = model->record(i).value("rubricItemID").toInt(); rubric.addRubricItem_withID(rubricItem.itemNum,rubricItem.itemDescription, rubricItem.itemGrade, rubricItem.itemID); } } }
void LazyWord::RestoreConfigall() //Get the configuration from the database { QSqlQueryModel GetTheLastconfig; GetTheLastconfig.setQuery("select * from LastConfig;"); QSqlRecord Lastconfig_Record = GetTheLastconfig.record(0); lastlib = Lastconfig_Record.value("LibSelect").toString(); Shtime = Lastconfig_Record.value("ShowTime").toInt(); Invertime = Lastconfig_Record.value("IntervalTime").toInt(); }
void PrepodMain::on_comboBox_2_currentIndexChanged(int index){ ui->comboBox->clear(); QSqlQueryModel model; QString s = QString("SELECT * FROM \"forkurator\" WHERE \"studGroupId\" = '%1' AND \"Kurator\"='%2' ").arg(groupIds.at(ui->comboBox_2->currentIndex())).arg(IDD); model.setQuery(s); studentsFio.clear(); studentsId.clear(); for (int i=0;i<model.rowCount();i++){ studentsFio<<model.record(i).value("FIO").toString(); studentsId<<model.record(i).value("id").toString(); } if (ui->comboBox->count()!=0) { ui->comboBox->clear(); } ui->comboBox->addItems(studentsFio); qDebug()<<studentsFio; }
void importDialog::selectionChanged(QItemSelection, QItemSelection) { ui->btnImportar->setEnabled(true); if(sender()==ui->listViewFP->selectionModel()) { QSqlQueryModel * model = qobject_cast<QSqlQueryModel*>(ui->listViewFP->model()); _empresaFp = model->record(ui->listViewFP->currentIndex().row()); _empDir = ui->txtRutaBD->text(); _empDir.append("/DBF"); _empDir.append(_empresaFp.value("CODEMP").toString().trimmed()); _contaDir = ui->txtRutaConta->text(); //_contaDir.append("/EMP"); //_contaDir.append(_empresaFp.value("CODEMP").toString().trimmed()); } else { QSqlQueryModel * model = qobject_cast<QSqlQueryModel*>(ui->listView->model()); int index = ui->listView->currentIndex().row(); _grupoMaya = model->record(index); QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL","grupo"); QString bd_name = model->data(model->index(index,2)).toString(); QString bd_host = model->data(model->index(index,5)).toString(); QString bd_user = model->data(model->index(index,6)).toString(); QString bd_pass = model->data(model->index(index,7)).toString(); int bd_port = model->data(model->index(index,8)).toInt(); db.setHostName(bd_host); db.setUserName(bd_user); db.setPassword(bd_pass); db.setPort(bd_port); db.setDatabaseName(bd_name); if(!db.open()) { QMessageBox::critical(this,tr("Error"),tr("No se puede conectar con la base de datos")); } } }
void So2sdr::populateDupesheet() // populates dupe sheet. Needs to be called when switching bands // or first turning on the dupesheet { // if only one dupesheet is active, figure out which one it is bool oneactive=false; int nr=0; if (nDupesheet==1) { oneactive=true; for (int i=0;i<2;i++) { if (!dupesheet[i]) continue; if (dupesheet[i]->isVisible()) { nr=i; break; } } } for (int id=0;id<2;id++) { if (!dupesheet[id]) continue; int ib=id; if (oneactive) { if (nr!=id) continue; ib=activeRadio; } dupesheet[id]->Dupes0->clear(); dupesheet[id]->Dupes1->clear(); dupesheet[id]->Dupes2->clear(); dupesheet[id]->Dupes3->clear(); dupesheet[id]->Dupes4->clear(); dupesheet[id]->Dupes5->clear(); dupesheet[id]->Dupes6->clear(); dupesheet[id]->Dupes7->clear(); dupesheet[id]->Dupes8->clear(); dupesheet[id]->Dupes9->clear(); for (int i = 0; i < dsColumns; i++) { dupeCalls[id][i].clear(); dupeCallsKey[id][i].clear(); } QSqlQueryModel m; m.setQuery("SELECT * FROM log WHERE valid='true' and BAND=" + QString::number(band[ib]), mylog->db); while (m.canFetchMore()) { m.fetchMore(); } for (int i = 0; i < m.rowCount(); i++) { QByteArray tmp = m.record(i).value("call").toString().toAscii(); updateDupesheet(tmp,id); } dupesheet[id]->setWindowTitle("Dupesheet " + bandName[band[ib]]); } }
PrepodMain::PrepodMain(QWidget *parent) : QMainWindow(parent), ui(new Ui::PrepodMain) { ui->setupUi(this); ui->label_2->setText(FIO); // QUuid uuid; // uuid.createUuid().toString(); // QSqlQuery query1111; // QString e1111 = "SELECT * FROM \"StudGroup\""; QSqlQueryModel model; model.setQuery(QString("SELECT * FROM \"forkurator\" WHERE \"Kurator\"='%1'").arg(IDD)); groupNames.clear(); groupIds.clear(); for (int i=0;i<model.rowCount();i++){ groupNames<<model.record(i).value("studGroupName").toString(); groupIds<<model.record(i).value("studGroupId").toString(); } QSet<QString> stringSet = QSet<QString>::fromList(groupNames); groupNames = stringSet.toList(); stringSet = QSet<QString>::fromList(groupIds); groupIds = stringSet.toList(); for (int i=0;i<groupNames.count();i++){ if (groupNames.at(i)=="none"){ groupNames.removeAt(i); groupIds.removeAt(i); break; } } if (ui->comboBox_2->count()!=0) { ui->comboBox_2->clear(); } ui->comboBox_2->addItems(groupNames); }
QVector<QString> ClinicInternalPayment::getDistinctFromDB(QString strColumn, QString strTable) { QVector<QString> vec; QSqlQueryModel *sqlModel = new QSqlTableModel; sqlModel->setQuery("SELECT distinct " + strColumn + " FROM " + strTable); for(int i = 0; i<sqlModel->rowCount();i++) { QSqlRecord record = sqlModel->record(i); QString strReceipt = record.value(strColumn).toString(); vec.append(strReceipt); } return vec; }
void EmployeeDataModel::readAllRecords() { QSqlQueryModel model; model.setQuery(QLatin1String("SELECT * FROM employee")); int colunmCount = model.columnCount(); int rowCount = model.rowCount(); QSqlRecord rec = model.record(); // int recCount = rec.count(); for (int i=0; i<rowCount; i++) { qDebug() << "Record : " << i; rec = model.record(i); for (int j=0; j<colunmCount; j++) { QString value = rec.value(j).toString(); qDebug() << "ColumnCount : " << j << " - Value = " << value; } } }
void AddPlan::on_pushButton_clicked() { QSqlQueryModel *potModel = new QSqlQueryModel(); potModel->setQuery("select id_dis from disciplina where n_dis = '" + ui->comboBox->currentText() + "';"); QString pot = potModel->record(0).field(0).value().toString(); QString query = "insert into plan (id_spec, id_dis, semes) values ('" + idSpec + "', '" + pot + "', '" + semes + "');"; emit InsertQuery(query); emit closeThisWidget(); }
Activity::Activity(int _activityID) { dbManager db; QSqlQueryModel* model = db.getActivityInfo_AID(_activityID); if (NULL != model) { activityID = _activityID; actName = model->record(0).value("activityName").toString(); actType = model->record(0).value("activityType").toString(); dueDate = model->record(0).value("dueDateTime").toDate(); dueTime = model->record(0).value("dueDateTime").toTime(); pathToStdSubm = model->record(0).value("pathToSubmissions").toString(); pathToSolnFile = model->record(0).value("pathToSolution").toString(); actLanguage = model->record(0).value("language").toString(); // bonusDays = model->record(0).value("dueDateTime").toString(); // penaltyDays = model->record(0).value("dueDateTime").toString(); // bonusPercentPerDay = model->record(0).value("dueDateTime").toString(); // penaltyPercentPerDay = model->record(0).value("dueDateTime").toString(); rubricChanged = false; delete model; model = db.getRubric(QString::number(activityID)); if (model != NULL) { rubricItem_t rubricItem; rubric.clearRubric(); int rowcount = model->rowCount(); for (int i=0; i<rowcount; i++) { rubricItem.itemDescription = model->record(i).value("rubricItemText").toString(); rubricItem.itemNum = model->record(i).value("rubricItemNumber").toInt(); rubricItem.itemGrade = model->record(i).value("rubricItemValue").toInt(); rubricItem.itemID = model->record(i).value("rubricItemID").toInt(); rubric.addRubricItem_withID(rubricItem.itemNum,rubricItem.itemDescription, rubricItem.itemGrade, rubricItem.itemID); } delete model; } } }
void L_TAB::on_pushButton_clicked() { QSqlQueryModel *model = new QSqlQueryModel(); model->setQuery("SELECT * FROM settings"); tableView->setFocus(); QModelIndex index = tableView->currentIndex(); QSqlRecord record; record = model->record(index.row()); model->setQuery("DELETE FROM settings WHERE table_name = '" +record.value("table_name").toString() +"'"); model->setQuery("DROP FUNCTION add_to_log_" +record.value("table_name").toString() +"() CASCADE"); model->setQuery("SELECT * FROM settings"); tableView->setModel(model); }
//Nach Doppelklick auf einen Event-Eintrag öffnet //sich ein neues Fenster // -a) entweder ohne Teilnehmer-Einträgen oder // -b) schon mit bereits eingetragenen Teilnehmern void MainWindow::on_listView_doubleClicked(const QModelIndex &index) { Q_UNUSED(index); //Teilnehmer *Fenster = new Teilnehmer(0, meineId); QVariant row = ui->listView->currentIndex().data(); QSqlQueryModel *model = (QSqlQueryModel*)ui->listView->model(); QSqlRecord record = model->record(ui->listView->currentIndex().row()); QSqlField field_ID = record.field("ID"); QString ID = field_ID.value().toString(); Teilnehmer teilnehmer(this, ID); teilnehmer.setModal(true); teilnehmer.setWindowTitle("Event "+row.toString()); teilnehmer.exec(); }
//Ausleitung als csv-Datei void MainWindow::on_pushButton_clicked() { QSqlQueryModel *model = (QSqlQueryModel*)ui->listView->model(); QSqlRecord record = model->record(ui->listView->currentIndex().row()); QSqlField field_ID = record.field("ID"); DBank con; con.con_open(); QSqlQuery query(con.myDB); query.prepare("SELECT t.Vorname as Vorname, t.Nachname as Nachname, time(t.Endzeit-e.Startzeit, \"unixepoch\") from TEILNEHMER as t JOIN EVENT as e ON e.ID == t.EVENT_ID where e.ID = '"+field_ID.value().toString()+"' ORDER BY t.Endzeit ASC"); if(query.exec()) { QSqlQueryModel *model=new QSqlQueryModel(); model->setQuery(query); QString DB_Inhalt; int rows=model->rowCount(); int columns=model->columnCount(); for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { DB_Inhalt += model->data(model->index(i,j)).toString(); DB_Inhalt += "; "; } DB_Inhalt += "\n"; } QString filename = QFileDialog::getSaveFileName(this,"Speichern unter","C://","All files (*.*);;ExcelFile(*.csv)"); QFile csvfile(filename); if(csvfile.open(QIODevice::WriteOnly|QIODevice::Truncate)) { QTextStream out(&csvfile); out<<DB_Inhalt; } csvfile.close(); } }