فهرست منبع

Авторизация сделана

Almir Myxametszanov 1 سال پیش
والد
کامیت
7d10261401
3فایلهای تغییر یافته به همراه24 افزوده شده و 6 حذف شده
  1. 1 1
      ROGOZ/App.config
  2. 4 0
      ROGOZ/App.xaml.cs
  3. 19 5
      ROGOZ/Pages/Authorization.xaml.cs

+ 1 - 1
ROGOZ/App.config

@@ -8,7 +8,7 @@
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
   </startup>
   <connectionStrings>
-    <add name="user1Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=VPMT.RU\IS4;initial catalog=user1;user id=user1;password = ScladniyParol;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
+    <add name="user1Entities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SRV-WSR\IS4;initial catalog=user1;user id=user1;password = ScladniyParol;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
   </connectionStrings>
   <entityFramework>
     <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">

+ 4 - 0
ROGOZ/App.xaml.cs

@@ -13,5 +13,9 @@ namespace ROGOZ
     /// </summary>
     public partial class App : Application
     {
+        public static user1Entities Context
+        { get; } = new user1Entities();
+
+        public static User CurentUser = null;
     }
 }

+ 19 - 5
ROGOZ/Pages/Authorization.xaml.cs

@@ -27,19 +27,33 @@ namespace ROGOZ.Pages
 
         private void BtnLogin_Click(object sender, RoutedEventArgs e)
         {
-            if (TBoxLogin.Text != "" && PBoxPassword.Password != "") 
+            //var curentUser = user1Entities.GetContext().User.FirstOrDefault(p => p.Login == TBoxLogin.Text && p.Password == PBoxPassword.Password);
+            var curentUser = App.Context.User.FirstOrDefault(p => p.Login == TBoxLogin.Text && p.Password == PBoxPassword.Password);
+
+            if (curentUser != null)
             {
-                //MessageBox.Show("Заходи", "хихихи", MessageBoxButton.OK, MessageBoxImage.Asterisk);
-                
+                App.CurentUser = curentUser;
                 MainWindow mainWindow = new MainWindow();
                 mainWindow.Show();
                 this.Close();
             }
-
             else
             {
-                MessageBox.Show("ДА.", "Капец", MessageBoxButton.OK, MessageBoxImage.Error);
+                MessageBox.Show("Пользователь с такими данными не найден.", "Ошибка", MessageBoxButton.OK, MessageBoxImage.Warning);
             }
+            //if (TBoxLogin.Text != "" && PBoxPassword.Password != "") 
+            //{
+            //    //MessageBox.Show("Заходи", "хихихи", MessageBoxButton.OK, MessageBoxImage.Asterisk);
+
+            //    MainWindow mainWindow = new MainWindow();
+            //    mainWindow.Show();
+            //    this.Close();
+            //}
+
+            //else
+            //{
+            //    MessageBox.Show("ДА.", "Капец", MessageBoxButton.OK, MessageBoxImage.Error);
+            //}
         }
 
         private void PBoxPassword_PasswordChanged(object sender, RoutedEventArgs e)