📄 ygdd.pas
字号:
unit ygdd;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, Grids, DBGrids, StdCtrls, Buttons, ComCtrls, ToolWin,
ExtCtrls;
type
Tygddfrm = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
TreeView1: TTreeView;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
SpeedButton1: TSpeedButton;
Panel3: TPanel;
Panel4: TPanel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
procedure FormShow(Sender: TObject);
procedure TreeView1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
procedure DBGrid1CellClick(Column: TColumn);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ygddfrm: Tygddfrm;
implementation
uses dbdata,cxtj;
{$R *.dfm}
procedure Tygddfrm.FormShow(Sender: TObject);
var
a,b:string;
subt:TTreenode;
begin
combobox1.Clear;
combobox2.Clear;
combobox3.Clear;
with data.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select distinct 单位名称 from 单位信息表');
open;
end;
a:=data.ADOpublic.FieldByName('单位名称').Value;
subt:=Treeview1.Items.Add(nil,a);
with data.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select distinct 部门名称 from 部门表');
open;
end;
while Not Data.ADOpublic.Eof do
begin
ComboBox1.Items.Add(Data.ADOpublic.FieldByName('部门名称').Value);
b:=Data.ADOpublic.FieldByName('部门名称').Value;
Data.ADOpublic.Next;
Treeview1.Items.AddChild(subt,b);
end;
with data.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select distinct 职务名称 from 职务表');
open;
end;
while Not Data.ADOpublic.Eof do
begin
ComboBox2.Items.Add(Data.ADOpublic.FieldByName('职务名称').Value);
Data.ADOpublic.Next;
end;
with data.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select distinct 职称名称 from 职称表');
open;
end;
while Not Data.ADOpublic.Eof do
begin
ComboBox3.Items.Add(Data.ADOpublic.FieldByName('职称名称').Value);
Data.ADOpublic.Next;
end;
with data.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select * from 人事表 where 是否离职= :b');
parameters.ParamByName('b').Value:='否';
open;
end;
data.ADOpublic.Active:=true;
edit1.Text:=data.ADOpublic.FieldByName('编号').Value;
edit2.Text:=data.ADOpublic.FieldByName('姓名').Value;
combobox1.Text:=data.ADOpublic.FieldByName('所属部门').Value;
combobox2.Text:=data.ADOpublic.FieldByName('职务').Value;
combobox3.Text:=data.ADOpublic.FieldByName('职称').Value;
TreeView1.FullExpand;
end;
procedure Tygddfrm.TreeView1Click(Sender: TObject);
var
s,d:string;
begin
with data.ADOQYdwxx do
begin
close;
sql.Clear;
sql.Add('select distinct 单位名称 from 单位信息表');
open;
end;
s:=treeview1.Selected.Text;
d:=data.ADOQYdwxx.FieldByName('单位名称').Value;
if treeview1.Selected<>nil then
if treeview1.Selected.Text=d then
begin
with data.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select * from 人事表 where 是否离职=:b ');
parameters.ParamByName('b').Value:='否';
open;
end;
end
else
begin
with data.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select * from 人事表 where 所属部门= :a and 是否离职=:b ');
parameters.ParamByName('a').Value:=s;
parameters.ParamByName('b').Value:='否';
open;
end;
end;
end;
procedure Tygddfrm.SpeedButton1Click(Sender: TObject);
begin
application.CreateForm(Tcxtjfrm,cxtjfrm);
cxtjfrm.ShowModal;
cxtjfrm.free;
end;
procedure Tygddfrm.SpeedButton2Click(Sender: TObject);
begin
combobox1.Enabled:=true;
combobox2.Enabled:=true;
combobox3.Enabled:=true;
end;
procedure Tygddfrm.SpeedButton3Click(Sender: TObject);
begin
try
with data.ADOpublic do
begin
edit;
FieldByName('所属部门').Value := Trim(combobox1.Text);
FieldByName('职务').Value := Trim(combobox2.Text);
FieldByName('职称').Value := Trim(combobox3.Text);
post
end;
SpeedButton2.OnClick(sender);
application.MessageBox('确认成功','提示',64);
close;
except
application.MessageBox('确认失败','提示',64);
close;
end;
end;
procedure Tygddfrm.SpeedButton4Click(Sender: TObject);
begin
close;
end;
procedure Tygddfrm.DBGrid1CellClick(Column: TColumn);
begin
If DBGrid1.DataSource.DataSet<> Nil then
if DBGrid1.DataSource.DataSet.RecordCount>0 then
begin
edit1.Text:=data.ADOpublic.FieldByName('编号').Value;
edit2.Text:=data.ADOpublic.FieldByName('姓名').Value;
combobox1.Text:=data.ADOpublic.FieldByName('所属部门').Value;
combobox2.Text:=data.ADOpublic.FieldByName('职务').Value;
combobox3.Text:=data.ADOpublic.FieldByName('职称').Value;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -