Ver Mensaje Individual
  #4  
Antiguo 23-05-2007
Avatar de vtdeleon
vtdeleon vtdeleon is offline
Miembro
 
Registrado: abr 2004
Ubicación: RD & USA
Posts: 3.236
Reputación: 26
vtdeleon Va por buen camino
Saludos

Un pequeño ahorro en codigo
Código Delphi [-]
procedure TfrmUsers.btnGuardarClick(Sender: TObject);
var
    sContra : String;
    i: integer;
begin
    btnGuardar.SetFocus;
 
    if VerificaDatos then
      begin
        with frmDatos.MDOUsers    do
          begin
            
            sContra := frmDatos.Encripta(edClave.Text);
            if cbCategoria.text = 'Instalador' then
              i := 1
            else if cbCategoria.text = 'Supervisor' then
              i := 2
            else
              i := 3;
 
            if sModo = 'Insertar' then
              begin
                Insert;
                //Nos ahorramos todas esas lineas repetidas
              end
            else
              begin
                Edit;
                FieldByName('Codigo').Value := iClave; //Clave Primaria
              end;
              FieldByName('Login').Value := Trim(edLogin.text);
              FieldByName('Clave').Value := sContra;
              FieldByName('Categoria').Value := i;
              FieldByName('Nombre').Value := Trim( edNombre.text);
              FieldByName('Paterno').Value := Trim(edPaterno.text);
              FieldByName('Materno').Value := Trim(edMaterno.text);
              FieldByName('Domicilio').Value := Trim(edDomicilio.text);
              FieldByName('Colonia').Value := Trim(edColonia.text);
              FieldByName('CP').Value := Trim(edCP.text);
              FieldByName('Ciudad').Value := Trim(edCiudad.text);
              FieldByName('Estado').Value := Trim(edEstado.text);
              FieldByName('Telefono').Value := Trim(edTelefono.text);
              Post;
            if sModo = 'Insertar' then
              begin
                iClave := sContra;
                lstUsuarios.Items.Add(edLogin.Text)
              end

          end;
      end;
      btnCancelarClick(Sender);
end;
__________________
Van Troi De León
(Not) Guía, Code vB:=Delphi-SQL, ¿Cómo?
Viajar en el tiempo no es teóricamente posible, pues si lo fuera, ya estarían aqui contándonos al respecto!
Responder Con Cita