Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
when i implement the method
MiseAjourEtatFactureWCF(ref string REF_COMPTE_FACTURATION, ref int STATUT)
in my wcf project this following error has appeared:

error:

Invalid expression term 'if'

code:

C#
public retour MiseAjourEtatFactureWCF(ref string REF_COMPTE_FACTURATION, ref int STATUT)
{
  Service1 ser = new Service1();
  retour rt = new retour();
  ser.MiseAJourFacture( //removed this
  if (ser.MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT).Equals(-1))
  {
    try
    {
      rt.CodeRetour = -1;
      rt.msgRetour = "mise à jour etat facture échoué";
    }
    catch (Exception e)
    {
      CreateLog log = new CreateLog(e);

      log.ErrorLog(@"C:\Documents and Settings\Administrateur\Bureau\fichierLog.txt");
    }

    return rt;
  }
  else
  {
    rt.CodeRetour = 0;
    rt.msgRetour = "mise à jour etat facture réussit";
    return rt;
  }
}




knowing that the goal of this method is to return error an message and to create log file in the case of failed call of the method
MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT) and the succes message in the case of succeeded call of this method.

[Added]
the problem is in if loop because when i run my project it show me always the case of success
[/Added]

Please help me because i'm a beginner. :(( :(( :((

[Modified: pre tags are much better for large blocks of code. code tags can be used when adding single lines of code. Also, just a small amount of time to add the proper spacing makes getting answers much easier.]
Posted
Updated 1-Jun-10 8:30am
v3
Comments
William Winner 1-Jun-10 14:33pm    
You're not new to this forum, but apparently no one has told you this:

Don't post answers to your own question!

They have added a lot to this forum. If you have additional information about the question, add it to the OP. If you want to comment on someone else's answer, there's a comment button below that answer. Posting an answer is only for posting an answer.

I've added the information into your OP.

1 solution

Ok, so your problem is that it always returns successfully? That doesn't sound like a problem to me.

Well, if you're never getting the message; "mise à jour etat facture échoué", and you're expecting to, then that is a problem, but without knowing what ser is or what MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT) should return with different cases, I can't tell you why it's not working.

I will say that you should never get an error log created though. Because, I would assume that
C#
rt.CodeRetour = -1;
rt.msgRetour = "mise à jour etat facture échoué";

should never throw an error.

Also, I'm a little confused with what your CreateLog is. You create a new log and pass it the exception. Then, you pass it a file location. Is that a class you wrote yourself? Because if so, you seem to do it backwards. Generally, you create a log file on disk or open a log file on disk, and then you pass it the information to put into the log.



[You've dealt with this]
It looks like your problem is here:

ser.MiseAJourFacture(
if (ser.MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT).Equals(-1))

You have an icomplete statement. I don't know what the ser.MiseAJourFacture is there for, but it's saying that the if is an invalid expression with regards to that because you didn't finish that statement.

If it's a method call that does some work to ser, then it could stand-alone, but it may not need to be there. if it does, try changing it to:
ser.MiseAJourFacture();
if (ser.MiseAjourEtatFacture(REF_COMPTE_FACTURATION,STATUT).Equals(-1))
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900