瀏覽代碼

Добавлен переход назад

Вадим Королёв 5 月之前
父節點
當前提交
fd3fb56801

+ 5 - 0
src/SASDesktop/Navigation.cs

@@ -35,6 +35,11 @@ namespace SASDesktop
             return (App.Current.MainWindow as MainWindow).ContentBody;
         }
 
+        public static void GoBack()
+        {
+            GetMainFrame().GoBack();
+        }
+        
         /// <summary>
         /// Показывает кнопку выхода
         /// </summary>

+ 1 - 1
src/SASDesktop/ViewModels/Drivers/Create.cs

@@ -149,7 +149,7 @@ namespace SASDesktop.ViewModels.Drivers
         {
             if (Popups.Confirm("отменить создание"))
             {
-                Navigation.ToPortal();
+                Navigation.GoBack();
             }
         }
 

+ 28 - 5
src/SASDesktop/ViewModels/Drivers/ListOutput.cs

@@ -10,19 +10,42 @@ using System.Windows.Data;
 
 namespace SASDesktop.ViewModels.Drivers
 {
-    internal class ListOutput : BindableBase
+    class ListOutput : BindableBase
     {
-        public ObservableCollection<Citizen> lvOutPutCitizen { get; set; }
+        public System.Collections.Generic.List<Citizen> lvOutPutCitizen { get; set; }
+        public DelegateCommand AddCmd { get; set; }
+        public DelegateCommand EditCmd { get; set; }
+        public DelegateCommand DeleteCmd { get; set; }
+        public DelegateCommand BackCmd { get; set; }
 
         public ListOutput()
         {
-            UpdateCitizenData();
+            var db = new Models.SASEntities();
+            lvOutPutCitizen = new System.Collections.Generic.List<Citizen>(db.Citizens);
+            AddCmd = new DelegateCommand(AddExecuted);
+            EditCmd = new DelegateCommand(EditExecuted);
+            DeleteCmd = new DelegateCommand(DeleteExecuted);
+            BackCmd = new DelegateCommand(BackExecuted);
         }
 
-        public void UpdateCitizenData()
+        public void AddExecuted()
         {
-            lvOutPutCitizen = new ObservableCollection<Citizen>(new SASEntities().Citizens.ToList());
+            Navigation.ToDriverCreateExecuted();
+        }
+        
+        public void EditExecuted()
+        {
+            Popups.NotImplementedSorry();
         }
 
+        public void DeleteExecuted()
+        {
+            Popups.NotImplementedSorry();
+        }
+
+        public void BackExecuted()
+        {
+            Navigation.GoBack();
+        }
     }
 }

+ 1 - 1
src/SASDesktop/ViewModels/Transport/Create.cs

@@ -525,7 +525,7 @@ namespace SASDesktop.ViewModels.Transport
         {
             if (Popups.Confirm("отменить создание"))
             {
-                Navigation.ToPortal();
+                Navigation.GoBack();
             }
         }
 

+ 16 - 2
src/SASDesktop/ViewModels/Transport/List.cs

