A
admin2008
Unregistered / Unconfirmed
GUEST, unregistred user!
这是我综合查询的代码 我这样写下去不是没完没了,都不敢往下写了 如果查询条件多 请大家给我指点一精
procedure Tinhouse_find.SpeedButton1Click(Sender: TObject); //查询
begin
if ypedit.Text<>'' then
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from v_inhouse_find');
sql.Add('where 品名='''+ypedit.Text+'''and (入库日期>='''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date)+'''and 入库日期<='''+FormatDateTime('yyyy-mm-dd',DateTimePicker2.Date)+''')');
open;
end;
end;
if edit2.Text<>'' then
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from v_inhouse_find');
sql.Add('where 入库单号 ='''+edit2.Text+'''and (入库日期>='''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date)+'''and 入库日期<='''+FormatDateTime('yyyy-mm-dd',DateTimePicker2.Date)+''')');
open;
end;
end;
if (ypedit.Text<>'') and(edit2.Text<>'') then
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from v_inhouse_find');
sql.Add('where 品名='''+ypedit.Text+'''and 入库单号 ='''+edit2.Text+'''and (入库日期>='''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date)+'''and 入库日期<='''+FormatDateTime('yyyy-mm-dd',DateTimePicker2.Date)+''')');
open;
end;
end;
if (ypedit.Text<>'') and (edit2.Text<>'') and (vendoredit.Text<>'') and (edit3.Text<>'')and(checkbox2.Checked) then //checkbox2.Checked 是标志
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from v_inhouse_find');
sql.Add('where 品名='''+ypedit.Text+'''and 入库单号 ='''+edit2.Text+'''and 供货单位='''+vendoredit.Text+'''and 批号 ='''+edit3.Text+'''and 标志=1 and (入库日期>='''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date)+'''and 入库日期<='''+FormatDateTime('yyyy-mm-dd',DateTimePicker2.Date)+''')');
open;
end;
end;
procedure Tinhouse_find.SpeedButton1Click(Sender: TObject); //查询
begin
if ypedit.Text<>'' then
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from v_inhouse_find');
sql.Add('where 品名='''+ypedit.Text+'''and (入库日期>='''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date)+'''and 入库日期<='''+FormatDateTime('yyyy-mm-dd',DateTimePicker2.Date)+''')');
open;
end;
end;
if edit2.Text<>'' then
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from v_inhouse_find');
sql.Add('where 入库单号 ='''+edit2.Text+'''and (入库日期>='''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date)+'''and 入库日期<='''+FormatDateTime('yyyy-mm-dd',DateTimePicker2.Date)+''')');
open;
end;
end;
if (ypedit.Text<>'') and(edit2.Text<>'') then
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from v_inhouse_find');
sql.Add('where 品名='''+ypedit.Text+'''and 入库单号 ='''+edit2.Text+'''and (入库日期>='''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date)+'''and 入库日期<='''+FormatDateTime('yyyy-mm-dd',DateTimePicker2.Date)+''')');
open;
end;
end;
if (ypedit.Text<>'') and (edit2.Text<>'') and (vendoredit.Text<>'') and (edit3.Text<>'')and(checkbox2.Checked) then //checkbox2.Checked 是标志
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from v_inhouse_find');
sql.Add('where 品名='''+ypedit.Text+'''and 入库单号 ='''+edit2.Text+'''and 供货单位='''+vendoredit.Text+'''and 批号 ='''+edit3.Text+'''and 标志=1 and (入库日期>='''+FormatDateTime('yyyy-mm-dd',DateTimePicker1.Date)+'''and 入库日期<='''+FormatDateTime('yyyy-mm-dd',DateTimePicker2.Date)+''')');
open;
end;
end;