oop_NFS_Andreas/Plattform/Plattform/Default.aspx.cs

68 lines
2.0 KiB
C#
Raw Normal View History

2018-08-19 14:31:58 +02:00
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
{
2018-08-23 21:22:04 +02:00
public partial class Default: System.Web.UI.Page
2018-08-19 14:31:58 +02:00
{
2018-08-23 22:48:13 +02:00
List<Hotel> Hotels { get; set; }
List<RoomType> RoomTypes { get; set; }
2018-08-19 14:31:58 +02:00
protected void Page_Load(object sender, EventArgs e)
{
2018-08-23 22:48:13 +02:00
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();
2018-08-19 14:31:58 +02:00
}
2018-08-23 21:23:13 +02:00
protected void DropDownRoomType_SelectedIndexChanged(object sender, EventArgs e)
2018-08-19 14:31:58 +02:00
{
2018-08-23 21:23:13 +02:00
2018-08-19 14:31:58 +02:00
}
2018-08-23 21:23:13 +02:00
protected void DropDownHotel_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void CalendarFrom_SelectionChanged(object sender, EventArgs e)
{
}
protected void CalendarTo_SelectionChanged(object sender, EventArgs e)
{
}
2018-08-19 14:31:58 +02:00
protected void ButtonAddRoom_Click(object sender, EventArgs e)
{
2018-08-23 22:48:13 +02:00
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);
2018-08-19 14:31:58 +02:00
}
}
2018-08-23 22:48:13 +02:00
}