add error handling to the websites
This commit is contained in:
parent
49914d3cd8
commit
eebc20215d
|
@ -8,19 +8,35 @@
|
|||
</head>
|
||||
<body>
|
||||
<form id="form1" runat="server">
|
||||
<h5>RoomType</h5>
|
||||
<asp:DropDownList ID="DropDownRoomType" runat="server" OnSelectedIndexChanged="DropDownRoomType_SelectedIndexChanged"></asp:DropDownList>
|
||||
<h5>RoomType
|
||||
</h5>
|
||||
<asp:Label ID="LabelRoomType" runat="server" Text=""></asp:Label>
|
||||
<br />
|
||||
<asp:DropDownList ID="DropDownRoomType" runat="server"
|
||||
OnSelectedIndexChanged="DropDownRoomType_SelectedIndexChanged"
|
||||
AppendDataBoundItems="true">
|
||||
<asp:ListItem Text="-- Choose one --" Value=""/>
|
||||
</asp:DropDownList>
|
||||
<br />
|
||||
<a href="FormRoomType.aspx">Add a room type</a>
|
||||
<br />
|
||||
<br />
|
||||
<h5>Hotel</h5>
|
||||
<asp:DropDownList ID="DropDownHotel" runat="server" OnSelectedIndexChanged="DropDownHotel_SelectedIndexChanged"></asp:DropDownList>
|
||||
<asp:Label ID="LabelHotel" runat="server" Text=""></asp:Label>
|
||||
<br />
|
||||
<asp:DropDownList ID="DropDownHotel" runat="server"
|
||||
OnSelectedIndexChanged="DropDownHotel_SelectedIndexChanged"
|
||||
AppendDataBoundItems="true">
|
||||
<asp:ListItem Text="-- Choose one --" Value=""/>
|
||||
</asp:DropDownList>
|
||||
<br />
|
||||
<a href="FormHotel.aspx">Add a hotel</a>
|
||||
<br />
|
||||
<br />
|
||||
<h3>Availability</h3>
|
||||
<h3>Availability
|
||||
</h3>
|
||||
<asp:Label ID="LabelAvailability" runat="server" Text=""></asp:Label>
|
||||
<br />
|
||||
<h5>From</h5>
|
||||
<asp:Calendar ID="CalendarFrom" runat="server" OnSelectionChanged="CalendarFrom_SelectionChanged"></asp:Calendar>
|
||||
<h5>To</h5>
|
||||
|
|
|
@ -30,6 +30,10 @@ namespace Plattform
|
|||
DropDownRoomType.DataTextField = "Name";
|
||||
DropDownRoomType.DataValueField = "RoomTypeID";
|
||||
DropDownRoomType.DataBind();
|
||||
|
||||
LabelHotel.ForeColor = System.Drawing.Color.Red;
|
||||
LabelRoomType.ForeColor = System.Drawing.Color.Red;
|
||||
LabelAvailability.ForeColor = System.Drawing.Color.Red;
|
||||
}
|
||||
|
||||
protected void DropDownRoomType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
|
@ -53,7 +57,26 @@ namespace Plattform
|
|||
}
|
||||
protected void ButtonAddRoom_Click(object sender, EventArgs e)
|
||||
{
|
||||
LabelHotel.Text = "";
|
||||
LabelRoomType.Text = "";
|
||||
LabelAvailability.Text = "";
|
||||
RoomDB roomDB = new RoomDB();
|
||||
if ((CalendarFrom.SelectedDate.Date == DateTime.MinValue.Date
|
||||
| CalendarTo.SelectedDate.Date == DateTime.MinValue.Date))
|
||||
{
|
||||
LabelAvailability.Text = "Please select a From and Until date.";
|
||||
}
|
||||
if (DropDownHotel.SelectedValue == "")
|
||||
{
|
||||
LabelHotel.Text = "Please selet a hotel.";
|
||||
}
|
||||
if(DropDownRoomType.SelectedValue == "")
|
||||
{
|
||||
LabelRoomType.Text = "Please select a room type.";
|
||||
}
|
||||
if (LabelHotel.Text == "" && LabelRoomType.Text == ""
|
||||
&& LabelAvailability.Text == "")
|
||||
{
|
||||
Room room = new Room
|
||||
{
|
||||
Hotel = this.Hotels.Single(h => h.HotelID == int.Parse(DropDownHotel.SelectedValue)),
|
||||
|
@ -62,6 +85,11 @@ namespace Plattform
|
|||
FreeUntil = CalendarTo.SelectedDate
|
||||
};
|
||||
roomDB.CreateRoom(room);
|
||||
DropDownHotel.ClearSelection();
|
||||
DropDownRoomType.ClearSelection();
|
||||
CalendarFrom.SelectedDates.Clear();
|
||||
CalendarTo.SelectedDates.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,15 @@ namespace Plattform {
|
|||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||
|
||||
/// <summary>
|
||||
/// LabelRoomType control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelRoomType;
|
||||
|
||||
/// <summary>
|
||||
/// DropDownRoomType control.
|
||||
/// </summary>
|
||||
|
@ -30,6 +39,15 @@ namespace Plattform {
|
|||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList DropDownRoomType;
|
||||
|
||||
/// <summary>
|
||||
/// LabelHotel control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelHotel;
|
||||
|
||||
/// <summary>
|
||||
/// DropDownHotel control.
|
||||
/// </summary>
|
||||
|
@ -39,6 +57,15 @@ namespace Plattform {
|
|||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList DropDownHotel;
|
||||
|
||||
/// <summary>
|
||||
/// LabelAvailability control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelAvailability;
|
||||
|
||||
/// <summary>
|
||||
/// CalendarFrom control.
|
||||
/// </summary>
|
||||
|
|
|
@ -11,10 +11,16 @@
|
|||
<p><a href="Default.aspx">Home</a></p>
|
||||
<h1>Add a new hotel</h1>
|
||||
<h5>Name</h5>
|
||||
<asp:Label ID="LabelName" runat="server" Text=""></asp:Label>
|
||||
<br />
|
||||
<asp:TextBox ID="TextBoxHotelName" runat="server" OnTextChanged="TextBoxHotelName_TextChanged"></asp:TextBox>
|
||||
<h5>Zip Code</h5>
|
||||
<asp:Label ID="LabelZipCode" runat="server" Text=""></asp:Label>
|
||||
<br />
|
||||
<asp:TextBox ID="TextBoxZipCode" type="number" runat="server" OnTextChanged="TextBoxZipCode_TextChanged"></asp:TextBox>
|
||||
<h5>City</h5>
|
||||
<asp:Label ID="LabelCityName" runat="server" Text=""></asp:Label>
|
||||
<br />
|
||||
<asp:TextBox ID="TextBoxCityName" runat="server" OnTextChanged="TextBoxCityName_TextChanged"></asp:TextBox>
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
@ -14,7 +14,9 @@ namespace Plattform
|
|||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
LabelName.ForeColor = System.Drawing.Color.Red;
|
||||
LabelZipCode.ForeColor = System.Drawing.Color.Red;
|
||||
LabelCityName.ForeColor = System.Drawing.Color.Red;
|
||||
}
|
||||
|
||||
protected void TextBoxHotelName_TextChanged(object sender, EventArgs e)
|
||||
|
@ -33,6 +35,28 @@ namespace Plattform
|
|||
}
|
||||
|
||||
protected void ButtonAddHotel_Click(object sender, EventArgs e)
|
||||
{
|
||||
LabelName.Text = "";
|
||||
LabelZipCode.Text = "";
|
||||
LabelCityName.Text = "";
|
||||
|
||||
if (TextBoxHotelName.Text == "")
|
||||
{
|
||||
LabelName.Text = "Please enter a hotel name.";
|
||||
}
|
||||
|
||||
if (TextBoxZipCode.Text == "")
|
||||
{
|
||||
LabelZipCode.Text = "Please enter a ZIP code.";
|
||||
}
|
||||
|
||||
if (TextBoxCityName.Text == "")
|
||||
{
|
||||
LabelCityName.Text = "Please enter a city name";
|
||||
}
|
||||
|
||||
if (LabelName.Text == "" && LabelZipCode.Text == ""
|
||||
&& LabelCityName.Text == "")
|
||||
{
|
||||
HotelDB hotelDB = new HotelDB();
|
||||
Hotel hotel = new Hotel
|
||||
|
@ -45,6 +69,10 @@ namespace Plattform
|
|||
}
|
||||
};
|
||||
hotelDB.CreateHotel(hotel);
|
||||
TextBoxHotelName.Text = string.Empty;
|
||||
TextBoxZipCode.Text = string.Empty;
|
||||
TextBoxCityName.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,15 @@ namespace Plattform {
|
|||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||
|
||||
/// <summary>
|
||||
/// LabelName control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelName;
|
||||
|
||||
/// <summary>
|
||||
/// TextBoxHotelName control.
|
||||
/// </summary>
|
||||
|
@ -30,6 +39,15 @@ namespace Plattform {
|
|||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox TextBoxHotelName;
|
||||
|
||||
/// <summary>
|
||||
/// LabelZipCode control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelZipCode;
|
||||
|
||||
/// <summary>
|
||||
/// TextBoxZipCode control.
|
||||
/// </summary>
|
||||
|
@ -39,6 +57,15 @@ namespace Plattform {
|
|||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox TextBoxZipCode;
|
||||
|
||||
/// <summary>
|
||||
/// LabelCityName control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelCityName;
|
||||
|
||||
/// <summary>
|
||||
/// TextBoxCityName control.
|
||||
/// </summary>
|
||||
|
|
|
@ -11,10 +11,16 @@
|
|||
<p><a href="Default.aspx">Home</a></p>
|
||||
<h1>Add a new room type</h1>
|
||||
<h5>Name</h5>
|
||||
<asp:Label ID="LabelName" runat="server" Text=""></asp:Label>
|
||||
<br />
|
||||
<asp:TextBox ID="TextBoxRoomType" runat="server" OnTextChanged="TextBoxRoomType_TextChanged"></asp:TextBox>
|
||||
<h5>Capacity</h5>
|
||||
<asp:Label ID="LabelCapacity" runat="server" Text=""></asp:Label>
|
||||
<br />
|
||||
<asp:TextBox ID="TextBoxCapacity" type="number" runat="server" OnTextChanged="TextBoxCapacity_TextChanged"></asp:TextBox>
|
||||
<h5>Intentory</h5>
|
||||
<asp:Label ID="LabelInventory" runat="server" Text=""></asp:Label>
|
||||
<br />
|
||||
<asp:TextBox ID="TextBoxInventory" runat="server" OnTextChanged="TextBoxInventory_TextChanged"></asp:TextBox>
|
||||
<br />
|
||||
<br />
|
||||
|
|
|
@ -4,6 +4,8 @@ using System.Linq;
|
|||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Plattform.DB;
|
||||
using Plattform.Models;
|
||||
|
||||
namespace Plattform
|
||||
{
|
||||
|
@ -11,7 +13,9 @@ namespace Plattform
|
|||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
LabelName.ForeColor = System.Drawing.Color.Red;
|
||||
LabelCapacity.ForeColor = System.Drawing.Color.Red;
|
||||
LabelInventory.ForeColor = System.Drawing.Color.Red;
|
||||
}
|
||||
|
||||
protected void TextBoxRoomType_TextChanged(object sender, EventArgs e)
|
||||
|
@ -31,7 +35,38 @@ namespace Plattform
|
|||
|
||||
protected void ButtonAddRoomType_Click(object sender, EventArgs e)
|
||||
{
|
||||
LabelName.Text = "";
|
||||
LabelCapacity.Text = "";
|
||||
LabelInventory.Text = "";
|
||||
|
||||
if (TextBoxRoomType.Text == "")
|
||||
{
|
||||
LabelName.Text = "Please enter a name.";
|
||||
}
|
||||
if (TextBoxCapacity.Text == "")
|
||||
{
|
||||
LabelCapacity.Text = "Please enter capacity.";
|
||||
}
|
||||
if (TextBoxInventory.Text == "")
|
||||
{
|
||||
LabelInventory.Text = "Please describe the inventory.";
|
||||
}
|
||||
|
||||
if (LabelName.Text == "" && LabelCapacity.Text == ""
|
||||
&& LabelInventory.Text == "")
|
||||
{
|
||||
RoomTypeDB roomTypeDB = new RoomTypeDB();
|
||||
RoomType roomType = new RoomType
|
||||
{
|
||||
Name = TextBoxRoomType.Text,
|
||||
Capacity = int.Parse(TextBoxCapacity.Text),
|
||||
Inventory = TextBoxInventory.Text
|
||||
};
|
||||
roomTypeDB.CreateRoomType(roomType);
|
||||
TextBoxRoomType.Text = string.Empty;
|
||||
TextBoxCapacity.Text = string.Empty;
|
||||
TextBoxInventory.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,6 +21,15 @@ namespace Plattform {
|
|||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlForm form1;
|
||||
|
||||
/// <summary>
|
||||
/// LabelName control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelName;
|
||||
|
||||
/// <summary>
|
||||
/// TextBoxRoomType control.
|
||||
/// </summary>
|
||||
|
@ -30,6 +39,15 @@ namespace Plattform {
|
|||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox TextBoxRoomType;
|
||||
|
||||
/// <summary>
|
||||
/// LabelCapacity control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelCapacity;
|
||||
|
||||
/// <summary>
|
||||
/// TextBoxCapacity control.
|
||||
/// </summary>
|
||||
|
@ -39,6 +57,15 @@ namespace Plattform {
|
|||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox TextBoxCapacity;
|
||||
|
||||
/// <summary>
|
||||
/// LabelInventory control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label LabelInventory;
|
||||
|
||||
/// <summary>
|
||||
/// TextBoxInventory control.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue