Fórum Qual é o erro? Vc sabe? #164787

05/06/2003

0

Olá Pessoal! Td bem?!

Estou desenvolvendo um Sistema de Ponto Eletrônico em
Delphi.
O Sistema está pronto, porém há um erro no Sistema.
Qdo o horário q o funcionário entrar for menor q 8h,
grava-se o horário como sendo 8h.
Qdo o funcionário entra entre 8h e 9h, o sistema marca o
horário real.
Qdo o funcionário entra ou sai após as 9h e antes das
18h, pede-se para digitar uma senha e habilita um campo
para comentários, registrando assim o horário de entrada
ou saída e os comentários no BD.
Qdo o funcionário sai entre 18h e 18h15, o sistema
registra o horário real no bd.
Se o funcionário sair após as 18h15, o sistema pede uma
senha e habilita um campo para comentários, gravando o
horário real e os comentários.
O problema é o seguinte.
Se o funcionário entrar antes das 8h, o sistema registra
8h, até aí td certo.
Agora se o funcionário entrar ou sair em uma das outras
condições, juntamente com o horário real é registrado o
horário de 8h.
Eu acho q tem um looping no sistema.
O mais estranho é q o sistema não aceita outra condição
diferente de Hora < 8, como por exemplo Hora < 7.
Se alguém puder me ajudar, dá uma olhadinha no código
das horas, ok?

Agradeço a atenção,




var
Ano,Mes,Dia:Word;
Hora,Min,Sec,MSec:Word;
Confirma: string;


If (Edit2.Text = ´senha101a´) then
begin
Edit1.Text:=´´;
Edit2.Text:=´´;

begin
If (Hora < 8) then
Begin
Label3.Caption:= ´´;
DbHora1.Text:=´´;
DbHora2.Text:=´´;
DbHora3.Text:= ´´;
DbHora4.Text:= ´´;
DbHora5.Text:= ´´;
DbHora6.Text:= ´´;
DbHora7.Text:= ´´;
DbHora8.Text:= ´´;
DbHora9.Text:= ´´;
DbHora10.Text:= ´´;
DbHora11.Text:= ´´;
DbHora12.Text:= ´´;
DbHora13.Text:= ´´;
DbHora14.Text:= ´´;
DbHora15.Text:=´´;

Begin
Table1.Append;
Table1.Edit;
DecodeDate(Now,Ano,Mes,Dia);
DecodeTime(Now,Hora,Min,Sec,MSec);
ShortDateFormat := ´dd/mm/yyyy´;
LongTimeFormat := ´hh:nn´;
LongDayNames[1] := ´Domingo´; LongDayNames[2] := ´Segunda´; LongDayNames[3] := ´Terça´;
LongDayNames[4] := ´Quarta´; LongDayNames[5] := ´Quinta´; LongDayNames[6] := ´Sexta´;
LongDayNames[7] := ´Sábado´;
Label3.Caption := FormatDateTime(´ dddd, c´,
StrToDateTime(IntToStr(Dia) + ´/´ + IntToStr(Mes) + ´/´ +
IntToStr(Ano) + ´ ´ + IntToStr(8) + ´:´ +
IntToStr(00) + ´:´ + IntToStr(Sec)));
DbHora1.Enabled:= true;
DbHora1.Text := Label3.Caption;
Table1.Post;
end;
end;
end;

begin
If (Hora >= 8.0) and (Hora < 9.0) then
Begin
Label3.Caption:= ´´;
DbHora1.Text:=´´;
DbHora2.Text:=´´;
DbHora3.Text:= ´´;
DbHora4.Text:= ´´;
DbHora5.Text:= ´´;
DbHora6.Text:= ´´;
DbHora7.Text:= ´´;
DbHora8.Text:= ´´;
DbHora9.Text:= ´´;
DbHora10.Text:= ´´;
DbHora11.Text:= ´´;
DbHora12.Text:= ´´;
DbHora13.Text:= ´´;
DbHora14.Text:= ´´;
DbHora15.Text:=´´;

Begin
Table1.Append;
Table1.Edit;
DecodeDate(Now,Ano,Mes,Dia);
DecodeTime(Now,Hora,Min,Sec,MSec);
ShortDateFormat := ´dd/mm/yyyy´;
LongTimeFormat := ´hh:nn´;
LongDayNames[1] := ´Domingo´; LongDayNames[2] := ´Segunda´; LongDayNames[3] := ´Terça´;
LongDayNames[4] := ´Quarta´; LongDayNames[5] := ´Quinta´; LongDayNames[6] := ´Sexta´;
LongDayNames[7] := ´Sábado´;
Label3.Caption := FormatDateTime(´ dddd, c´,
StrToDateTime(IntToStr(Dia) + ´/´ + IntToStr(Mes) + ´/´ +
IntToStr(Ano) + ´ ´ + IntToStr(Hora) + ´:´ +
IntToStr(Min) + ´:´ + IntToStr(Sec)));

