Ver Mensaje Individual
  #1  
Antiguo 22-09-2008
foxito foxito is offline
Miembro
 
Registrado: abr 2008
Ubicación: Orizaba, Ver
Posts: 32
Reputación: 0
foxito Va por buen camino
Thumbs down Tengo Duda de como usar ZTTable para MySQL

Hola lista

Tengo duda de como usar ZTTable cuando en un Formulario tengo un ZTQuery y ZTTable, el QUERY lo uso para mostrar en rejillas mi consulta y ZTTable para grabar en mi tabla, pero cuando busco en ZTQuery tambien busco en ZTTable para que ambos esten actualizados.

¿Mi pregunta es la siguiente con un solo objeto puedo hacer las 2 cosas?

Porque tengo Query y Table porque en el QUERY HAGO QUE MUESTRE EN BASE A UN CAMPO OTRA COSA. POR EJEMPLO

AQUI ESTA COMO CONSULTO
Código SQL [-]
size="1">SELECT Nombre,
CASE WHEN Nivel = 1 THEN 'Grupo' ELSE 'SubGrupo' 
END AS Nivel2,Id
FROM Lineas

AQUI COMO BUSCO

Código Delphi [-]
procedure TFrmLineas.bOkClick(Sender: TObject);
begin
  begin
    if EdFind.Text = '' then
    begin
      ShowMessage('Debe escribir un texto para realizar la búsqueda');
      EdFind.SetFocus;
    end
    else
    begin
      if qLineas.Locate('NOMBRE', EdFind.Text, [loCaseInsensitive, loPartialKey]) then
      begin
        tLineas.Locate('NOMBRE', EdFind.Text, [loCaseInsensitive, loPartialKey]);
        DBGrid.SetFocus;
      end
      else
        ShowMessage('No se encuentra ninguna linea con esa descripción');
        EdFind.Text := '';
        EdFind.Enabled := False;
        bOk.Enabled := False;
        bNew.Enabled := True;
        bEdit.Enabled := True;
        bDelete.Enabled := True;
      end;
  end;
end;

AQUI GRABO

Código Delphi [-]
procedure TFrmLineas.bAceptarClick(Sender: TObject);
var
cDes : String;
begin
  if GestionNuevo then
    begin
      tLineas.Close;
      tLineas.Open;
      tLineas.Insert;
      //ZTLineasID.AsInteger := Id;
      tLineasNombre.AsString := EdLinea.Text;
      tLineasNivel.AsInteger := rdNivel.ItemIndex + 1;
      tLineas.Post;
      cDes := EdLinea.Text;
      RefrescarLineas(cDes);
      CerrarEdicion;
    end
  else  { not GestionNuevo -> Editando existente }
  begin
    cDes := EdLinea.Text;
    tLineas.Edit;
    tLineasNOMBRE.AsString := EdLinea.Text;
    tLineasNivel.AsInteger := RdNivel.ItemIndex;
    tLineas.Post;
    RefrescarLineas(cDes);
    CerrarEdicion;
  end;
end;
Responder Con Cita