Consulta em Query - filtro não funciona qdo é d campo Código

Delphi

07/04/2006

Tenho uma Query em uma consulta, que consulta pedidos de serviços, e fiz alguns, mas tem um q não quer dar certo, ele traz sempre dois pedidos repetidos do mesmo pedido depois q eu coloquei ele, e não estou conseguindo achar como fazer, ele pega a tabela de Servicos e vincula com a de Pedidos, então faço filtro de um campo código, é esse q não dá certo, qdo eu pego campos como de String dá certo mas com Integer não dá. Qdo nao discrimino esse campo todos funcionam corretamente mas qdo faço esse filtro sai dois pedidos, os pedidos se repetem.

Minha Query está assim: ´VarBit´ q não funciona

With QryPedidos Do
Begin
SQL.clear;
SQL.Add(´Select Pedidos.Numero, Pedidos.DataPed,Pedidos.Situacao,Pedidos.Geral,Clientes.Nome,Pedidos.OS,FormaPag.Descricao,Pedidos.Entregue,Pedidos.Faturado´);
if (Edit2.Text <> ´´)or(Edit3.Text <> ´´)or(DBLookupComboBox3.Text <> ´´) then
SQL.Add(´From Pedidos,Clientes,FormaPag,ItensMO´)
else
SQL.Add(´From Pedidos,Clientes,FormaPag´);
SQL.Add(´Where Pedidos.CodCliente=Clientes.Codigo´);
SQL.Add(´and Upper(Clientes.Nome) Like Upper(:VarCliente)´);
SQL.Add(´and Pedidos.DataPed Between :VarDataI and :VarDataF´);
SQL.Add(´and FormaPag.Codigo = Pedidos.CodFormaPag´);
if (Edit2.Text <> ´´)or(Edit3.Text <> ´´)or(DBLookupComboBox3.Text <> ´´) then
SQL.Add(´and Pedidos.Numero = ItensMO.NroPed´);
if Edit2.Text <> ´´ then
SQL.Add(´and Upper(ItensMO.Serie) Like Upper(:VarSerie)´);
if Edit3.Text <> ´´ then
SQL.Add(´and ItensMO.Dot =:VarDot´);
if DBLookupComboBox3.Text <> ´´ then
SQL.Add(´and ItensMO.CodBitola =:VarBit´); //ESSE Q NAO FUNCIONA
if RadioGroup1.ItemIndex <> 2 then
SQL.Add(´and Pedidos.Entregue =:VarEnt´);
if RadioGroup2.ItemIndex <> 2 then
SQL.Add(´and Pedidos.Faturado =:VarFat´);
if Edit1.Text <> ´´ then
SQL.Add(´and Pedidos.OS =:VarCod´);
SQL.Add(´Order by Pedidos.DataPed, Clientes.Nome´);
// tb_tmp.IndexDefs.Add(´idx1´,´Total´,[ixDescending]);
end;
// tb_tmp.IndexName := ´idx1´;
QryPedidos.ParamByName(´VarCliente´).AsString:=DBLookupCombo1.Text+´¬´;
QryPedidos.ParamByName(´VarDataI´).AsDate:=Data1.Date;
QryPedidos.ParamByName(´VarDataF´).AsDate:=Data2.Date;
if (RadioGroup1.ItemIndex = 0)and(RadioGroup1.ItemIndex <> 2) then
QryPedidos.ParamByName(´VarEnt´).AsBoolean:=True;
if (RadioGroup1.ItemIndex = 1)and(RadioGroup1.ItemIndex <> 2) then
QryPedidos.ParamByName(´VarEnt´).AsBoolean:=False;
if (RadioGroup2.ItemIndex = 0)and(RadioGroup2.ItemIndex <> 2) then
QryPedidos.ParamByName(´VarFat´).AsBoolean:=True;
if (RadioGroup2.ItemIndex = 1)and(RadioGroup2.ItemIndex <> 2) then
QryPedidos.ParamByName(´VarFat´).AsBoolean:=False;
if Edit2.Text <> ´´ then
QryPedidos.ParamByName(´VarSerie´).AsString:=Edit2.Text+´¬´;
if Edit3.Text <> ´´ then
QryPedidos.ParamByName(´VarDot´).AsInteger:=StrToInt(Edit3.Text);
//////
if DBLookupComboBox3.Text <> ´´ then
QryPedidos.ParamByName(´VarBit´).AsInteger:=StrToInt(DBEdit1.Text);
//ESSE Q NAO FUNCIONA
/////
if Edit1.Text <> ´´ then
QryPedidos.ParamByName(´VarCod´).AsString:=(Edit1.Text);

QryPedidos.Prepare;
QryPedidos.Open;


Janete

Janete

Curtidas 0

Respostas

Janete

Janete

07/04/2006

Tenho uma Query em uma consulta, que consulta pedidos de serviços, e fiz alguns, mas tem um q não quer dar certo, ele traz sempre dois pedidos repetidos do mesmo pedido depois q eu coloquei ele, e não estou conseguindo achar como fazer, ele pega a tabela de Servicos e vincula com a de Pedidos, então faço filtro de um campo código, é esse q não dá certo, qdo eu pego campos como de String dá certo mas com Integer não dá. Qdo nao discrimino esse campo todos funcionam corretamente mas qdo faço esse filtro sai dois pedidos, os pedidos se repetem. Minha Query está assim: ´VarBit´ q não funciona With QryPedidos Do Begin SQL.clear; SQL.Add(´Select Pedidos.Numero, Pedidos.DataPed,Pedidos.Situacao,Pedidos.Geral,Clientes.Nome,Pedidos.OS,FormaPag.Descricao,Pedidos.Entregue,Pedidos.Faturado´); if (Edit2.Text <> ´´)or(Edit3.Text <> ´´)or(DBLookupComboBox3.Text <> ´´) then SQL.Add(´From Pedidos,Clientes,FormaPag,ItensMO´) else SQL.Add(´From Pedidos,Clientes,FormaPag´); SQL.Add(´Where Pedidos.CodCliente=Clientes.Codigo´); SQL.Add(´and Upper(Clientes.Nome) Like Upper(:VarCliente)´); SQL.Add(´and Pedidos.DataPed Between :VarDataI and :VarDataF´); SQL.Add(´and FormaPag.Codigo = Pedidos.CodFormaPag´); if (Edit2.Text <> ´´)or(Edit3.Text <> ´´)or(DBLookupComboBox3.Text <> ´´) then SQL.Add(´and Pedidos.Numero = ItensMO.NroPed´); if Edit2.Text <> ´´ then SQL.Add(´and Upper(ItensMO.Serie) Like Upper(:VarSerie)´); if Edit3.Text <> ´´ then SQL.Add(´and ItensMO.Dot =:VarDot´); if DBLookupComboBox3.Text <> ´´ then SQL.Add(´and ItensMO.CodBitola =:VarBit´); //ESSE Q NAO FUNCIONA if RadioGroup1.ItemIndex <> 2 then SQL.Add(´and Pedidos.Entregue =:VarEnt´); if RadioGroup2.ItemIndex <> 2 then SQL.Add(´and Pedidos.Faturado =:VarFat´); if Edit1.Text <> ´´ then SQL.Add(´and Pedidos.OS =:VarCod´); SQL.Add(´Order by Pedidos.DataPed, Clientes.Nome´); // tb_tmp.IndexDefs.Add(´idx1´,´Total´,[ixDescending]); end; // tb_tmp.IndexName := ´idx1´; QryPedidos.ParamByName(´VarCliente´).AsString:=DBLookupCombo1.Text+´¬´; QryPedidos.ParamByName(´VarDataI´).AsDate:=Data1.Date; QryPedidos.ParamByName(´VarDataF´).AsDate:=Data2.Date; if (RadioGroup1.ItemIndex = 0)and(RadioGroup1.ItemIndex <> 2) then QryPedidos.ParamByName(´VarEnt´).AsBoolean:=True; if (RadioGroup1.ItemIndex = 1)and(RadioGroup1.ItemIndex <> 2) then QryPedidos.ParamByName(´VarEnt´).AsBoolean:=False; if (RadioGroup2.ItemIndex = 0)and(RadioGroup2.ItemIndex <> 2) then QryPedidos.ParamByName(´VarFat´).AsBoolean:=True; if (RadioGroup2.ItemIndex = 1)and(RadioGroup2.ItemIndex <> 2) then QryPedidos.ParamByName(´VarFat´).AsBoolean:=False; if Edit2.Text <> ´´ then QryPedidos.ParamByName(´VarSerie´).AsString:=Edit2.Text+´¬´; if Edit3.Text <> ´´ then QryPedidos.ParamByName(´VarDot´).AsInteger:=StrToInt(Edit3.Text); ////// if DBLookupComboBox3.Text <> ´´ then QryPedidos.ParamByName(´VarBit´).AsInteger:=StrToInt(DBEdit1.Text); //ESSE Q NAO FUNCIONA ///// if Edit1.Text <> ´´ then QryPedidos.ParamByName(´VarCod´).AsString:=(Edit1.Text); QryPedidos.Prepare; QryPedidos.Open;


sobe


GOSTEI 0
Janete

Janete

07/04/2006

[quote:e07f842d2a=´Janete´]Tenho uma Query em uma consulta, que consulta pedidos de serviços, e fiz alguns, mas tem um q não quer dar certo, ele traz sempre dois pedidos repetidos do mesmo pedido depois q eu coloquei ele, e não estou conseguindo achar como fazer, ele pega a tabela de Servicos e vincula com a de Pedidos, então faço filtro de um campo código, é esse q não dá certo, qdo eu pego campos como de String dá certo mas com Integer não dá. Qdo nao discrimino esse campo todos funcionam corretamente mas qdo faço esse filtro sai dois pedidos, os pedidos se repetem. Minha Query está assim: ´VarBit´ q não funciona With QryPedidos Do Begin SQL.clear; SQL.Add(´Select Pedidos.Numero, Pedidos.DataPed,Pedidos.Situacao,Pedidos.Geral,Clientes.Nome,Pedidos.OS,FormaPag.Descricao,Pedidos.Entregue,Pedidos.Faturado´); if (Edit2.Text <> ´´)or(Edit3.Text <> ´´)or(DBLookupComboBox3.Text <> ´´) then SQL.Add(´From Pedidos,Clientes,FormaPag,ItensMO´) else SQL.Add(´From Pedidos,Clientes,FormaPag´); SQL.Add(´Where Pedidos.CodCliente=Clientes.Codigo´); SQL.Add(´and Upper(Clientes.Nome) Like Upper(:VarCliente)´); SQL.Add(´and Pedidos.DataPed Between :VarDataI and :VarDataF´); SQL.Add(´and FormaPag.Codigo = Pedidos.CodFormaPag´); if (Edit2.Text <> ´´)or(Edit3.Text <> ´´)or(DBLookupComboBox3.Text <> ´´) then SQL.Add(´and Pedidos.Numero = ItensMO.NroPed´); if Edit2.Text <> ´´ then SQL.Add(´and Upper(ItensMO.Serie) Like Upper(:VarSerie)´); if Edit3.Text <> ´´ then SQL.Add(´and ItensMO.Dot =:VarDot´); if DBLookupComboBox3.Text <> ´´ then SQL.Add(´and ItensMO.CodBitola =:VarBit´); //ESSE Q NAO FUNCIONA if RadioGroup1.ItemIndex <> 2 then SQL.Add(´and Pedidos.Entregue =:VarEnt´); if RadioGroup2.ItemIndex <> 2 then SQL.Add(´and Pedidos.Faturado =:VarFat´); if Edit1.Text <> ´´ then SQL.Add(´and Pedidos.OS =:VarCod´); SQL.Add(´Order by Pedidos.DataPed, Clientes.Nome´); // tb_tmp.IndexDefs.Add(´idx1´,´Total´,[ixDescending]); end; // tb_tmp.IndexName := ´idx1´; QryPedidos.ParamByName(´VarCliente´).AsString:=DBLookupCombo1.Text+´¬´; QryPedidos.ParamByName(´VarDataI´).AsDate:=Data1.Date; QryPedidos.ParamByName(´VarDataF´).AsDate:=Data2.Date; if (RadioGroup1.ItemIndex = 0)and(RadioGroup1.ItemIndex <> 2) then QryPedidos.ParamByName(´VarEnt´).AsBoolean:=True; if (RadioGroup1.ItemIndex = 1)and(RadioGroup1.ItemIndex <> 2) then QryPedidos.ParamByName(´VarEnt´).AsBoolean:=False; if (RadioGroup2.ItemIndex = 0)and(RadioGroup2.ItemIndex <> 2) then QryPedidos.ParamByName(´VarFat´).AsBoolean:=True; if (RadioGroup2.ItemIndex = 1)and(RadioGroup2.ItemIndex <> 2) then QryPedidos.ParamByName(´VarFat´).AsBoolean:=False; if Edit2.Text <> ´´ then QryPedidos.ParamByName(´VarSerie´).AsString:=Edit2.Text+´¬´; if Edit3.Text <> ´´ then QryPedidos.ParamByName(´VarDot´).AsInteger:=StrToInt(Edit3.Text); ////// if DBLookupComboBox3.Text <> ´´ then QryPedidos.ParamByName(´VarBit´).AsInteger:=StrToInt(DBEdit1.Text); //ESSE Q NAO FUNCIONA ///// if Edit1.Text <> ´´ then QryPedidos.ParamByName(´VarCod´).AsString:=(Edit1.Text); QryPedidos.Prepare; QryPedidos.Open;


sobe[/quote:e07f842d2a]
sobe


GOSTEI 0
POSTAR