Imagara 2 роки тому
батько
коміт
efa632dc99

+ 49 - 0
RaspisKusach/ConfirmationWindow.xaml

@@ -0,0 +1,49 @@
+<Window x:Class="RaspisKusach.ConfirmationWindow"
+        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:RaspisKusach"
+        mc:Ignorable="d"
+        MinHeight="120" 
+        Height="120"
+        Width="300" 
+        WindowStartupLocation="CenterOwner" 
+        WindowStyle="None" 
+        ResizeMode="NoResize">
+    <Border BorderBrush="Black"
+            BorderThickness="1"
+            MouseDown="Border_MouseDown">
+        <Grid>
+            <Grid.RowDefinitions>
+                <RowDefinition Height="27*"/>
+                <RowDefinition Height="13*"/>
+            </Grid.RowDefinitions>
+            <TextBlock Name="ErrorLabel" 
+               Text="Вы действительно хотите это сделать?" 
+               TextWrapping="Wrap"
+               HorizontalAlignment="Center" 
+               Margin="19,10,19,0" 
+               VerticalAlignment="Top" 
+               Width="262"
+                   Background="{x:Null}">
+            </TextBlock>
+            <Grid Grid.Row="1">
+                <StackPanel Orientation="Horizontal"
+                        HorizontalAlignment="Center"
+                        VerticalAlignment="Center">
+                    <Button Content="Да" 
+                Height="30" 
+                Width="130" 
+                        Margin="0,0,5,0"
+                Click="YesButton"/>
+                    <Button Content="Нет" 
+                Height="30" 
+                Width="130"
+                        Margin="5,0,0,0"
+                Click="NoButton"/>
+                </StackPanel>
+            </Grid>
+        </Grid>
+    </Border>
+</Window>

+ 30 - 0
RaspisKusach/ConfirmationWindow.xaml.cs

@@ -0,0 +1,30 @@
+using System.Windows;
+using System.Windows.Input;
+namespace RaspisKusach
+{
+    public partial class ConfirmationWindow : Window
+    {
+        public bool answer;
+        public ConfirmationWindow(bool _answer = false)
+        {
+            InitializeComponent();
+            Owner = Application.Current.MainWindow;
+            answer = _answer;
+        }
+        private void YesButton(object sender, RoutedEventArgs e)
+        {
+            answer = true;
+            this.Close();
+        }
+        private void NoButton(object sender, RoutedEventArgs e)
+        {
+            answer = false;
+            this.Close();
+        }
+        private void Border_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            if (e.LeftButton == MouseButtonState.Pressed)
+                DragMove();
+        }
+    }
+}

+ 1 - 1
RaspisKusach/EDM.Designer.cs

@@ -1,4 +1,4 @@
-// Создание кода T4 для модели "C:\Users\Imagara\source\repos\RaspisKusach\RaspisKusach\EDM.edmx" включено. 
+// Создание кода T4 для модели "C:\Users\milic\source\repos\RaspisKusach\RaspisKusach\EDM.edmx" включено. 
 // Чтобы включить формирование кода прежних версий, измените значение свойства "Стратегия создания кода" конструктора
 // на "Legacy ObjectContext". Это свойство доступно в окне "Свойства", если модель
 // открыта в конструкторе.

+ 1 - 1
RaspisKusach/EDM.edmx.diagram

@@ -4,7 +4,7 @@
   <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
-      <Diagram DiagramId="cbfc4ddba6b5479eb5c52b1c4156acc9" Name="Diagram1" ZoomLevel="98">
+      <Diagram DiagramId="cbfc4ddba6b5479eb5c52b1c4156acc9" Name="Diagram1" ZoomLevel="108">
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Carriages" Width="1.5" PointX="12" PointY="7.375" />
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Routes" Width="1.5" PointX="14.625" PointY="4.125" />
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.RoutesStations" Width="1.5" PointX="14.625" PointY="1" />

+ 1 - 2
RaspisKusach/ErrorWindow.xaml

@@ -11,8 +11,7 @@
         WindowStartupLocation="CenterScreen" 
         WindowStyle="None" 
         ResizeMode="NoResize">
-    <Border Background="{StaticResource ItemColor}"
-            MouseDown="Border_MouseDown"
+    <Border MouseDown="Border_MouseDown"
             BorderBrush="Black"
             BorderThickness="1.5">
         <Grid>

+ 0 - 1
RaspisKusach/MainWindow.xaml.cs

@@ -1,6 +1,5 @@
 using System.Windows;
 using System.Windows.Input;
-using System;
 
 namespace RaspisKusach
 {

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

@@ -31,6 +31,7 @@ namespace RaspisKusach.Pages
                     Session.User = user;
                     if (user.Permissions == 1)
                         Session.AdministrationPageOpenButton.Visibility = Visibility.Visible;
+                    Session.LogoutButtonButton.Visibility = Visibility = Visibility;
                     NavigationService.Navigate(new ProfilePage());
                 }
             }

+ 8 - 0
RaspisKusach/Pages/MenuPage.xaml

@@ -40,6 +40,14 @@
                     Margin="10,0,10,0"
                     Click="ProfileButton_Click">
             </Button>
+            <Button Name="LogoutButton"
+                    Width="120"
+                    Height="40"
+                    Content="Выйти из профиля"
+                    Margin="10,0,10,0"
+                    Click="LogoutButton_Click"
+                    Visibility="Collapsed">
+            </Button>
             <Button Name="AdministrationButton"
                     Width="120"
                     Height="40"

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

@@ -9,21 +9,19 @@ namespace RaspisKusach.Pages
         {
             InitializeComponent();
             Session.AdministrationPageOpenButton = AdministrationButton;
+            Session.LogoutButtonButton = LogoutButton;
         }
 
         private void BuyTicketButton_Click(object sender, RoutedEventArgs e)
         {
-            UserLogout();
             MainContentFrame.Content = new SearchForTicketsPage();
         }
         private void ScheduleButton_Click(object sender, RoutedEventArgs e)
         {
-            UserLogout();
             MainContentFrame.Content = new SchedulePage();
         }
         private void ProfileButton_Click(object sender, RoutedEventArgs e)
         {
-            UserLogout();
             if (Session.User == null)
                 MainContentFrame.Content = new LoginPage();
             else
@@ -36,10 +34,12 @@ namespace RaspisKusach.Pages
             else
                 ((Button)sender).Visibility = Visibility.Collapsed;
         }
-        void UserLogout()
+
+        private void LogoutButton_Click(object sender, RoutedEventArgs e)
         {
             Session.User = null;
             Session.AdministrationPageOpenButton.Visibility = Visibility.Collapsed;
+            Session.LogoutButtonButton.Visibility = Visibility.Collapsed;
         }
     }
 }

+ 0 - 1
RaspisKusach/Pages/ProfilePage.xaml

@@ -106,7 +106,6 @@
                                         Content="✕"
                                         HorizontalAlignment="Right">
                                 </Button>
-
                             </Grid>
                         </Border>
                     </DataTemplate>

+ 15 - 7
RaspisKusach/Pages/ProfilePage.xaml.cs

@@ -2,17 +2,10 @@
 using System.Collections.Generic;
 using System.Globalization;
 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
 {
@@ -62,6 +55,21 @@ namespace RaspisKusach.Pages
                 cnt.db.SaveChanges();
             }
         }
+        private void ReturnTicketButton_Click(object sender, RoutedEventArgs e)
+        {
+            Button btn = (Button)sender;
+            if (btn.DataContext is TicketsClass)
+            {
+                ConfirmationWindow confWindow = new ConfirmationWindow();
+                confWindow.ShowDialog();
+                if (confWindow.answer)
+                {
+                    cnt.db.Tickets.Remove(((TicketsClass)btn.DataContext).Ticket);
+                    cnt.db.SaveChanges();
+                    UpdateCarriagesList();
+                }
+            }
+        }
         public class TicketsClass
         {
             public Tickets Ticket { get; set; }

+ 0 - 1
RaspisKusach/Pages/SearchForTicketsPage.xaml

@@ -75,7 +75,6 @@
                  BorderBrush="{x:Null}"
                  ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                  SelectionChanged="ListBox_SelectionChanged">
-            temp
             <ListBox.ItemTemplate>
                 <DataTemplate>
                     <Border Height="120"

+ 2 - 7
RaspisKusach/Pages/TripInfoPage.xaml

@@ -12,7 +12,7 @@
     <Page.Resources>
         <math:MathConverter x:Key="math"/>
     </Page.Resources>
-    
+
     <Grid Background="White">
         <Grid.RowDefinitions>
             <RowDefinition Height="139*"/>
@@ -78,7 +78,6 @@
                  Grid.Row="1"
                  BorderBrush="{x:Null}"
                  ScrollViewer.HorizontalScrollBarVisibility="Disabled">
-            temp
             <ListBox.ItemTemplate>
                 <DataTemplate>
                     <Border Height="90"
@@ -135,9 +134,5 @@
                 </DataTemplate>
             </ListBox.ItemTemplate>
         </ListBox>
-        
-
     </Grid>
-
-
-</Page>
+</Page>

+ 7 - 0
RaspisKusach/RaspisKusach.csproj

@@ -71,6 +71,9 @@
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
     <Compile Include="cnt.cs" />
+    <Compile Include="ConfirmationWindow.xaml.cs">
+      <DependentUpon>ConfirmationWindow.xaml</DependentUpon>
+    </Compile>
     <Compile Include="EDM.Context.cs">
       <AutoGen>True</AutoGen>
       <DesignTime>True</DesignTime>
@@ -140,6 +143,10 @@
     <Compile Include="Users.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
+    <Page Include="ConfirmationWindow.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="ErrorWindow.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 1 - 0
RaspisKusach/Session.cs

@@ -5,6 +5,7 @@ namespace RaspisKusach
 {
     class Session
     {
+        public static Button LogoutButtonButton { get; set; }
         public static Button AdministrationPageOpenButton { get; set; }
         public static Users User { get; set; }
         public static Stations ThisStation = cnt.db.Stations.Where(item => item.Name == "TOMSK-2").FirstOrDefault();