protected void btnOrder_Click(object sender, EventArgs e)
        {
            Order order = new Order();
            order.OrderHotelRoomTypes = new List<OrderHotelRoomType>();
            int sId = int.Parse(Request["sId"]);
            _input = _db.SearchInputs.Find(sId);
            order.StartDate = _input.DateCheckIn;
            order.EndDate = _input.DateCheckOut;
            order.Price = 0;
            order.OrderHotelRoomTypes = new List<OrderHotelRoomType>();
            if (lvRoomDetail.Items.Count > 0)
            {
                foreach (ListViewDataItem it in lvRoomDetail.Items)
                {
                    HiddenField hidRoomTypeId = it.FindControl("hidRoomTypeId") as HiddenField;
                    HotelRoomType htrt = _db.HotelRoomTypes.Find(int.Parse(hidRoomTypeId.Value));
                    DropDownList ddlRoomCount = it.FindControl("ddlRoomCount") as DropDownList;
                    if (int.Parse(ddlRoomCount.SelectedValue) > 0)
                    {
                        Literal litPrice = it.FindControl("litPrice") as Literal;
                        order.Price += int.Parse(ddlRoomCount.SelectedValue) * int.Parse(litPrice.Text.Replace(".",""));

                        OrderHotelRoomType type = new OrderHotelRoomType();
                        type.HotelRoomType = htrt;
                        type.NumOfRoom = int.Parse(ddlRoomCount.SelectedValue);
                        TextBox txtPeople = it.FindControl("txtPeople") as TextBox;
                        int num;
                        if (int.TryParse(txtPeople.Text,out num)&&num>0)
                        {
                            type.NumOfPeople = num;
                        }
                        else
                        {
                            litError.Text = "cần phải nhập số người cho các phòng được chọn !";
                            return;
                        }
                        order.OrderHotelRoomTypes.Add(type);
                    }
                }
            }
            if(order.Price==0)
            {
                litError.Text = "cần chọn ít nhất một phòng !";
                return;
            }
            OrderContact contact = new OrderContact();
            contact.Name = txtName.Text;
            contact.Phone = txtPhone.Text;
            contact.Adress = txtAdress.Text;
            contact.Email = txtEmail.Text;
            contact.BirthDay = order.StartDate;
            order.OrderContact = contact;
            order.OrderDate = DateTime.Now;
            order.State = OrderStateEnum.NEW;
            _db.Orders.Add(order);
            _db.SaveChanges();
            //Response.Redirect("http://google.com.vn");
        }
 protected void btnState_Click(object sender, EventArgs e)
 {
     try
     {
         int state = int.Parse(ddlState.SelectedValue);
         int orderId = int.Parse(Request["orderId"]);
         _order = _db.Orders.Find(orderId);
         _order.State = (OrderStateEnum)state;
         _db.SaveChanges();
         Notify.ShowMessageSuccess("Lưu trạng thái thành công !", Page);
     }
     catch
     {
         Notify.ShowMessageError("Đã xảy ra lỗi. Vui lòng thử lại !", Page);
     }
 }
        private void LoadData()
        {
            try
            {
                //kiem tra quyen
                Manager currentUser=  BackEndAuthentication.GetCurrentUserLogin(_db);
                 int orderId = int.Parse(Request["orderId"]);
                _order = _db.Orders.Find(orderId);
                if (currentUser.IsManagerOfHotel(_order.OrderHotelRoomTypes.First().HotelRoomType.Hotel) ||
                    currentUser.IsManagerOfHotel(_order.OrderHotelRoomTypes))
                {

                    litOrderId.Text = _order.Id.ToString();
                    litStartDate.Text = _order.StartDate.ToString("dd/MM/yyyy");
                    litEndDate.Text = _order.EndDate.ToString("dd/MM/yyyy");
                    litPrice.Text = _order.Price.ToString();
                    lblName.Text = _order.OrderContact.Name;
                    lblAdress.Text = _order.OrderContact.Adress;
                    lblPhone.Text = _order.OrderContact.Phone;
                    lblEmail.Text = _order.OrderContact.Email;
                    litOrderDate.Text = _order.OrderDate.ToString("dddd dd/MM/yyyy HH:mm",CultureInfo.GetCultureInfo("vi-Vn"));
                    Hotel hotel = _order.OrderHotelRoomTypes.First().HotelRoomType.Hotel;
                    litHotel.Text = hotel.Name + " - địa chỉ :" + hotel.Adress;
                    ddlState.SelectedValue = ((int)_order.State).ToString();

                    dtgOrderRoom.DataSource = _order.OrderHotelRoomTypes.ToList();
                    dtgOrderRoom.DataBind();
                    DataGridHelper.SetStyle(dtgOrderRoom);
                }
                else
                {
                    Notify.ShowMessageErrorFromAnotherPage("Bạn không có quyền xem đơn hàng này !");
                    Response.Redirect("ManagerBooking.aspx");
                }
            }
            catch { }
        }