?? 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 錄單日期,單據(jù)編碼,經(jīng)手人,供貨商名稱,備注 from jhd ');
adoq1.active:=true;
statusbar1.Panels[1].Text :=inttostr(adoq1.Recordset.RecordCount);
adoq2.SQL.Add('select distinct 錄單日期,單據(jù)編碼,經(jīng)手人,供貨商名稱,備注 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['單據(jù)編碼'];
with database do
begin
adoq6.Connection :=adoc;
adoq6.SQL.Clear ;
adoq6.SQL.Add('select 商品簡碼,商品編碼,商品名稱,類別,規(guī)格,型號,單位 from jhd where 單據(jù)編碼=: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['單據(jù)編碼'];
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['單據(jù)編碼'];
with database do
begin
adoq7.Connection :=adoc;
adoq7.SQL.Clear ;
adoq7.SQL.Add('select 商品簡碼,商品編碼,商品名稱,類別,規(guī)格,型號,單位 from xshd where 單據(jù)編碼=: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 錄單日期,單據(jù)編碼,經(jīng)手人,供貨商名稱,備注 from jhd where 單據(jù)編碼=:djbm ');
adoq9.Parameters.ParamByName('djbm').Value :=edit1.text;
//adoq9.Active :=true;
end;
1:begin
adoq9.SQL.Add('select distinct 錄單日期,單據(jù)編碼,經(jīng)手人,供貨商名稱,備注 from jhd where 單據(jù)編碼 like :djbm ');
adoq9.Parameters.ParamByName('djbm').Value :=edit1.text+'%';
// adoq9.Active :=true;
end;
end; //combobox2結(jié)束
end;//combobox1(0)結(jié)束
1:begin
case combobox2.ItemIndex of
0:begin
adoq9.SQL.Add('select distinct 錄單日期,單據(jù)編碼,經(jīng)手人,供貨商名稱,備注 from jhd where 經(jīng)手人=:djbm ');
adoq9.Parameters.ParamByName('djbm').Value :=edit1.text;
// adoq9.Active :=true;
end;
1:begin
adoq9.SQL.Add('select distinct 錄單日期,單據(jù)編碼,經(jīng)手人,供貨商名稱,備注 from jhd where 經(jīng)手人 like :djbm ');
adoq9.Parameters.ParamByName('djbm').Value :=edit1.text+'%';
// adoq9.Active :=true;
end;
end; //combobox2結(jié)束
end;//combobox1(1)結(jié)束
end;//combobox1結(jié)束
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 錄單日期,單據(jù)編碼,經(jīng)手人,供貨商名稱,備注 from xshd where 單據(jù)編碼=:djbm ');
adoq8.Parameters.ParamByName('djbm').Value :=edit1.text;
// adoq8.Active :=true;
end;
1:begin
adoq8.SQL.Add('select distinct 錄單日期,單據(jù)編碼,經(jīng)手人,供貨商名稱,備注 from xshd where 單據(jù)編碼 like :djbm ');
adoq8.Parameters.ParamByName('djbm').Value :=edit1.text+'%';
// adoq8.Active :=true;
end;
end; //combobox2結(jié)束
end;//combobox1(0)結(jié)束
1:begin
case combobox2.ItemIndex of
0:begin
adoq8.SQL.Add('select distinct 錄單日期,單據(jù)編碼,經(jīng)手人,供貨商名稱,備注 from xshd where 經(jīng)手人=:djbm ');
adoq8.Parameters.ParamByName('djbm').Value :=edit1.text;
// adoq8.Active :=true;
end;
1:begin
adoq8.SQL.Add('select distinct 錄單日期,單據(jù)編碼,經(jīng)手人,供貨商名稱,備注 from xshd where 經(jīng)手人 like :djbm ');
adoq8.Parameters.ParamByName('djbm').Value :=edit1.text+'%';
// adoq8.Active :=true;
end;
end; //combobox2結(jié)束
end;//combobox1(1)結(jié)束
end;//combobox1結(jié)束
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['單據(jù)編碼'];
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.
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -