123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558 |
- $PBExportHeader$w_fj_fileadd_p.srw
- forward
- global type w_fj_fileadd_p from window
- end type
- type dw_fileedit from u_dw_rbtnfilter within w_fj_fileadd_p
- end type
- type cb_3 from uo_imflatbutton within w_fj_fileadd_p
- end type
- type cb_2 from uo_imflatbutton within w_fj_fileadd_p
- end type
- type cb_1 from uo_imflatbutton within w_fj_fileadd_p
- end type
- type cb_read from uo_imflatbutton within w_fj_fileadd_p
- end type
- type r_bar from rectangle within w_fj_fileadd_p
- end type
- type ln_bar from line within w_fj_fileadd_p
- end type
- end forward
- global type w_fj_fileadd_p from window
- integer width = 3355
- integer height = 1288
- boolean titlebar = true
- string title = "Untitled"
- boolean controlmenu = true
- windowtype windowtype = response!
- long backcolor = 134217739
- string icon = "AppIcon!"
- boolean center = true
- event ue_selectfile ( )
- dw_fileedit dw_fileedit
- cb_3 cb_3
- cb_2 cb_2
- cb_1 cb_1
- cb_read cb_read
- r_bar r_bar
- ln_bar ln_bar
- end type
- global w_fj_fileadd_p w_fj_fileadd_p
- type variables
- s_fileinfo s_file
- boolean import = false
- boolean success = false
- long originallyheight,originallywidth
- end variables
- forward prototypes
- public function integer wf_getfiledata (string arg_filepath, ref blob arg_filedata, ref string arg_msg)
- end prototypes
- event ue_selectfile();// //ue_selectfile
- String Pathname,Filename[],FileType, ls_Pathname
- Integer i, li_cnt, poi, li_failcnt
- Long row
- String arg_msg
- long ll_FileLength
- 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 THEN RETURN
- li_cnt = UpperBound(Filename)
- IF li_cnt = 1 THEN
-
- ls_Pathname = Pathname
-
- ll_FileLength = FileLength(ls_Pathname)/1024
- IF ll_FileLength > 10240 THEN
- MessageBox('限制','附件文件大小不得大于10M')
- RETURN
- END IF
-
- IF dw_fileedit.GetRow() > 0 THEN
- IF dw_fileedit.Object.filepath[dw_fileedit.GetRow()] = '' THEN
- row = dw_fileedit.GetRow()
- ELSE
- row = dw_fileedit.InsertRow(0)
- END IF
- ELSE
- row = dw_fileedit.InsertRow(0)
- END IF
-
- dw_fileedit.Object.filepath[row] = ls_Pathname
- dw_fileedit.Object.filesize[row] = ll_FileLength
-
- poi = lastpos(Filename[1], '.')
- IF poi > 0 THEN
- dw_fileedit.Object.Filename[row] = Mid(Filename[1],1,poi -1)
- dw_fileedit.Object.DisplayName[row] = Mid(Filename[1],1,poi -1)
- dw_fileedit.Object.FileType[row] = Mid(Filename[1],poi +1,Len(Filename[1]) - poi)
- ELSE
- dw_fileedit.Object.Filename[row] = Filename[1]
- dw_fileedit.Object.DisplayName[row] = Filename[1]
- dw_fileedit.Object.FileType[row] = ''
- END IF
- ELSE
- FOR i = 1 To li_cnt
-
- ls_Pathname = String(Pathname) + "\" +(String(Filename[i]))
-
- ll_FileLength = FileLength(ls_Pathname)/1024
- IF ll_FileLength > 10240 THEN
- arg_msg = '附件文件大小不得大于10M'
- li_failcnt ++
- continue
- END IF
-
- IF dw_fileedit.GetRow() > 0 THEN
- IF dw_fileedit.Object.filepath[dw_fileedit.GetRow()] = '' THEN
- row = dw_fileedit.GetRow()
- ELSE
- row = dw_fileedit.InsertRow(0)
- END IF
- ELSE
- row = dw_fileedit.InsertRow(0)
- END IF
- dw_fileedit.Object.filepath[row] = ls_Pathname
- dw_fileedit.Object.filesize[row] = ll_FileLength
-
- poi = lastpos(Filename[i], '.')
- IF poi > 0 THEN
- dw_fileedit.Object.Filename[row] = Mid(Filename[i],1,poi -1)
- dw_fileedit.Object.DisplayName[row] = Mid(Filename[i],1,poi -1)
- dw_fileedit.Object.FileType[row] = Mid(Filename[i],poi +1,Len(Filename[i]) - poi)
- ELSE
- dw_fileedit.Object.Filename[row] = Filename[i]
- dw_fileedit.Object.DisplayName[row] = Filename[i]
- dw_fileedit.Object.FileType[row] = ''
- END IF
-
- NEXT
-
- IF li_failcnt > 0 THEN
- MessageBox('限制','附件文件大小不得大于10M,'+String(li_failcnt)+'个文件导入失败!')
- END IF
-
- END IF
- end event
- public function integer 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_p.create
- this.dw_fileedit=create dw_fileedit
- this.cb_3=create cb_3
- this.cb_2=create cb_2
- this.cb_1=create cb_1
- this.cb_read=create cb_read
- this.r_bar=create r_bar
- this.ln_bar=create ln_bar
- this.Control[]={this.dw_fileedit,&
- this.cb_3,&
- this.cb_2,&
- this.cb_1,&
- this.cb_read,&
- this.r_bar,&
- this.ln_bar}
- end on
- on w_fj_fileadd_p.destroy
- destroy(this.dw_fileedit)
- destroy(this.cb_3)
- destroy(this.cb_2)
- destroy(this.cb_1)
- destroy(this.cb_read)
- destroy(this.r_bar)
- destroy(this.ln_bar)
- end on
- event 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 resize;ln_bar.EndX = THIS.Width
- r_bar.Width = THIS.Width
- end event
- type dw_fileedit from u_dw_rbtnfilter within w_fj_fileadd_p
- integer y = 176
- integer width = 3323
- integer height = 1016
- integer taborder = 50
- string dataobject = "dw_fj_fileadd_p"
- boolean hscrollbar = true
- boolean vscrollbar = true
- boolean hsplitscroll = true
- boolean rbutton_setposition_use = true
- boolean titleclick_sort_use = true
- end type
- event rowfocuschanged;call super::rowfocuschanged;if IsNull(currentrow) then return
- if (currentrow <= 0) then return
- this.SelectRow(0, false)
- this.SelectRow(currentrow, true)
- end event
- type cb_3 from uo_imflatbutton within w_fj_fileadd_p
- integer x = 818
- integer width = 274
- integer height = 164
- integer taborder = 40
- boolean bringtotop = true
- string text = "取消"
- string normalpicname = "exit.bmp"
- integer picsize = 16
- toolbaralignment pic_align = alignattop!
- boolean border = false
- end type
- event clicked;call super::clicked;success = false
- close(parent)
- end event
- type cb_2 from uo_imflatbutton within w_fj_fileadd_p
- integer x = 544
- integer width = 274
- integer height = 164
- integer taborder = 30
- boolean bringtotop = true
- string text = "上传"
- string normalpicname = "preview.bmp"
- integer picsize = 16
- toolbaralignment pic_align = alignattop!
- boolean border = false
- end type
- event clicked;call super::clicked;Long row,rt_fileid, ll_succnt, ll_failcnt
- int rslt = 1
- Long cnt
- String arg_msg, ls_msg
- String filepath
- s_fileinfo_arr s_file_arr
- uo_fx_fj uo_fj
- uo_fj = create uo_fx_fj
- dw_fileedit.AcceptText( )
- FOR row = 1 To dw_fileedit.RowCount()
- IF dw_fileedit.Object.filepath[row] <> '' THEN
- IF dw_fileedit.Object.Filename[row] = '' THEN
- MessageBox('系统提示','行:'+String(row)+',请输入文件名称')
- RETURN
- END IF
- IF dw_fileedit.Object.DisplayName[row] = '' THEN
- MessageBox('系统提示','行:'+String(row)+',请输入档案名称')
- RETURN
- END IF
- END IF
- NEXT
- FOR row = 1 To dw_fileedit.RowCount()
-
- IF dw_fileedit.Object.filepath[row] <> '' and dw_fileedit.Object.fileid[row] = 0 THEN
- s_file.Fileid = 0
- s_file.Filename = dw_fileedit.Object.Filename[row]
- s_file.FileType = dw_fileedit.Object.FileType[row]
- s_file.dscrp = dw_fileedit.Object.dscrp[row]
- s_file.DisplayName = dw_fileedit.Object.DisplayName[row]
- s_file.filepath = dw_fileedit.Object.filepath[row]
-
- filepath = dw_fileedit.Object.filepath[row]
-
- IF wf_getfiledata(filepath,s_file.filedata,arg_msg) <= 0 THEN
- ll_failcnt++
- ls_msg += "行:"+String(row)+","+arg_msg+'~r~n'
- rslt = 0
- GOTO nxtfj
- END IF
- cnt++
- s_file_arr.fileid[cnt] = s_file.fileid
- s_file_arr.billtype[cnt] = s_file.billtype
- s_file_arr.displayName[cnt] = s_file.displayName
- s_file_arr.fileName[cnt] = s_file.fileName
- s_file_arr.fileType[cnt] = s_file.fileType
- s_file_arr.dscrp[cnt] = s_file.dscrp
- s_file_arr.opemp[cnt] = s_file.opemp
- s_file_arr.opdate[cnt] = s_file.opdate
- s_file_arr.fileData[cnt] = s_file.fileData
- s_file_arr.relid_mx[cnt] = s_file.relid_mx
- s_file_arr.relid[cnt] = s_file.relid
- s_file_arr.relcode[cnt] = s_file.relcode
- s_file_arr.filepath[cnt] = s_file.filepath
- END IF
- nxtfj:
- NEXT
- IF uo_fj.update_fxfj(s_file_arr,arg_msg) = 0 THEN
- MessageBox('失败',arg_msg )
- RETURN
- ELSE
- MessageBox('成功',"上传文件成功" )
- Close(Parent)
- END IF
- end event
- type cb_1 from uo_imflatbutton within w_fj_fileadd_p
- integer x = 270
- integer width = 274
- integer height = 164
- integer taborder = 20
- boolean bringtotop = true
- string text = "删明细"
- string normalpicname = "delete.bmp"
- integer picsize = 16
- toolbaralignment pic_align = alignattop!
- boolean border = false
- end type
- event clicked;call super::clicked;IF dw_fileedit.GetRow() <= 0 THEN RETURN
- IF MessageBox("系统提示", "是否确定删除当前明细行?", Question!, YesNo!) = 2 THEN RETURN
- dw_fileedit.DeleteRow(0)
- end event
- type cb_read from uo_imflatbutton within w_fj_fileadd_p
- integer width = 274
- integer height = 164
- integer taborder = 10
- boolean bringtotop = true
- string text = "选择文件"
- string normalpicname = "open.bmp"
- integer picsize = 16
- toolbaralignment pic_align = alignattop!
- boolean border = false
- end type
- event clicked;call super::clicked;// //ue_selectfile
- String Pathname,Filename[],FileType, ls_Pathname
- Integer i, li_cnt, poi, li_failcnt
- Long row
- String arg_msg
- long ll_FileLength
- 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 THEN RETURN
- li_cnt = UpperBound(Filename)
- IF li_cnt = 1 THEN
-
- ls_Pathname = Pathname
-
- ll_FileLength = FileLength(ls_Pathname)/1024
- IF ll_FileLength > 10240 THEN
- MessageBox('限制','附件文件大小不得大于10M')
- RETURN
- END IF
-
- IF dw_fileedit.GetRow() > 0 THEN
- IF dw_fileedit.Object.filepath[dw_fileedit.GetRow()] = '' THEN
- row = dw_fileedit.GetRow()
- ELSE
- row = dw_fileedit.InsertRow(0)
- END IF
- ELSE
- row = dw_fileedit.InsertRow(0)
- END IF
-
- dw_fileedit.Object.filepath[row] = ls_Pathname
- dw_fileedit.Object.filesize[row] = ll_FileLength
-
- poi = lastpos(Filename[1], '.')
- IF poi > 0 THEN
- dw_fileedit.Object.Filename[row] = Mid(Filename[1],1,poi -1)
- dw_fileedit.Object.DisplayName[row] = Mid(Filename[1],1,poi -1)
- dw_fileedit.Object.FileType[row] = Mid(Filename[1],poi +1,Len(Filename[1]) - poi)
- ELSE
- dw_fileedit.Object.Filename[row] = Filename[1]
- dw_fileedit.Object.DisplayName[row] = Filename[1]
- dw_fileedit.Object.FileType[row] = ''
- END IF
- ELSE
- FOR i = 1 To li_cnt
-
- ls_Pathname = String(Pathname) + "\" +(String(Filename[i]))
-
- ll_FileLength = FileLength(ls_Pathname)/1024
- IF ll_FileLength > 10240 THEN
- arg_msg = '附件文件大小不得大于10M'
- li_failcnt ++
- continue
- END IF
-
- IF dw_fileedit.GetRow() > 0 THEN
- IF dw_fileedit.Object.filepath[dw_fileedit.GetRow()] = '' THEN
- row = dw_fileedit.GetRow()
- ELSE
- row = dw_fileedit.InsertRow(0)
- END IF
- ELSE
- row = dw_fileedit.InsertRow(0)
- END IF
- dw_fileedit.Object.filepath[row] = ls_Pathname
- dw_fileedit.Object.filesize[row] = ll_FileLength
-
- poi = lastpos(Filename[i], '.')
- IF poi > 0 THEN
- dw_fileedit.Object.Filename[row] = Mid(Filename[i],1,poi -1)
- dw_fileedit.Object.DisplayName[row] = Mid(Filename[i],1,poi -1)
- dw_fileedit.Object.FileType[row] = Mid(Filename[i],poi +1,Len(Filename[i]) - poi)
- ELSE
- dw_fileedit.Object.Filename[row] = Filename[i]
- dw_fileedit.Object.DisplayName[row] = Filename[i]
- dw_fileedit.Object.FileType[row] = ''
- END IF
-
- NEXT
-
- IF li_failcnt > 0 THEN
- MessageBox('限制','附件文件大小不得大于10M,'+String(li_failcnt)+'个文件导入失败!')
- END IF
-
- END IF
- end event
- type r_bar from rectangle within w_fj_fileadd_p
- long linecolor = 16777215
- integer linethickness = 4
- long fillcolor = 1073741824
- integer x = 1687
- integer y = 40
- integer width = 87
- integer height = 52
- end type
- event constructor;THIS.FillColor = 14215660
- THIS.LineColor = 14215660
- THIS.X = -1
- THIS.Y = -1
- THIS.Height = ln_bar.BeginY - 5
- end event
- type ln_bar from line within w_fj_fileadd_p
- long linecolor = 268435456
- integer linethickness = 4
- integer beginy = 164
- integer endx = 2002
- integer endy = 164
- end type
|