Ejemplo n.º 1
0
 private void searchTB_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(searchTB.Text) && table != "Data" && column != null)
     {
         string query;
         if (column != "ID")
         {
             query = "Select * from " + table + " Where " + column + " like N'%" + searchTB.Text + "%'";
         }
         else
         {
             query = "Select * from " + table + " Where " + column + " = " + searchTB.Text + " ";
         }
         DataBaseTools.open();
         SqlCommand cmd = new SqlCommand(query, DataBaseTools.conn);
         cmd.ExecuteNonQuery();
         SqlDataAdapter a = new SqlDataAdapter(cmd);
         DataTable      t = new DataTable();
         a.Fill(t);
         searchGrid.ItemsSource = t;
         DataBaseTools.close();
         matchesTB.Text = searchGrid.VisibleRowCount + "";
     }
     else
     {
         matchesTB.Text         = "";
         searchGrid.ItemsSource = null;
         searchGrid.Columns.Clear();
     }
 }
Ejemplo n.º 2
0
        private void searchBTN_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string searchFor = searchTB.Text;
            string query     = @"select b.Title ,d.pageid [Page Number] , d.text [Text] 
                                from books b inner join Data d 
                                on b.ID = d.BookID
                                where d.Text like N'%" + searchFor + @"%'
                                union 
                                select b.Title ,pd.pageid [Page Number] , 'Image : ' + pd.text [Text] 
                                from books b inner join PicturesData pd
                                on b.ID = pd.BookID
                                where pd.text like N'%" + searchFor + "%' order by b.Title";

            DataBaseTools.open();
            ExecuteAndFill(query);
        }