📄 jh_sp_find_unit.pas
字号:
unit jh_sp_find_unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, Grids, DBGrids, StdCtrls, Buttons;
type
Tjh_sp_find_form = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Edit1: TEdit;
DBGrid1: TDBGrid;
StatusBar1: TStatusBar;
DBGrid2: TDBGrid;
DBGrid3: TDBGrid;
DBGrid4: TDBGrid;
procedure FormCreate(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure DBGrid1DblClick(Sender: TObject);
procedure DBGrid2DblClick(Sender: TObject);
procedure DBGrid3DblClick(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure DBGrid4DblClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
jh_sp_find_form: Tjh_sp_find_form;
implementation
uses data_unit, spzl_unit, jh_unit, jh_th_unit, khth_unit, xsh_unit;
{$R *.dfm}
procedure Tjh_sp_find_form.FormCreate(Sender: TObject);
begin
self.Top :=150;
self.Left :=30;
self.Height :=300;
self.Width :=703;
self.DBGrid1.Visible :=true;
self.DBGrid2.Visible :=false;
self.DBGrid3.Visible :=false;
self.DBGrid4.Visible :=false;
with database do
begin
adoq1.Connection :=adoc;
adoq1.SQL.Clear ;
adoq1.SQL.Add('select * from spzl ');
adoq1.active:=true;
statusbar1.Panels[1].Text :=inttostr(adoq1.Recordset.RecordCount);
datas1.DataSet :=adoq1;
dbgrid1.DataSource:=datas1;
dbgrid2.DataSource:=datas1;
dbgrid3.DataSource:=datas1;
dbgrid4.DataSource:=datas1;
end;
end;
procedure Tjh_sp_find_form.SpeedButton1Click(Sender: TObject);
begin
with database do
begin
adoq3.Connection :=adoc;
adoq3.SQL.Clear;
case combobox1.ItemIndex of
0:
begin
case combobox2.ItemIndex of
0:
begin
adoq3.SQL.Add('select * from spzl where 商品编码=:spbm');
adoq3.Parameters.ParamByName('spbm').Value :=edit1.Text;
end;
1:
begin
adoq3.SQL.Add('select * from spzl where 商品编码 like :spbm2');
adoq3.Parameters.ParamByName('spbm2').Value :=edit1.Text+'%';
end;
end;
end;
1:
begin
case combobox2.ItemIndex of
0:
begin
adoq3.SQL.Add('select * from spzl where 商品名称=:mc');
adoq3.Parameters.ParamByName('mc').Value :=edit1.Text;
end;
1:
begin
adoq3.SQL.Add('select * from spzl where 商品名称 like :mc2');
adoq3.Parameters.ParamByName('mc2').Value :=edit1.Text+'%';
end;
end;
end;
2:
begin
case combobox2.ItemIndex of
0:
begin
adoq3.SQL.Add('select * from spzl where 拼音简码=:jm');
adoq3.Parameters.ParamByName('jm').Value :=edit1.Text;
end;
1:
begin
adoq3.SQL.Add('select * from spzl where 拼音简码 like :jm2');
adoq3.Parameters.ParamByName('jm2').Value :=edit1.Text+'%';
end;
end;
end
else
begin
adoq3.SQL.Clear ;
adoq3.SQL.Add('select * from spzl order by 商品编码');
end;
end;
adoq3.Active :=true;
if adoq3.Recordset.RecordCount >0 then
begin
datas2.DataSet :=nil;
datas2.DataSet :=adoq3;
//self.Hide ;
if dbgrid1.Visible then dbgrid1.DataSource:=datas2;
if dbgrid2.Visible then dbgrid2.DataSource:=datas2;
if dbgrid3.Visible then dbgrid3.DataSource:=datas2;
if dbgrid4.Visible then dbgrid1.DataSource:=datas2;
//if dbgrid5.Visible then dbgrid1.DataSource:=datas2;
//spzl_form.statusbar1.Panels[1].Text :=inttostr(adoq3.Recordset.RecordCount);
end
else
begin
showmessage('无此记录!');
end;
end;
end;
procedure Tjh_sp_find_form.SpeedButton3Click(Sender: TObject);
begin
spzl_form:=Tspzl_form.create(application);
spzl_form.show;
end;
procedure Tjh_sp_find_form.SpeedButton2Click(Sender: TObject);
begin
close;
end;
procedure Tjh_sp_find_form.DBGrid1DblClick(Sender: TObject);
begin
if dbgrid1.DataSource.DataSet.RecordCount>0 then
begin
jh_form.Edit6.Text:=dbgrid1.DataSource.DataSet.FieldValues['拼音简码'];
jh_form.Edit7.Text:=dbgrid1.DataSource.DataSet.FieldValues['商品编码'];
jh_form.Edit8.Text:=dbgrid1.DataSource.DataSet.FieldValues['商品名称'];
jh_form.Edit9.Text:=dbgrid1.DataSource.DataSet.FieldValues['类别'];
jh_form.Edit10.Text:=dbgrid1.DataSource.DataSet.FieldValues['规格'];
jh_form.Edit11.Text:=dbgrid1.DataSource.DataSet.FieldValues['型号'];
jh_form.Edit12.Text:=dbgrid1.DataSource.DataSet.FieldValues['单位'];
jh_form.Edit13.SetFocus ;
dbgrid1.DataSource.DataSet :=nil;
self.Hide ;
end
else
showmessage('无此记录!');
end;
procedure Tjh_sp_find_form.DBGrid2DblClick(Sender: TObject);
begin
if dbgrid2.DataSource.DataSet.RecordCount>0 then
begin
jh_th_form.Edit6.Text:=dbgrid2.DataSource.DataSet.FieldValues['拼音简码'];
jh_th_form.Edit7.Text:=dbgrid2.DataSource.DataSet.FieldValues['商品编码'];
jh_th_form.Edit8.Text:=dbgrid2.DataSource.DataSet.FieldValues['商品名称'];
jh_th_form.Edit9.Text:=dbgrid2.DataSource.DataSet.FieldValues['类别'];
jh_th_form.Edit10.Text:=dbgrid2.DataSource.DataSet.FieldValues['规格'];
jh_th_form.Edit11.Text:=dbgrid2.DataSource.DataSet.FieldValues['型号'];
jh_th_form.Edit12.Text:=dbgrid2.DataSource.DataSet.FieldValues['单位'];
jh_th_form.Edit13.SetFocus ;
dbgrid1.DataSource.DataSet :=nil;
self.Hide ;
end
else
showmessage('无此记录!');
end;
procedure Tjh_sp_find_form.DBGrid3DblClick(Sender: TObject);
begin
if dbgrid3.DataSource.DataSet.RecordCount>0 then
begin
khth_form.Edit6.Text:=dbgrid3.DataSource.DataSet.FieldValues['拼音简码'];
khth_form.Edit7.Text:=dbgrid3.DataSource.DataSet.FieldValues['商品编码'];
khth_form.Edit8.Text:=dbgrid3.DataSource.DataSet.FieldValues['商品名称'];
khth_form.Edit9.Text:=dbgrid3.DataSource.DataSet.FieldValues['类别'];
khth_form.Edit10.Text:=dbgrid3.DataSource.DataSet.FieldValues['规格'];
khth_form.Edit11.Text:=dbgrid3.DataSource.DataSet.FieldValues['型号'];
khth_form.Edit12.Text:=dbgrid3.DataSource.DataSet.FieldValues['单位'];
khth_form.Edit13.SetFocus ;
dbgrid3.DataSource.DataSet :=nil;
self.Hide ;
end
else
showmessage('无此记录!');
end;
procedure Tjh_sp_find_form.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
speedbutton1click(nil);
end;
procedure Tjh_sp_find_form.DBGrid4DblClick(Sender: TObject);
begin
if dbgrid4.DataSource.DataSet.RecordCount>0 then
begin
xsh_form.Edit6.Text:=dbgrid4.DataSource.DataSet.FieldValues['拼音简码'];
xsh_form.Edit7.Text:=dbgrid4.DataSource.DataSet.FieldValues['商品编码'];
xsh_form.Edit8.Text:=dbgrid4.DataSource.DataSet.FieldValues['商品名称'];
xsh_form.Edit9.Text:=dbgrid4.DataSource.DataSet.FieldValues['类别'];
xsh_form.Edit10.Text:=dbgrid4.DataSource.DataSet.FieldValues['规格'];
xsh_form.Edit11.Text:=dbgrid4.DataSource.DataSet.FieldValues['型号'];
xsh_form.Edit12.Text:=dbgrid4.DataSource.DataSet.FieldValues['单位'];
xsh_form.Edit13.SetFocus ;
dbgrid4.DataSource.DataSet :=nil;
self.Hide ;
end
else
showmessage('无此记录!');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -