este es el codigo que estoy utilizando
bueno solo la parte que manda a guardar
Código:
procedure Tsilfpe0001.TB_SalvarClick(Sender: TObject);
begin
if sistema_lw_trigger_pedi = 'UPDATE' then
begin
if sil_pedi_lw_cambio_datos = 'S' then
begin
sistema_lw_ejecuta_bitacora := 'TRUE';
if sistema_lw_ejecuta_bitacora = 'TRUE' then
begin
Application.CreateForm(Tsilfpe0001_Bitacora_Cambios_Pedidos,silfpe0001_Bitacora_Cambios_Pedidos);
silfpe0001_Bitacora_Cambios_Pedidos.ShowModal;
end;
sistema_lw_ejecuta_bitacora := 'FALSE';
end;
end;
sistema_lw_ejecuta_bitacora := 'FALSE';
if T_PEDI.State <> dsBrowse then
COMPLEMENTA_PEDIDO();
{Stores.SIL_P_COMPLEMENTA_PEDIDO(T_PEDI.FieldByName('pedi_serie').Value, T_PEDI.FieldByName('pedi_numero').Value, lw_error);
if not(VarIsNull(lw_error)) and (lw_error <> '') then
begin
Application.MessageBox(PChar(lw_error), 'SIL Light', mb_ok+mb_iconinformation);
Abort;
end;}
sil_pedi_lw_usuario_autoriza := T_PEDI.FieldValues['pedi_usuario_autoriza'];
sil_pedi_lw_clave_autoriza := T_PEDI.FieldValues['pedi_clave_autoriza'];
sil_pedi_lw_pedi_estatus := T_PEDI.FieldValues['pedi_estatus'];
sil_pedi_lw_ante_estatus := sil_pedi_lw_pedi_estatus;
sil_pedi_lw_prod_original := NVL(T_PEDI.FieldValues['pedi_prod_clave'],'');
sil_pedi_lw_cant_fec_actual := FPE0001_CANTIDAD_FECHA(gw_plan_clave,T_PEDI.FieldValues['pedi_fecha_suministro'],T_PEDI.FieldValues['pedi_serie'],T_PEDI.FieldValues['pedi_numero'],'A');
sil_pedi_lw_cant_fec_ante := FPE0001_CANTIDAD_FECHA(gw_plan_clave,T_PEDI.FieldValues['pedi_fecha_suministro'],T_PEDI.FieldValues['pedi_serie'],T_PEDI.FieldValues['pedi_numero'],'O');
//Aquie es la parte donde mandoa guardar la tabla maestra T_PEDI y los detalles T_BOPE Y T_DEPE
if T_PEDI.State in [dsInsert, dsEdit] then
T_PEDI.Post;
if T_BOPE.State in [dsInsert, dsEdit] then
T_BOPE.Post;
if T_DEPE.State in [dsInsert, dsEdit] then
T_DEPE.Post;
PPE0001_INSERTA_PROG_PEDIDO; //inserta programacion de pedidos
Q_Consulta.Close;
Q_Consulta.SQL.Clear;
Q_Consulta.SQL.Add(' UPDATE sil_programas_pedido ');
Q_Consulta.SQL.Add(' SET prpe_pedi_serie = :gw_pedi_serie, ');
Q_Consulta.SQL.Add(' prpe_pedi_numero = :gw_pedi_numero ');
Q_Consulta.SQL.Add(' WHERE prpe_pedi_serie = ''X'' ');
Q_Consulta.SQL.Add(' AND prpe_pedi_numero = 0 ');
Q_Consulta.ParamByName('gw_pedi_serie').Value := DBE_Pedi_Serie.Text;
Q_Consulta.ParamByName('gw_pedi_numero').Value := DBE_Pedi_Numero.Text;
Q_Consulta.ExecSQL;
A_PRPE := NIL; //limpia el arreglo
end;
//aqui es donde surge el problema porque en lugar de hacer directamente el boforepost de PEDI hace el de DEPE
procedure Tsilfpe0001.T_PEDIBeforePost(DataSet: TDataSet);
begin
if T_PEDI.State = dsInsert then
begin
PEDI_PRE_INSERT();
end
else if T_PEDI.State = dsEdit then
begin
PEDI_PRE_UPDATE();
end;
end;
procedure Tsilfpe0001.T_BOPEBeforePost(DataSet: TDataSet);
begin
if not(T_BOPE.FieldByName('bope_pedi_serie').IsNull) and not(T_BOPE.FieldByName('bope_pedi_numero').IsNull) then
begin
if T_BOPE.State = dsInsert then
begin
T_BOPE_PRE_INSERT;
silfse0000.Trigger_Insert(DataSet);
sistema_lw_trigger_bope := 'INSERT';
end;
if T_BOPE.State = dsEdit then
begin
T_BOPE_PRE_UPDATE;
silfse0000.Trigger_Update(DataSet);
sistema_lw_trigger_bope := 'UPDATE';
end;
end
else
begin
T_BOPE.Cancel;
Abort;
end;
end;
procedure Tsilfpe0001.T_DEPEBeforePost(DataSet: TDataSet);
begin
if not(T_DEPE.FieldByName('depe_pedi_serie').IsNull) and not(T_DEPE.FieldByName('depe_pedi_numero').IsNull) then
begin
if T_DEPE.State = dsInsert then
begin
T_DEPE_PRE_INSERT;
silfse0000.Trigger_Insert(DataSet)
end;
end
else
begin
T_DEPE.Cancel;
Abort;
end;
end;
solo una cosa mas las tablas de BOPE y DEPE tienen un procedimiento Oncalc
gracias Lepe por el apoyo