Example #1
0
        private void btnsearch_Click(object sender, EventArgs e)
        {
            BindingSource source = new BindingSource();

            if (txtname.Text == "" && cmbsearchbydep.Text != "")
            {
                server.Service1 server = new server.Service1();
                server.SearchByDepartment(cmbsearchbydep.Text);

                source.DataSource      = server.SearchByDepartment(cmbsearchbydep.Text);
                dgv.DataSource         = source;
                dgv.Columns[0].Visible = false;
                dgv.Columns[1].Visible = false;
            }
            else if (cmbsearchbydep.Text == "" && txtname.Text != "")
            {
                server.Service1 server = new server.Service1();
                server.SearchByname(txtname.Text);

                source.DataSource      = server.SearchByname(txtname.Text);
                dgv.DataSource         = source;
                dgv.Columns[0].Visible = false;
                dgv.Columns[1].Visible = false;
            }
            else if (cmbsearchbydep.Text != "" && txtname.Text != "")
            {
                MessageBox.Show("Please fill only one box");
            }
            else
            {
                MessageBox.Show("Please Select the parameter for Searching");
            }
        }