123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- $PBExportHeader$w_fj_fileadd.srw
- forward
- global type w_fj_fileadd from w_publ_base
- end type
- type cb_save from uo_xls_imflatbutton within w_fj_fileadd
- end type
- type dw_fileedit from datawindow within w_fj_fileadd
- end type
- type ln_bar2 from line within w_fj_fileadd
- end type
- type ln_bar from line within w_fj_fileadd
- end type
- type r_bar from rectangle within w_fj_fileadd
- end type
- end forward
- global type w_fj_fileadd from w_publ_base
- integer width = 2734
- integer height = 976
- string title = "文件上传"
- boolean minbox = false
- windowtype windowtype = response!
- event ue_selectfile ( )
- cb_save cb_save
- dw_fileedit dw_fileedit
- ln_bar2 ln_bar2
- ln_bar ln_bar
- r_bar r_bar
- end type
- global w_fj_fileadd w_fj_fileadd
- type variables
- s_fileinfo s_file
- boolean import = false
- boolean success = false
- uo_fileview obj_fileview
- Transaction Transaction_pic
- long originallyheight,originallywidth
- end variables
- forward prototypes
- public subroutine wf_priview ()
- public function long wf_getfiledata (string arg_filepath, ref blob arg_filedata, ref string arg_msg)
- end prototypes
- event ue_selectfile();// //ue_selectfile
- String Pathname,Filename,FileType
- Integer i
- Long row
- row = 1 //dw_fileedit.getrow( )
- FileType = ''
- FileType = '所有文件(*.*),*.*,'
- // FileType += "配置文件(*.ini), *.ini,"
- FileType += "Zip压缩文件(*.Zip),*.Zip,"
- FileType += "RAR压缩文件(*.rar),*.rar,"
- // FileType += "XML文件(*.xml),*.xml,"
- FileType += "文本文件(*.txt),*.txt,"
- FileType += "Excel模版(*.xlt),*.xlt,"
- // FileType += "Excel文档(*.xls),*.xls,"
- // FileType += "Word模版(*.dot),*.dot,"
- FileType += "Word文档(*.doc),*.doc,"
- FileType += "JPG(*.JPG),*.JPG,"
- FileType += "位图文件(*.bmp),*.bmp,"
- FileType += "GIF文件(*.GIF),*.GIF"
- i = GetFileOpenName("请选择文件", Pathname,Filename, "All", FileType)
- IF i = 1 And Trim(Pathname) <> '' And Trim(Filename) <> "" THEN
- IF Pathname = '' Or Not FileExists(Pathname) THEN
- MessageBox('提示','请选择文件!',information!,OK!)
- success = False
- import = False
- RETURN
- END IF
- IF FileLength(Pathname)/1024 > 10240 THEN
- // messagebox('提示','附件文件大小不得大于10M',information!,OK!)
- IF MessageBox ("询问","附件文件大小大于10M,是否继续?",question!,yesno! ) = 2 THEN RETURN
-
- END IF
- dw_fileedit.Object.filepath[row] = Pathname
- Long poi = 0,Begin = 1
- Begin = Pos(Filename,'.',1)
- DO WHILE Begin > 0
- poi = Begin
- Begin = Pos(Filename,'.',Begin + 1)
- LOOP
- IF poi > 0 THEN
- dw_fileedit.Object.Filename[row] = Mid(Filename,1,poi -1)
- dw_fileedit.Object.DisplayName[row] = Mid(Filename,1,poi -1)
- dw_fileedit.Object.FileType[row] = Mid(Filename,poi +1,Len(Filename) - poi)
- ELSE
- dw_fileedit.Object.Filename[row] = Filename
- dw_fileedit.Object.DisplayName[row] = Filename
- dw_fileedit.Object.FileType[row] = ''
- END IF
- END IF
- //wf_priview()
- dw_fileedit.Object.filesize[row] = FileLength(Pathname)/1024
- end event
- public subroutine wf_priview ();//IF cbx_pv.Checked THEN
- // String arg_msg
- // String Pathname
- // String Filename
- // Pathname = dw_fileedit.Object.filepath[dw_fileedit.GetRow()]
- // Filename = dw_fileedit.Object.Filename[dw_fileedit.GetRow()]
- //
- // IF wf_getfiledata(Pathname,s_file.filedata,arg_msg) <> 1 THEN
- // MessageBox('系统提示',arg_msg)
- // RETURN
- // END IF
- //
- // IF NOT IsValid(obj_fileview) THEN
- // obj_fileview = CREATE uo_fileview_pic
- // OpenUserObject(obj_fileview)
- // END IF
- //
- // IF obj_fileview.of_showfile( s_file.filedata,Filename, arg_msg) <> 1 THEN
- // IF IsValid(obj_fileview) THEN
- // CloseUserObject(obj_fileview)
- // END IF
- // THIS.Height = THIS.originallyheight
- // THIS.Width = THIS.originallywidth
- // cbx_pv.Checked = FALSE
- // MessageBox('系统提示',arg_msg)
- // RETURN
- // END IF
- //
- // THIS.Height = obj_fileview.ii_screenheight - 570
- // THIS.Width = obj_fileview.ii_screenwidth
- // obj_fileview.X = 0
- // obj_fileview.Y = dw_fileedit.Y + dw_fileedit.Height+10
- // obj_fileview.Width = THIS.Width - 20
- // obj_fileview.Height = THIS.Height - obj_fileview.Y
- // obj_fileview.OriginalSize = cbx_originalsize.Checked
- //
- //
- // THIS.X = 0
- // THIS.Y = 0
- // obj_fileview.of_setfilesize( )
- //ELSE
- // IF IsValid(obj_fileview) THEN
- // CloseUserObject(obj_fileview)
- // END IF
- // THIS.Height = THIS.originallyheight
- // THIS.Width = THIS.originallywidth
- // wf_movetocenter()
- //END IF
- //
- //
- //RETURN
- //
- //
- //
- //
- //
- end subroutine
- public function long wf_getfiledata (string arg_filepath, ref blob arg_filedata, ref string arg_msg);
- Long rslt = 1,i
- Long ll_fileLength,li_FileNum,loops,bytes_read
- Blob b,temp
- IF arg_filepath = '' Or Not FileExists(arg_filepath) THEN
- rslt = 0
- arg_msg = '文件'+arg_filepath+'不存在'
- GOTO ext
- END IF
- ll_fileLength = FileLength(arg_filepath)
- IF ll_fileLength = 0 THEN
- rslt = 0
- arg_msg = '文件'+arg_filepath+'没有内容'
- GOTO ext
- END IF
- li_FileNum = FileOpen(arg_filepath, StreamMode!, Read!, LockRead!)
- IF ll_fileLength > 32765 THEN
- IF Mod(ll_fileLength, 32765) = 0 THEN
- loops = ll_fileLength/32765
- ELSE
- loops = (ll_fileLength/32765) + 1
- END IF
- ELSE
- loops = 1
- END IF
- IF li_FileNum = -1 THEN
- rslt = 0
- arg_msg = '读取文件'+arg_filepath+'出错,文件可能正在被使用'
- GOTO ext
- END IF
- FOR i = 1 To loops
- bytes_read = FileRead(li_FileNum, b)
- IF bytes_read < 0 THEN
- rslt = 0
- arg_msg = '读取文件'+arg_filepath+'出错'
- GOTO ext
- END IF
-
- temp = temp + b
- NEXT
- FileClose(li_FileNum)
- arg_filedata = temp
- rslt=ll_fileLength
- ext:
- RETURN rslt
- end function
- on w_fj_fileadd.create
- int iCurrent
- call super::create
- this.cb_save=create cb_save
- this.dw_fileedit=create dw_fileedit
- this.ln_bar2=create ln_bar2
- this.ln_bar=create ln_bar
- this.r_bar=create r_bar
- iCurrent=UpperBound(this.Control)
- this.Control[iCurrent+1]=this.cb_save
- this.Control[iCurrent+2]=this.dw_fileedit
- this.Control[iCurrent+3]=this.ln_bar2
- this.Control[iCurrent+4]=this.ln_bar
- this.Control[iCurrent+5]=this.r_bar
- end on
- on w_fj_fileadd.destroy
- call super::destroy
- destroy(this.cb_save)
- destroy(this.dw_fileedit)
- destroy(this.ln_bar2)
- destroy(this.ln_bar)
- destroy(this.r_bar)
- end on
- event open;call super::open;s_file = Message.PowerObjectParm
- Long ll_i_row
- ll_i_row = dw_fileedit.InsertRow(0)
- dw_fileedit.SetFocus()
- dw_fileedit.SetColumn('displayname')
- this.triggerevent( 'ue_selectfile')
- end event
- event close;call super::close;
- if not success then
- //s_file.classid = 0
- s_file.fileid = 0
- s_file.filename = ''
- s_file.dscrp = ''
- s_file.encrypted = 0
- s_file.compressed = 0
- s_file.filetype = ''
- setnull(s_file.filedata )
- end if
- CloseWithReturn(THIS,s_file)
- end event
- event ue_before_open;call super::ue_before_open;s_file = message.powerobjectparm
- IF Not IsNull(s_file.sqltransaction ) THEN
-
- Transaction_pic = s_file.sqltransaction
- ELSE
- MessageBox('提示','没有数据库事务',information!,OK!)
- Close(This)
- RETURN
- END IF
- this.originallyheight = this.height
- this.originallywidth = this.width
- dw_fileedit.settransobject( Transaction_pic)
- DataWindowChild dw_c
- dw_fileedit.getchild( "classid", dw_c)
- dw_c.settransobject( sqlca)
- dw_c.retrieve( )
- end event
- event resize;call super::resize;ln_bar.endx = this.width
- ln_bar2.endx = this.width
- r_bar.width = this.width
- end event
- type cb_func from w_publ_base`cb_func within w_fj_fileadd
- boolean visible = false
- integer x = 3099
- integer y = 744
- end type
- type cb_exit from w_publ_base`cb_exit within w_fj_fileadd
- integer x = 151
- integer width = 151
- integer height = 164
- string text = "取消"
- integer picsize = 16
- toolbaralignment pic_align = alignattop!
- boolean border = false
- boolean havefocusrect = false
- end type
- event cb_exit::clicked;success = false
- close(parent)
- end event
- type cb_save from uo_xls_imflatbutton within w_fj_fileadd
- integer width = 151
- integer height = 164
- integer taborder = 50
- boolean bringtotop = true
- string text = "上传"
- string normalpicname = "save.bmp"
- integer picsize = 16
- toolbaralignment pic_align = alignattop!
- boolean border = false
- boolean havefocusrect = false
- end type
- event clicked;Long row,rt_fileid
- uo_fj_mng_billtype ls_uo_btfj
- ls_uo_btfj= create uo_fj_mng_billtype
- dw_fileedit.AcceptText( )
- String arg_msg
- row = dw_fileedit.GetRow( )
- IF row <= 0 THEN RETURN
- String filepath
- s_file.Filename = dw_fileedit.Object.Filename[row]
- s_file.FileType = dw_fileedit.Object.FileType[row]
- s_file.opemp = publ_operator
- s_file.opdate = DateTime(Today())
- //s_file.encrypted = dw_fileedit.Object.encrypted[row]
- //s_file.compressed = dw_fileedit.Object.compressed[row]
- //s_file.classid = dw_fileedit.Object.classid[row]
- s_file.dscrp = dw_fileedit.Object.dscrp[row]
- s_file.DisplayName = dw_fileedit.Object.DisplayName[row]
- filepath = dw_fileedit.Object.filepath[row]
- IF s_file.Filename = '' THEN
- MessageBox('提示','请输入文件名称',information!,OK!)
- dw_fileedit.SetColumn('Filename')
- dw_fileedit.SetFocus( )
- RETURN
- END IF
- IF s_file.DisplayName = '' THEN
- MessageBox('提示','请输入档案名称',information!,OK!)
- dw_fileedit.SetColumn('DisplayName')
- dw_fileedit.SetFocus( )
- RETURN
- END IF
- IF filepath = '' THEN
- MessageBox('提示','请选择文件',information!,OK!)
- dw_fileedit.SetColumn('b_ch')
- dw_fileedit.SetFocus( )
- RETURN
- END IF
- IF wf_getfiledata(filepath,s_file.filedata,arg_msg) <=0 THEN
- MessageBox('错误',arg_msg,stopsign!,OK!)
- RETURN
- END IF
- if ls_uo_btfj.uf_save_fj( s_file, rt_fileid, Transaction_pic , arg_msg )=1 then
- MessageBox('提示',"更新文件成功",information!,OK! )
- Close(Parent)
- RETURN
- ELSE
- MessageBox('错误','请重试>'+arg_msg,stopsign!,OK! )
- RETURN
- END IF
- end event
- type dw_fileedit from datawindow within w_fj_fileadd
- integer y = 184
- integer width = 2665
- integer height = 660
- integer taborder = 20
- boolean bringtotop = true
- string title = "none"
- string dataobject = "dw_fj_file_edit"
- boolean livescroll = true
- borderstyle borderstyle = stylelowered!
- end type
- event clicked;IF dwo.Name = 'b_ch' THEN
- parent.triggerevent( 'ue_selectfile')
- END IF
- end event
- type ln_bar2 from line within w_fj_fileadd
- long linecolor = 16777215
- integer linethickness = 4
- integer beginy = 172
- integer endx = 2039
- integer endy = 172
- end type
- type ln_bar from line within w_fj_fileadd
- long linecolor = 268435456
- integer linethickness = 4
- integer beginy = 168
- integer endx = 2469
- integer endy = 168
- end type
- type r_bar from rectangle within w_fj_fileadd
- long linecolor = 16777215
- integer linethickness = 4
- long fillcolor = 1073741824
- integer x = 1531
- integer width = 146
- integer height = 68
- end type
- event constructor;this.fillcolor = 14215660
- this.linecolor = 14215660
- this.x = -1
- this.y = -1
- this.height = ln_bar.beginy - 5
- end event
|