以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]按条件打开提示框,不能得到预想结果?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=28857)

--  作者:红颜
--  发布时间:2013/2/20 16:28:00
--  [求助]按条件打开提示框,不能得到预想结果?

窗口按钮代码:

Dim Count As Integer = DataTables("SFMX").Compute("Count(ZT)","ZT = 0")
Dim Result As DialogResult
Result = MessageBox.Show("存在未收费的单据,是否继续收费?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Count > 0 Then
    If Result = DialogResult.Yes Then
        Tables("SFMX").Filter = "[ZT] = 0"
        Forms("找零计算").Show()
    Else
        e.Form.Controls("ComboBox1").value = Nothing
        e.form.Controls("ComboBox1").Select()
    End If
End If

 

问题:表中已经不存在未收费的单据Count > 0,提示框依然打开。

预想效果:

1、表中存在未收费单据时,打开提示框;

    点击“是”时,筛选出未收费单据,同时打开Forms("找零计算")窗口。

    点击“否”时,执行代码: e.Form.Controls("ComboBox1").value = Nothing
                                       e.form.Controls("ComboBox1").Select()
2、表中不存在未收费单据时Count <= 0,不打开提示框,直接执行代码:

    e.Form.Controls("ComboBox1").value = Nothing
    e.form.Controls("ComboBox1").Select()

 


--  作者:blackzhu
--  发布时间:2013/2/20 16:36:00
--  
Dim Count As Integer = DataTables("SFMX").Compute("Count(ZT)","ZT = 0")
If Count > 0 Then
    Dim Result As DialogResult
    Result = MessageBox.Show("存在未收费的单据,是否继续收费?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If Result = DialogResult.Yes Then
        Tables("SFMX").Filter = "[ZT] = 0"
        Forms("找零计算").Show()
    Else
        e.Form.Controls("ComboBox1").value = Nothing
        e.form.Controls("ComboBox1").Select()
    End If
End If

--  作者:lin_hailun
--  发布时间:2013/2/20 16:37:00
--  
 这样试试看看。不可能有错的,肯定是你的数据有问题。

Dim Count As Integer = DataTables("SFMX").Compute("Count(_Identify)","ZT = 0")
If Count > 0 Then
    Dim Result As DialogResult
    Result = MessageBox.Show("存在未收费的单据,是否继续收费?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If Result = DialogResult.Yes Then
        Tables("SFMX").Filter = "[ZT] = 0"
        Forms("找零计算").Show()
        return
    End If
End If
e.Form.Controls("ComboBox1").value = Nothing
e.form.Controls("ComboBox1").Select()
[此贴子已经被作者于2013-2-20 17:19:30编辑过]

--  作者:红颜
--  发布时间:2013/2/20 17:12:00
--  

谢谢!blackzhu,在易表论坛似曾相识,在这里有见面了。

 

Dim Count As Integer = DataTables("SFMX").Compute("Count(ZT)","ZT = 0")
If Count > 0 Then
    Dim Result As DialogResult
    Result = MessageBox.Show("存在未收费的单据,是否继续收费?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If Result = DialogResult.Yes Then
        Tables("SFMX").Filter = "[ZT] = 0"
        Forms("找零计算").Show()
    Else
        Tables("SFMX").Filter = "[BH] Is Null"
        e.Form.Controls("ComboBox1").value = Nothing
        e.Form.Controls("ComboBox2").value = Nothing
        e.Form.Controls("ComboBox3").value = Nothing
        e.Form.Controls("NumericComboBox1").value = Nothing
        e.Form.Controls("NumericComboBox2").value = Nothing
        e.form.Controls("ComboBox1").Select()
    End If
End If
If Count <= 0 Then
    Tables("SFMX").Filter = "[BH] Is Null"
    e.Form.Controls("ComboBox1").value = Nothing
    e.Form.Controls("ComboBox2").value = Nothing
    e.Form.Controls("ComboBox3").value = Nothing
    e.Form.Controls("NumericComboBox1").value = Nothing
    e.Form.Controls("NumericComboBox2").value = Nothing
    e.form.Controls("ComboBox1").Select()
End If

请大虾们看看上面代码能不能合并或简化。红色的两段有些啰嗦。


--  作者:lin_hailun
--  发布时间:2013/2/20 17:20:00
--  
Dim Count As Integer = DataTables("SFMX").Compute("Count(ZT)","ZT = 0")
If Count > 0 Then
    Dim Result As DialogResult
    Result = MessageBox.Show("存在未收费的单据,是否继续收费?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    If Result = DialogResult.Yes Then
        Tables("SFMX").Filter = "[ZT] = 0"
        Forms("找零计算").Show()
        Return
    End If
End If

Tables("SFMX").Filter = "[BH] Is Null"
e.Form.Controls("ComboBox1").value = Nothing
e.Form.Controls("ComboBox2").value = Nothing
e.Form.Controls("ComboBox3").value = Nothing
e.Form.Controls("NumericComboBox1").value = Nothing
e.Form.Controls("NumericComboBox2").value = Nothing
e.form.Controls("ComboBox1").Select()