If e.Form.Controls("日期"). Value IsNot Nothing And e.Form.Controls("菜名"). Value IsNot Nothing And e.Form.Controls("配菜名称"). Value IsNot Nothing And e.Form.Controls("数量"). Value IsNot Nothing And e.Form.Controls("餐别"). Value IsNot Nothing Then
Dim Result As DialogResult
Dim dtt As DataTable = e.Form.Controls("Table1").Table.DataTable
Dim name As String = e.Form.Controls("配菜名称").text
If dtt.Find("日期 = '"& e.Form.Controls("日期").text &"'and " 配菜名称 = '" & e.Form.Controls("配菜名称").text & "'") IsNot Nothing Then
MessageBox.Show(" " & e.Form.Controls("日期").Value & " 已有 " & e.Form.Controls("配菜名称").text & "" )
Else
Result = messagebox.show("是否新增: 配菜名称: " & e.Form.Controls("配菜名称").text & " 吗 ?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Dim dr As DataRow = dtt.AddNew
dr("日期") = e.Form.Controls("日期").Value
dr("菜名") = e.Form.Controls("菜名").text
dr("配菜名称") = e.Form.Controls("配菜名称").text
dr("数量") = e.Form.Controls("数量").Value
dr("餐别") = e.Form.Controls("餐别").text
End If
End If
End If
代码该怎样改?请指教