
Ayuda con Runtime Delphi
Publicado por Ema (5 intervenciones) el 22/02/2014 18:09:05
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..
//ESTE ME CREA EL TABSHEET EN TIEMPO DE EJECUCION---
tabtmp:= Ttabsheet.Create(paginarecibo);
tabtmp.PageControl := paginarecibo;
tabtmp.Name:= 'tabSheet' + inttostr(paginarecibo.PageCount);
tabTmp.Caption := 'INCIDENTE Nº' + codegcia1.Text;
paginarecibo.ActivePage:=tabtmp;
with tabtmp do
begin
listapersonal:= Tdblookuplistbox.Create(self);
listapersonal.SetBounds(182, 56, 179, 212);
listapersonal.Parent:= tabtmp;
listapersonal.ListSource:= datapers;
listapersonal.ListField:= 'nom_p';
listapersonal.KeyField:='id_p';
listapersonal2:=Tlistbox.Create(self);
listapersonal2.SetBounds(384,88,179,180);
listapersonal2.Parent:= tabtmp;
jefdot:= Tcombobox.Create(self);
jefdot.SetBounds(384,56,179,21);
jefdot.Parent:= tabtmp;
labelid:= Tlabel.Create(self);
labelid.Caption:= inttostr(idinci);
labelid.SetBounds(584,13,31,13);
labelid.Parent:= tabtmp;
with save do
begin
save:= tbitbtn.Create(self);
save.SetBounds(182,274,179,25);
save.Parent:= tabtmp;
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;
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;
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;
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;
end;
with finemer do
begin
finemer:=tbitbtn.Create(self);
finemer.SetBounds(507,387,75,25);
finemer.Parent:=tabtmp;
finemer.Caption:='FIN';
finemer.OnClick:= fin;
end;
o:= 30;
with desp_1 do
begin
sql.Clear;
sql.Text:= 'select * from m_t order by m_n asc ';
open;
end;
SetLength(botones, datadesp1.DataSet.RecordCount);
for i:= low(botones) to high(botones) do
begin
num:=datadesp1.DataSet.FieldValues['m_n'];
botones[i]:= tbutton.Create(tabtmp);
botones[i].SetBounds(9,i*30,136,25);
botones[i].parent:= tabtmp;
botones[i].caption:= (datadesp1.dataset.FieldByName('m_n').AsString);
datadesp1.DataSet.Next;
end;
end;
//ESTE ME CREA EL FORM A DONDE SE CREAN TAMBIEN LOS DBEDITS PARA MODIFICAR//
procedure Tdespacho.modindatos;
var
cap1,cap2,cap3,cap4,cap5,cap6: Tlabel;
botmod: Tbitbtn;
begin
formmodifin := TForm.Create(tabtmp);
Formmodifin.SetBounds(201,90,497,257);
Formmodifin.Parent:= self;
Formmodifin.Caption:='MODIFICAR DATOS INCIDENTE Nº'+ inttostr(idinci);
formmodifin.Enabled:=true;
Formmodifin.FormStyle:= fsStayOnTop;
formmodifin.BorderStyle:=Bsdialog;
formmodifin.Show;
botmod:= Tbitbtn.Create(tabtmp);
botmod.SetBounds(120,168,130,25);
botmod.Caption:='MODIFICAR INCIDENTE';
botmod.Parent:= formmodifin;
botmod.OnClick:=modif;
botcancelmod:=Tbitbtn.Create(tabtmp);
botcancelmod.SetBounds(256,168,130,25);
botcancelmod.Parent:=formmodifin;
botcancelmod.Caption:='CANCELAR';
botcancelmod.OnClick:=cancelador;
idinci:= strtoint(labelid.Caption);
with queriinci do
begin
sql.Clear;
sql.Text:='select * from salida_emer where id_inci=:idinci';
parameters[0].Value:=idinci;
open;
end;
datainci.DataSet.FieldValues['dir_emer1'];
cedit1:=Tdbedit.Create(tabtmp);
cedit1.SetBounds(120,8,327,21);
cedit1.Parent:= formmodifin;
cedit1.DataSource:=datainci;
cedit1.DataField:='dir_emer1';
cedit2:=Tdbedit.Create(tabtmp);
cedit2.SetBounds(120,38,327,21);
cedit2.Parent:= formmodifin;
cedit2.DataSource:=datainci;
cedit2.DataField:='dir_emer2';
cedit3:=Tdbedit.Create(tabtmp);
cedit3.SetBounds(120,68,327,21);
cedit3.Parent:= formmodifin;
cedit3.DataSource:=datainci;
cedit3.DataField:='dir_emer3';
cedit4:=Tdbedit.Create(tabtmp);
cedit4.SetBounds(120,98,327,21);
cedit4.Parent:= formmodifin;
cedit4.DataSource:=datainci;
cedit4.DataField:='nom_emer';
cedit5:=Tdbedit.Create(tabtmp);
cedit5.SetBounds(120,128,327,21);
cedit5.Parent:= formmodifin;
cedit5.DataSource:=datainci;
cedit5.DataField:='tel';
end;
// El problema como comente se da que cuando hay multiples tabsheets creados dinamicamente, me toma el ultimo registro en el form, y no los que corresponden a cada uno.
Gracias por la ayuda de antemano!
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..
//ESTE ME CREA EL TABSHEET EN TIEMPO DE EJECUCION---
tabtmp:= Ttabsheet.Create(paginarecibo);
tabtmp.PageControl := paginarecibo;
tabtmp.Name:= 'tabSheet' + inttostr(paginarecibo.PageCount);
tabTmp.Caption := 'INCIDENTE Nº' + codegcia1.Text;
paginarecibo.ActivePage:=tabtmp;
with tabtmp do
begin
listapersonal:= Tdblookuplistbox.Create(self);
listapersonal.SetBounds(182, 56, 179, 212);
listapersonal.Parent:= tabtmp;
listapersonal.ListSource:= datapers;
listapersonal.ListField:= 'nom_p';
listapersonal.KeyField:='id_p';
listapersonal2:=Tlistbox.Create(self);
listapersonal2.SetBounds(384,88,179,180);
listapersonal2.Parent:= tabtmp;
jefdot:= Tcombobox.Create(self);
jefdot.SetBounds(384,56,179,21);
jefdot.Parent:= tabtmp;
labelid:= Tlabel.Create(self);
labelid.Caption:= inttostr(idinci);
labelid.SetBounds(584,13,31,13);
labelid.Parent:= tabtmp;
with save do
begin
save:= tbitbtn.Create(self);
save.SetBounds(182,274,179,25);
save.Parent:= tabtmp;
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;
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;
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;
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;
end;
with finemer do
begin
finemer:=tbitbtn.Create(self);
finemer.SetBounds(507,387,75,25);
finemer.Parent:=tabtmp;
finemer.Caption:='FIN';
finemer.OnClick:= fin;
end;
o:= 30;
with desp_1 do
begin
sql.Clear;
sql.Text:= 'select * from m_t order by m_n asc ';
open;
end;
SetLength(botones, datadesp1.DataSet.RecordCount);
for i:= low(botones) to high(botones) do
begin
num:=datadesp1.DataSet.FieldValues['m_n'];
botones[i]:= tbutton.Create(tabtmp);
botones[i].SetBounds(9,i*30,136,25);
botones[i].parent:= tabtmp;
botones[i].caption:= (datadesp1.dataset.FieldByName('m_n').AsString);
datadesp1.DataSet.Next;
end;
end;
//ESTE ME CREA EL FORM A DONDE SE CREAN TAMBIEN LOS DBEDITS PARA MODIFICAR//
procedure Tdespacho.modindatos;
var
cap1,cap2,cap3,cap4,cap5,cap6: Tlabel;
botmod: Tbitbtn;
begin
formmodifin := TForm.Create(tabtmp);
Formmodifin.SetBounds(201,90,497,257);
Formmodifin.Parent:= self;
Formmodifin.Caption:='MODIFICAR DATOS INCIDENTE Nº'+ inttostr(idinci);
formmodifin.Enabled:=true;
Formmodifin.FormStyle:= fsStayOnTop;
formmodifin.BorderStyle:=Bsdialog;
formmodifin.Show;
botmod:= Tbitbtn.Create(tabtmp);
botmod.SetBounds(120,168,130,25);
botmod.Caption:='MODIFICAR INCIDENTE';
botmod.Parent:= formmodifin;
botmod.OnClick:=modif;
botcancelmod:=Tbitbtn.Create(tabtmp);
botcancelmod.SetBounds(256,168,130,25);
botcancelmod.Parent:=formmodifin;
botcancelmod.Caption:='CANCELAR';
botcancelmod.OnClick:=cancelador;
idinci:= strtoint(labelid.Caption);
with queriinci do
begin
sql.Clear;
sql.Text:='select * from salida_emer where id_inci=:idinci';
parameters[0].Value:=idinci;
open;
end;
datainci.DataSet.FieldValues['dir_emer1'];
cedit1:=Tdbedit.Create(tabtmp);
cedit1.SetBounds(120,8,327,21);
cedit1.Parent:= formmodifin;
cedit1.DataSource:=datainci;
cedit1.DataField:='dir_emer1';
cedit2:=Tdbedit.Create(tabtmp);
cedit2.SetBounds(120,38,327,21);
cedit2.Parent:= formmodifin;
cedit2.DataSource:=datainci;
cedit2.DataField:='dir_emer2';
cedit3:=Tdbedit.Create(tabtmp);
cedit3.SetBounds(120,68,327,21);
cedit3.Parent:= formmodifin;
cedit3.DataSource:=datainci;
cedit3.DataField:='dir_emer3';
cedit4:=Tdbedit.Create(tabtmp);
cedit4.SetBounds(120,98,327,21);
cedit4.Parent:= formmodifin;
cedit4.DataSource:=datainci;
cedit4.DataField:='nom_emer';
cedit5:=Tdbedit.Create(tabtmp);
cedit5.SetBounds(120,128,327,21);
cedit5.Parent:= formmodifin;
cedit5.DataSource:=datainci;
cedit5.DataField:='tel';
end;
// El problema como comente se da que cuando hay multiples tabsheets creados dinamicamente, me toma el ultimo registro en el form, y no los que corresponden a cada uno.
Gracias por la ayuda de antemano!
Valora esta pregunta


0