GARANTIR DESCONTO

Fórum o programa fecha qdo imprimo no quickreport. #270117

25/02/2005

0

Tenho uma maquina win xp, uma aplicacao em delphi a base de dados esta locada na rede. Faço a pesquica gero os graficos no quickreport ´tqrchart´ e aparece tudo nos conformes mas qdo vou imprimir ele finaliza a aplicacao, alguem tem ideia do que seja, nunca passei por isto.


Host

Host

Responder

Posts

25/02/2005

Diogoalles

coloque o código aqui de como vc esta chamando o relatorio.


Responder

Gostei + 0

25/02/2005

Host

Esta é a chamada de um outro form.

//RelProducaoDiaria;
//QuickRep1.PreviewModal;
Application.CreateForm(TFRelProducao, FRelProducao);
//FRelProducao.ShowModal;
FRelProducao.QuickRep1.Preview;
FRelProducao.Free;

no form que vai fazer o prcesso.
depois ele volta pro form anterior e da um preview.

procedure TFRelProducao.FormCreate(Sender: TObject);
var
carrosdia, carrosdefeito, totA, totB, totC : integer;
Qry2:TQuery;
begin
//Data da produção
qrDiaProd.Caption := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataProducao.date ) + ´ a ´ +
formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataFinal.date );
qrlabel5.caption := qrDiaProd.caption;
//Quantidade de carros descarregados
Qry2:=tquery.create(nil);
Qry2.DatabaseName:= FMenu.BaseDados.DatabaseName;
Qry2.SQL.Text := ´select count(*) ´ +
´from bkp_carros ´ +
´where datasaida >= :mydate and datasaida <= :datfim´;
Qry2.ParamByName( ´mydate´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataProducao.date );
Qry2.ParamByName( ´datfim´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataFinal.date );
Qry2.open;
qrProdDiaCarro.Caption := Qry2.fields[ 0 ].AsString + ´ Carros.´;
qrlabel7.Caption := Qry2.fields[ 0 ].asstring + ´ Carros.´;
carrosdia := Qry2.fields[ 0 ].asinteger;
Qry2.free;

//Tipo de Carro - A, B, C

qrTipoCarro.Close;
qrTipoCarro.databasename := FMenu.BaseDados.DatabaseName;
qrTipoCarro.sql.text := ´select tipocarga, count(*) ´ +
´from bkp_carros ´ +
´where datasaida >= :mydate and datasaida <= :datfim´;
qrTipoCarro.ParamByName( ´mydate´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataProducao.date );
qrTipoCarro.ParamByName( ´datfim´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataFinal.date );
case FRelatorios.rgTurno.itemindex of
0 : begin
qrTipoCarro.sql.Add( ´ and ( horasaida >= :HorMin and horasaida < :HorMax ) ´ );
qrTipoCarro.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
qrTipoCarro.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
end;
1 : begin
qrTipoCarro.sql.Add( ´ and ( horasaida >= :HorMin and horasaida < :HorMax ) ´ );
qrTipoCarro.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
qrTipoCarro.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
end;
2 : begin
qrTipoCarro.sql.Add( ´ and ( horasaida >= :HorMin or horasaida < :HorMax ) ´ );
qrTipoCarro.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
qrTipoCarro.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
end;
end;
qrTipoCarro.sql.add( ´group by tipocarga ´ );
qrTipoCarro.open;
//Carros por turno
//Busca qtd turno 1
Qry2:=tquery.create( nil );
Qry2.databasename := FMenu.BaseDados.DatabaseName;
Qry2.sql.text := ´select count(*) ´ +
´from bkp_carros ´ +
´where ( datasaida >= :mydate and datasaida <= :datfim ) ´ +
´ and ( horasaida >= :HorMin and horasaida < :HorMax ) ´;
Qry2.ParamByName( ´mydate´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataProducao.date );
Qry2.ParamByName( ´datfim´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataFinal.date );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
Qry2.open;
totA := Qry2.fields[ 0 ].asinteger;
PieSeries1.Add( Qry2.fields[ 0 ].AsInteger, ´Turno A´, clBlue );
Qry2.free;
//Busca qtd turno 2
Qry2:=tquery.create(nil);
Qry2.databasename := FMenu.BaseDados.DatabaseName;
Qry2.sql.text := ´select count(*) ´ +
´from bkp_carros ´ +
´where ( datasaida >= :mydate and datasaida <= :datfim ) ´ +
´ and ( horasaida >= :HorMin and horasaida < :HorMax ) ´;
Qry2.ParamByName( ´mydate´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataProducao.date );
Qry2.ParamByName( ´datfim´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataFinal.date );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
Qry2.open;
totB := Qry2.fields[ 0 ].asinteger;
PieSeries1.Add( Qry2.fields[ 0 ].AsInteger, ´Turno B´, clGreen );
Qry2.free;

