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

📄 zl_del.pas

📁 人事管理系统的源代码
💻 PAS
字号:
unit Zl_Del;

interface

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

type
  TZl_Del_Form = class(TForm)
    DataSource1: TDataSource;
    ADOConnection1: TADOConnection;
    ADOTable1: TADOTable;
    DBGrid1: TDBGrid;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit10: TEdit;
    Edit11: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Label14: TLabel;
    Label15: TLabel;
    Edit5: TEdit;
    MaskEdit1: TMaskEdit;
    Edit2: TEdit;
    ADOQuery1: TADOQuery;
    ADOQuery2: TADOQuery;
    procedure BitBtn2Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure ADOTable1AfterScroll(DataSet: TDataSet);
    procedure Edit1Exit(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure initform();
    procedure initdbgrid();
    procedure loadfromtable();
  end;

var
  Zl_Del_Form: TZl_Del_Form;

implementation

uses Main;

{$R *.dfm}




procedure TZl_Del_Form.loadfromtable();
begin
     edit1.Text:=adotable1.Fieldbyname('职工编号').AsString;
     edit2.Text:=adotable1.Fieldbyname('通信地址').AsString;
     edit11.Text:=adotable1.Fieldbyname('职工姓名').AsString;
     edit10.Text:=adotable1.Fieldbyname('身份证号').AsString;
     edit5.Text:=adotable1.Fieldbyname('操作人').AsString;
     maskedit1.Text:=datetostr(adotable1.Fieldbyname('最后操作时间').AsDateTime);

end;



procedure TZl_Del_Form.initform();
begin
   edit1.Text:='';
   edit2.Text:='';
   edit10.Text:='';
   edit11.Text:='';
   edit5.Text:='';
   maskedit1.Text:=datetostr(date());
end;

procedure TZl_Del_Form.initdbgrid();
begin
      dbgrid1.Columns[0].Width:=100;
    dbgrid1.Columns[1].Width:=90;
    dbgrid1.Columns[2].Width:=60;
    dbgrid1.Columns[3].Width:=80;
    dbgrid1.Columns[4].Width:=100;
    dbgrid1.Columns[5].Width:=100;
    dbgrid1.Columns[6].Width:=100;

    dbgrid1.Columns[7].Width:=100;
    dbgrid1.Columns[8].Width:=100;
    dbgrid1.Columns[9].Width:=100;
    dbgrid1.Columns[10].Width:=80;
    dbgrid1.Columns[11].Width:=80;
    dbgrid1.Columns[12].Width:=80;
    dbgrid1.Columns[13].Width:=80;
    dbgrid1.Columns[14].Width:=80;
end;

procedure TZl_Del_Form.BitBtn2Click(Sender: TObject);
begin
   close;
end;

procedure TZl_Del_Form.FormActivate(Sender: TObject);
begin
    dbgrid1.ReadOnly:=true;
    ADOConnection1:=MAIN_FORM.ADOConnection1;
    dbgrid1.DataSource:=DataSource1;
    DataSource1.DataSet:=adotable1;
    adotable1.Close;

    adotable1.Connection:=ADOConnection1;
    adotable1.TableName:='职工信息表';
    adotable1.Active:=true;

    adoquery1.Close;
    adoquery1.Connection:=ADOConnection1;

    adoquery2.Connection:=ADOConnection1;
    adoquery2.Close;


    if adotable1.Recordset.RecordCount<1 then
        bitbtn1.Enabled:=false
    else
        loadfromtable();
    initdbgrid ;
    initform;
end;

procedure TZl_Del_Form.BitBtn1Click(Sender: TObject);
begin
 if  adotable1.Recordset.RecordCount>=1 then
     begin
 //-----------------------------------------------------------
 //            删除职工信息表中的记录
 //------------------------------------------------------------
          adoquery2.Close;
          adoquery2.SQL.Clear;
          adoquery2.SQL.Add('delete * from 职工工资信息表 where 职工编号 =:ZgNo');
          adoquery2.Parameters.Clear;
          adoquery2.Parameters.AddParameter;
          adoquery2.Parameters[0].Name:='ZgNo';
          adoquery2.Parameters[0].DataType:=ftstring;
          adoquery2.Parameters[0].Direction:=pdinput;
          adoquery2.Parameters[0].Value:=strtoint(edit1.Text);
          adoquery2.ExecSQL;
          adoquery2.Close;

          adotable1.Delete;
     end
 else
     bitbtn1.Enabled:=false;
end;

procedure TZl_Del_Form.ADOTable1AfterScroll(DataSet: TDataSet);
begin
if  adotable1.Recordset.RecordCount>=1 then
    loadfromtable();
end;

procedure TZl_Del_Form.Edit1Exit(Sender: TObject);
begin
      if edit1.Text<>'' then
     begin
        adoquery1.Close;
        adoquery1.SQL.Clear;
        adoquery1.SQL.Add('select * from 职工信息表 where 职工编号=:zgnumber');
        adoquery1.Parameters.Clear;
        adoquery1.Parameters.AddParameter;
        adoquery1.Parameters[0].Name:='zgnumber';
        adoquery1.Parameters[0].DataType:=ftstring;
        adoquery1.Parameters[0].Direction:=pdinput;
        adoquery1.Parameters[0].Value:=edit1.Text;
        adoquery1.Active:=true;

        adotable1.Recordset:=adoquery1.Recordset;
               if adoquery1.Recordset.RecordCount >=1 then
                   begin
                      loadfromtable;
                      initdbgrid;
                   end
                else
                   begin
                     application.MessageBox('该职工不存在!','警告',48);
                     edit1.SetFocus;
                   end;
      adoquery1.Close;
     end;
end;

end.

⌨️ 快捷键说明

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