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

📄 backupdata.~pas

📁 企业端数据申报系统:单位管理模块 单位查询. 业务申报模块 在线数据下载 在线数据上传 在线业务申核 申报业务查询 磁盘数据导出 磁盘数据导入 在线业务模块 在线业务
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
unit backupdata;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, basepop, StdCtrls, TFlatMemoUnit, TFlatButtonUnit, TFlatEditUnit,
  DB, DBTables,Math,StrUtils, ComCtrls, TFlatGaugeUnit, XPMenu,Registry,
  ActnList, jpeg, ExtCtrls,shellapi, TFlatComboBoxUnit, ztvregister,
  ztvBase, ztvZip;

const cLicenseString = '17055475153342401579512r612895AS';

type
  Tbackupdata_frm = class(Tbasepop_frm)
    Label1: TLabel;
    FE_filename: TFlatEdit;
    FB_fileselect: TFlatButton;
    M_info: TMemo;
    FB_backup: TFlatButton;
    FB_close: TFlatButton;
    SaveDialog1: TSaveDialog;
    ProgressBar1: TProgressBar;
    FlatGauge1: TFlatGauge;
    LB_list: TListBox;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    Panel1: TPanel;
    Image1: TImage;
    FB_help: TFlatButton;
    GroupBox3: TGroupBox;
    Memo3: TMemo;
    P_backup: TPanel;
    Label2: TLabel;
    FlatComboBox1: TFlatComboBox;
    Zip: TZip;
    procedure FB_fileselectClick(Sender: TObject);
    procedure FB_closeClick(Sender: TObject);
    procedure FB_backupClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    {procedure helpExecute(Sender: TObject);}
  private
    { Private declarations }
    hZip : LongInt;
    PB_pos:integer;
    procedure export_data(Query:TQuery;Sqlstr,filename:widestring;note:string);
  public
    { Public declarations }
  end;

  {function  XceedZipInitDLL : LongInt; stdcall; external 'XceedZip.DLL';
  function  XceedZipShutdownDLL : LongInt; stdcall; external 'XceedZip.DLL';

  function  XzCreateXceedZipA( pszLicense : PChar) : LongInt; stdcall; external 'XceedZip.DLL';
  procedure XzDestroyXceedZip( hZip : LongInt ); stdcall; external 'XceedZip.DLL';
  procedure XzSetXceedZipWindow( hZip : LongInt; hWnd : LongInt ); stdcall; external 'XceedZip.DLL';

  procedure XzSetZipFilenameA( hZip : LongInt; pszValue : PChar); stdcall; external 'XceedZip.DLL';
  procedure XzSetFilesToProcessA( hZip : LongInt; pszValue : PChar ); stdcall; external 'XceedZip.DLL';
  procedure XzSetProcessSubfolders( hZip : LongInt; bValue : LongInt ); stdcall; external 'XceedZip.DLL';
  procedure XzSetEncryptionPasswordA(hZip:LongInt;pwd:PChar); stdcall; external 'XceedZip.DLL';

  function  XzZip( hZip : LongInt ) : LongInt; stdcall; external 'XceedZip.DLL';
  function  XzGetErrorDescriptionA( hZip : LongInt; xType : LongInt; xCode : LongInt; pszBuffer : PChar; uMaxLength : LongInt ) : LongInt; stdcall; external 'XceedZip.DLL';}

var
  backupdata_frm: Tbackupdata_frm;

implementation

uses datashare, main, commlist, basedialog,hh, imp;
{$R *.dfm}
procedure Tbackupdata_frm.export_data(Query:TQuery;Sqlstr,filename:widestring;note:string);
var
  filehandle,i:integer;
  Namewithdir,ls_line:widestring; // dirstr,
  txt:Tstrings;
  //txtfile:Textfile;
