Beispiel #1
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            string EmployeeName = txtName.Text.ToString();

            if (EmployeeName != "" && ddlDepart.SelectedValue == "")
            {
                DataTable dt   = ContactInfo.EmployeeIdOfName(EmployeeName);
                DataView  view = dt.DefaultView;
                string    sort = (string)ViewState["SortExpression"] + " " + (string)ViewState["SortDir"];
                view.Sort = sort;

                if (dt.Rows.Count == 0)
                {
                    dt.Rows.Add(dt.NewRow());
                    UI.BindCtrl(view, gvContact, AspNetPager1);
                    gvContact.Rows[0].Visible = false;
                }
                else
                {
                    UI.BindCtrl(view, gvContact, AspNetPager1);
                }
            }
            else if (ddlDepart.SelectedValue != "" && EmployeeName == "")
            {
                int       departid = Convert.ToInt32(ddlDepart.SelectedValue);
                DataTable dt       = ContactInfo.ContactOfDepart(departid);
                DataView  view     = dt.DefaultView;
                string    sort     = (string)ViewState["SortExpression"] + " " + (string)ViewState["SortDir"];
                view.Sort = sort;

                if (dt.Rows.Count == 0)
                {
                    dt.Rows.Add(dt.NewRow());
                    UI.BindCtrl(view, gvContact, AspNetPager1);
                    gvContact.Rows[0].Visible = false;
                }
                else
                {
                    UI.BindCtrl(view, gvContact, AspNetPager1);
                }
            }
            else if (ddlDepart.SelectedValue != "" && EmployeeName != "")
            {
                string    EmployeeN = txtName.Text.ToString();
                int       deid      = Convert.ToInt32(ddlDepart.SelectedValue);
                DataTable dt        = ContactInfo.ContactOfBoth(deid, EmployeeN);
                DataView  view      = dt.DefaultView;
                string    sort      = (string)ViewState["SortExpression"] + " " + (string)ViewState["SortDir"];
                view.Sort = sort;

                if (dt.Rows.Count == 0)
                {
                    dt.Rows.Add(dt.NewRow());
                    UI.BindCtrl(view, gvContact, AspNetPager1);
                    gvContact.Rows[0].Visible = false;
                }
                else
                {
                    UI.BindCtrl(view, gvContact, AspNetPager1);
                }
            }
            else
            {
                gvDataBind();
            }
        }