Ejemplo n.º 1
0
void FacturaView::on_mui_veralbaranes_clicked()
{
    BL_FUNC_DEBUG
    AlbaranClienteView *bud = NULL;
    BlDbRecordSet *cur = NULL;
    try {
        QString SQLQuery = "SELECT * FROM albaran WHERE refalbaran = '" + dbValue ( "reffactura" ) + "'";
        cur = mainCompany() ->loadQuery ( SQLQuery );
        if ( !cur->eof() ) {
            while ( !cur->eof() ) {
	      
		/// Como estamos en un plugin buscamos nuevas formas de creacion de objetos.
		int resur = g_plugins->run ( "SNewAlbaranClienteView", mainCompany() );
		if ( !resur ) {
		    blMsgInfo ( _ ( "No se pudo crear instancia de albaran" ) );
		    return;
		} // end if
                bud = ( AlbaranClienteView * ) g_plugParams;
                mainCompany() ->m_pWorkspace->addSubWindow ( bud );
                bud->load ( cur->value( "idalbaran" ) );
                bud->show();
                cur->nextRecord();
            } // end while
        } else {
            blMsgInfo ( _ ( "No hay albaranes con esta referencia" ), this );
        } // end if
        delete cur;
    } catch ( ... ) {
        blMsgInfo ( _ ( "Error inesperado" ), this );
        if ( cur ) delete cur;
        if ( bud ) delete bud;
    } // end try
    
}
Ejemplo n.º 2
0
QString ServerLight::categoryArticleXML()
{
    QString textoXML = "";
    QString query;

    BlDbRecordSet *familias;
    BlDbRecordSet *articulos;
    
    query = "SELECT idfamilia, codigocompletofamilia, nombrefamilia FROM familia ORDER BY nombrefamilia";
    familias = mainCompany()->loadQuery(query);

    while (!familias->eof()) {
	textoXML += "<CATEGORIA>\\\n";

	  textoXML += "<CODCATEGORIA>";
	  textoXML += familias->value("codigocompletofamilia");
	  textoXML += "</CODCATEGORIA>\\\n";

	  textoXML += "<NOMCATEGORIA>";
	  textoXML += familias->value("nombrefamilia");
	  textoXML += "</NOMCATEGORIA>\\\n";

	      query = "SELECT idarticulo, nomarticulo, pvpivaincarticulo FROM articulo WHERE idfamilia = " + familias->value("idfamilia") + "ORDER BY nomarticulo";
	      articulos = mainCompany()->loadQuery(query);
	      
	      if (articulos->numregistros() > 0) {
		
		while (!articulos->eof()) {
		  
		      textoXML += "<ARTICULO>\\\n";

			  textoXML += "<IDARTICULO>";
			  textoXML += articulos->value("idarticulo");
			  textoXML += "</IDARTICULO>\\\n";

			  textoXML += "<NOMARTICULO>";
			  textoXML += articulos->value("nomarticulo");
			  textoXML += "</NOMARTICULO>\\\n";

			  textoXML += "<PVPARTICULO>";
			  textoXML += articulos->value("pvpivaincarticulo");
			  textoXML += "</PVPARTICULO>\\\n";
		      
		      textoXML += "</ARTICULO>\\\n";
		      
		      articulos->nextRecord();
		  
		} // end while
		
	      } // end if

	textoXML += "</CATEGORIA>\\\n\\\n\\\n";
	
	familias->nextRecord();

    } // end while
    
    return textoXML;
}
void BcAsientoInteligenteView::inicializaVariables()
{
    BL_FUNC_DEBUG
    QString subcadena;
    QString buffer;
    QDate fecha;
    fecha = QDate::currentDate();
    buffer.sprintf ( "%d/%d/%d", fecha.day(), fecha.month(), fecha.year() );
    subcadena = buffer;
    variablespredefinidas[VAR_PRED_FECHAACTUAL][0] = "$fechaactual$";
    variablespredefinidas[VAR_PRED_FECHAACTUAL][1] = subcadena;
    buffer.sprintf ( "SELECT * FROM asiento WHERE idasiento = %d", numasiento );
    mainCompany() ->begin();
    BlDbRecordSet *cur = mainCompany() ->loadQuery ( buffer, "cargaasiento" );
    mainCompany() ->commit();
    if ( !cur->eof() ) {
        variablespredefinidas[VAR_PRED_FECHAASIENTO][0] = "$fechaasiento$";
        variablespredefinidas[VAR_PRED_FECHAASIENTO][1] = cur->value( "fecha" );
    } else {
        variablespredefinidas[VAR_PRED_FECHAASIENTO][0] = "$fechaasiento$";
        variablespredefinidas[VAR_PRED_FECHAASIENTO][1] = "";
    } // end if
    delete cur;
    indvariablespredefinidas = 2;
    
}
Ejemplo n.º 4
0
Trabajadores::Trabajadores ( BlMainCompany *emp, QWidget *parent, bool deleteOnClose ) : QDialog ( parent ), BlMainCompanyPointer ( emp )
{
    setupUi ( this );

    connect (this, SIGNAL(rejected()), this, SLOT(closeDialog()) );
    
    mui_password->setFocus(Qt::OtherFocusReason);
    installEventFilter(this);
    
    m_validUser = false;
    m_deleteOnClose = deleteOnClose;
    
    BlDbRecordSet *cur = mainCompany() ->loadQuery ( "SELECT * FROM trabajador" );
    while ( !cur->eof() ) {
        QPushButton * toolbutton = new QPushButton ( mui_frame );
        toolbutton->setText ( cur->value( "nomtrabajador" ) + " " + cur->value( "apellidostrabajador" ) );
        toolbutton->setMaximumHeight(200);

        QVBoxLayout *m_hboxLayout1 = mui_frame->findChild<QVBoxLayout *> ( "hboxLayout1" );
        if ( !m_hboxLayout1 ) {
            m_hboxLayout1 = new QVBoxLayout ( mui_frame );
            m_hboxLayout1->setSpacing ( 0 );
            m_hboxLayout1->setMargin ( 0 );
            m_hboxLayout1->setObjectName ( QString::fromUtf8 ( "hboxLayout1" ) );
        } // end if
        m_hboxLayout1->addWidget ( toolbutton );
        connect ( toolbutton, SIGNAL ( clicked() ), this, SLOT ( trabajadorClicked() ) );
        cur->nextRecord();
    } // end while
    
    delete cur;
}
Ejemplo n.º 5
0
/**
\param val
**/
void BlSearchWidget::setFieldValue ( QString campo, QString val )
{
    BL_FUNC_DEBUG
    BlDebug::blDebug ( "BlSearchWidget::setcifprofesor", 0, val );

    QString SQLQuery("");
    SQLQuery = "SELECT * FROM " + m_tabla + " WHERE " + campo + " = $1";
    BlDbRecordSet *cur = mainCompany() ->load ( SQLQuery, val );

    if ( !cur->eof() ) {
        /// Inicializamos los valores de vuelta a ""
        QMapIterator<QString, QString> i ( m_valores );
        while ( i.hasNext() ) {
            i.next();
            m_valores.insert ( i.key(), cur->value( i.key() ) );
        } // end while
    } else {
        /// Inicializamos los valores de vuelta a ""
        QMapIterator<QString, QString> i ( m_valores );
        while ( i.hasNext() ) {
            i.next();
            m_valores.insert ( i.key(), "" );
        } // end while
    } // end if
    delete cur;
    pinta();
    
}
int BtTicket_insertarArticuloCodigoNL_Post ( BtTicket *tick )
{
    BL_FUNC_DEBUG
    int valor = -1;
    static int semaforo = 0;
    if ( semaforo == 0 ) {
        valor = 0;
        semaforo = 1;
        QString query = "SELECT * FROM tc_articulo_alias LEFT JOIN tc_talla AS t1 ON tc_articulo_alias.idtc_talla = t1.idtc_talla LEFT JOIN tc_color AS t2 ON tc_articulo_alias.idtc_color = t2.idtc_color WHERE aliastc_articulo_tallacolor = '" + ( ( BtCompany * ) tick->mainCompany() )->valorBtInput() + "'";
        BlDbRecordSet *cur = tick->mainCompany() ->loadQuery ( query );
        if ( !cur->eof() ) {
            BlDbRecord * rec = tick->insertarArticulo ( cur->value( "idarticulo" ), BlFixed ( "1" ), true );
            rec->setDbValue ( "idtc_talla", cur->value( "idtc_talla" ) );
            rec->setDbValue ( "idtc_color", cur->value( "idtc_color" ) );
            rec->setDbValue ( "nomtc_talla", cur->value( "nomtc_talla" ) );
            rec->setDbValue ( "nomtc_color", cur->value( "nomtc_color" ) );
        } else {
	    valor = -1;
	} // end if
        delete cur;
        tick->pintar();
        semaforo = 0;
    } // end if
    
    return valor;
}
Ejemplo n.º 7
0
/**
\param l
\return
**/
int BfBuscarReferencia_on_mui_rferencia_returnPressed ( BfBuscarReferencia *l )
{
    BL_FUNC_DEBUG

    /// Buscamos la ficha que corresponde al widget.
    QList<BfForm *> lista = g_main->findChildren<BfForm *>();

    BfForm *ficha = ( BfForm * ) l->parentWidget();

    while ( ficha && !lista.contains ( ficha ) ) {
        ficha = ( BfForm * ) ficha->parentWidget();
    } // end while

    if ( ficha ) {
        QString query = "SELECT * FROM " + ficha->tableName() + " WHERE ref" + ficha->tableName() + " = '" + l->text() + "'";
        BlDebug::blDebug ( Q_FUNC_INFO, 0, QString(_("Consulta: '%1'.")).arg(query) );
        BlDbRecordSet *cur = l->mainCompany()->loadQuery ( query );
        if ( !cur->eof() ) {
            ficha->load ( cur->value( "id" + ficha->tableName() ) );
        } // end if
        delete cur;
    } // end if

    
    return 0;
}
Ejemplo n.º 8
0
/**
\param comp
\param idprevcobro
**/
linprevcobro::linprevcobro ( BcCompany *comp, QString idprevcobro )
{
    BL_FUNC_DEBUG
    company = comp;
    dbConnection = comp->bdempresa();
    QString SQLQuery = "SELECT * FROM prevcobro "
                       "LEFT JOIN  cuenta ON prevcobro.idcuenta = cuenta.idcuenta "
                       "LEFT JOIN (SELECT codigo AS codigoctacliente, descripcion AS nomctacliente, idcuenta AS idctacliente FROM cuenta) AS T1 ON T1.idctacliente = prevcobro.idctacliente "
                       "WHERE idprevcobro = " + idprevcobro;
    BlDbRecordSet *cur = dbConnection->loadQuery ( SQLQuery );
    if ( !cur->eof() ) {
        mdb_idprevcobro = cur->value( "idprevcobro" );
        mdb_fprevistaprevcobro = cur->value( "fprevistaprevcobro" );
        mdb_fcobroprevcobro = cur->value( "fcobroprevcobro" );
        mdb_idfpago = cur->value( "idfpago" );
        mdb_idcuenta = cur->value( "idcuenta" );
        mdb_idasiento = cur->value( "idasiento" );
        mdb_cantidadprevistaprevcobro = cur->value( "cantidadprevistaprevcobro" );
        mdb_cantidadprevcobro = cur->value( "cantidadprevcobro" );
        mdb_idregistroiva = cur->value( "idregistroiva" );
        mdb_tipoprevcobro = cur->value( "tipoprevcobro" );
        mdb_docprevcobro = cur->value( "docprevcobro" );
        mdb_codigocuenta = cur->value( "codigo" );
        mdb_nomcuenta = cur->value( "descripcion" );
        mdb_idctacliente = cur->value( "idctacliente" );
        mdb_codigoctacliente = cur->value( "codigoctacliente" );
        mdb_nomctacliente = cur->value( "nomctacliente" );
    } else {
        vacialinprevcobro();
    }// end if
    
}
Ejemplo n.º 9
0
void ArtGraficos::cargaXML ( QString filename )
{
    QFile file ( filename );
    if ( !file.open ( QIODevice::ReadOnly ) )
        return;
    if ( !m_doc.setContent ( &file ) ) {
        file.close();
        return;
    }
    file.close();

    /// Cogemos parametros adicionales para que no haya que ir a buscarlos a la base de datos y asi mejore la velocidad.

    /// Itero sobre las pantallas para obtener los nombres de pantalla y crear los botones pretinentes.
    QDomElement docElem = m_doc.documentElement();
    QDomNodeList nodos = docElem.elementsByTagName ( "ITEM" );

    for ( int i = 0; i < nodos.count(); i++ ) {
        /// Cogemos el titulo de la pantalla
        QString codigo = nodos.item ( i ).firstChildElement ( "CODIGO" ).text();
        /// Buscamos los parametros en la base de datos.
        QString query = "SELECT * FROM articulo LEFT JOIN (SELECT idtipo_iva, porcentasa_iva, fechatasa_iva FROM tasa_iva ) AS t1 ON articulo.idtipo_iva = t1.idtipo_iva WHERE codigocompletoarticulo = '" + codigo + "' ORDER BY t1.fechatasa_iva LIMIT 1";
        BlDbRecordSet *cur = mainCompany() ->loadQuery ( query );
        if ( !cur->eof() ) {

		QDomElement tag = m_doc.createElement( "PVPIVAINCARTICULO" );
		tag.appendChild( m_doc.createTextNode( cur->value("pvpivaincarticulo") ) );
		nodos.item(i).appendChild( tag );

		QDomElement tag4 = m_doc.createElement( "PVPARTICULO" );
		tag4.appendChild( m_doc.createTextNode( cur->value("pvparticulo") ) );
		nodos.item(i).appendChild( tag4 );

		QDomElement tag1 = m_doc.createElement( "IDARTICULO" );
		tag1.appendChild( m_doc.createTextNode( cur->value("idarticulo") ) );
		nodos.item(i).appendChild( tag1 );

		QDomElement tag2 = m_doc.createElement( "NOMARTICULO" );
		tag2.appendChild( m_doc.createTextNode( cur->value("nomarticulo") ) );
		nodos.item(i).appendChild( tag2 );

		QDomElement tag3 = m_doc.createElement( "IVAARTICULO" );
		tag3.appendChild( m_doc.createTextNode( cur->value("porcentasa_iva") ) );
		nodos.item(i).appendChild( tag3 );

		/// Ponemos todos los campos del registro cargado para que esten cacheados.
		for (int j = 0; j < cur->numcampos(); j++) {
			QDomElement tag3 = m_doc.createElement(cur->fieldName(j) );
			tag3.appendChild( m_doc.createTextNode( cur->value(j) ) );
			nodos.item(i).appendChild( tag3 );
		} // end for

        } // end if
        delete cur;

    } // end for


}
Ejemplo n.º 10
0
void BcBloqueaFechaView::on_mui_crear_clicked()
{
    BL_FUNC_DEBUG
    /// Tomamos el anyo pasado como referencia.
    int ejer = QDate::currentDate().year() - 1;

    /// Miramos si ya hay ejercicios introducidos y si es asi cogemos el siguiente como referencia.
    QString consultabd = "SELECT max(ejercicio) AS ej FROM ejercicios";
    BlDbRecordSet *cur = mainCompany()->loadQuery ( consultabd );
    if ( cur ) {
        if ( !cur->eof() ) {
            if ( cur->value( "ej" ).toInt() != 0 )
                ejer = cur->value( "ej" ).toInt();
        } // end if
        delete cur;
    } // end if
    ejer++;

    /// Presentamos el dialogo preguntado que ejercicio crear.
    bool ok = false;
    ejer = QInputDialog::getInt ( this, _ ( "Introduzca Ejercicio a Crear" ),
                                      _ ( "Ponga el anyo:" ), ejer, 0, 10000, 1, &ok );

    /// Comprobamos que el ejercicio introducido sea valido.
    if ( !ok ) return;
    if ( ejer < 1000 ) {
        blMsgInfo ( "Ejercicio invalido" );
        return;
    } // end if
    QString query = "SELECT * FROM ejercicios WHERE ejercicio = " + QString::number ( ejer );
    cur = mainCompany()->loadQuery ( query );
    if ( cur ) {
        if ( cur->numregistros() > 0 ) {
            delete cur;
            blMsgInfo ( _ ( "Ejercicios ya contemplado" ) );
            return;
        } // end if
    } // end if


    /// Creamos el ejercicio.
    for ( int x = 0; x <= 12; x++ ) {
        try {
            QString consultabd = "INSERT INTO ejercicios (ejercicio, periodo, bloqueado) VALUES('" + QString::number ( ejer ) + "', '" + QString::number ( x ) + "', 'f')";
            mainCompany()->begin();
            mainCompany() ->runQuery ( consultabd );
            mainCompany()->commit();
        } catch ( ... ) {
            blMsgInfo ( "Error con la base de datos" );
            mainCompany()->rollback();
        } // end try
    } // end for

    /// Presentamos
    inicializa();

    
}
Ejemplo n.º 11
0
/**
\param emp
\param parent
**/
BalanceView::BalanceView ( BcCompany *emp, QWidget *parent, int )
    : BcForm ( emp, parent )
{
    BL_FUNC_DEBUG
    setupUi ( this );

    setAttribute(Qt::WA_DeleteOnClose);
    setTitleName ( _ ( "Balance" ) );
    /// Establezco cual es la tabla en la que basarse para el sistema de permisos.
    setDbTableName ( "asiento" );

    /// Para imprimir usaremos la plantilla balance
    setTemplateName("balance");

    mui_cuentaInicial->setMainCompany ( emp );
    /// Arreglamos la cuenta.
    mui_cuentaInicial->setLabel ( _ ( "Cuenta inicial:" ) );
    mui_cuentaInicial->setTableName ( "cuenta" );
    mui_cuentaInicial->setFieldId("idcuenta");
    mui_cuentaInicial->m_valores["descripcion"] = "";
    mui_cuentaInicial->m_valores["codigo"] = "";
    mui_cuentaInicial->hideLabel();

    mui_cuentaFinal->setMainCompany ( emp );
    /// Arreglamos la cuenta.
    mui_cuentaFinal->setLabel ( _ ( "Cuenta final:" ) );
    mui_cuentaFinal->setTableName ( "cuenta" );
    mui_cuentaFinal->setFieldId("idcuenta");
    mui_cuentaFinal->m_valores["descripcion"] = "";
    mui_cuentaFinal->m_valores["codigo"] = "";
    mui_cuentaFinal->hideLabel();

    QString query = "SELECT DISTINCT length(codigo) AS orden FROM cuenta ORDER BY orden DESC";
    BlDbRecordSet *niveles = NULL;
    /// Primero, averiguaremos la cantidad de ramas iniciales que nacen de la ra&iacute;z
    /// (tantas como n&uacute;mero de cuentas de nivel 2) y las vamos creando.
    niveles = mainCompany() ->loadQuery ( query );

    while ( !niveles->eof() ) {
        mui_nivel->insertItem ( 0, niveles->value("orden") );
        niveles->nextRecord();
    } // end while
    delete niveles;

    /// Iniciamos los componentes de la fecha para que al principio aparezcan
    /// como el a&ntilde;o inicial.
    QString cadena;
    cadena.sprintf ( "%2.2d/%2.2d/%4.4d", 1, 1, QDate::currentDate().year() );
    mui_fechaInicial->setText ( cadena );
    cadena.sprintf ( "%2.2d/%2.2d/%4.4d", 31, 12, QDate::currentDate().year() );
    mui_fechaFinal->setText ( cadena );

    mainCompany() ->insertWindow ( windowTitle(), this );
    /// Llamamos a los scripts
    blScript(this);
}
Ejemplo n.º 12
0
void TicketQToolButton::click()
{
    BL_FUNC_DEBUG
    QString txt = "";

    /// Copiamos el archivo.
    QString archivo = g_confpr->value( CONF_DIR_OPENREPORTS ) + "etiquetas.rml";
    QString archivod = g_confpr->value( CONF_DIR_USER ) + "etiquetas.rml";
    blCopyFile(archivo,archivod);

    BlFile file;
    file.setFileName ( archivod );
    file.open ( QIODevice::ReadOnly );
    QTextStream stream ( &file );
    QString buff = stream.readAll();
    file.close();
    QString fitxersortidatxt = "";


    /// Hacemos el texto de las etiquetas.
    m_companyact = m_albaranProveedorView->mainCompany();

    QString query = "SELECT * , ceil(cantlalbaranp) AS cantidad FROM lalbaranp NATURAL LEFT JOIN articulo WHERE idalbaranp = " + m_albaranProveedorView->dbValue ( "idalbaranp" );
    BlDbRecordSet *cur = m_companyact->loadQuery ( query );
    while ( !cur->eof() ) {
        int i = 0;
        while ( i < cur->value( "cantidad" ).toInt() ) {
            fitxersortidatxt += "<blockTable><tr><td>";
            fitxersortidatxt += "<para><font face=\"Helvetica\" size=\"4\">" + cur->value( "nomarticulo" ) + "</font></para>\n";
            fitxersortidatxt += "<barCode code=\"code128\" height=\"0.60cm\">" + cur->value( "codigocompletoarticulo" ) + "</barCode>\n";
            fitxersortidatxt += "<para><font face=\"Helvetica\" size=\"4\">" + cur->value( "codigocompletoarticulo" ) + " - (" + m_albaranProveedorView->dbValue ( "fechaalbaranp" ).left ( 10 ) + ")</font></para>\n";
//     if (cur->numcampo("lotelalbaranp") != -1)
//             fitxersortidatxt += "<para><font face=\"Helvetica\" size=\"4\"> Lote: " + cur->value("lotelalbaranp") + "</font></para>\n";
            fitxersortidatxt += "</td></tr></blockTable>";
            fitxersortidatxt += "<spacer length=\"0.5cm\"/>\n";
            i++;
        } // end while
        cur->nextRecord();
    } // end while
    delete cur;


    buff.replace ( "[story]", fitxersortidatxt );

    if ( file.open ( QIODevice::WriteOnly ) ) {
        QTextStream stream ( &file );
        stream << buff;
        file.close();
    } // end if
    blCreateAndLoadPDF ( "etiquetas" );



    
}
int BtTicket_insertarArticuloNL_Post ( BtTicket *tick )
{
    BL_FUNC_DEBUG
    QString query = "SELECT * FROM tc_articulo_alias WHERE aliastc_articulo_tallacolor = '" + ( ( BtCompany * ) tick->mainCompany() )->valorBtInput() + "'";
    BlDbRecordSet *cur = tick->mainCompany() ->loadQuery ( query );
    if ( !cur->eof() ) {
        tick->insertarArticulo ( cur->value( "idarticulo" ), BlFixed ( "1" ) );
    } // end if
    delete cur;
    
    return 0;
}
Ejemplo n.º 14
0
/**
\param val
**/
void BfBuscarArticulo::setcodigocompletoarticulo ( QString val )
{
    BL_FUNC_DEBUG
    QString SQLQuery = "SELECT * FROM articulo WHERE codigocompletoarticulo=$1";
    BlDbRecordSet *cur = mainCompany() ->load ( SQLQuery, val );
    if ( !cur->eof() ) {
        setId ( cur->value( "idarticulo" ) );
    } else {
        setId ( "" );
    } // end if
    delete cur;
    
}
int BfBuscarReferencia_on_mui_abrirtodo_clicked_Post ( BfBuscarReferencia *ref )
{
    QString SQLQuery = "SELECT * FROM facturap WHERE reffacturap = '" + ref->mui_referencia->text() + "'";
    BlDbRecordSet *cur = ref->mainCompany() ->loadQuery ( SQLQuery );
    while ( !cur->eof() ) {
        FacturaProveedorView * bud = new FacturaProveedorView ( ( BfCompany * ) ref->mainCompany(), NULL );
        ref->mainCompany() ->m_pWorkspace->addSubWindow ( bud );
        bud->load ( cur->value( "idfacturap" ) );
        bud->show();
        cur->nextRecord();
    } // end while
    delete cur;
    return 0;
}
Ejemplo n.º 16
0
void DuplicarAsientoView::lostFocus()
{
    BL_FUNC_DEBUG
    QString ainicial = aoinicial->text();
    QString query = "SELECT * FROM asiento WHERE ordenasiento = " + ainicial;
    mainCompany() ->begin();
    BlDbRecordSet *cur = mainCompany() ->loadQuery ( query, "hola" );
    mainCompany() ->commit();
    if ( !cur->eof() ) {
        foinicial->setText ( cur->value( "fecha" ).left ( 10 ) );
    } // end if
    delete cur;
    
}
Ejemplo n.º 17
0
/* Calcula el PVP IVA incluido a partir del precio sin IVA.
*/
void IVAincluidoView::on_mui_calcula_iva_inc_clicked()
{
    QString SQlQuery = "SELECT * FROM tasa_iva WHERE idtipo_iva = '" + m_trab->mui_idtipo_iva->id() + "' ORDER BY fechatasa_iva DESC LIMIT 1";
    BlDbRecordSet *cur = m_trab->mainCompany() ->loadQuery ( SQlQuery );

    if ( !cur->eof() ) {
        mui_pvpivaincarticulo->setValue( m_trab->mui_pvparticulo->value() * (1 + (cur->value( "porcentasa_iva" ).toDouble() / 100)) );
    } else {
        mui_pvpivaincarticulo->setValue( m_trab->mui_pvparticulo->value() );
    } // end if

    delete cur;

}
Ejemplo n.º 18
0
void Compra::on_mui_codigoarticulo_returnPressed()
{

    QString texto = "<TABLE width=\"100%\">";
    QString tventas = "0";
    QString tcompras = "0";
    QString bgcolor = "#FFFFFF";
    texto += "<TR bgcolor=\"#BBBBBB\">";
    texto += "<TD width=\"100\">Color</TD>";
    texto += "<TD width=\"100\">Talla</TD>";
    texto += "<TD width=\"100\">Comprados</TD>";
    texto += "<TD width=\"100\">Vendidos</TD>";
    texto += "<TD width=\"100\">Stock</TD>";
    texto += "</TR>";
    QString query = "SELECT * FROM articulo LEFT JOIN tc_articulo_alias AS t3 ON articulo.idarticulo = t3.idarticulo  LEFT JOIN tc_talla AS t1 ON t3.idtc_talla = t1.idtc_talla LEFT JOIN tc_color AS t2 ON t3.idtc_color = t2.idtc_color WHERE t3.aliastc_articulo_tallacolor = '" + mui_codigoarticulo->text() + "' OR articulo.codigocompletoarticulo = '" + mui_codigoarticulo->text() + "' ORDER BY nomtc_color, nomtc_talla";
    BlDbRecordSet *cur = mainCompany()->loadQuery ( query );
    while ( ! cur->eof() ) {
        QString query1 = "SELECT SUM(cantlalbaranp) AS suma FROM lalbaranp WHERE idarticulo=" + cur->value( "idarticulo" ) + "  AND idtc_talla=" + cur->value( "idtc_talla" ) + " AND idtc_color=" + cur->value( "idtc_color" );
        QString query2 = "SELECT SUM(cantlalbaran) AS suma FROM lalbaran WHERE idarticulo=" + cur->value( "idarticulo" ) + "  AND idtc_talla=" + cur->value( "idtc_talla" ) + " AND idtc_color=" + cur->value( "idtc_color" );
        BlDbRecordSet *cur1 = mainCompany()->loadQuery ( query1 );
        BlDbRecordSet *cur2 = mainCompany()->loadQuery ( query2 );
        if ( !cur2->eof() ) {
            tventas = cur2->value( "suma" );
        } // end if
        if ( !cur1->eof() ) {
            tcompras = cur1->value( "suma" );
        } // end if

        if ( !cur1->eof() ) {
            texto += "<TR bgcolor=\"" + bgcolor + "\">";
            texto += "<TD>" + cur->value( "nomtc_color" ) + "</TD>";
            texto += "<TD>" + cur->value( "nomtc_talla" ) + "</TD>";
            texto += "<TD align=\"right\">" + tcompras + "</TD>";
            texto += "<TD align=\"right\">" + tventas + "</TD>";
            texto += "<TD align=\"right\">" + QString::number ( tcompras.toFloat() - tventas.toFloat() ) + "</TD>";
            texto += "</TR>";
        } // end if
        delete cur1;
        delete cur2;
        cur->nextRecord();
        if ( bgcolor == "#FFFFFF" ) {
            bgcolor = "#CCCCFF";
        } else {
            bgcolor =  "#FFFFFF";
        } // end if
    } // end while
    delete cur;
    mui_subform->setText ( texto );
}
Ejemplo n.º 19
0
void SubForm_Proveedor::nuevoProveedor( )
{
    BL_FUNC_DEBUG
  
    BlSubForm * sub = ( BlSubForm * ) parent();

    QString idarticleold="0";
    BlDbRecordSet *cur = sub->mainCompany() ->loadQuery ( "SELECT max(idproveedor) as id FROM proveedor " );
    if ( !cur->eof() ) {
	idarticleold = cur->value("id");
    } // end if
    delete cur;
    
    ProveedorView *artlist = new ProveedorView ( ( BfCompany * ) sub->mainCompany(), 0 );
	/// Desabilitamos el borrado automatico de la clase y lo realizaremos manualmente para que no se llame al isHidden sobre un objeto eliminado.
    artlist->setAttribute ( Qt::WA_DeleteOnClose, false );
    /// Esto es convertir un QWidget en un sistema modal de dialogo.
    sub->setEnabled ( false );
    artlist->show();
    while ( !artlist->isHidden() )
        g_theApp->processEvents();
    sub->setEnabled ( true );
    delete artlist;
	
    cur = sub->mainCompany() ->loadQuery ( "SELECT * FROM proveedor ORDER BY idproveedor DESC LIMIT 1" );
    if ( !cur->eof() ) {
		if (cur->value("idproveedor") != idarticleold) {
		  sub->lineaact()->setDbValue ( "idproveedor", cur->value("idproveedor") );
		  sub->lineaact()->setDbValue ( "cifproveedor", cur->value( "cifproveedor" ) );
		  sub->m_registrolinea->setDbValue ( "nomproveedor", cur->value( "nomproveedor" ) );
		} // end if
    } // end if
    delete cur;

    
}
Ejemplo n.º 20
0
/**
\param as
\return
**/
int BcAsientoForm_guardaAsiento1_post ( BcAsientoForm *asientoForm )
{
    BL_FUNC_DEBUG
    
    
    BcCompany *companyact = asientoForm->company();
    QString cuentas = "";
    QString query = "SELECT valor FROM configuracion WHERE nombre = 'RegistroEmitida' OR nombre = 'RegistroSoportada'";
    BlDbRecordSet *curvalor = companyact->loadQuery ( query );
    while ( !curvalor->eof() ) {
        /// Preparamos una expresi&oacute;n regular para usar en la consulta.
        cuentas += curvalor->value( "valor" ) + "%|";
        curvalor->nextRecord();
    } // end while
    delete curvalor;
    /// Le quitamos el &uacute;ltimo '|' que nos sobra.
    cuentas.truncate ( cuentas.length() - 1 );

    /// Recorremos la tabla en busca de entradas de factura no introducidas y las
    /// preguntamos antes de cerrar nada.
    QString SQLQuery = "SELECT bcontrapartidaborr(idborrador) AS contra FROM borrador LEFT JOIN cuenta ON borrador.idcuenta = cuenta.idcuenta WHERE idasiento = " + asientoForm->dbValue ( "idasiento" ) + " AND codigo SIMILAR TO '" + companyact->sanearCadena ( cuentas.toAscii().constData() ) + "' GROUP BY contra";

    BlDbRecordSet *cursborr = companyact->loadQuery ( SQLQuery );
    while ( !cursborr->eof() ) {
        int idborrador = cursborr->value( "contra" ).toInt();
        RegistroIvaView *reg = new RegistroIvaView ( companyact, 0 );
        reg->inicializa1 ( idborrador );
        companyact->pWorkspace() ->addSubWindow ( reg );
        reg->show();
        cursborr->nextRecord();
    } // end while
    delete cursborr;
    
    
    return 0;
}
Ejemplo n.º 21
0
/**
\param idcuenta
**/
void BcAsientoInteligenteView::cifCuenta ( int idcuenta )
{
    BL_FUNC_DEBUG
    QString query;
    query.sprintf ( "SELECT * FROM cuenta WHERE idcuenta = %d", idcuenta );
    mainCompany() ->begin();
    BlDbRecordSet *cur = mainCompany() ->loadQuery ( query, "cursor" );
    mainCompany() ->commit();
    if ( !cur->eof() ) {
        variablesapunte[VAR_APUNT_CIFCUENTA][1] = cur->value( "cifent_cuenta" );
    } else {
        variablesapunte[VAR_APUNT_CIFCUENTA][1] = "";
    } // end if
    delete cur;
    
}
Ejemplo n.º 22
0
/**
\param val
**/
void BfBuscarFamilia::setcodigocompletofamilia ( QString val )
{
    BL_FUNC_DEBUG

    QString SQLQuery = "SELECT * FROM familia WHERE codigocompletofamilia='" + val + "'";
    BlDbRecordSet *cur = mainCompany() ->loadQuery ( SQLQuery );

    if ( !cur->eof() ) {
        setId ( cur->value( "idfamilia" ) );
    } else {
        setId ( "" );
    } // end if

    delete cur;
    
}
Ejemplo n.º 23
0
void Devolucion::on_mui_ref_returnPressed()
{
    if ( m_ticket )  {
        delete m_ticket;
        m_ticket = NULL;
    } // end if

    QString query1 = "SELECT * FROM albaran WHERE refalbaran = '" + mui_ref->text() + "'";

    BlDbRecordSet *curs = mainCompany()->loadQuery ( query1 );
    if ( !curs->eof() ) {
        m_ticket = new BtTicket ( mainCompany(), NULL );
        m_ticket->load ( curs->value( "idalbaran" ) );
    }
    delete curs;
    m_totalin = "";
    pintar();
}
Ejemplo n.º 24
0
void AlbaranProveedorView::on_mui_verpedidosproveedor_clicked()
{
    BL_FUNC_DEBUG
    QString query = "SELECT * FROM pedidoproveedor WHERE refpedidoproveedor = '" + dbValue ( "refalbaranp" ) + "'";
    BlDbRecordSet *cur = mainCompany() ->loadQuery ( query );
    while ( !cur->eof() ) {
	/// Como estamos en un plugin buscamos nuevas formas de creacion de objetos.
	int resur = g_plugins->run ( "SNewPedidoProveedorView", ( BfCompany * ) mainCompany() );
	if ( !resur ) {
	      blMsgInfo (_( "no se pudo crear instancia de pedido proveedor" ));
	      return;
	} // end if
	PedidoProveedorView * pedpro = ( PedidoProveedorView * ) g_plugParams;
        pedpro->load ( cur->value( "idpedidoproveedor" ) );
        mainCompany() ->m_pWorkspace->addSubWindow ( pedpro );
        pedpro->show();
        cur->nextRecord();
    } // end while
    delete cur;
    
}
Ejemplo n.º 25
0
void generarVencimientos (FacturaView *art) {
			BlDbRecordSet *cur1 = art->mainCompany()->loadQuery("SELECT totalfactura FROM factura WHERE idfactura = " + art->dbValue("idfactura"));
			blMsgInfo( _("El total de la factura es :") + cur1->value("totalfactura"));
			BlFixed contado("0.00");

			BlDbRecordSet *cur = art->mainCompany()->loadQuery("SELECT * FROM vencimientocliente WHERE idcliente = " + art->dbValue("idcliente"));
			while (!cur->eof())  {
				QString query = "SELECT ffactura + " + cur->value("diasvencimientocliente") + " AS fechav, totalfactura / 100 * "+cur->value("porcentajevencimientocliente")+" AS porcent FROM factura WHERE idfactura = " + art->dbValue("idfactura");
				if (cur->isLastRecord()) {
					query = "SELECT ffactura + " + cur->value("diasvencimientocliente") + " AS fechav, totalfactura - "+ contado.toQString('.') +" AS porcent FROM factura WHERE idfactura = " + art->dbValue("idfactura");
				} //end if
				BlDbRecordSet *cur2 = art->mainCompany()->loadQuery(query);
				/// REALIZAMOS EL QUERY
				query = "INSERT INTO vencimientoc (idfactura, fechavencimientoc, cantvencimientoc, idforma_pago, refvencimientoc, idcliente) VALUES ("+art->dbValue("idfactura")+",'"+cur2->value("fechav")+"',"+cur2->value("porcent")+","+cur->value("idforma_pago")+",'"+art->dbValue("reffactura")+"',"+art->dbValue("idcliente")+")";
				contado = contado + BlFixed(cur2->value("porcent"));
				art->mainCompany()->runQuery(query);
				delete cur2;
				cur->nextRecord();
			} // end while
			delete cur;
			delete cur1;
}
Ejemplo n.º 26
0
/**
\param emp
**/
BalancePrintView::BalancePrintView ( BfCompany *emp, QWidget *parent, int ) : BfForm(emp, parent)
//        : QDialog ( 0 ), BlMainCompanyPointer ( emp )
{
    BL_FUNC_DEBUG
    setupUi ( this );
    mui_cuentaInicial->setMainCompany ( emp );
    mui_cuentaInicial->setLabel ( _ ( "Cuenta inicial:" ) );
    mui_cuentaInicial->setTableName ( "cuenta" );
    mui_cuentaInicial->setFieldId("idcuenta");
    mui_cuentaInicial->m_valores["descripcion"] = "";
    mui_cuentaInicial->m_valores["codigo"] = "";
    mui_cuentaInicial->hideLabel();

    mui_cuentaFinal->setMainCompany ( emp );
    mui_cuentaFinal->setLabel ( _ ( "Cuenta final:" ) );
    mui_cuentaFinal->setTableName ( "cuenta" );
    mui_cuentaFinal->setFieldId("idcuenta");
    mui_cuentaFinal->m_valores["descripcion"] = "";
    mui_cuentaFinal->m_valores["codigo"] = "";
    mui_cuentaFinal->hideLabel();

    /// Buscamos los diferentes niveles que existen seg&uacute;n existan en la tabla
    /// de cuentas.
    mainCompany() ->begin();
    QString query = "SELECT nivel(codigo) FROM cuenta GROUP BY nivel ORDER BY nivel";
    BlDbRecordSet *niveles = mainCompany() ->loadQuery ( query, "Niveles" );
    int i = 0;
    while ( !niveles->eof() ) {
        /// Inicializamos la tabla de nivel.
        mui_nivel->insertItem ( i, niveles->value( "nivel" ) );
        niveles->nextRecord();
        i++;
    } // end while
    mainCompany() ->commit();
    delete niveles;
    
}
Ejemplo n.º 27
0
/**
\param val
**/
void BlSearchWidget::setId ( QString val, bool cargarvalores )
{
    BL_FUNC_DEBUG
    BlDebug::blDebug ( "BlSearchWidget::setId", 0, val );
    mdb_id = val;

    if ( m_tabla == "" || !cargarvalores) {
        return;
    } // end if

    if ( val == "" ) {
        m_inputBusqueda->setText ( "" );
        m_textBusqueda->setText ( "" );
        mdb_id = "";
        /// Inicializamos los valores de vuelta a ""
        QMapIterator<QString, QString> i ( m_valores );
        while ( i.hasNext() ) {
            i.next();
            m_valores.insert ( i.key(), "" );
        } // end while
    } else {
        QString SQLQuery("");
	SQLQuery = "SELECT * FROM " + m_tabla + " WHERE " + m_campoid + "= $1";
        BlDbRecordSet *cur = mainCompany() ->load( SQLQuery, mdb_id );
        if ( !cur->eof() ) {
            /// Inicializamos los valores de vuelta a ""
            QMapIterator<QString, QString> i ( m_valores );
            while ( i.hasNext() ) {
                i.next();
                m_valores.insert ( i.key(), cur->value( i.key() ) );
            } // end while
        } // end if
        delete cur;
    } // end if
    pinta();
    
}
Ejemplo n.º 28
0
/**
\param cuentas
\param ramas
**/
void BcPlanContableArbol::SintetizarRamas ( BlDbRecordSet **cuentas, tiporama **ramas )
{
    BL_FUNC_DEBUG

    tiporama *guia, *rama;
    tipohoja *hoja;
    int nivel;
    BlDbRecordSet *ptrcuentas = *cuentas;
    nivel = atoi ( ptrcuentas->value( "nivel" ).toAscii().constData() );
    ptrcuentas->nextRecord();
    guia = NULL;
    while ( !ptrcuentas->eof() && ( atoi ( ptrcuentas->value( "nivel" ).toAscii().constData() ) > nivel ) ) {
        /// Reservamos un huequecito de memoria para almacenar los datos de la rama.
        rama = new tiporama;
        if ( !guia ) {
            *ramas = guia = rama;
        } else {
            guia->sgte = rama;
            guia = guia->sgte;
        } // end if
        hoja = new tipohoja; /// Idem para una hojita.
        hoja->idcuenta = atoi ( ptrcuentas->value( "idcuenta" ).toAscii().constData() );
        hoja->codigo = ptrcuentas->value( "codigo" );
        hoja->descripcion = ptrcuentas->value( "descripcion" );
        hoja->saldoant = hoja->debe = hoja->haber = hoja->saldo = hoja->debeej = hoja->haberej = hoja->saldoej = BlFixed ( "0.00" );
        hoja->numapuntes = 0;
        hoja->ramas = NULL;
        guia->hoja = hoja;
        guia->sgte = NULL;
        /// Pero a&uacute;n puede haber m&aacute;s ramas que crezcan, en tal caso habr&aacute;
        /// que sintetizarlas
        SintetizarRamas ( &ptrcuentas, & ( hoja->ramas ) );
    } // end while

    
}
Ejemplo n.º 29
0
void DuplicarAsientoView::on_mui_aceptar_clicked()
{
    BL_FUNC_DEBUG
    QString asientoi = aoinicial->text();
    QString asientof = aofinal->text();
    QString query1, query2;
    QString textidasiento;

    QString idasiento;
    QString ordenasiento;

    QString textordeninicial;
    QDate fedinicial = blNormalizeDate ( fdinicial->text() );

    query1 = "SELECT * FROM asiento WHERE ordenasiento >= " + asientoi + " AND ordenasiento <= " + asientof + " AND EXTRACT (YEAR FROM fecha) = EXTRACT (YEAR FROM '" + fedinicial.toString ( "dd/MM/yyyy" ) + "'::date)";
    BlDbRecordSet *curasiento = mainCompany() ->loadQuery ( query1 );
    while ( !curasiento->eof() ) {

        query1 = "INSERT INTO asiento (descripcion, fecha, comentariosasiento) VALUES('" + curasiento->value( "descripcion" ) + "','" + fedinicial.toString ( "dd/MM/yyyy" ) + "','" + curasiento->value( "comentariosasiento" ) + "')";
        mainCompany() ->runQuery ( query1 );


        query1 = "SELECT * FROM asiento  ORDER BY idasiento DESC LIMIT 1";
        BlDbRecordSet *cursaux = mainCompany() ->loadQuery ( query1 );
        if ( !cursaux->eof() ) {
            idasiento = cursaux->value( "idasiento" );
            ordenasiento = cursaux->value( "ordenasiento" );
        } // end if
        delete cursaux;



        query2 = "SELECT * FROM borrador WHERE idasiento = " + curasiento->value( "idasiento" );
        BlDbRecordSet *curborrador = mainCompany() ->loadQuery ( query2 );

        while ( !curborrador->eof() ) {
            QString textiddiario = curborrador->value( "iddiario" );
            if ( textiddiario == "" ) {
                textiddiario = "NULL";
            } // end if
            QString textfecha = curborrador->value( "fecha" );
            textfecha = fedinicial.toString ( "dd/MM/yyyy" );
            QString textconceptocontable = curborrador->value( "conceptocontable" );
            QString textidcuenta = curborrador->value( "idcuenta" );
            if ( textidcuenta == "" ) {
                textidcuenta = "NULL";
            } // end if
            QString textdescripcion = curborrador->value( "descripcion" );
            QString textdebe = curborrador->value( "debe" );
            QString texthaber = curborrador->value( "haber" );
            QString textcontrapartida = curborrador->value( "contrapartida" );
            if ( textcontrapartida == "" ) {
                textcontrapartida = "NULL";
            } // end if
            QString textorden = curborrador->value( "ordenborrador" );
            if ( textorden == "" ) {
                textorden = "0";
            } // end if
            query2 = "INSERT INTO borrador (ordenborrador, idasiento, iddiario, fecha, conceptocontable, idcuenta, descripcion, debe, haber, contrapartida) VALUES (" + textorden + "," + idasiento + "," + textiddiario + ",'" + textfecha + "','" + textconceptocontable + "'," + textidcuenta + ",'" + textdescripcion + "'," + textdebe + "," + texthaber + "," + textcontrapartida + ")";
            mainCompany() ->runQuery ( query2 );
            curborrador->nextRecord();
        } // end while
        delete curborrador;
        query2 = "SELECT cierraasiento(" + idasiento + ")";
        BlDbRecordSet *cur = mainCompany() ->loadQuery ( query2 );
        delete cur;
        curasiento->nextRecord();
    } // end while
    delete curasiento;
    mainCompany() ->commit();
    done ( 1 );
    
}
Ejemplo n.º 30
0
/**
\param menu El menu sobre el que pintar la opcion
**/
void EQToolButtonMail::trataMenu ( QAction *action )
{
    BL_FUNC_DEBUG

    /// Buscamos ficheros que tengan el nombre de la tabla
    QDir dir ( g_confpr->value( CONF_DIR_OPENREPORTS ) );
    dir.setFilter ( QDir::Files | QDir::NoSymLinks );
    dir.setSorting ( QDir::Size | QDir::Reversed );
    /// Hacemos un filtrado de busqueda
    QStringList filters;
    filters << "*" + m_BlForm->tableName() + "*.rml";
    dir.setNameFilters ( filters );


    QFileInfoList list = dir.entryInfoList();
    for ( int i = 0; i < list.size(); ++i ) {
        QFileInfo fileInfo = list.at ( i );

        if ( action->objectName() == "em_" + fileInfo.fileName() ) {

            if ( m_BlForm->generateRML ( fileInfo.fileName() ) ) {

                QString email = "";
                QString id = m_BlForm->dbValue ( "id" + m_BlForm->tableName() );
                QString num = m_BlForm->dbValue ( "num" + m_BlForm->tableName() );
                QString ref = m_BlForm->dbValue ( "ref" + m_BlForm->tableName() );
                QString idcliente = m_BlForm->dbValue ( "idcliente" );
                if ( !idcliente.isEmpty() ) {
                    QString query = "SELECT mailcliente from cliente WHERE idcliente=" + idcliente;
                    BlDbRecordSet *curs = ( ( BlForm * ) parent() )->mainCompany()->loadQuery ( query );
                    if ( !curs->eof() ) {
                        email = curs->value( "mailcliente" );
                    } // end if
                    delete curs;
                } // end if

                QString idproveedor = m_BlForm->dbValue ( "idproveedor" );
                if ( !idproveedor.isEmpty() ) {
                    QString query = "SELECT emailproveedor from proveedor WHERE idproveedor=" + idproveedor;
                    BlDbRecordSet *curs = ( ( BlForm * ) parent() )->mainCompany()->loadQuery ( query );
                    if ( !curs->eof() ) {
                        email = curs->value( "emailproveedor" );
                    } // end if
                    delete curs;
                } // end if

                QString doc = fileInfo.fileName().left ( fileInfo.fileName().size() - 4 );
                blCreatePDF ( doc );

                QString oldName = g_confpr->value( CONF_DIR_USER ) + doc + ".pdf";
                QString newName = g_confpr->value( CONF_DIR_USER ) +   doc  + num + ".pdf";
                blMoveFile(oldName,newName);
#ifdef Q_OS_WIN32
		/// En windows las rutas relativas no funcionan bien con algunos sistemas de e-mail
		/// Por eso pasamos una posible ruta relativa a absoluta.
		newName = QDir(g_confpr->value( CONF_DIR_USER )).absolutePath() + "/"+ doc + num + ".pdf";
#endif
		QString subject = doc + num;
		QString body = "Adjunto remito " + doc + " numero " + num + ". Con referencia " + ref + "\n Atentamente\n";
		QString bcc= "";

		blSendEmail( email, bcc, subject , body, newName );


            } // end if
        } // end if
    }
    
}