|
@@ -24,9 +24,11 @@ namespace KursachMukha692gr
|
|
|
public Tournments()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
- SqlConnection connection = new SqlConnection("server=WIN-2CL665KE0ED; Trusted_Connection=YES;DataBase=KURSACH1;");
|
|
|
+ SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_mkm;");
|
|
|
connection.Open();
|
|
|
- string cmd = "select id,name_tournment as 'Название турнира', mesto_provedeniya as 'Место проведения', fk_disciplina_id as 'id дисциплины',fk_gruppa_id as 'Номер группы, принимающей участие', fk_infotrener_id as 'id тренера' from sorevnovaniya";
|
|
|
+ string cmd = "select sorevnovaniya.id as 'Код',name_tournment as 'Название турнира', mesto_provedeniya as 'Место проведения', disciplina.disciplina as 'Дисциплина',gruppa.gruppa as 'Номер группы, принимающей участие'," +
|
|
|
+ "CONCAT(infotrener.familiyaTrener, ' ', left(infotrener.imyaTrener, 1), '.', left(infotrener.otchestvoTrener, 1), '.') as 'ФИО тренера' from sorevnovaniya, disciplina, gruppa, infotrener " +
|
|
|
+ "where disciplina.id = sorevnovaniya.fk_disciplina_id and gruppa.id = sorevnovaniya.fk_gruppa_id and infotrener.id = sorevnovaniya.fk_infotrener_id";
|
|
|
SqlCommand createcommand = new SqlCommand(cmd, connection);
|
|
|
createcommand.ExecuteNonQuery();
|
|
|
SqlDataAdapter sql = new SqlDataAdapter(createcommand);
|
|
@@ -66,27 +68,14 @@ namespace KursachMukha692gr
|
|
|
|
|
|
private void Button_Click_Search(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
- /*ViborSearchTournment searchTournment = new ViborSearchTournment();
|
|
|
- searchTournment.Show();
|
|
|
- Close();*/
|
|
|
- /*SqlConnection connection = new SqlConnection("server=WIN-2CL665KE0ED; Trusted_Connection=YES;DataBase=KURSACH1;");
|
|
|
- connection.Open();
|
|
|
- string cmd = "select id,name_tournment as 'Название турнира', mesto_provedeniya as 'Место проведения', fk_disciplina_id as 'id дисциплины',fk_gruppa_id as 'Номер группы, принимающей участие', fk_infotrener_id as 'id тренера' from sorevnovaniya";
|
|
|
- SqlCommand createcommand = new SqlCommand(cmd, connection);
|
|
|
- SqlDataAdapter sql = new SqlDataAdapter(createcommand);
|
|
|
- DataTable dt = new DataTable("sorevi");
|
|
|
- if(dt.Rows.Count > 0)
|
|
|
- {
|
|
|
- dt.DefaultView.RowFilter = string.Format("id like '%{0}%'", search.Text);
|
|
|
- sorevigrid.ItemsSource = dt.DefaultView;
|
|
|
- }
|
|
|
- */
|
|
|
if(search.Text.Length > 0)
|
|
|
{
|
|
|
- SqlConnection connection = new SqlConnection("server=WIN-2CL665KE0ED; Trusted_Connection=YES;DataBase=KURSACH1;");
|
|
|
+ SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_mkm;");
|
|
|
connection.Open();
|
|
|
- string cmd = "select id,name_tournment as 'Название турнира', mesto_provedeniya as 'Место проведения', fk_disciplina_id as 'id дисциплины',fk_gruppa_id as 'Номер группы, принимающей участие', fk_infotrener_id as 'id тренера' from sorevnovaniya where id like '%" + search.Text + "%' or mesto_provedeniya like '%" + search.Text + "%'" +
|
|
|
- " or fk_disciplina_id like '%" + search.Text + "%' or fk_gruppa_id like '%" + search.Text + "%' or fk_infotrener_id like '%" + search.Text + "%'";
|
|
|
+ string cmd = "select sorevnovaniya.id as 'Код',name_tournment as 'Название турнира', mesto_provedeniya as 'Место проведения', disciplina.disciplina as 'Дисциплина',gruppa.gruppa as 'Номер группы, принимающей участие'," +
|
|
|
+ "CONCAT(infotrener.familiyaTrener, ' ', left(infotrener.imyaTrener, 1), '.', left(infotrener.otchestvoTrener, 1), '.') as 'ФИО тренера' from sorevnovaniya, disciplina, gruppa, infotrener " +
|
|
|
+ "where disciplina.id = sorevnovaniya.fk_disciplina_id and gruppa.id = sorevnovaniya.fk_gruppa_id and infotrener.id = sorevnovaniya.fk_infotrener_id" +
|
|
|
+ " and (sorevnovaniya.id like '%" + search.Text + "%' or mesto_provedeniya like '%" + search.Text + "%' or disciplina.disciplina like '%" + search.Text + "%' or gruppa.gruppa like '%" + search.Text + "%' or CONCAT(infotrener.familiyaTrener,' ',left(infotrener.imyaTrener,1) ,'.',left(infotrener.otchestvoTrener,1),'.') like '%" + search.Text + "%')";
|
|
|
SqlCommand createcommand = new SqlCommand(cmd, connection);
|
|
|
createcommand.ExecuteNonQuery();
|
|
|
SqlDataAdapter sql = new SqlDataAdapter(createcommand);
|
|
@@ -97,9 +86,11 @@ namespace KursachMukha692gr
|
|
|
}
|
|
|
else if (search.Text.Length == 0)
|
|
|
{
|
|
|
- SqlConnection connection = new SqlConnection("server=WIN-2CL665KE0ED; Trusted_Connection=YES;DataBase=KURSACH1;");
|
|
|
+ SqlConnection connection = new SqlConnection("server=mssql; Trusted_Connection=YES;DataBase=gr692_mkm;");
|
|
|
connection.Open();
|
|
|
- string cmd = "select id,name_tournment as 'Название турнира', mesto_provedeniya as 'Место проведения', fk_disciplina_id as 'id дисциплины',fk_gruppa_id as 'Номер группы, принимающей участие', fk_infotrener_id as 'id тренера' from sorevnovaniya";
|
|
|
+ string cmd = "select sorevnovaniya.id as 'Код',name_tournment as 'Название турнира', mesto_provedeniya as 'Место проведения', disciplina.disciplina as 'Дисциплина',gruppa.gruppa as 'Номер группы, принимающей участие'," +
|
|
|
+ "CONCAT(infotrener.familiyaTrener, ' ', left(infotrener.imyaTrener, 1), '.', left(infotrener.otchestvoTrener, 1), '.') as 'ФИО тренера' from sorevnovaniya, disciplina, gruppa, infotrener " +
|
|
|
+ "where disciplina.id = sorevnovaniya.fk_disciplina_id and gruppa.id = sorevnovaniya.fk_gruppa_id and infotrener.id = sorevnovaniya.fk_infotrener_id";
|
|
|
SqlCommand createcommand = new SqlCommand(cmd, connection);
|
|
|
createcommand.ExecuteNonQuery();
|
|
|
SqlDataAdapter sql = new SqlDataAdapter(createcommand);
|