| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 | 
							- using System;
 
- using System.Collections.Generic;
 
- 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.Navigation;
 
- using System.Windows.Shapes;
 
- using System.Data.SqlClient;
 
- using System.Data;
 
- namespace BorisProject
 
- {
 
-     /// <summary>
 
-     /// Логика взаимодействия для MainWindow.xaml
 
-     /// </summary>
 
-     public partial class MainWindow : Window
 
-     {
 
-         public MainWindow()
 
-         {
 
-             InitializeComponent();
 
-         }
 
-         SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=boris;Integrated Security=True");
 
-         TrenerWindow trenerwindow = new TrenerWindow();
 
-         //Авторизация
 
-         private void Vhod_Click(object sender, RoutedEventArgs e)
 
-         {
 
-             if (logintxt.Text == "" || passwordpsw.Password == "")
 
-             {
 
-                 MessageBox.Show("Ошибка! Пустые поля!");
 
-             }
 
-             else if (logintxt.Text =="1")
 
-             {
 
-                 TrenerWindow trenerWindow = new TrenerWindow();
 
-                 this.Close();
 
-                 trenerWindow.Show();
 
-             }
 
-             else if (logintxt.Text == "admin" && passwordpsw.Password=="admin")
 
-             {
 
-                 WindowAdmin admin = new WindowAdmin();
 
-                 this.Close();
 
-                 admin.Show();
 
-             }
 
-             else
 
-             {
 
-                 try
 
-                 {
 
-                     con.Open();
 
-                     SqlCommand cmd = new SqlCommand("Select * from Trener where Login ='" + logintxt.Text + "'  and Password ='" + passwordpsw.Password + "'", con);
 
-                     cmd.CommandType = CommandType.Text;
 
-                     SqlDataAdapter adapter = new SqlDataAdapter();
 
-                     adapter.SelectCommand = cmd;
 
-                     DataSet dataSet = new DataSet();
 
-                     adapter.Fill(dataSet);
 
-                     if (dataSet.Tables[0].Rows.Count > 0)
 
-                     {
 
-                         MessageBox.Show("Добро пожаловать!");
 
-                         string username = dataSet.Tables[0].Rows[0]["ID_trener"].ToString();
 
-                         trenerwindow.txtidtrener.Text = username;
 
-                         trenerwindow.Show();
 
-                         this.Close();
 
-                     }
 
-                     else
 
-                     {
 
-                         con.Close();
 
-                         MessageBox.Show("Такого пользователь нет!");
 
-                     }
 
-                 }
 
-                 catch
 
-                 {
 
-                     con.Close();
 
-                     MessageBox.Show("Ошибка");
 
-                 }
 
-             }
 
-         }
 
-         private void Exit_Click(object sender, RoutedEventArgs e)
 
-         {
 
-             Application.Current.Shutdown();
 
-         }
 
-         //Тест
 
-         public bool Auth(string login, string password)
 
-         {
 
-             SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=boris;Integrated Security=True");
 
-             con.Open();
 
-             SqlCommand cmd = new SqlCommand("Select * from Trener where Login ='" + login.ToString() + "'  and Password ='" + password.ToString() + "'", con);
 
-             cmd.CommandType = CommandType.Text;
 
-             SqlDataAdapter adapter = new SqlDataAdapter();
 
-             adapter.SelectCommand = cmd;
 
-             DataSet dataSet = new DataSet();
 
-             adapter.Fill(dataSet);
 
-             if (dataSet.Tables[0].Rows.Count > 0)
 
-             {
 
-                 con.Close();
 
-                 MessageBox.Show("Вы авторизованы");
 
-                 return true;
 
-             }
 
-             else
 
-             {
 
-                 con.Close();
 
-                 MessageBox.Show("Ошибка логина/пароля");
 
-                 return false;
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |