Beispiel #1
0
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;

}
void mantenimientoTitulo::on_btmBuscar_clicked()
{
    if(m_ui->btmTitulo->isChecked()) {

        QSqlQueryModel *model = new QSqlQueryModel(m_ui->titulos);
        model->setQuery("SELECT tituloObra, isbn FROM titulo WHERE tituloObra LIKE '%"+m_ui->busqueda->text()+"%';", QSqlDatabase::database("sibcues"));
        if (model->lastError().isValid())
            qDebug() << model->lastError();

        model->setHeaderData(0, Qt::Horizontal, QObject::tr("Titulo Material Bibliografico"));
        model->setHeaderData(1, Qt::Horizontal, QObject::tr("ISBN"));
        m_ui->titulos->setModel(model);
        connect(m_ui->titulos->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(on_titulos_activated(QModelIndex)));
        m_ui->labelTitulo->setText("Titulos: "+QString::number(model->rowCount())+" resultados.");
    }
    else {

        QSqlQueryModel *model = new QSqlQueryModel(m_ui->titulos);
        model->setQuery("SELECT titulo.tituloObra, titulo.isbn FROM obrade left join titulo on titulo.idTitulo=obrade.idTitulo left join autor on obrade.idAutor=autor.idAutor WHERE autor.nombreAutor LIKE '%"+m_ui->busqueda->text()+"%';", QSqlDatabase::database("sibcues"));

        if (model->lastError().isValid())
            qDebug() << model->lastError();

        model->setHeaderData(0, Qt::Horizontal, QObject::tr("Titulo Material Bibliografico"));
        model->setHeaderData(1, Qt::Horizontal, QObject::tr("ISBN"));
        m_ui->titulos->setModel(model);
        connect(m_ui->titulos->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(on_titulos_activated(QModelIndex)));
        m_ui->labelTitulo->setText("Titulos: "+QString::number(model->rowCount())+" resultados.");
    }
}
Beispiel #3
0
/*!
   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);
    }
}
ServiceBlock::ServiceBlock(int idC, QWidget *parent) :
    QDialog(parent),
    idCar(idC),
    ui(new Ui::ServiceBlock)
{
    ui->setupUi(this);

    setCalendarColor(ui->deBegin->calendarWidget(),QColor(255,140,0));
    setCalendarColor(ui->deEnd->calendarWidget(),QColor(255,140,0));
    setCalendarColor(ui->deEvent->calendarWidget(),QColor(255,140,0));
    setCalendarColor(ui->deGuarantee->calendarWidget(),QColor(255,140,0));

    QSqlQueryModel * windTitle = new QSqlQueryModel(this);
    windTitle->setQuery(QString("SELECT Brand, Model, LicensePlate FROM car WHERE idCar = %1").arg(idCar));
    this->setWindowTitle( QString("Naprawy - ")
                          + windTitle->data(windTitle->index(windTitle->rowCount()-1,0)).toString() + QString(" ")
                          + windTitle->data(windTitle->index(windTitle->rowCount()-1,1)).toString() + QString(" - ")
                          + windTitle->data(windTitle->index(windTitle->rowCount()-1,2)).toString()
                          );

    connect(this,SIGNAL(saved()),this,SLOT(updateView()),Qt::DirectConnection);
    connect(this,SIGNAL(deleted()),this,SLOT(updateView()));

    // fill category combobox
    QStringList categoryList({QString("Silnik"),QString("Zawieszenie"),QString("Elektronika"),
                             QString("Elektryka"),QString("Układ napędowy"),QString("Układ hamulcowy"),
                             QString("Układ kierowniczy"),QString("Nadwozie")});
    ui->cbCategory->addItems(categoryList);

    updateView();

    isOpen = true;
}
Beispiel #5
0
void DataBank::tableLoad(struct Table0 *t,unsigned int i)
{
    QString name = "table";
    name.append(QString::number(i ,10));
    QString sql = QString("select * from '%1'").arg(name);

    if(!database.open()){
        qDebug()<<"database database is error";
    }else{
        qDebug()<<"database database is ok";
    }

    QSqlQueryModel model;
    model.setQuery(sql,database);

    for(int i = 0; i < model.rowCount(); ++i){
        t->Nummber[i] = model.record(i).value("number").toInt();
        t->Shendu[i] = model.record(i).value("shendu").toLongLong();
        t->Jixing[i] = model.record(i).value("jixing").toInt();
        t->Dianliu[i] = model.record(i).value("dianliu").toInt();
        t->Maikuan[i] = model.record(i).value("maikuan").toInt();
        t->Xiuzhi[i] = model.record(i).value("xiuzhi").toInt();
        t->Jianxi[i] = model.record(i).value("jianxi").toInt();
        t->Sudu[i] = model.record(i).value("sudu").toInt();
        t->Shenggao[i] = model.record(i).value("shenggao").toInt();
        t->Gongshi[i] = model.record(i).value("gongshi").toInt();
        t->LV[i] = model.record(i).value("lv").toInt();
        t->Gaoya[i] = model.record(i).value("gaoya").toInt();
        t->PPP[i] = model.record(i).value("ppp").toInt();
        t->WCLC[i] = model.record(i).value("wclc").toInt();
    }

    database.close();
}
Beispiel #6
0
void Calendar::addEvent()
{
    EventDialog dialog(this);
    dialog.setModal(true);

    if(dialog.exec() == QDialog::Accepted)
    {
        Event tmpEvent = dialog.getEvent();
        qDebug() << tmpEvent.name();

        if((!tmpEvent.name().isEmpty()) || (!tmpEvent.description().isEmpty()))
        {
            QSqlQueryModel check;
            check.setQuery("SELECT * FROM events WHERE date_time='" + tmpEvent.dateTime().toString(m_dateFormat) + "'", m_db);
            if(check.rowCount() == 0)
            {
                QSqlQuery insertion(m_db);
                insertion.prepare("INSERT INTO events(name, description, date_time) VALUES"
                                  "(?,?,?)");
                insertion.addBindValue(tmpEvent.name());
                insertion.addBindValue(tmpEvent.description());
                insertion.addBindValue(tmpEvent.dateTime().toString(m_dateFormat));
                insertion.exec();
                qDebug() << "Pushed";
                m_sqlTableModel->select();
            }
            else
            {
                //Item with this date already exists
                QMessageBox::warning(this, tr("Calendar"), tr("Item with this date and time already exists."));
            }
        }
    }
}
void AdminPatients::on_pushButton_update_clicked()
{

    QSqlQueryModel * model = new QSqlQueryModel();

    QSqlQuery * qry = new QSqlQuery(mydb);

    qry->prepare("select name,surname from patients");
    qry->exec();
    model->setQuery(*qry);
    ui->tableView->setModel(model);



    QSqlQuery * qry1 = new QSqlQuery(mydb);
    QSqlQueryModel * model1 = new QSqlQueryModel();

           qry1->prepare("select name, surname from patients where doctor is null  ");
           qry1->exec();
           model1->setQuery(*qry1);
           ui->tableView_noDoc->setModel(model1);


    QSqlQuery * qry2 = new QSqlQuery(mydb);
    QSqlQueryModel * model2 = new QSqlQueryModel();

           qry2->prepare("select name, surname,doctor from patients where diagnose is null");
           qry2->exec();
           model2->setQuery(*qry2);
           ui->tableView_noDiag->setModel(model2);



    qDebug()<<(model->rowCount());
}
mantenimientoTitulo::mantenimientoTitulo(int idUnidad, QWidget *parent) :
    QDialog(parent),
    m_ui(new Ui::mantenimientoTitulo)
{
    m_ui->setupUi(this);

    m_ui->btmTitulo->setChecked(true);


    Persistencia::Persistencia *servicioPersistencia=new Persistencia(idUnidad);

    QSqlQueryModel *model = new QSqlQueryModel(m_ui->titulos);
    model->setQuery("SELECT tituloObra, isbn FROM titulo;", QSqlDatabase::database("sibcues"));
    if (model->lastError().isValid())
        qDebug() << model->lastError();

    //model->setTable("titulo");
    //model->select();

    model->setHeaderData(0, Qt::Horizontal, QObject::tr("Titulo Material Bibliografico"));
    model->setHeaderData(1, Qt::Horizontal, QObject::tr("ISBN"));
    m_ui->titulos->setModel(model);
    m_ui->titulos->alternatingRowColors();
    //m_ui->titulos->hideColumn(0);
    m_ui->titulos->horizontalHeader()->resizeSection(0, 350);
    m_ui->titulos->setSelectionMode(QAbstractItemView::SingleSelection);
    connect(m_ui->titulos->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(on_titulos_activated(QModelIndex)));
    m_ui->labelTitulo->setText("Titulos: "+QString::number(model->rowCount())+" resultados.");


}
Beispiel #9
0
QSqlQueryModel * LazyWord::GetLibModel()		//Get the Date which the user want to show by degree selected
{
	GetSelect GS;		//more see about class GetSelect 
	int FS = GS.Select(show_StrangeBox->isChecked(),show_UnderstandBox->isChecked(),show_MasterBox->isChecked()
	,show_AllBox->isChecked());	
	//qDebug("FO = %d,IO = %d",FS,IO);
	
	QSqlQueryModel * LibModel = new QSqlQueryModel;
	QString model = "select * from ";	 

   	if( FS-4<=0 )
   	{
   		if( FS-4!=0)
   		{
   			model = model + WordLibBox->currentText() + " where Familiar =" + QString::number(FS);
  		}
  		else
  		{
  			model = model + WordLibBox->currentText();
 		}
  	}
  	else
  	{
		model = model + WordLibBox->currentText() + " where Familiar !=" + QString::number(FS-4);
 	}
 	LibModel->setQuery(model);
 	
 	CheckEnd = LibModel->rowCount();
 	
 	return LibModel; 	
}
Beispiel #10
0
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;
}
Beispiel #11
0
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;
}
Beispiel #12
0
void DetalleCompraVenta::populateCerealField()
{
    QSqlQueryModel cereal;
    cereal.setQuery("SELECT cereal,id FROM cereales");
    for(int i=0; i < cereal.rowCount(); i++)
    {
        //ui->grano->addItem( cereal.data(cereal.index(i,0)).toString(), QVariant( cereal.data(cereal.index(i,1)).toInt()));
    }
}
Beispiel #13
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // подключаемся к БД
    QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
    db.setHostName("localhost");
    db.setDatabaseName("postgres");
    db.setUserName("postgres");
    db.setPassword("12321");
    if(!db.open())
    {
        QMessageBox::critical(
                    this,
                    tr("Ошибка подключения к БД"),
                    tr("Не удалось подключиться к БД.\n")
                        + db.lastError().text()
                    );
        return;
    }
    else QMessageBox::information(
                this,
                tr("Всё огонь"),
                tr("Успешное подключение к БД.")
                );

    // создаём модель запроса и выполняем его в ней
    QSqlQueryModel *model = new QSqlQueryModel;
    // запрашиваем имена полей таблицы
    model->setQuery("SELECT column_name FROM information_schema.columns "
                    "WHERE information_schema.columns.table_name = "
                    "'ВАША_ТАБЛИЦА';");

    // создаём модель для комбо-бокса по числу строк из модели запроса
    QStandardItemModel *model4combo =
            new QStandardItemModel(model->rowCount(), 1, this);

    // переносим данные из модели запроса в модель для комбо-бокса
    QModelIndex index; // индекс для навигации по модели запроса
    for (int i = 0; i < model4combo->rowCount(); i++)
    {
        index = model->index(i, 0, QModelIndex());
        // создаём элемент для добавления в модель комбо-бокса
        QStandardItem* item = new QStandardItem(model->data(index).toString());
        // расставляем флаги, чтобы каждый элемент модели бы чекуемым
        item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
        item->setData(Qt::Checked, Qt::CheckStateRole);
        // добавляем элемент в модель для комбо-бокса
        model4combo->setItem(i, 0, item);
    }

    // назначаем комбо-боксу нашу модель
    ui->comboBox->setModel(model4combo);
}
Beispiel #14
0
void DetalleCompraVenta::populateClienteField()
{
    QSqlQueryModel cliente;
    cliente.setQuery ("SELECT nombre,cuit FROM cliente ORDER BY nombre");

    for(int i=0; i < cliente.rowCount(); i++)
    {
        ui->cliente->addItem( cliente.data(cliente.index(i,0)).toString(), QVariant( cliente.data(cliente.index(i,1)).toDouble()));
    }
}
Manager::Manager(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Manager)
{
    ui->setupUi(this);

    progressBar = new QProgressBar(ui->statusbar);
    progressBar->setMaximumSize(250,40);
    ui->statusbar->addPermanentWidget(progressBar);

    setTabOrder(ui->lineEdit_band_name, ui->lineEdit_Album);
    setTabOrder(ui->lineEdit_Album, ui->lineEdit_price_min);
    setTabOrder(ui->lineEdit_price_min, ui->lineEdit_price_max);

    Database conn;
    QSqlQueryModel * model = new QSqlQueryModel();

    conn.connOpen("Inventory");
    QSqlQuery * qry = new QSqlQuery(conn.mydb);

    qry->prepare("SELECT * from Inventory");
    qry->exec();
    while(qry->next())
    {
        newCatNum = qry->value(12).toInt();
    }
    ++newCatNum;

    model->setQuery(*qry);
    ui->tableView_Master->setModel(model);

    Database conn1;

    conn1.connOpen("Inventory");
    QSqlQuery * qry1 = new QSqlQuery(conn1.mydb);

    ui->comboBox_Type->addItem("Select a Type");

    qry1->prepare("SELECT DISTINCT Type from Inventory");
    qry1->exec();
    while(qry1->next())
    {
        ui->comboBox_Type->addItem(qry1->value(0).toString());
    }

    QModelIndex index = ui->comboBox_Type->model()->index(0, 0);
    QVariant v(0);
    ui->comboBox_Type->model()->setData(index, v, Qt::UserRole - 1);

    conn.connClose();
    conn1.connClose();

    qDebug() << (model->rowCount());
}
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]);
            }
        }
    }
}
Beispiel #17
0
/**
Chequea si existe un contrato de compra asociada al cliente para la carga realizada
**/
bool AgregarCarga::chequearCompra(qlonglong cliente, int grano)
{
    QSqlQueryModel compras;
    QString query = "SELECT * FROM compras WHERE cliente= " + QString::number(cliente) + " AND kilosconcretados-kilosentregados > 0 AND tipocereal = " + QString::number(grano);
    compras.setQuery(query);

    if(compras.rowCount() > 0)
        return true;
    else
        return false;
}
AdminPatients::AdminPatients(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AdminPatients)
{
    ui->setupUi(this);
    mydb =  QSqlDatabase::addDatabase("QSQLITE");
   mydb.setDatabaseName("F:/Documents/GitHub/KPIrepository/courses/prog_base_3/project/ClinicsManagementSystem/logininfo.db");
   if(! mydb.open()) QMessageBox::information(this, tr("oops"),"Failed to open the database");

   //to load the table
      QSqlQueryModel * model = new QSqlQueryModel();

      QSqlQuery * qry = new QSqlQuery(mydb);

      qry->prepare("select name, surname from patients");
      qry->exec();
      model->setQuery(*qry);
      ui->tableView->setModel(model);

QSqlQuery * qry1 = new QSqlQuery(mydb);
QSqlQueryModel * model1 = new QSqlQueryModel();

       qry1->prepare("select name, surname from patients where doctor is null");
       qry1->exec();
       model1->setQuery(*qry1);
       ui->tableView_noDoc->setModel(model1);


QSqlQuery * qry2 = new QSqlQuery(mydb);
QSqlQueryModel * model2 = new QSqlQueryModel();

       qry2->prepare("select name, surname,doctor from patients where diagnose is null");
       qry2->exec();
       model2->setQuery(*qry2);
       ui->tableView_noDiag->setModel(model2);



      QSqlQueryModel * model3 = new QSqlQueryModel();

      QSqlQuery * qry3 = new QSqlQuery(mydb);

      qry3->prepare("select surname from doctors");
      qry3->exec();
      model3->setQuery(*qry3);
      ui->comboBox->setModel(model3);



      qDebug()<<(model->rowCount());


}
Beispiel #19
0
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]]);
    }
}
Beispiel #20
0
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;
}
Beispiel #21
0
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));
    }
}
Beispiel #22
0
void DetalleCompraVenta::populateLocalizacionField()
{
    ui->localizacion->clear();
    QSqlQuery query;
    query.prepare("SELECT id, lugar FROM localizacion WHERE _id = 1 OR cliente = :cliente");
    query.bindValue(":cliente",ui->cliente->itemData(ui->cliente->currentIndex()).toLongLong());
    query.exec();

    QSqlQueryModel campos;
    campos.setQuery(query);

    for(int i=0; i < campos.rowCount(); i++)
    {
        ui->localizacion->addItem( campos.data(campos.index(i,1)).toString(), campos.data(campos.index(i,0)).toInt());
    }
}
void Manager::on_pushButton_Clear_clicked()
{
    //Clearing Text Fields
    progressBar->setValue(0);

    ui->lineEdit_Album->clear();
    ui->lineEdit_band_name->clear();
    ui->lineEdit_price_max->clear();
    ui->lineEdit_price_min->clear();
    ui->label_results->clear();

    Database conn;
    QSqlQueryModel * model = new QSqlQueryModel();

    conn.connOpen("Inventory");
    QSqlQuery * qry = new QSqlQuery(conn.mydb);
    progressBar->setValue(25);
    qry->prepare("SELECT * FROM Inventory");
    qry->exec();
    model->setQuery(*qry);
    ui->tableView_Master->setModel(model);

    ui->comboBox_Type->setCurrentIndex(0);
    progressBar->setValue(50);
    ui->checkBox_XS->setChecked(false);
    ui->checkBox_S->setChecked(false);
    ui->checkBox_M->setChecked(false);
    progressBar->setValue(75);
    ui->checkBox_L->setChecked(false);
    ui->checkBox_XL->setChecked(false);
    ui->checkBox_xxl->setChecked(false);
    progressBar->setValue(100);

    QGraphicsOpacityEffect* opacityEffect = new QGraphicsOpacityEffect(this);
         opacityEffect->setOpacity(1.0);
         ui->statusbar->setGraphicsEffect(opacityEffect);
         QPropertyAnimation* anim = new QPropertyAnimation(this);
         anim->setTargetObject(opacityEffect);
         anim->setPropertyName("opacity");
         anim->setDuration(4000);
         anim->setStartValue(opacityEffect->opacity());
         anim->setEndValue(0);
         anim->setEasingCurve(QEasingCurve::OutQuad);
         anim->start(QAbstractAnimation::DeleteWhenStopped);
    qDebug() << (model->rowCount());

}
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;
}
Beispiel #25
0
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();
}
Beispiel #26
0
void LoginDialog::on_pushButtonEnter_clicked()
{
    QCryptographicHash hash(QCryptographicHash::Md5);
    hash.addData(ui->lineEditPassword->text().toUtf8());

    QSqlQueryModel model;
    QSqlQuery query;
    query.prepare("Select * from users where username=:username and password=:password and status = 'A'");
    query.bindValue(":username", ui->lineEditUsername->text().trimmed());
    query.bindValue(":password", hash.result().toHex());
    query.exec();
    model.setQuery(query);
    if(model.rowCount() > 0){
        emit loggedIn();
    }else{
        qDebug() << "Login Failed";
    }
}
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);
    }

  }


}
Beispiel #28
0
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;
}
  //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();
    }
}
Beispiel #30
0
void QSqlQueryModel_snippets()
{
    {
//! [16]
    QSqlQueryModel *model = new QSqlQueryModel;
    model->setQuery("SELECT name, salary FROM employee");
    model->setHeaderData(0, Qt::Horizontal, tr("Name"));
    model->setHeaderData(1, Qt::Horizontal, tr("Salary"));

//! [17]
    QTableView *view = new QTableView;
//! [17] //! [18]
    view->setModel(model);
//! [18] //! [19]
    view->show();
//! [16] //! [19] //! [20]
    view->setEditTriggers(QAbstractItemView::NoEditTriggers);
//! [20]
    }

//! [21]
    QSqlQueryModel model;
    model.setQuery("SELECT * FROM employee");
    int salary = model.record(4).value("salary").toInt();
//! [21]
    Q_UNUSED(salary);

    {
//! [22]
    int salary = model.data(model.index(4, 2)).toInt();
//! [22]
    Q_UNUSED(salary);
    }

    for (int row = 0; row < model.rowCount(); ++row) {
        for (int col = 0; col < model.columnCount(); ++col) {
            qDebug() << model.data(model.index(row, col));
        }
    }
}