If e.DataCol.Name = "日期" Then
If e.DataRow.IsNull("日期") Then
e.DataRow("运单号") = Nothing
Else
Dim d As Date = e.DataRow("日期")
Dim y As Integer = d.Year
Dim m As Integer = d.Month
Dim Days As Integer = Date.DaysInMonth(y,m)
Dim fd As Date = New Date(y,m,1) '获得该月的第一天
Dim ld As Date = New Date(y,m,Days) '获得该月的最后一天
Dim bh As String = Format(d,"yyyyMM") '生成编号的前6位,4位年,2位月.
If e.DataRow("运单号").StartsWith(bh) = False '如果编号的前6位不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(运单号)","日期 >= #" & fd & "# And 日期 <= #" & ld & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该月的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(6,4)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("运单号") = bh & Format(idx,"0000") & _UserName
End If
End If
End If
Select Case e.DataCol.name
Case "运单号"
Dim dr As DataRow = DataTables("发货库存").Find("运单号 = '" & e.OldValue & "'")
If dr Is Nothing Then
dr = DataTables("发货库存").AddNew()
dr("运单号") = e.DataRow("运单号")
dr("补单号") = e.DataRow("补单号")
dr("序号") = e.DataRow("序号")
dr("货号") = e.DataRow("货号")
dr("托运日期") = e.DataRow("托运日期")
dr("发站") = e.DataRow("发站")
dr("到站")=e.DataRow("到站")
dr("中转地")=e.DataRow("中转地")
dr("发货人")=e.DataRow("发货人")
dr("收货人")=e.DataRow("收货人")
dr("现付")=e.DataRow("现付")
dr("提付")=e.DataRow("提付")
dr("回单付")=e.DataRow("回单付")
dr("月结")=e.DataRow("月结")
dr("备注")=e.DataRow("备注")
dr("制单人")=e.DataRow("制单人")
dr("本部站点")=e.DataRow("本部站点")
dr("所属公司")=e.DataRow("所属公司")
dr("回单要求")=e.DataRow("回单要求")
dr("单型")=e.DataRow("单型")
dr("品名")=e.DataRow("品名")
dr("件数")=e.DataRow("件数")
dr("重量")=e.DataRow("重量")
dr("包装")=e.DataRow("包装")
dr("回扣")=e.DataRow("回扣")
dr("代收货款")=e.DataRow("代收货款")
dr("总运费")=e.DataRow("总运费")
Else
dr("运单号") = e.DataRow("运单号")
End If
Case "补单号","序号","货号","托运日期","发站","到站","中转地","发货人","收货人","现付","提付","回单付","月结","备注","制单人","本部站点","所属公司","回单要求","单型","品名","件数","重量","包装","回扣","代收货款","总运费"
Dim dr As DataRow = DataTables("发货库存").Find(" 运单号 = '" & e.DataRow("运单号") & "'")
If dr IsNot Nothing Then
dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name)
End If
End Select
If e.DataRow("付款方式") = "现付"
e.DataRow("提付") = 0
e.DataRow("回单付") = 0
e.DataRow("月结") = 0
e.DataRow("货款扣") = 0
End If
If e.DataRow("付款方式") = "提付"
e.DataRow("现付") = 0
e.DataRow("回单付") = 0
e.DataRow("月结") = 0
e.DataRow("货款扣") = 0
End If
If e.DataRow("付款方式") = "回单付"
e.DataRow("提付") = 0
e.DataRow("现付") = 0
e.DataRow("月结") = 0
e.DataRow("货款扣") = 0
End If
If e.DataRow("付款方式") = "月结"
e.DataRow("提付") = 0
e.DataRow("回单付") = 0
e.DataRow("现付") = 0
e.DataRow("货款扣") = 0
End If
If e.DataRow("付款方式") = "货款扣"
e.DataRow("提付") = 0
e.DataRow("回单付") = 0
此主题相关图片如下:错误.png
e.DataRow("月结") = 0
e.DataRow("现付") = 0
End If
If e.DataRow("付款方式") = "免费"
e.DataRow("提付") = 0
e.DataRow("回单付") = 0
e.DataRow("月结") = 0
e.DataRow("现付") = 0
e.DataRow("货款扣") = 0
End If