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 { /// /// Логика взаимодействия для InfoBikes.xaml /// public partial class InfoBikes : Window { public InfoBikes() { 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 'Занятость',InfoAdm.Lname as 'Фамилия администратора' from Bikes,Zanyatost, InfoAdm where Bikes.IDZan = Zanyatost.ID and Bikes.IdAdm = InfoAdm.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(); } private void Button_Search(object sender, RoutedEventArgs e) { 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 'Занятость', InfoAdm.Lname as 'Фамилия администратора' from Bikes,Zanyatost where Bikes.IDZan = Zanyatost.ID and Bikes.IdAdm = InfoAdm.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 + "%' or Zanyatost.Zan like '%" + Search.Text + "%' or InfoAdm.Lname 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(); } 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 'Занятость',InfoAdm.Lname as 'Фамилия администратора' from Bikes,Zanyatost, InfoAdm where Bikes.IDZan = Zanyatost.ID and Bikes.IdAdm = InfoAdm.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(); } } private void Vixod(object sender, RoutedEventArgs e) { MainWindowProd MWA = new MainWindowProd(); MWA.Show(); Close(); } private void Insert(object sender, RoutedEventArgs e) { Changing_the_type CTT = new Changing_the_type(); CTT.Show(); Close(); } } }