using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace veloprokat2 { /// /// Логика взаимодействия для TestInfoBikes.xaml /// public partial class TestInfoBikes : Window { public TestInfoBikes() { InitializeComponent(); SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_kaa;"); connection.Open(); string cmd = "Select Bikes.ID as '№ велосипеда', Bikes.Company as 'Компания', Bikes.Title as 'Название',Bikes.[Type] as 'Тип',Zanyatost.Zan as 'Занятость' from Bikes,Zanyatost where Bikes.IDZan = Zanyatost.ID"; SqlCommand createcommand = new SqlCommand(cmd, connection); createcommand.ExecuteNonQuery(); SqlDataAdapter sql = new SqlDataAdapter(createcommand); DataTable dt = new DataTable("Bikes"); sql.Fill(dt); prodinfo.ItemsSource = dt.DefaultView; connection.Close(); } public bool SearchTest (string search) { Search.Text = search; if (Search.Text.Length > 0) { SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_kaa;"); connection.Open(); string cmd = "Select Bikes.ID as '№ велосипеда', Bikes.Company as 'Компания', Bikes.Title as 'Название',Bikes.[Type] as 'Тип',Zanyatost.Zan as 'Занятость' from Bikes,Zanyatost where Bikes.IDZan = Zanyatost.ID" + " and ( Bikes.ID like '%" + Search.Text + "%' or Bikes.Company like '%" + Search.Text + "%' or Bikes.[Type] like '%" + Search.Text + "%' or Bikes.Title like '%" + Search.Text + "%')"; SqlCommand createcommand = new SqlCommand(cmd, connection); createcommand.ExecuteNonQuery(); SqlDataAdapter sql = new SqlDataAdapter(createcommand); DataTable dt = new DataTable("SpisProk"); sql.Fill(dt); prodinfo.ItemsSource = dt.DefaultView; connection.Close(); if (dt.Rows.Count > 0) { MessageBox.Show("Тест вывода пройден"); return true; } else { return false; } } else if (Search.Text.Length == 0) { SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_kaa;"); connection.Open(); string cmd = "Select Bikes.ID as '№ велосипеда', Bikes.Company as 'Компания', Bikes.Title as 'Название',Bikes.[Type] as 'Тип',Zanyatost.Zan as 'Занятость' from Bikes,Zanyatost where Bikes.IDZan = Zanyatost.ID"; SqlCommand createcommand = new SqlCommand(cmd, connection); createcommand.ExecuteNonQuery(); SqlDataAdapter sql = new SqlDataAdapter(createcommand); DataTable dt = new DataTable("SpisProk"); sql.Fill(dt); prodinfo.ItemsSource = dt.DefaultView; connection.Close(); return false; } return false; } public bool TestVivod () { SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_kaa;"); connection.Open(); string cmd = "Select Bikes.ID as '№ велосипеда', Bikes.Company as 'Компания', Bikes.Title as 'Название',Bikes.[Type] as 'Тип',Zanyatost.Zan as 'Занятость' from Bikes,Zanyatost where Bikes.IDZan = Zanyatost.ID" + " and ( Bikes.ID like '%" + Search.Text + "%' or Bikes.Company like '%" + Search.Text + "%' or Bikes.[Type] like '%" + Search.Text + "%' or Bikes.Title like '%" + Search.Text + "%')"; SqlCommand createcommand = new SqlCommand(cmd, connection); createcommand.ExecuteNonQuery(); SqlDataAdapter sql = new SqlDataAdapter(createcommand); DataTable dt = new DataTable("SpisProk"); sql.Fill(dt); prodinfo.ItemsSource = dt.DefaultView; connection.Close(); if (dt.Rows.Count > 0) { return true; } else { return false; } } private void Button_Search(object sender, RoutedEventArgs e) { } private void Vixod(object sender, RoutedEventArgs e) { } private void Insert(object sender, RoutedEventArgs e) { } } }