Imagarrr 2 yıl önce
ebeveyn
işleme
869529a398

+ 1 - 1
RaspisKusach/EDM.Designer.cs

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

+ 327 - 327
RaspisKusach/EDM.edmx

@@ -4,235 +4,235 @@
   <edmx:Runtime>
     <!-- SSDL content -->
     <edmx:StorageModels>
-    <Schema Namespace="RouteScheduleDataBaseModel.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2012" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
-        <EntityType Name="Carriages">
-          <Key>
-            <PropertyRef Name="IdCarriage" />
-          </Key>
-          <Property Name="IdCarriage" Type="int" Nullable="false" />
-          <Property Name="IdTrain" Type="int" Nullable="false" />
-          <Property Name="Places" Type="int" Nullable="false" />
-          <Property Name="Category" Type="nvarchar" MaxLength="50" Nullable="false" />
-        </EntityType>
-        <EntityType Name="Routes">
-          <Key>
-            <PropertyRef Name="IdRoute" />
-          </Key>
-          <Property Name="IdRoute" Type="int" Nullable="false" />
-          <Property Name="Name" Type="nvarchar" MaxLength="50" />
-        </EntityType>
-        <EntityType Name="RoutesStations">
-          <Key>
-            <PropertyRef Name="IdRouteStation" />
-          </Key>
-          <Property Name="IdRouteStation" Type="int" Nullable="false" />
-          <Property Name="IdRoute" Type="int" Nullable="false" />
-          <Property Name="IdStation" Type="int" Nullable="false" />
-          <Property Name="StopTime" Type="time" Precision="7" Nullable="false" />
-          <Property Name="TravelTime" Type="time" Precision="7" Nullable="false" />
-        </EntityType>
-        <EntityType Name="Stations">
-          <Key>
-            <PropertyRef Name="IdStation" />
-          </Key>
-          <Property Name="IdStation" Type="int" Nullable="false" />
-          <Property Name="Name" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="Location" Type="nvarchar" MaxLength="50" Nullable="false" />
-        </EntityType>
-        <EntityType Name="sysdiagrams">
-          <Key>
-            <PropertyRef Name="diagram_id" />
-          </Key>
-          <Property Name="name" Type="nvarchar" MaxLength="128" Nullable="false" />
-          <Property Name="principal_id" Type="int" Nullable="false" />
-          <Property Name="diagram_id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
-          <Property Name="version" Type="int" />
-          <Property Name="definition" Type="varbinary(max)" />
-        </EntityType>
-        <EntityType Name="Tickets">
-          <Key>
-            <PropertyRef Name="IdTicket" />
-          </Key>
-          <Property Name="IdTicket" Type="int" Nullable="false" />
-          <Property Name="IdUser" 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="BuyDate" Type="datetime" Nullable="false" />
-        </EntityType>
-        <EntityType Name="Trains">
-          <Key>
-            <PropertyRef Name="IdTrain" />
-          </Key>
-          <Property Name="IdTrain" 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" />
-          </Key>
-          <Property Name="IdUser" Type="int" Nullable="false" />
-          <Property Name="Login" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="Password" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="Image" Type="varbinary(max)" />
-          <Property Name="Email" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="PhoneNum" Type="nvarchar" MaxLength="11" Nullable="false" />
-          <Property Name="Passport" Type="nvarchar" MaxLength="10" Nullable="false" />
-          <Property Name="Surname" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="Name" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="Patronymic" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="Permissions" Type="int" Nullable="false" />
-        </EntityType>
-        <Association Name="FK_Carriages_Trains">
-          <End Role="Trains" Type="Self.Trains" Multiplicity="1" />
-          <End Role="Carriages" Type="Self.Carriages" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Trains">
-              <PropertyRef Name="IdTrain" />
-            </Principal>
-            <Dependent Role="Carriages">
-              <PropertyRef Name="IdTrain" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
-        <Association Name="FK_RoutesStations_Routes">
-          <End Role="Routes" Type="Self.Routes" Multiplicity="1" />
-          <End Role="RoutesStations" Type="Self.RoutesStations" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Routes">
-              <PropertyRef Name="IdRoute" />
-            </Principal>
-            <Dependent Role="RoutesStations">
-              <PropertyRef Name="IdRoute" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
-        <Association Name="FK_RoutesStations_Stations">
-          <End Role="Stations" Type="Self.Stations" Multiplicity="1" />
-          <End Role="RoutesStations" Type="Self.RoutesStations" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Stations">
-              <PropertyRef Name="IdStation" />
-            </Principal>
-            <Dependent Role="RoutesStations">
-              <PropertyRef Name="IdStation" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
-        <Association Name="FK_Tickets_Carriages">
-          <End Role="Carriages" Type="Self.Carriages" Multiplicity="1" />
-          <End Role="Tickets" Type="Self.Tickets" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Carriages">
-              <PropertyRef Name="IdCarriage" />
-            </Principal>
-            <Dependent Role="Tickets">
-              <PropertyRef Name="IdCarriage" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
-        <Association Name="FK_Tickets_Trips">
-          <End Role="Trips" Type="Self.Trips" Multiplicity="1" />
-          <End Role="Tickets" Type="Self.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 Role="Users" Type="Self.Users" Multiplicity="1" />
-          <End Role="Tickets" Type="Self.Tickets" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Users">
-              <PropertyRef Name="IdUser" />
-            </Principal>
-            <Dependent Role="Tickets">
-              <PropertyRef Name="IdUser" />
-            </Dependent>
-          </ReferentialConstraint>
-        </Association>
-        <Association Name="FK_Trips_Routes">
-          <End Role="Routes" Type="Self.Routes" Multiplicity="1" />
-          <End Role="Trips" Type="Self.Trips" Multiplicity="*" />
-          <ReferentialConstraint>
-            <Principal Role="Routes">
-              <PropertyRef Name="IdRoute" />
-            </Principal>
-            <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" />
-          <EntitySet Name="RoutesStations" EntityType="Self.RoutesStations" Schema="dbo" store:Type="Tables" />
-          <EntitySet Name="Stations" EntityType="Self.Stations" Schema="dbo" store:Type="Tables" />
-          <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" />
-            <End Role="Carriages" EntitySet="Carriages" />
-          </AssociationSet>
-          <AssociationSet Name="FK_RoutesStations_Routes" Association="Self.FK_RoutesStations_Routes">
-            <End Role="Routes" EntitySet="Routes" />
-            <End Role="RoutesStations" EntitySet="RoutesStations" />
-          </AssociationSet>
-          <AssociationSet Name="FK_RoutesStations_Stations" Association="Self.FK_RoutesStations_Stations">
-            <End Role="Stations" EntitySet="Stations" />
-            <End Role="RoutesStations" EntitySet="RoutesStations" />
-          </AssociationSet>
-          <AssociationSet Name="FK_Tickets_Carriages" Association="Self.FK_Tickets_Carriages">
-            <End Role="Carriages" EntitySet="Carriages" />
-            <End Role="Tickets" EntitySet="Tickets" />
-          </AssociationSet>
-          <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_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>
+    <Schema Namespace="RouteScheduleDataBaseModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2012" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
+  <EntityContainer Name="RouteScheduleDataBaseModelStoreContainer">
+    <EntitySet Name="Carriages" EntityType="RouteScheduleDataBaseModel.Store.Carriages" store:Type="Tables" Schema="dbo" />
+    <EntitySet Name="Routes" EntityType="RouteScheduleDataBaseModel.Store.Routes" store:Type="Tables" Schema="dbo" />
+    <EntitySet Name="RoutesStations" EntityType="RouteScheduleDataBaseModel.Store.RoutesStations" store:Type="Tables" Schema="dbo" />
+    <EntitySet Name="Stations" EntityType="RouteScheduleDataBaseModel.Store.Stations" store:Type="Tables" Schema="dbo" />
+    <EntitySet Name="sysdiagrams" EntityType="RouteScheduleDataBaseModel.Store.sysdiagrams" store:Type="Tables" Schema="dbo" />
+    <EntitySet Name="Tickets" EntityType="RouteScheduleDataBaseModel.Store.Tickets" store:Type="Tables" Schema="dbo" />
+    <EntitySet Name="Trains" EntityType="RouteScheduleDataBaseModel.Store.Trains" store:Type="Tables" Schema="dbo" />
+    <EntitySet Name="Trips" EntityType="RouteScheduleDataBaseModel.Store.Trips" store:Type="Tables" Schema="dbo" />
+    <EntitySet Name="Users" EntityType="RouteScheduleDataBaseModel.Store.Users" store:Type="Tables" Schema="dbo" />
+    <AssociationSet Name="FK_Carriages_Trains" Association="RouteScheduleDataBaseModel.Store.FK_Carriages_Trains">
+      <End Role="Trains" EntitySet="Trains" />
+      <End Role="Carriages" EntitySet="Carriages" />
+    </AssociationSet>
+    <AssociationSet Name="FK_Tickets_Carriages" Association="RouteScheduleDataBaseModel.Store.FK_Tickets_Carriages">
+      <End Role="Carriages" EntitySet="Carriages" />
+      <End Role="Tickets" EntitySet="Tickets" />
+    </AssociationSet>
+    <AssociationSet Name="FK_RoutesStations_Routes" Association="RouteScheduleDataBaseModel.Store.FK_RoutesStations_Routes">
+      <End Role="Routes" EntitySet="Routes" />
+      <End Role="RoutesStations" EntitySet="RoutesStations" />
+    </AssociationSet>
+    <AssociationSet Name="FK_Trips_Routes" Association="RouteScheduleDataBaseModel.Store.FK_Trips_Routes">
+      <End Role="Routes" EntitySet="Routes" />
+      <End Role="Trips" EntitySet="Trips" />
+    </AssociationSet>
+    <AssociationSet Name="FK_RoutesStations_Stations" Association="RouteScheduleDataBaseModel.Store.FK_RoutesStations_Stations">
+      <End Role="Stations" EntitySet="Stations" />
+      <End Role="RoutesStations" EntitySet="RoutesStations" />
+    </AssociationSet>
+    <AssociationSet Name="FK_Tickets_Trips" Association="RouteScheduleDataBaseModel.Store.FK_Tickets_Trips">
+      <End Role="Trips" EntitySet="Trips" />
+      <End Role="Tickets" EntitySet="Tickets" />
+    </AssociationSet>
+    <AssociationSet Name="FK_Tickets_Users" Association="RouteScheduleDataBaseModel.Store.FK_Tickets_Users">
+      <End Role="Users" EntitySet="Users" />
+      <End Role="Tickets" EntitySet="Tickets" />
+    </AssociationSet>
+    <AssociationSet Name="FK_Trips_Trains" Association="RouteScheduleDataBaseModel.Store.FK_Trips_Trains">
+      <End Role="Trains" EntitySet="Trains" />
+      <End Role="Trips" EntitySet="Trips" />
+    </AssociationSet>
+  </EntityContainer>
+  <EntityType Name="Carriages">
+    <Key>
+      <PropertyRef Name="IdCarriage" />
+    </Key>
+    <Property Name="IdCarriage" Type="int" Nullable="false" />
+    <Property Name="IdTrain" Type="int" Nullable="false" />
+    <Property Name="Places" Type="int" Nullable="false" />
+    <Property Name="Category" Type="nvarchar" Nullable="false" MaxLength="50" />
+  </EntityType>
+  <EntityType Name="Routes">
+    <Key>
+      <PropertyRef Name="IdRoute" />
+    </Key>
+    <Property Name="IdRoute" Type="int" Nullable="false" />
+    <Property Name="Name" Type="nvarchar" Nullable="true" MaxLength="50" />
+  </EntityType>
+  <EntityType Name="RoutesStations">
+    <Key>
+      <PropertyRef Name="IdRouteStation" />
+    </Key>
+    <Property Name="IdRouteStation" Type="int" Nullable="false" />
+    <Property Name="IdRoute" Type="int" Nullable="false" />
+    <Property Name="IdStation" Type="int" Nullable="false" />
+    <Property Name="StopTime" Type="time" Nullable="false" Precision="7" />
+    <Property Name="TravelTime" Type="time" Nullable="false" Precision="7" />
+  </EntityType>
+  <EntityType Name="Stations">
+    <Key>
+      <PropertyRef Name="IdStation" />
+    </Key>
+    <Property Name="IdStation" Type="int" Nullable="false" />
+    <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Location" Type="nvarchar" Nullable="false" MaxLength="50" />
+  </EntityType>
+  <EntityType Name="sysdiagrams">
+    <Key>
+      <PropertyRef Name="diagram_id" />
+    </Key>
+    <Property Name="name" Type="nvarchar" Nullable="false" MaxLength="128" />
+    <Property Name="principal_id" Type="int" Nullable="false" />
+    <Property Name="diagram_id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+    <Property Name="version" Type="int" Nullable="true" />
+    <Property Name="definition" Type="varbinary(max)" Nullable="true" />
+  </EntityType>
+  <EntityType Name="Tickets">
+    <Key>
+      <PropertyRef Name="IdTicket" />
+    </Key>
+    <Property Name="IdTicket" Type="int" Nullable="false" />
+    <Property Name="IdUser" 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="BuyDate" Type="datetime" Nullable="false" />
+  </EntityType>
+  <EntityType Name="Trains">
+    <Key>
+      <PropertyRef Name="IdTrain" />
+    </Key>
+    <Property Name="IdTrain" Type="int" Nullable="false" />
+    <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Category" Type="nvarchar" Nullable="false" MaxLength="50" />
+  </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="datetime" Nullable="false" />
+  </EntityType>
+  <EntityType Name="Users">
+    <Key>
+      <PropertyRef Name="IdUser" />
+    </Key>
+    <Property Name="IdUser" Type="int" Nullable="false" />
+    <Property Name="Login" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Password" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Passport" Type="nvarchar" Nullable="false" MaxLength="10" />
+    <Property Name="Surname" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Name" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Patronymic" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="Permissions" Type="int" Nullable="false" />
+    <Property Name="Email" Type="nvarchar" Nullable="false" MaxLength="50" />
+    <Property Name="PhoneNum" Type="nvarchar" Nullable="false" MaxLength="11" />
+    <Property Name="Image" Type="varbinary(max)" Nullable="true" />
+  </EntityType>
+  <Association Name="FK_Carriages_Trains">
+    <End Role="Trains" Type="RouteScheduleDataBaseModel.Store.Trains" Multiplicity="1" />
+    <End Role="Carriages" Type="RouteScheduleDataBaseModel.Store.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 Role="Carriages" Type="RouteScheduleDataBaseModel.Store.Carriages" Multiplicity="1" />
+    <End Role="Tickets" Type="RouteScheduleDataBaseModel.Store.Tickets" Multiplicity="*" />
+    <ReferentialConstraint>
+      <Principal Role="Carriages">
+        <PropertyRef Name="IdCarriage" />
+      </Principal>
+      <Dependent Role="Tickets">
+        <PropertyRef Name="IdCarriage" />
+      </Dependent>
+    </ReferentialConstraint>
+  </Association>
+  <Association Name="FK_RoutesStations_Routes">
+    <End Role="Routes" Type="RouteScheduleDataBaseModel.Store.Routes" Multiplicity="1" />
+    <End Role="RoutesStations" Type="RouteScheduleDataBaseModel.Store.RoutesStations" Multiplicity="*" />
+    <ReferentialConstraint>
+      <Principal Role="Routes">
+        <PropertyRef Name="IdRoute" />
+      </Principal>
+      <Dependent Role="RoutesStations">
+        <PropertyRef Name="IdRoute" />
+      </Dependent>
+    </ReferentialConstraint>
+  </Association>
+  <Association Name="FK_Trips_Routes">
+    <End Role="Routes" Type="RouteScheduleDataBaseModel.Store.Routes" Multiplicity="1" />
+    <End Role="Trips" Type="RouteScheduleDataBaseModel.Store.Trips" Multiplicity="*" />
+    <ReferentialConstraint>
+      <Principal Role="Routes">
+        <PropertyRef Name="IdRoute" />
+      </Principal>
+      <Dependent Role="Trips">
+        <PropertyRef Name="IdRoute" />
+      </Dependent>
+    </ReferentialConstraint>
+  </Association>
+  <Association Name="FK_RoutesStations_Stations">
+    <End Role="Stations" Type="RouteScheduleDataBaseModel.Store.Stations" Multiplicity="1" />
+    <End Role="RoutesStations" Type="RouteScheduleDataBaseModel.Store.RoutesStations" Multiplicity="*" />
+    <ReferentialConstraint>
+      <Principal Role="Stations">
+        <PropertyRef Name="IdStation" />
+      </Principal>
+      <Dependent Role="RoutesStations">
+        <PropertyRef Name="IdStation" />
+      </Dependent>
+    </ReferentialConstraint>
+  </Association>
+  <Association Name="FK_Tickets_Trips">
+    <End Role="Trips" Type="RouteScheduleDataBaseModel.Store.Trips" Multiplicity="1" />
+    <End Role="Tickets" Type="RouteScheduleDataBaseModel.Store.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 Role="Users" Type="RouteScheduleDataBaseModel.Store.Users" Multiplicity="1" />
+    <End Role="Tickets" Type="RouteScheduleDataBaseModel.Store.Tickets" Multiplicity="*" />
+    <ReferentialConstraint>
+      <Principal Role="Users">
+        <PropertyRef Name="IdUser" />
+      </Principal>
+      <Dependent Role="Tickets">
+        <PropertyRef Name="IdUser" />
+      </Dependent>
+    </ReferentialConstraint>
+  </Association>
+  <Association Name="FK_Trips_Trains">
+    <End Role="Trains" Type="RouteScheduleDataBaseModel.Store.Trains" Multiplicity="1" />
+    <End Role="Trips" Type="RouteScheduleDataBaseModel.Store.Trips" Multiplicity="*" />
+    <ReferentialConstraint>
+      <Principal Role="Trains">
+        <PropertyRef Name="IdTrain" />
+      </Principal>
+      <Dependent Role="Trips">
+        <PropertyRef Name="IdTrain" />
+      </Dependent>
+    </ReferentialConstraint>
+  </Association>
+</Schema></edmx:StorageModels>
     <!-- CSDL content -->
     <edmx:ConceptualModels>
       <Schema Namespace="RouteScheduleDataBaseModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
@@ -485,104 +485,104 @@
     <edmx:Mappings>
     <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
   <EntityContainerMapping StorageEntityContainer="RouteScheduleDataBaseModelStoreContainer" CdmEntityContainer="RouteScheduleDataBaseEntities">
-          <EntitySetMapping Name="Carriages">
-            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Carriages">
-              <MappingFragment StoreEntitySet="Carriages">
-                <ScalarProperty Name="Category" ColumnName="Category" />
-                <ScalarProperty Name="Places" ColumnName="Places" />
-                <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
-                <ScalarProperty Name="IdCarriage" ColumnName="IdCarriage" />
-              </MappingFragment>
-            </EntityTypeMapping>
-          </EntitySetMapping>
-          <EntitySetMapping Name="Routes">
-            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Routes">
-              <MappingFragment StoreEntitySet="Routes">
-                <ScalarProperty Name="Name" ColumnName="Name" />
-                <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
-              </MappingFragment>
-            </EntityTypeMapping>
-          </EntitySetMapping>
-          <EntitySetMapping Name="RoutesStations">
-            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.RoutesStations">
-              <MappingFragment StoreEntitySet="RoutesStations">
-                <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" />
-              </MappingFragment>
-            </EntityTypeMapping>
-          </EntitySetMapping>
-          <EntitySetMapping Name="Stations">
-            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Stations">
-              <MappingFragment StoreEntitySet="Stations">
-                <ScalarProperty Name="Location" ColumnName="Location" />
-                <ScalarProperty Name="Name" ColumnName="Name" />
-                <ScalarProperty Name="IdStation" ColumnName="IdStation" />
-              </MappingFragment>
-            </EntityTypeMapping>
-          </EntitySetMapping>
-          <EntitySetMapping Name="sysdiagrams">
-            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.sysdiagrams">
-              <MappingFragment StoreEntitySet="sysdiagrams">
-                <ScalarProperty Name="definition" ColumnName="definition" />
-                <ScalarProperty Name="version" ColumnName="version" />
-                <ScalarProperty Name="diagram_id" ColumnName="diagram_id" />
-                <ScalarProperty Name="principal_id" ColumnName="principal_id" />
-                <ScalarProperty Name="name" ColumnName="name" />
-              </MappingFragment>
-            </EntityTypeMapping>
-          </EntitySetMapping>
-          <EntitySetMapping Name="Tickets">
-            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Tickets">
-              <MappingFragment StoreEntitySet="Tickets">
-                <ScalarProperty Name="BuyDate" ColumnName="BuyDate" />
-                <ScalarProperty Name="PlaceNumber" ColumnName="PlaceNumber" />
-                <ScalarProperty Name="IdCarriage" ColumnName="IdCarriage" />
-                <ScalarProperty Name="IdTrip" ColumnName="IdTrip" />
-                <ScalarProperty Name="IdUser" ColumnName="IdUser" />
-                <ScalarProperty Name="IdTicket" ColumnName="IdTicket" />
-              </MappingFragment>
-            </EntityTypeMapping>
-          </EntitySetMapping>
-          <EntitySetMapping Name="Trains">
-            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Trains">
-              <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="Image" ColumnName="Image" />
-                <ScalarProperty Name="PhoneNum" ColumnName="PhoneNum" />
-                <ScalarProperty Name="Email" ColumnName="Email" />
-                <ScalarProperty Name="Permissions" ColumnName="Permissions" />
-                <ScalarProperty Name="Patronymic" ColumnName="Patronymic" />
-                <ScalarProperty Name="Name" ColumnName="Name" />
-                <ScalarProperty Name="Surname" ColumnName="Surname" />
-                <ScalarProperty Name="Passport" ColumnName="Passport" />
-                <ScalarProperty Name="Password" ColumnName="Password" />
-                <ScalarProperty Name="Login" ColumnName="Login" />
-                <ScalarProperty Name="IdUser" ColumnName="IdUser" />
-              </MappingFragment>
-            </EntityTypeMapping>
-          </EntitySetMapping>
-        </EntityContainerMapping>
+    <EntitySetMapping Name="Carriages">
+      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.Carriages)">
+        <MappingFragment StoreEntitySet="Carriages">
+          <ScalarProperty Name="IdCarriage" ColumnName="IdCarriage" />
+          <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
+          <ScalarProperty Name="Places" ColumnName="Places" />
+          <ScalarProperty Name="Category" ColumnName="Category" />
+        </MappingFragment>
+      </EntityTypeMapping>
+    </EntitySetMapping>
+    <EntitySetMapping Name="Routes">
+      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.Routes)">
+        <MappingFragment StoreEntitySet="Routes">
+          <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
+          <ScalarProperty Name="Name" ColumnName="Name" />
+        </MappingFragment>
+      </EntityTypeMapping>
+    </EntitySetMapping>
+    <EntitySetMapping Name="RoutesStations">
+      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.RoutesStations)">
+        <MappingFragment StoreEntitySet="RoutesStations">
+          <ScalarProperty Name="IdRouteStation" ColumnName="IdRouteStation" />
+          <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
+          <ScalarProperty Name="IdStation" ColumnName="IdStation" />
+          <ScalarProperty Name="StopTime" ColumnName="StopTime" />
+          <ScalarProperty Name="TravelTime" ColumnName="TravelTime" />
+        </MappingFragment>
+      </EntityTypeMapping>
+    </EntitySetMapping>
+    <EntitySetMapping Name="Stations">
+      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.Stations)">
+        <MappingFragment StoreEntitySet="Stations">
+          <ScalarProperty Name="IdStation" ColumnName="IdStation" />
+          <ScalarProperty Name="Name" ColumnName="Name" />
+          <ScalarProperty Name="Location" ColumnName="Location" />
+        </MappingFragment>
+      </EntityTypeMapping>
+    </EntitySetMapping>
+    <EntitySetMapping Name="sysdiagrams">
+      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.sysdiagrams)">
+        <MappingFragment StoreEntitySet="sysdiagrams">
+          <ScalarProperty Name="diagram_id" ColumnName="diagram_id" />
+          <ScalarProperty Name="name" ColumnName="name" />
+          <ScalarProperty Name="principal_id" ColumnName="principal_id" />
+          <ScalarProperty Name="version" ColumnName="version" />
+          <ScalarProperty Name="definition" ColumnName="definition" />
+        </MappingFragment>
+      </EntityTypeMapping>
+    </EntitySetMapping>
+    <EntitySetMapping Name="Tickets">
+      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.Tickets)">
+        <MappingFragment StoreEntitySet="Tickets">
+          <ScalarProperty Name="IdTicket" ColumnName="IdTicket" />
+          <ScalarProperty Name="IdUser" ColumnName="IdUser" />
+          <ScalarProperty Name="IdTrip" ColumnName="IdTrip" />
+          <ScalarProperty Name="IdCarriage" ColumnName="IdCarriage" />
+          <ScalarProperty Name="PlaceNumber" ColumnName="PlaceNumber" />
+          <ScalarProperty Name="BuyDate" ColumnName="BuyDate" />
+        </MappingFragment>
+      </EntityTypeMapping>
+    </EntitySetMapping>
+    <EntitySetMapping Name="Trains">
+      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.Trains)">
+        <MappingFragment StoreEntitySet="Trains">
+          <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
+          <ScalarProperty Name="Name" ColumnName="Name" />
+          <ScalarProperty Name="Category" ColumnName="Category" />
+        </MappingFragment>
+      </EntityTypeMapping>
+    </EntitySetMapping>
+    <EntitySetMapping Name="Trips">
+      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.Trips)">
+        <MappingFragment StoreEntitySet="Trips">
+          <ScalarProperty Name="IdTrip" ColumnName="IdTrip" />
+          <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
+          <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
+          <ScalarProperty Name="TripStartDate" ColumnName="TripStartDate" />
+        </MappingFragment>
+      </EntityTypeMapping>
+    </EntitySetMapping>
+    <EntitySetMapping Name="Users">
+      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.Users)">
+        <MappingFragment StoreEntitySet="Users">
+          <ScalarProperty Name="IdUser" ColumnName="IdUser" />
+          <ScalarProperty Name="Login" ColumnName="Login" />
+          <ScalarProperty Name="Password" ColumnName="Password" />
+          <ScalarProperty Name="Passport" ColumnName="Passport" />
+          <ScalarProperty Name="Surname" ColumnName="Surname" />
+          <ScalarProperty Name="Name" ColumnName="Name" />
+          <ScalarProperty Name="Patronymic" ColumnName="Patronymic" />
+          <ScalarProperty Name="Permissions" ColumnName="Permissions" />
+          <ScalarProperty Name="Email" ColumnName="Email" />
+          <ScalarProperty Name="PhoneNum" ColumnName="PhoneNum" />
+          <ScalarProperty Name="Image" ColumnName="Image" />
+        </MappingFragment>
+      </EntityTypeMapping>
+    </EntitySetMapping>
+  </EntityContainerMapping>
 </Mapping></edmx:Mappings>
   </edmx:Runtime>
   <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->

+ 112 - 43
RaspisKusach/EDM.edmx.sql

@@ -2,8 +2,8 @@
 -- --------------------------------------------------
 -- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
 -- --------------------------------------------------
+-- Date Created: 09/21/2022 19:18:18
+-- Generated from EDMX file: C:\Users\Imagara\source\repos\RaspisKusach\RaspisKusach\EDM.edmx
 -- --------------------------------------------------
 
 SET QUOTED_IDENTIFIER OFF;
@@ -17,24 +17,30 @@ GO
 -- Dropping existing FOREIGN KEY constraints
 -- --------------------------------------------------
 
-IF OBJECT_ID(N'[dbo].[FK_Routes_Trains]', 'F') IS NOT NULL
-    ALTER TABLE [dbo].[Routes] DROP CONSTRAINT [FK_Routes_Trains];
+IF OBJECT_ID(N'[dbo].[FK_Carriages_Trains]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[Carriages] DROP CONSTRAINT [FK_Carriages_Trains];
 GO
 IF OBJECT_ID(N'[dbo].[FK_RoutesStations_Routes]', 'F') IS NOT NULL
     ALTER TABLE [dbo].[RoutesStations] DROP CONSTRAINT [FK_RoutesStations_Routes];
 GO
-IF OBJECT_ID(N'[dbo].[FK_RoutesStations_Station]', 'F') IS NOT NULL
-    ALTER TABLE [dbo].[RoutesStations] DROP CONSTRAINT [FK_RoutesStations_Station];
+IF OBJECT_ID(N'[dbo].[FK_RoutesStations_Stations]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[RoutesStations] DROP CONSTRAINT [FK_RoutesStations_Stations];
 GO
 IF OBJECT_ID(N'[dbo].[FK_Tickets_Carriages]', 'F') IS NOT NULL
     ALTER TABLE [dbo].[Tickets] DROP CONSTRAINT [FK_Tickets_Carriages];
 GO
-IF OBJECT_ID(N'[dbo].[FK_Tickets_Routes]', 'F') IS NOT NULL
-    ALTER TABLE [dbo].[Tickets] DROP CONSTRAINT [FK_Tickets_Routes];
+IF OBJECT_ID(N'[dbo].[FK_Tickets_Trips]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[Tickets] DROP CONSTRAINT [FK_Tickets_Trips];
 GO
 IF OBJECT_ID(N'[dbo].[FK_Tickets_Users]', 'F') IS NOT NULL
     ALTER TABLE [dbo].[Tickets] DROP CONSTRAINT [FK_Tickets_Users];
 GO
+IF OBJECT_ID(N'[dbo].[FK_Trips_Routes]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[Trips] DROP CONSTRAINT [FK_Trips_Routes];
+GO
+IF OBJECT_ID(N'[dbo].[FK_Trips_Trains]', 'F') IS NOT NULL
+    ALTER TABLE [dbo].[Trips] DROP CONSTRAINT [FK_Trips_Trains];
+GO
 
 -- --------------------------------------------------
 -- Dropping existing tables
@@ -49,8 +55,8 @@ GO
 IF OBJECT_ID(N'[dbo].[RoutesStations]', 'U') IS NOT NULL
     DROP TABLE [dbo].[RoutesStations];
 GO
-IF OBJECT_ID(N'[dbo].[Station]', 'U') IS NOT NULL
-    DROP TABLE [dbo].[Station];
+IF OBJECT_ID(N'[dbo].[Stations]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[Stations];
 GO
 IF OBJECT_ID(N'[dbo].[sysdiagrams]', 'U') IS NOT NULL
     DROP TABLE [dbo].[sysdiagrams];
@@ -61,6 +67,9 @@ GO
 IF OBJECT_ID(N'[dbo].[Trains]', 'U') IS NOT NULL
     DROP TABLE [dbo].[Trains];
 GO
+IF OBJECT_ID(N'[dbo].[Trips]', 'U') IS NOT NULL
+    DROP TABLE [dbo].[Trips];
+GO
 IF OBJECT_ID(N'[dbo].[Users]', 'U') IS NOT NULL
     DROP TABLE [dbo].[Users];
 GO
@@ -72,16 +81,16 @@ GO
 -- Creating table 'Carriages'
 CREATE TABLE [dbo].[Carriages] (
     [IdCarriage] int  NOT NULL,
-    [Count] int  NOT NULL
+    [IdTrain] int  NOT NULL,
+    [Places] int  NOT NULL,
+    [Category] nvarchar(50)  NOT NULL
 );
 GO
 
 -- Creating table 'Routes'
 CREATE TABLE [dbo].[Routes] (
     [IdRoute] int  NOT NULL,
-    [IdTrain] int  NOT NULL,
-    [Departure_Date] datetime  NOT NULL,
-    [Arrival_Date] datetime  NOT NULL
+    [Name] nvarchar(50)  NULL
 );
 GO
 
@@ -89,12 +98,14 @@ GO
 CREATE TABLE [dbo].[RoutesStations] (
     [IdRouteStation] int  NOT NULL,
     [IdRoute] int  NOT NULL,
-    [IdStation] int  NOT NULL
+    [IdStation] int  NOT NULL,
+    [StopTime] time  NOT NULL,
+    [TravelTime] time  NOT NULL
 );
 GO
 
-CREATE TABLE [dbo].[Station] (
+-- Creating table 'Stations'
+CREATE TABLE [dbo].[Stations] (
     [IdStation] int  NOT NULL,
     [Name] nvarchar(50)  NOT NULL,
     [Location] nvarchar(50)  NOT NULL
@@ -115,10 +126,9 @@ GO
 CREATE TABLE [dbo].[Tickets] (
     [IdTicket] int  NOT NULL,
     [IdUser] int  NOT NULL,
-    [IdRoute] int  NOT NULL,
+    [IdTrip] int  NOT NULL,
     [IdCarriage] int  NOT NULL,
     [PlaceNumber] int  NOT NULL,
-    [Category] int  NOT NULL,
     [BuyDate] datetime  NOT NULL
 );
 GO
@@ -126,7 +136,17 @@ GO
 -- Creating table 'Trains'
 CREATE TABLE [dbo].[Trains] (
     [IdTrain] int  NOT NULL,
-    [NameOfTrain] nvarchar(50)  NOT NULL
+    [Name] nvarchar(50)  NOT NULL,
+    [Category] nvarchar(50)  NOT NULL
+);
+GO
+
+-- Creating table 'Trips'
+CREATE TABLE [dbo].[Trips] (
+    [IdTrip] int  NOT NULL,
+    [IdTrain] int  NOT NULL,
+    [IdRoute] int  NOT NULL,
+    [TripStartDate] datetime  NOT NULL
 );
 GO
 
@@ -135,10 +155,14 @@ CREATE TABLE [dbo].[Users] (
     [IdUser] int  NOT NULL,
     [Login] nvarchar(50)  NOT NULL,
     [Password] nvarchar(50)  NOT NULL,
-    [Passport] nvarchar(10)  NULL,
-    [Surname] nvarchar(50)  NULL,
-    [Name] nvarchar(50)  NULL,
-    [Patronymic] nvarchar(50)  NULL
+    [Passport] nvarchar(10)  NOT NULL,
+    [Surname] nvarchar(50)  NOT NULL,
+    [Name] nvarchar(50)  NOT NULL,
+    [Patronymic] nvarchar(50)  NOT NULL,
+    [Permissions] int  NOT NULL,
+    [Email] nvarchar(50)  NOT NULL,
+    [PhoneNum] nvarchar(11)  NOT NULL,
+    [Image] varbinary(max)  NULL
 );
 GO
 
@@ -164,9 +188,9 @@ ADD CONSTRAINT [PK_RoutesStations]
     PRIMARY KEY CLUSTERED ([IdRouteStation] ASC);
 GO
 
-ALTER TABLE [dbo].[Station]
-ADD CONSTRAINT [PK_Station]
+-- Creating primary key on [IdStation] in table 'Stations'
+ALTER TABLE [dbo].[Stations]
+ADD CONSTRAINT [PK_Stations]
     PRIMARY KEY CLUSTERED ([IdStation] ASC);
 GO
 
@@ -188,6 +212,12 @@ ADD CONSTRAINT [PK_Trains]
     PRIMARY KEY CLUSTERED ([IdTrain] ASC);
 GO
 
+-- Creating primary key on [IdTrip] in table 'Trips'
+ALTER TABLE [dbo].[Trips]
+ADD CONSTRAINT [PK_Trips]
+    PRIMARY KEY CLUSTERED ([IdTrip] ASC);
+GO
+
 -- Creating primary key on [IdUser] in table 'Users'
 ALTER TABLE [dbo].[Users]
 ADD CONSTRAINT [PK_Users]
@@ -198,6 +228,21 @@ GO
 -- Creating all FOREIGN KEY constraints
 -- --------------------------------------------------
 
+-- Creating foreign key on [IdTrain] in table 'Carriages'
+ALTER TABLE [dbo].[Carriages]
+ADD CONSTRAINT [FK_Carriages_Trains]
+    FOREIGN KEY ([IdTrain])
+    REFERENCES [dbo].[Trains]
+        ([IdTrain])
+    ON DELETE NO ACTION ON UPDATE NO ACTION;
+GO
+
+-- Creating non-clustered index for FOREIGN KEY 'FK_Carriages_Trains'
+CREATE INDEX [IX_FK_Carriages_Trains]
+ON [dbo].[Carriages]
+    ([IdTrain]);
+GO
+
 -- Creating foreign key on [IdCarriage] in table 'Tickets'
 ALTER TABLE [dbo].[Tickets]
 ADD CONSTRAINT [FK_Tickets_Carriages]
@@ -213,21 +258,6 @@ ON [dbo].[Tickets]
     ([IdCarriage]);
 GO
 
-ALTER TABLE [dbo].[Routes]
-ADD CONSTRAINT [FK_Routes_Trains]
-    FOREIGN KEY ([IdTrain])
-    REFERENCES [dbo].[Trains]
-        ([IdTrain])
-    ON DELETE NO ACTION ON UPDATE NO ACTION;
-GO
-
-CREATE INDEX [IX_FK_Routes_Trains]
-ON [dbo].[Routes]
-    ([IdTrain]);
-GO
-
 -- Creating foreign key on [IdRoute] in table 'RoutesStations'
 ALTER TABLE [dbo].[RoutesStations]
 ADD CONSTRAINT [FK_RoutesStations_Routes]
@@ -243,36 +273,51 @@ ON [dbo].[RoutesStations]
     ([IdRoute]);
 GO
 
-ALTER TABLE [dbo].[Tickets]
-ADD CONSTRAINT [FK_Tickets_Routes]
+-- Creating foreign key on [IdRoute] in table 'Trips'
+ALTER TABLE [dbo].[Trips]
+ADD CONSTRAINT [FK_Trips_Routes]
     FOREIGN KEY ([IdRoute])
     REFERENCES [dbo].[Routes]
         ([IdRoute])
     ON DELETE NO ACTION ON UPDATE NO ACTION;
 GO
 
-CREATE INDEX [IX_FK_Tickets_Routes]
-ON [dbo].[Tickets]
+-- Creating non-clustered index for FOREIGN KEY 'FK_Trips_Routes'
+CREATE INDEX [IX_FK_Trips_Routes]
+ON [dbo].[Trips]
     ([IdRoute]);
 GO
 
 -- Creating foreign key on [IdStation] in table 'RoutesStations'
 ALTER TABLE [dbo].[RoutesStations]
-ADD CONSTRAINT [FK_RoutesStations_Station]
+ADD CONSTRAINT [FK_RoutesStations_Stations]
     FOREIGN KEY ([IdStation])
-    REFERENCES [dbo].[Station]
+    REFERENCES [dbo].[Stations]
         ([IdStation])
     ON DELETE NO ACTION ON UPDATE NO ACTION;
 GO
 
-CREATE INDEX [IX_FK_RoutesStations_Station]
+-- Creating non-clustered index for FOREIGN KEY 'FK_RoutesStations_Stations'
+CREATE INDEX [IX_FK_RoutesStations_Stations]
 ON [dbo].[RoutesStations]
     ([IdStation]);
 GO
 
+-- Creating foreign key on [IdTrip] in table 'Tickets'
+ALTER TABLE [dbo].[Tickets]
+ADD CONSTRAINT [FK_Tickets_Trips]
+    FOREIGN KEY ([IdTrip])
+    REFERENCES [dbo].[Trips]
+        ([IdTrip])
+    ON DELETE NO ACTION ON UPDATE NO ACTION;
+GO
+
+-- Creating non-clustered index for FOREIGN KEY 'FK_Tickets_Trips'
+CREATE INDEX [IX_FK_Tickets_Trips]
+ON [dbo].[Tickets]
+    ([IdTrip]);
+GO
+
 -- Creating foreign key on [IdUser] in table 'Tickets'
 ALTER TABLE [dbo].[Tickets]
 ADD CONSTRAINT [FK_Tickets_Users]
@@ -288,6 +333,21 @@ ON [dbo].[Tickets]
     ([IdUser]);
 GO
 
+-- Creating foreign key on [IdTrain] in table 'Trips'
+ALTER TABLE [dbo].[Trips]
+ADD CONSTRAINT [FK_Trips_Trains]
+    FOREIGN KEY ([IdTrain])
+    REFERENCES [dbo].[Trains]
+        ([IdTrain])
+    ON DELETE NO ACTION ON UPDATE NO ACTION;
+GO
+
+-- Creating non-clustered index for FOREIGN KEY 'FK_Trips_Trains'
+CREATE INDEX [IX_FK_Trips_Trains]
+ON [dbo].[Trips]
+    ([IdTrain]);
+GO
+
 -- --------------------------------------------------
 -- Script has ended
 -- --------------------------------------------------

+ 5 - 2
RaspisKusach/Pages/LoginPage.xaml.cs

@@ -27,8 +27,11 @@ namespace RaspisKusach.Pages
                     new ErrorWindow("Неверный логин или пароль").Show();
                 else
                 {
-                    Session.User = cnt.db.Users.Where(item => item.Login == LogBox.Text).FirstOrDefault();
-                    NavigationService.Navigate(new MenuPage());
+                    Users user = cnt.db.Users.Where(item => item.Login == LogBox.Text).FirstOrDefault();
+                    Session.User = user;
+                    if (user.Permissions == 1)
+                        Session.AdministrationPageOpenButton.Visibility = Visibility.Visible;
+                    NavigationService.Navigate(new ProfilePage());
                 }
             }
             catch

+ 1 - 1
RaspisKusach/Pages/MenuPage.xaml

@@ -45,7 +45,7 @@
                     Height="40"
                     Content="Администрирование"
                     Margin="10,0,10,0"
-                    Visibility="Visible"
+                    Visibility="Collapsed"
                     Click="AdministrationButton_Click">
             </Button>
         </StackPanel>

+ 10 - 1
RaspisKusach/Pages/MenuPage.xaml.cs

@@ -8,18 +8,22 @@ namespace RaspisKusach.Pages
         public MenuPage()
         {
             InitializeComponent();
+            Session.AdministrationPageOpenButton = AdministrationButton;
         }
 
         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
@@ -27,10 +31,15 @@ namespace RaspisKusach.Pages
         }
         private void AdministrationButton_Click(object sender, RoutedEventArgs e)
         {
-            if (Session.User == null || Session.User.Permissions == 1)
+            if (Session.User != null && Session.User.Permissions == 1)
                 MainContentFrame.Content = new AdministrationPage();
             else
                 ((Button)sender).Visibility = Visibility.Collapsed;
         }
+        void UserLogout()
+        {
+            Session.User = null;
+            Session.AdministrationPageOpenButton.Visibility = Visibility.Collapsed;
+        }
     }
 }

+ 2 - 0
RaspisKusach/Session.cs

@@ -1,9 +1,11 @@
 using System.Linq;
+using System.Windows.Controls;
 
 namespace RaspisKusach
 {
     class Session
     {
+        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();
     }