Imagara před 2 roky
rodič
revize
8725adfc71

+ 3 - 1
RaspisKusach/Carriages.cs

@@ -21,8 +21,10 @@ namespace RaspisKusach
         }
     
         public int IdCarriage { get; set; }
-        public int Count { get; set; }
+        public int IdTrain { get; set; }
+        public int Places { get; set; }
     
+        public virtual Trains Trains { get; set; }
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<Tickets> Tickets { get; set; }
     }

+ 76 - 33
RaspisKusach/EDM.edmx

@@ -10,14 +10,15 @@
             <PropertyRef Name="IdCarriage" />
           </Key>
           <Property Name="IdCarriage" Type="int" Nullable="false" />
-          <Property Name="Count" Type="int" Nullable="false" />
+          <Property Name="IdTrain" Type="int" Nullable="false" />
+          <Property Name="Places" Type="int" Nullable="false" />
         </EntityType>
         <EntityType Name="Routes">
           <Key>
             <PropertyRef Name="IdRoute" />
           </Key>
           <Property Name="IdRoute" Type="int" Nullable="false" />
-          <Property Name="IdTrain" Type="int" Nullable="false" />
+          <Property Name="Name" Type="nvarchar" MaxLength="50" />
         </EntityType>
         <EntityType Name="RoutesStations">
           <Key>
@@ -63,7 +64,9 @@
             <PropertyRef Name="IdTrain" />
           </Key>
           <Property Name="IdTrain" Type="int" Nullable="false" />
-          <Property Name="NameOfTrain" Type="nvarchar" MaxLength="50" Nullable="false" />
+          <Property Name="IdRoute" Type="int" Nullable="false" />
+          <Property Name="Name" Type="nvarchar" MaxLength="50" Nullable="false" />
+          <Property Name="Category" Type="nvarchar" MaxLength="50" Nullable="false" />
         </EntityType>
         <EntityType Name="Users">
           <Key>
@@ -77,14 +80,14 @@
           <Property Name="Name" Type="nvarchar" MaxLength="50" />
           <Property Name="Patronymic" Type="nvarchar" MaxLength="50" />
         </EntityType>
-        <Association Name="FK_Routes_Trains">
+        <Association Name="FK_Carriages_Trains">
           <End Role="Trains" Type="Self.Trains" Multiplicity="1" />
-          <End Role="Routes" Type="Self.Routes" Multiplicity="*" />
+          <End Role="Carriages" Type="Self.Carriages" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Trains">
               <PropertyRef Name="IdTrain" />
             </Principal>
-            <Dependent Role="Routes">
+            <Dependent Role="Carriages">
               <PropertyRef Name="IdTrain" />
             </Dependent>
           </ReferentialConstraint>
@@ -149,6 +152,18 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
+        <Association Name="FK_Trains_Routes">
+          <End Role="Routes" Type="Self.Routes" Multiplicity="1" />
+          <End Role="Trains" Type="Self.Trains" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Routes">
+              <PropertyRef Name="IdRoute" />
+            </Principal>
+            <Dependent Role="Trains">
+              <PropertyRef Name="IdRoute" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <EntityContainer Name="RouteScheduleDataBaseModelStoreContainer">
           <EntitySet Name="Carriages" EntityType="Self.Carriages" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Routes" EntityType="Self.Routes" Schema="dbo" store:Type="Tables" />
@@ -158,9 +173,9 @@
           <EntitySet Name="Tickets" EntityType="Self.Tickets" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Trains" EntityType="Self.Trains" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Users" EntityType="Self.Users" Schema="dbo" store:Type="Tables" />
-          <AssociationSet Name="FK_Routes_Trains" Association="Self.FK_Routes_Trains">
+          <AssociationSet Name="FK_Carriages_Trains" Association="Self.FK_Carriages_Trains">
             <End Role="Trains" EntitySet="Trains" />
-            <End Role="Routes" EntitySet="Routes" />
+            <End Role="Carriages" EntitySet="Carriages" />
           </AssociationSet>
           <AssociationSet Name="FK_RoutesStations_Routes" Association="Self.FK_RoutesStations_Routes">
             <End Role="Routes" EntitySet="Routes" />
@@ -182,6 +197,10 @@
             <End Role="Users" EntitySet="Users" />
             <End Role="Tickets" EntitySet="Tickets" />
           </AssociationSet>
+          <AssociationSet Name="FK_Trains_Routes" Association="Self.FK_Trains_Routes">
+            <End Role="Routes" EntitySet="Routes" />
+            <End Role="Trains" EntitySet="Trains" />
+          </AssociationSet>
         </EntityContainer>
       </Schema></edmx:StorageModels>
     <!-- CSDL content -->
@@ -196,14 +215,14 @@
           <EntitySet Name="Tickets" EntityType="RouteScheduleDataBaseModel.Tickets" />
           <EntitySet Name="Trains" EntityType="RouteScheduleDataBaseModel.Trains" />
           <EntitySet Name="Users" EntityType="RouteScheduleDataBaseModel.Users" />
+          <AssociationSet Name="FK_Carriages_Trains" Association="RouteScheduleDataBaseModel.FK_Carriages_Trains">
+            <End Role="Trains" EntitySet="Trains" />
+            <End Role="Carriages" EntitySet="Carriages" />
+          </AssociationSet>
           <AssociationSet Name="FK_Tickets_Carriages" Association="RouteScheduleDataBaseModel.FK_Tickets_Carriages">
             <End Role="Carriages" EntitySet="Carriages" />
             <End Role="Tickets" EntitySet="Tickets" />
           </AssociationSet>
-          <AssociationSet Name="FK_Routes_Trains" Association="RouteScheduleDataBaseModel.FK_Routes_Trains">
-            <End Role="Trains" EntitySet="Trains" />
-            <End Role="Routes" EntitySet="Routes" />
-          </AssociationSet>
           <AssociationSet Name="FK_RoutesStations_Routes" Association="RouteScheduleDataBaseModel.FK_RoutesStations_Routes">
             <End Role="Routes" EntitySet="Routes" />
             <End Role="RoutesStations" EntitySet="RoutesStations" />
@@ -212,6 +231,10 @@
             <End Role="Routes" EntitySet="Routes" />
             <End Role="Tickets" EntitySet="Tickets" />
           </AssociationSet>
+          <AssociationSet Name="FK_Trains_Routes" Association="RouteScheduleDataBaseModel.FK_Trains_Routes">
+            <End Role="Routes" EntitySet="Routes" />
+            <End Role="Trains" EntitySet="Trains" />
+          </AssociationSet>
           <AssociationSet Name="FK_RoutesStations_Station" Association="RouteScheduleDataBaseModel.FK_RoutesStations_Station">
             <End Role="Station" EntitySet="Station" />
             <End Role="RoutesStations" EntitySet="RoutesStations" />
@@ -226,7 +249,9 @@
             <PropertyRef Name="IdCarriage" />
           </Key>
           <Property Name="IdCarriage" Type="Int32" Nullable="false" />
-          <Property Name="Count" Type="Int32" Nullable="false" />
+          <Property Name="IdTrain" Type="Int32" Nullable="false" />
+          <Property Name="Places" Type="Int32" Nullable="false" />
+          <NavigationProperty Name="Trains" Relationship="RouteScheduleDataBaseModel.FK_Carriages_Trains" FromRole="Carriages" ToRole="Trains" />
           <NavigationProperty Name="Tickets" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Carriages" FromRole="Carriages" ToRole="Tickets" />
         </EntityType>
         <EntityType Name="Routes">
@@ -234,10 +259,10 @@
             <PropertyRef Name="IdRoute" />
           </Key>
           <Property Name="IdRoute" Type="Int32" Nullable="false" />
-          <Property Name="IdTrain" Type="Int32" Nullable="false" />
-          <NavigationProperty Name="Trains" Relationship="RouteScheduleDataBaseModel.FK_Routes_Trains" FromRole="Routes" ToRole="Trains" />
+          <Property Name="Name" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
           <NavigationProperty Name="RoutesStations" Relationship="RouteScheduleDataBaseModel.FK_RoutesStations_Routes" FromRole="Routes" ToRole="RoutesStations" />
           <NavigationProperty Name="Tickets" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Routes" FromRole="Routes" ToRole="Tickets" />
+          <NavigationProperty Name="Trains" Relationship="RouteScheduleDataBaseModel.FK_Trains_Routes" FromRole="Routes" ToRole="Trains" />
         </EntityType>
         <EntityType Name="RoutesStations">
           <Key>
@@ -246,9 +271,9 @@
           <Property Name="IdRouteStation" Type="Int32" Nullable="false" />
           <Property Name="IdRoute" Type="Int32" Nullable="false" />
           <Property Name="IdStation" Type="Int32" Nullable="false" />
+          <Property Name="DateTime" Type="DateTime" Nullable="false" Precision="0" />
           <NavigationProperty Name="Routes" Relationship="RouteScheduleDataBaseModel.FK_RoutesStations_Routes" FromRole="RoutesStations" ToRole="Routes" />
           <NavigationProperty Name="Station" Relationship="RouteScheduleDataBaseModel.FK_RoutesStations_Station" FromRole="RoutesStations" ToRole="Station" />
-          <Property Name="DateTime" Type="DateTime" Nullable="false" Precision="0" />
         </EntityType>
         <EntityType Name="Station">
           <Key>
@@ -289,8 +314,11 @@
             <PropertyRef Name="IdTrain" />
           </Key>
           <Property Name="IdTrain" Type="Int32" Nullable="false" />
-          <Property Name="NameOfTrain" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
-          <NavigationProperty Name="Routes" Relationship="RouteScheduleDataBaseModel.FK_Routes_Trains" FromRole="Trains" ToRole="Routes" />
+          <Property Name="IdRoute" Type="Int32" Nullable="false" />
+          <Property Name="Name" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <Property Name="Category" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <NavigationProperty Name="Carriages" Relationship="RouteScheduleDataBaseModel.FK_Carriages_Trains" FromRole="Trains" ToRole="Carriages" />
+          <NavigationProperty Name="Routes" Relationship="RouteScheduleDataBaseModel.FK_Trains_Routes" FromRole="Trains" ToRole="Routes" />
         </EntityType>
         <EntityType Name="Users">
           <Key>
@@ -305,6 +333,18 @@
           <Property Name="Patronymic" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
           <NavigationProperty Name="Tickets" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Users" FromRole="Users" ToRole="Tickets" />
         </EntityType>
+        <Association Name="FK_Carriages_Trains">
+          <End Type="RouteScheduleDataBaseModel.Trains" Role="Trains" Multiplicity="1" />
+          <End Type="RouteScheduleDataBaseModel.Carriages" Role="Carriages" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Trains">
+              <PropertyRef Name="IdTrain" />
+            </Principal>
+            <Dependent Role="Carriages">
+              <PropertyRef Name="IdTrain" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <Association Name="FK_Tickets_Carriages">
           <End Type="RouteScheduleDataBaseModel.Carriages" Role="Carriages" Multiplicity="1" />
           <End Type="RouteScheduleDataBaseModel.Tickets" Role="Tickets" Multiplicity="*" />
@@ -317,18 +357,6 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
-        <Association Name="FK_Routes_Trains">
-          <End Type="RouteScheduleDataBaseModel.Trains" Role="Trains" Multiplicity="1" />
-          <End Type="RouteScheduleDataBaseModel.Routes" Role="Routes" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Trains">
-              <PropertyRef Name="IdTrain" />
-            </Principal>
-            <Dependent Role="Routes">
-              <PropertyRef Name="IdTrain" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
         <Association Name="FK_RoutesStations_Routes">
           <End Type="RouteScheduleDataBaseModel.Routes" Role="Routes" Multiplicity="1" />
           <End Type="RouteScheduleDataBaseModel.RoutesStations" Role="RoutesStations" Multiplicity="*" />
@@ -353,6 +381,18 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
+        <Association Name="FK_Trains_Routes">
+          <End Type="RouteScheduleDataBaseModel.Routes" Role="Routes" Multiplicity="1" />
+          <End Type="RouteScheduleDataBaseModel.Trains" Role="Trains" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Routes">
+              <PropertyRef Name="IdRoute" />
+            </Principal>
+            <Dependent Role="Trains">
+              <PropertyRef Name="IdRoute" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <Association Name="FK_RoutesStations_Station">
           <End Type="RouteScheduleDataBaseModel.Station" Role="Station" Multiplicity="1" />
           <End Type="RouteScheduleDataBaseModel.RoutesStations" Role="RoutesStations" Multiplicity="*" />
@@ -386,7 +426,8 @@
           <EntitySetMapping Name="Carriages">
             <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Carriages">
               <MappingFragment StoreEntitySet="Carriages">
-                <ScalarProperty Name="Count" ColumnName="Count" />
+                <ScalarProperty Name="Places" ColumnName="Places" />
+                <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
                 <ScalarProperty Name="IdCarriage" ColumnName="IdCarriage" />
               </MappingFragment>
             </EntityTypeMapping>
@@ -394,7 +435,7 @@
           <EntitySetMapping Name="Routes">
             <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Routes">
               <MappingFragment StoreEntitySet="Routes">
-                <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
+                <ScalarProperty Name="Name" ColumnName="Name" />
                 <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
               </MappingFragment>
             </EntityTypeMapping>
@@ -445,7 +486,9 @@
           <EntitySetMapping Name="Trains">
             <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Trains">
               <MappingFragment StoreEntitySet="Trains">
-                <ScalarProperty Name="NameOfTrain" ColumnName="NameOfTrain" />
+                <ScalarProperty Name="Category" ColumnName="Category" />
+                <ScalarProperty Name="Name" ColumnName="Name" />
+                <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
                 <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
               </MappingFragment>
             </EntityTypeMapping>

+ 10 - 9
RaspisKusach/EDM.edmx.diagram

@@ -5,18 +5,19 @@
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
       <Diagram DiagramId="cbfc4ddba6b5479eb5c52b1c4156acc9" Name="Diagram1">
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Carriages" Width="1.5" PointX="1.5" PointY="1.875" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Routes" Width="1.5" PointX="3.875" PointY="4.25" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.RoutesStations" Width="1.5" PointX="3.875" PointY="7.875" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Station" Width="1.5" PointX="7.125" PointY="7.875" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.sysdiagrams" Width="1.5" PointX="7" PointY="4.375" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Tickets" Width="1.5" PointX="1.25" PointY="4.5" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Trains" Width="1.5" PointX="3.75" PointY="1.875" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Users" Width="1.5" PointX="1.25" PointY="8.125" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Carriages" Width="1.5" PointX="5.375" PointY="6.5" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Routes" Width="1.5" PointX="5.25" PointY="4" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.RoutesStations" Width="1.5" PointX="8.25" PointY="2.875" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Station" Width="1.5" PointX="5.125" PointY="1.625" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.sysdiagrams" Width="1.5" PointX="1.5" PointY="1.375" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Tickets" Width="1.5" PointX="1.5" PointY="4.25" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Trains" Width="1.5" PointX="8.25" PointY="5.875" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Users" Width="1.5" PointX="1.375" PointY="8.25" />
+        <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Carriages_Trains" />
         <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Tickets_Carriages" />
-        <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Routes_Trains" />
         <AssociationConnector Association="RouteScheduleDataBaseModel.FK_RoutesStations_Routes" />
         <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Tickets_Routes" />
+        <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Trains_Routes" />
         <AssociationConnector Association="RouteScheduleDataBaseModel.FK_RoutesStations_Station" />
         <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Tickets_Users" />
       </Diagram>

+ 1 - 1
RaspisKusach/Pages/LoginPage.xaml

@@ -15,7 +15,7 @@
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
             <RowDefinition/>
-            <RowDefinition Height="2.75*"/>
+            <RowDefinition Height="4*"/>
             <RowDefinition/>
         </Grid.RowDefinitions>
         <Image Source="/Resources/BackGround.jpg" 

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

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

+ 0 - 193
RaspisKusach/Pages/MainPage.xaml

@@ -1,193 +0,0 @@
-<Page x:Class="RaspisKusach.Pages.MainPage"
-      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="MainPage">
-
-    <Grid>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="210"/>
-            <ColumnDefinition/>
-        </Grid.ColumnDefinitions>
-
-        <!--LEFTBAR-->
-        <Border CornerRadius="15" 
-                Background="{StaticResource Color2}"
-                BorderThickness="1.5"
-                BorderBrush="{StaticResource Selection}"
-                Margin="5"
-                Grid.Column="0">
-
-            <Grid Background="{x:Null}">
-                <StackPanel>
-                    <Label Content="Направление"
-                           Margin="0,10,0,10"
-                           HorizontalAlignment="Center">
-                    </Label>
-                    <StackPanel Orientation="Horizontal"
-                                Grid.Row="0"
-                                HorizontalAlignment="Center"
-                                Height="50">
-                        <ComboBox Name="StationDepartureComboBox"
-                                  Margin="5,0,5,0"
-                                  IsEditable="True"
-                                  Width="80"
-                                  Text="Откуда">
-                        </ComboBox>
-
-                        <ComboBox Name="StationArrivalComboBox"
-                                  Margin="5,0,5,0"
-                                  IsEditable="True"
-                                  Width="80"
-                                  Text="Куда">
-                        </ComboBox>
-                    </StackPanel>
-
-                    <Label Content="Дата"
-                           Margin="0,10,0,10"
-                           HorizontalAlignment="Center">
-                    </Label>
-                    <StackPanel Orientation="Horizontal"
-                                Grid.Row="0"
-                                HorizontalAlignment="Center"
-                                Height="50">
-                        <DatePicker Margin="5,0,5,0"
-                             Width="80">
-                        </DatePicker>
-
-                        <DatePicker Margin="5,0,5,0"
-                             Width="80">
-                        </DatePicker>
-                    </StackPanel>
-
-                    <Button Content="Поиск"
-                            Margin="0,10,0,10"
-                            Width="120"
-                            Height="30"
-                            Click="FindRoutesButton_Click">
-                    </Button>
-                </StackPanel>
-
-            </Grid>
-        </Border>
-
-        <ListBox Name="ListBox"
-                 Grid.Column="1"
-                 BorderBrush="{x:Null}">
-            <ScrollViewer VerticalScrollBarVisibility="Visible"/>
-            <ListBox.ItemTemplate>
-                <DataTemplate>
-                    <Border Height="120"
-                            Width="555"
-                    CornerRadius="10"
-                    Background="{StaticResource Color2}"
-                    BorderThickness="1.5"
-                    BorderBrush="{StaticResource Selection}"
-                    Margin="10,2,10,2"
-                    MouseDown="Border_MouseDown">
-
-                        <Grid Background="{x:Null}">
-                            <Grid.ColumnDefinitions>
-                                <ColumnDefinition/>
-                                <ColumnDefinition/>
-                            </Grid.ColumnDefinitions>
-                            <Grid.RowDefinitions>
-                                <RowDefinition Height="40"/>
-                                <RowDefinition/>
-                            </Grid.RowDefinitions>
-
-                            <!--UPLEFT-->
-                            <StackPanel Orientation="Horizontal"
-                            Grid.Column="0">
-                                <Image Width="35"
-                               Height="35"
-                               Margin="5"
-                               HorizontalAlignment="Left"
-                               Source="/Resources/Train.png">
-                                </Image>
-                                <StackPanel>
-                                    <Label Content="{Binding route.IdRoute}"/>
-                                    <Label Content="{Binding str}"
-                                   Margin="0,-7,0,0"/>
-                                </StackPanel>
-                            </StackPanel>
-                            <!--UPRIGHT-->
-                            <StackPanel Orientation="Horizontal"
-                                Grid.Column="1"
-                                HorizontalAlignment="Right">
-                                <Image Source="/Resources/Train.png"
-                                       Margin="3">
-                                </Image>
-                                <Image Source="/Resources/Train.png"
-                                       Margin="3">
-                                </Image>
-                                <Image Source="/Resources/Train.png"
-                                       Margin="3">
-                                </Image>
-
-                            </StackPanel>
-
-                            <!--DOWNLEFT-->
-                            <Grid Grid.Row="1" Grid.Column="0"
-                                  Background="{x:Null}">
-                                <Grid Background="{x:Null}">
-                                    <Grid.ColumnDefinitions>
-                                        <ColumnDefinition/>
-                                        <ColumnDefinition/>
-                                        <ColumnDefinition/>
-                                    </Grid.ColumnDefinitions>
-
-                                    <StackPanel>
-                                        <Label Content="{Binding stationDeparture}"
-                                               Style="{StaticResource TextCenter}">
-                                        </Label>
-                                        <Label Content="{Binding timeDeparture}"
-                                               Style="{StaticResource TextCenter}">
-                                        </Label>
-                                    </StackPanel>
-
-                                    <Label Content="{Binding timeBetween}" 
-                                           Grid.Column="1"
-                                           Style="{StaticResource TextCenter}">
-                                    </Label>
-
-                                    <StackPanel Grid.Column="2">
-                                        <Label Content="{Binding stationArrival}"
-                                               Style="{StaticResource TextCenter}">
-
-                                        </Label>
-                                        <Label Content="{Binding timeArrival}"
-                                               Style="{StaticResource TextCenter}">
-
-                                        </Label>
-                                    </StackPanel>
-                                </Grid>
-                            </Grid>
-                            
-                            
-                            <!--DOWNRIGHT-->
-                            <ListBox Grid.Row="1" Grid.Column="1"
-                                     Background="{x:Null}"
-                                     BorderBrush="{x:Null}">
-                                <Grid Width="260" Height="20" Background="Black">
-
-                                </Grid>
-                                <Grid Width="260" Height="20" Background="Black">
-
-                                </Grid>
-                                <Grid Width="260" Height="20" Background="Black">
-                                </Grid>
-                            </ListBox>
-                        </Grid>
-                    </Border>
-                </DataTemplate>
-            </ListBox.ItemTemplate>
-        </ListBox>
-        
-    </Grid>
-</Page>

+ 0 - 102
RaspisKusach/Pages/MainPage.xaml.cs

@@ -1,102 +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 RaspisKusach.Pages
-{
-    public partial class MainPage : Page
-    {
-        public MainPage()
-        {
-            InitializeComponent();
-            ListBox.Items.Clear();
-            foreach (var station in cnt.db.Station.GroupBy(item => item.Location))
-            {
-                StationArrivalComboBox.Items.Add(station.Key);
-                StationDepartureComboBox.Items.Add(station.Key);
-            }
-            UpdateRoutesList();
-        }
-        private void UpdateRoutesList()
-        {
-            //var routesList = cnt.db.Routes.ToList();
-            //var list = routesList;
-            //foreach (Routes route in routesList)
-            //{
-            //    if (!cnt.db.RoutesStations.Select(item => item.IdRoute + " " + item.IdStation).Contains(route.IdRoute + " " + StationArrivalComboBox.Text)
-            //        || !cnt.db.RoutesStations.Select(item => item.IdRoute + " " + item.IdStation).Contains(route.IdRoute + " " + StationDepartureComboBox.Text))
-            //        list.Remove(route);
-            //}
-
-            List<RouteClass> routeList = new List<RouteClass>();
-
-            foreach (Routes route in cnt.db.Routes)
-            {
-                RouteClass rt = new RouteClass();
-                rt.route = route;
-                //rt.str = cnt.db.RoutesStations.
-                //    Where(item => item.IdStation == cnt.db.Station.
-                //        Where(it => it.Location == StationArrivalComboBox.Text).
-                //        Select(it => it.IdStation).FirstOrDefault()).
-                //    Select(item => item.DateTime).FirstOrDefault().
-                //    ToString();
-                rt.stationArrival = StationArrivalComboBox.Text;
-                rt.stationDeparture = StationDepartureComboBox.Text;
-                rt.timeArrival = cnt.db.RoutesStations.
-                    Where(item => item.IdRoute == route.IdRoute && item.Station.Location == StationArrivalComboBox.Text).
-                    Select(item => item.DateTime).FirstOrDefault();
-                rt.timeDeparture = cnt.db.RoutesStations.
-                    Where(item => item.IdRoute == route.IdRoute && item.Station.Location == StationDepartureComboBox.Text).
-                    Select(item => item.DateTime).FirstOrDefault();
-                rt.timeBetween = rt.timeDeparture - rt.timeArrival;
-
-                routeList.Add(rt);
-            }
-
-            ListBox.ItemsSource = routeList;
-        }
-        private void Button_Click(object sender, RoutedEventArgs e)
-        {
-
-        }
-        private void AddButton_Click(object sender, RoutedEventArgs e)
-        {
-
-        }
-
-
-
-        private void Border_MouseDown(object sender, MouseButtonEventArgs e)
-        {
-
-        }
-
-        private void FindRoutesButton_Click(object sender, RoutedEventArgs e)
-        {
-            UpdateRoutesList();
-        }
-
-        public class RouteClass
-        {
-            public Routes route { get; set; }
-            public string str { get; set; }
-            public string stationDeparture { get; set; }
-            public string stationArrival { get; set; }
-            public DateTime timeDeparture { get; set; }
-            public DateTime timeArrival { get; set; }
-            public TimeSpan timeBetween { get; set; }
-
-        }
-    }
-}

+ 1 - 1
RaspisKusach/Pages/MenuPage.xaml

@@ -15,7 +15,7 @@
         <Frame Name="MainContentFrame"
                Grid.Row="0"
                NavigationUIVisibility="Hidden" 
-               Source="/Pages/MainPage.xaml" >
+               Source="/Pages/SearchForTicketsPage.xaml" >
         </Frame>
         <StackPanel Grid.Row="1"
                     Orientation="Horizontal"

+ 58 - 1
RaspisKusach/Pages/ProfilePage.xaml

@@ -9,6 +9,63 @@
       Title="ProfilePage">
 
     <Grid>
-        
+        <StackPanel>
+            <Label>
+
+            </Label>
+            <ListBox Name="TicketsListBox"
+                 Grid.Row="1"
+                 Margin="10,0,10,0"
+                 Background="{StaticResource Color2}"
+                 BorderBrush="{x:Null}"
+                 SelectionChanged="TicketsListBox_SelectionChanged"
+                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"
+                 ScrollViewer.VerticalScrollBarVisibility="Hidden">
+                <ScrollBar></ScrollBar>
+                <ListBox.ItemTemplate>
+                    <DataTemplate>
+                        <Border Width="{Binding Path=ActualWidth, ElementName=TicketsListBox}"
+                            Margin="-10,0,0,0"
+                            Height="45"
+                            CornerRadius="10"
+                            Background="{StaticResource Color2}">
+                            <Grid>
+                                <StackPanel Orientation="Horizontal">
+                                    <Image Width="30"
+                               Height="30"
+                               Margin="10,5,5,5"
+                               HorizontalAlignment="Left"
+                               Source="/RaspisKusach;component/Resources/Train.png">
+                                    </Image>
+                                    <StackPanel>
+                                        <StackPanel Orientation="Horizontal">
+                                            <Label Content="qwe"/>
+                                            <Label Content="qweq"/>
+                                        </StackPanel>
+                                    </StackPanel>
+                                </StackPanel>
+                                <StackPanel Orientation="Horizontal"
+                                        HorizontalAlignment="Right">
+                                    <Button Width="30" Height="30"
+                                        Margin="0,0,5,0"
+                                        Content="✓"
+                                        >
+                                    </Button>
+                                    <Button Width="30" Height="30"
+                                        Margin="0,0,5,0"
+                                        Content="✎">
+                                    </Button>
+                                    <Button Width="30" Height="30"
+                                        Margin="0,0,5,0"
+                                        Content="✕">
+                                    </Button>
+                                </StackPanel>
+
+                            </Grid>
+                        </Border>
+                    </DataTemplate>
+                </ListBox.ItemTemplate>
+            </ListBox>
+        </StackPanel>
     </Grid>
 </Page>

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

@@ -23,6 +23,13 @@ namespace RaspisKusach.Pages
         public ProfilePage()
         {
             InitializeComponent();
+            TicketsListBox.Items.Clear();
+            TicketsListBox.ItemsSource = cnt.db.Tickets.Where(item => item.IdUser == Session.User.IdUser).ToList();
+        }
+
+        private void TicketsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
+        {
+
         }
     }
 }

+ 182 - 3
RaspisKusach/Pages/SearchForTicketsPage.xaml

@@ -5,10 +5,189 @@
       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="SearchForTicketsPage">
+      d:DesignHeight="450" 
+      d:DesignWidth="800"
+      Title="MainPage">
 
     <Grid>
-        
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="210"/>
+            <ColumnDefinition/>
+        </Grid.ColumnDefinitions>
+
+        <!--LEFTBAR-->
+        <Border CornerRadius="15" 
+                Background="{StaticResource Color2}"
+                BorderThickness="1.5"
+                BorderBrush="{StaticResource Selection}"
+                Margin="5"
+                Grid.Column="0">
+
+            <Grid Background="{x:Null}">
+                <StackPanel>
+                    <Label Content="Направление"
+                           Margin="0,10,0,10"
+                           HorizontalAlignment="Center">
+                    </Label>
+                    <StackPanel Orientation="Horizontal"
+                                Grid.Row="0"
+                                HorizontalAlignment="Center"
+                                Height="50">
+                        <ComboBox Name="StationDepartureComboBox"
+                                  Margin="5,0,5,0"
+                                  IsEditable="True"
+                                  Width="80"
+                                  Text="Откуда">
+                        </ComboBox>
+
+                        <ComboBox Name="StationArrivalComboBox"
+                                  Margin="5,0,5,0"
+                                  IsEditable="True"
+                                  Width="80"
+                                  Text="Куда">
+                        </ComboBox>
+                    </StackPanel>
+
+                    <Label Content="Дата"
+                           Margin="0,10,0,10"
+                           HorizontalAlignment="Center">
+                    </Label>
+                    <StackPanel Orientation="Horizontal"
+                                Grid.Row="0"
+                                HorizontalAlignment="Center"
+                                Height="50">
+                        <DatePicker Margin="5,0,5,0"
+                             Width="80">
+                        </DatePicker>
+
+                        <DatePicker Margin="5,0,5,0"
+                             Width="80">
+                        </DatePicker>
+                    </StackPanel>
+
+                    <Button Content="Поиск"
+                            Margin="0,10,0,10"
+                            Width="120"
+                            Height="30"
+                            Click="FindRoutesButton_Click">
+                    </Button>
+                </StackPanel>
+
+            </Grid>
+        </Border>
+
+        <ListBox Name="ListBox"
+                 Grid.Column="1"
+                 BorderBrush="{x:Null}">
+            <ScrollViewer VerticalScrollBarVisibility="Visible"/>
+            <ListBox.ItemTemplate>
+                <DataTemplate>
+                    <Border Height="120"
+                            Width="555"
+                    CornerRadius="10"
+                    Background="{StaticResource Color2}"
+                    BorderThickness="1.5"
+                    BorderBrush="{StaticResource Selection}"
+                    Margin="10,2,10,2"
+                    MouseDown="Border_MouseDown">
+
+                        <Grid Background="{x:Null}">
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition/>
+                                <ColumnDefinition/>
+                            </Grid.ColumnDefinitions>
+                            <Grid.RowDefinitions>
+                                <RowDefinition Height="40"/>
+                                <RowDefinition/>
+                            </Grid.RowDefinitions>
+
+                            <!--UPLEFT-->
+                            <StackPanel Orientation="Horizontal"
+                            Grid.Column="0">
+                                <Image Width="35"
+                               Height="35"
+                               Margin="5"
+                               HorizontalAlignment="Left"
+                               Source="/Resources/Train.png">
+                                </Image>
+                                <StackPanel>
+                                    <Label Content="{Binding route.IdRoute}"/>
+                                    <Label Content="{Binding str}"
+                                   Margin="0,-7,0,0"/>
+                                </StackPanel>
+                            </StackPanel>
+                            <!--UPRIGHT-->
+                            <StackPanel Orientation="Horizontal"
+                                Grid.Column="1"
+                                HorizontalAlignment="Right">
+                                <Image Source="/Resources/Train.png"
+                                       Margin="3">
+                                </Image>
+                                <Image Source="/Resources/Train.png"
+                                       Margin="3">
+                                </Image>
+                                <Image Source="/Resources/Train.png"
+                                       Margin="3">
+                                </Image>
+
+                            </StackPanel>
+
+                            <!--DOWNLEFT-->
+                            <Grid Grid.Row="1" Grid.Column="0"
+                                  Background="{x:Null}">
+                                <Grid Background="{x:Null}">
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition/>
+                                        <ColumnDefinition/>
+                                        <ColumnDefinition/>
+                                    </Grid.ColumnDefinitions>
+
+                                    <StackPanel>
+                                        <Label Content="{Binding stationDeparture}"
+                                               Style="{StaticResource TextCenter}">
+                                        </Label>
+                                        <Label Content="{Binding timeDeparture}"
+                                               Style="{StaticResource TextCenter}">
+                                        </Label>
+                                    </StackPanel>
+
+                                    <Label Content="{Binding timeBetween}" 
+                                           Grid.Column="1"
+                                           Style="{StaticResource TextCenter}">
+                                    </Label>
+
+                                    <StackPanel Grid.Column="2">
+                                        <Label Content="{Binding stationArrival}"
+                                               Style="{StaticResource TextCenter}">
+
+                                        </Label>
+                                        <Label Content="{Binding timeArrival}"
+                                               Style="{StaticResource TextCenter}">
+
+                                        </Label>
+                                    </StackPanel>
+                                </Grid>
+                            </Grid>
+
+
+                            <!--DOWNRIGHT-->
+                            <ListBox Grid.Row="1" Grid.Column="1"
+                                     Background="{x:Null}"
+                                     BorderBrush="{x:Null}">
+                                <Grid Width="260" Height="20" Background="Black">
+
+                                </Grid>
+                                <Grid Width="260" Height="20" Background="Black">
+
+                                </Grid>
+                                <Grid Width="260" Height="20" Background="Black">
+                                </Grid>
+                            </ListBox>
+                        </Grid>
+                    </Border>
+                </DataTemplate>
+            </ListBox.ItemTemplate>
+        </ListBox>
+
     </Grid>
 </Page>

+ 78 - 1
RaspisKusach/Pages/SearchForTicketsPage.xaml.cs

@@ -22,7 +22,84 @@ namespace RaspisKusach.Pages
     {
         public SearchForTicketsPage()
         {
-            InitializeComponent();
+            InitializeComponent(); 
+            ListBox.Items.Clear();
+            foreach (var station in cnt.db.Station.GroupBy(item => item.Location))
+            {
+                StationArrivalComboBox.Items.Add(station.Key);
+                StationDepartureComboBox.Items.Add(station.Key);
+            }
+            UpdateRoutesList();
+        }
+        private void UpdateRoutesList()
+        {
+            //var routesList = cnt.db.Routes.ToList();
+            //var list = routesList;
+            //foreach (Routes route in routesList)
+            //{
+            //    if (!cnt.db.RoutesStations.Select(item => item.IdRoute + " " + item.IdStation).Contains(route.IdRoute + " " + StationArrivalComboBox.Text)
+            //        || !cnt.db.RoutesStations.Select(item => item.IdRoute + " " + item.IdStation).Contains(route.IdRoute + " " + StationDepartureComboBox.Text))
+            //        list.Remove(route);
+            //}
+
+            List<RouteClass> routeList = new List<RouteClass>();
+
+            foreach (Routes route in cnt.db.Routes)
+            {
+                RouteClass rt = new RouteClass();
+                rt.route = route;
+                //rt.str = cnt.db.RoutesStations.
+                //    Where(item => item.IdStation == cnt.db.Station.
+                //        Where(it => it.Location == StationArrivalComboBox.Text).
+                //        Select(it => it.IdStation).FirstOrDefault()).
+                //    Select(item => item.DateTime).FirstOrDefault().
+                //    ToString();
+                rt.stationArrival = StationArrivalComboBox.Text;
+                rt.stationDeparture = StationDepartureComboBox.Text;
+                rt.timeArrival = cnt.db.RoutesStations.
+                    Where(item => item.IdRoute == route.IdRoute && item.Station.Location == StationArrivalComboBox.Text).
+                    Select(item => item.DateTime).FirstOrDefault();
+                rt.timeDeparture = cnt.db.RoutesStations.
+                    Where(item => item.IdRoute == route.IdRoute && item.Station.Location == StationDepartureComboBox.Text).
+                    Select(item => item.DateTime).FirstOrDefault();
+                rt.timeBetween = rt.timeDeparture - rt.timeArrival;
+
+                routeList.Add(rt);
+            }
+
+            ListBox.ItemsSource = routeList;
+        }
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+        private void AddButton_Click(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+
+
+        private void Border_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+
+        }
+
+        private void FindRoutesButton_Click(object sender, RoutedEventArgs e)
+        {
+            UpdateRoutesList();
+        }
+
+        public class RouteClass
+        {
+            public Routes route { get; set; }
+            public string str { get; set; }
+            public string stationDeparture { get; set; }
+            public string stationArrival { get; set; }
+            public DateTime timeDeparture { get; set; }
+            public DateTime timeArrival { get; set; }
+            public TimeSpan timeBetween { get; set; }
+
         }
     }
 }

+ 0 - 7
RaspisKusach/RaspisKusach.csproj

@@ -91,9 +91,6 @@
     <Compile Include="Pages\LoginPage.xaml.cs">
       <DependentUpon>LoginPage.xaml</DependentUpon>
     </Compile>
-    <Compile Include="Pages\MainPage.xaml.cs">
-      <DependentUpon>MainPage.xaml</DependentUpon>
-    </Compile>
     <Compile Include="Pages\MenuPage.xaml.cs">
       <DependentUpon>MenuPage.xaml</DependentUpon>
     </Compile>
@@ -152,10 +149,6 @@
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>
-    <Page Include="Pages\MainPage.xaml">
-      <SubType>Designer</SubType>
-      <Generator>MSBuild:Compile</Generator>
-    </Page>
     <Page Include="Pages\MenuPage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>

+ 4 - 2
RaspisKusach/Routes.cs

@@ -19,15 +19,17 @@ namespace RaspisKusach
         {
             this.RoutesStations = new HashSet<RoutesStations>();
             this.Tickets = new HashSet<Tickets>();
+            this.Trains = new HashSet<Trains>();
         }
     
         public int IdRoute { get; set; }
-        public int IdTrain { get; set; }
+        public string Name { get; set; }
     
-        public virtual Trains Trains { get; set; }
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<RoutesStations> RoutesStations { get; set; }
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<Tickets> Tickets { get; set; }
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<Trains> Trains { get; set; }
     }
 }

+ 6 - 3
RaspisKusach/Trains.cs

@@ -17,13 +17,16 @@ namespace RaspisKusach
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
         public Trains()
         {
-            this.Routes = new HashSet<Routes>();
+            this.Carriages = new HashSet<Carriages>();
         }
     
         public int IdTrain { get; set; }
-        public string NameOfTrain { get; set; }
+        public int IdRoute { get; set; }
+        public string Name { get; set; }
+        public string Category { get; set; }
     
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
-        public virtual ICollection<Routes> Routes { get; set; }
+        public virtual ICollection<Carriages> Carriages { get; set; }
+        public virtual Routes Routes { get; set; }
     }
 }