//Busca qtd turno 3
Qry2:=tquery.create( nil );
Qry2.databasename := FMenu.BaseDados.DatabaseName;
Qry2.sql.text := ´select count(*) ´ +
´from bkp_carros ´ +
´where ( datasaida >= :mydate and datasaida <= :datfim ) ´ +
´ and ( horasaida >= :HorMin or horasaida < :HorMax ) ´;
Qry2.ParamByName( ´mydate´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataProducao.date );
Qry2.ParamByName( ´datfim´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataFinal.date );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
Qry2.open;
totC := Qry2.fields[ 0 ].asinteger;
PieSeries1.Add( Qry2.fields[ 0 ].AsInteger, ´Turno C´, clRed );
Qry2.free;

//Carros com defeito
Qry2:=tquery.create(nil);
Qry2.databasename := FMenu.BaseDados.DatabaseName;
Qry2.sql.text := ´select distinct carro, data, hora ´ +
´from bkp_problemacarro ´ +
´where dleitura >= :mydate and dleitura <= :datfim´;
case FRelatorios.rgTurno.itemindex of
0 : begin
Qry2.sql.Add( ´ and ( hleitura >= :HorMin and hleitura < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
carrosdia := totA;
qrProdDiaCarro.Caption := inttostr( totA ) + ´ Carros.´;
qrlabel7.Caption := inttostr( totA ) + ´ Carros.´;
qrTurno.caption := ´TURNO: A´;
qrLabel4.Caption := ´TURNO: A´;
end;
1 : begin
Qry2.sql.Add( ´ and ( hleitura >= :HorMin and hleitura < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
carrosdia := totB;
qrProdDiaCarro.Caption := inttostr( totB ) + ´ Carros.´;
qrlabel7.Caption := inttostr( totB ) + ´ Carros.´;
qrTurno.caption := ´TURNO: B´;
qrLabel4.Caption := ´TURNO: B´;
end;
2 : begin
Qry2.sql.Add( ´ and ( hleitura >= :HorMin or hleitura < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
carrosdia := totC;
qrProdDiaCarro.Caption := inttostr( totC ) + ´ Carros.´;
qrlabel7.Caption := inttostr( totC ) + ´ Carros.´;
qrTurno.caption := ´TURNO: C´;
qrLabel4.Caption := ´TURNO: C´;
end;
else
qrTurno.caption := ´TURNO: Todos´;
qrLabel4.Caption := ´TURNO: Todos´;
end;
Qry2.ParamByName( ´mydate´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataProducao.date );
Qry2.ParamByName( ´datfim´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataFinal.date );
Qry2.open;
carrosdefeito := Qry2.recordcount;
PieSeries2.Add( carrosdia - carrosdefeito, ´Sem Problema´, clBlue );
PieSeries2.Add( carrosdefeito, ´Com Problema´, clRed );
Qry2.free;


//Carros - Ecoat
Qry2:=tquery.create( nil );
Qry2.databasename := FMenu.BaseDados.DatabaseName;
Qry2.sql.text := ´select distinct carro, data, hora ´ +
´from bkp_carros ´ +
´where data >= :mydate and data <= :datfim´;
Qry2.ParamByName( ´mydate´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataProducao.date );
Qry2.ParamByName( ´datfim´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataFinal.date );
case FRelatorios.rgTurno.itemindex of
0 : begin
Qry2.sql.Add( ´ and ( horasaida >= :HorMin and horasaida < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
end;
1 : begin
Qry2.sql.Add( ´ and ( horasaida >= :HorMin and horasaida < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
end;
2 : begin
Qry2.sql.Add( ´ and ( horasaida >= :HorMin or horasaida < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
end;
end;
Qry2.open;
carrosdia := Qry2.recordcount;
Qry2.free;

//Carros com defeito - Ecoat
Qry2:=tquery.create(nil);
Qry2.databasename := FMenu.BaseDados.DatabaseName;
Qry2.sql.text := ´select distinct carro, data, hora ´ +
´from bkp_problemacarro ´ +
´where ( dleitura >= :mydate and dleitura <= :datfim ) and onde = ´´E´´´;
Qry2.ParamByName( ´mydate´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataProducao.date );
Qry2.ParamByName( ´datfim´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataFinal.date );
case FRelatorios.rgTurno.itemindex of
0 : begin
Qry2.sql.Add( ´ and ( hleitura >= :HorMin and hleitura < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
end;
1 : begin
Qry2.sql.Add( ´ and ( hleitura >= :HorMin and hleitura < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
end;
2 : begin
Qry2.sql.Add( ´ and ( hleitura >= :HorMin or hleitura < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
end;
end;
Qry2.open;
carrosdefeito := Qry2.recordcount;
PieSeries3.Add( carrosdia - carrosdefeito, ´Ok´ , clBlue );
PieSeries3.Add( carrosdefeito, ´Não Ok´, clRed );
Qry2.free;

//Carros com defeito - Topcoat
Qry2:=tquery.create(nil);
Qry2.DatabaseName := FMenu.BaseDados.DatabaseName;
Qry2.SQL.Text := ´select distinct carro, data, hora ´ +
´from bkp_problemacarro ´ +
´where ( dleitura >= :mydate and dleitura <= :datfim ) and onde = ´´A´´´;
Qry2.ParamByName( ´mydate´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataProducao.date );
Qry2.ParamByName( ´datfim´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataFinal.date );
case FRelatorios.rgTurno.itemindex of
0 : begin
Qry2.sql.Add( ´ and ( hleitura >= :HorMin and hleitura < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
end;
1 : begin
Qry2.sql.Add( ´ and ( hleitura >= :HorMin and hleitura < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
end;
2 : begin
Qry2.sql.Add( ´ and ( hleitura >= :HorMin or hleitura < :HorMax ) ´ );
Qry2.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
Qry2.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
end;
end;
Qry2.open;
carrosdefeito := Qry2.recordcount;
PieSeries4.Add( carrosdia - carrosdefeito, ´Ok´ , clBlue );
PieSeries4.Add( carrosdefeito, ´Não Ok´, clRed );
Qry2.free;
end;

procedure TFRelProducao.QRBand2BeforePrint(Sender: TQRCustomBand; var PrintBand: Boolean);
var
Qry3:TQuery;
begin
//Problemas do E-Coat
PieSeries5.Clear;
Qry3:=TQuery.Create(nil);
Qry3.databasename:= FMenu.BaseDados.DatabaseName;
Qry3.sql.text:= ´ select p.descricao, count(*) ´ +
´ from problemas p, bkp_problemacarro pc ´ +
´ where pc.onde = ´´E´´ and p.problema = pc.problema ´ +
´ and (dleitura >= :mydate and dleitura <= :datfim ) ´;
Qry3.ParamByName(´mydate´).AsString := formatdatetime(´dd/mm/yyyy´, FRelatorios.DataProducao.date );
Qry3.ParamByName(´datfim´).AsString := formatdatetime(´dd/mm/yyyy´, FRelatorios.DataFinal.date );
case FRelatorios.rgTurno.itemindex of
0 : begin
Qry3.sql.Add(´ and ( hleitura >= :HorMin and hleitura < :HorMax ) ´);
Qry3.ParamByName(´HorMin´).AsString := formatdatetime(´hh:mm:ss´, strtotime( ´06:15:00´) );
Qry3.ParamByName(´HorMax´).AsString := formatdatetime(´hh:mm:ss´, strtotime( ´14:39:00´) );
end;
1 : begin
Qry3.sql.Add( ´ and ( hleitura >= :HorMin and hleitura < :HorMax ) ´ );
Qry3.ParamByName( ´HorMin´ ).AsString := formatdatetime(´hh:mm:ss´, strtotime(´14:39:00´) );
Qry3.ParamByName( ´HorMax´ ).AsString := formatdatetime(´hh:mm:ss´, strtotime(´23:20:00´) );
end;
2 : begin
Qry3.sql.Add( ´ and ( hleitura >= :HorMin or hleitura < :HorMax ) ´ );
Qry3.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
Qry3.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
end;
end;
Qry3.sql.add( ´group by p.descricao ´ );
Qry3.open;
while not Qry3.eof do begin
//if Qry.fields[1].AsString=´1´ then
//PieSeries5.add(0,Qry.fields[ 0 ].AsString);
//else
PieSeries5.add( Qry3.fields[ 1 ].AsInteger, Qry3.fields[ 0 ].AsString );
Qry3.next;
end;
Qry3.free;
//Problemas do Top-Coat
Qry3:=TQuery.Create(nil);
PieSeries6.Clear;
Qry3.databasename := FMenu.BaseDados.DatabaseName;
Qry3.sql.text := ´select p.descricao, count(*) ´ +
´from problemas p, bkp_problemacarro pc ´ +
´where pc.onde = ´´A´´ and p.problema = pc.problema ´ +
´ and ( dleitura >= :mydate and dleitura <= :datfim )´;
Qry3.ParamByName( ´mydate´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataProducao.date );
Qry3.ParamByName( ´datfim´ ).AsString := formatdatetime( ´dd/mm/yyyy´, FRelatorios.DataFinal.date );
case FRelatorios.rgTurno.itemindex of
0 : begin
Qry3.sql.Add( ´ and ( hleitura >= :HorMin and hleitura < :HorMax ) ´ );
Qry3.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
Qry3.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
end;
1 : begin
Qry3.sql.Add( ´ and ( hleitura >= :HorMin and hleitura < :HorMax ) ´ );
Qry3.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´14:39:00´ ) );
Qry3.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
end;
2 : begin
Qry3.sql.Add( ´ and ( hleitura >= :HorMin or hleitura < :HorMax ) ´ );
Qry3.ParamByName( ´HorMin´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´23:20:00´ ) );
Qry3.ParamByName( ´HorMax´ ).AsString := formatdatetime( ´hh:mm:ss´, strtotime( ´06:15:00´ ) );
end;
end;
Qry3.sql.add( ´group by p.descricao ´ );
Qry3.open;
while not Qry3.eof do begin
//if Qry.fields[ 1 ].AsInteger=1 then
//PieSeries6.add(0,Qry.fields[0].AsString);
//else
PieSeries6.add( Qry3.fields[ 1 ].AsInteger, Qry3.fields[ 0 ].AsString );
Qry3.next;
end;
Qry3.free;
end;


Responder

Gostei + 0

25/02/2005

Host

alguem se habilita....???


Responder

Gostei + 0

25/02/2005

Pistesil

Oi a todos.
Eu estou comecando agora a programar em delphi e eu gostaria de saber pq vc esta utilzando essa linha:
FRelProducao.Free;

Desde ja agradeco.[/code]


Responder

Gostei + 0

25/02/2005

Pistesil

Oi a todos.
Eu estou comecando agora a programar em delphi e eu gostaria de saber pq vc esta utilzando essa linha:
FRelProducao.Free;

Desde ja agradeco.


Responder

Gostei + 0

25/02/2005

Aroldo Zanela

Colega,

Free é o método mais seguro para chamar o destruidor do objeto, pois antes de destruir, ele verifica se o objeto é diferente de Nil.

Qual é a versão do Delphi? As versões anteriores ao Delphi 6 produzem AV em sistemas operacionais NT, 2K e XP.


Responder

Gostei + 0

26/02/2005

Pistesil

Obrigado pela explicacao Aroldo Zanela
Eu tenho uma outra duvida, vc poderia me ajudar?
O que eu preciso fazer para que o free seja executado, deixa eu explicar melhor, como antes dele tem um preview o que deve ser feito para que o programa passe do preview para o free (fechar o form, executar o que esta no onpreview, imprimir, ou alguma outra coisa) .
Desde ja agradeco pela atencao.


Responder

Gostei + 0

26/02/2005

Codigodelphi

a impressora e local ou voce tem mapeada de outra maquina?
Se for mapada e a maquina estiver desligada pode ser isso.
ou se voce nao tiver impressora instalada tambem pode ser.


Responder

Gostei + 0

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

Aceitar