0

hi i am trying to do an if else statement:

@{
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);
        }
}

for 2 submit buttons in one form like this:

<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>

However this is an error:

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

Can anyone point my mistake to me?? Thanks

Panda
  • 71
  • 1
  • 2
  • 9
  • 1
    what does your php code have to do with this? – Daniel A. White Apr 22 '12 at 20:28
  • You are running queries in the View? And please be clear about C# or PHP. – H H Apr 22 '12 at 20:30
  • hmm guys...i think there is a misunderstanding i was trying to give an idea of what i would to do...PHP have no link with this but i just want to say that in PHP I would use that. – Panda Apr 22 '12 at 20:31
  • ok my question is improved hope it is clearer now – Panda Apr 22 '12 at 20:33
  • @DanielA.White is the question better now? – Panda Apr 22 '12 at 20:33
  • 1
    @Panda: Read the question, it makes no sense right now. What have the Buttons to do with if/else ? – H H Apr 22 '12 at 20:39
  • 1
    @Panda what are you trying to accomplish? Your question is still unintelligible. Please give clear instructions: "If user clicks Reject button _such and such_ should happen, if user clicks Approve _this_ should happen." And tell us what isn't working that you need help with. – jb. Apr 22 '12 at 21:39
  • Your mistake is that you have SQL strings in your view. That REALLY should not be there at all. – Jeff LaFay Apr 22 '12 at 21:40
  • @jb. hmm sorry i just edited the question...is it better? – Panda Apr 22 '12 at 21:43
  • @jlafay Sorry i do not get what you mean...what do you mean by view? – Panda Apr 22 '12 at 21:43
  • @Panda `isset` is a PHP function, you can't use it in C# code. – jb. Apr 22 '12 at 21:45
  • @jb oh...is there any replacement for it to be use in C# node?? – Panda Apr 22 '12 at 21:48
  • @Panda, I'm sorry I just realized this is webmatrix. I was thinking it was MVC because this is razor syntax. In MVC you separate your data process from razor. Razor is often used as the view which is the code that renders the page with all the data retrieved from the model. Maybe webmatrix is a lot different. – Jeff LaFay Apr 22 '12 at 21:50
  • @Panda take a look at http://stackoverflow.com/q/8094827/116286 – jb. Apr 22 '12 at 21:52
  • @jlafay its alright...Webmatrix is really crap seriously...i am forced to use it...unfortunately – Panda Apr 22 '12 at 22:01
  • @jb if the button is not click its referred as null? – Panda Apr 22 '12 at 22:04

1 Answers1

0

elseif is not a keyword and isset is not available in c# here's some code that should get you going.

@{
    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); 
    }
}
Buildstarted
  • 26,529
  • 10
  • 84
  • 95