0

嗨,我正在尝试做一个 if else 语句:

@{
if(isset(Request["approve"])) { 
        var sql6 = "UPDATE Medical SET NurseDecision = 1, NurseCDSID = @0, NurseDate = GetDate() WHERE MedId = @1 AND AppId = @2 AND CDSID = @3";
        var appMedical = new[]{myCDSID, medicalData.MedId, permitAppAppId, employeeCDSID};
        db.Execute(sql6,appMedical);

        var sql7 = "UPDATE PermitApp SET NurseDecision = 1, NurseCDSID = @0, NurseDate = GetDate() WHERE MedId = @1 AND AppId = @2 AND CDSID = @3";
        var appPermitApp =new[]{myCDSID, reqPermit.MedId, permitAppAppId, employeeCDSID};
        db.Execute(sql7,appPermitApp);

    } elseif(isset(Request["reject"])){

        var sql8 = "UPDATE Medical SET NurseDecision = -1, NurseCDSID = @0, NurseDate = GetDate() WHERE MedId = @1 AND AppId = @2 AND CDSID = @3";
        var appMedical1 = new[]{myCDSID, medicalData.MedId, permitAppAppId, employeeCDSID};
        db.Execute(sql8,appMedical1);

        var sql9 = "UPDATE PermitApp SET NurseDecision = -1, NurseCDSID = @0, NurseDate = GetDate() WHERE MedId = @1 AND AppId = @2 AND CDSID = @3";
        var appPermitApp1 =new[]{myCDSID, reqPermit.MedId, permitAppAppId, employeeCDSID};
        db.Execute(sql9,appPermitApp1);
        }
}

以这样的一种形式提交 2 个提交按钮:

<form>
<input class="button" type="submit" style="margin:10px auto;" name="reject" value="Reject" />
<input class="button" type="submit" style="margin:10px auto; margin-left:400px;" name="approve" value="Approve" />
</form>

然而这是一个错误:

CS1026: ; expected on this line>> } elseif(isset(Request["reject"])){

谁能指出我的错误?谢谢

4

1 回答 1

0

elseif不是关键字,并且isset在 c# 中不可用这里的一些代码应该可以帮助您。

@{
    if(!string.IsNullOrEmpty(Request["approve"])) { 
        var sql6 = "UPDATE Medical SET NurseDecision = 1, NurseCDSID = @0, NurseDate = GetDate() WHERE MedId = @1 AND AppId = @2 AND CDSID = @3";
        var appMedical = new[]{myCDSID, medicalData.MedId, permitAppAppId, employeeCDSID};
        db.Execute(sql6,appMedical);

        var sql7 = "UPDATE PermitApp SET NurseDecision = 1, NurseCDSID = @0, NurseDate = GetDate() WHERE MedId = @1 AND AppId = @2 AND CDSID = @3";
        var appPermitApp =new[]{myCDSID, reqPermit.MedId, permitAppAppId, employeeCDSID};
        db.Execute(sql7,appPermitApp);

    } else if(!string.IsNullOrEmpty(Request["reject"])){

        var sql8 = "UPDATE Medical SET NurseDecision = -1, NurseCDSID = @0, NurseDate = GetDate() WHERE MedId = @1 AND AppId = @2 AND CDSID = @3";
        var appMedical1 = new[]{myCDSID, medicalData.MedId, permitAppAppId, employeeCDSID};
        db.Execute(sql8,appMedical1);

        var sql9 = "UPDATE PermitApp SET NurseDecision = -1, NurseCDSID = @0, NurseDate = GetDate() WHERE MedId = @1 AND AppId = @2 AND CDSID = @3";
        var appPermitApp1 =new[]{myCDSID, reqPermit.MedId, permitAppAppId, employeeCDSID};
        db.Execute(sql9,appPermitApp1); 
    }
}
于 2012-04-24T04:08:58.570 回答