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

📄 add_worker_pas.pas

📁 delphi6.0电子寻更源程序,用来计算保安有无查抄
💻 PAS
字号:
unit add_worker_pas;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Mask, ToolEdit, RXCtrls, Buttons, ExtCtrls,db, ComCtrls;

type
  Tadd_worker = class(TForm)
    Panel1: TPanel;
    BitBtn5: TBitBtn;
    BitBtn2: TBitBtn;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    ComboBox1: TComboBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Label9: TLabel;
    dateedit1: TDateTimePicker;
    Label5: TLabel;
    Edit7: TEdit;
    procedure FormShow(Sender: TObject);
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit2KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit3KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure ComboBox1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure DateEdit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit4KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Edit5KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure BitBtn2Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Edit2Exit(Sender: TObject);
    procedure ComboBox1Exit(Sender: TObject);
    procedure BitBtn5Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure DateEdit1Exit(Sender: TObject);
    procedure Edit6KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormActivate(Sender: TObject);
    procedure Edit7KeyPress(Sender: TObject; var Key: Char);
  private
  _mode:string;
    { Private declarations }
  public
    { Public declarations }
    e_code:string;
  end;

var
  add_worker: Tadd_worker;

implementation
uses menu,worker_pas,dm_worker_pas, FileCtrl,IniFiles;
{$R *.DFM}

procedure Tadd_worker.FormShow(Sender: TObject);
begin
if (screen.Height<600) and( screen.Width<800) then
  begin
  scaled:=true;
  height:=366;//round(height*longint(screen.height)*96 / 600/screen.pixelsperinch);
  width :=262;//round( width *longint(screen.width)*96 / 800/screen.pixelsperinch);
  left:=184;//round((screen.Width-Width)/2);
  top:=100;//round((screen.height-self.height)/2);
  end
  else
  begin
  self.Height:=366;
  self.Width:=242;
  end;

edit1.setfocus;
end;

procedure Tadd_worker.Edit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=vk_return then
edit2.SetFocus ;
end;

procedure Tadd_worker.Edit2KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=vk_return then
edit3.SetFocus ;

end;

procedure Tadd_worker.Edit3KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=vk_return then
combobox1.SetFocus ;
end;

procedure Tadd_worker.ComboBox1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=vk_return then
dateedit1.SetFocus ;
end;

procedure Tadd_worker.DateEdit1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=vk_return then
edit4.SetFocus ;
end;

procedure Tadd_worker.Edit4KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=vk_return then
edit5.SetFocus ;

end;

procedure Tadd_worker.Edit5KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=vk_return then
edit6.SetFocus ;
end;

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

procedure Tadd_worker.FormClose(Sender: TObject; var Action: TCloseAction);
begin
dm_worker.q_worker.close;
dm_worker.q_worker.open;
dm_worker.q_worker.Locate('id',(dm_worker.q_worker_ls.fieldbyname('id').asinteger),[loCaseInsensitive]);
end;

procedure Tadd_worker.Edit2Exit(Sender: TObject);
var ch,s1,s2:string;
begin
if edit2.Text<>'' then
begin
ch:=uppercase(trim(edit2.Text));
  try
   if (length(trim(ch)))<>2 then
   begin
   if _mode='0' then
   Application.MessageBox('請輸入人員鈕序列號的後兩位!','消息',MB_ICONINFORMATION);
   if _mode='1' then
   Application.MessageBox('請輸入兩位鈕號','消息',MB_ICONINFORMATION);
   edit2.SetFocus ;
   edit2.Text :='';
   exit;
   end;
   s1:=uppercase(copy(ch,1,1));
   s2:=uppercase(copy(ch,2,1));
  { if _mode='0' then
      begin
        if (((uppercase(s1)<'0')or(uppercase(s1)>'F'))or((uppercase(s2)<'0')or(uppercase(s2)>'3'))) then
        begin
        Application.MessageBox('請輸入人員鈕序列號的後兩位!','消息',MB_ICONINFORMATION);
        edit2.SetFocus ;
        edit2.Text :='';
        exit;
        end;
      end
      else}
   //if _mode='1' then
     // begin
      if (((uppercase(s1)<'0')or(uppercase(s1)>'F'))or((uppercase(s2)<'0')or(uppercase(s2)>'F'))) then
        begin
        Application.MessageBox('請輸入兩位鈕號!','消息',MB_ICONINFORMATION);
        edit2.SetFocus ;
        edit2.Text :='';
        exit;
        end;
     // end;
  except
  begin
   if _mode='0' then
   Application.MessageBox('請輸入人員鈕序列號的後兩位!','消息',MB_ICONINFORMATION);
   if _mode='1' then
   Application.MessageBox('請輸入兩位鈕號','消息',MB_ICONINFORMATION);
   edit2.SetFocus ;
   edit2.Text :='';
   exit;
   end;

  end;

