protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    using (QCAstServiceClient serviceClient = new QCAstServiceClient())
                    {
                        int  idUser = int.Parse(Session["IdUser"].ToString());
                        User user   = serviceClient.GetUserFromId(idUser);

                        if (user.IdProfile != 4 & user.IdProfile != 2)
                        {
                            Response.Redirect("ErrorPage.aspx?Error=NotAuthorised", false);
                        }
                        else
                        {
                            ddlProfiles.DataSource = serviceClient.GetAllProfiles();
                            ddlProfiles.DataBind();
                            ddlClient.DataSource = serviceClient.GetAllClients("All", "");
                            ddlClient.DataBind();
                            lbSearchedUsers.DataSource = serviceClient.GetAllUsers("All", "");
                            lbSearchedUsers.DataBind();
                            ddlProfiles.Items.Insert(0, new ListItem("Please select..", "0"));
                            ddlClient.Items.Insert(0, new ListItem("Please select..", ""));
                            trButtons.Visible    = false;
                            ibDeleteUser.Enabled = false;
                            ibEditUser.Enabled   = false;
                        }
                    }
                }
                catch (Exception ex)
                {
                    NotifyWebmasterOfError("Billing", "User Management", ex.ToString());
                    Response.Redirect("ErrorPage.aspx?Error=GeneralError", true);
                }
            }
        }
        protected void btnSearch_Click(object sender, ImageClickEventArgs e)
        {
            string searchTerm = tbSearch.Text;

            ClearTextAndListBoxes();

            if (searchTerm == "" & rblSearchFormat.SelectedValue != "All")
            {
                lblSearchError.Text = "Please enter a search term";
            }
            else
            {
                try
                {
                    using (QCAstServiceClient client = new QCAstServiceClient())
                    {
                        lblSearchError.Text = "";
                        List <User> users = client.GetAllUsers(rblSearchFormat.SelectedValue, searchTerm);

                        if (users == null)
                        {
                            lblSearchError.Text = "No results found";
                        }
                        else
                        {
                            lbSearchedUsers.DataSource = users;
                            lbSearchedUsers.DataBind();
                        }
                    }
                }
                catch (Exception ex)
                {
                    NotifyWebmasterOfError("Billing", "User Management Search", ex.ToString());
                    lblSearchError.Text = "Error experienced";
                }
            }
        }