以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  限制输入值  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=96824)

--  作者:luckbetter333
--  发布时间:2017/2/28 15:33:00
--  限制输入值

Select Case e.DataCol.name

Case "开票数量","订货数量","已开票数量"

 

If e.DataRow.IsNull("已开票数量") = False AndAlso e.DataRow("开票数量")> (e.DataRow("订货数量")-e.DataRow("已开票数量"))

 

    

MessageBox.Show("总开票数量已超过订货数量!")  

e.Cancel = True \'取消变动.

End If

If  e.DataRow.IsNull("已开票数量") = True AndAlso e.DataRow("开票数量")> e.DataRow("订货数量")

 

    

MessageBox.Show("开票数量已超过订货数量!")  

e.Cancel = True \'取消变动.

End If

 

 

End Select


我在datacolchanging中加了上面的代码,想实现总开票数量不能大于订货数量。其中已开票数量是动态汇总的,订货数量是固定值。开票数量是这张发票的开票数量。结果还是可以输入大于订货数量的开票数量,但一旦输入后,一更改就提示了,而且无法更改。


--  作者:有点色
--  发布时间:2017/2/28 15:39:00
--  

DataColChanged事件

 

Select Case e.DataCol.name
    Case "开票数量","订货数量","已开票数量"
        If e.DataRow.IsNull("已开票数量") = False AndAlso e.DataRow("开票数量")> (e.DataRow("订货数量")-e.DataRow("已开票数量"))
            MessageBox.Show("总开票数量已超过订货数量!")
            e.DataRow(e.DataCol.name) = e.OldValue
        End If
       
        If e.DataRow.IsNull("已开票数量") = True AndAlso e.DataRow("开票数量")> e.DataRow("订货数量")
            MessageBox.Show("开票数量已超过订货数量!")
            e.DataRow(e.DataCol.name) = e.OldValue
        End If
End Select