Ir para conteúdo
Fórum Script Brasil

robinhocne

Membros
  • Total de itens

    854
  • Registro em

  • Última visita

Tudo que robinhocne postou

  1. Micheus estou mandando um projeto de exemplo que fiz para você analizar e poder me ajudar se possivel. Projeto
  2. É Micheus, me confudi um pouco, pois para mim a cada dia que vejo algo assim ainda é novo, pois estou só a um ano mexendo e tive uns curso de inicio, mas... Fiz dessa maneira e esta dando os seguintes erros: procedure Tfrmalunos.SpbBaixarClick(Sender: TObject); begin with DtmIza.UpdAluLan do begin SQL.Clear; SQL.Add('UPDATE Lancamento '); // tabela que terá o campo atualizado SQL.Add('SET baixado = :Tipo'); // campo a ser atualizado com valor -> parâmetro SQL.Add('WHERE Codigo = :Codigo, Aluno, Tipo, Parcela, Valor, Vencimento, Emissao '); // campo(s) a ser(em) filtrado(s) p/ identificar o registro // campo da tabela receberá o valor 0 ou 1, conforme o seu radiobox if RdbBaixa.Checked then SQL.ParambyName('Tipo').AsInteger := 1 else SQL.ParamByname('Tipo').AsInteger := 0; ExecSQL; // instrução UPDATE é executa com este método, não o Open; end; end; O erro esta dando no ParamByname: [Error] falunos.pas(1082): Undeclared identifier: 'ParambyName' [Error] falunos.pas(1082): Missing operator or semicolon [Error] falunos.pas(1084): Undeclared identifier: 'ParamByname' [Error] falunos.pas(1084): Missing operator or semicolon [Fatal Error] Praticas.pas(99): Could not compile used unit 'falunos.pas' Bom desculpas por poucas informações, mas a tabela de Lancamento e assim
  3. Mas, não entendi Micheus: 1ª o UPDATE Lancamento SET baixado = :baixado WHERE Codigo = :Codigo, onde colocarei, tipo nos dados que você passou: procedure TCadAluno.SpbBaixaClick(Sender :TObject); begin dataset.edit; // campo da tabela recebe o valor 0 ou 1, conforme o seu radiobox if RdbBaixa.Checked then dataset_campo_baixado.Value := 1 else dataset_campo_baixado.Value := 0; dataset.post; end; ou With DtmIza.DsAluLan do Begin Close; Sql.Clear; Sql.Add ('Select L.Aluno, L.Parcela, L.Vencimento, L.Valor, L.Emissao, L.Aluno From Lancamento L,' +'Lancamento I Where L.Aluno=' + TxtMat.Text + ' AND I.Codigo=L.Aluno ORDER BY L.Parcela, L.Vencimento'); Open; end; E como eu vou ligar a Query, o DataSource e o DataSet ?
  4. Mas Micheus eu uso a IbQuery para buscar os dados e mostrar no meu DbGrid, ao substituir pelo IBDataSet ele dá erro na Instrução Sql que eu faço para buscar os dados:Aqui nomei o IBdataSet p/ DsAluLan: With DtmIza.DsAluLan do Begin Close; Sql.Clear; Sql.Add ('Select L.Aluno, L.Parcela, L.Vencimento, L.Valor, L.Emissao, L.Aluno From Lancamento L,' +'Lancamento I Where L.Aluno=' + TxtMat.Text + ' AND I.Codigo=L.Aluno ORDER BY L.Parcela, L.Vencimento'); Open; end; Dá esse erro: [Warning] fLibSof.pas(153): FOR-Loop variable 'o' may be undefined after loop [Hint] falunos.pas(260): Variable 'szBuff' is declared but never used in 'Tfrmalunos.spbsalClick' [Error] falunos.pas(498): Undeclared identifier: 'Sql' [Error] falunos.pas(499): Missing operator or semicolon [Error] falunos.pas(960): Undeclared identifier: 'Tipo' [Error] falunos.pas(962): Undeclared identifier: 'Tipo' [Error] falunos.pas(963): Undeclared identifier: 'Tipo' [Hint] falunos.pas(181): Private symbol 'AppEventsMessage' declared but never used [Fatal Error] Praticas.pas(99): Could not compile used unit 'falunos.pas'
  5. Micheus o nome do Banco de Dados é FDtmiIza e conecto com uma Query nome= QryAluLan e o nome do campo baixado com eu poderia fazer, bom fiz desse tipo mas ele dá erro no tipo que é o nome do campo que eu atribu-o o 1,0.
  6. No cadastro de Alunos eu coloquei um DbGrid (DbgLan) para poder vizualizar as parcelas lançadas para o aluno selecionado, mas gostaria de colocar para dar baixa tipo assim:"Clicar na parcela da Linha do DbgLan" e coloquei um RadioButton (RdbBaixa) para poder selecionar como dar baixa e um SpeedButton (SpbBaixa) para poder assim concluir a baixa da parcela. Na Tabela de Lancamentos eu coloquei um campo como Tipo numeric 1,0 sendo 0 Aberto e 1 Para Baixado. Uso o Firebird 2.0.3 e Delphi 7 Como poderei atribuir?
  7. Micheus era desse tipo que eu queria, mas do jeito que você me passou não estava dando meio certo, então eu fiz dois procedimentos no banco de dados para filtrar as categorias de carro e moto, e dois procedimentos na tabela para consultar as aulas de carros e outra para moto: Procedure para carro no banco de dados: CREATE PROCEDURE FILTROAULACARRO ( palu numeric(6,0)) returns ( pord numeric(3,0), pins numeric(2,0), pdat date, phor time, pcat char(2)) as BEGIN pOrd = 0; FOR Select P.Instrutor, P.Data, P.Horario, P.Categoria From Praticas P, Instrutores I Where P.Aluno=:pAlu AND P.Status=1 AND P.Categoria= 'B' AND I.Codigo=P.Instrutor ORDER BY P.Data, P.Horario INTO :pIns, :pDat, :pHor, :pCat DO BEGIN pOrd = :pOrd + 1; SUSPEND; END END; Procedure para carro no programa: procedure Tfrmalunos.ContaAulasCarro; var aulasCarro, aulasMoto : integer; begin With DtmIza.QryAluPraB do Begin Close; Sql.Clear; Sql.Add ( 'SELECT * FROM FiltroAulaCarro( ' + TxtMat.Text + ' );' ); Open; end; aulasCarro := 0; while ( not DtmIza.QryAluPraB.Eof ) do begin if ( Trim( DtmIza.QryAluPraB.FieldByName( 'pCat' ).AsString ) = 'B' ) then begin Inc( aulasCarro ); end; if ( aulasCarro <= 15 ) then begin txtCarro.Text := IntToStr( aulasCarro ); TxtExCarro.Text := '0'; end else begin txtCarro.Text := '15'; TxtExCarro.Text := IntToStr( aulasCarro - 15 ); end; DtmIza.QryAluPraB.Next; end; end; Procedure para moto no banco de dados: CREATE PROCEDURE FILTROAULAMOTO ( palu numeric(6,0)) returns ( pord numeric(3,0), pins numeric(2,0), pdat date, phor time, pcat char(2)) as BEGIN pOrd = 0; FOR Select P.Instrutor, P.Data, P.Horario, P.Categoria From Praticas P, Instrutores I Where P.Aluno=:pAlu AND P.Status=1 AND P.Categoria= 'A' AND I.Codigo=P.Instrutor ORDER BY P.Data, P.Horario INTO :pIns, :pDat, :pHor, :pCat DO BEGIN pOrd = :pOrd + 1; SUSPEND; END END; Procedure para moto no programa: procedure Tfrmalunos.ContaAulasMoto; var aulasCarro, aulasMoto : integer; Begin With DtmIza.QryAluPraA do Begin Close; Sql.Clear; Sql.Add ( 'SELECT * FROM FiltroAulaMoto( ' + TxtMat.Text + ' );' ); Open; end; aulasMoto := 0; while ( not DtmIza.QryAluPraA.Eof ) do begin if ( Trim( DtmIza.QryAluPraA.FieldByName( 'pCat' ).AsString ) = 'A' ) then begin Inc( aulasMoto ); end; if ( aulasMoto <= 15 ) then begin txtMoto.Text := IntToStr( aulasMoto ); TxtExMoto.Text := '0'; end else begin txtMoto.Text := '15'; TxtExMoto.Text := IntToStr( aulasMoto - 15 ); end; DtmIza.QryAluPraA.Next; end; end; O procedimento no banco de dados ficou para filtrar as aulas de moto e carro e atribuir contagem, e no delphi para atribuir no programas nos edits e nos dbgrids. Ok Resolvido!
  8. Olá pessoal, Estou querendo buscar em uma instrução SQL os seguintes dados, quer dizer usei desse tipo para buscar só um tipo de categoria para cada dbgrid, pois uso um dbgrid para "A" e "B", esses são um dos codigos, essa instrução deu certo, mas.... With DtmIza.QryAluPraB do Begin Close; Sql.Clear; Sql.Add ('Select P.Aluno, P.Instrutor, P.Data, P.Horario, P.Categoria, P.Aluno From Praticas P,' +'Instrutores I Where P.Aluno=' + TxtMat.Text + 'AND P.Categoria= ''B'' AND P.Status=1 AND I.Codigo=P.Instrutor ORDER BY P.Data, P.Horario'); Open; end; mas... Fiz esse procedimento no banco de dados para informar as ordens das aulas: SET TERM ^; CREATE PROCEDURE STPCSLAUL ( palu numeric(6,0)) returns ( pord numeric(3,0), pins numeric(2,0), pdat date, phor time, pcat char(2)) as BEGIN pOrd = 0; FOR Select P.Instrutor, P.Data, P.Horario, P.Categoria From Praticas P, Instrutores I Where P.Aluno=:pAlu AND P.Status=1 AND I.Codigo=P.Instrutor ORDER BY P.Data, P.Horario INTO :pIns, :pDat, :pHor, :pCat DO BEGIN pOrd = :pOrd + 1; SUSPEND; END END; Essa parte é relacionado com este tópico que eu abri e resolvi, mas eu tenho que mostar da mesma maneira na tabela de aulas, mas no DbGridA (para moto) e no DbGridB (para carro), essa é á busca referente ao tópico resolvido: procedure Tfrmpraticas.ConsultaAula; var aulasCarro, aulasMoto : integer; Begin With QryPra do Begin Close; Sql.Clear; Sql.Add ( 'SELECT * FROM stpCslAul( ' + txtcod.Text + ' );' ); Open; end; aulasCarro := 0; aulasMoto := 0; while ( not qryPra.Eof ) do begin if ( Trim( qryPra.FieldByName( 'pCat' ).AsString ) = 'A' ) then begin Inc( aulasMoto ); end else begin Inc( aulasCarro ); end; if ( aulasMoto <= 15 ) then begin txtMoto.Text := IntToStr( aulasMoto ); Edit1.Text := '0'; end else begin txtMoto.Text := '15'; Edit1.Text := IntToStr( aulasMoto - 15 ); end; if ( aulasCarro <= 15 ) then begin txtCarro.Text := IntToStr( aulasCarro ); Edit2.Text := '0'; end else begin txtCarro.Text := '15'; Edit2.Text := IntToStr( aulasCarro - 15 ); end; qryPra.Next; end; end; Então gostaria de saber como posso fazer para atribuir nesses codigos acima para o DbGridA e para o DbGridB, sendo que eu busco no meu Procedimento stpCslAul?
  9. Gostaria de saber como faz para por exemplo: No edit do codigo só digitar o codigo do cliente e assim que der tab, para ir no campo do nome aparecer o nome dele? Estou utilizando isso mas não deu certo, achei na net e implementei do meu jeito. If ((Length(trim(txtCod.Text))=0) or (not ConsultaRegistros('Alunos','Nome','Codigo=' + txtCod.Text))) then txtAlu.Text := LeDados('Nome'); Resolvido, fiz desse jeito: procedure Tfrmcadlan.txtcodExit(Sender: TObject); begin ConsultaRegistros ('Alunos', 'Nome', 'Codigo =' + Copy (TxtCod.Text, 1, 6)); TxtAlu.Text := LeDados ('Nome'); end;
  10. este dia de vencimento a partir do qual você quer gerar os vencimentos, não será informado pelo usuário? Por acaso você queria que fosse informado algo como vencimento todo dia 10 do mês? Se os vencimentos calculados, cairem em num final de semana, o vencimento deverá ser alterado para o próximo dia útil, é isto? Resolvido Fiz dessa maneira no Botão Gerar Parcelas. procedure Tfrmcadlan.SpbGeParClick(Sender: TObject); var a, prazo : integer; data : TDate; begin if ( not tblPar.Active ) then tblPar.Open else tblPar.EmptyTable; data := StrToDate( txtVen.Text ); prazo := 30; for a := 1 to StrToInt( txtPar.Text ) do begin with tblPar do begin Insert; Fields[00].AsInteger := a; Fields[01].AsDateTime := data; Fields[02].AsCurrency := StrToFloat( txtVal.Text ); Post; end; data := ( data + prazo ); end; end;
  11. Micheus Obrigado por tudo, mas consegui fazer deste jeito Resolvido procedure Tfrmalunos.spbsalClick(Sender: TObject); procedure imprimeFicha(); begin if (not pergunta('Deseja Imprimir o Contrato de Prestação de Serviço?')) then exit; With DtmIza.QryRelAlu do Begin Close; Sql.Clear; Sql.Add ('Select A.Codigo, A.Nome, A.Rg, I.Nome From Alunos A, ' + 'Alunos I Where A.Codigo=' + TxtMat.Text ); Open; End; With DtmIza.QryRelEmp do Begin Close; Sql.Clear; Sql.Add ('Select A.Empresa, A.Cnpj, A.Endereco, A.Numero, A.Bairro From Empresa A'); Open; end; With DtmIza.QryRelCid do Begin Close; Sql.Clear; Sql.Add( 'SELECT * FROM Cidades' ); Open; End; With TFrmRelContrato.Create (Application) do try QuickRep1.Preview; finally free; end; end; var szBuff: String; begin with vcpo do begin clear; add ('dtcadastro'); add ('servicos'); add ('categoria'); add ('nome'); add ('rg'); add ('uf_rg'); add ('emissor'); add ('cpf'); ................................... with vvlr do begin clear; Add ('Current_Date'); if (rdbhab.checked) then add ('1') else if (rdbalt.checked) then add('2') else if (rdbren.checked) then add('3'); add (#39 + txtcth.Text + #39); add (#39 + txtnom.Text + #39); add (#39 + txtrg.Text + #39); add (#39 + txtuf2.Text + #39); add (#39 + cboorg.Text + #39); Add (TiraMascara (TxtCPF.Text)); ..................... end; If (Editar) Then begin AlterarRegistro ('alunos', vCpo, vVlr, 'codigo =' + txtmat.Text) end else begin IncluirRegistro('alunos', vCpo, vVlr); imprimeFicha(); end; Inherited; End;
  12. Resolvido! O erro estava, na função de criptografia, que eu estava atribuindo 'where cfg2', então dava este erro.
  13. Está aparecendo esse erro, em meu programa: Project sistemacfc.exe raised exception class EIBInterBaseError with message 'Dynamic SQL Error SQL error code = -104 Unexpected end of command'.Process stopped. Use Step or Run to continue.
  14. Ok, Micheus mas tive que fazer umas outras alterações nessa consulta: if (not pergunta('Deseja Imprimir o Contrato de Prestação de Serviço?')) then exit; With DtmIza.QryRelEmp do Begin Close; Sql.Clear; Sql.Add('SELECT * FROM Empresa'); Open; end; With DtmIza.QryRelAlu do Begin Close; Sql.Clear; Sql.Add('SELECT * FROM Alunos'); Open; End; With DtmIza.QryRelCid do Begin Close; Sql.Clear; Sql.Add('SELECT * FROM Cidades'); Open; End; With TFrmRelContrato.Create (Application) do try QuickRep1.Preview; finally free; end; End; Então modifiquei do jeito que você colocou e ele da erro na consulta. Sobre a segunda questão eu tenho sim um procedimento, eu inicio os forms com todos os edits em branco, apartir disso eu localizo ou faço uma inclusão do registro. procedure incluirregistro (ptabela:string;pcampos, pvalores:tstringlist); var a:integer;instrucaosql:string; begin instrucaosql:='insert into ' + ptabela + ' ('; for a :=0 to (pcampos.Count-1) do begin instrucaoSQL := instrucaosql+pcampos [a] + ', '; end; instrucaosql:= copy (instrucaosql,1,length (instrucaosql)-2) + ') values ('; for a :=0 to (pvalores.Count-1) do begin instrucaoSQL := instrucaosql+pvalores [a] + ', '; end; instrucaosql:= copy (instrucaosql,1,length (instrucaosql)-2) + '); '; //showmessage (instrucaosql); with dtmiza.qryiza do begin close; sql.Clear; sql.add (instrucaosql); execsql; end; end; procedure alterarregistro (ptabela:string;pcampos, pvalores:tstringlist;pcondicao:string); var a:integer;instrucaosql:string; begin instrucaosql:='update ' + ptabela + ' set '; for a :=0 to (pcampos.Count-1) do begin instrucaoSQL := instrucaosql+pcampos [a]+ '='+ pvalores [a] + ', '; end; instrucaosql:= copy (instrucaosql,1,length (instrucaosql)-2); if (pcondicao<>'') then begin instrucaosql := instrucaosql + ' where ' + pcondicao; end; // showmessage (instrucaosql); with dtmiza.qryiza do begin close; sql.Clear; sql.add (instrucaosql); execsql; end; end;
  15. Micheus, eu coloquei a pergunta no final do codigo mas quando salvo ele já aparece o contrato e quando depois que fecho ai sim que aparece a pergunta: With DtmIza.QryRelEmp do Begin Close; Sql.Clear; Sql.Add('SELECT * FROM Empresa'); Open; end; With DtmIza.QryRelAlu do Begin Close; Sql.Clear; Sql.Add('SELECT * FROM Alunos'); Open; End; With DtmIza.QryRelCid do Begin Close; Sql.Clear; Sql.Add('SELECT * FROM Cidades'); Open; End; With TFrmRelContrato.Create (Application) do try QuickRep1.Preview; finally free; end; if (not pergunta('Deseja Imprimir o Contrato de Prestação de Serviço?')) then exit; Você quer dizer apenas quando está incluindo? Se for, como você não utiliza os métodos convencionais (datasets em modo inserção/edição), então sugiro que você utilize uma variável em algum lugar (só você vai saber qual o melhor) para indicar quando o registro está sendo incluído ou quando está sendo alterado. Daí você só chama o procedimento para o relatório após verificar esta variável. Aqui será que você me poderia me ajudar!
  16. Olá para todos. Bom, na hora que eu faço um cadastro e salvo ele eu coloquei essa pergunta para que ele possa imprimir o contrato do aluno, mas o erro é o seguinte, aki se eu escolho a opção não ele não salva, outro dois pontos é que só queria que aparecesse a opção de imprimir o contrato só na hora que eu faço o cadastro, mas não na hora que eu edito ele não aparece a opção, e o outro ponto, queria colocar para imprimir o contrato e uma ficha, quer dizer quando usuario clicasse em sim ai aparecesse para imprimir os dois! Esses são os codigos que eu coloquei, só não consiguo concluir espero ajuda! if (not pergunta('Deseja Imprimir o Contrato de Prestação de Serviço?')) then exit; With DtmIza.qryIza do Begin ConsultaRegistros ('Empresa', 'Empresa, Endereco, Numero, Cnpj, Bairro, Cidade', 'Codigo>=' + txtMat.Text); With TFrmRelContrato.Create (Application) do try QuickRep1.Preview; finally free; end; End; Inherited;
  17. Ok, Obrigado Jhonas consegui resolver, mas como são 15 aulas de carro e moto no agendamento, então eu tive que fazer assim:Resolvido procedure Tfrmpraticas.DbgRelDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); Begin If odd( qryPra.FieldByName( 'pOrd' ).AsInteger ) then // coloque aqui a sua query ou table begin DbgRel.Canvas.Font.Color:= clBlack; DbgRel.Canvas.Brush.Color:= cl3DLight; end else begin DbgRel.Canvas.Font.Color:= clBlack; DbgRel.Canvas.Brush.Color:= clMoneyGreen; end; if qryPra.FieldByName('pOrd').value >= 31 then begin DbgRel.Canvas.Font.Color:= clRed; DbgRel.Canvas.FillRect(Rect); end; DbgRel.Canvas.FillRect(Rect); DbgRel.DefaultDrawColumnCell(Rect, DataCol, Column, State); end;
  18. Ok, Jhonas consegui resolver com ajuda do meu professor e conclui nesse resultado. Fiz um procedimento no banco de dados e atribui no delphi também. No banco de dados: CREATE PROCEDURE STPCSLAUL ( palu numeric(6,0)) returns ( pord numeric(3,0), pins numeric(2,0), pdat date, phor time, pcat char(2)) as BEGIN pOrd = 0; FOR Select P.Instrutor, P.Data, P.Horario, P.Categoria From Praticas P, Instrutores I Where P.Aluno=:pAlu AND P.Status=1 AND I.Codigo=P.Instrutor ORDER BY P.Data, P.Horario INTO :pIns, :pDat, :pHor, :pCat DO BEGIN pOrd = :pOrd + 1; SUSPEND; END END^ SET TERM; ^ GRANT SELECT ON PRATICAS TO PROCEDURE STPCSLAUL; GRANT SELECT ON INSTRUTORES TO PROCEDURE STPCSLAUL; GRANT EXECUTE ON PROCEDURE STPCSLAUL TO SYSDBA; procedure Tfrmpraticas.ConsultaAula; var aulasCarro, aulasMoto : integer; Begin With QryPra do Begin Close; Sql.Clear; Sql.Add ( 'SELECT * FROM stpCslAul( ' + txtcod.Text + ' );' ); Open; end; aulasCarro := 0; aulasMoto := 0; while ( not qryPra.Eof ) do begin if ( Trim( qryPra.FieldByName( 'pCat' ).AsString ) = 'A' ) then begin Inc( aulasMoto ); end else begin Inc( aulasCarro ); end; if ( aulasMoto <= 15 ) then begin txtMoto.Text := IntToStr( aulasMoto ); Edit1.Text := '0'; end else begin txtMoto.Text := '15'; Edit1.Text := IntToStr( aulasMoto - 15 ); end; if ( aulasCarro <= 15 ) then begin txtCarro.Text := IntToStr( aulasCarro ); Edit2.Text := '0'; end else begin txtCarro.Text := '15'; Edit2.Text := IntToStr( aulasCarro - 15 ); end; qryPra.Next; end; end; Com isso resolvi o meu problema, mas também gostaria de saber algo em cima desse tema, no grid que eu mostro os dados cadastrados, queria colocar o seguinte que acima dos quinze ele mostrasse de outra cor.
  19. Jhonas é o seguinte: > O txtcod.text é onde atribui o codigo do aluno. Vou passar os dados da tabela de praticas para você entender melhor! unit Praticas; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, psvBasiclbl, psvBorderLabel, Buttons, WinSkinData, Grids, DBGrids, ExtCtrls, DateUtils, DB, DBTables, IBCustomDataSet, IBQuery; type Tfrmpraticas = class(TForm) txtcod: TEdit; txtaluno: TEdit; txtcodins: TEdit; txtnomins: TEdit; txtcodcat: TEdit; txtcat: TEdit; spbaluloc: TSpeedButton; psvBorderLabel1: TpsvBorderLabel; psvBorderLabel2: TpsvBorderLabel; psvBorderLabel3: TpsvBorderLabel; SbpInst: TSpeedButton; SpbCat: TSpeedButton; Panel1: TPanel; spbpro: TSpeedButton; spbant: TSpeedButton; sbxPra: TScrollBox; Panel2: TPanel; panHor: TPanel; Panel3: TPanel; Panel4: TPanel; Panel5: TPanel; Panel6: TPanel; panDom: TPanel; panTer: TPanel; panQua: TPanel; panQui: TPanel; panSex: TPanel; panSab: TPanel; Panel14: TPanel; Panel15: TPanel; Panel16: TPanel; Panel17: TPanel; Panel18: TPanel; Panel19: TPanel; Panel20: TPanel; Panel21: TPanel; panSeg: TPanel; Panel7: TPanel; DbgRel: TDBGrid; txtvei: TEdit; SpbImp: TSpeedButton; spbfec: TSpeedButton; DtsPra: TDataSource; QryPra: TIBQuery; psvBorderLabel4: TpsvBorderLabel; psvBorderLabel5: TpsvBorderLabel; TxtMoto: TEdit; TxtCarro: TEdit; psvBorderLabel6: TpsvBorderLabel; psvBorderLabel7: TpsvBorderLabel; Edit1: TEdit; Edit2: TEdit; procedure spbfecClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure spbantClick(Sender: TObject); procedure spbproClick(Sender: TObject); procedure PosicionaSemana; procedure ConsultaAgendamento; procedure PreencheEdit( Sender : TObject ); procedure BloqueioDesbloqueio( Sender: TObject; var Key: Word; Shift: TShiftState ); procedure SalvaBloqueio( Sender : TObject ); procedure RemoveBloqueio( Sender : TObject ); function RetornaData( edit : String ) : TDate; function RetornaHora( edit : String ) : TTime; procedure txtcodinsExit(Sender: TObject); procedure spbalulocClick(Sender: TObject); procedure LeRegistro (); procedure SbpInstClick(Sender: TObject); procedure SpbCatClick(Sender: TObject); Procedure ConsultaAula; procedure DbgRelDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); private linha : integer; dataInicial, InicioSemana, FinalSemana : TDate; procedure AppEventsMessage(var Msg: TMsg; var Handled: Boolean); public { Public declarations } end; var frmpraticas: Tfrmpraticas; implementation {$R *.dfm} uses funcoes, fprincipal, fdtmiza, Fpesquisa, finstrutores, fcategoria, falunos; Var cont : extended; procedure Tfrmpraticas.spbfecClick(Sender: TObject); begin close; end; procedure Tfrmpraticas.FormCreate(Sender: TObject);// Procedure para criar a Tabela var labels : TpsvBorderLabel; edits : TEdit; a, top_edit, top_label, left_edit : Integer; HoraAtual, HoraFinal : TTime; begin dataInicial := Date(); PosicionaSemana; top_edit := 3; top_label := 3; left_edit := 98; // left da primeira fileira dos edits HoraFinal := StrToTime( '22:10:00' ); HoraAtual := StrToTime( '08:00:00' ); while ( ( HoraAtual + StrToTime( '00:50' ) ) < HoraFinal ) do begin // cria a label do horario Labels := TpsvBorderLabel.Create( Self ); with Labels do begin Height := 18; // Tamanho do Labels Border := psvBorderLabel.bsRaised; // bordas do labels Parent := sbxPra; Top := top_label; Left := 16; Caption := FormatDateTime( 'hh:nn', HoraAtual ); Name := 'lbl_' + FormatDateTime( 'hhnn', HoraAtual ); with Font do begin Name := 'Courier New'; Size := 10; Style := [fsBold]; FocusColor := ClBlack; Width := 75; Layout := tlCenter; Alignment := TaCenter; end; end; for a := 1 to 7 do begin // cria o edit do codigo do aluno edits := TEdit.Create( Self ); with edits do begin Cursor := crCross; Parent := sbxPra; Top := top_edit; Left := left_edit; Name := 'ed_' + IntToStr( a ) + FormatDateTime( 'hhnn', HoraAtual ); Width := 65; //Enabled := False; ReadOnly := True; Text := ''; OnDblClick := PreencheEdit; OnKeyDown := BloqueioDesbloqueio; with Font do Begin Height := 15; Name := 'Courier New'; Size := 10; // Style := [fsBold]; end; end; // cria o edit da categoria left_edit := left_edit + 67; // espaço entre o edit codigo e edit categoria edits := TEdit.Create( Self ); with edits do begin Cursor := crCross; Parent := sbxPra; Top := top_edit; Left := left_edit; Name := 'ed_cat_' + IntToStr( a ) + FormatDateTime( 'hhnn', HoraAtual ); Width := 20; //Enabled := False; ReadOnly := True; Text := ''; with Font do Begin Height := 15; Name := 'Courier New'; Size := 10; // Style := [fsBold]; end; end; left_edit := left_edit + 23; // Espaço entre o edit da categoria para o codigo da outra fileira. end; top_label := top_label + 28; // top dos edits top_edit := top_edit + 28; // top dos labels left_edit := 98; // left das demais fileiras dos edits if ( HoraAtual < StrToTime( '17:00:00' ) ) then HoraAtual := HoraAtual + StrToTime( '01:00' ) else HoraAtual := HoraAtual + StrToTime( '00:50' ); end; Application.OnMessage := AppEventsMessage; // Para a movimentação do mouse linha := 1; end; procedure Tfrmpraticas.PosicionaSemana; // Procedure para mostrar as datas var hoje : Integer; begin hoje := DayOfTheWeek( dataInicial ); // 1->segunda;2->terca;...;7->domingo case hoje of 1 : begin InicioSemana := dataInicial-1; FinalSemana := dataInicial+5; panDom.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-1 ); panSeg.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial ); panTer.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+1 ); panQua.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+2 ); panQui.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+3 ); panSex.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+4 ); panSab.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+5 ); end; 2 : begin InicioSemana := dataInicial-2; FinalSemana := dataInicial+4; panDom.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-2 ); panSeg.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-1 ); panTer.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial ); panQua.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+1 ); panQui.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+2 ); panSex.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+3 ); panSab.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+4 ); end; 3 : begin InicioSemana := dataInicial-3; FinalSemana := dataInicial+3; panDom.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-3 ); panSeg.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-2 ); panTer.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-1 ); panQua.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial ); panQui.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+1 ); panSex.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+2 ); panSab.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+3 ); end; 4 : begin InicioSemana := dataInicial-4; FinalSemana := dataInicial+2; panDom.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-4 ); panSeg.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-3 ); panTer.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-2 ); panQua.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-1 ); panQui.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial ); panSex.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+1 ); panSab.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+2 ); end; 5 : begin InicioSemana := dataInicial-5; FinalSemana := dataInicial+1; panDom.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-5 ); panSeg.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-4 ); panTer.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-3 ); panQua.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-2 ); panQui.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-1 ); panSex.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial ); panSab.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+1 ); end; 6 : begin InicioSemana := dataInicial-6; FinalSemana := dataInicial; panDom.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-6 ); panSeg.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-5 ); panTer.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-4 ); panQua.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-3 ); panQui.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-2 ); panSex.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial-1 ); panSab.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial ); end; 7 : begin InicioSemana := dataInicial; FinalSemana := dataInicial+6; panDom.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial ); panSeg.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+1 ); panTer.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+2 ); panQua.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+3 ); panQui.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+4 ); panSex.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+5 ); panSab.Caption := FormatDateTime( 'dd/mm/yyyy', dataInicial+6 ); end; end; end; procedure Tfrmpraticas.spbantClick(Sender: TObject);// Procedure para mostrar a semana anterior begin dataInicial := ( dataInicial - 7 ); PosicionaSemana; ConsultaAgendamento; end; procedure Tfrmpraticas.spbproClick(Sender: TObject);// Procedure para mostrar a proxima semana begin dataInicial := ( dataInicial + 7 ); PosicionaSemana; ConsultaAgendamento; end; procedure Tfrmpraticas.ConsultaAgendamento;// Procedure para consultar os agendamentos dos Edits var a, nDia : Integer; begin for a := 0 to ComponentCount-1 do begin if ( Components[a] is TEdit ) then begin if ( Copy( ( Components[a] as TEdit ).Name, 01, 03 ) = 'ed_' ) then ( Components[a] as TEdit ).Text := ''; end; end; ConsultaRegistros( 'Praticas', 'Aluno, Instrutor, Categoria, Data, Horario, Status', 'Instrutor=' + txtCodIns.Text + ' AND Data BETWEEN ' + #39 + FormatDateTime( 'mm/dd/yyyy', InicioSemana ) + #39 + ' AND ' + #39 + FormatDateTime( 'mm/dd/yyyy', FinalSemana ) + #39 + ' ORDER BY Data, Horario' ); while ( not dtmIza.qryiza.EOF ) do begin nDia := DayOfTheWeek( LeDados( 'Data' ) ); if ( nDia <> 7 ) then nDia := nDia+1 else nDia := 1; if ( LeDados( 'Status' ) = 0 ) then begin TEdit( FindComponent( 'ed_' + IntToStr( nDia ) + FormatDateTime( 'hhnn', LeDados( 'Horario' ) ) ) ).Text := '**********'; end else begin TEdit( FindComponent( 'ed_' + IntToStr( nDia ) + FormatDateTime( 'hhnn', LeDados( 'Horario' ) ) ) ).Text := StrZero( LeDados( 'Aluno' ), 6 ); TEdit( FindComponent( 'ed_cat_' + IntToStr( nDia ) + FormatDateTime( 'hhnn', LeDados( 'Horario' ) ) ) ).Text := LeDados( 'Categoria' ); end; dtmIza.qryiza.Next; end; end; procedure Tfrmpraticas.PreencheEdit( Sender : TObject ); begin if ( Length( Trim( txtCod.Text ) ) = 0 ) then Exit; if ( Length( Trim( ( Sender as TEdit ).Text ) ) = 0 ) then begin if ( ConsultaRegistros( 'Praticas', 'Aluno', 'Aluno=' + txtCod.Text + ' AND ' + 'Data=' + #39 + FormatDateTime( 'mm/dd/yyyy', RetornaData( ( Sender as TEdit ).Name ) ) + #39 + ' AND ' + 'Horario=' + #39 + FormatDateTime( 'hh:nn', RetornaHora( ( Sender as TEdit ).Name ) ) + #39 + ' AND ' + 'Status=1' ) ) then begin ShowMessage( 'Aluno já tem aula marcada neste Horário!' ); Exit; end; ( Sender as TEdit ).Text := StrZero( StrToFloat( txtCod.Text ), 6 ); TEdit( FindComponent( 'ed_cat_' + Copy( ( Sender as TEdit ).Name, 4, 5 ) ) ).Text := txtCat.Text; // salva a aula na tabela with vCpo do begin Clear; Add( 'Aluno' ); Add( 'Instrutor' ); Add( 'Categoria' ); Add( 'Data' ); Add( 'Horario' ); Add( 'Status' ); end; with vVlr do begin Clear; Add( txtCod.Text ); Add( txtCodIns.Text ); Add( #39 + txtCat.Text + #39 ); Add( #39 + FormatDateTime( 'mm/dd/yyyy', RetornaData( ( Sender as TEdit ).Name ) ) + #39 ); Add( #39 + FormatDateTime( 'hh:nn', RetornaHora( ( Sender as TEdit ).Name ) ) + #39 ); Add( '1' ); end; IncluirRegistro( 'Praticas', vCpo, vVlr ); end else begin if ( ( Sender as TEdit ).Text <> txtCod.Text ) then begin ShowMessage( 'Código do Aluno não confere com o Nome do mesmo selecionado!' ); Exit; end; ExcluirRegistro( 'Praticas', 'Aluno=' + ( Sender as TEdit ).Text + ' AND ' + 'Instrutor=' + txtCodIns.Text + ' AND ' + 'Categoria=' + #39 + TEdit( FindComponent( 'ed_cat_' + Copy( ( Sender as TEdit ).Name, 4, 5 ) ) ).Text + #39 + ' AND ' + 'Data=' + #39 + FormatDateTime( 'mm/dd/yyyy', RetornaData( ( Sender as TEdit ).Name ) ) + #39 + ' AND ' + 'Horario=' + #39 + FormatDateTime( 'hh:nn', RetornaHora( ( Sender as TEdit ).Name ) ) + #39 ); ( Sender as TEdit ).Text := ''; TEdit( FindComponent( 'ed_cat_' + Copy( ( Sender as TEdit ).Name, 4, 5 ) ) ).Text := ''; end; ConsultaAula; end; function Tfrmpraticas.RetornaData(edit: String) : TDate;// Função para Retornar as datas var nDia : Integer; begin nDia := StrToInt( Copy( edit, 4, 1 ) ); case nDia of 1 : Result := StrToDate( panDom.Caption ); 2 : Result := StrToDate( panSeg.Caption ); 3 : Result := StrToDate( panTer.Caption ); 4 : Result := StrToDate( panQua.Caption ); 5 : Result := StrToDate( panQui.Caption ); 6 : Result := StrToDate( panSex.Caption ); 7 : Result := StrToDate( panSab.Caption ); end; end; function Tfrmpraticas.RetornaHora(edit: String): TTime;// Função para retornar as horas begin Result := StrToTime( Copy( edit, 5, 2 ) + ':' + Copy( edit, 7, 2 ) ); end; procedure Tfrmpraticas.txtcodinsExit(Sender: TObject); begin ConsultaAgendamento; end; procedure Tfrmpraticas.BloqueioDesbloqueio(Sender: TObject; var Key: Word;// Procedure para bloquear os Horarios Shift: TShiftState); begin if ( Length( Trim( txtCodIns.Text ) ) = 0 ) then Exit; if ( Key = Ord( 'B' ) ) then // Tecla para desbloqueio 'B' begin ( Sender as TEdit ).Text := '**********'; SalvaBloqueio( Sender ); end; if ( Key = Ord( 'D' ) ) then // Tecla para desbloqueio 'D' begin RemoveBloqueio( Sender ); ( Sender as TEdit ).Text := ''; end; end; procedure Tfrmpraticas.RemoveBloqueio( Sender : TObject );// Procedure para excluir os Bloqueio begin ExcluirRegistro( 'Praticas', 'Instrutor=' + txtCodIns.Text + ' AND ' + 'Categoria=' + #39 + 'A' + #39 + ' AND ' + 'Data=' + #39 + FormatDateTime( 'mm/dd/yyyy', RetornaData( ( Sender as TEdit ).Name ) ) + #39 + ' AND ' + 'Horario=' + #39 + FormatDateTime( 'hh:nn', RetornaHora( ( Sender as TEdit ).Name ) ) + #39 + ' AND ' + 'Status=0' ); end; procedure Tfrmpraticas.SalvaBloqueio( Sender : TObject );// Procedure para salvar os Bloqueio begin with vCpo do begin Clear; Add ( 'Aluno' ); Add ( 'Instrutor' ); Add ( 'Categoria' ); Add ( 'Data' ); Add ( 'Horario' ); Add ( 'Status' ); end; with vVlr do begin Clear; Add ( #39 + TxtCod.Text + #39 ); Add ( #39 + TxtCodIns.Text + #39 ); Add ( #39 + TxtCat.Text + #39 ); Add ( #39 + FormatDateTime( 'mm/dd/yyyy', RetornaData( ( Sender as TEdit ).Name ) ) + #39 ); Add ( #39 + FormatDateTime( 'hh:nn', RetornaHora( ( Sender as TEdit ).Name ) ) + #39 ); Add ( '0' ); end; IncluirRegistro( 'Praticas', vCpo, vVlr ); end; procedure Tfrmpraticas.spbalulocClick(Sender: TObject); begin with vcpo do begin clear; add ('Codigo'); add ('Nome'); add ('Cpf'); add ('Processo'); end; with vvlr do begin clear; add ('Codigo'); add ('Nome'); add ('Cpf'); add ('Processo'); end; with tfrmpesquisa.create (application) do begin try tabela := 'Alunos'; camporetorno := 'Codigo'; showmodal; finally free; end; end; if ( Retorno <> '' ) then begin inherited; ConsultaRegistros( 'Alunos', 'Codigo, Nome', 'Codigo=' + Retorno ); LeRegistro(); end; TxtCod.Text := StrZero (StrToFloat(TxtCod.Text), 6); SbpInst.Enabled := True; TxtCod.Enabled := False; end; procedure Tfrmpraticas.LeRegistro; begin txtCod.Text := LeDados ( 'Codigo' ); txtAluno.Text := LeDados ( 'Nome' ); ConsultaAula; end; procedure Tfrmpraticas.SbpInstClick(Sender: TObject); begin with vcpo do begin clear; add ('Codigo'); add ('Nome'); end; with vvlr do begin clear; add ('Codigo'); add ('Nome'); end; with tfrmpesquisa.create (application) do begin try tabela := 'Instrutores'; camporetorno := 'codigo'; showmodal; finally free; end; end; if (retorno<> '') then begin ConsultaRegistros( 'Instrutores', 'Nome', 'Codigo=' + Retorno ); txtCodIns.Text := Retorno; txtNomIns.Text := LeDados ( 'Nome' ); end; ConsultaAgendamento; TxtCodIns.Text := StrZero( StrToFloat( txtCodIns.Text ), 2 ); SpbCat.Enabled := True; TxtCodIns.Enabled := False; end; procedure Tfrmpraticas.SpbCatClick(Sender: TObject); begin with vcpo do begin clear; add ( 'Codigo' ); add ( 'Nome' ); add ( 'Categoria' ); end; with vvlr do begin clear; add ( 'Codigo' ); add ( 'Nome' ); add ( 'Categoria' ); end; with tfrmpesquisa.create (application) do begin try tabela := 'Veiculos'; camporetorno := 'codigo'; showmodal; finally free; end; end; if (retorno<> '') then begin ConsultaRegistros( 'Veiculos', 'Codigo, Categoria, Nome', 'Codigo=' + Retorno ); txtCodCat.Text := Retorno; txtCat.Text := LeDados ('Categoria'); TxtVei.Text := LeDados ('Nome' ); end; TxtCodCat.Text := StrZero( StrToFloat( txtCodCat.Text ), 3 ); SpbAnt.Enabled := True; SpbPro.Enabled := True; SpbImp.Enabled := True; TxtCodCat.Enabled := False; end; procedure Tfrmpraticas.ConsultaAula; Begin With QryPra do Begin Close; Sql.Clear; Sql.Add ('Select P.Aluno, P.Instrutor, P.Data, P.Horario, P.Categoria, P.Aluno From Praticas P,' +'Instrutores I Where P.Aluno=' + txtcod.Text + 'AND P.Status=1 AND I.Codigo=P.Instrutor ORDER BY P.Data, P.Horario'); Open; end; end; procedure Tfrmpraticas.AppEventsMessage(var Msg: TMsg; var Handled: Boolean); // para a a bolinha do mouse rolar var Sentido: SmallInt; WndClass :array[0..128] of char; begin if Msg.message = WM_MOUSEWHEEL then begin GetClassName(Msg.hwnd, WndClass, SizeOf(WndClass)-1); if StrComp(WndClass, 'TDBGrid') = 0 then begin Msg.message := WM_KEYDOWN; Msg.lParam := 0; Sentido := HiWord(Msg.wParam); if Sentido > 0 then Msg.wParam := VK_UP else Msg.wParam := VK_DOWN; end; End; end; procedure Tfrmpraticas.DbgRelDrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState); Begin If odd(linha) then // coloque aqui a sua query ou table begin DbgRel.Canvas.Font.Color:= clBlack; DbgRel.Canvas.Brush.Color:= cl3DLight; end else begin DbgRel.Canvas.Font.Color:= clBlack; DbgRel.Canvas.Brush.Color:= clMoneyGreen; end; DbgRel.Canvas.FillRect(Rect); DbgRel.DefaultDrawColumnCell(Rect, DataCol, Column, State); if ( DataCol = 4 ) then inc( linha ); end; end.
  20. É isso que eu quero sim, desculpe passei os codigos errados> procedure Tfrmpraticas.PreencheEdit( Sender : TObject ); begin if ( Length( Trim( txtCod.Text ) ) = 0 ) then Exit; if ( Length( Trim( ( Sender as TEdit ).Text ) ) = 0 ) then begin if ( ConsultaRegistros( 'Praticas', 'Aluno', 'Aluno=' + txtCod.Text + ' AND ' + 'Data=' + #39 + FormatDateTime( 'mm/dd/yyyy', RetornaData( ( Sender as TEdit ).Name ) ) + #39 + ' AND ' + 'Horario=' + #39 + FormatDateTime( 'hh:nn', RetornaHora( ( Sender as TEdit ).Name ) ) + #39 + ' AND ' + 'Status=1' ) ) then begin ShowMessage( 'Aluno já tem aula marcada neste Horário!' ); Exit; end; ( Sender as TEdit ).Text := StrZero( StrToFloat( txtCod.Text ), 6 ); TEdit( FindComponent( 'ed_cat_' + Copy( ( Sender as TEdit ).Name, 4, 5 ) ) ).Text := txtCat.Text; // salva a aula na tabela with vCpo do begin Clear; Add( 'Aluno' ); Add( 'Instrutor' ); Add( 'Categoria' ); Add( 'Data' ); Add( 'Horario' ); Add( 'Status' ); end; with vVlr do begin Clear; Add( txtCod.Text ); Add( txtCodIns.Text ); Add( #39 + txtCat.Text + #39 ); Add( #39 + FormatDateTime( 'mm/dd/yyyy', RetornaData( ( Sender as TEdit ).Name ) ) + #39 ); Add( #39 + FormatDateTime( 'hh:nn', RetornaHora( ( Sender as TEdit ).Name ) ) + #39 ); Add( '1' ); end; IncluirRegistro( 'Praticas', vCpo, vVlr ); end else begin if ( ( Sender as TEdit ).Text <> txtCod.Text ) then begin ShowMessage( 'Código do Aluno não confere com o Nome do mesmo selecionado!' ); Exit; end; ExcluirRegistro( 'Praticas', 'Aluno=' + ( Sender as TEdit ).Text + ' AND ' + 'Instrutor=' + txtCodIns.Text + ' AND ' + 'Categoria=' + #39 + TEdit( FindComponent( 'ed_cat_' + Copy( ( Sender as TEdit ).Name, 4, 5 ) ) ).Text + #39 + ' AND ' + 'Data=' + #39 + FormatDateTime( 'mm/dd/yyyy', RetornaData( ( Sender as TEdit ).Name ) ) + #39 + ' AND ' + 'Horario=' + #39 + FormatDateTime( 'hh:nn', RetornaHora( ( Sender as TEdit ).Name ) ) + #39 ); ( Sender as TEdit ).Text := ''; TEdit( FindComponent( 'ed_cat_' + Copy( ( Sender as TEdit ).Name, 4, 5 ) ) ).Text := ''; end; ConsultaAula; end;
  21. Esse é o do FormCreate. procedure Tfrmpraticas.FormCreate(Sender: TObject);// Procedure para criar a Tabela var labels : TpsvBorderLabel; edits : TEdit; a, top_edit, top_label, left_edit : Integer; HoraAtual, HoraFinal : TTime; begin dataInicial := Date(); PosicionaSemana; top_edit := 3; top_label := 3; left_edit := 98; // left da primeira fileira dos edits HoraFinal := StrToTime( '22:10:00' ); HoraAtual := StrToTime( '08:00:00' ); while ( ( HoraAtual + StrToTime( '00:50' ) ) < HoraFinal ) do begin // cria a label do horario Labels := TpsvBorderLabel.Create( Self ); with Labels do begin Height := 18; // Tamanho do Labels Border := psvBorderLabel.bsRaised; // bordas do labels Parent := sbxPra; Top := top_label; Left := 16; Caption := FormatDateTime( 'hh:nn', HoraAtual ); Name := 'lbl_' + FormatDateTime( 'hhnn', HoraAtual ); with Font do begin Name := 'Courier New'; Size := 10; Style := [fsBold]; FocusColor := ClBlack; Width := 75; Layout := tlCenter; Alignment := TaCenter; end; end; for a := 1 to 7 do begin // cria o edit do codigo do aluno edits := TEdit.Create( Self ); with edits do begin Cursor := crCross; Parent := sbxPra; Top := top_edit; Left := left_edit; Name := 'ed_' + IntToStr( a ) + FormatDateTime( 'hhnn', HoraAtual ); Width := 65; //Enabled := False; ReadOnly := True; Text := ''; OnDblClick := PreencheEdit; OnKeyDown := BloqueioDesbloqueio; with Font do Begin Height := 15; Name := 'Courier New'; Size := 10; // Style := [fsBold]; end; end; // cria o edit da categoria left_edit := left_edit + 67; // espaço entre o edit codigo e edit categoria edits := TEdit.Create( Self ); with edits do begin Cursor := crCross; Parent := sbxPra; Top := top_edit; Left := left_edit; Name := 'ed_cat_' + IntToStr( a ) + FormatDateTime( 'hhnn', HoraAtual ); Width := 20; //Enabled := False; ReadOnly := True; Text := ''; with Font do Begin Height := 15; Name := 'Courier New'; Size := 10; // Style := [fsBold]; end; end; left_edit := left_edit + 23; // Espaço entre o edit da categoria para o codigo da outra fileira. end; top_label := top_label + 28; // top dos edits top_edit := top_edit + 28; // top dos labels left_edit := 98; // left das demais fileiras dos edits if ( HoraAtual < StrToTime( '17:00:00' ) ) then HoraAtual := HoraAtual + StrToTime( '01:00' ) else HoraAtual := HoraAtual + StrToTime( '00:50' ); end; Application.OnMessage := AppEventsMessage; // Para a movimentação do mouse linha := 1; end;
  22. Jhonas duas perguntas, eu faço isso no formCreate da tabela. E como eu vou fazer com os codigos, para a contagem e atribuir o resultado nos edits?
  23. Estou com um projeto que faço marcação de aulas para auto escola e gostaria de acrescentar algumas utilidades para o usuário sendo um também: Informações: Delphi 07 Firebird 2.0.3 A tabela que eu marco aulas praticas é feita em tempo de execução: Coloquei dois tipos de edits um para aulas de carro e outro moto TxtCarro TxtMoto E mais dois para aulas extras TxtExtCarro TXTExtMoto É assim: Todos os alunos tem direito a 15 aulas de carro e 15 de moto então após ser marcado as 15 aulas ai contasse como aulas extras e registrasse no outro edit. Acho que isso é tudo. Se alguém poder me ajudar nesse tópico agradeço desde já.
×
×
  • Criar Novo...