Ver Mensaje Individual
  #3  
Antiguo 19-10-2016
Belen12 Belen12 is offline
Miembro
NULL
 
Registrado: may 2016
Posts: 29
Reputación: 0
Belen12 Va por buen camino
gracias

Cita:
Empezado por ecfisa Ver Mensaje
Hola Belen12.

Creo entender que tenes problemas para que en el CheckListBox se muestren (queden marcados) los puestos que a cada empleado ya le han sido asignados. Y, si interpreté bién, podrías hacer algo así:
Código Delphi [-]
// Cargar puestos en el CheckListBox
procedure TForm1.FormCreate( Sender: TObject );
begin
  //...

  // Cargar puestos en el CheckListBox
  qyPuestos.Open;
  while not qyPuestos.Eof do
  begin
    CheckListBox1.Items.AddObject(
      qyPuestos.FieldByName( 'NOMBREPUESTO' ).AsString,
      TObject( qyPuestos.FieldByName( 'IDPUESTO').AsInteger ) );
    qyPuestos.Next;
  end;

  //...
  tEmpleados.AfterScroll := tEmpleadosAfterScroll;
  tEmpleados.First;
end;

// Mostrar puestos del empleado actual en CheckListBox
procedure TForm1.tEmpleadosAfterScroll( DataSet: TDataSet );
var
  i: Integer;
begin
  for i := 0 to CheckListBox1.Count - 1 do
    CheckListBox1.Checked[i] := False;

  qyTmp.Close;
  qyTmp.SQL.Clear;
  qyTmp.SQL.Add( 'SELECT P.NOMBREPUESTO' );
  qyTmp.SQL.Add( 'FROM EMPLEADO E');
  qyTmp.SQL.Add( 'INNER JOIN ASIGNADO A ON E.IDEMPLEADO = A.IDEMPLEADO' );
  qyTmp.SQL.Add( 'INNER JOIN PUESTO P ON A.IDPUESTO = P.IDPUESTO' );
  qyTmp.SQL.Add( 'WHERE E.IDEMPLEADO = :PID' );
  qyTmp.ParamByName( 'PID' ).AsInteger :=
    tEmpleados.FieldByName( 'IDEMPLEADO' ).AsInteger;
  qyTmp.Open;

  while not qyTmp.Eof do
  begin
    i := CheckListBox1.Items.IndexOf( qyTmp.FieldByName( 'NOMBREPUESTO' ).AsString );
    if i <> -1 then
      CheckListBox1.Checked[i] := True;
    qyTmp.Next;
  end;
end;
...

procedure TForm1.FormDestroy(Sender: TObject);
begin
  tEmpleados.AfterScroll := nil;
end;

Saludos
Hola gracias por responder e probado el codigo y me perdi un poco.
Código Delphi [-]
procedure TForm1.tEmpleadosAfterScroll( DataSet: TDataSet );
var
  i: Integer;
begin
  for i := 0 to CheckListBox1.Count - 1 do
    CheckListBox1.Checked[i] := False;

  qyTmp.Close; 
  qyTmp.SQL.Clear;
//..
//..
aqui utilizas 2 query no es asi ? uno nuevo tengo que crear para realizar estas consultas por lo que logre entender dime si es que me equivoco.
Partiendo de esto creo un nuevo query lo llame "empleado" y realizo todo los pasos pero al intentar abrir el formulario ya sea del boton nuevo o del boton modificar me dice "SQL Query is Empty" gracias por tomarte el tiempo en ayudarme
Responder Con Cita