using System; using PizzaService; using PizzaSystem; namespace PizzaPresentation { public partial class StudentStart : System.Web.UI.Page { private StudentService studentService; protected void Page_Load(object sender, EventArgs e) { // check if app has yet run, set up APIs if (Application["PizzaSys"] == null) { PizzaConfig pizzaService = new PizzaConfig(); Application["PizzaSys"] = pizzaService; } PizzaConfig pizzaSystem = (PizzaConfig)Application["PizzaSys"]; studentService = pizzaSystem.StudentService; if (!IsPostBack) // only set room no. text on page load, let user's value show later { if (Session["room"] != null) RoomNumTextBox.Text = (String)Session["room"]; else RoomNumTextBox.Text = ""; } } // Here if user typed in text box--treat as submit protected void RoomNumTextBox_TextChanged1(object sender, EventArgs e) { SubmitButton_OnClick(sender, e); } // if have submit button and text box, need to click back to same // page to be sure to get user input from the text box public void SubmitButton_OnClick(object sender, EventArgs e) { String numberStr = RoomNumTextBox.Text; try { int roomNum = Int32.Parse(numberStr); Session["room"] = numberStr; } catch (FormatException e1) { RoomNumTextBox.Text = "Decimal number here" + e1.Message; } // If got room, redirect to next page. if (Session["room"] != null) Response.Redirect("ChooseAction.aspx", false); } } }