1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- 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>
- /// Логика взаимодействия для SpisokProk.xaml
- /// </summary>
- public partial class SpisokProk : Window
- {
- public SpisokProk()
- {
- InitializeComponent();
- SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_kaa;");
- connection.Open();
- string cmd = "select SpisProk.ID as '№', Bikes.Title as 'Название велосипеда', Bikes.[Type] as 'Тип велосипеда', Tarif.NameOfTarif as 'Название тарифа', cast(Tarif.Price as int) as 'Цена', FORMAT(SpisProk.Date, 'dd/MM/yyyy') as 'Дата', FORMAT(Time, N'hh\\:mm') as 'Время', [Count] as 'Количество', SpisProk.Lname as 'Фамилия', InfoRab.Lname as 'Фамилия сотрудника' from SpisProk, Bikes, Tarif, InfoRab " +
- "where SpisProk.ID_Bikes = Bikes.ID and SpisProk.ID_tarif = Tarif.ID and SpisProk.IdRab = InfoRab.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 MWP = new MainWindowProd();
- MWP.Show();
- 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 SpisProk.ID as '№', Bikes.Title as 'Название велосипеда', Bikes.[Type] as 'Тип велосипеда', Tarif.NameOfTarif as 'Название тарифа', cast(Tarif.Price as int) as 'Цена', FORMAT(SpisProk.Date, 'dd/MM/yyyy') as 'Дата', FORMAT(Time, N'hh\\:mm') as 'Время', [Count] as 'Количество', SpisProk.Lname as 'Фамилия', InfoRab.Lname as 'Фамилия сотрудника' from SpisProk, Bikes, Tarif, InfoRab where SpisProk.ID_Bikes = Bikes.ID and SpisProk.ID_tarif = Tarif.ID and SpisProk.IdRab = InfoRab.ID" +
- " and ( SpisProk.ID like '%" + Search.Text + "%' or Bikes.Title like '%" + Search.Text + "%' or Bikes.[Type] like '%" + Search.Text + "%' or Tarif.NameOfTarif like '%" + Search.Text + "%' or cast(Tarif.Price as int) like '%" + Search.Text + "%' or FORMAT(SpisProk.Date, 'dd/MM/yyyy') like '%" + Search.Text + "%' or FORMAT(Time, N'hh\\:mm') like '%" + Search.Text + "%' or[Count] like '%" + Search.Text + "%' or SpisProk.Lname like '%" + Search.Text + "%' or InfoRab.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 SpisProk.ID as '№', Bikes.Title as 'Название велосипеда', Bikes.[Type] as 'Тип велосипеда', Tarif.NameOfTarif as 'Название тарифа', cast(Tarif.Price as int) as 'Цена', FORMAT(SpisProk.Date, 'dd/MM/yyyy') as 'Дата', FORMAT(Time, N'hh\\:mm') as 'Время', [Count] as 'Количество', SpisProk.Lname as 'Фамилия', InfoRab.Lname as 'Фамилия сотрудника' from SpisProk, Bikes, Tarif, InfoRab " +
- "where SpisProk.ID_Bikes = Bikes.ID and SpisProk.ID_tarif = Tarif.ID and SpisProk.IdRab = InfoRab.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();
- }
- }
- }
- }
|