123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526 |
- $PBExportHeader$w_xls_backup.srw
- forward
- global type w_xls_backup from window
- end type
- type cb_2 from uo_xls_imflatbutton within w_xls_backup
- end type
- type cb_cancel from uo_xls_imflatbutton within w_xls_backup
- end type
- type cb_export from uo_xls_imflatbutton within w_xls_backup
- end type
- type cb_import from uo_xls_imflatbutton within w_xls_backup
- end type
- type st_2 from statictext within w_xls_backup
- end type
- type ddlb_fm from dropdownlistbox within w_xls_backup
- end type
- type sle_path from singlelineedit within w_xls_backup
- end type
- type st_1 from statictext within w_xls_backup
- end type
- end forward
- global type w_xls_backup from window
- integer width = 2533
- integer height = 480
- boolean titlebar = true
- string title = "Excel模版设置备份与恢复"
- boolean controlmenu = true
- windowtype windowtype = response!
- long backcolor = 134217739
- string icon = "AppIcon!"
- boolean center = true
- cb_2 cb_2
- cb_cancel cb_cancel
- cb_export cb_export
- cb_import cb_import
- st_2 st_2
- ddlb_fm ddlb_fm
- sle_path sle_path
- st_1 st_1
- end type
- global w_xls_backup w_xls_backup
- type variables
- uo_xls_backup uo_bc
- private string savepath = ''
- private string savename = ''
- long ins_rslt = 0 //0-取消(不刷新)1-导入(刷新)2-导出(不刷新)
- uo_win32api uo_api
- end variables
- on w_xls_backup.create
- this.cb_2=create cb_2
- this.cb_cancel=create cb_cancel
- this.cb_export=create cb_export
- this.cb_import=create cb_import
- this.st_2=create st_2
- this.ddlb_fm=create ddlb_fm
- this.sle_path=create sle_path
- this.st_1=create st_1
- this.Control[]={this.cb_2,&
- this.cb_cancel,&
- this.cb_export,&
- this.cb_import,&
- this.st_2,&
- this.ddlb_fm,&
- this.sle_path,&
- this.st_1}
- end on
- on w_xls_backup.destroy
- destroy(this.cb_2)
- destroy(this.cb_cancel)
- destroy(this.cb_export)
- destroy(this.cb_import)
- destroy(this.st_2)
- destroy(this.ddlb_fm)
- destroy(this.sle_path)
- destroy(this.st_1)
- end on
- event open; uo_bc = create uo_xls_backup
- uo_api = create uo_win32api
- uo_bc.xls_trans = sqlca
-
- sle_path.text = uo_api.u_getcurrentdirectory()+'\XlsExportFolder'
- if not DirectoryExists(sle_path.text) then
- CreateDirectory(sle_path.text)
- end if
- end event
- event close;closewithreturn(this,ins_rslt)
- end event
- type cb_2 from uo_xls_imflatbutton within w_xls_backup
- integer x = 2368
- integer y = 28
- integer width = 123
- integer height = 84
- integer taborder = 60
- string text = "..."
- end type
- event clicked;call super::clicked;
- //if GetFileSaveName("请选择备份文件的路径", savepath, savename, "Access", "Access Files(*.mdb),*.mdb") <> 1 then
- // sle_path.text = ''
- // savepath = ''
- // savename = ''
- // return
- //else
- // sle_path.text = savepath
- //end if
- string directory = ''
- if GetFolder ( "请选择备份目录", directory )<> 1 then
- directory = ''
- return
- end if
- sle_path.text = directory
- end event
- type cb_cancel from uo_xls_imflatbutton within w_xls_backup
- integer x = 1673
- integer y = 264
- integer taborder = 50
- string text = "取消"
- string normalpicname = "exit.bmp"
- integer picsize = 16
- end type
- event clicked;call super::clicked;ins_rslt = 0
- close(parent)
- end event
- type cb_export from uo_xls_imflatbutton within w_xls_backup
- integer x = 1134
- integer y = 264
- integer taborder = 50
- string text = "导出"
- string normalpicname = "SAVE.BMP"
- integer picsize = 16
- end type
- event clicked;call super::clicked;//if sle_path.text = '' then
- // messagebox('系统提示','请选择备份文件的路径')
- // return
- //end if
- //string arg_msg
- //string filedir = ''
- //savepath = sle_path.text
- //
- //Long Len = 1
- //DO WHILE Pos(Right(savepath,Len),'\') = 0
- // Len++
- // IF Len >= Len(savepath) THEN EXIT
- //LOOP
- //Len = Len(savepath)-Len
- //IF Len <= 0 THEN
- // messagebox('系统提示','保存Access文件的路径不正确')
- // RETURN
- //END IF
- //filedir = Left(savepath,Len)
- //IF NOT Directoryexists(filedir) THEN
- // messagebox('系统提示','保存Access文件的路径不正确')
- // RETURN
- //END IF
- //savename = right(savepath,len(savepath) - len -1)
- ////filedir = Left(savepath,Pos(savepath,savename) - 2)
- //
- //if uo_bc.exporttoaccess(filedir,savename,true,arg_msg) <>1 then
- // messagebox('',arg_msg)
- //else
- // messagebox('系统提示','导出成功!')
- // close(parent)
- //end if
- IF Not DirectoryExists(sle_path.Text) THEN
- MessageBox('系统提示','请选择备份文件存放目录')
- RETURN
- END IF
- datastore ds
- ds = Create datastore
- Long rslt = 1
- String tempname = '',datestr,ls_format_str
- //datestr = sle_path.text+'\['+string(today(),'yyyymmddhhmmss')+']'
- datestr = sle_path.Text+'\'
- if upper(ddlb_fm.text)='XML' then
- ls_format_str='XML'
- else
- ls_format_str='DBF'
- end if
- /*
- ds.DataObject = 'dw_u_xls_table_def'
- ds.SetTransObject( sqlca)
- ds.Retrieve( )
- tempname = datestr + 'u_xls_table_def.'+ls_format_str
- IF ds.SaveAs(tempname, XML!, True) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- ds.DataObject = 'dw_u_xls_column_def'
- ds.SetTransObject( sqlca)
- ds.Retrieve( )
- tempname = datestr + 'u_xls_column_def.'+ls_format_str
- IF ds.SaveAs(tempname, XML!, True) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- */
- ds.DataObject = 'dw_u_xls_billlist'
- ds.SetTransObject( sqlca)
- ds.Retrieve( )
- tempname = datestr + 'u_xls_billlist.'+ls_format_str
- if ls_format_str="XML" then
- IF ds.SaveAs(tempname, XML!, True) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- else
- IF ds.SaveAs(tempname, DBase3!, True) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- end if
- ds.DataObject = 'dw_u_xls_billcolumn_def'
- ds.SetTransObject( sqlca)
- ds.Retrieve( )
- tempname = datestr + 'u_xls_billcolumn_def.'+ls_format_str
- if ls_format_str="XML" then
- IF ds.SaveAs(tempname, XML!, True) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- else
- IF ds.SaveAs(tempname, DBase3!, True) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- end if
- ext:
- IF rslt = 1 THEN
-
- MessageBox('系统提示','导出成功!')
- ins_rslt = 2
- Close(Parent)
- ELSE
-
- MessageBox('系统提示','导出失败!')
- END IF
- //ds.DataObject = 'dw_u_xls_templates'
- //ds.SetTransObject( sqlca)
- //ds.retrieve( )
- //rslt = ds.SaveAs('blob_1',sle_1.Text, XML!, True)
- //rslt = ds.SaveAs('blob_1','C:\aa.xls', CSV!, True)
- //messagebox('',string(rslt))
- end event
- type cb_import from uo_xls_imflatbutton within w_xls_backup
- integer x = 594
- integer y = 264
- integer taborder = 40
- string text = "导入"
- string normalpicname = "open.bmp"
- integer picsize = 16
- end type
- event clicked;call super::clicked;IF Not DirectoryExists(sle_path.Text) THEN
- MessageBox('系统提示','请选择备份文件存放目录')
- RETURN
- END IF
- IF MessageBox ('系统提示',"是否确定要导入数据?(导入之后原有数据将会被删除)",Question!,YesNo! ) = 2 THEN
- RETURN
- END IF
- string arg_msg = ''
- datastore ds
- ds = Create datastore
- Long rslt = 1
- String tempname = '',datestr ,ls_format_str
- //datestr = sle_path.text+'\['+string(today(),'yyyymmddhhmmss')+']'
- datestr = sle_path.Text+'\'
- Long i
- if upper(ddlb_fm.text)='XML' then
- ls_format_str='XML'
- else
- ls_format_str='DBF'
- end if
- /*
- tempname = datestr + 'u_xls_table_def.xml'
- IF FileExists(tempname) THEN
- ds.DataObject = 'dw_u_xls_table_def'
- ds.SetTransObject( sqlca)
- ds.Retrieve( )
- FOR i = ds.RowCount( ) To 1 Step -1
- ds.DeleteRow( i)
- NEXT
- ds.ImportFile(XML!,tempname)
- IF ds.Update( ) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- arg_msg+='~n文件"u_xls_table_def.xml"导入成功'
- else
- rslt = 100
- arg_msg+='~n文件"u_xls_table_def.xml"不存在'
- END IF
- tempname = datestr + 'u_xls_column_def.xml'
- IF FileExists(tempname) THEN
- ds.DataObject = 'dw_u_xls_column_def'
- ds.SetTransObject( sqlca)
- ds.Retrieve( )
- FOR i = ds.RowCount( ) To 1 Step -1
- ds.DeleteRow( i)
- NEXT
- ds.ImportFile(XML!,tempname)
- IF ds.Update( ) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- arg_msg+='~n文件"u_xls_column_def.xml"导入成功'
- else
- rslt = 100
- arg_msg+='~n文件"u_xls_column_def.xml"不存在'
- END IF
- */
- tempname = datestr + 'u_xls_billlist.'+ls_format_str
- IF FileExists(tempname) THEN
- ds.DataObject = 'dw_u_xls_billlist'
- ds.SetTransObject( sqlca)
- ds.Retrieve( )
- FOR i = ds.RowCount( ) To 1 Step -1
- ds.DeleteRow( i)
- NEXT
-
- if ls_format_str="XML" then
- ds.ImportFile(XML!,tempname)
- else
- ds.ImportFile(DBase3!,tempname)
- end if
-
- IF ds.Update( ) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- arg_msg+='~n文件"u_xls_billlist.'+ls_format_str+'" 导入成功('+string(ds.rowcount())+')'
- else
- rslt = 100
- arg_msg+='~n文件"u_xls_billlist.'+ls_format_str+'"不存在'
- END IF
- tempname = datestr + 'u_xls_billcolumn_def.'+ls_format_str+''
- IF FileExists(tempname) THEN
- ds.DataObject = 'dw_u_xls_billcolumn_def'
- ds.SetTransObject( sqlca)
- ds.Retrieve( )
- FOR i = ds.RowCount( ) To 1 Step -1
- ds.DeleteRow( i)
- NEXT
- if ls_format_str="XML" then
- ds.ImportFile(XML!,tempname)
- else
- ds.ImportFile(DBase3!,tempname)
- end if
-
- IF ds.Update( ) <> 1 THEN
- rslt = 0
- GOTO ext
- END IF
- arg_msg+='~n文件"u_xls_billcolumn_def.'+ls_format_str+'"导入成功('+string(ds.rowcount())+')'
- else
- rslt = 100
- arg_msg+='~n文件"u_xls_billcolumn_def.'+ls_format_str+'"不存在'
- END IF
- ext:
- IF rslt = 1 THEN
- COMMIT;
- MessageBox('系统提示','导入成功:'+arg_msg)
- ins_rslt = 1
- close(parent)
- elseif rslt = 100 then
- commit;
- MessageBox('系统提示','导入成功:'+arg_msg)
- ELSE
- ROLLBACK;
- MessageBox('系统提示','导入失败!')
- END IF
- //IF sle_path.text = '' THEN
- // MessageBox('系统提示','请选择备份文件的路径')
- // RETURN
- //END IF
- //String arg_msg
- //String filedir = ''
- //savepath = sle_path.text
- //
- //Long Len = 1
- //DO WHILE Pos(Right(savepath,Len),'\') = 0
- // Len++
- // IF Len >= Len(savepath) THEN EXIT
- //LOOP
- //Len = Len(savepath)-Len
- //IF Len <= 0 THEN
- // messagebox('系统提示','保存Access文件的路径不正确')
- // RETURN
- //END IF
- //filedir = Left(savepath,Len)
- //IF NOT Directoryexists(filedir) THEN
- // messagebox('系统提示','保存Access文件的路径不正确')
- // RETURN
- //END IF
- //savename = right(savepath,len(savepath) - len -1)
- //filedir = Left(savepath,Pos(savepath,savename) - 2)
- //IF MessageBox ('系统提示',"将要覆盖原有的数据,是否确定要导入Excel模版设置?",Question!,YesNo! ) = 2 THEN
- // RETURN
- //END IF
- //IF uo_bc.importfromacess(filedir,savename,TRUE,arg_msg) <> 1 THEN
- // MessageBox('',arg_msg)
- //ELSE
- // MessageBox('系统提示','导入成功!')
- // close(parent)
- //END IF
- //
- end event
- type st_2 from statictext within w_xls_backup
- integer x = 23
- integer y = 152
- integer width = 288
- integer height = 64
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- long backcolor = 134217739
- string text = "文件格式:"
- boolean focusrectangle = false
- end type
- type ddlb_fm from dropdownlistbox within w_xls_backup
- integer x = 315
- integer y = 132
- integer width = 361
- integer height = 228
- integer taborder = 40
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- string text = "DBF"
- boolean vscrollbar = true
- string item[] = {"XML","DBF"}
- borderstyle borderstyle = stylelowered!
- end type
- type sle_path from singlelineedit within w_xls_backup
- integer x = 315
- integer y = 28
- integer width = 2043
- integer height = 84
- 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
- type st_1 from statictext within w_xls_backup
- integer x = 23
- integer y = 44
- integer width = 288
- integer height = 64
- integer textsize = -9
- integer weight = 400
- fontcharset fontcharset = gb2312charset!
- fontpitch fontpitch = variable!
- string facename = "宋体"
- long textcolor = 33554432
- long backcolor = 134217739
- string text = "文件路径:"
- boolean focusrectangle = false
- end type
|