Hi ,
I have written many statements like the one below before, however this one simply wont work, I always get the messagebox appearing even if the conditions are not met, btw i realise i can achieve this with the GUI but i prefer to use code.
It is attached to a sign button, whereby it simply checks if the person mentioned if the field matches the loggedonuser (which populated on form load), if so let them sign the field, if not then dont.
However two more people (DistributedTo & distributedfurther) may possibly need to sign the form also so this needs to be taken into account (hence the piped (||) conditonal values) notice i have tried both || and | and neither seem to work. There will only ever be 3 people who can sign this form, approver, distributed to and distributedfurther......yes i know they are terrible string names but thats neither here not there :D
thanks in advance, i will be suprosed if the code below formats correctly but i could not see a code insert tool.
public void Sign_Section1_Clicked(object sender, ClickedEventArgs e)
{
{
XPathNavigator Navigate = this.CreateNavigator();
string approver = Navigate.SelectSingleNode("/my:SpecReviewForm/my:Nominated/my:Person/my:AccountId", NamespaceManager).Value.ToString();string loggedinuser = Navigate.SelectSingleNode("/my:SpecReviewForm/my:loggedinuser", NamespaceManager).Value.ToString();
string DistributedTo = Navigate.SelectSingleNode("/my:SpecReviewForm/my:DistributedTo/my:Person/my:AccountId", NamespaceManager).Value.ToString();string signed = Navigate.SelectSingleNode("/my:SpecReviewForm/my:Section1/my:Signed", NamespaceManager).Value.ToString();string DistributedFurther = Navigate.SelectSingleNode("/my:SpecReviewForm/my:DistributeFurther/my:Person/my:AccountId", NamespaceManager).Value.ToString();
if (DistributedFurther == "" | DistributedTo == "" | approver != loggedinuser)
{
MessageBox.Show("You are not authorised to sign this form");return;
}
else
if ((approver != loggedinuser) | (DistributedTo != loggedinuser))
{
MessageBox.Show("You are not authorised to sign this form" + approver + loggedinuser + DistributedTo + DistributedFurther);return;
}
if (signed != "")
{
MessageBox.Show("You Cannot re-Sign this section");return;
}