123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619 |
- $PBExportHeader$w_backup_cleardata.srw
- forward
- global type w_backup_cleardata from window
- end type
- type st_1 from statictext within w_backup_cleardata
- end type
- type cb_1 from commandbutton within w_backup_cleardata
- end type
- type cbx_winrar from checkbox within w_backup_cleardata
- end type
- type cb_clearalldata from commandbutton within w_backup_cleardata
- end type
- type cb_cleardata from commandbutton within w_backup_cleardata
- end type
- type cb_exit from commandbutton within w_backup_cleardata
- end type
- type cb_restore from commandbutton within w_backup_cleardata
- end type
- type cb_backup from commandbutton within w_backup_cleardata
- end type
- type cb_ch from commandbutton within w_backup_cleardata
- end type
- type sle_filename from singlelineedit within w_backup_cleardata
- end type
- type gb_2 from groupbox within w_backup_cleardata
- end type
- type gb_1 from groupbox within w_backup_cleardata
- end type
- end forward
- global type w_backup_cleardata from window
- integer x = 814
- integer y = 864
- integer width = 1993
- integer height = 856
- boolean titlebar = true
- string title = "数据库备份与恢复"
- boolean minbox = true
- boolean maxbox = true
- boolean resizable = true
- long backcolor = 79741120
- st_1 st_1
- cb_1 cb_1
- cbx_winrar cbx_winrar
- cb_clearalldata cb_clearalldata
- cb_cleardata cb_cleardata
- cb_exit cb_exit
- cb_restore cb_restore
- cb_backup cb_backup
- cb_ch cb_ch
- sle_filename sle_filename
- gb_2 gb_2
- gb_1 gb_1
- end type
- global w_backup_cleardata w_backup_cleardata
- type variables
- string backupcmmd
- string restorecmmd
- BOOLEAN OL_BACKUP=TRUE
- string database,userid,dbpass,servername,isql
- end variables
- forward prototypes
- public function integer wf_cleardata ()
- public function integer wf_clearalldata ()
- end prototypes
- public function integer wf_cleardata ();//wf_cleardata
- long rslt=1,ls_d
- string arg_msg
- ls_d=f_cleardata(false,arg_msg)
- messagebox(string(ls_d),'清除数据操作完毕!'+arg_msg)
- return rslt
- end function
- public function integer wf_clearalldata ();//TRUNCATE TABLE
- long rslt=1,ls_d
- string arg_msg
- ls_d=f_cleardata(true,arg_msg)
- messagebox(string(ls_d),'清除数据操作完毕!'+arg_msg)
- return rslt
- end function
- on w_backup_cleardata.create
- this.st_1=create st_1
- this.cb_1=create cb_1
- this.cbx_winrar=create cbx_winrar
- this.cb_clearalldata=create cb_clearalldata
- this.cb_cleardata=create cb_cleardata
- this.cb_exit=create cb_exit
- this.cb_restore=create cb_restore
- this.cb_backup=create cb_backup
- this.cb_ch=create cb_ch
- this.sle_filename=create sle_filename
- this.gb_2=create gb_2
- this.gb_1=create gb_1
- this.Control[]={this.st_1,&
- this.cb_1,&
- this.cbx_winrar,&
- this.cb_clearalldata,&
- this.cb_cleardata,&
- this.cb_exit,&
- this.cb_restore,&
- this.cb_backup,&
- this.cb_ch,&
- this.sle_filename,&
- this.gb_2,&
- this.gb_1}
- end on
- on w_backup_cleardata.destroy
- destroy(this.st_1)
- destroy(this.cb_1)
- destroy(this.cbx_winrar)
- destroy(this.cb_clearalldata)
- destroy(this.cb_cleardata)
- destroy(this.cb_exit)
- destroy(this.cb_restore)
- destroy(this.cb_backup)
- destroy(this.cb_ch)
- destroy(this.sle_filename)
- destroy(this.gb_2)
- destroy(this.gb_1)
- end on
- event open;database =ProfileString (sys_inifilename, "database", "database", '')
- userid =ProfileString (sys_inifilename, "database", "userid", '')
- dbpass =f_psw_bczh(ProfileString (sys_inifilename, "database", "dbpass",''),1,sys_power_key)
- servername=ProfileString (sys_inifilename, "database", "servername", '')
- ISQL =ProfileString (sys_inifilename, "database", "ISQL", '')
- //IF RIGHT(LOWER(isql),8)<>'isql.exe' or not fileexists(isql) THEN
- // MESSAGEBOX('','请在系统数据连接设置中正确指示ISQL.EXE文件!')
- // CLOSE(THIS)
- //END IF
- IF Message.DoubleParm = 1 THEN
- OL_BACKUP=FALSE
- END IF
- end event
- type st_1 from statictext within w_backup_cleardata
- integer x = 178
- integer y = 352
- integer width = 974
- integer height = 76
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 255
- long backcolor = 67108864
- boolean enabled = false
- string text = "注意:[此功能要先安装winrar压缩软件]"
- alignment alignment = right!
- boolean focusrectangle = false
- end type
- type cb_1 from commandbutton within w_backup_cleardata
- integer x = 1449
- integer y = 444
- integer width = 384
- integer height = 96
- integer taborder = 60
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- string text = "清空系统信息"
- end type
- event clicked;if not sys_power_issuper then
- messagebox('提示','非管理员不可以操作', Information!, OK! )
- return
- end if
- string comm,msg
- integer bttn
- bttn=messagebox("警告!","是否进行"+this.text+"操作?",exclamation!,OKCancel!,2)
- if bttn=2 then
- RETURN
- end if
- comm='TRUNCATE TABLE sys_DB_version'
- Execute immediate :comm ;
- if sqlca.sqlcode<>0 then
- msg='操作失败>'+sqlca.sqlerrtext
- rollback;
- messagebox('提示',msg, Information!, OK! )
- else
- commit;
- messagebox('提示','操作成功,请稍后从新进入本系统!', Information!, OK! )
- end if
- HALT
- end event
- type cbx_winrar from checkbox within w_backup_cleardata
- integer x = 101
- integer y = 264
- integer width = 539
- integer height = 76
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 16711680
- long backcolor = 67108864
- string text = "备份且winrar加密"
- end type
- type cb_clearalldata from commandbutton within w_backup_cleardata
- integer x = 571
- integer y = 612
- integer width = 617
- integer height = 96
- integer taborder = 40
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- string text = "备份且清空全部数据"
- end type
- event clicked;if not sys_power_issuper then
- messagebox('提示','非管理员不可以操作', Information!, OK! )
- return
- end if
- string arg_msg
- if f_backup_db(cbx_winrar.checked,database,sle_filename.text,arg_msg)=0 then
- messagebox('提示',arg_msg, Information!, OK! )
- return
- end if
- messagebox('提示',arg_msg, Information!, OK! )
- if messagebox("询问","确定要清空当前数据库的全部数据吗!是否进行操作?",exclamation!,OKCancel!,2)=2 then
- RETURN
- end if
-
- wf_clearalldata()
- //------日志
- f_setsysoplog('数据删除','系统登录删除(全部数据),用户:'+publ_operator,arg_msg,TRUE)
- //------
- end event
- type cb_cleardata from commandbutton within w_backup_cleardata
- integer x = 571
- integer y = 444
- integer width = 617
- integer height = 96
- integer taborder = 30
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- boolean enabled = false
- string text = "备份且清空业务数据"
- end type
- event clicked;IF NOT sys_power_issuper THEN
- MessageBox('提示','非管理员不可以操作', Information!, OK! )
- RETURN
- END IF
- String arg_msg
- IF f_backup_db(cbx_winrar.Checked,Database,sle_filename.Text,arg_msg) = 0 THEN
- MessageBox('提示',arg_msg, Information!, OK! )
- RETURN
- END IF
- MessageBox('提示',arg_msg, Information!, OK! )
- IF MessageBox("警告!","确定要清空当前数据库的业务数据吗?恢复数据只能通过数据库的备份还原!是否进行操作?",exclamation!,OKCancel!,2) = 2 THEN
- RETURN
- END IF
- wf_cleardata()
- //------日志
- f_setsysoplog('数据删除','系统登录删除(业务数据),用户:'+publ_operator,arg_msg,TRUE)
- //------
- //string comm,msg
- //
- //comm='BACKUP DATABASE '+database+' TO DISK= ~''+sle_filename.text+'~' with init '
- //
- //transaction ls_transsqlca
- //ls_transsqlca=create transaction
- //
- //ls_transsqlca.DBMS=sqlca.DBMS
- //ls_transsqlca.database = 'master'
- //ls_transsqlca.userid=sqlca.userid
- //ls_transsqlca.dbpass=sqlca.dbpass
- //ls_transsqlca.logid=sqlca.logid
- //ls_transsqlca.logpass=sqlca.logpass
- //ls_transsqlca.servername=sqlca.servername
- //ls_transsqlca.dbparm=sqlca.dbparm
- //
- //if ls_transsqlca.database='' or ls_transsqlca.servername='' then
- // Messagebox("系统提示","连接数据管理库失败!")
- // return
- //end if
- //w_sys_wait.show()
- //connect using ls_transsqlca;
- //ls_transsqlca.autocommit=true
- //
- //Execute immediate :comm using ls_transsqlca;
- //w_sys_wait.hide()
- //if ls_transsqlca.sqlcode<>0 then
- // msg='备份操作失败>'+ls_transsqlca.sqlerrtext
- // rollback;
- // messagebox('系统提示',msg)
- //else
- // commit;
- // messagebox('系统提示','备份操作成功!')
- //
- // if messagebox("警告!","确定要清空当前数据库的业务数据吗?恢复数据只能通过数据库的备份还原!是否进行操作?",exclamation!,OKCancel!,2)=2 then
- // RETURN
- // end if
- //
- // wf_cleardata()
- //
- //end if
- //
- //destroy ls_transsqlca
- end event
- type cb_exit from commandbutton within w_backup_cleardata
- integer x = 1513
- integer y = 612
- integer width = 320
- integer height = 96
- integer taborder = 80
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- string text = "退出"
- end type
- event clicked;close(parent)
- end event
- type cb_restore from commandbutton within w_backup_cleardata
- integer x = 133
- integer y = 612
- integer width = 320
- integer height = 96
- integer taborder = 70
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- boolean enabled = false
- string text = "恢复"
- end type
- event clicked;if not sys_power_issuper then
- messagebox('提示','非管理员不可以操作', Information!, OK! )
- return
- end if
- //string ls_str
- //ls_str=ProfileString(sys_inifilename,'SERVER','SERVER','')
- //if trim(ls_str)="" then
- // messagebox("操作错误","必须在服务器上进行恢复操作",stopsign!)
- // close(parent)
- // return
- //end if
- string comm,msg
- integer bttn
- bttn=messagebox("警告!","如果数据库已经存在,此操作将使当前数据被覆盖,是否进行操作?",exclamation!,OKCancel!,2)
- if bttn=2 then
- RETURN
- end if
- bttn=messagebox("提示","请确保无其他用户使用系统,否则将会出现错误,是否准备好?",Question!,YesNo!,2)
- if bttn=2 then
- RETURN
- end if
- comm='restore DATABASE '+database+' from DISK= ~''+sle_filename.text+'~' with replace'
- transaction ls_transsqlca
- ls_transsqlca=create transaction
- ls_transsqlca.DBMS=sqlca.DBMS
- ls_transsqlca.database = 'master'
- ls_transsqlca.userid=sqlca.userid
- ls_transsqlca.dbpass=sqlca.dbpass
- ls_transsqlca.logid=sqlca.logid
- ls_transsqlca.logpass=sqlca.logpass
- ls_transsqlca.servername=sqlca.servername
- ls_transsqlca.dbparm=sqlca.dbparm
- if ls_transsqlca.database='' or ls_transsqlca.servername='' then
- Messagebox("提示","连接数据管理库失败!", Information!, OK! )
- return
- end if
- w_sys_wait.show()
- connect using ls_transsqlca;
- ls_transsqlca.autocommit=true
- DISCONNECT using sqlca;
- Execute immediate :comm using ls_transsqlca;
- w_sys_wait.hide()
- if ls_transsqlca.sqlcode<>0 then
- msg='恢复操作失败>'+ls_transsqlca.sqlerrtext
- rollback;
- messagebox('提示',msg, Information!, OK! )
- else
- commit;
- messagebox('提示','恢复操作成功,请稍后从新进入本系统!', Information!, OK! )
- end if
- destroy ls_transsqlca
- HALT
- end event
- type cb_backup from commandbutton within w_backup_cleardata
- integer x = 133
- integer y = 444
- integer width = 320
- integer height = 96
- integer taborder = 50
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- boolean enabled = false
- string text = "备份"
- end type
- event clicked;if not f_power_ind(161) then
- messagebox(publ_operator,'你没有使用权限!', Information!, OK! )
- return
- end if
- IF FileExists(sle_filename.text) THEN
- Messagebox('提示','备份文件已经存在,请重新填写备份文件名!', Information!, OK! )
- RETURN
- END IF
- string arg_msg
- f_backup_db(cbx_winrar.checked,database,sle_filename.text,arg_msg)
- messagebox('提示',arg_msg, Information!, OK! )
- //string comm,msg
- //
- //comm='BACKUP DATABASE '+database+' TO DISK= ~''+sle_filename.text+'~' with init '
- //
- //transaction ls_transsqlca
- //ls_transsqlca=create transaction
- //
- //ls_transsqlca.DBMS=sqlca.DBMS
- //ls_transsqlca.database = 'master'
- //ls_transsqlca.userid=sqlca.userid
- //ls_transsqlca.dbpass=sqlca.dbpass
- //ls_transsqlca.logid=sqlca.logid
- //ls_transsqlca.logpass=sqlca.logpass
- //ls_transsqlca.servername=sqlca.servername
- //ls_transsqlca.dbparm=sqlca.dbparm
- //
- //if ls_transsqlca.database='' or ls_transsqlca.servername='' then
- // Messagebox("系统提示","连接数据管理库失败!")
- // return
- //end if
- //w_sys_wait.show()
- //connect using ls_transsqlca;
- //ls_transsqlca.autocommit=true
- //
- //Execute immediate :comm using ls_transsqlca;
- //w_sys_wait.hide()
- //if ls_transsqlca.sqlcode<>0 then
- // msg='备份操作失败>'+ls_transsqlca.sqlerrtext
- // rollback;
- // messagebox('系统提示',msg)
- //else
- // commit;
- // messagebox('系统提示','备份操作成功!')
- //end if
- //
- //destroy ls_transsqlca
- //
- end event
- type cb_ch from commandbutton within w_backup_cleardata
- integer x = 1719
- integer y = 128
- integer width = 114
- integer height = 92
- integer taborder = 20
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- string text = "..."
- end type
- event clicked;//ole_openfile.object.filter="*.dat"
- //ole_openfile.object.defaultext="dat"
- //ole_openfile.object.showSAVE()
- //if trim(ole_openfile.object.filename)<>"" then
- // sle_filename.text=ole_openfile.object.filename
- // cb_backup.enabled=true
- // cb_restore.enabled=true
- //end if
- /////////////////old
- //new
- integer i
- string pathname,filename
- i=getfilesavename("选择备份文件",pathname,filename,"Dat","数据文件Dat,*.Dat")
- IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN
- cb_backup.enabled=OL_BACKUP
- cb_cleardata.enabled=OL_BACKUP
- cb_restore.enabled=true
- sle_filename.text=pathname
- END IF
- end event
- type sle_filename from singlelineedit within w_backup_cleardata
- event key pbm_keydown
- integer x = 133
- integer y = 128
- integer width = 1586
- integer height = 92
- integer taborder = 10
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- borderstyle borderstyle = stylelowered!
- end type
- event key;if trim(this.text)="" then
- cb_backup.enabled=false
- cb_restore.enabled=false
- cb_cleardata.enabled=false
- else
- cb_backup.enabled=OL_BACKUP
- cb_restore.enabled=true
- cb_cleardata.enabled=true
- end if
- end event
- event modified;if trim(this.text)="" then
- cb_backup.enabled=false
- cb_restore.enabled=false
- cb_cleardata.enabled=false
- else
- cb_backup.enabled=OL_BACKUP
- cb_restore.enabled=true
- cb_cleardata.enabled=OL_BACKUP
- end if
- end event
- type gb_2 from groupbox within w_backup_cleardata
- integer x = 73
- integer y = 268
- integer width = 1193
- integer height = 332
- integer taborder = 60
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- long backcolor = 67108864
- end type
- type gb_1 from groupbox within w_backup_cleardata
- integer x = 73
- integer y = 48
- integer width = 1810
- integer height = 216
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- long backcolor = 79741120
- string text = "备份文件路径"
- end type
|