Imagara il y a 2 ans
Parent
commit
1690cb91d3

+ 2 - 2
RaspisKusach/TrainsCarriages.cs

@@ -12,10 +12,10 @@ namespace RaspisKusach
     using System;
     using System.Collections.Generic;
     
-    public partial class TrainsCarriages
+    public partial class Carriages
     {
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
-        public TrainsCarriages()
+        public Carriages()
         {
             this.Tickets = new HashSet<Tickets>();
         }

+ 4 - 2
RaspisKusach/EDM.Context.cs

@@ -25,11 +25,13 @@ namespace RaspisKusach
             throw new UnintentionalCodeFirstException();
         }
     
+        public virtual DbSet<Carriages> Carriages { get; set; }
         public virtual DbSet<Routes> Routes { get; set; }
-        public virtual DbSet<TestTable> TestTable { get; set; }
+        public virtual DbSet<RoutesStations> RoutesStations { get; set; }
+        public virtual DbSet<Station> Station { get; set; }
+        public virtual DbSet<sysdiagrams> sysdiagrams { get; set; }
         public virtual DbSet<Tickets> Tickets { get; set; }
         public virtual DbSet<Trains> Trains { get; set; }
-        public virtual DbSet<TrainsCarriages> TrainsCarriages { get; set; }
         public virtual DbSet<Users> Users { get; set; }
     }
 }

+ 1 - 1
RaspisKusach/EDM.Designer.cs

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

+ 241 - 128
RaspisKusach/EDM.edmx

@@ -5,27 +5,47 @@
     <!-- 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="Count" 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="Departure_Station" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="Arrival_Station" Type="nvarchar" MaxLength="50" Nullable="false" />
           <Property Name="Departure_Date" Type="datetime" Nullable="false" />
           <Property Name="Arrival_Date" Type="datetime" Nullable="false" />
         </EntityType>
-        <EntityType Name="TestTable">
+        <EntityType Name="RoutesStations">
           <Key>
-            <PropertyRef Name="IdRoute" />
+            <PropertyRef Name="IdRouteStation" />
           </Key>
+          <Property Name="IdRouteStation" Type="int" Nullable="false" />
           <Property Name="IdRoute" Type="int" Nullable="false" />
-          <Property Name="IdTrain" Type="int" Nullable="false" />
-          <Property Name="Departure" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="Arrival" Type="nvarchar" MaxLength="50" Nullable="false" />
-          <Property Name="DepartureDate" Type="datetime" Nullable="false" />
-          <Property Name="ArrivalDate" Type="datetime" Nullable="false" />
+          <Property Name="IdStation" Type="int" Nullable="false" />
+        </EntityType>
+        <EntityType Name="Station">
+          <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>
@@ -34,7 +54,7 @@
           <Property Name="IdTicket" Type="int" Nullable="false" />
           <Property Name="IdUser" Type="int" Nullable="false" />
           <Property Name="IdRoute" Type="int" Nullable="false" />
-          <Property Name="IdTrainCarriage" 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" />
           <Property Name="BuyDate" Type="datetime" Nullable="false" />
@@ -46,13 +66,6 @@
           <Property Name="IdTrain" Type="int" Nullable="false" />
           <Property Name="NameOfTrain" Type="nvarchar" MaxLength="50" Nullable="false" />
         </EntityType>
-        <EntityType Name="TrainsCarriages">
-          <Key>
-            <PropertyRef Name="IdCarriage" />
-          </Key>
-          <Property Name="IdCarriage" Type="int" Nullable="false" />
-          <Property Name="Count" Type="int" Nullable="false" />
-        </EntityType>
         <EntityType Name="Users">
           <Key>
             <PropertyRef Name="IdUser" />
@@ -77,27 +90,51 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
-        <Association Name="FK_Tickets_Routes">
+        <Association Name="FK_RoutesStations_Routes">
           <End Role="Routes" Type="Self.Routes" Multiplicity="1" />
-          <End Role="Tickets" Type="Self.Tickets" Multiplicity="*" />
+          <End Role="RoutesStations" Type="Self.RoutesStations" Multiplicity="*" />
           <ReferentialConstraint>
             <Principal Role="Routes">
               <PropertyRef Name="IdRoute" />
             </Principal>
-            <Dependent Role="Tickets">
+            <Dependent Role="RoutesStations">
               <PropertyRef Name="IdRoute" />
             </Dependent>
           </ReferentialConstraint>
         </Association>
-        <Association Name="FK_Tickets_TrainsCarriages">
-          <End Role="TrainsCarriages" Type="Self.TrainsCarriages" Multiplicity="1" />
+        <Association Name="FK_RoutesStations_Station">
+          <End Role="Station" Type="Self.Station" Multiplicity="1" />
+          <End Role="RoutesStations" Type="Self.RoutesStations" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Station">
+              <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="TrainsCarriages">
+            <Principal Role="Carriages">
               <PropertyRef Name="IdCarriage" />
             </Principal>
             <Dependent Role="Tickets">
-              <PropertyRef Name="IdTrainCarriage" />
+              <PropertyRef Name="IdCarriage" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_Tickets_Routes">
+          <End Role="Routes" Type="Self.Routes" Multiplicity="1" />
+          <End Role="Tickets" Type="Self.Tickets" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Routes">
+              <PropertyRef Name="IdRoute" />
+            </Principal>
+            <Dependent Role="Tickets">
+              <PropertyRef Name="IdRoute" />
             </Dependent>
           </ReferentialConstraint>
         </Association>
@@ -114,22 +151,32 @@
           </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="TestTable" EntityType="Self.TestTable" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="RoutesStations" EntityType="Self.RoutesStations" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="Station" EntityType="Self.Station" 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="TrainsCarriages" EntityType="Self.TrainsCarriages" 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">
             <End Role="Trains" EntitySet="Trains" />
             <End Role="Routes" EntitySet="Routes" />
           </AssociationSet>
-          <AssociationSet Name="FK_Tickets_Routes" Association="Self.FK_Tickets_Routes">
+          <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_Station" Association="Self.FK_RoutesStations_Station">
+            <End Role="Station" EntitySet="Station" />
+            <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_TrainsCarriages" Association="Self.FK_Tickets_TrainsCarriages">
-            <End Role="TrainsCarriages" EntitySet="TrainsCarriages" />
+          <AssociationSet Name="FK_Tickets_Routes" Association="Self.FK_Tickets_Routes">
+            <End Role="Routes" EntitySet="Routes" />
             <End Role="Tickets" EntitySet="Tickets" />
           </AssociationSet>
           <AssociationSet Name="FK_Tickets_Users" Association="Self.FK_Tickets_Users">
@@ -142,52 +189,87 @@
     <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">
         <EntityContainer Name="RouteScheduleDataBaseEntities" annotation:LazyLoadingEnabled="true">
+          <EntitySet Name="Carriages" EntityType="RouteScheduleDataBaseModel.Carriages" />
           <EntitySet Name="Routes" EntityType="RouteScheduleDataBaseModel.Routes" />
-          <EntitySet Name="TestTable" EntityType="RouteScheduleDataBaseModel.TestTable" />
+          <EntitySet Name="RoutesStations" EntityType="RouteScheduleDataBaseModel.RoutesStations" />
+          <EntitySet Name="Station" EntityType="RouteScheduleDataBaseModel.Station" />
+          <EntitySet Name="sysdiagrams" EntityType="RouteScheduleDataBaseModel.sysdiagrams" />
           <EntitySet Name="Tickets" EntityType="RouteScheduleDataBaseModel.Tickets" />
           <EntitySet Name="Trains" EntityType="RouteScheduleDataBaseModel.Trains" />
-          <EntitySet Name="TrainsCarriages" EntityType="RouteScheduleDataBaseModel.TrainsCarriages" />
           <EntitySet Name="Users" EntityType="RouteScheduleDataBaseModel.Users" />
+          <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" />
+          </AssociationSet>
           <AssociationSet Name="FK_Tickets_Routes" Association="RouteScheduleDataBaseModel.FK_Tickets_Routes">
             <End Role="Routes" EntitySet="Routes" />
             <End Role="Tickets" EntitySet="Tickets" />
           </AssociationSet>
-          <AssociationSet Name="FK_Tickets_TrainsCarriages" Association="RouteScheduleDataBaseModel.FK_Tickets_TrainsCarriages">
-            <End Role="TrainsCarriages" EntitySet="TrainsCarriages" />
-            <End Role="Tickets" EntitySet="Tickets" />
+          <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_Users" Association="RouteScheduleDataBaseModel.FK_Tickets_Users">
             <End Role="Users" EntitySet="Users" />
             <End Role="Tickets" EntitySet="Tickets" />
           </AssociationSet>
         </EntityContainer>
+        <EntityType Name="Carriages">
+          <Key>
+            <PropertyRef Name="IdCarriage" />
+          </Key>
+          <Property Name="IdCarriage" Type="Int32" Nullable="false" />
+          <Property Name="Count" Type="Int32" Nullable="false" />
+          <NavigationProperty Name="Tickets" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Carriages" FromRole="Carriages" ToRole="Tickets" />
+        </EntityType>
         <EntityType Name="Routes">
           <Key>
             <PropertyRef Name="IdRoute" />
           </Key>
           <Property Name="IdRoute" Type="Int32" Nullable="false" />
           <Property Name="IdTrain" Type="Int32" Nullable="false" />
-          <Property Name="Departure_Station" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
-          <Property Name="Arrival_Station" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
           <Property Name="Departure_Date" Type="DateTime" Nullable="false" Precision="3" />
           <Property Name="Arrival_Date" Type="DateTime" Nullable="false" Precision="3" />
           <NavigationProperty Name="Trains" Relationship="RouteScheduleDataBaseModel.FK_Routes_Trains" FromRole="Routes" ToRole="Trains" />
+          <NavigationProperty Name="RoutesStations" Relationship="RouteScheduleDataBaseModel.FK_RoutesStations_Routes" FromRole="Routes" ToRole="RoutesStations" />
           <NavigationProperty Name="Tickets" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Routes" FromRole="Routes" ToRole="Tickets" />
         </EntityType>
-        <EntityType Name="TestTable">
+        <EntityType Name="RoutesStations">
           <Key>
-            <PropertyRef Name="IdRoute" />
+            <PropertyRef Name="IdRouteStation" />
           </Key>
+          <Property Name="IdRouteStation" Type="Int32" Nullable="false" />
           <Property Name="IdRoute" Type="Int32" Nullable="false" />
-          <Property Name="IdTrain" Type="Int32" Nullable="false" />
-          <Property Name="Departure" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
-          <Property Name="Arrival" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
-          <Property Name="DepartureDate" Type="DateTime" Nullable="false" Precision="3" />
-          <Property Name="ArrivalDate" Type="DateTime" Nullable="false" Precision="3" />
+          <Property Name="IdStation" Type="Int32" Nullable="false" />
+          <NavigationProperty Name="Routes" Relationship="RouteScheduleDataBaseModel.FK_RoutesStations_Routes" FromRole="RoutesStations" ToRole="Routes" />
+          <NavigationProperty Name="Station" Relationship="RouteScheduleDataBaseModel.FK_RoutesStations_Station" FromRole="RoutesStations" ToRole="Station" />
+        </EntityType>
+        <EntityType Name="Station">
+          <Key>
+            <PropertyRef Name="IdStation" />
+          </Key>
+          <Property Name="IdStation" Type="Int32" Nullable="false" />
+          <Property Name="Name" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <Property Name="Location" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <NavigationProperty Name="RoutesStations" Relationship="RouteScheduleDataBaseModel.FK_RoutesStations_Station" FromRole="Station" ToRole="RoutesStations" />
+        </EntityType>
+        <EntityType Name="sysdiagrams">
+          <Key>
+            <PropertyRef Name="diagram_id" />
+          </Key>
+          <Property Name="name" Type="String" Nullable="false" MaxLength="128" FixedLength="false" Unicode="true" />
+          <Property Name="principal_id" Type="Int32" Nullable="false" />
+          <Property Name="diagram_id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="version" Type="Int32" />
+          <Property Name="definition" Type="Binary" MaxLength="Max" FixedLength="false" />
         </EntityType>
         <EntityType Name="Tickets">
           <Key>
@@ -196,12 +278,12 @@
           <Property Name="IdTicket" Type="Int32" Nullable="false" />
           <Property Name="IdUser" Type="Int32" Nullable="false" />
           <Property Name="IdRoute" Type="Int32" Nullable="false" />
-          <Property Name="IdTrainCarriage" 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="TrainsCarriages" Relationship="RouteScheduleDataBaseModel.FK_Tickets_TrainsCarriages" FromRole="Tickets" ToRole="TrainsCarriages" />
           <NavigationProperty Name="Users" Relationship="RouteScheduleDataBaseModel.FK_Tickets_Users" FromRole="Tickets" ToRole="Users" />
         </EntityType>
         <EntityType Name="Trains">
@@ -212,14 +294,6 @@
           <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" />
         </EntityType>
-        <EntityType Name="TrainsCarriages">
-          <Key>
-            <PropertyRef Name="IdCarriage" />
-          </Key>
-          <Property Name="IdCarriage" Type="Int32" Nullable="false" />
-          <Property Name="Count" Type="Int32" Nullable="false" />
-          <NavigationProperty Name="Tickets" Relationship="RouteScheduleDataBaseModel.FK_Tickets_TrainsCarriages" FromRole="TrainsCarriages" ToRole="Tickets" />
-        </EntityType>
         <EntityType Name="Users">
           <Key>
             <PropertyRef Name="IdUser" />
@@ -233,6 +307,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_Tickets_Carriages">
+          <End Type="RouteScheduleDataBaseModel.Carriages" Role="Carriages" Multiplicity="1" />
+          <End Type="RouteScheduleDataBaseModel.Tickets" Role="Tickets" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Carriages">
+              <PropertyRef Name="IdCarriage" />
+            </Principal>
+            <Dependent Role="Tickets">
+              <PropertyRef Name="IdCarriage" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <Association Name="FK_Routes_Trains">
           <End Type="RouteScheduleDataBaseModel.Trains" Role="Trains" Multiplicity="1" />
           <End Type="RouteScheduleDataBaseModel.Routes" Role="Routes" Multiplicity="*" />
@@ -245,6 +331,18 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
+        <Association Name="FK_RoutesStations_Routes">
+          <End Type="RouteScheduleDataBaseModel.Routes" Role="Routes" Multiplicity="1" />
+          <End Type="RouteScheduleDataBaseModel.RoutesStations" Role="RoutesStations" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="Routes">
+              <PropertyRef Name="IdRoute" />
+            </Principal>
+            <Dependent Role="RoutesStations">
+              <PropertyRef Name="IdRoute" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <Association Name="FK_Tickets_Routes">
           <End Type="RouteScheduleDataBaseModel.Routes" Role="Routes" Multiplicity="1" />
           <End Type="RouteScheduleDataBaseModel.Tickets" Role="Tickets" Multiplicity="*" />
@@ -257,15 +355,15 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
-        <Association Name="FK_Tickets_TrainsCarriages">
-          <End Type="RouteScheduleDataBaseModel.TrainsCarriages" Role="TrainsCarriages" Multiplicity="1" />
-          <End Type="RouteScheduleDataBaseModel.Tickets" Role="Tickets" Multiplicity="*" />
+        <Association Name="FK_RoutesStations_Station">
+          <End Type="RouteScheduleDataBaseModel.Station" Role="Station" Multiplicity="1" />
+          <End Type="RouteScheduleDataBaseModel.RoutesStations" Role="RoutesStations" Multiplicity="*" />
           <ReferentialConstraint>
-            <Principal Role="TrainsCarriages">
-              <PropertyRef Name="IdCarriage" />
+            <Principal Role="Station">
+              <PropertyRef Name="IdStation" />
             </Principal>
-            <Dependent Role="Tickets">
-              <PropertyRef Name="IdTrainCarriage" />
+            <Dependent Role="RoutesStations">
+              <PropertyRef Name="IdStation" />
             </Dependent>
           </ReferentialConstraint>
         </Association>
@@ -281,79 +379,94 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
-      </Schema>
+        </Schema>
     </edmx:ConceptualModels>
     <!-- C-S mapping content -->
     <edmx:Mappings>
     <Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
   <EntityContainerMapping StorageEntityContainer="RouteScheduleDataBaseModelStoreContainer" CdmEntityContainer="RouteScheduleDataBaseEntities">
-    <EntitySetMapping Name="Routes">
-      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.Routes)">
-        <MappingFragment StoreEntitySet="Routes">
-          <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
-          <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
-          <ScalarProperty Name="Departure_Station" ColumnName="Departure_Station" />
-          <ScalarProperty Name="Arrival_Station" ColumnName="Arrival_Station" />
-          <ScalarProperty Name="Departure_Date" ColumnName="Departure_Date" />
-          <ScalarProperty Name="Arrival_Date" ColumnName="Arrival_Date" />
-        </MappingFragment>
-      </EntityTypeMapping>
-    </EntitySetMapping>
-    <EntitySetMapping Name="TestTable">
-      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.TestTable)">
-        <MappingFragment StoreEntitySet="TestTable">
-          <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
-          <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
-          <ScalarProperty Name="Departure" ColumnName="Departure" />
-          <ScalarProperty Name="Arrival" ColumnName="Arrival" />
-          <ScalarProperty Name="DepartureDate" ColumnName="DepartureDate" />
-          <ScalarProperty Name="ArrivalDate" ColumnName="ArrivalDate" />
-        </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="IdRoute" ColumnName="IdRoute" />
-          <ScalarProperty Name="IdTrainCarriage" ColumnName="IdTrainCarriage" />
-          <ScalarProperty Name="PlaceNumber" ColumnName="PlaceNumber" />
-          <ScalarProperty Name="Category" ColumnName="Category" />
-          <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="NameOfTrain" ColumnName="NameOfTrain" />
-        </MappingFragment>
-      </EntityTypeMapping>
-    </EntitySetMapping>
-    <EntitySetMapping Name="TrainsCarriages">
-      <EntityTypeMapping TypeName="IsTypeOf(RouteScheduleDataBaseModel.TrainsCarriages)">
-        <MappingFragment StoreEntitySet="TrainsCarriages">
-          <ScalarProperty Name="IdCarriage" ColumnName="IdCarriage" />
-          <ScalarProperty Name="Count" ColumnName="Count" />
-        </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" />
-        </MappingFragment>
-      </EntityTypeMapping>
-    </EntitySetMapping>
-  </EntityContainerMapping>
+          <EntitySetMapping Name="Carriages">
+            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Carriages">
+              <MappingFragment StoreEntitySet="Carriages">
+                <ScalarProperty Name="Count" ColumnName="Count" />
+                <ScalarProperty Name="IdCarriage" ColumnName="IdCarriage" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Routes">
+            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Routes">
+              <MappingFragment StoreEntitySet="Routes">
+                <ScalarProperty Name="Arrival_Date" ColumnName="Arrival_Date" />
+                <ScalarProperty Name="Departure_Date" ColumnName="Departure_Date" />
+                <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
+                <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="RoutesStations">
+            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.RoutesStations">
+              <MappingFragment StoreEntitySet="RoutesStations">
+                <ScalarProperty Name="IdStation" ColumnName="IdStation" />
+                <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
+                <ScalarProperty Name="IdRouteStation" ColumnName="IdRouteStation" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Station">
+            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Station">
+              <MappingFragment StoreEntitySet="Station">
+                <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="Category" ColumnName="Category" />
+                <ScalarProperty Name="PlaceNumber" ColumnName="PlaceNumber" />
+                <ScalarProperty Name="IdCarriage" ColumnName="IdCarriage" />
+                <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
+                <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="NameOfTrain" ColumnName="NameOfTrain" />
+                <ScalarProperty Name="IdTrain" ColumnName="IdTrain" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
+          <EntitySetMapping Name="Users">
+            <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.Users">
+              <MappingFragment StoreEntitySet="Users">
+                <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>
 </Mapping></edmx:Mappings>
   </edmx:Runtime>
   <!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->

+ 11 - 7
RaspisKusach/EDM.edmx.diagram

@@ -5,15 +5,19 @@
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
       <Diagram DiagramId="cbfc4ddba6b5479eb5c52b1c4156acc9" Name="Diagram1">
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Routes" Width="1.5" PointX="0.75" PointY="0.75" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.TestTable" Width="1.5" PointX="2.75" PointY="0.75" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Tickets" Width="1.5" PointX="0.75" PointY="3.75" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Trains" Width="1.5" PointX="2.75" PointY="3.75" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.TrainsCarriages" Width="1.5" PointX="4.75" PointY="0.75" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Users" Width="1.5" PointX="4.75" PointY="3.75" />
+        <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="7" PointY="4.5" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Station" Width="1.5" PointX="7.125" PointY="7.875" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.sysdiagrams" Width="1.5" PointX="10" PointY="4.625" />
+        <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" />
+        <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_Tickets_TrainsCarriages" />
+        <AssociationConnector Association="RouteScheduleDataBaseModel.FK_RoutesStations_Station" />
         <AssociationConnector Association="RouteScheduleDataBaseModel.FK_Tickets_Users" />
       </Diagram>
     </edmx:Diagrams>

+ 39 - 43
RaspisKusach/Pages/MainPage.xaml

@@ -22,55 +22,49 @@
                 BorderBrush="{StaticResource Selection}"
                 Margin="5"
                 Grid.Column="0">
-            <StackPanel Grid.Row="0"
-                        Orientation="Horizontal"
-                        HorizontalAlignment="Center">
-                <Button Height="45"
-                        Width="45"
-                        Content="+"
-                        FontSize="30"
-                        Margin="0,0,10,0"
-                        Click="AddButton_Click">
-                </Button>
-                <Grid Grid.Row="0"
-                      Background="{x:Null}">
+            
+            <Grid Background="{x:Null}">
+                <StackPanel>
+                    <Label Content="Направление"
+                           Margin="0,10,0,10"
+                           HorizontalAlignment="Center">
+                    </Label>
                     <StackPanel Orientation="Horizontal"
                                 Grid.Row="0"
                                 HorizontalAlignment="Center"
-                                Height="60">
-                        <TextBox Name="asddfg"
-                                 Width="120"
-                                 Margin="5"
-                                 Text="Откуда">
+                                Height="50">
+                        <TextBox Margin="5,0,5,0"
+                             Width="80"
+                             Text="Откуда">
                         </TextBox>
 
-                        <TextBox Name="CarNameBox"
-                             Margin="5"
-                             Width="120"
+                        <TextBox Margin="5,0,5,0"
+                             Width="80"
                              Text="Куда">
                         </TextBox>
+                    </StackPanel>
 
-                        <TextBox Name="asd"
-                             Margin="5"
-                             Width="120"
-                             Text="Туда">
+                    <Label Content="Дата"
+                           Margin="0,10,0,10"
+                           HorizontalAlignment="Center">
+                    </Label>
+                    <StackPanel Orientation="Horizontal"
+                                Grid.Row="0"
+                                HorizontalAlignment="Center"
+                                Height="50">
+                        <TextBox Margin="5,0,5,0"
+                             Width="80"
+                             Text="TIME">
                         </TextBox>
 
-                        <TextBox Name="asdf"
-                             Margin="5"
-                             Width="120"
-                             Text="Обратно">
+                        <TextBox Margin="5,0,5,0"
+                             Width="80"
+                             Text="TIME">
                         </TextBox>
-
                     </StackPanel>
-                </Grid>
-                <Button Height="45"
-                        Width="45"
-                        Content="P"
-                        Margin="10,0,0,0"
-                        Click="Button_Click">
-                </Button>
-            </StackPanel>
+                </StackPanel>
+                
+            </Grid>
         </Border>
 
         <!--TEMP-->
@@ -83,7 +77,7 @@
                     Background="{StaticResource Color2}"
                     BorderThickness="1.5"
                     BorderBrush="{StaticResource Selection}"
-                    Margin="10,0,10,0"
+                    Margin="10,2,10,2"
                     MouseDown="Border_MouseDown">
                 <Grid Background="{x:Null}">
                     <Grid.ColumnDefinitions>
@@ -128,14 +122,14 @@
                     <Grid Grid.Row="1" Grid.ColumnSpan="2">
                         <StackPanel>
                             <Label Name="FROML"
-                                   Content="{Binding Departure_Station}">
+                                   Content="{Binding Station.Name}">
                                 
                             </Label>
                             <Label Content="To">
                                 
                             </Label>
                             <Label Name="ToL"
-                                   Content="{Binding Arrival_Station}">
+                                   Content="{Binding Station.Name}">
                                 
                             </Label>
                         </StackPanel>
@@ -156,7 +150,7 @@
                     Background="{StaticResource Color2}"
                     BorderThickness="1.5"
                     BorderBrush="{StaticResource Selection}"
-                    Margin="10,0,10,0"
+                    Margin="10,5,10,5"
                     MouseDown="Border_MouseDown">
                         <Grid Background="{x:Null}">
                             <Grid.ColumnDefinitions>
@@ -201,19 +195,21 @@
                             <Grid Grid.Row="1" Grid.ColumnSpan="2">
                                 <StackPanel>
                                     <Label Name="FROML"
-                                   Content="{Binding Departure_Station}">
+                                   Content="{Binding Station.Name}">
 
                                     </Label>
                                     <Label Content="To">
 
                                     </Label>
                                     <Label Name="ToL"
-                                   Content="{Binding Arrival_Station}">
+                                   Content="{Binding Station.Name}">
 
                                     </Label>
                                 </StackPanel>
                             </Grid>
                         </Grid>
+
+
                     </Border>
                 </DataTemplate>
             </ListBox.ItemTemplate>

+ 10 - 4
RaspisKusach/RaspisKusach.csproj

@@ -64,6 +64,9 @@
       <Generator>MSBuild:Compile</Generator>
       <SubType>Designer</SubType>
     </ApplicationDefinition>
+    <Compile Include="Carriages.cs">
+      <DependentUpon>EDM.tt</DependentUpon>
+    </Compile>
     <Compile Include="cnt.cs" />
     <Compile Include="EDM.Context.cs">
       <AutoGen>True</AutoGen>
@@ -94,9 +97,15 @@
     <Compile Include="Routes.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
+    <Compile Include="RoutesStations.cs">
+      <DependentUpon>EDM.tt</DependentUpon>
+    </Compile>
     <Compile Include="Session.cs" />
+    <Compile Include="Station.cs">
+      <DependentUpon>EDM.tt</DependentUpon>
+    </Compile>
     <Compile Include="Styles\Style.cs" />
-    <Compile Include="TestTable.cs">
+    <Compile Include="sysdiagrams.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
     <Compile Include="Tickets.cs">
@@ -105,9 +114,6 @@
     <Compile Include="Trains.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>
-    <Compile Include="TrainsCarriages.cs">
-      <DependentUpon>EDM.tt</DependentUpon>
-    </Compile>
     <Compile Include="Users.cs">
       <DependentUpon>EDM.tt</DependentUpon>
     </Compile>

+ 3 - 2
RaspisKusach/Routes.cs

@@ -17,18 +17,19 @@ namespace RaspisKusach
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
         public Routes()
         {
+            this.RoutesStations = new HashSet<RoutesStations>();
             this.Tickets = new HashSet<Tickets>();
         }
     
         public int IdRoute { get; set; }
         public int IdTrain { get; set; }
-        public string Departure_Station { get; set; }
-        public string Arrival_Station { get; set; }
         public System.DateTime Departure_Date { get; set; }
         public System.DateTime Arrival_Date { 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; }
     }
 }

+ 6 - 6
RaspisKusach/TestTable.cs

@@ -12,13 +12,13 @@ namespace RaspisKusach
     using System;
     using System.Collections.Generic;
     
-    public partial class TestTable
+    public partial class RoutesStations
     {
+        public int IdRouteStation { get; set; }
         public int IdRoute { get; set; }
-        public int IdTrain { get; set; }
-        public string Departure { get; set; }
-        public string Arrival { get; set; }
-        public System.DateTime DepartureDate { get; set; }
-        public System.DateTime ArrivalDate { get; set; }
+        public int IdStation { get; set; }
+    
+        public virtual Routes Routes { get; set; }
+        public virtual Station Station { get; set; }
     }
 }

+ 30 - 0
RaspisKusach/Station.cs

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

+ 2 - 2
RaspisKusach/Tickets.cs

@@ -17,13 +17,13 @@ namespace RaspisKusach
         public int IdTicket { get; set; }
         public int IdUser { get; set; }
         public int IdRoute { get; set; }
-        public int IdTrainCarriage { 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 TrainsCarriages TrainsCarriages { get; set; }
         public virtual Users Users { get; set; }
     }
 }

+ 23 - 0
RaspisKusach/sysdiagrams.cs

@@ -0,0 +1,23 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace RaspisKusach
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class sysdiagrams
+    {
+        public string name { get; set; }
+        public int principal_id { get; set; }
+        public int diagram_id { get; set; }
+        public Nullable<int> version { get; set; }
+        public byte[] definition { get; set; }
+    }
+}