📄 depotquery.pas
字号:
unit depotquery;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, basequery, DB, StdCtrls, ComCtrls, Grids, DBGrids, ExtCtrls;
type
Tf_depotquery = class(Tf_basequery)
Counter: TComboBox;
Radio1: TRadioButton;
Radio2: TRadioButton;
Depot: TComboBox;
procedure FormShow(Sender: TObject);
procedure QueryClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
f_depotquery: Tf_depotquery;
implementation
uses data;
{$R *.dfm}
procedure Tf_depotquery.FormShow(Sender: TObject);
begin
inherited;
With t_data.Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select depotname from tb_depotinfo');
Open;
end;
while not t_data.Query1.Eof do
begin
Depot.Items.Add(Trim(t_data.Query1.Fields[0].Value));
t_data.Query1.Next;
end;
With t_data.Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select counter from tb_counter');
Open;
end;
while not t_data.Query1.Eof do
begin
Counter.Items.Add(Trim(t_data.Query1.Fields[0].Value));
t_data.Query1.Next;
end;
end;
procedure Tf_depotquery.QueryClick(Sender: TObject);
begin
inherited;
if (Trim(Field.Text)='')or(Trim(Value.Text)='') then
begin
Application.MessageBox('请设置查询条件.','提示',64);
Exit;
end;
if ((Radio1.Checked)and(Depot.ItemIndex = -1))or((Radio2.Checked)and(Counter.ItemIndex = -1)) then
begin
Application.MessageBox('请选择仓库或柜台.','提示',64);
Exit;
end;
With t_data.Query1 do
begin
Close;
SQL.Clear;
SQL.Add('select a.bookname,a.barcode,b.num from tb_bookinfo a inner join ');
if Radio1.Checked then
begin
SQL.Add('tb_bookdepot b on b.depot = :storage and ');
Parameters.ParamByName('Storage').Size := 100;
Parameters.ParamByName('Storage').Value := Trim(Depot.Text);
end
else
begin
SQL.Add('tb_bookcounter b on b.counter = :storage and ');
Parameters.ParamByName('Storage').Size := 100;
Parameters.ParamByName('Storage').Value := Trim(Counter.Text);
end;
case Field.ItemIndex of
0: SQL.Add(' a.bookname = :Value ');
1: SQL.Add(' a.barcode = :Value ');
end;
Parameters.ParamByName('Value').Size := 100;
Parameters.ParamByName('Value').Value := Trim(Value.Text);
Open;
end;
if t_data.Query1.RecordCount>0 then
begin
Source.DataSet := t_data.Query1;
end
else
begin
Source.DataSet := Nil;
t_data.Query1.Close;
Application.MessageBox('没有找到符合条件的记录.','提示',64);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -