terça-feira, 17 de outubro de 2017

Como usar o MonthCalendar1

Legenda.: mothcalendar = mp1 e spX = speedbutton

Tenho esse exemplo de uma agenda, mais acho que + ou - parecido

Citação:
Function tFAgenda.tratabotoes :string;
begin
dm.qagenda.close;
dm.qagenda.sql.clear;
dm.qagenda.sql.text := 'select * from agendamento where dataini = :params order by horaini';
dm.qagenda.ParamByName('params').AsDate := mc1.date;
dm.qagenda.Open;
///*************tratar botoes enablesd true e false***pega a data do dia
dm.qagenda.First;
While not (dm.qAgenda.EOF) do
begin
case dm.qagenda.fieldbyname('Tipo').asinteger of
0:
begin
IF dm.qagendahoraini.value = strtotime('07:30:00') THEN
begin
sp1.Enabled:=false;
end else
IF dm.qagendahoraini.value = strtotime('08:00:00') THEN
begin
sp2.Enabled:=false;
end else
IF dm.qagendahoraini.value = strtotime('08:30:00') THEN
begin
sp3.Enabled:=false;
end else
IF dm.qagendahoraini.value = strtotime('09:00:00') THEN
begin
sp4.Enabled:=false;
end else
IF dm.qagendahoraini.value = strtotime('09:30:00') THEN
begin
sp5.Enabled:=false;
end else
IF dm.qagendahoraini.value = strtotime('10:00:00') THEN
begin
sp6.Enabled:=false;
end else
IF dm.qagendahoraini.value = strtotime('10:30:00') THEN
begin
sp7.Enabled:=false;
end else
IF dm.qagendahoraini.value = strtotime('11:00:00') THEN
begin
sp8.Enabled:=false;
end else
IF dm.qagendahoraini.value = strtotime('11:30:00') THEN
begin
sp9.Enabled:=false;
end; //final dos sbuttoes
end; //final do begin do case 0
1:
begin
IF dm.qagendahoraini.value = strtotime('07:30:00') THEN
begin
sp1.Enabled:=true;
end else
IF dm.qagendahoraini.value = strtotime('08:00:00') THEN
begin
sp2.Enabled:=true;
end else
IF dm.qagendahoraini.value = strtotime('08:30:00') THEN
begin
sp3.Enabled:=true;
end else
IF dm.qagendahoraini.value = strtotime('09:00:00') THEN
begin
sp4.Enabled:=true;
end else
IF dm.qagendahoraini.value = strtotime('09:30:00') THEN
begin
sp5.Enabled:=true;
end else
IF dm.qagendahoraini.value = strtotime('10:00:00') THEN
begin
sp6.Enabled:=true;
end else
IF dm.qagendahoraini.value = strtotime('10:30:00') THEN
begin
sp7.Enabled:=true;
end else
IF dm.qagendahoraini.value = strtotime('11:00:00') THEN
begin
sp8.Enabled:=true;
end else
IF dm.qagendahoraini.value = strtotime('11:30:00') THEN
begin
sp9.Enabled:=true;
end; //final dos sbuttoes
end; //final do begin do case 1
end;
dm.qagenda.Next;
end;
//****************final tratar botoes******************
end;

Explicando o codigo: Bom eh o seguinte a ideia eh dar um clique nos dias do MonthCalendar e assim ir filtrando o dbGrid e ao mesmo tempo fazendo um EOF para ver se o campo Tipo esta 0 ou 1 e assim cfe. o dia ir mostrando os botoes disponiveis.

Bom nao fiz muitos testes, mais acho que esta funcionando...Pelo menos 90% nao sei ainda se esta 100% Very Happy

Bom por enquanto acho que o post vai

Nenhum comentário:

📌 Tela de Splash, Tela de Login e Tela Principal em Delphi: Aprendendo na Prática

  No desenvolvimento de sistemas, a experiência do usuário começa muito antes de utilizar as principais funcionalidades do software. Elemen...