@@ -13,18 +13,27 @@ namespace SASDesktop.ViewModels.Transport
 {
     class List : BindableBase
     {
-        public ObservableCollection<Models.Transport> TransportList { get; set; }
+        public System.Collections.Generic.List<Models.Transport> TransportList { get; set; }
+        public DelegateCommand AddCmd { get; set; }
         public DelegateCommand EditCmd { get; set; }
         public DelegateCommand DeleteCmd { get; set; }
+        public DelegateCommand BackCmd { get; set; }
 
         public List()
         {
             var db = new Models.SASEntities();
-            TransportList = new ObservableCollection<Models.Transport>(db.Transports.ToList());
+            TransportList = new System.Collections.Generic.List<Models.Transport>(db.Transports);
+            AddCmd = new DelegateCommand(AddExecuted);
             EditCmd = new DelegateCommand(EditExecuted);
             DeleteCmd = new DelegateCommand(DeleteExecuted);
+            BackCmd = new DelegateCommand(BackExecuted);
         }
 
+        public void AddExecuted()
+        {
+            Navigation.ToTransportCreateExecuted();
+        }
+        
         public void EditExecuted()
         {
             Popups.NotImplementedSorry();
@@ -34,5 +43,10 @@ namespace SASDesktop.ViewModels.Transport
         {
             Popups.NotImplementedSorry();
         }
+
+        public void BackExecuted()
+        {
+            Navigation.GoBack();
+        }
     }
 }

+ 56 - 53
src/SASDesktop/Views/Drivers/DriverListOutput.xaml

@@ -16,64 +16,67 @@
             <TextBlock HorizontalAlignment="Center"
                        Style="{StaticResource H2}"
                        Text="Список водителей"/>
-
+                       
             <Grid>
                 <StackPanel>
-                    <ListView ItemsSource="{Binding lvOutPutCitizen}" 
-                              ScrollViewer.HorizontalScrollBarVisibility="Disabled"
-                              Height="400">
-                        <ListView.ItemsPanel>
-                            <ItemsPanelTemplate>
-                                <WrapPanel Orientation="Horizontal"/>
-                            </ItemsPanelTemplate>
-                        </ListView.ItemsPanel>
-                        <ListView.ItemTemplate>
-                            <DataTemplate>
-                                <Grid >
-                                    <Grid.ColumnDefinitions>
-                                        <ColumnDefinition Width="*"/>
-                                        <ColumnDefinition Width="*"/>
-                                        <ColumnDefinition Width="*"/>
-                                    </Grid.ColumnDefinitions>
-                                    <StackPanel Width="160">
-                                        <StackPanel Orientation="Horizontal">
-                                            <TextBlock Text="{Binding GetHumanName}" 
-                                                       Style="{StaticResource H4}"/>
-                                        </StackPanel>
-                                        <TextBlock Text="{Binding Path=GetHumanPass}"/>
-                                        <TextBlock Text="{Binding Path=Job1.Name}"/>
-                                        <TextBlock Text="{Binding Path=Job1.Company1.Name}"/>
-                                        <Image
-                                               Width="140"
-                                               Height="140">
-                                            <Image.Source>
-                                                <Binding Path="GetFace">
-                                                    <Binding.TargetNullValue>
-                                                        <ImageSource>/Assets/BlackAvatar.png</ImageSource>
-                                                    </Binding.TargetNullValue>
-                                                </Binding>
-                                            </Image.Source>
-                                        </Image>
-                                    </StackPanel>
-                                </Grid>
-                            </DataTemplate>
-                        </ListView.ItemTemplate>
-                    </ListView>
-                    <StackPanel Orientation="Horizontal">
-                        <Button Content="Добавить"
-                                Style="{StaticResource StandartButton}"
-                                Command="{Binding Source={x:Static root:Navigation.ToDriverCreate}}"/>
-                        <Button Content="Редактировать"
-                                Style="{StaticResource StandartButton}"
-                                Command="{Binding Source={x:Static root:Navigation.ToDriverCreate}}"/>
-                        <Button Content="Удалить"
-                                Style="{StaticResource StandartButton}"
-                                Command="{Binding Source={x:Static root:Navigation.ToDriverCreate}}"/>
+
+                  <StackPanel Orientation="Horizontal">
+                      <Button Content="Добавить"
+                              Style="{StaticResource StandartButton}"
+                              Command="{Binding AddCmd}"/>
+                      <Button Content="Редактировать"
+                              Style="{StaticResource StandartButton}"
+                              Command="{Binding EditCmd}"/>
+                      <Button Content="Удалить"
+                              Style="{StaticResource StandartButton}"
+                              Command="{Binding DeleteCmd}"/>
+                      <Button Content="Назад"
+                              Style="{StaticResource StandartButton}"
+                              Command="{Binding BackCmd}"/>
                     </StackPanel>
+                    
+                  <ListView ItemsSource="{Binding lvOutPutCitizen}" 
+                            ScrollViewer.HorizontalScrollBarVisibility="Disabled"
+                            Height="400">
+                      <ListView.ItemsPanel>
+                          <ItemsPanelTemplate>
+                              <WrapPanel Orientation="Horizontal"/>
+                          </ItemsPanelTemplate>
+                      </ListView.ItemsPanel>
+                      <ListView.ItemTemplate>
+                          <DataTemplate>
+                              <Grid>
+                                  <Grid.ColumnDefinitions>
+                                      <ColumnDefinition Width="*"/>
+                                      <ColumnDefinition Width="*"/>
+                                      <ColumnDefinition Width="*"/>
+                                  </Grid.ColumnDefinitions>
+                                  <StackPanel Width="160">
+                                      <StackPanel Orientation="Horizontal">
+                                          <TextBlock Text="{Binding GetHumanName}" 
+                                                     Style="{StaticResource H4}"/>
+                                      </StackPanel>
+                                      <TextBlock Text="{Binding Path=GetHumanPass}"/>
+                                      <TextBlock Text="{Binding Path=Job1.Name}"/>
+                                      <TextBlock Text="{Binding Path=Job1.Company1.Name}"/>
+                                      <Image
+                                             Width="140"
+                                             Height="140">
+                                          <Image.Source>
+                                              <Binding Path="GetFace">
+                                                  <Binding.TargetNullValue>
+                                                      <ImageSource>/Assets/BlackAvatar.png</ImageSource>
+                                                  </Binding.TargetNullValue>
+                                              </Binding>
+                                          </Image.Source>
+                                      </Image>
+                                  </StackPanel>
+                              </Grid>
+                          </DataTemplate>
+                      </ListView.ItemTemplate>
+                  </ListView>
                 </StackPanel>
-                
             </Grid>
-
         </StackPanel>
     </ScrollViewer>
 </Page>

+ 20 - 16
src/SASDesktop/Views/Transport/List.xaml

@@ -20,6 +20,26 @@
                 Style="{StaticResource H2}"
                 Text="Список транспортных средств"/>
 
+            <!--Кнопки управления-->
+            <StackPanel Orientation="Horizontal">
+                <Button
+                    Content="Добавить"
+                    Style="{StaticResource StandartButton}"
+                    Command="{Binding Source={x:Static root:Navigation.ToTransportCreate}}"/>
+                <Button
+                    Content="Редактировать"
+                    Style="{StaticResource StandartButton}"
+                    Command="{Binding EditCmd}"/>
+                <Button
+                    Content="Удалить"
+                    Style="{StaticResource StandartButton}"
+                    Command="{Binding DeleteCmd}"/>
+                <Button
+                    Content="Назад"
+                    Style="{StaticResource StandartButton}"
+                    Command="{Binding BackCmd}"/>
+            </StackPanel>
+            
             <!--Сам список-->
             <ListView
                 ItemsSource="{Binding TransportList}"
@@ -74,22 +94,6 @@
                     </DataTemplate>
                 </ListView.ItemTemplate>
             </ListView>
-
-            <!--Кнопки управления-->
-            <StackPanel Orientation="Horizontal">
-                <Button
-                    Content="Добавить"
-                    Style="{StaticResource StandartButton}"
-                    Command="{Binding Source={x:Static root:Navigation.ToTransportCreate}}"/>
-                <Button
-                    Content="Редактировать"
-                    Style="{StaticResource StandartButton}"
-                    Command="{Binding EditCmd}"/>
-                <Button
-                    Content="Удалить"
-                    Style="{StaticResource StandartButton}"
-                    Command="{Binding DeleteCmd}"/>
-            </StackPanel>
         </StackPanel>
     </ScrollViewer>
 </Page>