老师,如何把下面代码放在窗口的按键单击事件,还是这些代码是放在新增,保存代码之前还是其位置之后?谢谢
有试一下,报错
Dim dr As DataRow = e.DataRow
Dim pf As String
If dr.RowState <> DataRowState.Added Then
Return
ElseIf dr.IsNull("制单日期") Then
e.Cancel = True
MessageBox.Show("必须输入日期!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Return
Else
pf = "SHDH" & "" & Format(dr("制单日期"),"yyyyMM")
End If
e.DataRow("送货单号") = pf & "-" & Format(Key,"0000") '流水号的设计)
e.DataRow("制单日期") = Date.Today()
e.DataRow("制单人") = User.name
Static Index As Integer = 99999
e.DataRow("送货单号") = Format(Date.Today(),"yyMM") & "-" & Index
Index = Index - 1