expressapp framework (以下简称xaf)是devexpress公司开发的一套基于.net平台的o/r m快速开发应用架构,其特点是可以快速的开发出基于web和winform的数据库应用程序,在xaf的实际应用开发过程中,我们难免要实现单据编号的自动生成和管理,传统的很多应用系统都是利用存储过程来实现这一目的的,我们知道xaf的是用xpo来和数据库存储系统交互的,有没有办法不用存储过程而直接用xpo来生成和管理应用系统的单据编号呢?答案是肯定的,下面就把这个实现的实体类和相应的实现函数共享出来,给大家参考.
1.单据编号设定实体类
imports system
imports system.componentmodel
imports devexpress.xpo
imports devexpress.expressapp
imports devexpress.persistent.base
imports devexpress.persistent.baseimpl
imports devexpress.persistent.validation
_
_
public class b_billcodeprex
inherits baseobject
public sub new(byval session as session)
mybase.new(session)
end sub
private ftbname as string
_
_
public property tbname() as string
get
return ftbname
end get
set(byval value as string)
setpropertyvalue("tbname", ftbname, value)
end set
end property
private ftbcaption as string
_
_
public property tbcaption() as string
get
return ftbcaption
end get
set(byval value as string)
setpropertyvalue("tbcaption", ftbcaption, value)
end set
end property
|||
private fprex as string
_
public property prex() as string
get
return fprex
end get
set(byval value as string)
setpropertyvalue("prex", fprex, value)
end set
end property
private flenth as integer = 5
_
public property lenth() as integer
get
return flenth
end get
set(byval value as integer)
setpropertyvalue("lenth", flenth, value)
end set
end property
private finterval as string = "-"
_
public property interval() as string
get
return finterval
end get
set(byval value as string)
setpropertyvalue("interval", finterval, value)
end set
end property
public enum eprex
无
年
年月
年月日
end enum
|||
private fdprex as eprex
_
public property dprex() as eprex
get
return fdprex
end get
set(byval value as eprex)
setpropertyvalue("dprex", fdprex, value)
end set
end property
end class
2.单据编号生成函数
生成单据编号函数
1 public function updatebillcode()function updatebillcode(byval fbcode as string, byval bo as object)
2 dim billcodeprex as b_billcodeprex = session.findobject(of b_billcodeprex)(new binaryoperator("tbname", bo.gettype.name))
3 if billcodeprex isnot nothing then
4 if billcodeprex.tbname isnot nothing then
5 if bo.gettype.name = billcodeprex.tbname.trim then
6 dim bb as string = ""
7 dim pre as string = ""
8 if billcodeprex.interval is nothing then
9 bb = ""
10 else
11 bb = billcodeprex.interval.trim
12 end if
13 if not billcodeprex.prex.trim = nothing then
14 pre = billcodeprex.prex.toupper.trim & bb
15 else
16 pre = ""
17 end if
18 dim cc as string = ""
19 if not billcodeprex.dprex = nothing then
20 select case billcodeprex.dprex
21 case b_billcodeprex.eprex.年
22 cc = format(now.year, "00").tostring & bb
23 case b_billcodeprex.eprex.年月
24 cc = format(now.year, "00").tostring & bb & format(now.month, "00").tostring & bb
25 case b_billcodeprex.eprex.年月日
26 cc = format(now.year, "00").tostring & bb & format(now.month, "00").tostring & bb & format(now.day, "00").tostring & bb
27 case b_billcodeprex.eprex.无
28 cc = ""
29 end select
30 else
31 cc = ""
32 end if
33 dim flowlenth as integer = 4
34 dim aa as string = ""
35 if billcodeprex.lenth > 0 then
36 flowlenth = billcodeprex.lenth
37 end if
38 for i = 1 to flowlenth step 1
39 aa &= "0"
40 next
41 fbcode = pre & cc & format(distributedidgeneratorhelper.generate(bo.session.datalayer, bo.[gettype]().fullname, cc), aa)
42 else
43 fbcode = format(distributedidgeneratorhelper.generate(bo.session.datalayer, bo.[gettype]().fullname, "erp"), "00000000")
44 end if
45 else
46 fbcode = format(distributedidgeneratorhelper.generate(bo.session.datalayer, bo.[gettype]().fullname, "erp"), "00000000")
47 end if
48 else
49 fbcode = format(distributedidgeneratorhelper.generate(bo.session.datalayer, bo.[gettype]().fullname, "erp"), "00000000")
50
51 end if
52 return fbcode
53 end function
54
3.调用方法代码
调用方法代码
1 public overloads overrides sub afterconstruction()sub afterconstruction()
2 mybase.afterconstruction()
3 fbillcode = updatebillcode(fbillcode, me)
4 bkbillcode = fbillcode
5
6 end sub
7 private fbillcode as string
8
9 _
10 public property billcode()property billcode() as string
11 get
12 return fbillcode
13 end get
14 set(byval value as string)
15 setpropertyvalue("billcode", fbillcode, value)
16 end set
17 end property
新闻热点
疑难解答