File: FLInventario.cpp

package info (click to toggle)
facturalux 0.4-7
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,040 kB
  • ctags: 1,359
  • sloc: ansic: 15,260; cpp: 12,761; sh: 10,520; perl: 2,023; makefile: 692; xml: 194
file content (196 lines) | stat: -rw-r--r-- 4,935 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/***************************************************************************
                          FLInventario.cpp  -  description
                             -------------------
    begin                : Fri Oct 14 2002
    copyright            : (C) 2002 by Luis Toro Teijeiro
    email                : linuxx@gulic.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "FLInventario.h"

FLInventario::FLInventario ()
{
}

FLInventario::~FLInventario ()
{
if (cursor_)
	  disconnect (cursor_, SIGNAL (newBuffer ()), this, SLOT (newBuffer ()));

}

void
FLInventario::setSender (FLFormDB *sender)
{
   sender_=sender;

   if (!cursor_)
    return;

 connect (cursor_, SIGNAL (newBuffer ()), SLOT (newBuffer ())); 

 QWidget * main = sender_->mainWidget();

  if (!main)
  return;

QObject *obj = main ->child ("selecalmacen");
 obj = main->child ("selecalmacen");
  if (obj)
    {
      connect (((FLTableDB *) obj)->cursor (), SIGNAL (cursorUpdated ()), SLOT (calcularTotal ()));
    }

}

/*void
FLInventario::newBuffer ()
{
  if (!sender_)
	return;
  QWidget * main = sender_->mainWidget();

  if (!main)
    return;

  QObject *obj = main ->child ("numero");

  if (obj)
	((QLabel *) obj)->setText (cursor_->valueBuffer ("idinventario").toString ());


    {
        obj = main->child ("codempresa");
        if (obj)
            ((FLFieldDB *) obj)->setEnabled(false);


         if (cursor_->modeAccess () == FLSqlCursor::INSERT)
	    {
	        FLSqlCursor *c = new FLSqlCursor ("flempresas");
	        QString s;

	        if (c)
		    {
		        c->select ("empdefecto='t'");
		        if (c->next ())
			    {
			        obj = main->child ("codempresa");
			        if (obj)
				    {
				        s = c->valueBuffer ("codempresa").toString ();
				        ((QLineEdit *) ((FLFieldDB *) obj)->editor ())->setText (s);
				    }
			    }
		        delete c;
		    }

            }
    }





  QWidget * main = sender_->mainWidget(); 

  if (!main)
    return;

  QObject *obj = main->child("selecalmacen");

obj = main->child("codalmacen");
if(obj)
  {
          QTable *table = ((QTable *)obj);

          FLSqlCursor *inventario = new FLSqlCursor("flstocks");


          for(int i = 0; i<table->numRows(); i ++)
          {
                    inventario->setMainFilter("codalmacen="+table->text(i,0));
                    inventario->refresh();

                    QObject *obj2 = main->child("lineasinventario");
                    FLSqlCursor *lineainventario = ((FLTableDB *)obj2)->cursor();

                    //Borramos todas las lineas
                    while(lineainventario->next())
                    {
                              lineainventario->del();
                    }

                    //Aadimos las lineas
                    while(inventario->next())
                    {

                              lineainventario->setModeAccess(FLSqlCursor::INSERT);
                              lineainventario->refreshBuffer();


            lineainventario->setValueBuffer("codarticulo",inventario->valueBuffer("codarticulo"));
            lineainventario->setValueBuffer("cantidad",inventario->valueBuffer("cantidad"));
            lineainventario->setValueBuffer("total",inventario->valueBuffer("total"));

                      //     Insertar comando para finalizar proceso de insertar registro.
                              lineainventario->commitBuffer();

                    }
          }

  }

} */

void
FLInventario::imprimirInventario ()
{
  FLSqlQuery *q = FLManager::query ("inventario");

  

  FLReportViewer *rW = new FLReportViewer ((QWidget *)sender_);

  rW->setReportTemplate ("inventario");
  rW->setReportData (q);
  rW->renderReport ();
  rW->setFocus ();
  rW->show ();
}

/*void
FLInventario::calcularTotal ()
{
  if (!sender_)
	return;

  QWidget * main = sender_->mainWidget();

  if (!main)
    return;

  QObject *obj = main->child ("lineasinventario");

  if (obj)
	{
	  double res = 0;

	  QSqlQuery query ("SELECT SUM(total) FROM fllineasinventario WHERE idinventario=" + cursor_->valueBuffer ("idinventario").toString () + ";");
	  if (query.next ())
		res = query.value (0).toDouble ();
	  obj = main->child ("total");
	  if (obj)
		((QLabel *) obj)->setText (QString::number (res));
	}
} */