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

📄 menu.pas

📁 delphi6.0电子寻更源程序,用来计算保安有无查抄
💻 PAS
📖 第 1 页 / 共 4 页
字号:
child:tyxxx_form;
begin
child:=tyxxx_form.Create(application) ;
child.show;
end;

procedure Tmainform.ToolButton21Click(Sender: TObject);
begin
click_time:=tclick_time.Create(self);
click_time.ShowModal ;
click_time.free;

end;

procedure Tmainform.Action1Execute(Sender: TObject);
begin
  if not Assigned(point) then
    point:=tpoint.Create(self);
  ShowWindow(point.Handle,SW_MAXIMIZE);
// point.ShowModal ;
// point.free;
end;

procedure Tmainform.Action2Execute(Sender: TObject);
begin
  if not Assigned(worker) then
    worker :=tworker.Create(self);
  ShowWindow(worker.Handle,SW_MAXIMIZE);
end;

procedure Tmainform.Action3Execute(Sender: TObject);
begin
  if not Assigned(class_form) then
    class_form :=tclass_form.Create(self);
  ShowWindow(class_form.Handle,SW_MAXIMIZE);
end;

procedure Tmainform.Action4Execute(Sender: TObject);
var
  child:tfpxl;
begin
  fpxl:=tfpxl.create(self);
  fpxl.ShowModal ;
  fpxl.free;
end;

procedure Tmainform.Action5Execute(Sender: TObject);
begin
  click_time:=tclick_time.Create(self);
  click_time.ShowModal ;
  click_time.free;
end;

procedure Tmainform.Action6Execute(Sender: TObject);
begin
  add_penform:=tadd_penform.Create(self);
  add_penform.ShowModal ;
  add_penform.free;
end;

procedure Tmainform.xtAction7Execute(Sender: TObject);
var
 Child: Tuser;
begin
  user:=tuser.Create(self);
  user.ShowModal ;
  user.free;
end;

procedure Tmainform.xtAction8Execute(Sender: TObject);
var child:tpass;
begin
pass:=Tpass.create(self);
pass.ShowModal ;
pass.free;
end;

procedure Tmainform.xtAction9Execute(Sender: TObject);
 var
   count:integer;
    mytextfile: textfile;
    filename:string;
    linestr: string;
    str:string;
    flag:boolean;
begin
flag:=false;
count:=0;
      //初始化变量
//progressbar1.Position := 0;
//得到要保存的数据库记录
  with query1 do
    begin
      close;
      sql.Clear;
      sql.Add('select * from patrolrec order by dataseq');
      prepare;
      open;
      count:=recordcount;
      //if count=0 then
      //begin
     // Application.MessageBox('没有巡更信息需要备份!','消息',MB_ICONINFORMATION);
     // exit;
     // end;  //巡更信息
      close;
      sql.clear;
      sql.add('select * from point ') ;
      prepare;
      open;
      count:=count+recordcount;  //巡更点信息
      close;
      sql.clear;
      sql.add('select * from worker ') ;
      prepare;
      open;
      count:=count+recordcount;  //人员信息
      close;
      sql.clear;
      sql.add('select * from shiftrule ') ;
      prepare;
      open;
      count:=count+recordcount;  //班次信息
      close;
      sql.clear;
      sql.add('select * from fpxl ') ;
      prepare;
      open;
      count:=count+recordcount;  //线路分配信息信息
    end;
       if Count =0 then
    begin
    Application.MessageBox('資料庫中沒有需要備份的資料!','消息',MB_ICONINFORMATION);
    exit;
    end
    else
    begin
      if Application.MessageBox('確實要備份嗎?','消息', MB_ICONINFORMATION+MB_OKCANCEL) = IDOK then
         begin//0.1
      savedialog1.Filter:='文本文件(*.hdx)|*.hdx';
      savedialog1.InitialDir:=ExtractFiledir(APPLICATION.EXENAME);
      //flage:=savedialog1.Execute;
      while  not flag do
       begin  //00
        flag:=true;
          if savedialog1.Execute then
           begin            //11
            filename:=savedialog1.FileName;
            str:=filename+'已經存在,請重新選擇檔案名稱!' ;
              if FileExists(filename) then
                begin       //999
                 flag:=false;
                 Application.MessageBox(Pchar(str),'消息',MB_ICONINFORMATION);
                  //if messagedlg(str,mtconfirmation,[mbyes,mbno],0)= mrno then
                   //begin   //99
                   //end;  //99
                end;     //999
          end  //11
          else
           begin
           exit;
           end;
         end;    //00
         end;
        //assignfile(mytextfile,filename);
        //filesetattr(filename,4);
         panel4.Visible :=true;
         panel4.Height:=65;
         panel4.Width:=537;
         panel4.left:=round((screen.Width-panel4.Width)/2);
         panel4.top:=round((screen.height-panel4.height)/2)-50;
         progressbar1.Position := 0;
         rxlabel3.Update;
         progressbar1.Width:=520;
         progressbar1.Max:=Count;
  //创建文本文件并进行异常处理
       assignfile(mytextfile,filename);
       filesetattr(filename,4);
  try
  rewrite(mytextfile);
 //writeln(mytextfile,encrypt('xfry'));
  writeln(mytextfile,('xfry'));   //备份巡更信息
  with query1  do
    begin
    close;
    sql.Clear;
    sql.Add('select * from patrolrec order by dataseq');
    prepare;
    open;
    first ;
    while not eof do
      begin
      linestr:=datetimetostr(FieldByName('pdate').Asdatetime);
      linestr:=linestr+'|'+timetostr(FieldByName('ptime').Asdatetime);
      linestr:=linestr+'|'+FieldByName('pencode').Asstring;
      linestr:=linestr+'|'+FieldByName('node').AsString;
      linestr:=linestr+'|'+FieldByName('workercode').AsString;
      linestr:=linestr+'|'+FieldByName('pstatu').AsString;
      linestr:=linestr+'|'+FieldByName('nodename').AsString;
      linestr:=linestr+'|'+FieldByName('nodeplace').AsString;
      linestr:=linestr+'|'+FieldByName('workername').AsString;
      linestr:=linestr+'|'+FieldByName('linename').asstring;
      linestr:=linestr+'|'+inttostr(FieldByName('lseq').Asinteger)+'|';
      //linestr:=encrypt(linestr);
      writeln(mytextfile,linestr);
      next;
      progressbar1.Position := progressbar1.Position +1;
      end;
    end;
   writeln(mytextfile,('point'));   //备份巡更点信息
  with query1  do
    begin
    close;
    sql.Clear;
    sql.Add('select * from point order by node');
    prepare;
    open;
    first ;
    while not eof do
      begin
      linestr:=fieldbyname('node').asstring;
      linestr:=linestr+'|'+FieldByName('linename').asstring;
      linestr:=linestr+'|'+FieldByName('name').Asstring;
      linestr:=linestr+'|'+inttostr(FieldByName('lseq').Asinteger);
      linestr:=linestr+'|'+inttostr(FieldByName('ntime').Asinteger);
      linestr:=linestr+'|'+FieldByName('nodeplace').AsString+'|';
     // linestr:=encrypt(linestr);
      writeln(mytextfile,linestr);
      next;
      progressbar1.Position := progressbar1.Position +1;
      end;
    end;
   writeln(mytextfile,('worker'));   //备份巡更员信息
  with query1  do
    begin
    close;
    sql.Clear;
    sql.Add('select * from worker order by code');
    prepare;
    open;
    first ;
    while not eof do
      begin
      linestr:=fieldbyname('code').asstring;
      linestr:=linestr+'|'+FieldByName('name').asstring;
      linestr:=linestr+'|'+datetostr(FieldByName('birthday').asdatetime);
      linestr:=linestr+'|'+FieldByName('sex').Asstring;
      linestr:=linestr+'|'+FieldByName('address').Asstring;
      linestr:=linestr+'|'+FieldByName('phone').Asstring;
      linestr:=linestr+'|'+FieldByName('pager').AsString;
      //linestr:=linestr+'|'+FieldByName('pager').AsString;
      linestr:=linestr+'|'+fieldbyname('number').asstring+'|';
      //linestr:=encrypt(linestr);
      writeln(mytextfile,linestr);
      next;
      progressbar1.Position := progressbar1.Position +1;
      end;
    end;
   writeln(mytextfile,('shiftrule'));   //备份班次信息
  with query1  do
    begin
    close;
    sql.Clear;
    sql.Add('select * from shiftrule');
    prepare;
    open;
    first ;
    while not eof do
      begin
      linestr:=fieldbyname('linename').asstring;
      linestr:=linestr+'|'+FieldByName('shifts').asstring;
      //linestr:=linestr+'|'+datetostr(FieldByName('birthday').asdatetime);
      linestr:=linestr+'|'+timetostr(FieldByName('firstp').Asdatetime);
      linestr:=linestr+'|'+timetostr(FieldByName('lastp').Asdatetime);
      linestr:=linestr+'|'+inttostr(FieldByName('chkcycl').Asinteger);
      linestr:=linestr+'|'+inttostr(FieldByName('dgpcxx').Asinteger);
      linestr:=linestr+'|'+inttostr(FieldByName('dgpcSX').Asinteger);
      linestr:=linestr+'|'+inttostr(FieldByName('TIMES').Asinteger)+'|';
      //linestr:=encrypt(linestr);
      writeln(mytextfile,linestr);
      next;
      progressbar1.Position := progressbar1.Position +1;
      end;
    end;
   writeln(mytextfile,('fpxl'));   //备份巡更信息
  with query1  do
    begin
    close;
    sql.Clear;
    sql.Add('select * from fpxl');
    prepare;
    open;
    first ;
    while not eof do
      begin
      linestr:=FieldByName('code').Asstring;
      linestr:=linestr+'|'+FieldByName('shift').AsString;
      linestr:=linestr+'|'+FieldByName('linename').AsString+'|';
      //linestr:=encrypt(linestr);
      writeln(mytextfile,linestr);
      next;
      progressbar1.Position := progressbar1.Position +1;
      end;
    end;
 //异常处理
    except
     //on einouterror do
    begin
      panel4.Visible:=false;
       try
       closefile(mytextfile);
       except
       Application.MessageBox('資料備份産生錯誤!','消息',MB_ICONINFORMATION);
       EXIT;
       end;
       Application.MessageBox('資料備份産生錯誤!','消息',MB_ICONINFORMATION);
       closefile(mytextfile);
      exit;
    end;
  end;  //end try
  filesetattr(filename,1);
  closefile(mytextfile);
  Application.MessageBox('資料備份成功!','消息',MB_ICONINFORMATION);
  panel4.Visible :=false;
  end;

 panel4.Visible:=false;
