w_backup_cleardata.srw 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. $PBExportHeader$w_backup_cleardata.srw
  2. forward
  3. global type w_backup_cleardata from window
  4. end type
  5. type st_1 from statictext within w_backup_cleardata
  6. end type
  7. type cb_1 from commandbutton within w_backup_cleardata
  8. end type
  9. type cbx_winrar from checkbox within w_backup_cleardata
  10. end type
  11. type cb_clearalldata from commandbutton within w_backup_cleardata
  12. end type
  13. type cb_cleardata from commandbutton within w_backup_cleardata
  14. end type
  15. type cb_exit from commandbutton within w_backup_cleardata
  16. end type
  17. type cb_restore from commandbutton within w_backup_cleardata
  18. end type
  19. type cb_backup from commandbutton within w_backup_cleardata
  20. end type
  21. type cb_ch from commandbutton within w_backup_cleardata
  22. end type
  23. type sle_filename from singlelineedit within w_backup_cleardata
  24. end type
  25. type gb_2 from groupbox within w_backup_cleardata
  26. end type
  27. type gb_1 from groupbox within w_backup_cleardata
  28. end type
  29. end forward
  30. global type w_backup_cleardata from window
  31. integer x = 814
  32. integer y = 864
  33. integer width = 1993
  34. integer height = 856
  35. boolean titlebar = true
  36. string title = "数据库备份与恢复"
  37. boolean minbox = true
  38. boolean maxbox = true
  39. boolean resizable = true
  40. long backcolor = 79741120
  41. st_1 st_1
  42. cb_1 cb_1
  43. cbx_winrar cbx_winrar
  44. cb_clearalldata cb_clearalldata
  45. cb_cleardata cb_cleardata
  46. cb_exit cb_exit
  47. cb_restore cb_restore
  48. cb_backup cb_backup
  49. cb_ch cb_ch
  50. sle_filename sle_filename
  51. gb_2 gb_2
  52. gb_1 gb_1
  53. end type
  54. global w_backup_cleardata w_backup_cleardata
  55. type variables
  56. string backupcmmd
  57. string restorecmmd
  58. BOOLEAN OL_BACKUP=TRUE
  59. string database,userid,dbpass,servername,isql
  60. end variables
  61. forward prototypes
  62. public function integer wf_cleardata ()
  63. public function integer wf_clearalldata ()
  64. end prototypes
  65. public function integer wf_cleardata ();//wf_cleardata
  66. long rslt=1,ls_d
  67. string arg_msg
  68. ls_d=f_cleardata(false,arg_msg)
  69. messagebox(string(ls_d),'清除数据操作完毕!'+arg_msg)
  70. return rslt
  71. end function
  72. public function integer wf_clearalldata ();//TRUNCATE TABLE
  73. long rslt=1,ls_d
  74. string arg_msg
  75. ls_d=f_cleardata(true,arg_msg)
  76. messagebox(string(ls_d),'清除数据操作完毕!'+arg_msg)
  77. return rslt
  78. end function
  79. on w_backup_cleardata.create
  80. this.st_1=create st_1
  81. this.cb_1=create cb_1
  82. this.cbx_winrar=create cbx_winrar
  83. this.cb_clearalldata=create cb_clearalldata
  84. this.cb_cleardata=create cb_cleardata
  85. this.cb_exit=create cb_exit
  86. this.cb_restore=create cb_restore
  87. this.cb_backup=create cb_backup
  88. this.cb_ch=create cb_ch
  89. this.sle_filename=create sle_filename
  90. this.gb_2=create gb_2
  91. this.gb_1=create gb_1
  92. this.Control[]={this.st_1,&
  93. this.cb_1,&
  94. this.cbx_winrar,&
  95. this.cb_clearalldata,&
  96. this.cb_cleardata,&
  97. this.cb_exit,&
  98. this.cb_restore,&
  99. this.cb_backup,&
  100. this.cb_ch,&
  101. this.sle_filename,&
  102. this.gb_2,&
  103. this.gb_1}
  104. end on
  105. on w_backup_cleardata.destroy
  106. destroy(this.st_1)
  107. destroy(this.cb_1)
  108. destroy(this.cbx_winrar)
  109. destroy(this.cb_clearalldata)
  110. destroy(this.cb_cleardata)
  111. destroy(this.cb_exit)
  112. destroy(this.cb_restore)
  113. destroy(this.cb_backup)
  114. destroy(this.cb_ch)
  115. destroy(this.sle_filename)
  116. destroy(this.gb_2)
  117. destroy(this.gb_1)
  118. end on
  119. event open;database =ProfileString (sys_inifilename, "database", "database", '')
  120. userid =ProfileString (sys_inifilename, "database", "userid", '')
  121. dbpass =f_psw_bczh(ProfileString (sys_inifilename, "database", "dbpass",''),1,sys_power_key)
  122. servername=ProfileString (sys_inifilename, "database", "servername", '')
  123. ISQL =ProfileString (sys_inifilename, "database", "ISQL", '')
  124. //IF RIGHT(LOWER(isql),8)<>'isql.exe' or not fileexists(isql) THEN
  125. // MESSAGEBOX('','请在系统数据连接设置中正确指示ISQL.EXE文件!')
  126. // CLOSE(THIS)
  127. //END IF
  128. IF Message.DoubleParm = 1 THEN
  129. OL_BACKUP=FALSE
  130. END IF
  131. end event
  132. type st_1 from statictext within w_backup_cleardata
  133. integer x = 178
  134. integer y = 352
  135. integer width = 974
  136. integer height = 76
  137. integer textsize = -9
  138. integer weight = 400
  139. fontcharset fontcharset = gb2312charset!
  140. fontpitch fontpitch = variable!
  141. string facename = "宋体"
  142. long textcolor = 255
  143. long backcolor = 67108864
  144. boolean enabled = false
  145. string text = "注意:[此功能要先安装winrar压缩软件]"
  146. alignment alignment = right!
  147. boolean focusrectangle = false
  148. end type
  149. type cb_1 from commandbutton within w_backup_cleardata
  150. integer x = 1449
  151. integer y = 444
  152. integer width = 384
  153. integer height = 96
  154. integer taborder = 60
  155. integer textsize = -9
  156. integer weight = 400
  157. fontcharset fontcharset = gb2312charset!
  158. fontpitch fontpitch = variable!
  159. string facename = "宋体"
  160. string text = "清空系统信息"
  161. end type
  162. event clicked;if not sys_power_issuper then
  163. messagebox('提示','非管理员不可以操作', Information!, OK! )
  164. return
  165. end if
  166. string comm,msg
  167. integer bttn
  168. bttn=messagebox("警告!","是否进行"+this.text+"操作?",exclamation!,OKCancel!,2)
  169. if bttn=2 then
  170. RETURN
  171. end if
  172. comm='TRUNCATE TABLE sys_DB_version'
  173. Execute immediate :comm ;
  174. if sqlca.sqlcode<>0 then
  175. msg='操作失败>'+sqlca.sqlerrtext
  176. rollback;
  177. messagebox('提示',msg, Information!, OK! )
  178. else
  179. commit;
  180. messagebox('提示','操作成功,请稍后从新进入本系统!', Information!, OK! )
  181. end if
  182. HALT
  183. end event
  184. type cbx_winrar from checkbox within w_backup_cleardata
  185. integer x = 101
  186. integer y = 264
  187. integer width = 539
  188. integer height = 76
  189. integer textsize = -9
  190. integer weight = 400
  191. fontcharset fontcharset = gb2312charset!
  192. fontpitch fontpitch = variable!
  193. string facename = "宋体"
  194. long textcolor = 16711680
  195. long backcolor = 67108864
  196. string text = "备份且winrar加密"
  197. end type
  198. type cb_clearalldata from commandbutton within w_backup_cleardata
  199. integer x = 571
  200. integer y = 612
  201. integer width = 617
  202. integer height = 96
  203. integer taborder = 40
  204. integer textsize = -9
  205. integer weight = 400
  206. fontcharset fontcharset = gb2312charset!
  207. fontpitch fontpitch = variable!
  208. string facename = "宋体"
  209. string text = "备份且清空全部数据"
  210. end type
  211. event clicked;if not sys_power_issuper then
  212. messagebox('提示','非管理员不可以操作', Information!, OK! )
  213. return
  214. end if
  215. string arg_msg
  216. if f_backup_db(cbx_winrar.checked,database,sle_filename.text,arg_msg)=0 then
  217. messagebox('提示',arg_msg, Information!, OK! )
  218. return
  219. end if
  220. messagebox('提示',arg_msg, Information!, OK! )
  221. if messagebox("询问","确定要清空当前数据库的全部数据吗!是否进行操作?",exclamation!,OKCancel!,2)=2 then
  222. RETURN
  223. end if
  224. wf_clearalldata()
  225. //------日志
  226. f_setsysoplog('数据删除','系统登录删除(全部数据),用户:'+publ_operator,arg_msg,TRUE)
  227. //------
  228. end event
  229. type cb_cleardata from commandbutton within w_backup_cleardata
  230. integer x = 571
  231. integer y = 444
  232. integer width = 617
  233. integer height = 96
  234. integer taborder = 30
  235. integer textsize = -9
  236. integer weight = 400
  237. fontcharset fontcharset = gb2312charset!
  238. fontpitch fontpitch = variable!
  239. string facename = "宋体"
  240. boolean enabled = false
  241. string text = "备份且清空业务数据"
  242. end type
  243. event clicked;IF NOT sys_power_issuper THEN
  244. MessageBox('提示','非管理员不可以操作', Information!, OK! )
  245. RETURN
  246. END IF
  247. String arg_msg
  248. IF f_backup_db(cbx_winrar.Checked,Database,sle_filename.Text,arg_msg) = 0 THEN
  249. MessageBox('提示',arg_msg, Information!, OK! )
  250. RETURN
  251. END IF
  252. MessageBox('提示',arg_msg, Information!, OK! )
  253. IF MessageBox("警告!","确定要清空当前数据库的业务数据吗?恢复数据只能通过数据库的备份还原!是否进行操作?",exclamation!,OKCancel!,2) = 2 THEN
  254. RETURN
  255. END IF
  256. wf_cleardata()
  257. //------日志
  258. f_setsysoplog('数据删除','系统登录删除(业务数据),用户:'+publ_operator,arg_msg,TRUE)
  259. //------
  260. //string comm,msg
  261. //
  262. //comm='BACKUP DATABASE '+database+' TO DISK= ~''+sle_filename.text+'~' with init '
  263. //
  264. //transaction ls_transsqlca
  265. //ls_transsqlca=create transaction
  266. //
  267. //ls_transsqlca.DBMS=sqlca.DBMS
  268. //ls_transsqlca.database = 'master'
  269. //ls_transsqlca.userid=sqlca.userid
  270. //ls_transsqlca.dbpass=sqlca.dbpass
  271. //ls_transsqlca.logid=sqlca.logid
  272. //ls_transsqlca.logpass=sqlca.logpass
  273. //ls_transsqlca.servername=sqlca.servername
  274. //ls_transsqlca.dbparm=sqlca.dbparm
  275. //
  276. //if ls_transsqlca.database='' or ls_transsqlca.servername='' then
  277. // Messagebox("系统提示","连接数据管理库失败!")
  278. // return
  279. //end if
  280. //w_sys_wait.show()
  281. //connect using ls_transsqlca;
  282. //ls_transsqlca.autocommit=true
  283. //
  284. //Execute immediate :comm using ls_transsqlca;
  285. //w_sys_wait.hide()
  286. //if ls_transsqlca.sqlcode<>0 then
  287. // msg='备份操作失败>'+ls_transsqlca.sqlerrtext
  288. // rollback;
  289. // messagebox('系统提示',msg)
  290. //else
  291. // commit;
  292. // messagebox('系统提示','备份操作成功!')
  293. //
  294. // if messagebox("警告!","确定要清空当前数据库的业务数据吗?恢复数据只能通过数据库的备份还原!是否进行操作?",exclamation!,OKCancel!,2)=2 then
  295. // RETURN
  296. // end if
  297. //
  298. // wf_cleardata()
  299. //
  300. //end if
  301. //
  302. //destroy ls_transsqlca
  303. end event
  304. type cb_exit from commandbutton within w_backup_cleardata
  305. integer x = 1513
  306. integer y = 612
  307. integer width = 320
  308. integer height = 96
  309. integer taborder = 80
  310. integer textsize = -9
  311. integer weight = 400
  312. fontcharset fontcharset = gb2312charset!
  313. fontpitch fontpitch = variable!
  314. string facename = "宋体"
  315. string text = "退出"
  316. end type
  317. event clicked;close(parent)
  318. end event
  319. type cb_restore from commandbutton within w_backup_cleardata
  320. integer x = 133
  321. integer y = 612
  322. integer width = 320
  323. integer height = 96
  324. integer taborder = 70
  325. integer textsize = -9
  326. integer weight = 400
  327. fontcharset fontcharset = gb2312charset!
  328. fontpitch fontpitch = variable!
  329. string facename = "宋体"
  330. boolean enabled = false
  331. string text = "恢复"
  332. end type
  333. event clicked;if not sys_power_issuper then
  334. messagebox('提示','非管理员不可以操作', Information!, OK! )
  335. return
  336. end if
  337. //string ls_str
  338. //ls_str=ProfileString(sys_inifilename,'SERVER','SERVER','')
  339. //if trim(ls_str)="" then
  340. // messagebox("操作错误","必须在服务器上进行恢复操作",stopsign!)
  341. // close(parent)
  342. // return
  343. //end if
  344. string comm,msg
  345. integer bttn
  346. bttn=messagebox("警告!","如果数据库已经存在,此操作将使当前数据被覆盖,是否进行操作?",exclamation!,OKCancel!,2)
  347. if bttn=2 then
  348. RETURN
  349. end if
  350. bttn=messagebox("提示","请确保无其他用户使用系统,否则将会出现错误,是否准备好?",Question!,YesNo!,2)
  351. if bttn=2 then
  352. RETURN
  353. end if
  354. comm='restore DATABASE '+database+' from DISK= ~''+sle_filename.text+'~' with replace'
  355. transaction ls_transsqlca
  356. ls_transsqlca=create transaction
  357. ls_transsqlca.DBMS=sqlca.DBMS
  358. ls_transsqlca.database = 'master'
  359. ls_transsqlca.userid=sqlca.userid
  360. ls_transsqlca.dbpass=sqlca.dbpass
  361. ls_transsqlca.logid=sqlca.logid
  362. ls_transsqlca.logpass=sqlca.logpass
  363. ls_transsqlca.servername=sqlca.servername
  364. ls_transsqlca.dbparm=sqlca.dbparm
  365. if ls_transsqlca.database='' or ls_transsqlca.servername='' then
  366. Messagebox("提示","连接数据管理库失败!", Information!, OK! )
  367. return
  368. end if
  369. w_sys_wait.show()
  370. connect using ls_transsqlca;
  371. ls_transsqlca.autocommit=true
  372. DISCONNECT using sqlca;
  373. Execute immediate :comm using ls_transsqlca;
  374. w_sys_wait.hide()
  375. if ls_transsqlca.sqlcode<>0 then
  376. msg='恢复操作失败>'+ls_transsqlca.sqlerrtext
  377. rollback;
  378. messagebox('提示',msg, Information!, OK! )
  379. else
  380. commit;
  381. messagebox('提示','恢复操作成功,请稍后从新进入本系统!', Information!, OK! )
  382. end if
  383. destroy ls_transsqlca
  384. HALT
  385. end event
  386. type cb_backup from commandbutton within w_backup_cleardata
  387. integer x = 133
  388. integer y = 444
  389. integer width = 320
  390. integer height = 96
  391. integer taborder = 50
  392. integer textsize = -9
  393. integer weight = 400
  394. fontcharset fontcharset = gb2312charset!
  395. fontpitch fontpitch = variable!
  396. string facename = "宋体"
  397. boolean enabled = false
  398. string text = "备份"
  399. end type
  400. event clicked;if not f_power_ind(161) then
  401. messagebox(publ_operator,'你没有使用权限!', Information!, OK! )
  402. return
  403. end if
  404. IF FileExists(sle_filename.text) THEN
  405. Messagebox('提示','备份文件已经存在,请重新填写备份文件名!', Information!, OK! )
  406. RETURN
  407. END IF
  408. string arg_msg
  409. f_backup_db(cbx_winrar.checked,database,sle_filename.text,arg_msg)
  410. messagebox('提示',arg_msg, Information!, OK! )
  411. //string comm,msg
  412. //
  413. //comm='BACKUP DATABASE '+database+' TO DISK= ~''+sle_filename.text+'~' with init '
  414. //
  415. //transaction ls_transsqlca
  416. //ls_transsqlca=create transaction
  417. //
  418. //ls_transsqlca.DBMS=sqlca.DBMS
  419. //ls_transsqlca.database = 'master'
  420. //ls_transsqlca.userid=sqlca.userid
  421. //ls_transsqlca.dbpass=sqlca.dbpass
  422. //ls_transsqlca.logid=sqlca.logid
  423. //ls_transsqlca.logpass=sqlca.logpass
  424. //ls_transsqlca.servername=sqlca.servername
  425. //ls_transsqlca.dbparm=sqlca.dbparm
  426. //
  427. //if ls_transsqlca.database='' or ls_transsqlca.servername='' then
  428. // Messagebox("系统提示","连接数据管理库失败!")
  429. // return
  430. //end if
  431. //w_sys_wait.show()
  432. //connect using ls_transsqlca;
  433. //ls_transsqlca.autocommit=true
  434. //
  435. //Execute immediate :comm using ls_transsqlca;
  436. //w_sys_wait.hide()
  437. //if ls_transsqlca.sqlcode<>0 then
  438. // msg='备份操作失败>'+ls_transsqlca.sqlerrtext
  439. // rollback;
  440. // messagebox('系统提示',msg)
  441. //else
  442. // commit;
  443. // messagebox('系统提示','备份操作成功!')
  444. //end if
  445. //
  446. //destroy ls_transsqlca
  447. //
  448. end event
  449. type cb_ch from commandbutton within w_backup_cleardata
  450. integer x = 1719
  451. integer y = 128
  452. integer width = 114
  453. integer height = 92
  454. integer taborder = 20
  455. integer textsize = -9
  456. integer weight = 400
  457. fontcharset fontcharset = gb2312charset!
  458. fontpitch fontpitch = variable!
  459. string facename = "宋体"
  460. string text = "..."
  461. end type
  462. event clicked;//ole_openfile.object.filter="*.dat"
  463. //ole_openfile.object.defaultext="dat"
  464. //ole_openfile.object.showSAVE()
  465. //if trim(ole_openfile.object.filename)<>"" then
  466. // sle_filename.text=ole_openfile.object.filename
  467. // cb_backup.enabled=true
  468. // cb_restore.enabled=true
  469. //end if
  470. /////////////////old
  471. //new
  472. integer i
  473. string pathname,filename
  474. i=getfilesavename("选择备份文件",pathname,filename,"Dat","数据文件Dat,*.Dat")
  475. IF i=1 AND TRIM(pathname)<>'' AND TRIM(FILENAME)<>"" THEN
  476. cb_backup.enabled=OL_BACKUP
  477. cb_cleardata.enabled=OL_BACKUP
  478. cb_restore.enabled=true
  479. sle_filename.text=pathname
  480. END IF
  481. end event
  482. type sle_filename from singlelineedit within w_backup_cleardata
  483. event key pbm_keydown
  484. integer x = 133
  485. integer y = 128
  486. integer width = 1586
  487. integer height = 92
  488. integer taborder = 10
  489. integer textsize = -9
  490. integer weight = 400
  491. fontcharset fontcharset = gb2312charset!
  492. fontpitch fontpitch = variable!
  493. string facename = "宋体"
  494. long textcolor = 33554432
  495. borderstyle borderstyle = stylelowered!
  496. end type
  497. event key;if trim(this.text)="" then
  498. cb_backup.enabled=false
  499. cb_restore.enabled=false
  500. cb_cleardata.enabled=false
  501. else
  502. cb_backup.enabled=OL_BACKUP
  503. cb_restore.enabled=true
  504. cb_cleardata.enabled=true
  505. end if
  506. end event
  507. event modified;if trim(this.text)="" then
  508. cb_backup.enabled=false
  509. cb_restore.enabled=false
  510. cb_cleardata.enabled=false
  511. else
  512. cb_backup.enabled=OL_BACKUP
  513. cb_restore.enabled=true
  514. cb_cleardata.enabled=OL_BACKUP
  515. end if
  516. end event
  517. type gb_2 from groupbox within w_backup_cleardata
  518. integer x = 73
  519. integer y = 268
  520. integer width = 1193
  521. integer height = 332
  522. integer taborder = 60
  523. integer textsize = -9
  524. integer weight = 400
  525. fontcharset fontcharset = gb2312charset!
  526. fontpitch fontpitch = variable!
  527. string facename = "宋体"
  528. long textcolor = 33554432
  529. long backcolor = 67108864
  530. end type
  531. type gb_1 from groupbox within w_backup_cleardata
  532. integer x = 73
  533. integer y = 48
  534. integer width = 1810
  535. integer height = 216
  536. integer textsize = -9
  537. integer weight = 400
  538. fontcharset fontcharset = gb2312charset!
  539. fontpitch fontpitch = variable!
  540. string facename = "宋体"
  541. long textcolor = 33554432
  542. long backcolor = 79741120
  543. string text = "备份文件路径"
  544. end type