DbHora1.Enabled:= true;
DbHora1.Text := Label3.Caption;
Table1.Post;
end;
end;
end;


begin
If (Hora >= 9.0) and (Hora < 18.0) then

Begin
Label3.Caption:= ´´;
DbHora1.Text:=´´;
DbHora2.Text:=´´;
DbHora3.Text:= ´´;
DbHora4.Text:= ´´;
DbHora5.Text:= ´´;
DbHora6.Text:= ´´;
DbHora7.Text:= ´´;
DbHora8.Text:= ´´;
DbHora9.Text:= ´´;
DbHora10.Text:= ´´;
DbHora11.Text:= ´´;
DbHora12.Text:= ´´;
DbHora13.Text:= ´´;
DbHora14.Text:= ´´;
DbHora15.Text:=´´;

Confirma:= Inputbox (´.:Ponto Eletrônico:.´, ´Digite a senha para confirmar o horário:´, ´´);
If (Confirma = ´roberto´) then
Begin
Table1.Append;
Table1.Edit;
DecodeDate(Now,Ano,Mes,Dia);
DecodeTime(Now,Hora,Min,Sec,MSec);
ShortDateFormat := ´dd/mm/yyyy´;
LongTimeFormat := ´hh:nn´;
LongDayNames[1] := ´Domingo´; LongDayNames[2] := ´Segunda´; LongDayNames[3] := ´Terça´;
LongDayNames[4] := ´Quarta´; LongDayNames[5] := ´Quinta´; LongDayNames[6] := ´Sexta´;
LongDayNames[7] := ´Sábado´;
Label3.Caption := FormatDateTime(´ dddd, c´,
StrToDateTime(IntToStr(Dia) + ´/´ + IntToStr(Mes) + ´/´ +
IntToStr(Ano) + ´ ´ + IntToStr(Hora) + ´:´ +
IntToStr(Min) + ´:´ + IntToStr(Sec)));

DbHora1.Enabled:= True;
DbHora1.Text := Label3.Caption;
DbCom1.Visible:= True;
DbCom1.Enabled:= True;
BitBtn6.Enabled:= True;
BitBtn1.Enabled:= False;
Table1.Post;
end
Else
Begin
DbCom1.Visible:= False;
Label3.Caption:= ´´;
DbHora1.Text:= ´´;
DbHora2.Text:=´´;
DbHora3.Text:= ´´;
DbHora4.Text:= ´´;
DbHora5.Text:= ´´;
DbHora6.Text:= ´´;
DbHora7.Text:= ´´;
DbHora8.Text:= ´´;
DbHora9.Text:= ´´;
DbHora10.Text:= ´´;
DbHora11.Text:= ´´;
DbHora12.Text:= ´´;
DbHora13.Text:= ´´;
DbHora14.Text:= ´´;
DbHora15.Text:=´´;
End;
end;
end;

begin
If (Hora >= 18.0) and (Hora < 18.25) then
Begin
Label3.Caption:= ´´;
DbHora1.Text:=´´;
DbHora2.Text:=´´;
DbHora3.Text:= ´´;
DbHora4.Text:= ´´;
DbHora5.Text:= ´´;
DbHora6.Text:= ´´;
DbHora7.Text:= ´´;
DbHora8.Text:= ´´;
DbHora9.Text:= ´´;
DbHora10.Text:= ´´;
DbHora11.Text:= ´´;
DbHora12.Text:= ´´;
DbHora13.Text:= ´´;
DbHora14.Text:= ´´;
DbHora15.Text:=´´;
Begin
Table1.Append;
Table1.Edit;
DecodeDate(Now,Ano,Mes,Dia);
DecodeTime(Now,Hora,Min,Sec,MSec);
ShortDateFormat := ´dd/mm/yyyy´;
LongTimeFormat := ´hh:nn´;
LongDayNames[1] := ´Domingo´; LongDayNames[2] := ´Segunda´; LongDayNames[3] := ´Terça´;
LongDayNames[4] := ´Quarta´; LongDayNames[5] := ´Quinta´; LongDayNames[6] := ´Sexta´;
LongDayNames[7] := ´Sábado´;
Label3.Caption := FormatDateTime(´ dddd, c´,
StrToDateTime(IntToStr(Dia) + ´/´ + IntToStr(Mes) + ´/´ +
IntToStr(Ano) + ´ ´ + IntToStr(Hora) + ´:´ +
IntToStr(Min) + ´:´ + IntToStr(Sec)));

DbHora1.Enabled:= True;
DbHora1.Text := Label3.Caption;
Table1.Post;
end;
end;
end;


begin
If (Hora >= 18.25) and (Hora < 21) then
Begin
Label3.Caption:= ´´;
DbHora1.Text:=´´;
DbHora2.Text:=´´;
DbHora3.Text:= ´´;
DbHora4.Text:= ´´;
DbHora5.Text:= ´´;
DbHora6.Text:= ´´;
DbHora7.Text:= ´´;
DbHora8.Text:= ´´;
DbHora9.Text:= ´´;
DbHora10.Text:= ´´;
DbHora11.Text:= ´´;
DbHora12.Text:= ´´;
DbHora13.Text:= ´´;
DbHora14.Text:= ´´;
DbHora15.Text:=´´;
Confirma:= Inputbox (´.:Ponto Eletrônico:.´, ´Digite a senha para confirmar o horário:´, ´´);
If (Confirma = ´roberto´) then
Begin
Table1.Append;
Table1.Edit;
DecodeDate(Now,Ano,Mes,Dia);
DecodeTime(Now,Hora,Min,Sec,MSec);
ShortDateFormat := ´dd/mm/yyyy´;
LongTimeFormat := ´hh:nn´;
LongDayNames[1] := ´Domingo´; LongDayNames[2] := ´Segunda´; LongDayNames[3] := ´Terça´;
LongDayNames[4] := ´Quarta´; LongDayNames[5] := ´Quinta´; LongDayNames[6] := ´Sexta´;
LongDayNames[7] := ´Sábado´;
Label3.Caption := FormatDateTime(´ dddd, c´,
StrToDateTime(IntToStr(Dia) + ´/´ + IntToStr(Mes) + ´/´ +
IntToStr(Ano) + ´ ´ + IntToStr(Hora) + ´:´ +
IntToStr(Min) + ´:´ + IntToStr(Sec)));

DbHora1.Enabled:= True;
DbHora1.Text := Label3.Caption;
DbCom1.Visible:= True;
DbCom1.Enabled:= True;
BitBtn6.Enabled:= True;
BitBtn1.Enabled:= False;
Table1.Post;
end
Else
Begin
DbCom1.Visible:= False;
Label3.Caption:= ´´;
DbHora1.Text:= ´´;
DbHora2.Text:=´´;
DbHora3.Text:= ´´;
DbHora4.Text:= ´´;
DbHora5.Text:= ´´;
DbHora6.Text:= ´´;
DbHora7.Text:= ´´;
DbHora8.Text:= ´´;
DbHora9.Text:= ´´;
DbHora10.Text:= ´´;
DbHora11.Text:= ´´;
DbHora12.Text:= ´´;
DbHora13.Text:= ´´;
DbHora14.Text:= ´´;
DbHora15.Text:=´´;
end;
End;
end;
end;


Kaybueno

Kaybueno

Responder

Posts

05/06/2003

Dedi

Kaybueno,
adicione o commando exit;antes do ultimo end;de cada if ...then begin


begin 
If (Hora <  then 
Begin 
Label3.Caption:= ´´; 
DbHora1.Text:=´´; 
DbHora2.Text:=´´; 
DbHora3.Text:= ´´; 
DbHora4.Text:= ´´; 
DbHora5.Text:= ´´; 
DbHora6.Text:= ´´; 
DbHora7.Text:= ´´; 
DbHora8.Text:= ´´; 
DbHora9.Text:= ´´; 
DbHora10.Text:= ´´; 
DbHora11.Text:= ´´; 
DbHora12.Text:= ´´; 
DbHora13.Text:= ´´; 
DbHora14.Text:= ´´; 
DbHora15.Text:=´´; 

Begin 
Table1.Append; 
Table1.Edit; 
DecodeDate(Now,Ano,Mes,Dia); 
DecodeTime(Now,Hora,Min,Sec,MSec); 
ShortDateFormat := ´dd/mm/yyyy´; 
LongTimeFormat := ´hh:nn´; 
LongDayNames[1] := ´Domingo´; LongDayNames[2] := ´Segunda´; LongDayNames[3] := ´Terça´; 
LongDayNames[4] := ´Quarta´; LongDayNames[5] := ´Quinta´; LongDayNames[6] := ´Sexta´; 
LongDayNames[7] := ´Sábado´; 
Label3.Caption := FormatDateTime(´ dddd, c´, 
StrToDateTime(IntToStr(Dia) + ´/´ + IntToStr(Mes) + ´/´ + 
IntToStr(Ano) + ´ ´ + IntToStr( + ´:´ + 
IntToStr(00) + ´:´ + IntToStr(Sec))); 
DbHora1.Enabled:= true; 
DbHora1.Text := Label3.Caption; 
Table1.Post; 
end; 
end;
[b]exit; [/b]
end; 


ele executa hora < :oops: porem executa hora >=8 fica valendo a ultima.


Dedi


Responder

Gostei + 0

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

Aceitar