?? ygfz.pas
字號:
unit ygfz;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, DB, Grids, DBGrids, StdCtrls, Buttons, ToolWin,
ExtCtrls;
type
Tygfzfrm = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
CoolBar1: TCoolBar;
ToolBar1: TToolBar;
SpeedButton1: TSpeedButton;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
SpeedButton4: TSpeedButton;
Panel3: TPanel;
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Edit2: TEdit;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
Label6: TLabel;
Edit3: TEdit;
Panel4: TPanel;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
TreeView1: TTreeView;
procedure FormShow(Sender: TObject);
procedure TreeView1Click(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
procedure SpeedButton4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
ygfzfrm: Tygfzfrm;
implementation
uses dbdata, cxtj, djrxm;
{$R *.dfm}
procedure Tygfzfrm.FormShow(Sender: TObject);
var
a,b:string;
subt:TTreenode;
begin
combobox1.Clear;
combobox2.Clear;
combobox3.Clear;
treeview1.Items.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 是否離職=:a');
parameters.ParamByName('a').Value:='是';
open;
end;
data.ADOpublic.Active:=true;
if data.ADOpublic.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;
TreeView1.FullExpand;
end;
procedure Tygfzfrm.TreeView1Click(Sender: TObject);
var
s,d:string;
begin
with data.ADOQYdwxx do
begin
close;
sql.Clear;
sql.Add('select distinct 單位名稱 from 單位信息表');
open;
end;
d:=data.ADOQYdwxx.FieldByName('單位名稱').Value;
s:=treeview1.Selected.Text;
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 Tygfzfrm.SpeedButton1Click(Sender: TObject);
begin
application.CreateForm(Tcxtjfrm,cxtjfrm);
cxtjfrm.ShowModal;
cxtjfrm.Free;
end;
procedure Tygfzfrm.SpeedButton2Click(Sender: TObject);
begin
with data.ADOpublic do
begin
close;
sql.Clear;
sql.Add('select * from 人事表 where 是否離職=:a');
parameters.ParamByName('a').Value:='是';
open;
end;
end;
procedure Tygfzfrm.SpeedButton3Click(Sender: TObject);
begin
if messagebox(self.Handle,'確定要復職嗎?','提示',mb_yesno+mb_iconquestion)=idyes then
begin
if trim(edit3.Text)<>'' then
begin
with data.ADOpublic do
begin
edit;
fieldbyname('是否離職').Value:='否';
fieldbyname('復職日期').Value:=date();
fieldbyname('所屬部門').Value:=ygfzfrm.ComboBox1.Text;
fieldbyname('職務').Value:=ygfzfrm.ComboBox2.Text;
fieldbyname('職稱').Value:=ygfzfrm.ComboBox3.Text;
fieldbyname('登記人').Value:=trim(edit3.Text);
post;
end;
application.MessageBox('復職成功','提示',64);
self.OnShow(sender);
end
else
application.MessageBox('請輸入登記人姓名!','提示',64);
end;
end;
procedure Tygfzfrm.SpeedButton4Click(Sender: TObject);
begin
close;
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -