Imagara 2 年 前
コミット
46daae4b38

+ 1 - 0
RaspisKusach/EDM.Context.cs

@@ -32,6 +32,7 @@ namespace RaspisKusach
         public virtual DbSet<sysdiagrams> sysdiagrams { get; set; }
         public virtual DbSet<Tickets> Tickets { get; set; }
         public virtual DbSet<Trains> Trains { get; set; }
+        public virtual DbSet<Trips> Trips { get; set; }
         public virtual DbSet<Users> Users { get; set; }
     }
 }

+ 111 - 44
RaspisKusach/EDM.edmx

@@ -27,7 +27,8 @@
           <Property Name="IdRouteStation" Type="int" Nullable="false" />
           <Property Name="IdRoute" Type="int" Nullable="false" />
           <Property Name="IdStation" Type="int" Nullable="false" />
-          <Property Name="DateTime" Type="date" Nullable="false" />
+          <Property Name="StopTime" Type="time" Precision="7" Nullable="false" />
+          <Property Name="TravelTime" Type="time" Precision="7" Nullable="false" />
         </EntityType>
         <EntityType Name="Station">
           <Key>
@@ -53,7 +54,7 @@
           </Key>
           <Property Name="IdTicket" Type="int" Nullable="false" />
           <Property Name="IdUser" Type="int" Nullable="false" />
-          <Property Name="IdRoute" Type="int" Nullable="false" />
+          <Property Name="IdTrip" Type="int" Nullable="false" />
           <Property Name="IdCarriage" Type="int" Nullable="false" />
           <Property Name="PlaceNumber" Type="int" Nullable="false" />
           <Property Name="Category" Type="int" Nullable="false" />
@@ -64,10 +65,18 @@
             <PropertyRef Name="IdTrain" />
           </Key>
           <Property Name="IdTrain" Type="int" 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="Trips">
+          <Key>
+            <PropertyRef Name="IdTrip" />
+          </Key>
+          <Property Name="IdTrip" Type="int" Nullable="false" />
+          <Property Name="IdTrain" Type="int" Nullable="false" />
+          <Property Name="IdRoute" Type="int" Nullable="false" />
+          <Property Name="TripStartDate" Type="date" Nullable="false" />
+        </EntityType>
         <EntityType Name="Users">
           <Key>
             <PropertyRef Name="IdUser" />
@@ -79,6 +88,7 @@
           <Property Name="Surname" Type="nvarchar" MaxLength="50" />
           <Property Name="Name" Type="nvarchar" MaxLength="50" />
           <Property Name="Patronymic" Type="nvarchar" MaxLength="50" />
+          <Property Name="Permissions" Type="int" Nullable="false" />
         </EntityType>
         <Association Name="FK_Carriages_Trains">
           <End Role="Trains" Type="Self.Trains" Multiplicity="1" />
@@ -128,15 +138,15 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
-        <Association Name="FK_Tickets_Routes">
-          <End Role="Routes" Type="Self.Routes" Multiplicity="1" />
+        <Association Name="FK_Tickets_Trips">
+          <End Role="Trips" Type="Self.Trips" Multiplicity="1" />
           <End Role="Tickets" Type="Self.Tickets" Multiplicity="*" />
           <ReferentialConstraint>
-            <Principal Role="Routes">
-              <PropertyRef Name="IdRoute" />
+            <Principal Role="Trips">
+              <PropertyRef Name="IdTrip" />
             </Principal>
             <Dependent Role="Tickets">
-              <PropertyRef Name="IdRoute" />
+              <PropertyRef Name="IdTrip" />
             </Dependent>
           </ReferentialConstraint>
         </Association>
@@ -152,18 +162,30 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
-        <Association Name="FK_Trains_Routes">
+        <Association Name="FK_Trips_Routes">
           <End Role="Routes" Type="Self.Routes" Multiplicity="1" />
-          <End Role="Trains" Type="Self.Trains" Multiplicity="*" />
+          <End Role="Trips" Type="Self.Trips" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Routes">
               <PropertyRef Name="IdRoute" />
             </Principal>
-            <Dependent Role="Trains">
+            <Dependent Role="Trips">
               <PropertyRef Name="IdRoute" />
             </Dependent>
           </ReferentialConstraint>
         </Association>
+        <Association Name="FK_Trips_Trains">
+          <End Role="Trains" Type="Self.Trains" Multiplicity="1" />
+          <End Role="Trips" Type="Self.Trips" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Trains">
+              <PropertyRef Name="IdTrain" />
+            </Principal>
+            <Dependent Role="Trips">
+              <PropertyRef Name="IdTrain" />
+            </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" />
@@ -172,6 +194,7 @@
           <EntitySet Name="sysdiagrams" EntityType="Self.sysdiagrams" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Tickets" EntityType="Self.Tickets" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Trains" EntityType="Self.Trains" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="Trips" EntityType="Self.Trips" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Users" EntityType="Self.Users" Schema="dbo" store:Type="Tables" />
           <AssociationSet Name="FK_Carriages_Trains" Association="Self.FK_Carriages_Trains">
             <End Role="Trains" EntitySet="Trains" />
@@ -189,17 +212,21 @@
             <End Role="Carriages" EntitySet="Carriages" />
             <End Role="Tickets" EntitySet="Tickets" />
           </AssociationSet>
-          <AssociationSet Name="FK_Tickets_Routes" Association="Self.FK_Tickets_Routes">
-            <End Role="Routes" EntitySet="Routes" />
+          <AssociationSet Name="FK_Tickets_Trips" Association="Self.FK_Tickets_Trips">
+            <End Role="Trips" EntitySet="Trips" />
             <End Role="Tickets" EntitySet="Tickets" />
           </AssociationSet>
           <AssociationSet Name="FK_Tickets_Users" Association="Self.FK_Tickets_Users">
             <End Role="Users" EntitySet="Users" />
             <End Role="Tickets" EntitySet="Tickets" />
           </AssociationSet>
-          <AssociationSet Name="FK_Trains_Routes" Association="Self.FK_Trains_Routes">
+          <AssociationSet Name="FK_Trips_Routes" Association="Self.FK_Trips_Routes">
             <End Role="Routes" EntitySet="Routes" />
+            <End Role="Trips" EntitySet="Trips" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Trips_Trains" Association="Self.FK_Trips_Trains">
             <End Role="Trains" EntitySet="Trains" />
+            <End Role="Trips" EntitySet="Trips" />
           </AssociationSet>
         </EntityContainer>
       </Schema></edmx:StorageModels>
@@ -214,6 +241,7 @@
           <EntitySet Name="sysdiagrams" EntityType="RouteScheduleDataBaseModel.sysdiagrams" />
           <EntitySet Name="Tickets" EntityType="RouteScheduleDataBaseModel.Tickets" />
           <EntitySet Name="Trains" EntityType="RouteScheduleDataBaseModel.Trains" />
+          <EntitySet Name="Trips" EntityType="RouteScheduleDataBaseModel.Trips" />
           <EntitySet Name="Users" EntityType="RouteScheduleDataBaseModel.Users" />
           <AssociationSet Name="FK_Carriages_Trains" Association="RouteScheduleDataBaseModel.FK_Carriages_Trains">
             <End Role="Trains" EntitySet="Trains" />
@@ -227,22 +255,26 @@
             <End Role="Routes" EntitySet="Routes" />
             <End Role="RoutesStations" EntitySet="RoutesStations" />
           </AssociationSet>
-          <AssociationSet Name="FK_Tickets_Routes" Association="RouteScheduleDataBaseModel.FK_Tickets_Routes">
+          <AssociationSet Name="FK_Trips_Routes" Association="RouteScheduleDataBaseModel.FK_Trips_Routes">
             <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" />
+            <End Role="Trips" EntitySet="Trips" />
           </AssociationSet>
           <AssociationSet Name="FK_RoutesStations_Station" Association="RouteScheduleDataBaseModel.FK_RoutesStations_Station">
             <End Role="Station" EntitySet="Station" />
             <End Role="RoutesStations" EntitySet="RoutesStations" />
           </AssociationSet>
+          <AssociationSet Name="FK_Tickets_Trips" Association="RouteScheduleDataBaseModel.FK_Tickets_Trips">
+            <End Role="Trips" EntitySet="Trips" />
+            <End Role="Tickets" EntitySet="Tickets" />
+          </AssociationSet>
           <AssociationSet Name="FK_Tickets_Users" Association="RouteScheduleDataBaseModel.FK_Tickets_Users">
             <End Role="Users" EntitySet="Users" />
             <End Role="Tickets" EntitySet="Tickets" />
           </AssociationSet>
+          <AssociationSet Name="FK_Trips_Trains" Association="RouteScheduleDataBaseModel.FK_Trips_Trains">
+            <End Role="Trains" EntitySet="Trains" />
+            <End Role="Trips" EntitySet="Trips" />
+          </AssociationSet>
         </EntityContainer>
         <EntityType Name="Carriages">
           <Key>
@@ -261,8 +293,7 @@
           <Property Name="IdRoute" Type="Int32" Nullable="false" />
           <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" />
+          <NavigationProperty Name="Trips" Relationship="RouteScheduleDataBaseModel.FK_Trips_Routes" FromRole="Routes" ToRole="Trips" />
         </EntityType>
         <EntityType Name="RoutesStations">
           <Key>
@@ -271,9 +302,10 @@
           <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="StopTime" Type="Time" Nullable="false" Precision="7" />
+          <Property Name="TravelTime" Type="Time" Nullable="false" Precision="7" />
         </EntityType>
         <EntityType Name="Station">
           <Key>
@@ -300,13 +332,13 @@
           </Key>
           <Property Name="IdTicket" Type="Int32" Nullable="false" />
           <Property Name="IdUser" Type="Int32" Nullable="false" />
-          <Property Name="IdRoute" Type="Int32" Nullable="false" />
+          <Property Name="IdTrip" Type="Int32" Nullable="false" />
           <Property Name="IdCarriage" Type="Int32" Nullable="false" />
           <Property Name="PlaceNumber" Type="Int32" Nullable="false" />
           <Property Name="Category" Type="Int32" Nullable="false" />
           <Property Name="BuyDate" Type="DateTime" Nullable="false" Precision="3" />
           <NavigationProperty Name="Carriages" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Carriages" FromRole="Tickets" ToRole="Carriages" />
-          <NavigationProperty Name="Routes" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Routes" FromRole="Tickets" ToRole="Routes" />
+          <NavigationProperty Name="Trips" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Trips" FromRole="Tickets" ToRole="Trips" />
           <NavigationProperty Name="Users" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Users" FromRole="Tickets" ToRole="Users" />
         </EntityType>
         <EntityType Name="Trains">
@@ -314,11 +346,22 @@
             <PropertyRef Name="IdTrain" />
           </Key>
           <Property Name="IdTrain" Type="Int32" Nullable="false" />
-          <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" />
+          <NavigationProperty Name="Trips" Relationship="RouteScheduleDataBaseModel.FK_Trips_Trains" FromRole="Trains" ToRole="Trips" />
+        </EntityType>
+        <EntityType Name="Trips">
+          <Key>
+            <PropertyRef Name="IdTrip" />
+          </Key>
+          <Property Name="IdTrip" Type="Int32" Nullable="false" />
+          <Property Name="IdTrain" Type="Int32" Nullable="false" />
+          <Property Name="IdRoute" Type="Int32" Nullable="false" />
+          <NavigationProperty Name="Routes" Relationship="RouteScheduleDataBaseModel.FK_Trips_Routes" FromRole="Trips" ToRole="Routes" />
+          <NavigationProperty Name="Tickets" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Trips" FromRole="Trips" ToRole="Tickets" />
+          <NavigationProperty Name="Trains" Relationship="RouteScheduleDataBaseModel.FK_Trips_Trains" FromRole="Trips" ToRole="Trains" />
+          <Property Name="TripStartDate" Type="DateTime" Nullable="false" Precision="0" />
         </EntityType>
         <EntityType Name="Users">
           <Key>
@@ -332,6 +375,7 @@
           <Property Name="Name" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
           <Property Name="Patronymic" Type="String" MaxLength="50" FixedLength="false" Unicode="true" />
           <NavigationProperty Name="Tickets" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Users" FromRole="Users" ToRole="Tickets" />
+          <Property Name="Permissions" Type="Int32" Nullable="false" />
         </EntityType>
         <Association Name="FK_Carriages_Trains">
           <End Type="RouteScheduleDataBaseModel.Trains" Role="Trains" Multiplicity="1" />
@@ -369,26 +413,14 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
-        <Association Name="FK_Tickets_Routes">
+        <Association Name="FK_Trips_Routes">
           <End Type="RouteScheduleDataBaseModel.Routes" Role="Routes" Multiplicity="1" />
-          <End Type="RouteScheduleDataBaseModel.Tickets" Role="Tickets" Multiplicity="*" />
+          <End Type="RouteScheduleDataBaseModel.Trips" Role="Trips" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Routes">
               <PropertyRef Name="IdRoute" />
             </Principal>
-            <Dependent Role="Tickets">
-              <PropertyRef Name="IdRoute" />
-            </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">
+            <Dependent Role="Trips">
               <PropertyRef Name="IdRoute" />
             </Dependent>
           </ReferentialConstraint>
@@ -405,6 +437,18 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
+        <Association Name="FK_Tickets_Trips">
+          <End Type="RouteScheduleDataBaseModel.Trips" Role="Trips" Multiplicity="1" />
+          <End Type="RouteScheduleDataBaseModel.Tickets" Role="Tickets" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Trips">
+              <PropertyRef Name="IdTrip" />
+            </Principal>
+            <Dependent Role="Tickets">
+              <PropertyRef Name="IdTrip" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <Association Name="FK_Tickets_Users">
           <End Type="RouteScheduleDataBaseModel.Users" Role="Users" Multiplicity="1" />
           <End Type="RouteScheduleDataBaseModel.Tickets" Role="Tickets" Multiplicity="*" />
@@ -417,6 +461,18 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
+        <Association Name="FK_Trips_Trains">
+          <End Type="RouteScheduleDataBaseModel.Trains" Role="Trains" Multiplicity="1" />
+          <End Type="RouteScheduleDataBaseModel.Trips" Role="Trips" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Trains">
+              <PropertyRef Name="IdTrain" />
+            </Principal>
+            <Dependent Role="Trips">
+              <PropertyRef Name="IdTrain" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         </Schema>
     </edmx:ConceptualModels>
     <!-- C-S mapping content -->
@@ -443,7 +499,8 @@
           <EntitySetMapping Name="RoutesStations">
             <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.RoutesStations">
               <MappingFragment StoreEntitySet="RoutesStations">
-                <ScalarProperty Name="DateTime" ColumnName="DateTime" />
+                <ScalarProperty Name="TravelTime" ColumnName="TravelTime" />
+                <ScalarProperty Name="StopTime" ColumnName="StopTime" />
                 <ScalarProperty Name="IdStation" ColumnName="IdStation" />
                 <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
                 <ScalarProperty Name="IdRouteStation" ColumnName="IdRouteStation" />
@@ -477,7 +534,7 @@
                 <ScalarProperty Name="Category" ColumnName="Category" />
                 <ScalarProperty Name="PlaceNumber" ColumnName="PlaceNumber" />
                 <ScalarProperty Name="IdCarriage" ColumnName="IdCarriage" />
-                <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
+                <ScalarProperty Name="IdTrip" ColumnName="IdTrip" />
                 <ScalarProperty Name="IdUser" ColumnName="IdUser" />
                 <ScalarProperty Name="IdTicket" ColumnName="IdTicket" />
               </MappingFragment>
@@ -488,14 +545,24 @@
               <MappingFragment StoreEntitySet="Trains">
                 <ScalarProperty Name="Category" ColumnName="Category" />
                 <ScalarProperty Name="Name" ColumnName="Name" />
+                <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Trips">
+            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Trips">
+              <MappingFragment StoreEntitySet="Trips">
+                <ScalarProperty Name="TripStartDate" ColumnName="TripStartDate" />
                 <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
                 <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
+                <ScalarProperty Name="IdTrip" ColumnName="IdTrip" />
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
           <EntitySetMapping Name="Users">
             <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Users">
               <MappingFragment StoreEntitySet="Users">
+                <ScalarProperty Name="Permissions" ColumnName="Permissions" />
                 <ScalarProperty Name="Patronymic" ColumnName="Patronymic" />
                 <ScalarProperty Name="Name" ColumnName="Name" />
                 <ScalarProperty Name="Surname" ColumnName="Surname" />

+ 12 - 10
RaspisKusach/EDM.edmx.diagram

@@ -5,21 +5,23 @@
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
       <Diagram DiagramId="cbfc4ddba6b5479eb5c52b1c4156acc9" Name="Diagram1">
-        <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" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Carriages" Width="1.5" PointX="4.125" PointY="7.75" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Routes" Width="1.5" PointX="6.5" PointY="4.5" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.RoutesStations" Width="1.5" PointX="6.375" PointY="1.625" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Station" Width="1.5" PointX="4.25" PointY="1.75" IsExpanded="true" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.sysdiagrams" Width="1.5" PointX="9.75" PointY="5.625" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Tickets" Width="1.5" PointX="1.5" PointY="4" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Trains" Width="1.5" PointX="6.375" PointY="7.75" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Trips" Width="1.5" PointX="4.125" PointY="4.375" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Users" Width="1.5" PointX="1.5" PointY="7.625" />
         <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Carriages_Trains" />
         <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Tickets_Carriages" />
         <AssociationConnector Association="RouteScheduleDataBaseModel.FK_RoutesStations_Routes" />
-        <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Tickets_Routes" />
-        <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Trains_Routes" />
+        <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Trips_Routes" />
         <AssociationConnector Association="RouteScheduleDataBaseModel.FK_RoutesStations_Station" />
+        <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Tickets_Trips" />
         <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Tickets_Users" />
+        <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Trips_Trains" />
       </Diagram>
     </edmx:Diagrams>
   </edmx:Designer>

+ 2 - 0
RaspisKusach/MainWindow.xaml.cs

@@ -1,4 +1,5 @@
 using System.Windows;
+using System.Linq;
 using System.Windows.Input;
 
 namespace RaspisKusach
@@ -8,6 +9,7 @@ namespace RaspisKusach
         public MainWindow()
         {
             InitializeComponent();
+            //MessageBox.Show($" {cnt.db.RoutesStations.Where(item => item.IdRouteStation == 1).Select(item => item.StopTime).FirstOrDefault() + cnt.db.RoutesStations.Where(item => item.IdRouteStation == 1).Select(item => item.TravelTime).FirstOrDefault()}");
         }
         private void Border_MouseDown(object sender, MouseButtonEventArgs e)
         {

+ 6 - 0
RaspisKusach/Pages/MenuPage.xaml

@@ -38,6 +38,12 @@
                     Margin="10,0,10,0"
                     Click="ProfileButton_Click">
             </Button>
+            <Button Width="120"
+                    Height="40"
+                    Content="Администрирование"
+                    Margin="10,0,10,0"
+                    Click="AdminButton_Click">
+            </Button>
         </StackPanel>
     </Grid>
 </Page>

+ 5 - 0
RaspisKusach/Pages/MenuPage.xaml.cs

@@ -40,5 +40,10 @@ namespace RaspisKusach.Pages
             else
                 MainContentFrame.Content = new ProfilePage();
         }
+        private void AdminButton_Click(object sender, RoutedEventArgs e)
+        {
+            if(Session.User.)
+                MainContentFrame.Content = new ProfilePage();
+        }
     }
 }

+ 5 - 16
RaspisKusach/Pages/ProfilePage.xaml

@@ -26,7 +26,7 @@
                     <DataTemplate>
                         <Border Width="{Binding Path=ActualWidth, ElementName=TicketsListBox}"
                             Margin="-10,0,0,0"
-                            Height="45"
+                            Height="70"
                             CornerRadius="10"
                             Background="{StaticResource Color2}">
                             <Grid>
@@ -44,22 +44,11 @@
                                         </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"
+                                <Button Width="30" Height="30"
                                         Margin="0,0,5,0"
-                                        Content="✕">
-                                    </Button>
-                                </StackPanel>
+                                        Content="✕"
+                                        HorizontalAlignment="Right">
+                                </Button>
 
                             </Grid>
                         </Border>

+ 23 - 45
RaspisKusach/Pages/SearchForTicketsPage.xaml.cs

@@ -15,14 +15,11 @@ using System.Windows.Shapes;
 
 namespace RaspisKusach.Pages
 {
-    /// <summary>
-    /// Логика взаимодействия для SearchForTicketsPage.xaml
-    /// </summary>
     public partial class SearchForTicketsPage : Page
     {
         public SearchForTicketsPage()
         {
-            InitializeComponent(); 
+            InitializeComponent();
             ListBox.Items.Clear();
             foreach (var station in cnt.db.Station.GroupBy(item => item.Location))
             {
@@ -33,50 +30,32 @@ namespace RaspisKusach.Pages
         }
         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<TripClass> routeList = new List<TripClass>();
 
-            List<RouteClass> routeList = new List<RouteClass>();
-
-            foreach (Routes route in cnt.db.Routes)
+            foreach (Trips trip in cnt.db.Trips)
             {
-                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;
+                if (cnt.db.RoutesStations.Select(item => item.Station.Location + " " + item.IdRoute).Contains(StationArrivalComboBox.Text + " " + trip.IdRoute)
+                    || cnt.db.RoutesStations.Select(item => item.Station.Location + " " + item.IdRoute).Contains(StationDepartureComboBox.Text + " " + trip.IdRoute))
+                {
+                    TripClass rt = new TripClass();
+                    rt.trip = trip;
+                    rt.trainCategory = trip.Trains.Category;
+                    rt.stationArrival = StationArrivalComboBox.Text;
+                    rt.stationDeparture = StationDepartureComboBox.Text;
+                    //rt.timeArrival = cnt.db.RoutesStations.
+                    //    Where(item => item.IdRoute == trip.Routes.IdRoute && item.Station.Location == StationArrivalComboBox.Text).
+                    //    Select(item => item.DateTime).FirstOrDefault();
+                    //rt.timeDeparture = cnt.db.RoutesStations.
+                    //    Where(item => item.IdRoute == trip.Routes.IdRoute && item.Station.Location == StationDepartureComboBox.Text).
+                    //    Select(item => item.DateTime).FirstOrDefault();
+                    //rt.timeBetween = rt.timeDeparture - rt.timeArrival;
 
-                routeList.Add(rt);
+                    routeList.Add(rt);
+                }
             }
 
             ListBox.ItemsSource = routeList;
         }
-        private void Button_Click(object sender, RoutedEventArgs e)
-        {
-
-        }
-        private void AddButton_Click(object sender, RoutedEventArgs e)
-        {
-
-        }
 
 
 
@@ -90,16 +69,15 @@ namespace RaspisKusach.Pages
             UpdateRoutesList();
         }
 
-        public class RouteClass
+        public class TripClass
         {
-            public Routes route { get; set; }
-            public string str { get; set; }
+            public Trips trip { get; set; }
+            public string trainCategory { 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; }
-
         }
     }
 }

+ 3 - 0
RaspisKusach/RaspisKusach.csproj

@@ -126,6 +126,9 @@
     <Compile Include="Trains.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
+    <Compile Include="Trips.cs">
+      <DependentUpon>EDM.tt</DependentUpon>
+    </Compile>
     <Compile Include="Users.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>

+ 2 - 5
RaspisKusach/Routes.cs

@@ -18,8 +18,7 @@ namespace RaspisKusach
         public Routes()
         {
             this.RoutesStations = new HashSet<RoutesStations>();
-            this.Tickets = new HashSet<Tickets>();
-            this.Trains = new HashSet<Trains>();
+            this.Trips = new HashSet<Trips>();
         }
     
         public int IdRoute { get; set; }
@@ -28,8 +27,6 @@ namespace RaspisKusach
         [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; }
+        public virtual ICollection<Trips> Trips { get; set; }
     }
 }

+ 2 - 1
RaspisKusach/RoutesStations.cs

@@ -17,7 +17,8 @@ namespace RaspisKusach
         public int IdRouteStation { get; set; }
         public int IdRoute { get; set; }
         public int IdStation { get; set; }
-        public System.DateTime DateTime { get; set; }
+        public System.TimeSpan StopTime { get; set; }
+        public System.TimeSpan TravelTime { get; set; }
     
         public virtual Routes Routes { get; set; }
         public virtual Station Station { get; set; }

+ 2 - 2
RaspisKusach/Tickets.cs

@@ -16,14 +16,14 @@ namespace RaspisKusach
     {
         public int IdTicket { get; set; }
         public int IdUser { get; set; }
-        public int IdRoute { get; set; }
+        public int IdTrip { get; set; }
         public int IdCarriage { get; set; }
         public int PlaceNumber { get; set; }
         public int Category { get; set; }
         public System.DateTime BuyDate { get; set; }
     
         public virtual Carriages Carriages { get; set; }
-        public virtual Routes Routes { get; set; }
+        public virtual Trips Trips { get; set; }
         public virtual Users Users { get; set; }
     }
 }

+ 3 - 2
RaspisKusach/Trains.cs

@@ -18,15 +18,16 @@ namespace RaspisKusach
         public Trains()
         {
             this.Carriages = new HashSet<Carriages>();
+            this.Trips = new HashSet<Trips>();
         }
     
         public int IdTrain { 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<Carriages> Carriages { get; set; }
-        public virtual Routes Routes { get; set; }
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<Trips> Trips { get; set; }
     }
 }

+ 33 - 0
RaspisKusach/Trips.cs

@@ -0,0 +1,33 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace RaspisKusach
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class Trips
+    {
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+        public Trips()
+        {
+            this.Tickets = new HashSet<Tickets>();
+        }
+    
+        public int IdTrip { get; set; }
+        public int IdTrain { get; set; }
+        public int IdRoute { get; set; }
+        public System.DateTime TripStartDate { get; set; }
+    
+        public virtual Routes Routes { get; set; }
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<Tickets> Tickets { get; set; }
+        public virtual Trains Trains { get; set; }
+    }
+}

+ 1 - 0
RaspisKusach/Users.cs

@@ -27,6 +27,7 @@ namespace RaspisKusach
         public string Surname { get; set; }
         public string Name { get; set; }
         public string Patronymic { get; set; }
+        public int Permissions { get; set; }
     
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<Tickets> Tickets { get; set; }