书城管理价值链会计发展研究
4865700000033

第33章 价值链会计信息交换系统开发案例(4)

em_date.y=dw_pz0.y+dw_pz0.height+100

em_bill.y=dw_pz0.y+dw_pz0.height+100

st_number.y=dw_pz0.y+dw_pz0.height+100

st_3.y=dw_pz0.y+dw_pz0.height+100

st_7.y=dw_pz0.y+dw_pz0.height+100

st_15.y=dw_pz0.y+dw_pz0.height+100

st_17.y=dw_pz0.y+dw_pz0.height+100

st_19.y=dw_pz0.y+dw_pz0.height+100

st_20.y=dw_pz0.y+dw_pz0.height+100

st_21.y=dw_pz0.y+dw_pz0.height+100

st_8.y=dw_pz0.y+dw_pz0.height+100

tab_1.x=dw_pz0.width+dw_pz0.x+50

tab_1.height=dw_pz0.height

3.“保存转换文件路径及文件名”按钮(cb_1)的鼠标单击(cilcked)事件代码:要求检验用户输入的文件路径及文件名的正确性,对正确的输入内容予以确认和保存。

long filepointer

string readstring,ufservername,ufsapassword

filepointer=FileOpen( getcurrentdirectory()+″\fibank_uffile.ini″, &

LineMode!, write!, LockReadWrite!, Replace!)

ufservername=″path=″+trim(SLe_1.TEXT)

ufsapassword=″filename=″+trim(sle_2.text)

filewrite(filepointer, ufservername)

filewrite(filepointer, ufsapassword)

fileclose(filepointer)

messagebox(″提示!″,″已保存转换文件的路径及文件名!″)

4.“凭证转换”按钮(cb_3)的鼠标单击(cilcked)事件代码:逐张凭证进行识读,按要求转换为要求的数据格式,保存到指定的文件。

//检验所选凭证范围的正确性

if trim(tab_1.tabpage_1.em_2.text)=″″ or isnull(tab_1.tabpage_1.em_2.text) or &

trim(tab_1.tabpage_1.em_3.text)=″″ or isnull(tab_1.tabpage_1.em_3.text) then

messagebox(″错误!″,″凭证号未选择!请确定需转换的凭证编号。″)

return

end if

if long(tab_1.tabpage_1.em_2.text) 〈 long(condition_ns) or &

long(tab_1.tabpage_1.em_3.text) 〉 long(condition_ne) then

messagebox(″错误!″,″凭证号选择超出了范围!″)

return

end if

dw_pz.setfilter(″″)

dw_pz.filter()

dw_pz.setfilter(″yue="″+condition_yue+″" and long(number) 〉=″+tab_1. &

tabpage_1.em_2.text+″ and long(number) 〈=″+tab_1.tabpage_1.em_3.text )

dw_pz.filter()

//检验保存文件的路径和文件名的正确性

if not DirectoryExists( SLe_1.TEXT ) then

messagebox(″错误!″,″保存路径不存在!请事先创建好文件夹。″)

return

end if

if trim(SLe_2.TEXT)=or isnull( SLe_2.TEXT ) then

messagebox(″错误!″,″未指定文件名!请在输入需保存的文件名称。″)

return

end if

//////////////////////////

if messagebox(″提示!″,″确实要转换 ″+string(integer(tab_1.tabpage_1.em_1.text)) &

+″ 月份的 ″+tab_1.tabpage_1.em_2.text+″-″+tab_1.tabpage_1.em_3.text+&

″ 号凭证吗?″,question!,yesno!)=2 then

return

end if

string filename,linestring,number1

string f[68]

integer filepointer,rows,rown,n68

long foundrow

boolean goon, erroroccur

filename=trim(SLe_1.TEXT)+″\″+trim(SLe_2.TEXT)+″.txt″

if fileExists( filename ) then

if messagebox(″提示!″,″指定的文件已经存在,要替换这个文件吗?″, &

question!,yesno!)=2 then return

if FileDelete( filename )=false then return

end if

//创建并打开文件

filepointer=FileOpen( filename, LineMode!, Write! )

if filepointer=-1 then

messagebox(″错误!″,″不能创建或打开文件: ″+filename+″ !″)

return

end if

//写入第一行

linestring=″凭证输出″,″V800″,″001″,″Accounting Systrm″,″+currentyear+″,″F1日期F2类别″,″F3凭证号F4附单据数″,″F5摘要F6科目编码″,″F7借方F8贷方″,″F9数量F10外币″,″F11汇率″,″F12制单人″,″F13结算方式″,″F14票号″,″F15发生日期″,″F16部门编码″,″F17个人编码″,″F18客户编码″,″F19供应商编码″,″F20业务员″,″F21项目编码″,″F22自定义项1″,″F23自定义项2″,″F24自由项1″,″F25自由项2″,″F26自由项3″,″F27自由项4″,″F28自由项5″,″F29自由项6″,″F30自由项7″,″F31自由项8″,″F32自由项9″,″F33自由项10″,″F34外部系统标识″,″F35业务类型″,″F36单据类型″,″F37单据日期″,″F38单据号″,″F39凭证是否可改″,″F40分录是否可增删″,″F41合计金额是否保值″,″F42数值是否可改″,″F43科目是否可改″,″F44受控科目″,″F45往来是否可改″,″F46部门是否可改″,″F47项目是否可改″,″F48往来项是否必输″,″F49账套号″,″F50核算单位″,″F51会计年度″,″F52会计期间″,″F53类别顺序号″,″F54凭证号″,″F55审核人″,″F56记账人″,″F57是否记账″,″F58出纳人″,″F59行号″,″F60外币名称″,″F61单价″,″F62科目名称″,″F63部门名称″,″F64个人名称″,″F65客户简称″,″F66供应商简称″,″F67项目名称″,″F68项目大类编码″,″F69项目大类名称″,″F70对方科目″,″F71银行两清标志″,″F72往来两清标志″,″F73银行核销标志″,″F74外部系统名称″,″F75外部账套号″,″F76外部会计年度″,″F77外部会计期间″,″F78外部制单日期″,″F79外部系统版本″,″F80凭证标识″,″F81分录自动编号″,″F82唯一标识″,″F83主管签字″,″F84自由项11″,″F85自由项12″,″F86自由项13″,″F87自由项14″,″F88自由项15″,″F89自由项16″

