diff --git a/Plattform/Plattform/Default.aspx b/Plattform/Plattform/Default.aspx index d8045eb..4c23ec0 100644 --- a/Plattform/Plattform/Default.aspx +++ b/Plattform/Plattform/Default.aspx @@ -8,19 +8,35 @@
-
RoomType
- +
RoomType +
+ +
+ + +
Add a room type

Hotel
- + +
+ + +
Add a hotel

-

Availability

+

Availability +

+ +
From
To
diff --git a/Plattform/Plattform/Default.aspx.cs b/Plattform/Plattform/Default.aspx.cs index d8edf21..b4d70d0 100644 --- a/Plattform/Plattform/Default.aspx.cs +++ b/Plattform/Plattform/Default.aspx.cs @@ -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,15 +57,39 @@ namespace Plattform } protected void ButtonAddRoom_Click(object sender, EventArgs e) { + LabelHotel.Text = ""; + LabelRoomType.Text = ""; + LabelAvailability.Text = ""; RoomDB roomDB = new RoomDB(); - Room room = new Room + if ((CalendarFrom.SelectedDate.Date == DateTime.MinValue.Date + | CalendarTo.SelectedDate.Date == DateTime.MinValue.Date)) { - Hotel = this.Hotels.Single(h => h.HotelID == int.Parse(DropDownHotel.SelectedValue)), - RoomType = this.RoomTypes.Single(t => t.RoomTypeID == int.Parse(DropDownRoomType.SelectedValue)), - FreeFrom = CalendarFrom.SelectedDate, - FreeUntil = CalendarTo.SelectedDate - }; - roomDB.CreateRoom(room); + 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)), + RoomType = this.RoomTypes.Single(t => t.RoomTypeID == int.Parse(DropDownRoomType.SelectedValue)), + FreeFrom = CalendarFrom.SelectedDate, + FreeUntil = CalendarTo.SelectedDate + }; + roomDB.CreateRoom(room); + DropDownHotel.ClearSelection(); + DropDownRoomType.ClearSelection(); + CalendarFrom.SelectedDates.Clear(); + CalendarTo.SelectedDates.Clear(); + } } } } diff --git a/Plattform/Plattform/Default.aspx.designer.cs b/Plattform/Plattform/Default.aspx.designer.cs index d0b83a1..5d34318 100644 --- a/Plattform/Plattform/Default.aspx.designer.cs +++ b/Plattform/Plattform/Default.aspx.designer.cs @@ -21,6 +21,15 @@ namespace Plattform { /// protected global::System.Web.UI.HtmlControls.HtmlForm form1; + /// + /// LabelRoomType control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelRoomType; + /// /// DropDownRoomType control. /// @@ -30,6 +39,15 @@ namespace Plattform { /// protected global::System.Web.UI.WebControls.DropDownList DropDownRoomType; + /// + /// LabelHotel control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelHotel; + /// /// DropDownHotel control. /// @@ -39,6 +57,15 @@ namespace Plattform { /// protected global::System.Web.UI.WebControls.DropDownList DropDownHotel; + /// + /// LabelAvailability control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelAvailability; + /// /// CalendarFrom control. /// diff --git a/Plattform/Plattform/FormHotel.aspx b/Plattform/Plattform/FormHotel.aspx index a1bb51f..b0a566f 100644 --- a/Plattform/Plattform/FormHotel.aspx +++ b/Plattform/Plattform/FormHotel.aspx @@ -11,10 +11,16 @@

Home

Add a new hotel

Name
+ +
Zip Code
+ +
City
+ +


diff --git a/Plattform/Plattform/FormHotel.aspx.cs b/Plattform/Plattform/FormHotel.aspx.cs index 82a49c5..e6ecfe2 100644 --- a/Plattform/Plattform/FormHotel.aspx.cs +++ b/Plattform/Plattform/FormHotel.aspx.cs @@ -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) @@ -34,17 +36,43 @@ namespace Plattform protected void ButtonAddHotel_Click(object sender, EventArgs e) { - HotelDB hotelDB = new HotelDB(); - Hotel hotel = new Hotel + LabelName.Text = ""; + LabelZipCode.Text = ""; + LabelCityName.Text = ""; + + if (TextBoxHotelName.Text == "") { - Name = TextBoxHotelName.Text, - City = new City + 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 { - ZipCode = int.Parse(TextBoxZipCode.Text), - Name = TextBoxCityName.Text - } - }; - hotelDB.CreateHotel(hotel); + Name = TextBoxHotelName.Text, + City = new City + { + ZipCode = int.Parse(TextBoxZipCode.Text), + Name = TextBoxCityName.Text + } + }; + hotelDB.CreateHotel(hotel); + TextBoxHotelName.Text = string.Empty; + TextBoxZipCode.Text = string.Empty; + TextBoxCityName.Text = string.Empty; + } } } -} \ No newline at end of file +} diff --git a/Plattform/Plattform/FormHotel.aspx.designer.cs b/Plattform/Plattform/FormHotel.aspx.designer.cs index 8d2a880..d7bf5ef 100644 --- a/Plattform/Plattform/FormHotel.aspx.designer.cs +++ b/Plattform/Plattform/FormHotel.aspx.designer.cs @@ -21,6 +21,15 @@ namespace Plattform { /// protected global::System.Web.UI.HtmlControls.HtmlForm form1; + /// + /// LabelName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelName; + /// /// TextBoxHotelName control. /// @@ -30,6 +39,15 @@ namespace Plattform { /// protected global::System.Web.UI.WebControls.TextBox TextBoxHotelName; + /// + /// LabelZipCode control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelZipCode; + /// /// TextBoxZipCode control. /// @@ -39,6 +57,15 @@ namespace Plattform { /// protected global::System.Web.UI.WebControls.TextBox TextBoxZipCode; + /// + /// LabelCityName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelCityName; + /// /// TextBoxCityName control. /// diff --git a/Plattform/Plattform/FormRoomType.aspx b/Plattform/Plattform/FormRoomType.aspx index 025a153..6282f54 100644 --- a/Plattform/Plattform/FormRoomType.aspx +++ b/Plattform/Plattform/FormRoomType.aspx @@ -11,10 +11,16 @@

Home

Add a new room type

Name
+ +
Capacity
+ +
Intentory
+ +


diff --git a/Plattform/Plattform/FormRoomType.aspx.cs b/Plattform/Plattform/FormRoomType.aspx.cs index 9225016..89c4724 100644 --- a/Plattform/Plattform/FormRoomType.aspx.cs +++ b/Plattform/Plattform/FormRoomType.aspx.cs @@ -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; + } } } -} \ No newline at end of file +} diff --git a/Plattform/Plattform/FormRoomType.aspx.designer.cs b/Plattform/Plattform/FormRoomType.aspx.designer.cs index 3281893..76e8a4f 100644 --- a/Plattform/Plattform/FormRoomType.aspx.designer.cs +++ b/Plattform/Plattform/FormRoomType.aspx.designer.cs @@ -21,6 +21,15 @@ namespace Plattform { /// protected global::System.Web.UI.HtmlControls.HtmlForm form1; + /// + /// LabelName control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelName; + /// /// TextBoxRoomType control. /// @@ -30,6 +39,15 @@ namespace Plattform { /// protected global::System.Web.UI.WebControls.TextBox TextBoxRoomType; + /// + /// LabelCapacity control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelCapacity; + /// /// TextBoxCapacity control. /// @@ -39,6 +57,15 @@ namespace Plattform { /// protected global::System.Web.UI.WebControls.TextBox TextBoxCapacity; + /// + /// LabelInventory control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label LabelInventory; + /// /// TextBoxInventory control. ///