电子发票登记代码
功能:防止电子发票重复报销,与OA单据号进行绑定便于查询
以前的电子发票后台表存在流向库中,此库其它的数据已不再更新,为了备份电子发票的数据每天都 要备份,劳财伤民,计划将相关表迁到一个新库中,3年没有看过PB代码,恍如隔世;
内网使用,请无视安全;
1、登录
string password
int flag
username = trim(sle_1.text)
password = trim(sle_2.text)
select sw_name into :name from swryzd where sw_username = :username and sw_password = :password ;
If sqlca.sqlcode<>0 then
messagebox("错误",'登录出错,不正确的用户名或密码!'+sqlca.sqlerrtext)
rollback;
Return
else
select sw_ztbh into :ztbh from swryzd where sw_username = :username;
select sw_type into :yhlx from swryzd where sw_username= :username;
SetProfileString('linshi.ini','user','name',username)
End if
OpenWithParm(w_e_invoice,name)
2、先扫描报销单据上的OA流水号条码,再扫电子发票二维码(数据库中加入了电子发票唯一值规则,如果有重复会报错,所以没有在程序 中进行查重,直接取出错信息)
OA流水号条码是12位,电子发票的二维码格式也是固定 的。
//电子发票录入 2019-01-22
string vsorgtext,vssql,vsdate,oaname
string vscode,vsno,vstemp1,vstemp2,vsamount
dec vdamount
long vlrow,rownb
int id = 0
vsamount ='0'
vdamount = 0
vsorgtext = trim(sle_1.text)
If vsorgtext = '' or isnull(vsorgtext) then
sle_1.text = ''
sle_1.setfocus()
return
End if
if len(vsorgtext) = 12 then
vsoabh = vsorgtext
select id into:ID from oabh where oabh=:vsoabh;
if id=0 then
select a.fd_name into :oaname from EKP.ekptest.dbo.sys_org_element as a,EKP.ekptest.dbo.km_review_main as b where b.fd_number = :vsoabh and b.doc_creator_id=a.fd_id;
if oaname='' then
st_4.text='OA信息查询失败!'
return
end if
insert into oabh(date,oabh,oaname,syb,czy) values (convert(varchar(10),getdate(),120),:vsoabh,:oaname,:yhlx,:name);
st_4.text ='流程编号录入成功,现在进行发票绑定'
sle_1.text =''
dw_2.settransobject(sqlca)
dw_2.retrieve(name,yhlx)
dw_2.scrolltorow ( 999999 )
sle_1.setfocus()
else
st_4.text='该流程已录入,进入绑定环节!'
rownb = dw_2.find("oabh = '"+vsoabh+"'", 1, dw_2.rowcount())
dw_2.scrolltorow ( rownb )
sle_1.text =''
sle_1.setfocus()
end if
return
end if
If istemp = vsorgtext then
messagebox('提醒','发票号重复!')
sle_1.text =''
sle_1.setfocus()
return
End if
//以,号为分隔符,将二维码的各个部分截取出来;
vsdate = string(today())
vstemp1 = vsorgtext
vstemp2 = get_token(vstemp1,',')
vstemp2 = get_token(vstemp1,',')
vscode = get_token(vstemp1,',')
vsno = get_token(vstemp1,',')
vsamount =get_token(vstemp1,',')
vdamount = dec(vsamount)
if vsamount ='0' or vsamount='' then
//Messagebox('警告','发票信息不正确,请重新输入!'+'~n~r'+vsorgtext)
st_4.text='警告,发票信息不正确,请重新输入!'
sle_1.text = ''
sle_1.setfocus()
return
end if
if vsoabh <>'' then
vssql = "insert into invoice (org_text,invoice_code,invoice_no,amount,input_date,czy,oabh,syb) "
vssql += " values('"+vsorgtext +"',"
vssql += "'"+ vscode+"',"
vssql += "'"+ vsno+"',"
vssql += " "+ vsamount+","
vssql += "'"+ vsdate+"',"
vssql += "'"+name+"',"
vssql +=" '"+vsoabh+"',"
vssql +=" '"+yhlx+"')"
execute immediate :vssql ;
If sqlca.sqlcode<>0 then
messagebox("警告",'该发票已经核销过!'+'~n~r'+sqlca.sqlerrtext)
rollback;
sle_1.text = ''
sle_1.setfocus()
Return
else
dw_1.retrieve(vsoabh)
sle_1.text = ''
sle_1.setfocus()
End if
else
st_4.text = 'OA编号尚未录入'
sle_1.text = ''
sle_1.setfocus()
end if
3、刷新
string vsdate1,vsdate2
vsdate1= sle_rq1.text
vsdate2= sle_rq2.text
dw_2.settransobject(sqlca)
dw_2.retrieve(name,yhlx)
4、部分函数
1 字符串为空判断
/*--------------------------------------
名称:gf_zfwkpd()
功能:字符串为空判断
参数:pszdm 字段名
pstsf 返回提示符
返回:1 正确 0 错误
2006-01-17
- ------------------------------------*/
if Trim(pszdm)='' or isnull(pszdm) or len(trim(pszdm))=0 then
messagebox('提示',pstsf+'不能为空,请返回重填!')
RETURN 0
eLSE
RETURN 1
eND IF
2、截取字符串get_token(被截取的字符串,分隔符)
int vPos
string vsRet=""
vPos=pos(P_string,p_seperator)
if vPos >= 1 then
vsRet=left(p_string,vpos - 1)
P_string=right(p_string,Len(p_string) - vPos - Len(p_seperator)+1) //去掉分隔符
ELSE
vsRet=p_string
p_string=""
end if
return vsRet
附图:
程序主界面:文本框的modify 事件代码为上面2
活到老,学到老。