Exemplo n.º 1
0
    protected void btnBook_Click(object sender, EventArgs e)
    {
        try
        {
            int    rowindex = 0;
            Button chk      = (Button)sender;

            GridViewRow Grow = (GridViewRow)chk.NamingContainer;

            rowindex = Grow.RowIndex;



            int rcatid  = 0;
            int rtypeid = 0;

            HiddenField  hdnctid   = (HiddenField)Grow.FindControl("hfrctId");
            HiddenField  hfntpid   = (HiddenField)Grow.FindControl("hfrtype");
            DropDownList ddlConv   = (DropDownList)Grow.FindControl("ddlConvert");
            DropDownList ddlGuests = (DropDownList)Grow.FindControl("ddlGuests");


            Int32.TryParse(hdnctid.Value.ToString(), out rcatid);
            Int32.TryParse(hfntpid.Value.ToString(), out rtypeid);

            ViewState["rcatid"]  = rcatid;
            ViewState["rtypeid"] = rtypeid;



            int al  = gdvSelectedRooms.Rows.Count + 1;
            int pax = 0;
            Int32.TryParse(ddlGuests.SelectedItem.Text, out pax);
            Returndt         = new DataTable();
            Returndt         = ViewState["Rrate"] as DataTable;
            lblCurrency.Text = Returndt.Rows[0]["Currency"].ToString();
            Int32.TryParse(ViewState["rcatid"].ToString(), out roomCatId);
            Int32.TryParse(ViewState["rtypeid"].ToString(), out roomtypeid);
            // Int32.TryParse(pax, out irpax);
            dv = new DataView();
            dv = new DataView(Returndt, "RoomCategoryId='" + roomCatId + "' and RoomTypeId='" + roomtypeid + "'", "RoomCategoryId,RoomTypeId", DataViewRowState.CurrentRows);
            if (pax > 0 && gdvSelectedRooms.Rows.Count < Convert.ToInt32(dv.ToTable().Rows[0]["rcount"]))
            {
                if (Session["UserCode"] != null)
                {
                    DateTime.TryParse(Session["HCheckin"].ToString(), out chkin);
                    Int32.TryParse(Session["AcId"].ToString(), out iAccomId);
                    blsr.accomId      = iAccomId;
                    blsr._iAgentId    = Convert.ToInt32(Session["UserCode"].ToString());
                    blsr.action       = "getmaxroomsHotel";
                    blsr._dtStartDate = chkin;

                    Returndt = new DataTable();
                    Returndt = dlsr.getMaxRoomsBookable(blsr);
                    if (Returndt != null)
                    {
                        if (gdvSelectedRooms.Rows.Count < Convert.ToInt32(Returndt.Rows[0][0]))
                        {
                            addrows(dv, roomCatId, pax, ddlConv.SelectedIndex.ToString());
                            CalculateRoomRates();
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "QuoteFull", "javascript:alert('You cannot book any more rooms. Please contact our reservations office to make additional bookings.')", true);
                        }
                    }
                }
                else
                {
                    addrows(dv, roomCatId, pax, ddlConv.SelectedIndex.ToString());
                    CalculateRoomRates();
                }
            }

            if (gdvSelectedRooms.Rows.Count > 0)
            {
                DivRmRate.Style.Remove("display");
            }
            else
            {
                DivRmRate.Style.Add("display", "None");
            }
        }
        catch
        {
        }
    }