0

我的 IF 语句有问题。

此声明的目的是所有 3 名经理必须批准订单才能处理。

这是声明:

Dim RstAllchk
Dim RstAllchk_numRows
Set RstAllchk = Server.CreateObject("ADODB.Recordset")
RstAllchk.ActiveConnection = MM_DBConn_STRING
RstAllchk.Source = "SELECT comitee.OrderNo, comitee.Bart, comitee.Carel, comitee.Charl             FROM comitee WHERE (((comitee.OrderNo)='" + Replace(RstAllData__varOrderNum, "'", "''") + "'));"
RstAllchk.CursorType = 0
RstAllchk.CursorLocation = 2
RstAllchk.LockType = 1
RstAllchk.Open()
RstAllchk_numRows = 0

    if  (RstAllchk.Fields.Item("Bart").Value)= "Approved" then
if  (RstAllchk.Fields.Item("Carel").Value)= "Approved" then
    if  (RstAllchk.Fields.Item("Charl").Value)= "Approved" then 

set cdata1 = Server.CreateObject("ADODB.Command")
cdata1.ActiveConnection = MM_DBConn_STRING
cdata1.CommandText = " UPDATE TblOrderData SET Fldapproved = 'Approved'  WHERE FldOrderID  = '" & RstAllData__varOrderNum  & "'" 
cdata1.CommandType = 1
cdata1.CommandTimeout = 0
cdata1.Prepared = true
cdata1.Execute()
cdata1.ActiveConnection.Close

set cdata2 = Server.CreateObject("ADODB.Command")
cdata2.ActiveConnection = MM_DBConn_STRING
cdata2.CommandText = " UPDATE TblOrderDetail SET FldMainapproved = 'Approved'  WHERE FldOrderNum  = '" & RstAllData__varOrderNum  & "'"
cdata2.CommandType = 1
cdata2.CommandTimeout = 0
cdata2.Prepared = true
cdata2.Execute()
cdata2.ActiveConnection.Close

`

有时,如果只有一位经理确认了订单,订单仍然被批准。这几天我一直在为此苦苦挣扎。希望大家能给我一些建议。

谢谢

4

3 回答 3

1

假设 VB.NET:

IF (RstAllchk.Fields.Item("Bart").Value = "Approved" AND _
    RstAllchk.Fields.Item("Carel").Value = "Approved" AND _
    RstAllchk.Fields.Item("Charl").Value = "Approved") THEN

在 C# 中:

if (RstAllchk.Fields.Item("Bart").Value == "Approved" &&
    RstAllchk.Fields.Item("Carel").Value == "Approved" &&
    RstAllchk.Fields.Item("Charl").Value == "Approved") 
于 2012-09-03T12:58:27.103 回答
0

使用 C#(&& 是 And , == 是相等的)

if ( RstAllchk.Fields.Item("Bart").Value == "Approved"

 &&  RstAllchk.Fields.Item("Carel").Value == "Approved"

 && RstAllchk.Fields.Item("Charl").Value == "Approved"
)

{

   //treatment

}
于 2012-09-03T12:58:48.383 回答
0

你可以合并所有喜欢

(if var1 == x && var2 == y && var3 == z) {
    //Do what you want
}
于 2012-09-03T12:59:53.117 回答