
Another problem concerns the display of the seat arrangement, as shown in the picture.
Check it out for yourself...
private void btnBook_Click(object sender, EventArgs e)
{
try{
int iSeatNo = 0;
iSeatNo = int.Parse(txtSeat.Text);
if (iSeatNo <= 10)
{
}
else
{
MessageBox.Show("Seat Number not valid");
txtSeat.Clear();
txtSeat.Focus();
}
if ((iSeatNo <= 5) && (iSeatNo > 0) && (radSmoke.Checked == true))
{
if (book[iSeatNo - 1] == false)
{
book[iSeatNo - 1] = true;
grpSmokingArea.Controls[iSeatNo-1].Text = "BOOKED";
grpSmokingArea.Controls[iSeatNo-1].ForeColor = Color.Red;
lblInfo.Text = "You have booked Seat # " + iSeatNo + " \nin the
Smoking Area";
}
else
{
MessageBox.Show("Seat already taken");
}
}
else if (radSmoke.Checked== true)
{
MessageBox.Show("Seat allowed in non-smoking section only");
txtSeat.Clear();
txtSeat.Focus();
return;
}
/* Non Smoking */
if ((iSeatNo > 5) && (iSeatNo <= 10) && (radNoSmoke.Checked == true))
{
if (book[iSeatNo - 1] == false)
{
book[iSeatNo - 1] = true;
grpNonSmokingArea.Controls[iSeatNo - 6].Text = "BOOKED";
grpNonSmokingArea.Controls[iSeatNo - 6].ForeColor = Color.Red;
lblInfo.Text = "You have booked Seat # " + iSeatNo + " \nin the Non
Smoking Area";
}
else
{
MessageBox.Show("Seat already taken");
}
}
else if (radNoSmoke.Checked== true)
{
MessageBox.Show("Seat allowed in smoking section only");
txtSeat.Clear();
txtSeat.Focus();
return;
}
}
catch
{
MessageBox.Show("Please enter correct Seat Number");
txtSeat.Text = "";
txtSeat.Focus();
}
}
No comments:
Post a Comment