XAF如何生成单据编号(3)
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