private bool checkRoomOccupency() { bool result = false; DropDownList ddlPropertyName = (DropDownList)Master.FindControl("ddlProperty"); string PropertyName = ddlPropertyName.SelectedItem.Text; string PropertyVale = ddlPropertyName.SelectedValue; SqlDataReader sdr2 = uc.CheckOccupency1(PropertyVale, ddlRoomNo.SelectedItem.Text); if (sdr2.HasRows) { sdr2.Read(); Session["r_BedsValue"] = Convert.ToInt32(sdr2["r_BedsValue"]); } sdr2.Close(); SqlDataReader sdr = uc.CheckOccupency(PropertyVale, ddlRoomNo.SelectedItem.Text); if (sdr.HasRows) { sdr.Read(); Int32 tenantsCount = Convert.ToInt32(sdr["countTen"]); int r_BedsValue = Convert.ToInt32(Session["r_BedsValue"]); Session["r_BedsValue"] = r_BedsValue.ToString(); if (r_BedsValue > tenantsCount) { result = true; } else { result = false; string text = "This " + ddlRoomNo.SelectedItem.Text + " olny " + r_BedsValue + " capacity so sorry this room already full "; ScriptManager.RegisterStartupScript(this, typeof(Page), "Warning", "<script>showpoperror('" + text + "')</script>", false); } sdr.Close(); } else { result = true; } return(result); }