Esempio n. 1
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtSearch.Text.Length < 3 || txtSearch.Text.Equals(""))
            {
                MessageBox.Show("Invalid search", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            DataRow[] foundRecord;
            authorsTable.DefaultView.Sort = "Author";
            foundRecord = authorsTable.Select("Author LIKE '*" + txtSearch.Text + "*'");

            if (foundRecord.Length == 0)
            {
                MessageBox.Show("Nothing was found", "Nothing", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                frmSearch searchForm = new frmSearch(foundRecord, "Authors");
                searchForm.ShowDialog();
                var index = searchForm.Index;
                authorsManager.Position = authorsTable.DefaultView.Find(foundRecord[index]["Author"]);
            }
        }
        private void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtSearch.Text.Equals("") || txtSearch.Text.Length < 3)
            {
                MessageBox.Show("Invalid Search", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DataRow[] foundRows;
            pubTable.DefaultView.Sort = "Name";
            foundRows = pubTable.Select("Name LIKE '*" + txtSearch.Text + "*'");

            if (foundRows.Length == 0)
            {
                MessageBox.Show("No Record Found", "No Record Found", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                frmSearch searchForm = new frmSearch(foundRows, "Publishers");
                searchForm.ShowDialog();
                var index = searchForm.Index;
                pubManager.Position = pubTable.DefaultView.Find(foundRows[index]["Name"]);
            }
        }