Foxtable(狐表)用户栏目专家坐堂 → 判断空表


  共有5072人关注过本帖树形打印复制链接

主题:判断空表

美女呀,离线,留言给我吧!
采菊东篱下
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
判断空表  发帖心情 Post By: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编辑过]

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By: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编辑过]

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By: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

 回到顶部
帅哥,在线噢!
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106658 积分:542473 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/9/24 9:23:00 [只看该作者]

for each s as string in {"TextBox1","TextBox2",.........}
e.Form.Controls(s).ReadOnly = BooleanEnum.True

 回到顶部
美女呀,离线,留言给我吧!
采菊东篱下
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10368 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By: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编辑过]

 回到顶部