以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]这个错误帮忙给检查下代码,不知道哪里错了。  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=52860)

--  作者:viking
--  发布时间:2014/6/24 16:15:00
--  [求助]这个错误帮忙给检查下代码,不知道哪里错了。

报错:

 

.NET Framework 版本:2.0.50727.5477
Foxtable 版本:2014.4.16.1
错误所在事件:表,利润明细单,PrepareEdit
详细错误信息:
调用的目标发生了异常。
未将对象引用设置到对象的实例。

 

代码如下:

帮忙给看下,谢谢,本人比较菜1

 

 

Select Case e.Col.Name
    Case "申请支出", "实际支出","支出说明","支出去向"
        If e.Row.IsNull("实收") = False  Then  \'AndAlso  \'e.Row.Isnull("第二列") = False Then
            e.Cancel = True
        End If
End Select

Select Case e.Col.Name
    Case "实收", "入账","收入凭号","收入说明"
        If e.Row.IsNull("申请支出") = False  Then  \'AndAlso  \'e.Row.Isnull("第二列") = False Then
            e.Cancel = True
        End If
End Select

Dim r As DataRow = e.Row.DataRow.GetParentrow("利润单")   \'如果当前表的父表"利润单"中的"订单状态"列中的内容等于以下内容,那么锁定子表中的关联行
If r IsNot Nothing Then
    If r("订单状态") = "3-业务审核" OrElse r("订单状态")  = "4-订单完成"  Then
        e.cancel = True
    End If
End If

 

Dim s As DataRow = e.Row.DataRow.GetParentrow("利润单")   \'如果当前表的父表"利润单"中的"订单状态"列中的内容等于"2-财务审核",那么锁定子表中的下列(订单编号,实收,收入凭号等)多列
If  e.Col.Name = "订单编号" OrElse e.Col.Name = "实收" OrElse e.Col.Name = "收入凭号" OrElse e.Col.Name = "收入说明" OrElse e.Col.Name = "申请支出"  OrElse e.Col.Name = "支出说明" OrElse e.Col.Name = "支出去向"Then
    If s("订单状态") = "2-财务审核"   Then
        e.cancel = True
    End If
End If


Dim p As DataRow = e.Row.DataRow.GetParentrow("利润单")   \'如果当前表的父表"利润单"中的"订单状态"列中的内容等于"2-财务审核",那么锁定子表中的下列(订单编号,实收,收入凭号等)多列
If  e.Col.Name = "账单编号" OrElse e.Col.Name = "入账" OrElse e.Col.Name = "实际支出" Then
    If p("订单状态") = "1-新增订单"   Then
        If User.Group <>  "办公室"  Then  \'且用户不是办公室
            e.cancel = True
        End If
    End If
End If

Dim d As DataRow = e.Row.DataRow.GetParentrow("利润单")   \'如果当前表的父表"利润单"中的"订单状态"列中的内容等于"2-财务审核" 且登录用户不是"办公室"组成员时.那么锁定子表中的关联行
If User.Group <>  "办公室"  Then  \'且用户不是办公室
    If d("订单状态") = "2-财务审核"  Then
        e.cancel = True
    End If
End If


Dim g As DataRow = e.Row.DataRow.GetParentrow("利润单")  \'如果当前表的父表"利润单"中的"订单状态"列中的内容等于"2-财务审核" 且登录用户不是"办公室"组成员时.那么锁定子表中的关联行
If  e.Col.Name = "实收" OrElse e.Col.Name = "收入凭号" OrElse e.Col.Name = "收入说明" OrElse e.Col.Name = "支出说明" OrElse e.Col.Name = "支出去向"  OrElse e.Col.Name = "申请支出" Then
    If User.Name  <> g("业务负责")  Then    \'如果当前登陆不是业务负责时
        If g ("订单状态") = "1-新增订单"  Then  \'如果内容是"1-新增订单"
            e.Cancel =  True       \'禁止编辑
        End  If
    End  If
End  If


If e.Table.Current IsNot Nothing Then
    If Forms("营业报账").Opened Then
        If e.Table.Current.isnull("账单编号") = True  Then
            Forms("营业报账").Controls("删除利润明细按键").Enabled = True
        Else
            Forms("营业报账").Controls("删除利润明细按键").Enabled = False
        End If
    End If
End If


--  作者:有点甜
--  发布时间:2014/6/24 16:18:00
--  

 类似这一段的代码,红色地方

 

Dim s As DataRow = e.Row.DataRow.GetParentrow("利润单")   \'如果当前表的父表"利润单"中的"订单状态"列中的内容等于"2-财务审核",那么锁定子表中的下列(订单编号,实收,收入凭号等)多列
If  e.Col.Name = "订单编号" OrElse e.Col.Name = "实收" OrElse e.Col.Name = "收入凭号" OrElse e.Col.Name = "收入说明" OrElse e.Col.Name = "申请支出"  OrElse e.Col.Name = "支出说明" OrElse e.Col.Name = "支出去向"Then
    If s IsNot Nothing AndAlso s("订单状态") = "2-财务审核"   Then
        e.cancel = True
    End If
End If


--  作者:Bin
--  发布时间:2014/6/24 16:19:00
--  
建议您用这个方法:
http://www.foxtable.com/help/topics/1485.htm

先找出是哪一行出错,然后分析原因,搞不定,贴出代码,并告诉我们运行到哪一行出错,以及错误提示。 或者上例子.

--  作者:有点甜
--  发布时间:2014/6/24 16:22:00
--  

 完整代码

 

Select Case e.Col.Name
    Case "申请支出", "实际支出","支出说明","支出去向"
        If e.Row.IsNull("实收") = False  Then  \'AndAlso  \'e.Row.Isnull("第二列") = False Then
            e.Cancel = True
        End If
End Select

Select Case e.Col.Name
    Case "实收", "入账","收入凭号","收入说明"
        If e.Row.IsNull("申请支出") = False  Then  \'AndAlso  \'e.Row.Isnull("第二列") = False Then
            e.Cancel = True
        End If
End Select

Dim pr As DataRow = e.Row.DataRow.GetParentrow("利润单")   \'如果当前表的父表"利润单"中的"订单状态"列中的内容等于以下内容,那么锁定子表中的关联行
If pr IsNot Nothing Then
    If pr("订单状态") = "3-业务审核" OrElse pr("订单状态")  = "4-订单完成"  Then
        e.cancel = True
    End If
End If


If  e.Col.Name = "订单编号" OrElse e.Col.Name = "实收" OrElse e.Col.Name = "收入凭号" OrElse e.Col.Name = "收入说明" OrElse e.Col.Name = "申请支出"  OrElse e.Col.Name = "支出说明" OrElse e.Col.Name = "支出去向"Then
    If pr IsNot Nothing AndAlso pr("订单状态") = "2-财务审核"   Then
        e.cancel = True
    End If
End If


If  e.Col.Name = "账单编号" OrElse e.Col.Name = "入账" OrElse e.Col.Name = "实际支出" Then
    If pr IsNot Nothing AndAlso pr("订单状态") = "1-新增订单"   Then
        If User.Group <>  "办公室"  Then  \'且用户不是办公室
            e.cancel = True
        End If
    End If
End If

If User.Group <>  "办公室"  Then  \'且用户不是办公室
    If pr IsNot Nothing AndAlso pr("订单状态") = "2-财务审核"  Then
        e.cancel = True
    End If
End If


If  e.Col.Name = "实收" OrElse e.Col.Name = "收入凭号" OrElse e.Col.Name = "收入说明" OrElse e.Col.Name = "支出说明" OrElse e.Col.Name = "支出去向"  OrElse e.Col.Name = "申请支出" Then
    If User.Name  <> pr("业务负责")  Then    \'如果当前登陆不是业务负责时
        If pr IsNot Nothing AndAlso pr("订单状态") = "1-新增订单"  Then  \'如果内容是"1-新增订单"
            e.Cancel =  True       \'禁止编辑
        End  If
    End  If
End  If


If e.Table.Current IsNot Nothing Then
    If Forms("营业报账").Opened Then
        If e.Table.Current.isnull("账单编号") = True  Then
            Forms("营业报账").Controls("删除利润明细按键").Enabled = True
        Else
            Forms("营业报账").Controls("删除利润明细按键").Enabled = False
        End If
    End If
End If


--  作者:Bin
--  发布时间:2014/6/24 16:23:00
--  
 If s IsNot Nothing AndAlso s("订单状态") = "2-财务审核"   Then
        e.cancel = True
    End If

类似这种地方要分开判断

 If s IsNot Nothing then
   If s("订单状态") = "2-财务审核"   Then
       e.cancel = True
   end if
end if


--  作者:viking
--  发布时间:2014/6/24 16:36:00
--  
以下是引用Bin在2014-6-24 16:19:00的发言:
建议您用这个方法:
http://www.foxtable.com/help/topics/1485.htm

先找出是哪一行出错,然后分析原因,搞不定,贴出代码,并告诉我们运行到哪一行出错,以及错误提示。 或者上例子.

谢谢啊,主要我太菜了,好多这个都不会,我努力啊,谢谢。。。

 

 

甜甜大侠,问你下你男的还是女的,结婚没?多大了?

爱死你了!!!图片点击可在新窗口打开查看