Imagara 2 år sedan
förälder
incheckning
40f75867b0

+ 3 - 6
RaspisKusach/EDM.edmx

@@ -18,8 +18,6 @@
           </Key>
           <Property Name="IdRoute" Type="int" Nullable="false" />
           <Property Name="IdTrain" Type="int" Nullable="false" />
-          <Property Name="Departure_Date" Type="datetime" Nullable="false" />
-          <Property Name="Arrival_Date" Type="datetime" Nullable="false" />
         </EntityType>
         <EntityType Name="RoutesStations">
           <Key>
@@ -28,6 +26,7 @@
           <Property Name="IdRouteStation" Type="int" Nullable="false" />
           <Property Name="IdRoute" Type="int" Nullable="false" />
           <Property Name="IdStation" Type="int" Nullable="false" />
+          <Property Name="DateTime" Type="date" Nullable="false" />
         </EntityType>
         <EntityType Name="Station">
           <Key>
@@ -236,8 +235,6 @@
           </Key>
           <Property Name="IdRoute" Type="Int32" Nullable="false" />
           <Property Name="IdTrain" Type="Int32" Nullable="false" />
-          <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" />
@@ -251,6 +248,7 @@
           <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" />
+          <Property Name="DateTime" Type="DateTime" Nullable="false" Precision="0" />
         </EntityType>
         <EntityType Name="Station">
           <Key>
@@ -396,8 +394,6 @@
           <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>
@@ -406,6 +402,7 @@
           <EntitySetMapping Name="RoutesStations">
             <EntityTypeMapping TypeName="RouteScheduleDataBaseModel.RoutesStations">
               <MappingFragment StoreEntitySet="RoutesStations">
+                <ScalarProperty Name="DateTime" ColumnName="DateTime" />
                 <ScalarProperty Name="IdStation" ColumnName="IdStation" />
                 <ScalarProperty Name="IdRoute" ColumnName="IdRoute" />
                 <ScalarProperty Name="IdRouteStation" ColumnName="IdRouteStation" />

+ 1 - 1
RaspisKusach/EDM.edmx.diagram

@@ -7,7 +7,7 @@
       <Diagram DiagramId="cbfc4ddba6b5479eb5c52b1c4156acc9" Name="Diagram1">
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Carriages" Width="1.5" PointX="1.5" PointY="1.875" />
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Routes" Width="1.5" PointX="3.875" PointY="4.25" />
-        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.RoutesStations" Width="1.5" PointX="7" PointY="4.5" />
+        <EntityTypeShape EntityType="RouteScheduleDataBaseModel.RoutesStations" Width="1.5" PointX="3.875" PointY="7.875" />
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Station" Width="1.5" PointX="7.125" PointY="7.875" />
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.sysdiagrams" Width="1.5" PointX="10" PointY="4.625" />
         <EntityTypeShape EntityType="RouteScheduleDataBaseModel.Tickets" Width="1.5" PointX="1.25" PointY="4.5" />

+ 33 - 24
RaspisKusach/Pages/MainPage.xaml

@@ -33,15 +33,19 @@
                                 Grid.Row="0"
                                 HorizontalAlignment="Center"
                                 Height="50">
-                        <TextBox Margin="5,0,5,0"
-                             Width="80"
-                             Text="Откуда">
-                        </TextBox>
-
-                        <TextBox Margin="5,0,5,0"
-                             Width="80"
-                             Text="Куда">
-                        </TextBox>
+                        <ComboBox Name="StationArrivalComboBox"
+                                  Margin="5,0,5,0"
+                                  IsEditable="True"
+                                  Width="80"
+                                  Text="Откуда">
+                        </ComboBox>
+
+                        <ComboBox Name="StationDepartureComboBox"
+                                  Margin="5,0,5,0"
+                                  IsEditable="True"
+                                  Width="80"
+                                  Text="Куда">
+                        </ComboBox>
                     </StackPanel>
 
                     <Label Content="Дата"
@@ -52,16 +56,21 @@
                                 Grid.Row="0"
                                 HorizontalAlignment="Center"
                                 Height="50">
-                        <TextBox Margin="5,0,5,0"
-                             Width="80"
-                             Text="TIME">
-                        </TextBox>
-
-                        <TextBox Margin="5,0,5,0"
-                             Width="80"
-                             Text="TIME">
-                        </TextBox>
+                        <DatePicker Margin="5,0,5,0"
+                             Width="80">
+                        </DatePicker>
+
+                        <DatePicker Margin="5,0,5,0"
+                             Width="80">
+                        </DatePicker>
                     </StackPanel>
+
+                    <Button Content="Поиск"
+                            Margin="0,10,0,10"
+                            Width="120"
+                            Height="30"
+                            Click="FindRoutesButton_Click">
+                    </Button>
                 </StackPanel>
                 
             </Grid>
@@ -99,7 +108,7 @@
                         </Image>
                         <StackPanel>
                             <Label Content="{Binding IdRoute}"/>
-                            <Label Content="FAST"
+                            <Label Content="{Binding str}"
                                    Margin="0,-7,0,0"/>
                         </StackPanel>
                     </StackPanel>
@@ -150,7 +159,7 @@
                     Background="{StaticResource Color2}"
                     BorderThickness="1.5"
                     BorderBrush="{StaticResource Selection}"
-                    Margin="10,5,10,5"
+                    Margin="10,2,10,2"
                     MouseDown="Border_MouseDown">
                         <Grid Background="{x:Null}">
                             <Grid.ColumnDefinitions>
@@ -171,8 +180,8 @@
                                Source="/Resources/Train.png">
                                 </Image>
                                 <StackPanel>
-                                    <Label Content="{Binding IdRoute}"/>
-                                    <Label Content="FAST"
+                                    <Label Content="{Binding route.IdRoute}"/>
+                                    <Label Content="{Binding str}"
                                    Margin="0,-7,0,0"/>
                                 </StackPanel>
                             </StackPanel>
@@ -195,14 +204,14 @@
                             <Grid Grid.Row="1" Grid.ColumnSpan="2">
                                 <StackPanel>
                                     <Label Name="FROML"
-                                   Content="{Binding Station.Name}">
+                                   Content="{Binding stationArrival}">
 
                                     </Label>
                                     <Label Content="To">
 
                                     </Label>
                                     <Label Name="ToL"
-                                   Content="{Binding Station.Name}">
+                                   Content="{Binding stationDeparture}">
 
                                     </Label>
                                 </StackPanel>

+ 52 - 1
RaspisKusach/Pages/MainPage.xaml.cs

@@ -20,9 +20,43 @@ namespace RaspisKusach.Pages
         public MainPage()
         {
             InitializeComponent();
-            ListBox.ItemsSource = cnt.db.Routes.ToList();
+
+            foreach (var station in cnt.db.Station.GroupBy(item => item.Location))
+            {
+                StationArrivalComboBox.Items.Add(station.Key);
+                StationDepartureComboBox.Items.Add(station.Key);
+            }
+            //UpdateRoutesList();
         }
+        private void UpdateRoutesList()
+        {
+            //var routesList = cnt.db.Routes.ToList();
+            //var list = routesList;
+            //foreach (Routes route in routesList)
+            //{
+            //    if (!cnt.db.RoutesStations.Select(item => item.IdRoute + " " + item.IdStation).Contains(route.IdRoute + " " + StationArrivalComboBox.Text)
+            //        || !cnt.db.RoutesStations.Select(item => item.IdRoute + " " + item.IdStation).Contains(route.IdRoute + " " + StationDepartureComboBox.Text))
+            //        list.Remove(route);
+            //}
+
+            List<RouteClass> playerApps = new List<RouteClass>();
+
+            foreach (Routes route in cnt.db.Routes)
+            {
+                RouteClass playerApp = new RouteClass();
+                playerApp.route = route;
+                playerApp.str = cnt.db.RoutesStations.Where(item => item.IdStation == cnt.db.Station.Where(it => it.Location == StationArrivalComboBox.Text).Select(it => it.IdStation).FirstOrDefault()).Select(item => item.DateTime).FirstOrDefault().ToString();
+                playerApp.stationArrival = StationArrivalComboBox.Text;
+                playerApp.stationDeparture = StationDepartureComboBox.Text;
+                //playerApp.timeArrival = Data
+                //playerApp.timeDe
 
+
+                playerApps.Add(playerApp);
+            }
+
+            ListBox.ItemsSource = playerApps;
+        }
         private void Button_Click(object sender, RoutedEventArgs e)
         {
 
@@ -38,5 +72,22 @@ namespace RaspisKusach.Pages
         {
 
         }
+
+        public class RouteClass
+        {
+
+            public Routes route { get; set; }
+            public string str { get; set; }
+            public string stationDeparture { get; set; }
+            public string stationArrival { get; set; }
+            public DateTime timeDeparture { get; set; }
+            public DateTime timeArrival { get; set; }
+
+        }
+
+        private void FindRoutesButton_Click(object sender, RoutedEventArgs e)
+        {
+            UpdateRoutesList();
+        }
     }
 }

+ 0 - 2
RaspisKusach/Routes.cs

@@ -23,8 +23,6 @@ namespace RaspisKusach
     
         public int IdRoute { get; set; }
         public int IdTrain { 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")]

+ 1 - 0
RaspisKusach/RoutesStations.cs

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

+ 3 - 0
RaspisKusach/Styles/Style.xaml

@@ -54,5 +54,8 @@
         </Setter>
         <Setter Property="Foreground" Value="{StaticResource TextColor}"/>
     </Style>
+    
+    
+    
 
 </ResourceDictionary>