Ver Mensaje Individual
  #3  
Antiguo 03-08-2011
Avatar de oscarac
[oscarac] oscarac is offline
Miembro Premium
 
Registrado: sep 2006
Ubicación: Lima - Perú
Posts: 2.010
Reputación: 20
oscarac Va por buen camino
Post

mmmm me parece algo complicado tu codigo.. tienes muchas cosas que son redundantes

por ejemplo
Código Delphi [-]
 
dmacceso.cdsClientes.Active := True;  // esto es igual que open
dmacceso.cdsClientes.Last; // no es necesatio cuando insertas pq se va al final
dmacceso.cdsClientes.Open;
dmacceso.cdsClientes.Insert;

yo particularmente hago esto

Boton Modificar del form donde muestro los datos
Código Delphi [-]
 
procedure TfrmCatalogoAnexo.btnModificaClick(Sender: TObject);
begin
  btn_opcion := 1;
  qryAnexos.Edit;
  frmCatalogoAnexod := TfrmCatalogoAnexod.Create(nil);
  frmCatalogoAnexod.Show
end;

y en el create del formulario invocado hago mas o menos esto
Código Delphi [-]
 
 
procedure TfrmCatalogoAnexod.FormCreate(Sender: TObject);
var i: Integer;
begin
  if frmCatalogoAnexo.btn_opcion =1 then
    begin
      edtCodigo.Enabled := False;
      ComboBox1.ItemIndex := StrToInt(frmCatalogoAnexo.qryAnexosTipoAnexo.Value) - 1;
    end;
  if frmCatalogoAnexo.btn_opcion >= 1 then
        edtTipoAnexoExit(sender);
  if frmCatalogoAnexo.btn_opcion = 2 then
    begin
      btnGrabar.Caption := 'Eliminar';
      for i := 0 to (Self.ComponentCount - 1) do  begin
        if (Self.Components[i] is TDBEdit) or (Self.Components[i] is TComboBox) then begin
          TEdit(Self.Components[i]).Enabled := False;
        end;
      end;
    end;
end;

y en el boton de grabar hago mas o menos esto

Código Delphi [-]
 
procedure TfrmCatalogoAnexod.btnGrabarClick(Sender: TObject);
begin
  if frmCatalogoAnexo.btn_opcion <> 2 then
    begin
      frmCatalogoAnexo.qryAnexosTipoAnexo.AsString := FormatFillStringNumber (IntToStr(ComboBox1.ItemIndex + 1),2);
      frmCatalogoAnexo.qryAnexosEmpresa.AsString := dmGlobal.g_CodigoEmpresa;
      frmCatalogoAnexo.qryAnexos.Post;
    end;
  if frmCatalogoAnexo.btn_opcion = 2 then
    frmCatalogoAnexo.qryAnexos.Delete;
  Close;
  frmCatalogoAnexo.dbgAnexo.SetFocus;
end;
__________________
Dulce Regalo que Satanas manda para mi.....
Responder Con Cita