end;
end;

procedure Tadd_worker.ComboBox1Exit(Sender: TObject);
begin
if combobox1.Text='' then
combobox1.Text:='男';

end;

procedure Tadd_worker.BitBtn5Click(Sender: TObject);
var
bookmark1:tbookmark ;
recno1,recno2:integer;
begin
dm_worker.Q_FIND.close;
dm_worker.q_find.open;
with dm_worker.q_worker_ls do
 begin
 close;
 open;
if add_worker.Caption='增加巡更員資訊' then
  begin//增加
    try
      if edit2.Text='' then
      begin
      Application.MessageBox('请輸入巡更員鈕號!','消息',MB_ICONINFORMATION);
      edit2.Text:='';
      edit2.SetFocus ;
      exit;
      end;
      {if edit7.Text='' then
         begin
         Application.MessageBox('請輸入該巡更員所屬的棒號!','消息',MB_ICONINFORMATION);
         edit7.Text:='';
         edit7.SetFocus ;
         exit;
         end;
      if length(edit7.Text)<>2 then
         begin
         Application.MessageBox('請2位棒號!','消息',MB_ICONINFORMATION);
         edit7.Text:='';
         edit7.SetFocus ;
         exit;
         end;}
      if edit3.Text='' then
      begin
      Application.MessageBox('請輸入巡更員姓名!','消息',MB_ICONINFORMATION);
      edit3.SetFocus ;
      exit;
      end;
      dm_worker.q_find.First;
      if dm_worker.q_find.Locate('code',edit2.text,[loCaseInsensitive]) then
      begin
      Application.MessageBox('人員鈕號不能重復,請重新輸入!','消息',MB_ICONINFORMATION);
      edit2.SetFocus ;
      edit2.Text:='';
      exit;
      end;
      if edit1.Text<>'' then
      begin
      dm_worker.q_find.First;
      if dm_worker.Q_FIND.Locate('number',edit1.text,[loCaseInsensitive]) then
      begin
      Application.MessageBox('人員鈕號不能重復,請重新輸入!','消息',MB_ICONINFORMATION);
      edit1.SetFocus ;
      edit1.Text:='';
      exit;
      end;
      end;
      append;
      edit;
      fieldbyname('number').asstring:=uppercase(edit1.Text) ;
      fieldbyname('code').asstring:=uppercase(edit2.Text);
      //fieldbyname('pencode').asstring:=edit7.Text ;
      fieldbyname('name').asstring:=uppercase(edit3.Text);
      fieldbyname('address').asstring:=uppercase(edit4.Text);
      fieldbyname('phone').asstring:=uppercase(edit5.text);
      fieldbyname('pager').asstring:=uppercase(edit6.text);
      fieldbyname('sex').asstring:=uppercase(combobox1.text);
      fieldbyname('birthday').asdatetime:=dateedit1.Date;
      post;
      add_worker.Close ;
    except
      begin
      Application.MessageBox('資訊錄入有誤,請重新輸入','消息',MB_ICONINFORMATION);
      exit;
      end;
    end;
  end //增加
 else
  begin //修改
  bookmark1:=dm_worker.q_worker.GetBookmark;
  recno1:=dm_worker.q_worker.RecNo;
  try
  if edit2.Text='' then
      begin
      Application.MessageBox('請輸入巡更員鈕號!','消息',MB_ICONINFORMATION);
      edit2.SetFocus ;
      edit2.Text:='';
      exit;
      end;
      {if edit7.Text='' then
         begin
         Application.MessageBox('請輸入該巡更員所屬的棒號!','消息',MB_ICONINFORMATION);
         edit7.Text:='';
         edit7.SetFocus ;
         exit;
         end;
      if edit3.Text='' then
      begin
      Application.MessageBox('請輸入巡更員姓名!') ;
      edit3.SetFocus ;
      exit;
      end; }
      if dm_worker.q_worker.Locate('code',edit2.text,[loCaseInsensitive]) then
      begin
         recno2:=dm_worker.q_worker.RecNo;
         if recno1<>recno2 then
         begin
         Application.MessageBox('人員鈕號不能重復,請重新輸入!','消息',MB_ICONINFORMATION);
         edit2.setfocus;
         dm_worker.q_worker.gotobookmark(bookmark1);
         exit;
         end;
      end;
       if edit1.Text<>'' then
      begin
     if dm_worker.q_worker.Locate('number',edit1.text,[loCaseInsensitive]) then
        begin
        recno2:=dm_worker.q_worker.RecNo;
        if recno1<>recno2 then
         begin
          Application.MessageBox('人員鈕號不能重復,請重新輸入!','消息',MB_ICONINFORMATION);
          edit1.SetFocus ;
          edit1.Text:='';
          dm_worker.q_worker.gotobookmark(bookmark1);
          exit;
         end;
        end;
      end;
      //open;
      Locate('id',(dm_worker.q_worker.fieldbyname('id').asinteger),[loCaseInsensitive]);
      edit;
      //fieldbyname('pencode').asstring:=edit7.Text ;
      fieldbyname('number').asstring:=uppercase(edit1.Text) ;
      fieldbyname('code').asstring:=uppercase(edit2.Text);
      fieldbyname('name').asstring:=uppercase(edit3.Text);
      fieldbyname('address').asstring:=uppercase(edit4.Text);
      fieldbyname('phone').asstring:=uppercase(edit5.text);
      fieldbyname('pager').asstring:=uppercase(edit6.text);
      fieldbyname('birthday').asdatetime:=dateedit1.Date;
      fieldbyname('sex').asstring:=uppercase(combobox1.Text);
      post;
      with dm_worker.q_edit do
         begin
         close;
         sql.Clear ;
         sql.Add('update fpxl set code='''+uppercase(edit2.Text)+''' where code='''+uppercase(e_code)+'''');
         execsql;
         end;
      add_worker.Close;
    except
       begin
      Application.MessageBox('資料錄入有誤,請重新輸入','消息',MB_ICONINFORMATION);
      exit;
      end;
    end; // end try
  end;  //修改
 end;
end;

procedure Tadd_worker.Button1Click(Sender: TObject);
begin
Application.MessageBox(pchar('width='+inttostr(self.width)+'--'+'height='+inttostr(self.height)+'--'+'left='+inttostr(self.left)+'--top='+inttostr(self.top)),'消息',MB_ICONINFORMATION);

end;

procedure Tadd_worker.DateEdit1Exit(Sender: TObject);
var ss:tdate;
ii:string;
begin
try
ss:=(dateedit1.datetime) ;
if now<dateedit1.DateTime  then
begin
Application.MessageBox('出生日期不能大於系統當前日期!','消息',MB_ICONINFORMATION);
dateedit1.SetFocus ;
exit;
end;
ii:=formatdatetime('yyyy',now-dateedit1.DateTime);
//showmessage(ii);
if strtoint(ii)>2000 then
begin
Application.MessageBox('此人年齡過大,不適合巡更員工作,請選擇其他人員!','消息',MB_ICONINFORMATION);
dateedit1.SetFocus ;
exit;
end;
if strtoint(ii)<1910 then
begin
Application.MessageBox('此人年齡太小,不適合巡更員工作,請選擇其他人員!','消息',MB_ICONINFORMATION);
dateedit1.SetFocus ;
exit;
end;
except
Application.MessageBox('輸入的日期有誤!','消息',MB_ICONINFORMATION);
dateedit1.SetFocus ;
end;
end;

procedure Tadd_worker.Edit6KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
if key=vk_return then
BitBtn5click(self);
end;

procedure Tadd_worker.FormActivate(Sender: TObject);
var
inif:tinifile;
temp,path,filename:string;
begin
filename:=ExtractFiledir(APPLICATION.EXENAME)+'\'+ExtractFilename(APPLICATION.EXENAME);//+'\hdxgxt.ini';
if not fileexists(filename) then
filename:=ExtractFileDir(APPLICATION.EXENAME)+'hdxgxt.ini'
else filename:=extractfiledir(application.exename)+'\hdxgxt.ini';
inif:=TInifile.Create(filename);
_mode:=inif.readstring('penmode','mode',temp);

end;

procedure Tadd_worker.Edit7KeyPress(Sender: TObject; var Key: Char);
begin
  if (not (key in ['0'..'9']))  and (not (key in ['a'..'f']))and (not (key in ['A'..'F'])) then
     begin
     key:=#0;
     exit;
     end;
  if (key in ['a'..'f']) then
     begin
    key:=chr(ord(key)-32);
     end;
end;

end.

⌨️ 快捷键说明

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