filewrite(filepointer,linestring)

//重复写入多行内容

goon=true

erroroccur=true

rows=dw_pz.rowcount()

for rown=1 to rows

f[1]=string(dw_pz.getitemdatetime(rown, ″pzdate″),″yyyy-mm-dd″)

if isnull(f[1]) then erroroccur=false

f[2]=″记″

f[3]=dw_pz.getitemstring(rown, ″number″)

if isnull(f[3]) then erroroccur=false

f[4]=string(dw_pz.getitemnumber(rown, ″bill″))

if isnull(f[4]) then f[4]=″0″

f[5]=dw_pz.getitemstring(rown, ″note″)

if isnull(f[5]) then erroroccur=false

//得到用友科目编码

number1=dw_pz.getitemstring(rown, ″inumber″)

foundrow=dw_i.find(″number=″+number1+″″, 1, 10000 )

if foundrow 〈=0 then

goon=false

//f[6]=″没有″

else

f[6]=dw_i.getitemstring(foundrow,″ufcode″)

if isnull(f[6]) then goon=false

end if

//////////////////////

f[7]=string(dw_pz.getitemnumber(rown, ″jje″),″#########.00″)

if isnull(f[7]) then f[7]=″.00″

f[8]=string(dw_pz.getitemnumber(rown, ″dje″),″#########.00″)

if isnull(f[8]) then f[8]=″.00″

f[9]=″.00″

f[10]=″.00″

f[11]=″.00″

f[12]=dw_pz.getitemstring(rown, ″zdy″)

if isnull(f[12]) then f[12]=″″

f[13]=″″

f[14]=″″

f[15]=″″

//得到用友部门编码

number1=dw_pz.getitemstring(rown, ″bnumber″)

if trim(number1)=″″ or isnull(number1) then

f[16]=″″

else

foundrow=dw_b.find(″number="″+number1+″"″, 1, 10000 )

if foundrow 〈=0 then

goon=false

//f[16]=″″

else

f[16]=dw_b.getitemstring(foundrow,″ufcode″)

if isnull(f[16]) then goon=false

end if

end if

//////////////////////

//得到用友个人编码

number1=dw_pz.getitemstring(rown, ″pnumber″)

if trim(number1)=″″ or trim(number1)=fill(″9″,psumno) or&

trim(number1)=fill(″0″,psumno) or isnull(number1) then

f[17]=″″

else

foundrow=dw_p.find(″number="″+number1+″"″, 1, 10000 )

if foundrow 〈=0 then

goon=false

//f[17]=″″

else

f[17]=dw_p.getitemstring(foundrow,″ufcode″)

if isnull(f[17]) then goon=false

end if

end if

//////////////////////

f[18]=″″

f[19]=″″

f[20]=″″

//得到用友费用编码

number1=dw_pz.getitemstring(rown, ″enumber″)

if trim(number1)=″″ or isnull(number1) then

f[21]=″″

else

foundrow=dw_e.find(″number="″+number1+″"″, 1, 10000 )

if foundrow 〈=0 then

goon=false

//f[21]=″″

else

f[21]=mid(dw_e.getitemstring(foundrow,″ufcode″),4)

f[68]=left(dw_e.getitemstring(foundrow,″ufcode″),2)

if isnull(f[21]) or isnull(f[68]) then goon=false//f[21]=″″

end if

end if

//////////////////////

linestring=″″

for n68=1 to 68

if n68 〈 7 or (n68 〉 11 and n68 〈 22 ) or n68=68 then

if f[n68] 〈〉 ″″ then linestring=linestring+″+f[n68]+″

else

linestring=linestring+f[n68]

end if

if n68 〈〉 68 then linestring=linestring+″,″

next

//messagebox(″提示!″,linestring)

filewrite(filepointer,linestring)

next

//关闭文件

fileclose(filepointer)

if not goon then

messagebox(″提示!″,″所转换的凭证中有的编码还没有指定与U8 &

系统的编码相对应!~r~n本次转换无效,请设置对应关系后再转换!″)

FileDelete( filename )

return

end if

if not erroroccur then

messagebox(″提示!″,″转换发生了错误!~r~n本次转换无效,&

请设置对应关系后再转换!″)

return

//FileDelete( filename )

else

messagebox(″提示!″,″数据转换成功!~r~n文件成功保存到″+&

trim(SLe_1.TEXT)+″\″中,可在总账工具中“引入凭证”!″)

end if

四 输出文件

《标准》要求输出的数据具有对自身内容和格式的自描述特性。因此转换后的文件首先包括格式说明文件,然后才是数据文件。转换文件格式可以是文本文件,也可以是XML文件。但是与XML文件相比,文本文件对数据结构的自描述性功能相对较弱,因此文本接口的可扩展性相对较低,通常适用于标准财务数据的交换,如记账凭证、科目余额、会计报表的传递。本案例的主要用于记账凭证的转换,因此采用文本文件方式进行数据转换。上述文件VOUCHER.TXT能被价值链信息整合平台——U8系统直接读取,并经第八章第二节所述的“数据抽取”,即可参与生成价值链虚拟企业会计信息。