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 KursachMukha692gr { /// /// Логика взаимодействия для SpisokUchenikov.xaml /// public partial class SpisokUchenikov : Window { public SpisokUchenikov() { InitializeComponent(); SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_mkm;"); connection.Open(); string cmd = "select infouchenik.id as 'Код',familiya as 'Фамилия', imya as 'Имя', otchestvo as 'Отчество' , dataUchenik as 'Дата рождения',disciplina.disciplina as 'Дисциплина', gruppa.gruppa as 'Номер группы',pol.pol_name as 'Пол', telephonenumUchenik as 'Номер телефона' from infouchenik,disciplina,gruppa,pol " + "where disciplina.id = infouchenik.fk_disciplina_id and gruppa.id = infouchenik.fk_gruppa_id and pol.id = infouchenik.fk_pol_id"; SqlCommand createcommand = new SqlCommand(cmd, connection); createcommand.ExecuteNonQuery(); SqlDataAdapter sql = new SqlDataAdapter(createcommand); DataTable dt = new DataTable("ucheniki"); sql.Fill(dt); uchenikigrid.ItemsSource = dt.DefaultView; connection.Close(); } private void Button_Click_add(object sender, RoutedEventArgs e) { AddUchenik uchenik = new AddUchenik(); uchenik.Show(); Close(); } private void Button_Click_delete(object sender, RoutedEventArgs e) { DeleteSpisokUchenikov spisokUchenikov = new DeleteSpisokUchenikov(); spisokUchenikov.Show(); Close(); } private void Button_Click_Back(object sender, RoutedEventArgs e) { KabinetAdmina kabinet = new KabinetAdmina(); kabinet.Show(); Close(); } private void Button_Click_update(object sender, RoutedEventArgs e) { ViborUchenikUpdate uchenikUpdate = new ViborUchenikUpdate(); uchenikUpdate.Show(); Close(); } private void Button_Click_Search(object sender, RoutedEventArgs e) { if (search.Text.Length > 0) { SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_mkm;"); connection.Open(); string cmd = "select infouchenik.id as 'Код',familiya as 'Фамилия', imya as 'Имя', otchestvo as 'Отчество' , dataUchenik as 'Дата рождения',disciplina.disciplina as 'Дисциплина', gruppa.gruppa as 'Номер группы',pol.pol_name as 'Пол', telephonenumUchenik as 'Номер телефона' from infouchenik,disciplina,gruppa,pol " + "where disciplina.id = infouchenik.fk_disciplina_id and gruppa.id = infouchenik.fk_gruppa_id and pol.id = infouchenik.fk_pol_id and (infouchenik.id like '%" + search.Text + "%' or familiya like '%" + search.Text + "%' or otchestvo like '%" + search.Text + "%' or dataUchenik like '%" + search.Text + "%' or disciplina.disciplina like '%" + search.Text + "%' or gruppa.gruppa like '%" + search.Text + "%' or pol.pol_name like '%" + search.Text + "%' or telephonenumUchenik like '%" + search.Text + "%')"; SqlCommand createcommand = new SqlCommand(cmd, connection); createcommand.ExecuteNonQuery(); SqlDataAdapter sql = new SqlDataAdapter(createcommand); DataTable dt = new DataTable("sorevi"); sql.Fill(dt); uchenikigrid.ItemsSource = dt.DefaultView; connection.Close(); } else if (search.Text.Length == 0) { SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_mkm;"); connection.Open(); string cmd = "select infouchenik.id as 'Код',familiya as 'Фамилия', imya as 'Имя', otchestvo as 'Отчество' , dataUchenik as 'Дата рождения',disciplina.disciplina as 'Дисциплина', gruppa.gruppa as 'Номер группы',pol.pol_name as 'Пол', telephonenumUchenik as 'Номер телефона' from infouchenik,disciplina,gruppa,pol " + "where disciplina.id = infouchenik.fk_disciplina_id and gruppa.id = infouchenik.fk_gruppa_id and pol.id = infouchenik.fk_pol_id"; SqlCommand createcommand = new SqlCommand(cmd, connection); createcommand.ExecuteNonQuery(); SqlDataAdapter sql = new SqlDataAdapter(createcommand); DataTable dt = new DataTable("sorevi"); sql.Fill(dt); uchenikigrid.ItemsSource = dt.DefaultView; connection.Close(); } } private void search_TextChanged(object sender, TextChangedEventArgs e) { } } }