Hola Rudi, Buenas tardes, tu consejo no me funciono, lo estoy haciendo de esta manera, pues no me funciona, estoy seguro que estoy fallando, a ver:
Código Delphi
[-]procedure TFFactura.BitBtn1Click(Sender: TObject);
begin
if MessageDlg('¿Está seguro que desea Guardar?', mtConfirmation,
[mbYes, mbNo], 0) = mrYes then
begin
if ZPedido.Fields[19].IsNull then <--Si el campo no tiene datos entonces:
begin
if ZFactura.State in [dsedit,dsinsert] then
begin
ZRegPed.SQL.Clear;
ZRegPed.SQL.Add('UPDATE reg_pedidos SET oc_no_sigef_2='+Quotedstr('Sí')+', oc_no_sigef='+Quotedstr(DBEdit1.Text)+'');
ZRegPed.SQL.Add(' WHERE no = '+Quotedstr(DBEdit15.Text)+' ');
ShowMessage(ZRegPed.SQL.Text);
ZRegPed.ExecSQL;
ZFactura.Post;
ZFactura.Insert;
end else begin
if not ZPedido.fields[19].IsNull then <--si el campo tiene datos entoces:
begin
if ZFactura.State in [dsedit,dsinsert] then
begin
ZRegPed.SQL.Clear;
ZRegPed.SQL.Add('UPDATE reg_pedidos SET oc_no_sigef1='+Quotedstr(DBEdit1.Text)+'');
ZRegPed.SQL.Add(' WHERE no = '+Quotedstr(DBEdit15.Text)+' ');
ShowMessage(ZRegPed.SQL.Text);
ZRegPed.ExecSQL;
ZFactura.Post;
ZFactura.Insert;
end else begin
if not ZPedido.Fields[42].IsNull then <--SI el campo anterior tiene datos entonces:
begin
if ZFactura.State in [dsedit,dsinsert] then
begin
ZRegPed.SQL.Clear;
ZRegPed.SQL.Add('UPDATE reg_pedidos SET oc_no_sigef2='+Quotedstr(DBEdit1.Text)+'');
ZRegPed.SQL.Add(' WHERE no = '+Quotedstr(DBEdit15.Text)+' ');
ShowMessage(ZRegPed.SQL.Text);
ZRegPed.ExecSQL;
ZFactura.Post;
ZFactura.Insert;
end;
end else
showmessage('No hago nada, no estoy editando');
end;
end;
end;
end;
end;
end;
se que hay una mejor manera de hacerlo, ojala me puedan ayudar
.
Saludos.