//! Populates the checked in and not checked in item tables.
void wndInventoryCheck::refreshTables( void )
{
    QSqlQuery checkedQuery;
    checkedQuery.prepare( "SELECT iid,name FROM inventorycheck WHERE checked=1" );
    _pDB->query( checkedQuery );
    QSqlQueryModel *checkmodel = new QSqlQueryModel;
    checkmodel->setQuery(checkedQuery);

    // Set header values
    checkmodel->setHeaderData( 0, Qt::Horizontal, tr( "ID" ) );
    checkmodel->setHeaderData( 1, Qt::Horizontal, tr( "Name" ) );

    // Set options for the QTableView
    _pUI->tblCheckedIn->setModel( checkmodel );
    _pUI->tblCheckedIn->verticalHeader()->hide();
    _pUI->tblCheckedIn->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch );
    _pUI->tblCheckedIn->horizontalHeader()->setResizeMode( 1, QHeaderView::Stretch );

    QSqlQuery ncheckedQuery;
    ncheckedQuery.prepare( "SELECT iid,name FROM inventorycheck WHERE checked=0" );
    _pDB->query( ncheckedQuery );
    QSqlQueryModel *ncheckmodel = new QSqlQueryModel;
    ncheckmodel->setQuery( ncheckedQuery );

    // Set header values
    ncheckmodel->setHeaderData( 0, Qt::Horizontal, tr( "ID" ) );
    ncheckmodel->setHeaderData( 1, Qt::Horizontal, tr( "Name" ) );

    // Set options for the QTableView
    _pUI->tblNotCheckedIn->setModel( ncheckmodel );
    _pUI->tblNotCheckedIn->verticalHeader()->hide();
    _pUI->tblNotCheckedIn->horizontalHeader()->setResizeMode( 0, QHeaderView::Stretch );
    _pUI->tblNotCheckedIn->horizontalHeader()->setResizeMode( 1, QHeaderView::Stretch );
}
void UserManagement::setup()
{
    {
    Database conn;
    QSqlQueryModel * model = new QSqlQueryModel();

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

    qry->prepare("SELECT Name, ID from Employees");
    qry->exec();
    model->setQuery(*qry);
    ui->tableView_Users->setModel(model);
    ui->tableView_Users->setColumnWidth(0, 340);
    ui->tableView_Users->horizontalHeader()->setStretchLastSection(true);
    conn.connClose();
    }

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

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

    qry->prepare("SELECT Name, ID from Employees WHERE ONCLOCK = '1'");
    qry->exec();
    model->setQuery(*qry);
    ui->tableView_clock->setModel(model);
    ui->tableView_clock->horizontalHeader()->setStretchLastSection(true);
    conn.connClose();
    }


}
예제 #3
0
파일: log.cpp 프로젝트: n4ogw/so2sdr
/*!
   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);
    }
}
예제 #4
0
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 Search::on_lineEdit_cursorPositionChanged(int arg1, int arg2)
{
    QString name=ui->lineEdit->text();
    if(name.isEmpty())
    {
        QSqlQueryModel *model = new QSqlQueryModel;
            model->setQuery("SELECT firstname, lastname, class, roll_no,STATUS FROM  student where firstname like '"+name+"%'");
            model->setHeaderData(0, Qt::Horizontal, tr("Firstname"));
            model->setHeaderData(1, Qt::Horizontal, tr("Lastname"));
            model->setHeaderData(2,Qt::Horizontal,tr("Class"));
            model->setHeaderData(3,Qt::Horizontal,tr("Roll"));
             model->setHeaderData(4,Qt::Horizontal,tr("Status"));
             ui->tableView->setModel(model);
    }
    else
    {
    QSqlQueryModel *model = new QSqlQueryModel;
        model->setQuery("SELECT firstname, lastname, class, roll_no,STATUS FROM  student where firstname like '"+name+"%'");
        model->setHeaderData(0, Qt::Horizontal, tr("Firstname"));
        model->setHeaderData(1, Qt::Horizontal, tr("Lastname"));
        model->setHeaderData(2,Qt::Horizontal,tr("Class"));
        model->setHeaderData(3,Qt::Horizontal,tr("Roll"));
         model->setHeaderData(4,Qt::Horizontal,tr("Status"));
         ui->tableView->setModel(model);
    }

}
예제 #6
0
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.");
    }
}
void UtilitiesView::setup(int raceTrack){
    //Caricamento tabella tempi
    QSqlQuery q(MainWindow::database);
    q.prepare("SELECT COUNT(*) FROM GPSCoord WHERE CodCircuito = :id");
    q.bindValue(":id",raceTrack);
    q.exec();
    q.next();

    QStringList header;
    header<<"Trascorso"<<"Giro"<<"Gap";
    for(int i=0; i<q.value(0).toInt(); i++){
        header<<QString("Inter. %1").arg(i+1);
    }
    ui->timeTable->setColumnCount(header.count());
    ui->timeTable->setHorizontalHeaderLabels(header);

    GPSSettings settings;
    timeChannel = settings.getSpecialChannel(TIME_CHANNEL);
    lapChannel = settings.getSpecialChannel(LAP_CHANNEL);
    waypointChannel = settings.getSpecialChannel(WAYPOINT_CHANNEL);

    //Caricamento tabella statistiche
    QSqlQueryModel *columnModel = new QSqlQueryModel;
    columnModel->setQuery("SELECT CanID, Nome FROM Canale "
                          "WHERE (CodTipoDato=1 OR CodTipoDato=2) AND (CodTipoIO=1 OR CodTipoIO=3)",
                          MainWindow::database
                          );
    ui->channelList->setModel(columnModel);
    ui->channelList->setModelColumn(1);

    //Caricamento invio msg CAN
    QSqlQueryModel *outputModel = new QSqlQueryModel;
    outputModel->setQuery("SELECT CanID, Nome FROM Canale WHERE (CodTipoIO=2 OR CodTipoIO=3)",
                          MainWindow::database
                          );
    ui->outChannelCombo->setModel(outputModel);
    ui->outChannelCombo->setModelColumn(1);

    statsUpdate->start();

    //Caricamento chiamata team
    //Member::lastCallID = 0;
    QListWidgetItem *item;
    q.exec("SELECT Cognome, Nome, Ruolo,Tel FROM Team ORDER BY Ruolo,Cognome,Nome");
    ui->teamList->clear();
    teamMembers.clear();
    while(q.next()){
        item = new QListWidgetItem(
                    QIcon(":/images/icons/nocall.png"),
                    QString("%1 %2 (%3)")
                        .arg(q.value(0).toString()).arg(q.value(1).toString()).arg(q.value(2).toString()),
                    ui->teamList
                    );
        ui->teamList->addItem(item);
        teamMembers.append(Member(-1,CALL_DISCONNECT,q.value(3).toString()));
    }

}
예제 #8
0
FormAgregarServicio::FormAgregarServicio( QWidget* parent )
: EVentana( parent ), Ui::FormAgregarServPeluqueriaBase()
{
	setupUi(this);
	setObjectName( "FormAgregarServicio" );
	setWindowTitle( "Agregar Nuevo Servicio de Peluqueria" );
	setWindowIcon( QIcon( ":/imagenes/pelu.gif" ) );

	this->addAction( new EActCerrar( this ) );

	QSqlQueryModel *modeloMascota = new QSqlQueryModel( CBMascota );
	if( QSqlDatabase::database().driverName() == "QSQLITE" )
	{
		modeloMascota->setQuery( "SELECT m.id, m.nombre||' - '||d.apellido||', '||d.nombre FROM mascota m, dueno d WHERE m.id_dueno = d.id ORDER BY 2" );
	}
	else if( QSqlDatabase::database().driverName() == "QMYSQL" )
	{
		modeloMascota->setQuery( "SELECT m.id, CONCAT( CONCAT( CONCAT( CONCAT( m.nombre, \" - \" ), d.apellido ), \", \" ), d.nombre ) FROM mascota m, dueno d WHERE m.id_dueno = d.id ORDER BY 2" );
	}
	CBMascota->setModel( modeloMascota );
	CBMascota->setModelColumn( 1 );
	CBMascota->setCurrentIndex( -1 );
	connect( CBMascota, SIGNAL( currentIndexChanged( int ) ), this, SLOT( cambioIndice( int ) ) );

	CWFecha->setMaximumDate( QDate::currentDate() );
	CWFecha->setSelectionMode( QCalendarWidget::SingleSelection );

	PBAgregar->setIcon( QIcon( ":/imagenes/add.png" ) );
	PBAgregar->setShortcut( QKeySequence( "Ctrl+a" ) );
	PBAgregar->setText( "&Agregar" );
	PBBorrar->setIcon( QIcon( ":/imagenes/borrar.png" ) );
	PBBorrar->setShortcut( QKeySequence( "Ctrl+L" ) );
	PBBorrar->setText( "&Limpiar" );

	modeloPeluqueria = new MPeluqueria( this, false );
	modeloPeluqueria->setSolo_lectura( true );
	preferencias *p = preferencias::getInstancia();
	modeloPeluqueria->setLimite( p->value( "General\\limite", 5 ).toInt() );
	modeloPeluqueria->setSort( 4, Qt::DescendingOrder );
 	modeloPeluqueria->setEditStrategy( QSqlTableModel::OnRowChange );
	TVHistorial->setModel( modeloPeluqueria );
	TVHistorial->hideColumn( 0 );
	TVHistorial->hideColumn( 1 );
	TVHistorial->resizeColumnsToContents();

	connect( PBAgregar, SIGNAL( clicked() ), this, SLOT( agregar() ) );
	connect( PBBorrar , SIGNAL( clicked() ), this, SLOT( borrar()  ) );

	QCompleter *completador = new QCompleter( LEDescripcion );
	QSqlQueryModel *modeloDescripciones = new QSqlQueryModel( completador );
	modeloDescripciones->setQuery( "SELECT DISTINCT descripcion FROM peluqueria" );
	completador->setModel( modeloDescripciones );
	LEDescripcion->setCompleter( completador );
}
예제 #9
0
FormListaPeluqueria::FormListaPeluqueria( QWidget* parent )
: EVentana( parent ), Ui::FormListadoPeluqueriaBase()
{
	setupUi(this);
	setObjectName( "lista_servicios" );
	setWindowTitle( "Listado de servicios brindados" );
	setWindowIcon( QIcon( ":/imagenes/pelu.gif" ) );

	this->addAction( new EActCerrar( this ) );
	QAction *ActAgregar = new QAction( "Agregar", this );
	ActAgregar->setIcon( QIcon( ":/imagenes/add.png" ) );
	ActAgregar->setShortcut( QKeySequence( "Ctrl+a" ) );
	DigiFauno *digifauno = qobject_cast<DigiFauno *>(parent);
        connect( ActAgregar, SIGNAL( triggered() ), this, SLOT( agregarServicioPeluqueria() ) );
	this->addAction( ActAgregar );

	QAction *ActBorrar = new QAction( "Borrar", this );
	ActBorrar->setIcon( QIcon( ":/imagenes/eliminar.png" ) );
	ActBorrar->setShortcut( QKeySequence( "Ctrl+b" ) );
	connect( ActBorrar, SIGNAL( triggered() ), this, SLOT( borrar() ) );
	this->addAction( ActBorrar );

	modelo = new MPeluqueria( TVPeluqueria, true );
	modelo->setEditStrategy( QSqlTableModel::OnRowChange );
	TVPeluqueria->setModel( modelo );
	modelo->select();
	TVPeluqueria->setSelectionBehavior( QAbstractItemView::SelectRows );
	TVPeluqueria->resizeColumnsToContents();
	TVPeluqueria->hideColumn( 0 );
	TVPeluqueria->setSortingEnabled( true );

	GBFiltrado->setChecked( false );

	QSqlQueryModel *modeloMascota = new QSqlQueryModel( CBMascota );
	if( QSqlDatabase::database().driverName() == "QSQLITE" )
	{
		modeloMascota->setQuery( "SELECT m.id, m.nombre||' - '||d.apellido||', '||d.nombre FROM mascota m, dueno d WHERE m.id_dueno = d.id" );
	}
	else if( QSqlDatabase::database().driverName() == "QMYSQL" )
	{
		modeloMascota->setQuery( "SELECT m.id, CONCAT( CONCAT( CONCAT( CONCAT( m.nombre, \" - \" ), d.apellido ), \", \" ), d.nombre ) FROM mascota m, dueno d WHERE m.id_dueno = d.id" );
	}
	CBMascota->setModel( modeloMascota );
	CBMascota->setModelColumn( 1 );
	CBMascota->setCurrentIndex( -1 );

	connect( GBFiltrado, SIGNAL( toggled ( bool )              ), this, SLOT( cambioEstadoGrupo( bool )    ) );
	connect( ChBMascota, SIGNAL( stateChanged ( int )          ), this, SLOT( cambioEstadoMascota( int )   ) );
	connect( ChBFecha  , SIGNAL( stateChanged ( int )          ), this, SLOT( cambioEstadoFecha( int )     ) );
	connect( CBMascota , SIGNAL( currentIndexChanged( int )    ), this, SLOT( cambioIndice( int )          ) );
	connect( DEFecha   , SIGNAL( dateChanged ( const QDate & ) ), this, SLOT( cambioFecha( const QDate & ) ) );

	///@todo Agregar calculo de fecha maxima y minima desde la tabla para limitar el filtrado
}
예제 #10
0
void AddressWindowImpl::refreshCategories() {
	qDebug("AddressWindowImpl::refreshCategories");
	QSqlQueryModel *query = new QSqlQueryModel();
	query->setQuery("SELECT category FROM Addresses2Categories WHERE address_id="+currentRecord.value("id").toString());
	if(query->lastError().isValid()) qDebug() << query->lastError();
	categoryList->setModel(query);
	
	query = new QSqlQueryModel();
	query->setQuery("SELECT DISTINCT category FROM Addresses2Categories");
	if(query->lastError().isValid()) qDebug() << query->lastError();
	newCategoryCombo->setModel(query);
}//end refreshCategories
void MainWindow::refreshTrackAndVehicle(){
    int tindex = ui->comboTrack->currentIndex();
    int vindex = ui->comboVehicle->currentIndex();
    QSqlQueryModel *trackModel = (QSqlQueryModel*)ui->comboTrack->model();
    QSqlQueryModel *vehicleModel = (QSqlQueryModel*)ui->comboVehicle->model();
    trackModel->setQuery("SELECT IDCircuito, Nome FROM Circuito", MainWindow::database);
    vehicleModel->setQuery("SELECT IDVeicolo, Nome FROM Veicolo", MainWindow::database);
    ui->comboTrack->setModelColumn(1);
    ui->comboVehicle->setModelColumn(1);
    ui->comboTrack->setCurrentIndex(tindex);
    ui->comboVehicle->setCurrentIndex(vindex);

}
예제 #12
0
frmConfigurar_terminal::frmConfigurar_terminal(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::frmConfigurar_terminal)
{
    ui->setupUi(this);
    QSqlQueryModel *series = new QSqlQueryModel(this);
    series->setQuery("select serie from series",Configuracion_global->empresaDB);
    ui->cboserie->setModel(series);
    ui->cboUsuarioActivo->setModel(Configuracion_global->usuarios_model);
    ui->cboUsuarioActivo->setModelColumn(1);
    QSqlQueryModel *cajas = new QSqlQueryModel(this);
    cajas->setQuery("select desc_caja from cajas",Configuracion_global->empresaDB);
    ui->cbocaja->setModel(cajas);

}
예제 #13
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));
    }
}
예제 #14
0
void EvictionWindow::on_showAllBtn_clicked()
{
    DataBase db;
    db.connectionOpen();

    QSqlQuery query;
    query.prepare("select * from clients");
    query.exec();

    QSqlQueryModel * model = new QSqlQueryModel();
    model->setQuery(query);
    model->QSqlQueryModel::setHeaderData(0, Qt::Horizontal, "ID");
    model->QSqlQueryModel::setHeaderData(1, Qt::Horizontal, "Имя");
    model->QSqlQueryModel::setHeaderData(2, Qt::Horizontal, "Фамилия");
    model->QSqlQueryModel::setHeaderData(3, Qt::Horizontal, "Паспорт");
    model->QSqlQueryModel::setHeaderData(4, Qt::Horizontal, "Количество дней");
    model->QSqlQueryModel::setHeaderData(5, Qt::Horizontal, "Дата посления");
    model->QSqlQueryModel::setHeaderData(6, Qt::Horizontal, "№ комнаты");
    model->QSqlQueryModel::setHeaderData(7, Qt::Horizontal, "Тип комнаты");
    ui->tableView->setModel(model);
    ui->tableView->resizeColumnToContents(4);
    ui->tableView->resizeColumnToContents(5);

    db.connectionClose();
}
activityhome::activityhome(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::activityhome)
{
    ui->setupUi(this);

    ui->myName->setText(getName());
    ui->courseName->setText(getCourseName());
    ui->activityName->setText(getActivityName());

    QSqlQueryModel *model = new QSqlQueryModel();

    QSqlQuery qry;
    QSqlQuery cts;

    cts.prepare("select studentID from CoursesToStudent where courseID = ?");
    cts.addBindValue(courseid);
    cts.exec();

    qry.prepare("select studentName from Students where studentID = ?");

    qry.exec();
    model->setQuery(qry);
    ui->studentList->setModel(model);
}
예제 #16
0
void TableWindow::Prepare(QString filter)
{
    Database database = Database::getInstance();
    QSqlDatabase db = database.getDatabase();

    if (db.open()) {
        Users *user = new Users();
        if (user->userCanEdit(login)) {
            QSqlTableModel *model = new QSqlTableModel();
            model->setTable("money_management");
            model->setFilter(filter);
            model->select();
            model->setEditStrategy(QSqlTableModel::OnFieldChange);
            ui->tableView->setModel(model);
        }
        else {
            QSqlQueryModel *model = new QSqlQueryModel();
            QString query = "select * from money_management";

            if (!filter.isEmpty()) {
                query +=  " where " + filter;
            }

            model->setQuery(query, db);
            ui->tableView->setModel(model);
        }
    }
    else {
        qDebug() << "Open db error.";
    }
}
예제 #17
0
파일: mw1.cpp 프로젝트: Demelode/cs3307a
void MainWindow::updateCustomers()
{
    qDebug() << "Update clicked" << endl;

    QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
    db.setHostName("group1.cs3307.ca");
    db.setDatabaseName("group1");
    db.setUserName("group1_user");
    db.setPassword("AsHa9vg*3_El6oi");

    if (! db.open())
      qFatal("Failed to connect to database.  Check your hostname, username, password, and database name, and try again.");

    QSqlQuery query;
    query.prepare("SELECT first_name, email FROM users WHERE role = 'customer' LIMIT :max");
    query.bindValue(":max", this->ui->spnCount->value());

    if (query.exec())
    {
      QSqlQueryModel* model = new QSqlQueryModel();
      model->setQuery(query);
      this->ui->tblCustomers->setModel(model);
    }
    else
      qFatal(query.lastError().text().toUtf8().constData());
}
//! Loads all items from inventory into the table view in the window.
void wndInventoryControl::refreshMasterList( void )
{
    QSqlQuery selectInventory;

    // If the filter category is all, do not condition SELECT query
    if ( _pUI->cmbCategoryFilter->currentText() == "[All]" )
    {
        selectInventory.prepare( "SELECT * FROM inventory" );
    }  
    else // Otherwise, append the filter text to a condition in the query
    {
        selectInventory.prepare( "SELECT * FROM inventory WHERE category=?" );
        selectInventory.addBindValue( _pUI->cmbCategoryFilter->currentText() );
    }

    if ( _pDB->query( selectInventory ) )
    {
        // Create a SQL Query Model for the QTableView
        QSqlQueryModel *model = new QSqlQueryModel;
        model->setQuery( selectInventory );

        // Set header values
        model->setHeaderData( 0, Qt::Horizontal, tr( "Barcode" ) );
        model->setHeaderData( 1, Qt::Horizontal, tr( "Name" ) );
        model->setHeaderData( 2, Qt::Horizontal, tr( "Description" ) );
        model->setHeaderData( 3, Qt::Horizontal, tr( "Category" ) );

        // Set options for the QTableView
        _pUI->tblInventory->setModel( model );
        _pUI->tblInventory->verticalHeader()->hide();
        _pUI->tblInventory->horizontalHeader()->setResizeMode( 1, QHeaderView::Stretch );
        _pUI->tblInventory->horizontalHeader()->setResizeMode( 2, QHeaderView::Stretch );
        _pUI->tblInventory->horizontalHeader()->setResizeMode( 3, QHeaderView::Stretch );
    }
}
예제 #19
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;
}
예제 #20
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();
}
void CharacteristicAssignmentPrivate::handleTargetType()
{
  QString charuseTargetType = targetType;

  if (targetType == "I" || targetType == "ITEMGRP")
  {
    _template=true;
  }
  else if (targetType == "CT")
  {
    _template=true;
    charuseTargetType = "C"; // bug 25940
  }
  else
    parent->_default->hide();

  if (targetType != "I")
    parent->_listprice->hide();

  parent->setWindowTitle(parent->tr("Characteristic: %1").arg(targetTypeMap.value(targetType)));

  QSqlQueryModel *model = new QSqlQueryModel;
  model->setQuery("SELECT char_id, char_name, char_type"
                  "  FROM char JOIN charuse ON char_id = charuse_char_id"
                  " WHERE charuse_target_type = '" + charuseTargetType + "'"
                  " ORDER BY char_order, char_name");
  parent->_char->setModel(model);
  idCol   = model->query().record().indexOf("char_id");
  nameCol = model->query().record().indexOf("char_name");
  typeCol = model->query().record().indexOf("char_type");
  parent->_char->setModelColumn(nameCol); // char_name
  parent->sHandleChar();
}
예제 #22
0
void HModifyProd::getComponetsLot()
{
    QSqlQuery q(db);
  //  idlot=ui->tvLots->model()->index(ui->tvLots->currentIndex().row(),0).data(0).toInt();
    QString sql="select operazioni.ID,operazioni.IDlotto,lotdef.lot,prodotti.ID,prodotti.descrizione,operazioni.quantita,unita_di_misura.ID,unita_di_misura.descrizione from operazioni,lotdef,prodotti,unita_di_misura where prodotti.ID=operazioni.IDprodotto and lotdef.ID=operazioni.IDlotto and unita_di_misura.ID=operazioni.um and  operazioni.ID in (SELECT operazione from composizione_lot where ID_lotto=:lotid )order by operazioni.quantita desc";
    QSqlQueryModel *qmod = new QSqlQueryModel();
    q.prepare(sql);
    q.bindValue(":lotid",QVariant(idlot));
    q.exec();
    qmod->setQuery(q);
   // // qDebug()<<q.lastQuery();

    ui->tvDetails->setModel(qmod);
    connect(ui->tvDetails->selectionModel(),SIGNAL(currentChanged(QModelIndex,QModelIndex)),this,SLOT(getLotRowData()));
    //// qDebug()<<q.lastError().text();
    qmod->setHeaderData(4,Qt::Horizontal,QObject::tr("Ingrediente"));
    qmod->setHeaderData(5,Qt::Horizontal,QObject::tr("Quantità"));
    ui->tvDetails->setColumnHidden(0,true);
    ui->tvDetails->setColumnHidden(1,true);
    ui->tvDetails->setColumnHidden(3,true);
    ui->tvDetails->setColumnHidden(6,true);


    QString lbtxt;
    lbtxt=ui->tvLots->model()->index(ui->tvLots->currentIndex().row(),1).data(0).toString();
    lbtxt.append(" - ");
    lbtxt.append(ui->tvLots->model()->index(ui->tvLots->currentIndex().row(),2).data(0).toString());
    ui->lbProd->setText(lbtxt);



// qDebug()<<QString::number(idlot);


}
예제 #23
0
파일: all.cpp 프로젝트: antonmazun/gogog
All::All(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::All)
{
    ui->setupUi(this);
setWindowFlags( Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint );

regall = QSqlDatabase::addDatabase("QSQLITE");
regall.setDatabaseName("D:/Kyrs/Kyrs/Reg.db");

    db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("D:/Kyrs/Kyrs/Book.db");

    if(!db.open()){

        qDebug() << db.lastError().text();
         return;
     }
     else {

        qDebug() << "Success!";

   }

    //All conn;
    QSqlQueryModel * modal = new QSqlQueryModel();

    //conn.connOpen();
    QSqlQuery * qry = new QSqlQuery(db);
    qry->prepare("select Genre , Name , Author , Year  from Book");
    qry->exec();

    modal->setQuery(*qry);
    ui->tableView->setModel(modal);
    db.close();

/*
    regall.setDatabaseName("D:/Kyrs/Kyrs/Reg.db");
    if(!regall.open()){
        qDebug() << regall.lastError().text();
         return;
     }
     else {
        qDebug() << "Success reg!";
   }
*/

   /*
    QSqlQueryModel * model = new QSqlQueryModel();

    QSqlQuery * qry = new QSqlQuery(mydb);

    qry->prepare("select * from doctors");
    qry->exec();
    model->setQuery(*qry);
    ui->tableView->setModel(model);

    mydb.close();
    qDebug()«(model->rowCount());*/
}
예제 #24
0
void AdminWindow::onTransactionTableDoubleClicked(QModelIndex index)
{

    if(index.column() >0) return;
  QSqlQueryModel* model = new QSqlQueryModel();
  transactionDetail = new QTableView();

  qDebug()<< transactionTable->model()->data(index).toString();
  QString data  = transactionTable->model()->data(index).toString();
  QSqlQuery qr ;
  qr.prepare("SELECT food, quantity, subtotal FROM TransactionsDetails WHERE TransactionID = :t_id");
  qr.bindValue(":t_id",data);
  bool res = qr.exec();
  if(res)
  {
      model->setQuery(qr);
      transactionDetail->setModel(model);

      qDebug()<<data;

      while(qr.next())
      {

          qDebug()<<qr.record().value("food")<<qr.record().value("quantity");
      }
  }

  transactionDetail->resizeColumnsToContents();
  transactionDetail->horizontalHeader()->setStretchLastSection(true);
  transactionDetail->setWindowModality(Qt::ApplicationModal);
  transactionDetail->show();

}
예제 #25
0
파일: users.cpp 프로젝트: HackeaMesta/Qt
void Users::loadData() {
    /*
     * Inicializa la clase DBConnect en el objeto connection y
     * Valida la conexion a la BD
    */\
    DBConnect connection;
    if (!connection.dbOpen()) {
        QMessageBox::critical(this, tr("Error!"), tr("Ocurrio un error al cargar la Base de Datos"));
    }

    QSqlQueryModel * modal = new QSqlQueryModel;
    QSqlQuery* query = new QSqlQuery(connection.db);

    query->prepare("SELECT usuario, nombre, tipo FROM empleados WHERE tipo != 'developer'");

    if (query->exec()) {
        /*
         * Si la consulta es correcta
         * muestra en la tabla los usuarios
         * y en la lista desplegable
        */
        modal->setQuery(*query);
        ui->userslist->setModel(modal);
        ui->comboBox->setModel(modal);
        connection.dbClose(); //cierra la conexion a la BD
    }
}
예제 #26
0
FrmTransportistas::FrmTransportistas(QWidget *parent) :
    MayaModule(module_zone(),module_name(),parent),
    ui(new Ui::FrmTransportistas),
    menuButton(QIcon(":/Icons/PNG/transport.png"),tr("Transportistas"),this)
{
    ui->setupUi(this);

    transportistas oTransportista(this);
    anadiendo = false;
    ui->txtCodigo_proveedor->installEventFilter(this);
    //------------------
    // Busqueda
    //------------------
    ui->stackedWidget->setCurrentIndex(0);
    m = new QSqlQueryModel(this);
    m->setQuery("select codigo,transportista from transportista",Configuracion_global->groupDB);
    ui->tablaBusqueda->setModel(m);

    //---------------
    // Cargo combos
    //---------------
    QSqlQueryModel *paises = new QSqlQueryModel(this);
    paises->setQuery("select pais from paises order by pais",Configuracion_global->groupDB);
    ui->cbopais->setModel(paises);
    Bloquear_campos(true);

    setUpBusqueda();
}
예제 #27
0
void Browser::exec()
{
    last_query = sqlEdit->toPlainText();
    tablelisten.clear();
    QSqlDatabase currendb(connectionWidget->currentDatabase());
    tablelisten = currendb.tables();
     for (int i = 0; i < tablelisten.size(); ++i)  {
          QString tabi = tablelisten.at(i);
          if (last_query.contains(tabi,Qt::CaseInsensitive)) {
          runningtable = tabi;
          }
     }
    QSqlQueryModel *model = new QSqlQueryModel(table);
    model->setQuery(QSqlQuery(last_query,currendb));
    table->setModel(model);
    if (model->lastError().type() != QSqlError::NoError) {
        emit statusMessage(model->lastError().text());
    } else if (model->query().isSelect()) {
        emit statusMessage(tr("Query OK on table %1").arg(runningtable));
        emit registerQuerySuccess(last_query,runningtable);  /* take last register table name .... */
    } else {
        emit statusMessage(tr("Query OK, number of affected rows: %1").arg(
                           model->query().numRowsAffected()));
    }

    updateActions();
}
예제 #28
0
파일: mainwindow.cpp 프로젝트: proton/lau
void MainWindow::setModel()
{
    if(QSqlDatabase::contains(QSqlDatabase::defaultConnection)) {
        db = QSqlDatabase::database();
    } else {
        db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabaseName("d:\\db.db3");
    }
    if (db.open())
    {
    QSqlQueryModel *model = new QSqlQueryModel();
    model->setQuery("SELECT title FROM databases");

    ui->listView->setModel(model);

    }else{
        qDebug()<<QObject::trUtf8("Ошибка");
    }
    QSqlQuery query;

    if (query.exec("SELECT * FROM settings WHERE Setting = 'path';"))
    {
         QSqlRecord rec = query.record();
        while (query.next())
        {
        ui->label_path->setText(query.value(rec.indexOf("VALUE")).toString());
        }
    }else{
        ui->label_path->setText(QObject::tr("Невозможно прочитать путь к файлам"));
    }
}
예제 #29
0
Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
        ui->setupUi(this);

        setFixedSize(750, 500); // 窗口大小
        ui->stackedWidget->setCurrentIndex(0);

        QSqlQueryModel *typeModel = new QSqlQueryModel(this);
        typeModel->setQuery("select name from type");
        ui->sellTypeComboBox->setModel(typeModel);

        QSplitter *splitter = new QSplitter(ui->managePage);
        splitter->resize(700, 360);
        splitter->move(0, 50);

        splitter->addWidget(ui->toolBox);
        splitter->addWidget(ui->dailyList);
        splitter->setStretchFactor(0, 1);
        splitter->setStretchFactor(1, 1);

        on_sellCancelBtn_clicked();

        showDailyList();
}
예제 #30
0
Deluser::Deluser(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Deluser)
{
    ui->setupUi(this);


setWindowFlags( Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint );
    delusbd = QSqlDatabase::addDatabase("QSQLITE");

    delusbd.setDatabaseName("D:/Kyrs/Kyrs/Reg.db");
    delusbd.open();
    if(!delusbd.isOpen()){

        qDebug() << delusbd.lastError().text();
         return;
     }
     else {

        qDebug() << "Success!";

   }

    //All conn;
    QSqlQueryModel * modal = new QSqlQueryModel();

    //conn.connOpen();
    QSqlQuery * qry = new QSqlQuery(delusbd);
    qry->prepare("select Name  , Surname, Username  from Reg");
    qry->exec();

    modal->setQuery(*qry);
    ui->tableView->setModel(modal);
   // delusbd.close();
}