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

📄 xgryda.pas

📁 一个比较实用的人事管理系统,Delphi+SQL开发
💻 PAS
字号:
unit xgryda;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, mp, ExtCtrls, StdCtrls, Buttons, Grids, DBGrids, DB;

type
  TForm78 = class(TForm41)
    Panel1: TPanel;
    Label1: TLabel;
    ComboBox1: TComboBox;
    ComboBox2: TComboBox;
    SpeedButton1: TSpeedButton;
    DBGrid1: TDBGrid;
    Panel2: TPanel;
    Label8: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Label14: TLabel;
    CheckBox1: TCheckBox;
    Label10: TLabel;
    CheckBox2: TCheckBox;
    Label11: TLabel;
    CheckBox3: TCheckBox;
    Label12: TLabel;
    CheckBox4: TCheckBox;
    Label13: TLabel;
    ComboBox3: TComboBox;
    ComboBox4: TComboBox;
    ComboBox5: TComboBox;
    Edit2: TEdit;
    Panel3: TPanel;
    DataSource1: TDataSource;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    BitBtn3: TBitBtn;
    CheckBox5: TCheckBox;
    Label2: TLabel;
    BitBtn4: TBitBtn;
    BitBtn5: TBitBtn;
    Label3: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label9: TLabel;
    procedure ComboBox1KeyPress(Sender: TObject; var Key: Char);
    procedure BitBtn4MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure BitBtn4MouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormShow(Sender: TObject);
    procedure ComboBox1Change(Sender: TObject);
    Procedure Clear;
    Procedure EditValue;
    procedure SpeedButton1Click(Sender: TObject);
    procedure BitBtn4Click(Sender: TObject);
    procedure BitBtn5Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form78: TForm78;

implementation
  uses Dataa;
{$R *.dfm}

procedure TForm78.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
  inherited;
  Key := #0;
end;

procedure TForm78.BitBtn4MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  inherited;
  TBitBtn(Sender).Font.Color := clRed;
end;

procedure TForm78.BitBtn4MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  inherited;
  TBitBtn(Sender).Font.Color := clBlue;
end;

procedure TForm78.FormShow(Sender: TObject);
begin
  inherited;
  with Data3.ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from 员工基础信息表');
    Open;
  end;
  if Data3.ADOQuery1.RecordCount<1 then
  begin
    Application.MessageBox('没有人员信息可以修改。','提示',64);
    BitBtn1.Enabled := False;
    BitBtn2.Enabled := False;
    BitBtn3.Enabled := False;
    BitBtn4.Enabled := False;
    BitBtn5.Enabled := False;
    Exit;
  end;
  Clear;
  ComboBox2.Clear;
  ComboBox4.Items.Clear;
  with Data3.ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from 人员类别表');
    Open;
  end;
  while Not Data3.ADOQuery1.Eof do
  begin
    ComboBox4.Items.Add(Data3.ADOQuery1.FieldByName('人员类别').Value);
    Data3.ADOQuery1.Next;
  end;
  ComboBox5.Items.Clear;
  with Data3.ADOQuery1 do
  begin
    Close;
    SQL.Clear;
    SQL.Add('select * from 银行信息表');
    Open;
  end;
  while Not Data3.ADOQuery1.Eof do
  begin
    ComboBox5.Items.Add(Data3.ADOQuery1.FieldByName('银行名称').Value);
    Data3.ADOQuery1.Next;
  end;

end;

procedure TForm78.ComboBox1Change(Sender: TObject);
begin
  if Trim(ComboBox1.Text)<>'' then
  begin
    with Data3.ADOQuery1 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select distinct');
      SQL.Add(ComboBox1.Text);
      SQL.Add('From 员工基础信息表');
      Open;
    end;
    ComboBox2.Clear;
    while Not Data3.ADOQuery1.Eof do
    begin
      ComboBox2.Items.Add(Data3.ADOQuery1.Fields[0].Value);
      Data3.ADOQuery1.Next;
    end;
  end;
end;

procedure TForm78.SpeedButton1Click(Sender: TObject);
begin
  if CheckBox5.Checked = False then
  begin
    if (Trim(ComboBox1.Text)<>'')and(Trim(ComboBox2.Text)<>'')then
    begin
      with Data3.ADOQuery2 do
      begin
        Close;
        SQL.Clear;
        SQL.Add('select * from 员工基础信息表 where');
        SQL.Add(Trim(ComboBox1.Text));
        SQL.Add('= ');
        SQL.Add(':a');
        Parameters.ParamByName('a').Value := Trim(ComboBox2.Text);
        Open;
      end;
      if Data3.ADOQuery2.RecordCount<1 then
        Clear
      else
      begin
        DataSource1.DataSet := Data3.ADOQuery2;
        EditValue;
      end;
    end
  end
  else
  begin
    with Data3.ADOQuery2 do
    begin
      Close;
      SQL.Clear;
      SQL.Add('select * from 员工基础信息表 ');
     Open;
    end;
    if Data3.ADOQuery2.RecordCount<1 then
      Clear
    else
    begin
      DataSource1.DataSet := Data3.ADOQuery2;
      EditValue;
    end;
  end;
