以文本方式查看主题

-  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=24296)

--  作者:akzzwj
--  发布时间:2012/10/10 8:58:00
--  请问各位高手,下面这段代码,哪里出错了?

If e.col.Name = "期末结存_数量" Then
    If e.Row.IsNull("期末结存_数量") = False
        If e.Row("期末结存_数量") <= DataTables("物品管理").DataCols("最低库存") Then
            e.Style = "最低库存"
        End If
    End If
End If

 

 

我是想实现这种效果,当前表 列 期末结存_数量 如果小于或等于 物品管理表 的 最低库存 则 会作出提醒。


--  作者:程兴刚
--  发布时间:2012/10/10 9:24:00
--  

If e.col.Name = "期末结存_数量" Then
    If e.Row.IsNull("期末结存_数量") = False
        Dim dr As DataRow = DataTables("物品管理").find("[物品编码] = \'" & e.Row("物品编码") & "\'","出库日期 Desc",0)
        If e.Row("期末结存_数量") <= dr("最低库存") Then
            e.Style = "最低库存"
        End If
    End If
End If

 

[物品编码]和[出库日期]两列为我给您假设,换成您自己的具备类似特征的列名称即可!


--  作者:akzzwj
--  发布时间:2012/10/10 10:17:00
--  

我把代码改成这样 可是确一直出错啊

If e.col.Name = "期末结存_数量" Then
    If e.Row.IsNull("期末结存_数量") = False
        Dim dr As DataRow = DataTables("物品管理").find("[最低库存] = \'" & e.Row("期末结存_数量") & "\'","月份 Desc",0)
        If e.Row("期末结存_数量") <= dr("最低库存") Then
            e.Style = "最低库存"
        End If
    End If
End If

请问 到底是哪里出错了呢?


--  作者:blackzhu
--  发布时间:2012/10/10 10:34:00
--  
If e.col.Name = "期末结存_数量" Then
    If e.Row.IsNull("期末结存_数量") = False
        Dim dr As DataRow = DataTables("物品管理").find("[最低库存] = \'" & e.Row("期末结存_数量") & "\'","月份 Desc",0)
      if dr isnot nothing then
        If e.Row("期末结存_数量") <= dr("最低库存") Then
            e.Style = "最低库存"
        End If
end if
    End If
End If

--  作者:akzzwj
--  发布时间:2012/10/10 10:39:00
--  

上面的这个代码 还是出错

上面的这个代码是写子啊DrawCell里,出现这样的错误提示:

NET Framework 版本:2.0.50727.3634
Foxtable 版本:2012.9.29.1
错误所在事件:表,收发存报表,DrawCellEdit
详细错误信息:
System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.IndexOutOfRangeException: 无法找到列 月份。
   在 System.Data.DataTable.ParseSortString(String sortString)
   在 System.Data.Select..ctor(DataTable table, String filterExpression, String sort, DataViewRowState recordStates)
   在 System.Data.DataTable.Select(String filterExpression, String sort)
   在 Foxtable.DataTable.Find(String OO01ll0Ol1O10ll1, String O01l, Int32 O1lOO)
   在 UserCode.DrawCell(DrawCellEventArgs e)
   --- 内部异常堆栈跟踪的结尾 ---
   在 System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   在 System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   在 Foxtable.Ol0OOl0100lO10.Ol00O10ll1l1OllO(Object O101l0, OwnerDrawCellEventArgs O, Boolean OO1101l001O100001100l, Boolean Ol0l0l1)


--  作者:akzzwj
--  发布时间:2012/10/10 10:41:00
--  

没有

 


--  作者:akzzwj
--  发布时间:2012/10/10 10:56:00
--  

如果去掉 那代码又该怎么写呢

试了好多次 总是出现错误提示


--  作者:czy
--  发布时间:2012/10/10 10:56:00
--  

暂不说有没有月份列,凭我的感觉要达到你设想的要求,你的代码表达式判断是有问题的。

当然如果你的物品管理表不区分不能同物品就另说了。

 


--  作者:程兴刚
--  发布时间:2012/10/10 11:07:00
--  
就是,哪有表达式值用数量来判断的?99%的时候dr都为nothing