PAGUE 6 MESES
LEVE 12 MESES
GARANTIR DESCONTO

Fórum O que há de errado #220741

17/03/2004

0

Estou utilizando banco de dados Firebird e os componentes DBEXpress. Estouuasndo a triade TSQLDataset+Provider+TClientDataset.
Este codigo tem a função de calcular a media da nota do aluno especificado. Mas infelizmente, quando confirmo, ele retorna nemhuma mensagem, bem como não faz o calculo da media. As notas estão cadastradas na tabela NOTAS, mas não calcula.

Ajudem-me! O que há de errado neste codigo.


procedure TF_ResultFinal.BtOkClick(Sender: TObject);
Var Media,Posicao:Integer;
MediaParcial,Nota1,Nota2,Nota3,Nota4:Real;
begin
Case Radio1.ItemIndex Of
0:Begin
If Db1.KeyValue <= 0 Then
Begin
MessageDlg(´Selecione um Aluno´,MtInformation,[MbOk],0);
Db1.SetFocus;
Exit;
End;

Query1.Close;
Query1.CommandText:=´Select * From TNOTA Where Aluno=:PAluno And Ano=:PAno´;
Query1.Params[0].Asinteger:=Dm_Base.TAlunoCodigo.Value;
Query1.Params[1].AsInteger:=Dm_Base.TEmpresaAno.Value;
Query1.Open;

If Query1.IsEmpty Then
Begin
MessageDlg(´Aluno não possui notas cadastradas para este ano.´,MtInformation,[MbOk],0);
Db1.SetFocus;
Exit;
End;

Progresso1.Max:=Query1.RecordCount;
Progresso1.Position:=0;

Progresso1.Visible:=True;
BtOk.Enabled:=False;
BtFechar.Enabled:=False;
Label2.Visible:=True;

Query1.First;
While Not Query1.Eof Do
Begin
Media:=0;

Progresso1.Position:=Progresso1.Position + 1;

If Query1Nota1.IsNull Then
Begin
Nota1:=0;
End
Else
Begin
Media:=Media + 1;
Nota1:=Query1NOTA1.Value;
End;

If Query1Nota2.IsNull Then
Begin
Nota2:=0;
End
Else
Begin
Media:=Media + 1;
Nota2:=Query1Nota2.Value;
End;

If Query1Nota3.IsNull Then
Begin
Nota3:=0;
End
Else
Begin
Media:=Media + 1;
Nota3:=Query1Nota3.Value;
End;

If Query1Nota4.IsNull Then
Begin
Nota4:=0;
End
Else
Begin
Media:=Media + 1;
Nota4:=Query1Nota4.Value;
End;

Query1.Edit;
If Media <= 0 Then
Begin
End
Else
Query1MediaParcial.Value:=Media/(Nota1 + Nota2 + Nota3 + Nota4);

Query1.ApplyUpdates(0);
Query1.Refresh;

Query1.Next;
End;

Query1.Refresh;

Progresso1.Visible:=False;
BtOk.Enabled:=True;
BtFechar.Enabled:=True;
Label2.Visible:=False;

End;


Rocha1208

Rocha1208

Responder

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar