user2 4 سال پیش
والد
کامیت
18251acebb

+ 5 - 1
Chekryshov_lessons/App.xaml

@@ -4,6 +4,10 @@
              xmlns:local="clr-namespace:Chekryshov_lessons"
              StartupUri="MainWindow.xaml">
     <Application.Resources>
-         
+        <ResourceDictionary>
+            <ResourceDictionary.MergedDictionaries>
+                <ResourceDictionary Source="Dictionary1.xaml"/>
+            </ResourceDictionary.MergedDictionaries>
+        </ResourceDictionary>
     </Application.Resources>
 </Application>

+ 22 - 6
Chekryshov_lessons/Chekryshov_lessons.csproj

@@ -55,20 +55,30 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
-    <Page Include="MainWindow.xaml">
-      <Generator>MSBuild:Compile</Generator>
+    <Page Include="Dictionary1.xaml">
       <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
     </Page>
     <Compile Include="App.xaml.cs">
       <DependentUpon>App.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
-    <Compile Include="MainWindow.xaml.cs">
-      <DependentUpon>MainWindow.xaml</DependentUpon>
-      <SubType>Code</SubType>
-    </Compile>
+    <Page Include="Page\AuthPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+    <Page Include="Page\MainWindow.xaml">
+      <Generator>MSBuild:Compile</Generator>
+      <SubType>Designer</SubType>
+    </Page>
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Page\AuthPage.xaml.cs">
+      <DependentUpon>AuthPage.xaml</DependentUpon>
+    </Compile>
+    <Compile Include="Page\MainWindow.xaml.cs">
+      <DependentUpon>MainWindow.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Properties\AssemblyInfo.cs">
       <SubType>Code</SubType>
     </Compile>
@@ -94,5 +104,11 @@
   <ItemGroup>
     <None Include="App.config" />
   </ItemGroup>
+  <ItemGroup>
+    <Page Include="Page\Page2.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 9 - 0
Chekryshov_lessons/Dictionary1.xaml

@@ -0,0 +1,9 @@
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+                    xmlns:local="clr-namespace:Chekryshov_lessons">
+    <Style TargetType="{x:Type Label}">
+        <Setter Property="Background" Value="AntiqueWhite"/>
+        <Setter Property="Padding" Value="0"/>
+    </Style>
+    
+</ResourceDictionary>

+ 0 - 12
Chekryshov_lessons/MainWindow.xaml

@@ -1,12 +0,0 @@
-<Window x:Class="Chekryshov_lessons.MainWindow"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:Chekryshov_lessons"
-        mc:Ignorable="d"
-        Title="MainWindow" Height="360" Width="800">
-    <Grid>
-        
-    </Grid>
-</Window>

+ 0 - 28
Chekryshov_lessons/MainWindow.xaml.cs

@@ -1,28 +0,0 @@
-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 Chekryshov_lessons
-{
-    /// <summary>
-    /// Логика взаимодействия для MainWindow.xaml
-    /// </summary>
-    public partial class MainWindow : Window
-    {
-        public MainWindow()
-        {
-            InitializeComponent();
-        }
-    }
-}

+ 32 - 0
Chekryshov_lessons/Page/AuthPage.xaml

@@ -0,0 +1,32 @@
+<Page x:Class="Chekryshov_lessons.Page.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:Chekryshov_lessons.Page"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="AuthPage">
+
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="*"/>
+            <ColumnDefinition Width="50"/>
+            <ColumnDefinition Width="170"/>
+            <ColumnDefinition Width="*"/>
+        </Grid.ColumnDefinitions>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="*"/>
+            <RowDefinition Height="105"/>
+            <RowDefinition Height="*"/>
+        </Grid.RowDefinitions>
+        <Label Content="Логин" Grid.Column="1" Grid.Row="1" VerticalAlignment="Top" Height="25"/>
+        <Label Content="Пароль" Grid.Column="1" Margin="0,30,0,0" Grid.Row="1" VerticalAlignment="Top" Height="25"/>
+        <TextBox x:Name="TextBoxLogin" Grid.Column="2" Height="25" Grid.Row="1" TextWrapping="Wrap" VerticalAlignment="Top"/>
+        <PasswordBox x:Name="PasswordBox" Grid.Column="2" Margin="0,30,0,0" Grid.Row="1" VerticalAlignment="Top"/>
+        <Button Click="ButtonEnter_OnClick" Content="Вход" Grid.Column="2" Margin="0,60,0,0" Grid.Row="1" VerticalAlignment="Top"/>
+        <Button Content="Регитрация " Grid.Column="2" Margin="0,85,0,0" Grid.Row="1" VerticalAlignment="Top"/>
+        
+
+    </Grid>
+</Page>

