Dim rq As WinForm.DateTimePicker = e.Form.Controls("日期")
Dim djlx As WinForm.ComboBox = e.Form.Controls("单据类型")
Dim pp As WinForm.ComboBox = e.Form.Controls("品牌")
Dim md As WinForm.ComboBox = e.Form.Controls("门店")
Dim djbh As WinForm.TextBox = e.Form.Controls("单据编号")
If rq.Value = Nothing Then
djbh.Text =""
Else
Dim bh As String = Format(rq.value,"yyyyMMdd") '取得编号的8位前缀
If DataTables("库调明细表_主表").DataRow("业务单号").StartsWith(bh) = False
Dim max As String
Dim idx As Integer
max = e.DataTables("库调明细表_主表").Compute("Max("业务单号")","单据日期 = #" & rq.Value & "# And [_Identify] <> " & DataTables("库调明细表_主表").DataRow("_Identify") And )
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(9,3)) + 1 Else
idx = 1
End If
djbh.text = bh & "-" & Format(idx,"000")
End If
End If
End If