expressapp framework (以下簡(jiǎn)稱xaf)是devexpress公司開發(fā)的一套基于.net平臺(tái)的o/r m快速開發(fā)應(yīng)用架構(gòu),其特點(diǎn)是可以快速的開發(fā)出基于web和winform的數(shù)據(jù)庫(kù)應(yīng)用程序,在xaf的實(shí)際應(yīng)用開發(fā)過程中,我們難免要實(shí)現(xiàn)單據(jù)編號(hào)的自動(dòng)生成和管理,傳統(tǒng)的很多應(yīng)用系統(tǒng)都是利用存儲(chǔ)過程來(lái)實(shí)現(xiàn)這一目的的,我們知道xaf的是用xpo來(lái)和數(shù)據(jù)庫(kù)存儲(chǔ)系統(tǒng)交互的,有沒有辦法不用存儲(chǔ)過程而直接用xpo來(lái)生成和管理應(yīng)用系統(tǒng)的單據(jù)編號(hào)呢?答案是肯定的,下面就把這個(gè)實(shí)現(xiàn)的實(shí)體類和相應(yīng)的實(shí)現(xiàn)函數(shù)共享出來(lái),給大家參考.
1.單據(jù)編號(hào)設(shè)定實(shí)體類
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
無(wú)
年
年月
年月日
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.單據(jù)編號(hào)生成函數(shù)
生成單據(jù)編號(hào)函數(shù)
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.無(wú)
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.調(diào)用方法代碼
調(diào)用方法代碼
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
新聞熱點(diǎn)
疑難解答
圖片精選