各位老师,
如何运用select case让下面红色的代码能够更简洁些?
以下是保存数据前在BeforeSaveDataRow检查行中的列不能为空的代码,行中可能有很多列的数据都要求不能为空。
If e.DataRow("唛头") = "" OrElse e.DataRow("业务员") = "" OrElse e.DataRow("生产单号") = "" OrElse e.DataRow.GetChildRows("生产明细").Count = 0 Then '判断是否不符合验证要求
MessageBox.Show("唛头,业务员,生产单号,生产明细不能为空","存盘失败",MessageBoxButtons.OK,MessageBoxIcon.Exclamation) '提示用户
End If
就象下面DataColChanging的代码一样比较简洁,
'表中的列不允许为空
'Select Case e.DataCol.Name
' Case "生产单号","唛头","业务员"
' If e.NewValue Is Nothing Then
' MessageBox.Show("'生产单号,唛头,业务员'不允许为空!")
' e.Cancel = True
' End If
'End Select
但BeforeSaveDataRow又没有DataCol,NewValue这样的e参数?
谢谢!