-- 作者:mamuaiqing
-- 发布时间:2013/7/16 21:56:00
-- 表中行状态判断
想在窗口按钮代码中加个判断,判断窗口中表的所有行内容没发生过变化就提示用户,下面的代码怎么不行,pd的值都是等于 True,请教老师
Dim dt As DataTable = DataTables("授权_Table1") Dim pd As Boolean = False For Each dr As DataRow In dt.DataRows If dr.RowState = DataRowState.Unchanged Then pd = True End If Next If pd = True Then MessageBox.Show("当前并未对数据进行授权?", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question) Else
这里省略........
Endif
|
-- 作者:有点甜
-- 发布时间:2013/7/16 22:02:00
--
你逻辑有问题:
Dim dt As DataTable = DataTables("授权_Table1") Dim pd As Boolean = True For Each dr As DataRow In dt.DataRows If dr.RowState <> DataRowState.Unchanged Then pd = False
Exit For End If Next If pd = True Then MessageBox.Show("当前并未对数据进行授权?", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question) Else
这里省略........
Endif
|
-- 作者:mamuaiqing
-- 发布时间:2013/7/16 23:32:00
--
解决了,把代码改为这样:
Dim dt As DataTable = DataTables("授权_Table1") Dim pd As Boolean = True For Each dr As DataRow In dt.DataRows If dr.RowState = DataRowState.Modified Then pd = False Exit For End If Next If pd = True Then MessageBox.Show("当前并未对数据进行授权!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question) Else
这里省略......
End If
|