以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  判断空表  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=180028)

--  作者:采菊东篱下
--  发布时间:2022/9/23 21:25:00
--  判断空表
我用If DataTables("库存数据源").DataRows.Count = 0 And DataTables("出纳数据记账源").DataRows.Count = 0 And DataTables("财务数据源").DataRows.Count = 0 Then判断空表,如果是空表,就执行反审,结果死活不让我反审,调试发现库存数据源没有数据,但存在空行,如何判断所有单元格为空值?这样写了一下,不会弄了!不能用Compute函数统计整行为0,因为有的单元格是字符类型,不能统计。
        Dim sr() As String = {"库存数据源", "出纳数据记账源", "财务数据源"}
        For Each s As String In sr
            For Each c As DataCol In DataTables(s).DataCols
                For Each dr As DataRow In DataTables(s).DataRows
                    If dr.IsNull(c) Then
                        
                    End If 
                Next
            Next                       
        Next 
图片点击可在新窗口打开查看

[此贴子已经被作者于2022/9/24 9:28:26编辑过]

--  作者:采菊东篱下
--  发布时间:2022/9/23 22:27:00
--  
哦,行了,不过红色标注代码能用历遍控件简化代码吗?我试过历遍,但报错,因为有多种控件。
Dim t1 As WinForm.TextBox = e.Form.Controls("TextBox1")
Dim t2 As WinForm.TextBox = e.Form.Controls("TextBox2")
Dim t3 As WinForm.TextBox = e.Form.Controls("TextBox3")
Dim t4 As WinForm.TextBox = e.Form.Controls("TextBox4")
Dim t5 As WinForm.RadioButton = e.Form.Controls("RadioButton1")
Dim t6 As WinForm.RadioButton = e.Form.Controls("RadioButton2")
Dim t7 As WinForm.RadioButton = e.Form.Controls("RadioButton3")
Dim t8 As WinForm.RadioButton = e.Form.Controls("RadioButton4")
Dim t9 As WinForm.RadioButton = e.Form.Controls("RadioButton5")
Dim t10 As WinForm.RadioButton = e.Form.Controls("RadioButton6")
Dim t11 As WinForm.RadioButton = e.Form.Controls("RadioButton7")
Dim t12 As WinForm.RadioButton = e.Form.Controls("RadioButton8")
Dim t13 As WinForm.RadioButton = e.Form.Controls("RadioButton9")
Dim t14 As WinForm.ComboBox = e.Form.Controls("ComboBox1")
Dim t15 As WinForm.ComboBox = e.Form.Controls("ComboBox2")
Dim t16 As WinForm.RadioButton = e.Form.Controls("工业账")
Dim t17 As WinForm.RadioButton = e.Form.Controls("商业账")
Dim t18 As WinForm.CheckBox = e.Form.Controls("CheckBox1")
    Case "取消确定" 
        Dim sr() As String = {"库存数据源", "出纳数据记账源", "财务数据源"}
        For Each s As String In sr
            For Each c As DataCol In DataTables(s).DataCols
                For Each dr As DataRow In DataTables(s).DataRows
                    If dr IsNot Nothing Then
                        If dr.IsNull(c) = False Then
                            Return
                        ElseIf DataTables(s).DataRows.Count = 0 OrElse (DataTables(s).DataRows.Count > 0 And dr.IsNull(c)) Then
                            For Each tb As DataTable In DataTables
                                If tb.name = "企业资料" Then
                                    DataTables("企业资料").AllowEdit = True
                                    t1.ReadOnly = BooleanEnum.False
                                    t2.ReadOnly = BooleanEnum.False
                                    t3.ReadOnly = BooleanEnum.False
                                    t4.ReadOnly = BooleanEnum.False
                                    t5.ReadOnly = BooleanEnum.False
                                    t6.ReadOnly = BooleanEnum.False
                                    t7.ReadOnly = BooleanEnum.False
                                    t8.ReadOnly = BooleanEnum.False
                                    t9.ReadOnly = BooleanEnum.False
                                    t10.ReadOnly = BooleanEnum.False
                                    t11.ReadOnly = BooleanEnum.False
                                    t12.ReadOnly = BooleanEnum.False
                                    t13.ReadOnly = BooleanEnum.False
                                    t14.ReadOnly = BooleanEnum.False
                                    t15.ReadOnly = BooleanEnum.False
                                    t16.ReadOnly = BooleanEnum.False
                                    t17.ReadOnly = BooleanEnum.False
                                    t18.ReadOnly = BooleanEnum.False
                                Else
                                    DataTables(tb.name).AllowEdit = False
                                End If
                            Next
                        End If
                    End If
                Next
            Next 
        Next 
End Select
[此贴子已经被作者于2022/9/23 23:24:01编辑过]

--  作者:采菊东篱下
--  发布时间:2022/9/23 23:16:00
--  
红色部份代码我改为这样报错:“找不到t1控件”
             For i As Integer = 1 To 18
                    Dim t As WinForm.Control = e.Form.Controls("t" & i)
                    t.ReadOnly = BooleanEnum.True
                Next

--  作者:有点蓝
--  发布时间:2022/9/24 9:23:00
--  
for each s as string in {"TextBox1","TextBox2",.........}
e.Form.Controls(s).ReadOnly = BooleanEnum.True

--  作者:采菊东篱下
--  发布时间:2022/9/24 10:06:00
--  
我又看了一下帮助,这样写就可以了:
                                For Each t As WinForm.Control In e.Form.Controls
                                    t.ReadOnly = BooleanEnum.False
                                Next 
[此贴子已经被作者于2022/9/24 10:19:00编辑过]