Click here to Skip to main content
15,907,233 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, can someone see why this piece of code doesnt work? I know its something todo with the if statement but I am not sure what it looks ok to me!

private void button1_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Board visit submitted. Would you like to enter another Visit?","Board Visit",MessageBoxButton.YesNo,MessageBoxImage.Question,MessageBoxResult.No);
            if (MessageBoxResult.No.Equals(true))
            {
                Visit_Class visit = new Visit_Class(file,date);
                visit.connectionOpen();
                visit.setEnvVisit(Convert.ToString(envDate.Text),Convert.ToString(envBoard.Text),Convert.ToString(envDesc.Text),Convert.ToInt16(envScore.Value));
                visit.setHSVisit(Convert.ToString(hsDate.Text), Convert.ToString(hsBoard.Text), Convert.ToString(hsDesc.Text), Convert.ToInt16(hsScore.Value));
                visit.connectionClose();
                MessageBox.Show("Your Triangle is Complete!","Triangle Complete!",MessageBoxButton.OK);
                this.Close();
            }
            else if (MessageBoxResult.No.Equals(false))
            {
                Visit_Class visit = new Visit_Class(file, date);
                visit.connectionOpen();
                visit.setEnvVisit(Convert.ToString(envDate.Text), Convert.ToString(envBoard.Text), Convert.ToString(envDesc.Text), Convert.ToInt16(envScore.Value));
                visit.setHSVisit(Convert.ToString(hsDate.Text), Convert.ToString(hsBoard.Text), Convert.ToString(hsDesc.Text), Convert.ToInt16(hsScore.Value));
                visit.connectionClose();
            }
        }


Thanks in advance

Dan
Posted
Comments
DanHodgson88 26-Jul-11 10:41am    
sorry about the editing, looks shocking when i copied and pasted it in
thatraja 26-Jul-11 10:49am    
No, it looks fine with proper title, tag, code-block, etc., keep it that way always.
DanHodgson88 26-Jul-11 10:51am    
yeh just the code block's a bit messy lol I like my code to look nice to!

1 solution

Look at this[^]:

C#
var result = MessageBox.Show("Board visit submitted. Would you like to enter another Visit?","Board Visit",MessageBoxButton.YesNo,MessageBoxImage.Question,MessageBoxResult.No);
// If the no button was pressed ...
if (result == DialogResult.No)
{
}
else if(result == DialogResult.Yes)
{
}
 
Share this answer
 
Comments
DanHodgson88 26-Jul-11 10:45am    
spot on mate thats great thank you!
Manas Bhardwaj 26-Jul-11 10:49am    
your welcome!

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