⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ygfz.pas

📁 实现人力资源的管理
💻 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 + -