123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- 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
- {
- /// <summary>
- /// Логика взаимодействия для TestInfoBikes.xaml
- /// </summary>
- 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)
- {
- }
- }
- }
|