
Tabsheets dinamicos ayuda!
Publicado por ema (5 intervenciones) el 01/03/2014 20:02:23
Hace un tiempo atras tuve este problema: "Hola, tengo un problema que me lleva loco ya hace rato.
Estoy trabajando en un soft que registra un despacho, y resulta que trabajo con pagecontrol y sus tabsheets dinamicos, funciona asi: se recibe un llamado y cuando se registra un incidente (en el evento on click) se genera una nueva hoja dinamica, que ya esta establecida.. (hasta ahi todo bien) hay un boton que sirve para modificar los datos que ingrese al principio y crea un form tambien dinamico que contiene los dbedits de c/u de los campos de la tabla a modificar.
Cuando yo creo varios incidentes es donde se produce el problema, por que me toma el ultimo registro que cargue al principio, y no los anteriores correspondientes, y el form se crea de forma unica para todos los tabsheets, es ahi donde tengo el problema, he probado hacer los tabsheets en array... etc.. pero no resulta aca le pongo una parte del codigo"
Amablemente un miembro del foro que se llama E.T me salvo las papas.. he aqui el link del hilo por si las dudas le sirve a alguien http://www.lawebdelprogramador.com/foros/Delphi/1423290-Ayuda_con_Runtime_Delphi.html.-
El Problema que estoy teniendo ahora es similar, pero con la diferencia que yo creo unos DBText en tiempo de ejecucion en c/pestaña del pagecontrol, pero el problema es que la query me esta tomando el ultimo dato de la tabla y me los imprime en cada incidente, a todos por igual, cuando deberia hacerlo, leyendo a cada uno de ellos con su id correspondiente... Si alguien me puede ayudar aca les dejo la parte del codigo.. Ya he probado varias opciones, como poner los tabshits en un array en incluso he probado ponerle un tag a los tabsheets.. pero ni asi!
En cuestion aca el codigo!
Desde ya muchas gracias!
Estoy trabajando en un soft que registra un despacho, y resulta que trabajo con pagecontrol y sus tabsheets dinamicos, funciona asi: se recibe un llamado y cuando se registra un incidente (en el evento on click) se genera una nueva hoja dinamica, que ya esta establecida.. (hasta ahi todo bien) hay un boton que sirve para modificar los datos que ingrese al principio y crea un form tambien dinamico que contiene los dbedits de c/u de los campos de la tabla a modificar.
Cuando yo creo varios incidentes es donde se produce el problema, por que me toma el ultimo registro que cargue al principio, y no los anteriores correspondientes, y el form se crea de forma unica para todos los tabsheets, es ahi donde tengo el problema, he probado hacer los tabsheets en array... etc.. pero no resulta aca le pongo una parte del codigo"
Amablemente un miembro del foro que se llama E.T me salvo las papas.. he aqui el link del hilo por si las dudas le sirve a alguien http://www.lawebdelprogramador.com/foros/Delphi/1423290-Ayuda_con_Runtime_Delphi.html.-
El Problema que estoy teniendo ahora es similar, pero con la diferencia que yo creo unos DBText en tiempo de ejecucion en c/pestaña del pagecontrol, pero el problema es que la query me esta tomando el ultimo dato de la tabla y me los imprime en cada incidente, a todos por igual, cuando deberia hacerlo, leyendo a cada uno de ellos con su id correspondiente... Si alguien me puede ayudar aca les dejo la parte del codigo.. Ya he probado varias opciones, como poner los tabshits en un array en incluso he probado ponerle un tag a los tabsheets.. pero ni asi!
En cuestion aca el codigo!
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
//CREADOR DINAMICO DE TODA LA HOJA//
Inc(contador);
tabtmp[contador]:= Ttabsheet.Create(paginarecibo);
with tabtmp[contador] do
tabtmp[contador].PageControl := paginarecibo;
tabtmp[contador].Name:= 'tabSheet' + inttostr(paginarecibo.PageCount);
tabtmp[contador].Caption := 'INCIDENTE Nº' + inttostr(idinci);
tabtmp[contador].Tag := idinci;
paginarecibo.ActivePage:=tabtmp[contador];
with tabtmp[contador] do
begin
listapersonal:= Tdblookuplistbox.Create(self);
listapersonal.SetBounds(182, 56, 179, 212);
listapersonal.Parent:= tabtmp[contador];
listapersonal.ListSource:= datapers;
listapersonal.ListField:= 'nom_p';
listapersonal.KeyField:='id_p';
listapersonal2:=Tlistbox.Create(self);
listapersonal2.SetBounds(384,88,179,180);
listapersonal2.Parent:= tabtmp[contador];
jefdot:= Tcombobox.Create(self);
jefdot.SetBounds(384,56,179,21);
jefdot.Parent:= tabtmp[contador];
labelid:= Tlabel.Create(self);
labelid.Caption:= inttostr(idinci);
labelid.SetBounds(584,13,31,13);
labelid.Parent:= tabtmp[contador];
with save do
begin
save:= tbitbtn.Create(self);
save.SetBounds(182,274,179,25);
save.Parent:= tabtmp[contador];
save.Caption:='AGREGAR A DOTACION';
save.OnClick:= proc1;
end;
with quit do
begin
quit:=Tbitbtn.Create(self);
quit.SetBounds(384,274,179,25);
quit.Parent:= tabtmp[contador];
quit.Caption:='BAJAR DE DOTACION';
quit.OnClick:=proc2;
end;
with modin do
begin
modin:= Tbitbtn.Create(self);
modin.SetBounds(704,296,105,25);
modin.Parent:= tabtmp[contador];
modin.Caption:='MODIFICAR DATOS INCIDENTE';
modin.OnClick:=modindatos;
end;
with labels do
begin
labels:= tlabel.Create(self);
labels.SetBounds(208,13,121,28);
labels.Caption:='DOTACION';
labels.Font.Name:= 'Arial Black' ;
labels.Font.Size:= 15;
labels.Parent:= tabtmp[contador];
end;
with labels1 do
begin
labels1:= tlabel.Create(self);
labels1.SetBounds(381,13,121,28);
labels1.Caption:='JEFE DOTACION';
labels1.Font.Name:= 'Arial Black' ;
labels1.Font.Size:= 15;
labels1.Parent:= tabtmp[contador];
end;
with l1 do
begin
l1:= tlabel.Create(self);
l1.SetBounds(624,53,41,13);
l1.Caption:='REGISTRO INCIDENTE Nº:';
L1.Font.Size:= 10;
l1.Parent:= tabtmp[contador];
end;
with l2 do
begin
l2:= tlabel.Create(self);
l2.SetBounds(624,73,41,13);
l2.Caption:='DIRECCION:';
L2.Font.Size:= 10;
l2.Parent:= tabtmp[contador];
end;
with l3 do
begin
l3:= tlabel.Create(self);
l3.SetBounds(624,93,41,13);
l3.Caption:='ENTRE CALLE 1:';
L3.Font.Size:= 10;
l3.Parent:= tabtmp[contador];
end;
with l4 do
begin
l4:= tlabel.Create(self);
l4.SetBounds(624,113,41,13);
l4.Caption:='ENTRE CALLE 2:';
L4.Font.Size:= 10;
l4.Parent:= tabtmp[contador];
end;
with L5 do
begin
l5:= tlabel.Create(self);
l5.SetBounds(624,133,41,13);
l5.Caption:='NOMBRE LLAMANTE:';
L5.Font.Size:= 10;
l5.Parent:= tabtmp[contador];
end;
with l6 do
begin
l6:= tlabel.Create(self);
l6.SetBounds(624,153,41,13);
l6.Caption:='TELEFONO:';
L6.Font.Size:= 10;
l6.Parent:= tabtmp[contador];
end;
with l7 do
begin
l7:= tlabel.Create(self);
l7.SetBounds(624,173,41,13);
l7.Caption:='TIPO INCIDENTE:';
L7.Font.Size:= 10;
l7.Parent:= tabtmp[contador];
end;
with l8 do
begin
l8:= tlabel.Create(self);
l8.SetBounds(624,192,41,13);
l8.Caption:='CODIGO:';
L8.Font.Size:= 10;
l8.Parent:= tabtmp[contador];
end;
// A PARTIR DE ACA ME EMPIEZA A CREAR LOS TDBTEXT DINAMICOS--> LOS QUE MUESTRAN EL MISMO CONTENIDO EN CADA UNA DE LAS TABSHEETS, CUANDO DEBERIA MOSTRAR EL PROPIO A CADA TABSHEET//
idinci := paginarecibo.Pages[paginarecibo.TabIndex].Tag;
with inci1 do
begin
sql.Clear;
sql.Text:='Select * from salida_emer where id_inci=:idinci ';
parameters[0].Value:=idinci;
open;
end;
with lt1 do
begin
lt1:=tdbtext.Create(self);
lt1.SetBounds(768,59,225,17);
lt1.Parent:= tabtmp[contador];
lt1.DataSource:= dinc;
lt1.DataField:='id_inci';
end;
with lt2 do
begin
LT2:=tdbtext.Create(self);
LT2.SetBounds(768,78,250,17);
LT2.Parent:= tabtmp[contador];
LT2.DataSource:= dinc;
LT2.DataField:='dir_emer1';
end;
with lt3 do
begin
LT3:=tdbtext.Create(self);
LT3.SetBounds(768,97,250,17);
LT3.Parent:= tabtmp[contador];
LT3.DataSource:= dinc;
LT3.DataField:='dir_emer2';
end;
with lt4 do
begin
LT4:=tdbtext.Create(self);
LT4.SetBounds(768,116,250,17);
LT4.Parent:= tabtmp[contador];
LT4.DataSource:= dinc;
LT4.DataField:='dir_emer3';
end;
with lt5 do
begin
LT5:=tdbtext.Create(self);
LT5.SetBounds(768,135,250,17);
LT5.Parent:= tabtmp[contador];
LT5.DataSource:= dinc;
LT5.DataField:='nom_emer';
end;
with lt6 do
begin
LT6:=tdbtext.Create(self);
LT6.SetBounds(768,154,250,17);
LT6.Parent:= tabtmp[contador];
LT6.DataSource:= dinc;
LT6.DataField:='tel';
end;
with lt7 do
begin
LT7:=tdbtext.Create(self);
LT7.SetBounds(768,173,250,17);
LT7.Parent:= tabtmp[contador];
LT7.DataSource:= dinc;
LT7.DataField:='cod_emer';
end;
with lt8 do
begin
LT8:=tdbtext.Create(self);
LT8.SetBounds(768,192,250,17);
LT8.Parent:= tabtmp[contador];
LT8.DataSource:= dinc;
LT8.DataField:='clave_emer';
end;
end;
with finemer do
begin
finemer:=tbitbtn.Create(self);
finemer.SetBounds(507,387,75,25);
finemer.Parent:=tabtmp[contador];
finemer.Caption:='FIN';
finemer.OnClick:= fin;
end;
o:= 30;
Desde ya muchas gracias!
Valora esta pregunta


0