busquedaseriefactura.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Tomeu Borras Riera                              *
00003  *   tborras@conetxia.com                                                  *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 #include "qcombobox2.h"
00022 
00023 #include "busquedaseriefactura.h"
00024 #include "company.h"
00025 #include "funcaux.h"
00026 
00027 
00035 BusquedaSerieFactura::BusquedaSerieFactura(QWidget *parent)
00036         : QComboBox2(parent) {
00037     _depura("BusquedaSerieFactura::BusquedaSerieFactura", 0);
00038     m_cursorcombo = NULL;
00039     m_codigoserie_factura = "";
00040     connect(this, SIGNAL(activated(int)), this, SLOT(m_activated(int)));
00041     _depura("END BusquedaSerieFactura::BusquedaSerieFactura", 0);
00042 }
00043 
00044 
00049 BusquedaSerieFactura::~BusquedaSerieFactura() {
00050     _depura("BusquedaSerieFactura::~BusquedaSerieFactura", 0);
00051     if (m_cursorcombo != NULL)
00052         delete m_cursorcombo;
00053     _depura("END BusquedaSerieFactura::~BusquedaSerieFactura", 0);
00054 }
00055 
00056 
00065 void BusquedaSerieFactura::setcodigoserie_factura(QString codigo) {
00066     _depura("BusquedaSerieFactura::setcodigoserie_factura", 0);
00067     if (m_cursorcombo != NULL)
00068         delete m_cursorcombo;
00069     m_cursorcombo = empresaBase()->cargacursor("SELECT * FROM serie_factura");
00070     if(!m_cursorcombo) return;
00071     int i = 0;
00072     int i1 = 0;
00073     int i2 = 0;
00074     clear();
00075     addItem("--");
00076     while (!m_cursorcombo->eof()) {
00077         i ++;
00078         if (m_cursorcombo->valor("codigoserie_factura") == m_codigoserie_factura)
00079             i2 = i;
00080         if (m_cursorcombo->valor("codigoserie_factura") == codigo)
00081             i1 = i;
00082         addItem(m_cursorcombo->valor("codigoserie_factura") + ".-" + m_cursorcombo->valor("descserie_factura"));
00083         m_cursorcombo->siguienteregistro();
00084     } // end if
00085     if (i1 != 0) {
00086         setCurrentIndex(i1);
00087     } else {
00088            setCurrentIndex(i2);
00089     } // end if
00090     _depura("END BusquedaSerieFactura::setcodigoserie_factura", 0);
00091 }
00092 
00093 
00095 
00098 void BusquedaSerieFactura::setValorCampo(QString codigo) {
00099     _depura("BusquedaSerieFactura::setValorCampo", 0);
00100         setcodigoserie_factura(codigo);
00101     _depura("END BusquedaSerieFactura::setValorCampo", 0);
00102 }
00103 
00104 
00106 
00109 void BusquedaSerieFactura::m_activated(int index) {
00110     _depura("BusquedaSerieFactura::m_activated", 0);
00111         if (index > 0) {
00112             emit(valueChanged(m_cursorcombo->valor("codigoserie_factura", index - 1)));
00113         } else {
00114             emit(valueChanged(""));
00115         } // end if
00116     _depura("END BusquedaSerieFactura::m_activated", 0);
00117 }
00118 
00119 
00121 
00124 QString BusquedaSerieFactura::codigoserie_factura() {
00125     _depura("BusquedaSerieFactura::codigoserie_factura", 0);
00126         int index = currentIndex();
00127         if (index > 0) {
00128             return(m_cursorcombo->valor("codigoserie_factura", index - 1));
00129         } else {
00130             return "";
00131         } // end if
00132     _depura("END BusquedaSerieFactura::codigoserie_factura", 0);
00133 }
00134 
00135 
00137 
00140 QString BusquedaSerieFactura::valorCampo() {
00141     _depura("BusquedaSerieFactura::valorCampo", 0);
00142         return codigoserie_factura();
00143     _depura("END BusquedaSerieFactura::valorCampo", 0);
00144 }
00145 
00146 
00148 
00152 void BusquedaSerieFactura::setEmpresaBase(Company *comp) {
00153     _depura("BusquedaSerieFactura::setEmpresaBase", 0);
00154         PEmpresaBase::setEmpresaBase(comp);
00155         cursor2 *cur = empresaBase()->cargacursor("SELECT * FROM configuracion WHERE nombre ='SerieFacturaDefecto'");
00156         if (!cur) return;
00157         if (!cur->eof()) {
00158                 m_codigoserie_factura = cur->valor("valor");
00159         } // end if
00160         delete cur;
00161     _depura("END BusquedaSerieFactura::setEmpresaBase", 0);
00162 }
00163 

Generated on Sat Dec 15 00:01:12 2007 for BulmaGes by  doxygen 1.5.1