[C#] If-else

โค้ด

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void btRoom_Click(object sender, EventArgs e)
        {
            string strOut = "";
            DialogResult resp;
            resp = MessageBox.Show("Are you pleased about our room ?", "Room", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            
            if (resp == DialogResult.Yes)
            {
                strOut = "Thank You!, Hope to see you next time.";
                MessageBox.Show(strOut, "Pim Resort", 
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                strOut = "Sorry!, We will improve next time.";
                MessageBox.Show(strOut, "Pim Resort", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        private void btService_Click(object sender, EventArgs e)
        {
            if (txtService.Text == "")
            {
                MessageBox.Show("You have no recommendation about our service.", "Pim Resort");
            }
            else
            {
                MessageBox.Show("Thank you for your opinion.", "Pim Resort", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
    }
}
Previous
Next Post »