oop_NFS_Andreas/Plattform/Plattform/Default.aspx.cs

68 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Plattform.Models;
using Plattform.DB;
using Plattform;
namespace Plattform
{
public partial class Default: System.Web.UI.Page
{
List<Hotel> Hotels { get; set; }
List<RoomType> RoomTypes { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
HotelDB hotelDB = new HotelDB();
RoomTypeDB roomTypeDB = new RoomTypeDB();
this.Hotels = hotelDB.GetAllHotels();
DropDownHotel.DataSource = Hotels;
DropDownHotel.DataTextField = "Name";
DropDownHotel.DataValueField = "HotelID";
DropDownHotel.DataBind();
RoomTypes = roomTypeDB.GetAllRoomTypes();
DropDownRoomType.DataSource = RoomTypes;
DropDownRoomType.DataTextField = "Name";
DropDownRoomType.DataValueField = "RoomTypeID";
DropDownRoomType.DataBind();
}
protected void DropDownRoomType_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void DropDownHotel_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void CalendarFrom_SelectionChanged(object sender, EventArgs e)
{
}
protected void CalendarTo_SelectionChanged(object sender, EventArgs e)
{
}
protected void ButtonAddRoom_Click(object sender, EventArgs e)
{
RoomDB roomDB = new RoomDB();
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);
}
}
}