Ver Mensaje Individual
  #16  
Antiguo 05-11-2008
Elite237 Elite237 is offline
Miembro
 
Registrado: jul 2007
Posts: 162
Reputación: 17
Elite237 Va por buen camino
Ya lo modifique, pero me manda el siguiente error:
Código Delphi [-]
Project Project1.exe raised exception class EInOutError with message 'I/O error 6'

De todas maneras te muestro como quedo el codigo en el boton:
Código Delphi [-]
procedure TForm1.BitBtnGenerarClick(Sender: TObject);
var
  X: Integer;
  Valor: Integer;
  Evalua: string;
begin
   //Obtiene la clave del combo evaluacion
  Evalua := copy(cmbEvaluacion.Text, 0, Pos('-', cmbEvaluacion.Text) - 1);
  //OBTIENE LA VERSION
  Query1.Close;
  Query1.SQL.Text := Format('select det_version from det_evaluacion ' +
    'where det_eval = ''%s''', [Evalua]);
  Query1.Open;
  lblVersion.Caption := Query1.FieldByName('det_version').AsString;
  //OBTIENE LA SECCION
  Query1.Close;
  Query1.SQL.Text := Format('select * from det_evaluacion ' +
    'where det_eval = ''%s'' and det_tipo = 0 and ' +
    'det_valor = 0 order by det_clave', [Evalua]);
  Query1.Open;
  // sgEvaluacion debe tener solo la línea de encabezados, esto es: RowCount = 1
  X := 1;
  while not Query1.Eof do
  begin
    sgEvaluacion.RowCount := X + 1; // Agregamos línea para sección
    // Agregamos la clave y la descripción de la sección
    sgEvaluacion.Cells[0, X] := Query1.FieldByName('det_pregunta').AsString;
    sgEvaluacion.Cells[1, X] := Query1.FieldByName('det_pregunta').AsString;
    // Buscamos las preguntas
    Query2.Close;
    Query2.SQL.Text := Format('select * from det_evaluacion ' + 
      'where det_eval = ''%s'' and det_tipo = 1 and ' +
      'det_clave like ''%s.%%'' and det_valor = 0 ' +
      'order by det_clave', [Evalua, Query1.FieldByName('det_clave').AsString]);
    Query2.Open;
    while not Eof do
    begin
      Inc(X);
      sgEvaluacion.RowCount := X + 1; // Agregamos otra línea para pregunta
      sgEvaluacion.Cells[0, X] := Query2.FieldByName('det_clave').AsString;
       sgEvaluacion.Cells[1, X] := Query2.FieldByName('det_pregunta').AsString;
      // Buscamos las respuestas de la pregunta actual
      Query3.Close;
      Query3.SQL.Text := Format('select det_valor from det_evaluacion ' +
        'where det_eval = ''%s'' and det_clave like ''%s.%%'' and ' +
        'det_tipo = 2 order by det_valor asc', [Evalua,
        Query1.FieldByName('det_clave').AsString]);
      Query3.Open;
      while not Query3.Eof do
      begin
        Valor := Query3.FieldByName('det_valor').AsInteger;
        sgEvaluacion.Cells[Valor + 1, X] := IntToStr(Valor);
        Query3.Next;
      end;
      sgEvaluacion.Cells[7, X] := 'Resultado';
      Query2.Next
    end;
    Inc(X); // Incrementamos X para obtener la siguiente sección
    Query1.next
  end
end;
Responder Con Cita