begin
  NamewithDir:=extractfilepath(application.ExeName)+'Exportfile\'+filename+'.txt';
  txt:=Tstringlist.Create ;
  //filehandle:=Filecreate(namewithdir);
  {if filehandle<0 then
    begin
      application.MessageBox('数据导出异常!','恩普软件',mb_iconerror+mb_ok);
      exit;
    end;}
  {fileclose(filehandle);
  assignfile(txtfile,namewithdir);}
  try
  with Query do
    begin
      close;
      sql.Clear ;
      sql.Add(Sqlstr);
      prepare;
      open;
      while not eof do
        begin
          if not Fields[0].IsNull then   ls_line:=Fields[0].AsString else ls_line:='';
          for i:=1 to Fieldcount-1 do
            if not Fields[i].IsNull then ls_line:=ls_line+chr(9)+Fields[i].AsString
               else ls_line:=ls_line+char(9);
          txt.Add(ls_line);
          next;
        end;
      //memo1.Lines.Add('共导出'+inttostr(recordcount)+'条'+note+'信息.')
    end;
  except
    txt.Free ;
    application.MessageBox('导出异常!','恩普软件',mb_iconerror+mb_ok); 
   end;
   if Query.RecordCount>0 then
     begin
       txt.SaveToFile(NamewithDir);
       Flatcombobox1.Items.Add(NamewithDir);
     end;
   Query.Close ;  
   txt.Free ;
end;

