以文本方式查看主题

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

--  作者:zaq3574020
--  发布时间:2020/9/12 14:10:00
--  代码垄余,相同的代码。怎么封装
If zdc.Checked Then
                                zd=DataTables("转仓单明细").Find("款号=\'" & drs("款号") & "\' And 花色=\'" & drs("花色") & "\' and 尺码 = \'" & drs("尺码") & "\' and 仓库=\'" & ck & "\'and 调入仓库=\'总部仓库\'","日期")
                                If zd Is Nothing Then
                                    If drts.Text.Length>0 Then
                                        dr=DataTables("转仓单明细").Find("款号=\'" & drs("款号") & "\' And 花色=\'" & drs("花色") & "\' and 尺码 = \'" & drs("尺码") & "\' and 仓库=\'" & ck & "\'","日期")
                                        dc=DataTables("转仓单明细").Find("款号=\'" & drs("款号") & "\' And 花色=\'" & drs("花色") & "\' and 尺码 = \'" & drs("尺码") & "\' and 调出仓库=\'" & ck & "\'","日期")
                                        If dc IsNot Nothing And dr IsNot Nothing Then
                                            Dim t1 As TimeSpan =  dc("日期") - dr("日期")
                                            If t1.TotalDays<drts.Text
                                                If cnt > 0 Then
                                                    drs(ck) = 1
                                                    cnt = cnt - 1
                                                Else
                                                    drs(ck) = Nothing
                                                End If
                                            End If
                                        End If
                                    Else
                                        If cnt > 0 Then
                                            drs(ck) = 1
                                            cnt = cnt - 1
                                        Else
                                            drs(ck) = Nothing
                                        End If
                                    End If
                                End If
                            End If
                        Else
                            If drts.Text.Length>0 Then
                                dr=DataTables("转仓单明细").Find("款号=\'" & drs("款号") & "\' And 花色=\'" & drs("花色") & "\' and 尺码 = \'" & drs("尺码") & "\' and 仓库=\'" & ck & "\'","日期")
                                dc=DataTables("转仓单明细").Find("款号=\'" & drs("款号") & "\' And 花色=\'" & drs("花色") & "\' and 尺码 = \'" & drs("尺码") & "\' and 调出仓库=\'" & ck & "\'","日期")
                                If dc IsNot Nothing And dr IsNot Nothing Then
                                    Dim t1 As TimeSpan =  dc("日期") - dr("日期")
                                    If t1.TotalDays<drts.Text
                                        If cnt > 0 Then
                                            drs(ck) = 1
                                            cnt = cnt - 1
                                        Else
                                            drs(ck) = Nothing
                                        End If
                                    End If
                                End If
                            Else
                                If cnt > 0 Then
                                    drs(ck) = 1
                                    cnt = cnt - 1
                                Else
                                    drs(ck) = Nothing
                                End If
                            End If
                        End If


--  作者:有点蓝
--  发布时间:2020/9/12 14:34:00
--  
dim cando as boolean = true
If zdc.Checked Then
      zd=DataTables("转仓单明细").Find("款号=\'" & drs("款号") & "\' And 花色=\'" & drs("花色") & "\' and 尺码 = \'" & drs("尺码") & "\' and 仓库=\'" & ck & "\'and 调入仓库=\'总部仓库\'","日期")
       If zd Isnot Nothing Then cando =false
end if

if cando  then
重复的代码放这里
endif