end;

procedure TForm78.Clear;
begin
  ComboBox3.Text := '';
  ComboBox4.Text := '';
  ComboBox5.Text := '';
  Label6.Caption := '';
  Label9.Caption := '';
  Edit2.Clear;
  CheckBox1.Checked := False;
  CheckBox2.Checked := True;
  CheckBox3.Checked := True;
  CheckBox4.Checked := False;
  DataSource1.DataSet := Nil;
  CheckBox5.Checked := False;
end;

procedure TForm78.EditValue;
begin
  if Data3.ADOQuery2.RecordCount>0 then
  begin
    Label6.Caption := Data3.ADOQuery2.FieldByName('员工编号').Value;
    Label9.Caption := Data3.ADOQuery2.FieldByName('员工姓名').Value;
    ComboBox3.Text := Data3.ADOQuery2.FieldByName('文化程度').Value;
    ComboBox4.Text := Data3.ADOQuery2.FieldByName('人员类别').Value;
    ComboBox5.Text := Data3.ADOQuery2.FieldByName('代发银行').Value;
    Edit2.Text := Data3.ADOQuery2.FieldByName('银行账号').Value;
    if Data3.ADOQuery2.FieldByName('停发工资').Value = 0 then
       CheckBox1.Checked := False
    else
      CheckBox1.Checked := True;
    if Data3.ADOQuery2.FieldByName('计税').Value = 0 then
       CheckBox2.Checked := True
    else
      CheckBox2.Checked := False;
    if Data3.ADOQuery2.FieldByName('中方人员').Value = 0 then
       CheckBox3.Checked := True
    else
      CheckBox3.Checked := False;
    if Data3.ADOQuery2.FieldByName('离职').Value = 0 then
       CheckBox4.Checked := False
    else
      CheckBox4.Checked := True;
  end;
end;

procedure TForm78.BitBtn4Click(Sender: TObject);
begin
  inherited;
  BitBtn5.Enabled := True;
  if Data3.ADOQuery2.Active = True then
    if Not Data3.ADOQuery2.Bof then
    begin
      Data3.ADOQuery2.Prior;
      EditValue;
    end
    else
      BitBtn4.Enabled := False;
end;

procedure TForm78.BitBtn5Click(Sender: TObject);
begin
  inherited;
  BitBtn4.Enabled := True;
  if Data3.ADOQuery2.Active = True then
    if Not Data3.ADOQuery2.Eof then
    begin
      Data3.ADOQuery2.Next;
      EditValue;
    end
    else
      BitBtn5.Enabled := False;
end;

procedure TForm78.BitBtn3Click(Sender: TObject);
begin
  inherited;
  Close;
end;

procedure TForm78.BitBtn2Click(Sender: TObject);
begin
  inherited;
  if Data3.ADOQuery2.RecordCount>0 then
    EditValue;
end;

procedure TForm78.BitBtn1Click(Sender: TObject);
begin
  inherited;
  if Data3.ADOQuery2.RecordCount>0 then
  begin
    if Application.MessageBox('确实要修改当前记录吗?','提示',MB_YesNo)= ID_Yes then
    begin
      if (Trim(ComboBox3.Text)<>'')and(Trim(ComboBox4.Text)<>'')and(Trim(ComboBox5.Text)<>'')and
        (Trim(Edit2.Text)<>'') then
      begin
        Try
          Data3.ADOQuery2.Edit;
          Data3.ADOQuery2.FieldByName('文化程度').Value := Trim(ComboBox3.Text);
          Data3.ADOQuery2.FieldByName('人员类别').Value := Trim(ComboBox4.Text);
          Data3.ADOQuery2.FieldByName('代发银行').Value := Trim(ComboBox5.Text);
          Data3.ADOQuery2.FieldByName('银行账号').Value := Trim(Edit2.Text);
          if CheckBox1.Checked = True then
            Data3.ADOQuery2.FieldByName('停发工资').Value := 1
          else
            Data3.ADOQuery2.FieldByName('停发工资').Value := 0;
          if CheckBox2.Checked = True then
            Data3.ADOQuery2.FieldByName('计税').Value := 0
          else
            Data3.ADOQuery2.FieldByName('计税').Value := 1;
          if CheckBox3.Checked = True then
            Data3.ADOQuery2.FieldByName('中方人员').Value := 0
          else
            Data3.ADOQuery2.FieldByName('中方人员').Value := 1;
          if CheckBox4.Checked = True then
            Data3.ADOQuery2.FieldByName('离职').Value := 1
          else
            Data3.ADOQuery2.FieldByName('离职').Value := 0;
          Data3.ADOQuery2.Post;
          Application.MessageBox('数据修改成功。','提示',64);
        Except
          Application.MessageBox('系统出错。','提示',64);
          Close;
        end;
      end
      else
        Application.MessageBox('数据项不能为空.','提示',64);
    end
    else
      EditValue;
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -