Bläddra i källkod

создал форму авторизации

andrey 3 år sedan
förälder
incheckning
70f5d083e0
4 ändrade filer med 96 tillägg och 1 borttagningar
  1. 1 1
      MainWindow.xaml
  2. 31 0
      Pages/AuthPage.xaml
  3. 57 0
      Pages/AuthPage.xaml.cs
  4. 7 0
      savelev_avtor.csproj

+ 1 - 1
MainWindow.xaml

@@ -29,7 +29,7 @@
             </Rectangle.RenderTransform>
         </Rectangle>
         <Button Content="Назад" HorizontalAlignment="Left" Margin="26,10,0,0" VerticalAlignment="Top" Width="75"/>
-        <Frame Content="MainFrame" HorizontalAlignment="Left" Height="215" Grid.Row="1" VerticalAlignment="Top" Width="245"/>
+        <Frame Content="MainFrame" Source="Pages/AuthPage.xaml" Grid.Row="1" Grid.Column="1"/>
 
     </Grid>
 </Window>

+ 31 - 0
Pages/AuthPage.xaml

@@ -0,0 +1,31 @@
+<Page x:Class="savelev_avtor.Pages.AuthPage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:savelev_avtor.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="Авторизация">
+
+    <Grid Background="#FFFDFDFD">
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="80*"/>
+            <ColumnDefinition Width="129*"/>
+            <ColumnDefinition Width="507*"/>
+            <ColumnDefinition Width="84*"/>
+        </Grid.ColumnDefinitions>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="25*"/>
+            <RowDefinition Height="344*"/>
+            <RowDefinition Height="81*"/>
+        </Grid.RowDefinitions>
+        <Label Content="Логин" Margin="10,53,0,0" Grid.Row="1" Grid.Column="1" HorizontalAlignment="Left" Width="109" Height="23" VerticalAlignment="Top"/>
+        <TextBox Name="TextBoxLogin" Grid.Column="2" HorizontalAlignment="Left" Height="23" Grid.Row="1" TextWrapping="Wrap"  VerticalAlignment="Top" Width="120" Margin="10,53,0,0"/>
+        <Label Content="Пароль" Grid.Column="1" Margin="10,82,0,0" Grid.Row="1" HorizontalAlignment="Left" Width="109" Height="23" VerticalAlignment="Top"/>
+        <Button Content="Вход" Grid.Column="2" HorizontalAlignment="Left" Margin="10,110,0,0" Grid.Row="1" VerticalAlignment="Top" Width="120" Height="20" Click="ButtonEnter_OnClick"/>
+        <Button Content="Регистрация" Grid.Column="2" HorizontalAlignment="Left" Margin="10,135,0,0" Grid.Row="1" VerticalAlignment="Top" Width="120" Height="20"/>
+        <PasswordBox Name="PasswordBox" Grid.Column="2" HorizontalAlignment="Left" Margin="10,82,0,0" Grid.Row="1" VerticalAlignment="Top" Width="120" Height="23"/>
+
+    </Grid>
+</Page>

+ 57 - 0
Pages/AuthPage.xaml.cs

@@ -0,0 +1,57 @@
+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;
+
+namespace savelev_avtor.Pages
+{
+    /// <summary>
+    /// Логика взаимодействия для AuthPage.xaml
+    /// </summary>
+    public partial class AuthPage : Page
+    {
+        public AuthPage()
+        {
+            InitializeComponent();
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void ButtonEnter_OnClick(object sender, RoutedEventArgs e)
+        {
+         if (string.IsNullOrEmpty(TextBoxLogin.Text)  || string.IsNullOrEmpty(PasswordBox.Password))
+            {
+                MessageBox.Show("Введите логин и пароль!");
+                return;
+            }
+            using (var db = new Entities())
+            {
+                Version user = db.User
+                      .AsNoTracing()
+                      .FirstOrDefault(u => u.Login == TextBox.TextProperty && u.Passowrd == PasswordBox.Password);
+
+                if (user == null)
+                {
+                    MessageBox.Show("Пользователь с такими данными не найден!");
+                    return;
+                }
+            }
+            
+
+          
+        }
+    }
+}

+ 7 - 0
savelev_avtor.csproj

@@ -71,8 +71,15 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Page Include="Pages\AuthPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Pages\AuthPage.xaml.cs">
+      <DependentUpon>AuthPage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Properties\AssemblyInfo.cs">
       <SubType>Code</SubType>
     </Compile>