protected void Page_Load(object sender, EventArgs e) { if ((Session["Reservation"] == null) || (Session["Customer"] == null)) Response.Redirect("Default.aspx"); if (!IsPostBack) { Reservation = (Table_HotelReservation)Session["Reservation"]; paymethods = dbc.GetAllPayMethod(); } }
protected void Button_BookNow_Click(object sender, EventArgs e) { DateTimeFormatInfo dtFormat = new DateTimeFormatInfo(); dtFormat.ShortDatePattern = "yyyy/MM/dd"; Table_HotelReservation reservation = new Table_HotelReservation(); reservation.Id = -1; reservation.CheckIn = Convert.ToDateTime(CheckIn, dtFormat); reservation.CheckOut = Convert.ToDateTime(CheckOut, dtFormat); reservation.HotelId = hotel.Id; reservation.RoomNum = RoomNum; reservation.RoomType = GridView1.SelectedRow.Cells[0].Text; reservation.GuestNum = GuestNum; reservation.Status = 0; reservation.Value = dbc.GetRoomByHotelIdAndRoomType(reservation.HotelId, reservation.RoomType).FullRate * reservation.RoomNum * (reservation.CheckOut - reservation.CheckIn).Days; //订单的用户将在下一个页面确定 Session["Reservation"] = null; Session["Reservation"] = reservation; Response.Redirect("ConfirmOrder.aspx?hotelId=" + Request["hotelId"] + "&Address=" + Request["Address"] + "&CheckIn=" + Request["CheckIn"] + "&CheckOut=" + Request["CheckOut"] + "&RoomNum=" + Request["RoomNum"] + "&GuestNum=" + Request["GuestNum"]); }
partial void DeleteTable_HotelReservation(Table_HotelReservation instance);
partial void UpdateTable_HotelReservation(Table_HotelReservation instance);
partial void InsertTable_HotelReservation(Table_HotelReservation instance);
private void detach_Table_HotelReservation(Table_HotelReservation entity) { this.SendPropertyChanging(); entity.Table_Customer = null; }
private void attach_Table_HotelReservation(Table_HotelReservation entity) { this.SendPropertyChanging(); entity.Table_Room = this; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { reservation = (Table_HotelReservation)Session["Reservation"]; if (reservation.Id != -1) { TextBox1.Text = reservation.name.Substring(0, reservation.name.IndexOf(".", 0)); TextBox2.Text = reservation.name.Substring(reservation.name.IndexOf(".", 0) + 1, reservation.name.Length - reservation.name.IndexOf(".", 0) - 1); TextBox3.Text = reservation.PhoneNum.ToString(); TextBox5.Text = reservation.EmailAddress; if (reservation.sex == "male") DropDownList1.SelectedIndex = 0; else DropDownList1.SelectedIndex = 1; } //如果用户已经登陆则textbox1-5依次填入用户信息。 else if (Session["Customer"] != null) { Table_Customer customer = dbc.GetCustomer(Session["Customer"].ToString()); TextBox1.Text = customer.FirstName; TextBox2.Text = customer.LastName; TextBox3.Text = customer.PhoneNumber; TextBox5.Text = customer.EmailAddress; if (customer.Sex == "male") DropDownList1.SelectedIndex = 0; else DropDownList1.SelectedIndex = 1; TextBox1.Enabled = TextBox2.Enabled = TextBox3.Enabled = TextBox5.Enabled = false; DropDownList1.Enabled = false; } //如果用户没有登陆,则textbook1-5为空 //加载右边订单信息 hotel = dbc.GetHotelById(reservation.HotelId); room = dbc.GetRoomByHotelIdAndRoomType(reservation.HotelId, reservation.RoomType); TimeSpan t=reservation.CheckOut-reservation.CheckIn; // Label10.Text = "$" + room.FullRate.ToString(); Label1.Text = t.Days.ToString(); Label2.Text = reservation.RoomNum.ToString(); Label3.Text = reservation.GuestNum.ToString(); Label4.Text = "$" + reservation.Value.ToString(); Label_cost.InnerText = "$" + reservation.Value.ToString(); Label5.Text = hotel.Name; Label6.Text = hotel.Address; Label7.Text = reservation.RoomType; Label8.Text = reservation.CheckIn.ToString("yyyy/MM/dd"); Label9.Text = reservation.CheckOut.ToString("yyyy/MM/dd"); } }
//添加新酒店预订 public void AddHotelReservation(Table_HotelReservation hotelReservation) { data.Table_HotelReservation.InsertOnSubmit(hotelReservation); data.SubmitChanges(); }
//更新一个预订 public void UpdateHotelReservation(Table_HotelReservation hotelReservation) { var q = from s in data.Table_HotelReservation where s.Id == hotelReservation.Id select s; foreach (Table_HotelReservation c in q) { c.CheckIn = hotelReservation.CheckIn; c.CheckOut = hotelReservation.CheckOut; c.Customer = hotelReservation.Customer; c.HotelId = hotelReservation.HotelId; c.RoomNum = hotelReservation.RoomNum; c.RoomType = hotelReservation.RoomType; c.Status = hotelReservation.Status; } data.SubmitChanges(); }