📄 gx_lsjl.~pas
字号:
unit Gx_LSJL;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, Grids, DBGrids, DB, ADODB;
type
TGx_LSJL_Form = class(TForm)
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
GroupBox1: TGroupBox;
Label1: TLabel;
Label3: TLabel;
Edit1: TEdit;
ComboBox1: TComboBox;
GroupBox2: TGroupBox;
BitBtn2: TBitBtn;
BitBtn1: TBitBtn;
procedure BitBtn2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure ComboBox1Click(Sender: TObject);
procedure Edit1Exit(Sender: TObject);
procedure Edit1Change(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure initdbgrid();
end;
var
Gx_LSJL_Form: TGx_LSJL_Form;
case_flag:integer;
implementation
uses Main;
{$R *.dfm}
procedure TGx_LSJL_Form.initdbgrid();
begin
dbgrid1.Columns[0].Width:=80;
dbgrid1.Columns[1].Width:=90;
dbgrid1.Columns[2].Width:=90;
dbgrid1.Columns[3].Width:=80;
dbgrid1.Columns[4].Width:=100;
dbgrid1.Columns[5].Width:=100;
dbgrid1.Columns[6].Width:=100;
dbgrid1.Columns[7].Width:=100;
dbgrid1.Columns[8].Width:=100;
dbgrid1.Columns[9].Width:=100;
dbgrid1.Columns[10].Width:=80;
dbgrid1.Columns[11].Width:=80;
dbgrid1.Columns[12].Width:=80;
dbgrid1.Columns[13].Width:=80;
dbgrid1.Columns[14].Width:=80;
dbgrid1.Columns[15].Width:=80;
dbgrid1.Columns[16].Width:=80;
dbgrid1.Columns[17].Width:=80;
dbgrid1.Columns[18].Width:=60;
dbgrid1.Columns[19].Width:=60;
dbgrid1.Columns[20].Width:=130;
dbgrid1.Columns[21].Width:=30;
end;
procedure TGx_LSJL_Form.FormActivate(Sender: TObject);
begin
combobox1.Items.Clear;
combobox1.Items.Add('按工资编号');
combobox1.Items.Add('按职工编号');
combobox1.Items.Add('按职工姓名');
combobox1.Items.Add('按月份');
label1.Visible:=false;
edit1.Visible:=false;
case_flag:=0;
ADOConnection1:=MAIN_FORM.ADOConnection1;
adoquery1.Connection:=ADOConnection1;
adoquery1.Close;
dbgrid1.DataSource:=DataSource1;
DataSource1.DataSet:=adotable1;
adotable1.Close;
adotable1.Connection:=ADOConnection1;
adotable1.TableName:='工资历史信息表';
adotable1.Active:=true;
initdbgrid();
dbgrid1.ReadOnly:=true;
if adotable1.Recordset.RecordCount>=1 then
bitbtn1.Enabled:=true
else
bitbtn1.Enabled:=false;
if (qx[4]=false) and (qx[3]=false) then
bitbtn1.Enabled:=false;
end;
procedure TGx_LSJL_Form.ComboBox1Click(Sender: TObject);
begin
label1.Visible:=true;
label1.Width:=200;
edit1.Visible:=true;
case ComboBox1.ItemIndex of
0:
begin
//
label1.Caption:='请输入工资编号';
case_flag:=1;
end;
1:
begin
//
label1.Caption:='请输入职工编号';
case_flag:=2;
end;
2:
begin
//
label1.Caption:='请输入职工姓名';
case_flag:=3;
end;
3:
begin
//
label1.Caption:='请输入查询月份';
case_flag:=4;
end;
else
end;
end;
procedure TGx_LSJL_Form.Edit1Exit(Sender: TObject);
begin
if edit1.Text<>'' then
begin
case case_flag of
1:
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from 工资历史信息表 '+
' where 工资编号=:ZgNo order by 工资编号 '
);
adoquery1.Parameters.Clear;
adoquery1.Parameters.AddParameter;
adoquery1.Parameters[0].Name:='ZgNo';
adoquery1.Parameters[0].DataType:=ftstring;
adoquery1.Parameters[0].Direction:=pdinput;
adoquery1.Parameters[0].Value:=strtoint(edit1.Text);
adoquery1.Active:=true;
adotable1.Recordset:=adoquery1.Recordset;
initdbgrid;
adoquery1.Close;
end;
2:
begin
//
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from 工资历史信息表 '+
' where 职工编号=:ZgNo order by 职工编号 '
);
adoquery1.Parameters.Clear;
adoquery1.Parameters.AddParameter;
adoquery1.Parameters[0].Name:='ZgNo';
adoquery1.Parameters[0].DataType:=ftstring;
adoquery1.Parameters[0].Direction:=pdinput;
adoquery1.Parameters[0].Value:=strtoint(edit1.Text);
adoquery1.Active:=true;
adotable1.Recordset:=adoquery1.Recordset;
initdbgrid;
adoquery1.Close;
end;
3:
begin
//
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from 工资历史信息表 '+
' where 职工姓名=:ZgName order by 职工编号 '
);
adoquery1.Parameters.Clear;
adoquery1.Parameters.AddParameter;
adoquery1.Parameters[0].Name:='ZgName';
adoquery1.Parameters[0].DataType:=ftstring;
adoquery1.Parameters[0].Direction:=pdinput;
adoquery1.Parameters[0].Value:=edit1.Text;
adoquery1.Active:=true;
adotable1.Recordset:=adoquery1.Recordset;
initdbgrid;
adoquery1.Close;
end;
4:
begin
//
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from 工资历史信息表 '+
' where 工资月份=:ZgName order by 职工编号 '
);
adoquery1.Parameters.Clear;
adoquery1.Parameters.AddParameter;
adoquery1.Parameters[0].Name:='ZgName';
adoquery1.Parameters[0].DataType:=ftstring;
adoquery1.Parameters[0].Direction:=pdinput;
adoquery1.Parameters[0].Value:=strtoint(edit1.Text);
adoquery1.Active:=true;
adotable1.Recordset:=adoquery1.Recordset;
initdbgrid;
adoquery1.Close;
end;
else
end;
end
else
begin
adoquery1.Close;
application.MessageBox('输入不正确!','提示',48);
end;
end;
procedure TGx_LSJL_Form.BitBtn2Click(Sender: TObject);
begin
close;
end;
procedure TGx_LSJL_Form.Edit1Change(Sender: TObject);
begin
if edit1.Text<>'' then
begin
case case_flag of
1:
begin
adotable1.Locate('工资编号',strtoint(edit1.Text),[lopartialkey]);
end;
2:
begin
adotable1.Locate('职工编号',strtoint(edit1.Text),[lopartialkey]);
end;
3:
begin
adotable1.Locate('职工姓名',edit1.Text,[lopartialkey]);
end;
4:
begin
adotable1.Locate('工资月份',strtoint(edit1.Text),[lopartialkey]);
end;
else
end;
end;
end;
procedure TGx_LSJL_Form.BitBtn1Click(Sender: TObject);
var k:integer;
begin
k:=application.MessageBox('确定要清空工资历史库的信息吗?','严重警告!',49);
if k=id_ok then
begin
while adotable1.Eof<>true do
adotable1.Delete;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -