以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [讨论]有条件执行代码 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=69920) |
||||
-- 作者:wangyinming -- 发布时间:2015/6/12 17:14:00 -- [讨论]有条件执行代码 选择性工序后,执行代码. 现在是勾选:检查工序,会计算一下标准作业和能力,代码如下。 实现:在工程列,填入仕上工序,才会执行一下代码,否则标准作业和能力=0 请高手看看如何加条件?
Dim ary() As String = {"检查","切边","自动切边","空检","磁检","套弹簧","封油脂","组装","防锈包装","称油脂","返工","不良调试","毛边确认","气泡确认","裂开确认"} Select Case e.DataCol.Name Case "型号1" If e.NewValue = Nothing Then e.DataRow("作业标准") = Nothing e.DataRow("能力") = Nothing Else e.DataTable.DataCols("检查").RaiseDataColChanged(e.DataRow) End If Case Else If array.IndexOf(ary, e.DataCol.Name) > -1 Then Dim filter As String = "1=1" For Each a As String In ary If e.DataRow.IsNull(a) OrElse e.DataRow(a) = False Then filter &= " and " & a.Replace("1", "") & " Is null" Else filter &= " and " & a.Replace("1", "") & " = \'*\'" End If Next Dim fdr As DataRow = DataTables("工序标准").Find(filter) If fdr IsNot Nothing Then e.DataRow("作业标准") = fdr("标准工序") If DataTables("标准能力").DataCols.Contains(fdr("标准工序")) Then filter = "型号 = \'" & e.DataRow("型号1") & "\'" fdr = DataTables("标准能力").Find(filter) If fdr IsNot Nothing Then e.DataRow("能力") = val(fdr(e.DataRow("作业标准"))) Else e.DataRow("能力") = Nothing End If Else e.DataRow("能力") = Nothing End If Else e.DataRow("作业标准") = Nothing e.DataRow("能力") = Nothing End If End If End Select
|
||||
-- 作者:大红袍 -- 发布时间:2015/6/12 17:44:00 -- Dim ary() As String = {"检查","切边","自动切边","空检","磁检","套弹簧","封油脂","组装","防锈包装","称油脂","返工","不良调试","毛边确认","气泡确认","裂开确认"} Select Case e.DataCol.Name Case "工程" If e.NewValue = Nothing Then e.DataRow("作业标准") = Nothing e.DataRow("能力") = Nothing Else e.DataTable.DataCols("检查").RaiseDataColChanged(e.DataRow) End If Case Else If e.DataRow.IsNull("工程") Then e.DataRow("作业标准") = Nothing e.DataRow("能力") = Nothing Else If array.IndexOf(ary, e.DataCol.Name) > -1 Then Dim filter As String = "1=1" For Each a As String In ary If e.DataRow.IsNull(a) OrElse e.DataRow(a) = False Then filter &= " and " & a.Replace("1", "") & " Is null" Else filter &= " and " & a.Replace("1", "") & " = \'*\'" End If Next Dim fdr As DataRow = DataTables("工序标准").Find(filter) If fdr IsNot Nothing Then e.DataRow("作业标准") = fdr("标准工序") If DataTables("标准能力").DataCols.Contains(fdr("标准工序")) Then filter = "型号 = \'" & e.DataRow("型号1") & "\'" fdr = DataTables("标准能力").Find(filter) If fdr IsNot Nothing Then e.DataRow("能力") = val(fdr(e.DataRow("作业标准"))) Else e.DataRow("能力") = Nothing End If Else e.DataRow("能力") = Nothing End If Else e.DataRow("作业标准") = Nothing e.DataRow("能力") = Nothing End If End If End If End Select |
||||
-- 作者:wangyinming -- 发布时间:2015/6/12 21:47:00 -- 谢谢!,修改了一下, If e.DataRow("工程") = "加硫" Then e.DataRow("作业标准") = "0" e.DataRow("能力") ="0" 列工程等于加硫的时候就=0,谢谢。已决解 |