在服务端的AfterOpenProjet事件调试
Dim dt As DataTable
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "Selec t Year(登记日期) As 年, Month(登记日期) As 月, Max(合同编号) as 合同编号 From {采购计划} Group By Year(登记日期), Month(登记日期)"
dt = cmd.ExecuteReader
flbhs.Clear()
msgbox(“CG-----------”)
For Each dr As DataRow In dt.DataRows
Dim qz As String = "CG" & dr("年") & Format(dr("月"), "00") '编号前缀,4位年,2位月
msgbox(qz )
Dim bh As String = dr("合同编号")
msgbox(bh )
Dim id As Integer
If bh.Length = 12 Then 'CG202301-001
bh = bh.SubString(9)
If Integer.TryParse(bh, id) Then
msgbox("bh" & bh & ",id=" & id)
flbhs.Add(qz, id)
End If
End If
Next
Dim rk As DataTable
'Dim rkcmd As New SQLCommand
'rkcmd.C
cmd.CommandText = "Sele ct Year(入库日期) As 年, Month(入库日期) As 月, Max(入库单号) as 入库单号 From {入库} Group By Year(入库日期), Month(入库日期)"
rk = cmd.ExecuteReader
flbhs.Clear()
msgbox(“RK-----------”)
For Each dr As DataRow In rk.DataRows
Dim qz As String = "RK" & dr("年") & Format(dr("月"), "00") '编号前缀,4位年,2位月
msgbox(qz )
Dim bh As String = dr("入库单号")
msgbox(bh )
Dim id As Integer
If bh.Length = 12 Then 'CG202301-001
bh = bh.SubString(9)
If Integer.TryParse(bh, id) Then
msgbox("bh" & bh & ",id=" & id)
flbhs.Add(qz, id)
End If
End If
Next