If Forms("主界面").opened Then
MyTimers("计划1").Enabled = False
Forms("主界面").controls("库存警告").Enabled = False
Dim Today As Date = Date.Today
Dim Names As String = "日一二三四五六"
Dim Result As String
Result = "星期" & Names.Chars(Today.DayOfWeek)
Forms("主界面").controls("登录账号").Text = user.Name
Forms("主界面").controls("用户姓名").Text = user.Name
Forms("主界面").controls("用户分组").Text = User.Group
Forms("主界面").controls("登录日期").Text = Today & " " & Result
Dim cmd1,cmd2 As new SQLCommand
Dim dt1,dt2 As DataTable
Dim s As String
下面的黑字和红字部分的代码几乎完全一样,红字代码可以正常执行,而黑字部分,执行到绿字部分出错,提示为"查询过于复杂."甚为不解,请大家帮忙看看!
If user.Group = "兰州嘉禾天悦商贸有限公司" Then
cmd1.C
cmd2.C
cmd1.CommandText = "Select * from {库存表} where 库房 <>'" & user.Group & "库房'"
cmd2.CommandText = "Select * from {库存表} where 库房 ='" & user.Group & "库房'"
dt1 = cmd1.ExecuteReader()
dt2 = cmd2.ExecuteReader()
MessageBox.Show(1)
If dt2.DataRows.count > 0 Then
For Each dr2 As DataRow In dt2.DataRows
Dim dr1 As DataRow = dt1.Find("货号 = '" & dr2("货号") & "' And 颜色 ='" & dr2("颜色") & "'")
If dr1 Is Nothing Then
s = s & "Or [_Identify] =" & dr2("_Identify")
End If
Next
s = s.trim("O")
s = s.trim("r")
MessageBox.Show(2)
If s > "" Then
Forms("主界面").controls("库存警告").Enabled = True
Forms("主界面").controls("库存警告").Image = GetImage("kcjg.gif")
MyTimers("计划1").Enabled = True
MessageBox.Show(3)
DataTables("库存表").LoadFilter = ""
MessageBox.Show(4)
DataTables("库存表").LoadFilter = s
MessageBox.Show(s)
DataTables("库存表").Load()
Else
Forms("主界面").controls("库存警告").Image = GetImage("44.gif")
MyTimers("计划1").Enabled = False
Forms("主界面").controls("库存警告").Enabled = False
End If
End If
End If
If user.Type = UserTypeEnum.User Then
If user.Group <> "兰州嘉禾天悦商贸有限公司" Then
cmd1.C
cmd1.CommandText = "Select * from {库存表} where 库房 ='" & user.Group & "库房'" & " And 库区 ='展厅'"
dt1 = cmd1.ExecuteReader()
cmd2.C
cmd2.CommandText = "select * from {库存表} where 库房 ='" & user.Group & "库房'" & " And 库区 ='后堂'"
dt2 = cmd2.ExecuteReader()
If dt2.DataRows.count > 0 Then
For Each dr2 As DataRow In dt2.DataRows
Dim dr1 As DataRow = dt1.Find("货号 = '" & dr2("货号") & "' And 颜色 ='" & dr2("颜色") & "'")
If dr1 Is Nothing Then
s = s & "Or [_Identify] =" & dr2("_Identify")
End If
Next
s = s.trim("O")
s = s.trim("r")
If s > "" Then
Forms("主界面").controls("库存警告").Enabled = True
Forms("主界面").controls("库存警告").Image = GetImage("kcjg.gif")
MyTimers("计划1").Enabled = True
DataTables("库存表").LoadFilter = ""
DataTables("库存表").LoadFilter = s
MessageBox.Show(s)
DataTables("库存表").Load()
Else
Forms("主界面").controls("库存警告").Image = GetImage("44.gif")
MyTimers("计划1").Enabled = False
Forms("主界面").controls("库存警告").Enabled = False
End If
End If
End If
End If
End If