📄 jh_jhdh_find_unit.pas
字号:
unit jh_jhdh_find_unit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, Buttons, ComCtrls;
type
Tjh_jhdh_find_form = class(TForm)
GroupBox1: TGroupBox;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Edit1: TEdit;
StatusBar1: TStatusBar;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
DBGrid1: TDBGrid;
DBGrid2: TDBGrid;
Edit2: TEdit;
DBGrid3: TDBGrid;
DBGrid4: TDBGrid;
procedure FormCreate(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
procedure DBGrid1DblClick(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure DBGrid3CellClick(Column: TColumn);
procedure SpeedButton1Click(Sender: TObject);
procedure DBGrid3DblClick(Sender: TObject);
procedure Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
end;
var
jh_jhdh_find_form: Tjh_jhdh_find_form;
implementation
uses data_unit, jh_unit, xsh_unit;
{$R *.dfm}
procedure Tjh_jhdh_find_form.FormCreate(Sender: TObject);
begin
self.Top :=80;
self.Left :=40;
self.ClientHeight :=450;
self.ClientWidth :=720;
with database do
begin
adoq1.Connection :=adoc;
adoq2.Connection :=adoc;
adoq1.SQL.Clear ;
adoq2.SQL.Clear ;
adoq1.SQL.Add('select distinct 录单日期,单据编码,经手人,供货商名称,备注 from jhd ');
adoq1.active:=true;
statusbar1.Panels[1].Text :=inttostr(adoq1.Recordset.RecordCount);
adoq2.SQL.Add('select distinct 录单日期,单据编码,经手人,供货商名称,备注 from xshd');
adoq2.Active :=true;
datas1.DataSet :=adoq1;
datas2.DataSet :=adoq2;
dbgrid1.DataSource:=datas1;
dbgrid3.DataSource :=datas2;
dbgrid1.Visible :=true;
dbgrid2.Visible :=true;
dbgrid3.Visible :=false;
dbgrid4.Visible :=false;
end;
end;
procedure Tjh_jhdh_find_form.DBGrid1CellClick(Column: TColumn);
begin
dbgrid2.Visible :=true;
dbgrid3.Visible :=false;
dbgrid4.Visible :=false;
if dbgrid1.DataSource.DataSet.RecordCount>0 then
begin
edit2.Text:=dbgrid1.DataSource.DataSet.FieldValues['单据编码'];
with database do
begin
adoq6.Connection :=adoc;
adoq6.SQL.Clear ;
adoq6.SQL.Add('select 商品简码,商品编码,商品名称,类别,规格,型号,单位 from jhd where 单据编码=:djbm');
adoq6.Parameters.ParamByName('djbm').Value :=edit2.text;
adoq6.Active :=true;
datas6.DataSet :=adoq6;
dbgrid2.DataSource:=datas6;
end;
end;
end;
procedure Tjh_jhdh_find_form.DBGrid1DblClick(Sender: TObject);
begin
if dbgrid1.DataSource.DataSet.RecordCount>0 then
begin
jh_form.Edit18.Text:=dbgrid1.DataSource.DataSet.FieldValues['单据编码'];
jh_form.combobox3.SetFocus ;
self.Hide ;
end
else
showmessage('无此记录!');
end;
procedure Tjh_jhdh_find_form.SpeedButton2Click(Sender: TObject);
begin
close;
end;
procedure Tjh_jhdh_find_form.DBGrid3CellClick(Column: TColumn);
begin
if dbgrid3.DataSource.DataSet.RecordCount>0 then
begin
edit2.Text:=dbgrid3.DataSource.DataSet.FieldValues['单据编码'];
with database do
begin
adoq7.Connection :=adoc;
adoq7.SQL.Clear ;
adoq7.SQL.Add('select 商品简码,商品编码,商品名称,类别,规格,型号,单位 from xshd where 单据编码=:djbm');
adoq7.Parameters.ParamByName('djbm').Value :=edit2.text;
adoq7.Active :=true;
datas7.DataSet :=adoq7;
dbgrid4.DataSource:=datas7;
end;
end;
end;
procedure Tjh_jhdh_find_form.SpeedButton1Click(Sender: TObject);
begin
with database do
begin
adoq9.Connection :=adoc;
adoq8.Connection :=adoc;
adoq9.SQL.Clear ;
adoq8.SQL.Clear ;
if dbgrid1.Visible and dbgrid2.Visible then
begin
//dbgrid2.Visible :=true;
//dbgrid3.Visible :=false;
//dbgrid4.Visible :=false;
case combobox1.ItemIndex of //combobox1开始
0: begin //combobox1(0)开始
case combobox2.ItemIndex of
0:begin
adoq9.SQL.Add('select distinct 录单日期,单据编码,经手人,供货商名称,备注 from jhd where 单据编码=:djbm ');
adoq9.Parameters.ParamByName('djbm').Value :=edit1.text;
//adoq9.Active :=true;
end;
1:begin
adoq9.SQL.Add('select distinct 录单日期,单据编码,经手人,供货商名称,备注 from jhd where 单据编码 like :djbm ');
adoq9.Parameters.ParamByName('djbm').Value :=edit1.text+'%';
// adoq9.Active :=true;
end;
end; //combobox2结束
end;//combobox1(0)结束
1:begin
case combobox2.ItemIndex of
0:begin
adoq9.SQL.Add('select distinct 录单日期,单据编码,经手人,供货商名称,备注 from jhd where 经手人=:djbm ');
adoq9.Parameters.ParamByName('djbm').Value :=edit1.text;
// adoq9.Active :=true;
end;
1:begin
adoq9.SQL.Add('select distinct 录单日期,单据编码,经手人,供货商名称,备注 from jhd where 经手人 like :djbm ');
adoq9.Parameters.ParamByName('djbm').Value :=edit1.text+'%';
// adoq9.Active :=true;
end;
end; //combobox2结束
end;//combobox1(1)结束
end;//combobox1结束
adoq9.Active :=true;
if adoq9.Recordset.RecordCount >0 then
begin
datas9.DataSet :=adoq9;
dbgrid1.DataSource:=datas9;
dbgrid2.DataSource :=nil;
end
else begin showmessage('没有此记录!');dbgrid1.DataSource :=nil;end;
end;
if dbgrid3.Visible=true and dbgrid4.Visible=true then
begin
case combobox1.ItemIndex of //combobox1开始
0: begin //combobox1(0)开始
case combobox2.ItemIndex of
0:begin
adoq8.SQL.Add('select distinct 录单日期,单据编码,经手人,供货商名称,备注 from xshd where 单据编码=:djbm ');
adoq8.Parameters.ParamByName('djbm').Value :=edit1.text;
// adoq8.Active :=true;
end;
1:begin
adoq8.SQL.Add('select distinct 录单日期,单据编码,经手人,供货商名称,备注 from xshd where 单据编码 like :djbm ');
adoq8.Parameters.ParamByName('djbm').Value :=edit1.text+'%';
// adoq8.Active :=true;
end;
end; //combobox2结束
end;//combobox1(0)结束
1:begin
case combobox2.ItemIndex of
0:begin
adoq8.SQL.Add('select distinct 录单日期,单据编码,经手人,供货商名称,备注 from xshd where 经手人=:djbm ');
adoq8.Parameters.ParamByName('djbm').Value :=edit1.text;
// adoq8.Active :=true;
end;
1:begin
adoq8.SQL.Add('select distinct 录单日期,单据编码,经手人,供货商名称,备注 from xshd where 经手人 like :djbm ');
adoq8.Parameters.ParamByName('djbm').Value :=edit1.text+'%';
// adoq8.Active :=true;
end;
end; //combobox2结束
end;//combobox1(1)结束
end;//combobox1结束
adoq8.Active :=true;
if adoq8.Recordset.RecordCount >0 then
begin
datas8.DataSet :=adoq8;
dbgrid3.DataSource:=datas8;
dbgrid4.DataSource :=nil;
end
else begin showmessage('没有此记录!'); dbgrid3.DataSource :=nil;end;
end;
end;
end;
procedure Tjh_jhdh_find_form.DBGrid3DblClick(Sender: TObject);
begin
if dbgrid3.DataSource.DataSet.RecordCount>0 then
begin
xsh_form.Edit18.Text:=dbgrid3.DataSource.DataSet.FieldValues['单据编码'];
xsh_form.combobox3.SetFocus ;
self.Hide ;
end
else
//begin
showmessage('无此记录!');
//dbgrid3.DataSource :=nil;end;
end;
procedure Tjh_jhdh_find_form.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=vk_return then
speedbutton1click(nil);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -