📄 u_ygfz.pas
字号:
unit U_ygfz;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, Grids, DBGrids, ComCtrls, Buttons, ToolWin,
ExtCtrls;
type
Tfrm_ygfz = class(TForm)
Panel1: TPanel;
TreeView1: TTreeView;
Panel2: TPanel;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
SpeedButton1: TSpeedButton;
ToolButton1: TToolButton;
SpeedButton2: TSpeedButton;
ToolButton2: TToolButton;
SpeedButton4: TSpeedButton;
ToolButton3: TToolButton;
SpeedButton3: TSpeedButton;
Panel3: TPanel;
DBGrid1: TDBGrid;
Panel4: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
DataSource1: TDataSource;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
Label6: TLabel;
Edit3: TEdit;
procedure FormShow(Sender: TObject);
procedure TreeView1Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_ygfz: Tfrm_ygfz;
implementation
uses U_data, U_tj, U_xm;
{$R *.dfm}
procedure Tfrm_ygfz.FormShow(Sender: TObject);
var
a,b:string;
subt:TTreenode;
begin
combobox1.Clear;
combobox2.Clear;
combobox3.Clear;
treeview1.Items.Clear;
with data1.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select distinct 单位名称 from 单位信息表');
open;
end;
a:=data1.ADOpublic.FieldByName('单位名称').Value;
subt:=Treeview1.Items.Add(nil,a);
with data1.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select distinct 部门名称 from 部门表');
open;
end;
while not data1.ADOpublic.Eof do
begin
combobox1.Items.Add(data1.ADOpublic.FieldByName('部门名称').Value);
b:=Data1.ADOpublic.FieldByName('部门名称').Value;
data1.ADOpublic.Next;
Treeview1.Items.AddChild(subt,b);
end;
with data1.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select distinct 职务名称 from 职务表');
open;
end;
while not data1.ADOpublic.Eof do
begin
combobox2.Items.Add(data1.ADOpublic.FieldByName('职务名称').Value);
data1.ADOpublic.Next;
end;
with data1.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select distinct 职称名称 from 职称表');
open;
end;
while not data1.ADOpublic.Eof do
begin
combobox3.Items.Add(data1.ADOpublic.FieldByName('职称名称').Value);
data1.ADOpublic.Next;
end;
with data1.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select * from 人事表 where sflz=:a');
parameters.ParamByName('a').Value:='是';
open;
end;
data1.ADOpublic.Active:=true;
if data1.ADOpublic.RecordCount>0 then
begin
edit1.Text:=data1.ADOpublic.FieldByName('bh').Value;
edit2.Text:=data1.ADOpublic.FieldByName('xm').Value;
combobox1.Text:=data1.ADOpublic.FieldByName('ssbm').Value;
combobox2.Text:=data1.ADOpublic.FieldByName('zw').Value;
combobox3.Text:=data1.ADOpublic.FieldByName('zc').Value;
end;
TreeView1.FullExpand;
end;
procedure Tfrm_ygfz.TreeView1Click(Sender: TObject);
var
s,d:string;
begin
with data1.ADOQYdwxx do
begin
close;
sql.Clear;
sql.Add('select distinct 单位名称 from 单位信息表');
open;
end;
d:=data1.ADOQYdwxx.FieldByName('单位名称').Value;
s:=treeview1.Selected.Text;
IF Treeview1.Selected<>nil then
if Treeview1.Selected.Text=d then
begin
with data1.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select * from 人事表 where sflz=:b ');
parameters.ParamByName('b').Value:='是';
open;
end;
end
else
begin
with data1.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select * from 人事表 where ssbm = :a and sflz=:b ');
parameters.ParamByName('a').Value:=s;
parameters.ParamByName('b').Value:='是';
open;
end;
end;
end;
procedure Tfrm_ygfz.SpeedButton3Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_ygfz.SpeedButton1Click(Sender: TObject);
begin
application.CreateForm(Tfrm_cxtj,frm_cxtj);
frm_cxtj.ShowModal;
frm_cxtj.Free;
end;
procedure Tfrm_ygfz.SpeedButton2Click(Sender: TObject);
begin
with data1.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select * from 人事表 where sflz=:a');
parameters.ParamByName('a').Value:='是';
open;
end;
end;
procedure Tfrm_ygfz.SpeedButton4Click(Sender: TObject);
begin
if messagebox(self.Handle,'确定要复职吗?','提示',mb_yesno+mb_iconquestion)=idyes then
begin
if trim(edit3.Text)<>'' then
begin
with data1.ADOpublic do
begin
edit;
fieldbyname('sflz').Value:='否';
fieldbyname('fzrq').Value:=date();
fieldbyname('ssbm').Value:=frm_ygfz.ComboBox1.Text;
fieldbyname('zw').Value:=frm_ygfz.ComboBox2.Text;
fieldbyname('zc').Value:=frm_ygfz.ComboBox3.Text;
fieldbyname('lzfydjr').Value:=trim(edit3.Text);
post;
end;
application.MessageBox('修改成功','提示',64);
self.OnShow(sender);
end
else
application.MessageBox('请输入登记人姓名!','提示',64);
end;
end;
procedure Tfrm_ygfz.DBGrid1CellClick(Column: TColumn);
begin
if dbgrid1.DataSource.DataSet<>nil then
if dbgrid1.DataSource.DataSet.RecordCount>0 then
edit1.Text:=data1.ADOpublic.FieldByName('bh').Value;
edit2.Text:=data1.ADOpublic.FieldByName('xm').Value;
combobox1.Text:=data1.ADOpublic.FieldByName('ssbm').Value;
combobox2.Text:=data1.ADOpublic.FieldByName('zw').Value;
combobox3.Text:=data1.ADOpublic.FieldByName('zc').Value;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -