예제 #1
0
    protected void btnSearchAgent_Click(object sender, EventArgs e)
    {
        // Currently available search fields.
        int genderId = getIntValue(cboGender.SelectedValue, -1);
        int cityId   = getIntValue(cboAgentCity.SelectedValue, -1);
        // Currently non-available search fields.
        int      employeeId = -1;
        string   firstName  = string.Empty;
        string   lastName   = string.Empty;
        DateTime birthDate  = default(DateTime);
        string   email      = string.Empty;
        string   phone      = string.Empty;
        double   salary     = -1;
        string   username   = string.Empty;

        // The positionId: parameter is set to (int)Position.Agent in order to filter for Agents only.
        EmployeeList agentList = new EmployeeList(employeeId, firstName, lastName, birthDate, email, genderId, phone, cityId,
                                                  (int)Position.Agent, salary, username);

        DataSet dsAgents = agentList.AsDataSet();

        if ((dsAgents != null) && (dsAgents.Tables[0].Rows.Count > 0))
        {
            GridResult.DataSource = dsAgents;
            GridResult.DataBind();

            LiteralResult.Text = "";
        }
        else
        {
            GridResult.DataSource = "";

            //Building an HTML string.
            StringBuilder html = new StringBuilder();

            string msgNoResult = "<div class=\"alert alert-info alert-dismissable\">";
            msgNoResult += "<a href=\"#\" class=\"close\" data-dismiss=\"alert\" aria-label=\"close\">&times;</a>";
            msgNoResult += "Sorry, no results for your search.</div>";

            html.Append(msgNoResult);

            LiteralResult.Text = html.ToString();
        }
    }