+ 58 - 0
Chekryshov_lessons/Page/AuthPage.xaml.cs

@@ -0,0 +1,58 @@
+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 Chekryshov_lessons.Page
+{
+    /// <summary>
+    /// Логика взаимодействия для AuthPage.xaml
+    /// </summary>
+    public partial class AuthPage : Page
+    {
+        public AuthPage()
+        {
+            InitializeComponent();
+        }
+        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())
+            {
+                var user = db.User
+                        .AsNoTracking()
+                        .FirstOrDeafult(u->u.login == TextBoxLogin.Text && u.Password == PasswordBox.Password);
+                if (user == null)
+                {
+                    MessageBox.Show("Пользователь с такими данными не найден");
+                    return;
+                }
+                MessageBox.Show("Пользователь успешно найден");
+                switch (user.Role)
+                {
+                    case "Заказчик":
+                        NavigationService? Navigate(new Menu());
+                        break;
+                    case "Директор":
+                        NavigationService? Navigate(new Menu());
+                        break;
+                }
+
+            }
+        }
+    } 
+}

+ 24 - 0
Chekryshov_lessons/Page/MainWindow.xaml

@@ -0,0 +1,24 @@
+<Window x:Class="Chekryshov_lessons.MainWindow"
+        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+        xmlns:local="clr-namespace:Chekryshov_lessons"
+        mc:Ignorable="d"
+        Title="MainWindow" Height="460" Width="800">
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="42"/>
+            <RowDefinition />
+            <RowDefinition Height="42"/>
+        </Grid.RowDefinitions>
+        <Grid.ColumnDefinitions>
+           
+            
+        </Grid.ColumnDefinitions>
+        <Rectangle Fill="#FFF4F4F5" StrokeThickness="0"/>
+        <Button Content="Назад" HorizontalAlignment="Left" Margin="10,10,0,10" x:Name="ButtonBack" Width="75"/>
+        <Frame x:Name="MainFrame" Content="Frame" Grid.Row="1" Navigated="MainFrame_OnNavigated" Source="Page/AuthPage.xaml"/>
+        
+    </Grid>
+</Window>

+ 67 - 0
Chekryshov_lessons/Page/MainWindow.xaml.cs

@@ -0,0 +1,67 @@
+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 Chekryshov_lessons
+{
+    /// <summary>
+    /// Логика взаимодействия для MainWindow.xaml
+    /// </summary>
+    public partial class MainWindow : Window
+    {
+        public MainWindow()
+        {
+            InitializeComponent();
+        }
+
+        private void MainFrame_OnNavigated(object sender, NavigationEventArgs e)
+        {
+            if (!(e.Content is Page page)) return;
+            this.Title = $"LESSON - {page.Title}";
+
+            if (page is AuthPage)
+            {
+                ButtonBack.Visibility = Visibility.Hidden;
+             
+            }
+            else 
+            {
+                ButtonBack.Visibility = Visibility.Visible;
+            }
+        }
+
+
+        private void ButtonBack(object sender, NavigationEventArgs e)
+        {
+            if (MainFrame.CanGoBack) MainFrame.GoBack();
+
+        }
+        private void ButtonPage1_OnClick(object sender, NavigationEventArgs e) 
+        {
+            NavigationService?.Navigate(new Page2());
+        }
+        private void ButtonPage2_OnClick(object sender, NavigationEventArgs e)
+        {
+            NavigationService?.Navigate(new AuthPage());
+        }
+        private void ButtonPage3_OnClick(object sender, NavigationEventArgs e)
+        {
+            NavigationService?.Navigate(new Menu());
+        }
+        
+
+        }
+    }
+
+}

+ 1 - 0
Chekryshov_lessons/Page/Page2.xaml

@@ -0,0 +1 @@
+<?xml version="1.0" encoding="utf-8" ?> 

+ 1 - 0
OslopovaLessons

@@ -0,0 +1 @@
+Subproject commit abe76498a9526a469fcd302cfb8b314e569b5b51