Imagara 2 vuotta sitten
vanhempi
commit
dc5d8f86b3

+ 64 - 0
RaspisKusach/Pages/AdministrationPage.xaml

@@ -0,0 +1,64 @@
+<Page x:Class="RaspisKusach.Pages.AdministrationPage"
+      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:RaspisKusach.Pages"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="AdministrationPage">
+
+    <Grid>
+        <Grid.RowDefinitions>
+            <RowDefinition Height="35"/>
+            <RowDefinition/>
+            <RowDefinition/>
+        </Grid.RowDefinitions>
+        
+        <Label Content="Администрирование"
+               HorizontalContentAlignment="Center"
+               FontSize="20"
+               FontWeight="SemiBold"/>
+
+        <StackPanel Grid.Row="1"
+                    Orientation="Horizontal"
+                    HorizontalAlignment="Center">
+            
+            <Button Width="120"
+                    Height="40"
+                    Content="Маршруты"
+                    Margin="10,0,10,0">
+            </Button>
+            
+            <Button Width="120"
+                    Height="40"
+                    Content="Станции"
+                    Margin="10,0,10,0">
+            </Button>
+            
+            <Button Width="120"
+                    Height="40"
+                    Content="Поезда"
+                    Margin="10,0,10,0">
+            </Button>
+            
+        </StackPanel>
+
+        <StackPanel Grid.Row="2"
+                    Orientation="Horizontal"
+                    HorizontalAlignment="Center">
+            
+            <Button Width="120"
+                    Height="40"
+                    Content="Профиль"
+                    Margin="10,0,10,0">
+            </Button>
+
+            <Button Width="120"
+                    Height="40"
+                    Content="Профиль"
+                    Margin="10,0,10,0">
+            </Button>
+        </StackPanel>
+    </Grid>
+</Page>

+ 28 - 0
RaspisKusach/Pages/AdministrationPage.xaml.cs

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

+ 1 - 1
RaspisKusach/Pages/LoginPage.xaml

@@ -4,7 +4,7 @@
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:RaspisKusach.Pages"
-      mc:Ignorable="d" 
+      mc:Ignorable="d"
       d:DesignHeight="450" 
       d:DesignWidth="800">
     <Grid>

+ 1 - 0
RaspisKusach/Pages/LoginPage.xaml.cs

@@ -36,6 +36,7 @@ namespace RaspisKusach.Pages
             if (Test)
             {
                 Session.User = cnt.db.Users.Where(item => item.IdUser == 1).FirstOrDefault();
+                
                 NavigationService.Navigate(new ProfilePage());
             }
             else

+ 4 - 2
RaspisKusach/Pages/MenuPage.xaml

@@ -38,11 +38,13 @@
                     Margin="10,0,10,0"
                     Click="ProfileButton_Click">
             </Button>
-            <Button Width="120"
+            <Button Name="AdministrationButton"
+                    Width="120"
                     Height="40"
                     Content="Администрирование"
                     Margin="10,0,10,0"
-                    Click="AdminButton_Click">
+                    Visibility="{Binding Path=Session.}"
+                    Click="AdministrationButton_Click">
             </Button>
         </StackPanel>
     </Grid>

+ 6 - 4
RaspisKusach/Pages/MenuPage.xaml.cs

@@ -35,15 +35,17 @@ namespace RaspisKusach.Pages
         }
         private void ProfileButton_Click(object sender, RoutedEventArgs e)
         {
-            if(Session.User == null)
+            if (Session.User == null)
                 MainContentFrame.Content = new LoginPage();
             else
                 MainContentFrame.Content = new ProfilePage();
         }
-        private void AdminButton_Click(object sender, RoutedEventArgs e)
+        private void AdministrationButton_Click(object sender, RoutedEventArgs e)
         {
-            if(Session.User.)
-                MainContentFrame.Content = new ProfilePage();
+            if (Session.User == null || Session.User.Permissions == 1)
+                MainContentFrame.Content = new AdministrationPage();
+            else
+                ((Button)sender).Visibility = Visibility.Collapsed;
         }
     }
 }

+ 7 - 0
RaspisKusach/RaspisKusach.csproj

@@ -88,6 +88,9 @@
       <DependentUpon>ErrorWindow.xaml</DependentUpon>
     </Compile>
     <Compile Include="Functions.cs" />
+    <Compile Include="Pages\AdministrationPage.xaml.cs">
+      <DependentUpon>AdministrationPage.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Pages\LoginPage.xaml.cs">
       <DependentUpon>LoginPage.xaml</DependentUpon>
     </Compile>
@@ -148,6 +151,10 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Page Include="Pages\AdministrationPage.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Pages\LoginPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 2 - 1
RaspisKusach/Session.cs

@@ -1,9 +1,10 @@
 using System.Linq;
+
 namespace RaspisKusach
 {
     class Session
     {
         public static Users User { get; set; }
-        public static Station ThisTableStation = cnt.db.Station.Where(item => item.IdStation == 1).FirstOrDefault();//cnt.db.Station.Where(item => item.Location == "Tomsk").FirstOrDefault();
+        public static Station ThisTableStation = cnt.db.Station.Where(item => item.IdStation == 1).FirstOrDefault();//cnt.db.Station.Where(item => item.Location == "Tomsk").FirstOrDefault
     }
 }