end;

procedure Tmainform.xtAction10Execute(Sender: TObject);
var mytextfile:textfile;
filename:string;
linestr:string;
i,j:integer;
a:array[1..2] of integer;
flag:boolean;
//sql:array[1..1000] of tquery;
//sql1:tquery;
begin
flag:=false;
for i:=1 to 2 do
begin
a[i]:=0;
end;
  if Application.MessageBox('資料恢復後,將刪除以前的記錄!是否執行資料恢復操作?','消息', MB_ICONINFORMATION+MB_OKCANCEL) = IDOK then
begin//0.1
  opendialog1.filter:='文本文件(*.hdx)|*.hdx';
  opendialog1.InitialDir:=ExtractFiledir(APPLICATION.EXENAME);
  try
   while not flag do
    begin //begin while
    flag:=true;
     if opendialog1.Execute then
      begin
       filename:=opendialog1.FileName;
        if not FileExists(filename) then
         begin
         Application.MessageBox(Pchar(filename+'不存在,請重新選擇!'),'消息',MB_ICONINFORMATION);
         flag:=false;
         end;
      end
     else
     exit;
    end;
   progressbar2.Position := 0;
   panel1.Visible:=true;
   panel1.Height:=65;
   panel1.Width:=537;
   panel1.left :=round((screen.Width-panel1.Width)/2);
   panel1.top:=round((screen.height-panel1.height)/2)-50;
   progressbar2.Width:=520;
   rxlabel4.Update ;
   assignfile(mytextfile,filename);
   reset(mytextfile);
   readln(mytextfile,linestr);
   //linestr:=decrypt(linestr);
   while not eoln(mytextfile)  do
      begin
       readln(mytextfile,linestr);
       if linestr='point' then
       break;
       a[1]:=a[1]+1;
      end;
   while not eoln(mytextfile)  do
      begin
       readln(mytextfile,linestr);
       a[2]:=a[2]+1;
      end;
      progressbar2.max :=a[1]*2+a[2]-4;//计算进度数量
   except
      panel1.Visible:=false;
      Application.MessageBox('文件選擇有誤,請重新選擇!','消息',MB_ICONINFORMATION);
      exit;
   end;
     // showmessage(inttostr(progressbar2.max)+'#1') ;
        //showmessage(inttostr(i));
      dm_sjbf.Database1.StartTransaction ;
     try
      with dm_sjbf.q_point do
    begin
    close;
    open;
    first;
    while not eof do
    begin
    delete;
    end;
    end;
      with dm_sjbf.q_worker do
    begin
    close;
    open;
    first;
    while not eof do
    begin
    delete;
    end;
    end;
      with dm_sjbf.q_shiftrule do
    begin
    close;
    open;
    first;
    while not eof do
    begin
    delete;
    end;
    end;
      with dm_sjbf.q_fpxl do
    begin
    close;

⌨️ 快捷键说明

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