{
procedure Tbackupdata_form.DelBackupFile();
begin
  if fileexists('cparch.dbf') then
    deletefile('cparch.dbf');
  if fileexists('homeinfo.dbf') then
    deletefile('homeinfo.dbf');
  if fileexists('infoctor.dbf') then
    deletefile('infoctor.dbf');
  if fileexists('manpay.dbf') then
    deletefile('manpay.dbf');
  if fileexists('organization.dbf') then
    deletefile('organization.dbf');
  if fileexists('organmap.dbf') then
    deletefile('organmap.dbf');
  if fileexists('pactinfo.dbf') then
    deletefile('pactinfo.dbf');
  if fileexists('psarch.dbf') then
    deletefile('psarch.dbf');
  if fileexists('psupcase.dbf') then
    deletefile('psupcase.dbf');
  if fileexists('pswgcase.dbf') then
    deletefile('pswgcase.dbf');
  if fileexists('pycpmain.dbf') then
    deletefile('pycpmain.dbf');
  if fileexists('pycpsel.dbf') then
    deletefile('pycpsel.dbf');
  if fileexists('pystp.dbf') then
    deletefile('pystp.dbf');
  if fileexists('pytbmt.dbf') then
    deletefile('pytbmt.dbf');
  if fileexists('refetab.dbf') then
    deletefile('refetab.dbf');
  if fileexists('studyinfo.dbf') then
    deletefile('studyinfo.dbf');
  if fileexists('traiinfo.dbf') then
    deletefile('traiinfo.dbf');
  if fileexists('unitright.dbf') then
    deletefile('unitright.dbf');
  if fileexists('userright.dbf') then
    deletefile('userright.dbf');
  if fileexists('users.dbf') then
    deletefile('users.dbf');
  if fileexists('workinfo.dbf') then
    deletefile('workinfo.dbf');
  with datashare_form.Query1 do
  begin
    close;
    sql.Clear;
    sql.Add('select tbname from pytbmt');
    prepare;
    open;
    while not eof do
    begin
      if fileexists(fieldbyname('tbname').AsString+'.dbf') then
        deletefile(fieldbyname('tbname').AsString+'.dbf');
      next;
    end;
  end;
end;

procedure Tbackupdata_form.CreateTab();
var
  ls_sql:string;
begin
  with query1 do
  begin
    ls_sql:='CREATE TABLE cparch (cpseno numeric(8,0) NOT NULL,cpcode char(8) NOT NULL';
    ls_sql:=ls_sql+',cpname char(60) NOT NULL,regno char(14),taxno char(24),eccode char(3)';
    ls_sql:=ls_sql+',atcode char(2),sbcode char(2),dpcode char(4),tdcode char(6),address char(40)';
    ls_sql:=ls_sql+',zip char(6),chief char(10),walla char(10),walladept char(20)';
    ls_sql:=ls_sql+',watel char(16),bank char(40),acname char(40),acctno char(20)';
    ls_sql:=ls_sql+',licode char(2),licno char(40),lidate date,lilife date,aufile char(18)';
    ls_sql:=ls_sql+',chid char(18),chtel char(20),opcode char(10),opdate date,procflg char(1)';
    ls_sql:=ls_sql+',lockflg char(1) )';
    close;
    sql.Clear;
    sql.Add(ls_sql);
    ExecSql;

    ls_sql:='CREATE TABLE psarch (psseno numeric(8,0) NOT NULL,cpseno numeric(6,0) NOT NULL,iscode char(18),agcardno char(8),psname char(10),';
    ls_sql:=ls_sql+'sex char(1),bdate date,household char(1),wkattr char(2),identity char(1),pflg char(1),wkdate date,joindate date,';
    ls_sql:=ls_sql+'status char(1),rewage numeric(8,2),topwage numeric(8,2),bfidyears numeric(4,2),folk char(8),spwktype char(1),';
    ls_sql:=ls_sql+'spwkyears numeric(4,2),workno char(8),marry char(1),govis char(16),cover char(16),healstat char(8),relatel char(12),';
    ls_sql:=ls_sql+'address char(50),indvid char(10),cultdegr char(2),degree char(3),special char(6),entetime date,organid integer,';
    ls_sql:=ls_sql+'wordsort char(6),dutyname char(7),cadrlevl char(4),prosduty char(3),wordid char(15),dbad char(16),chgstat char(16),';
    ls_sql:=ls_sql+'chantime date,otherinfo char(100),ifdel char(1),chaninfo char(30),manid numeric(8,0),chgreason char(3),';
    ls_sql:=ls_sql+'ifmodify char(1),opcode integer,opdate date,itcode numeric(4,0),lockflg char(1))';
    close;
    sql.Clear;
    sql.Add(ls_sql);
    ExecSql;

  end;
end;

procedure Tbackupdata_form.CparchBackup();
var
  ls_sql:string;
  i:integer;
begin
  i:=M_info.Lines.Add('正在备份单位基本信息表...');
  with query1 do
  begin
    ls_sql:='CREATE TABLE cparch (cpseno numeric(8,0) NOT NULL,cpcode char(8) NOT NULL';
    ls_sql:=ls_sql+',cpname char(60) NOT NULL,regno char(14),taxno char(24),eccode char(3)';
    ls_sql:=ls_sql+',atcode char(2),sbcode char(2),dpcode char(4),tdcode char(6),address char(40)';
    ls_sql:=ls_sql+',zip char(6),chief char(10),walla char(10),walladept char(20)';
    ls_sql:=ls_sql+',watel char(16),bank char(40),acname char(40),acctno char(20)';
    ls_sql:=ls_sql+',licode char(2),licno char(40),lidate date,lilife date,aufile char(18)';
    ls_sql:=ls_sql+',chid char(18),chtel char(20),opcode integer,opdate date,procflg char(1)';
    ls_sql:=ls_sql+',lockflg char(1) )';
    close;
    sql.Clear;
    sql.Add(ls_sql);
    ExecSql;
  end;

  with query2 do
  begin
    close;
    sql.Clear;
    sql.Add('select * from cparch');
    prepare;
    open;
    while not eof do
    begin
      ls_sql:='insert into cparch(cpseno,cpcode,cpname,regno,taxno,eccode,atcode,sbcode,dpcode,tdcode,address,zip,chief,walla,walladept,watel,bank,acname,acctno,licode,licno,lidate,lilife,aufile,chid,chtel,opcode,opdate,procflg,lockflg)';
      ls_sql:=ls_sql+' values('+fieldbyname('cpseno').AsString+','+chr(39)+fieldbyname('cpcode').AsString+chr(39)+','+chr(39)+fieldbyname('cpname').AsString+chr(39);
      ls_sql:=ls_sql+','+chr(39)+fieldbyname('regno').AsString+chr(39)+','+chr(39)+fieldbyname('taxno').AsString+chr(39)+','+chr(39)+fieldbyname('eccode').AsString+chr(39);
      ls_sql:=ls_sql+','+chr(39)+fieldbyname('atcode').AsString+chr(39)+','+chr(39)+fieldbyname('sbcode').AsString+chr(39)+','+chr(39)+fieldbyname('dpcode').AsString+chr(39);
      ls_sql:=ls_sql+','+chr(39)+fieldbyname('tdcode').AsString+chr(39)+','+chr(39)+fieldbyname('address').AsString+chr(39)+','+chr(39)+fieldbyname('zip').AsString+chr(39);
      ls_sql:=ls_sql+','+chr(39)+fieldbyname('chief').AsString+chr(39)+','+chr(39)+fieldbyname('walla').AsString+chr(39)+','+chr(39)+fieldbyname('walladept').AsString+chr(39);
      ls_sql:=ls_sql+','+chr(39)+fieldbyname('watel').AsString+chr(39)+','+chr(39)+fieldbyname('bank').AsString+chr(39)+','+chr(39)+fieldbyname('acname').AsString+chr(39);
      ls_sql:=ls_sql+','+chr(39)+fieldbyname('acctno').AsString+chr(39)+','+chr(39)+fieldbyname('licode').AsString+chr(39)+','+chr(39)+fieldbyname('licno').AsString+chr(39);
      ls_sql:=ls_sql+','+ifthen(fieldbyname('lidate').AsString='','null','ctod('+chr(39)+FormatDateTime('mm/dd/yyyy',fieldbyname('lidate').AsDateTime)+chr(39)+')')+','+ifthen(fieldbyname('lilife').AsString='','null','ctod('+chr(39)+FormatDateTime('mm/dd/yyyy',fieldbyname('lilife').AsDateTime)+chr(39)+')')+','+chr(39)+fieldbyname('aufile').AsString+chr(39);
      ls_sql:=ls_sql+','+chr(39)+fieldbyname('chid').AsString+chr(39)+','+chr(39)+fieldbyname('chtel').AsString+chr(39)+','+ifthen(fieldbyname('opcode').AsString='','null',fieldbyname('opcode').AsString);
      ls_sql:=ls_sql+','+ifthen(fieldbyname('opdate').AsString='','null','ctod('+chr(39)+FormatDateTime('mm/dd/yyyy',fieldbyname('opdate').AsDateTime)+chr(39)+')')+','+chr(39)+fieldbyname('procflg').AsString+chr(39)+','+chr(39)+fieldbyname('lockflg').AsString+chr(39)+')';
      query1.Close;
      query1.SQL.Clear;
      query1.SQL.Add(ls_sql);
      query1.ExecSQL;
      next;
    end;
  end;
  M_info.Lines.Delete(i);
  m_info.Lines.Add('正在备份单位基本信息表...已备份!');
  ProgressBar1.Position:=PB_pos;
  FlatGauge1.Progress:=PB_pos;
end;

procedure Tbackupdata_form.OrganizationBackup();
var
  ls_sql:string;
  i:integer;
begin
  i:=M_info.Lines.Add('正在备份机构设置信息表...');
  with query1 do
  begin
    ls_sql:='CREATE TABLE organization (parentid integer NOT NULL,id integer NOT NULL,name char(100) NOT NULL,';
    ls_sql:=ls_sql+'disptype integer NOT NULL,describe char(254) NOT NULL,cpseno numeric(6,0))';
    close;
    sql.Clear;
    sql.Add(ls_sql);
    ExecSql;
  end;

  with query2 do
  begin
    close;
    sql.Clear;
    sql.Add('select * from organization');
    prepare;
    open;
    while not eof do
    begin
      ls_sql:='insert into organization(parentid,id,name,disptype,describe,cpseno)';
      ls_sql:=ls_sql+' values('+fieldbyname('parentid').AsString+','+fieldbyname('id').AsString+','+chr(39)+fieldbyname('name').AsString+chr(39);
      ls_sql:=ls_sql+','+fieldbyname('disptype').AsString+','+chr(39)+fieldbyname('describe').AsString+chr(39)+','+fieldbyname('cpseno').AsString+')';
      query1.Close;
      query1.SQL.Clear;
      query1.SQL.Add(ls_sql);
      query1.ExecSQL;
      next;
    end;
  end;
  M_info.Lines.Delete(i);
  m_info.Lines.Add('正在备份机构设置信息表...已备份!');
  ProgressBar1.Position:=PB_pos;
  FlatGauge1.Progress:=PB_pos;
end;

procedure Tbackupdata_form.OrganmapBackup();
var
  ls_sql:string;
  i:integer;
begin
  i:=M_info.Lines.Add('正在备份机构映射信息表...');
  with query1 do
  begin
    ls_sql:='CREATE TABLE organmap (id integer NOT NULL,parentid integer NOT NULL,name char(100) NOT NULL,disptype integer NOT NULL,';
    ls_sql:=ls_sql+'describe char(254) NOT NULL,groupid numeric(8,0) NOT NULL,cpseno numeric(8,0))';
    close;
    sql.Clear;
    sql.Add(ls_sql);
    ExecSql;
  end;

⌨️ 快捷键说明

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