Переглянути джерело

Доделать изменения по комнатам

Oleg Kireev 3 роки тому
батько
коміт
b273f814fd

+ 3 - 3
Hotel_Course_Project/AdminPage.xaml.cs

@@ -149,15 +149,15 @@ namespace Hotel_Course_Project
 
         private void AddRoomBtn_Click(object sender, RoutedEventArgs e)
         {
-            RoomAddOrChangeWindow roomAddOrChange = new RoomAddOrChangeWindow(null);
-            roomAddOrChange.ShowDialog();
+            RoomAddOrChangePage roomAddOrChange = new RoomAddOrChangePage(null);
+            PChanger.MainFrame.Navigate(new RoomAddOrChangePage(null));
             Page_Loaded(sender, e);
         }
 
         private void SelectRoomBtn_Click(object sender, RoutedEventArgs e)
         {
             Room room = (sender as Button).DataContext as Room;
-            RoomAddOrChangeWindow roomAddOrChange = new RoomAddOrChangeWindow(room);
+            PChanger.MainFrame.Navigate(new RoomAddOrChangePage(room));
             Page_Loaded(sender, e);
         }
     }

+ 3 - 3
Hotel_Course_Project/Hotel_Course_Project.csproj

@@ -98,8 +98,8 @@
     <Compile Include="Room.cs">
       <DependentUpon>ModelDB.tt</DependentUpon>
     </Compile>
-    <Compile Include="RoomAddOrChangeWindow.xaml.cs">
-      <DependentUpon>RoomAddOrChangeWindow.xaml</DependentUpon>
+    <Compile Include="RoomAddOrChangePage.xaml.cs">
+      <DependentUpon>RoomAddOrChangePage.xaml</DependentUpon>
     </Compile>
     <Compile Include="RoomStatus.cs">
       <DependentUpon>ModelDB.tt</DependentUpon>
@@ -148,7 +148,7 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
-    <Page Include="RoomAddOrChangeWindow.xaml">
+    <Page Include="RoomAddOrChangePage.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
     </Page>

+ 40 - 0
Hotel_Course_Project/RoomAddOrChangePage.xaml

@@ -0,0 +1,40 @@
+<Page x:Class="Hotel_Course_Project.RoomAddOrChangePage"
+      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+      xmlns:local="clr-namespace:Hotel_Course_Project"
+      mc:Ignorable="d" 
+      d:DesignHeight="450" d:DesignWidth="800"
+      Title="RoomAddOrChangePage">
+
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition></ColumnDefinition>
+            <ColumnDefinition></ColumnDefinition>
+            <ColumnDefinition></ColumnDefinition>
+            <ColumnDefinition></ColumnDefinition>
+        </Grid.ColumnDefinitions>
+        <Grid.RowDefinitions>
+            <RowDefinition></RowDefinition>
+            <RowDefinition></RowDefinition>
+            <RowDefinition></RowDefinition>
+            <RowDefinition></RowDefinition>
+            <RowDefinition></RowDefinition>
+            <RowDefinition></RowDefinition>
+            <RowDefinition></RowDefinition>
+        </Grid.RowDefinitions>
+
+        <TextBlock Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">Номер комнаты</TextBlock>
+        <TextBlock Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">Вместимость</TextBlock>
+        <TextBlock Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">Дневная оплата</TextBlock>
+        <TextBlock Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">Состояние комнаты</TextBlock>
+
+        <TextBox x:Name="RNum" Grid.Row="1" Grid.Column="2" Text="{Binding NumRoom}"></TextBox>
+        <TextBox x:Name="RRoominess" Grid.Row="2" Grid.Column="2" Text="{Binding CountOfSeats}"></TextBox>
+        <TextBox x:Name="RCostPerDay" Grid.Row="3" Grid.Column="2" Text="{Binding CostPerDay}"></TextBox>
+        <ComboBox x:Name="RStatus" Grid.Row="4" Grid.Column="2" SelectedItem="{Binding RoomStatus}" DisplayMemberPath="Name" ItemsSource="{Binding Id_RoomStatus.RoomStatus.Id.Name}"></ComboBox>
+        <Button x:Name="CancelBtn" Grid.Row="5" Grid.Column="1" IsCancel="True" Click="CancelBtn_Click">Отмена</Button>
+        <Button x:Name="AddBtn" Grid.Row="5" Grid.Column="2" IsDefault="True" Click="AddBtn_Click">Добавить</Button>
+    </Grid>
+</Page>

+ 16 - 9
Hotel_Course_Project/RoomAddOrChangeWindow.xaml.cs

@@ -10,31 +10,38 @@ using System.Windows.Documents;
 using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
 using System.Windows.Shapes;
 
 namespace Hotel_Course_Project
 {
     /// <summary>
-    /// Логика взаимодействия для RoomAddOrChangeWindow.xaml
+    /// Логика взаимодействия для RoomAddOrChangePage.xaml
     /// </summary>
-    public partial class RoomAddOrChangeWindow : Window
+    public partial class RoomAddOrChangePage : Page
     {
-        public RoomAddOrChangeWindow(Room room)
+        public RoomAddOrChangePage(Room room)
         {
             InitializeComponent();
-            Room _room = room;
-            DataContext = _room;
-            RStatus.SelectedItem = DataBase.db.RoomStatus.Where(item => item.Name == "Доступна").ToString();
+            DataContext = room;
+            RStatus.ItemsSource = DataBase.db.RoomStatus.ToList();
+            if(DataContext != null)
+            {
+                RStatus.Text = room.ToString();
+                AddBtn.Content = "Изменить данные о комнате";
+            }
         }
+
         private void CancelBtn_Click(object sender, RoutedEventArgs e)
         {
-            DialogResult = false;
+
+            PChanger.MainFrame.GoBack();
         }
 
         private void AddBtn_Click(object sender, RoutedEventArgs e)
         {
-            DialogResult = true;
+            DataBase.db.SaveChanges();
+            PChanger.MainFrame.GoBack();
         }
-
     }
 }

+ 0 - 34
Hotel_Course_Project/RoomAddOrChangeWindow.xaml

@@ -1,34 +0,0 @@
-<Window x:Class="Hotel_Course_Project.RoomAddOrChangeWindow"
-        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
-        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
-        xmlns:local="clr-namespace:Hotel_Course_Project"
-        mc:Ignorable="d"
-        Title="RoomAddWindow" Height="350" Width="250" WindowStartupLocation="CenterOwner" ResizeMode="NoResize">
-    <Grid>
-        <Grid.ColumnDefinitions>
-            <ColumnDefinition></ColumnDefinition>
-            <ColumnDefinition></ColumnDefinition>
-        </Grid.ColumnDefinitions>
-        <Grid.RowDefinitions>
-            <RowDefinition></RowDefinition>
-            <RowDefinition></RowDefinition>
-            <RowDefinition></RowDefinition>
-            <RowDefinition></RowDefinition>
-            <RowDefinition></RowDefinition>
-        </Grid.RowDefinitions>
-
-        <TextBlock Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center">Номер комнаты</TextBlock>
-        <TextBlock Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center">Вместимость</TextBlock>
-        <TextBlock Grid.Row="2" HorizontalAlignment="Right" VerticalAlignment="Center">Дневная оплата</TextBlock>
-        <TextBlock Grid.Row="3" HorizontalAlignment="Right" VerticalAlignment="Center">Состояние комнаты</TextBlock>
-
-        <TextBox x:Name="RNum" Grid.Row="0" Grid.Column="1" Text="{Binding NumRoom}"></TextBox>
-        <TextBox x:Name="RRoominess" Grid.Row="1" Grid.Column="1" Text="{Binding CountOfSeats}"></TextBox>
-        <TextBox x:Name="RCostPerDay" Grid.Row="2" Grid.Column="1" Text="{Binding CostPerDay}"></TextBox>
-        <ComboBox x:Name="RStatus" Grid.Row="3" Grid.Column="1" SelectedItem="{Binding RoomStatus}" DisplayMemberPath="Name" ItemsSource="{Binding Id_RoomStatus.RoomStatus.Id.Name}"></ComboBox>
-        <Button x:Name="CancelBtn" Click="CancelBtn_Click">Отмена</Button>
-        <Button x:Name="AddBtn" Click="AddBtn_Click">Добавить</Button>
-    </Grid>
-</Window>

+ 2 - 1
Hotel_Course_Project/StaffChangeOrAddPage.xaml.cs

@@ -31,6 +31,7 @@ namespace Hotel_Course_Project
             InitializeComponent();
             DataContext = staff;
             _staff = staff;
+            SStaffRole.ItemsSource = DataBase.db.StaffRole.ToList();
             if (DataContext != null)
             {
                 SStaffRole.Text = staff.ToString();
@@ -53,7 +54,7 @@ namespace Hotel_Course_Project
                 this.Title = "Окно добавления сотрудника";
                 StaffDeleteOrRestoreBtn.Visibility = Visibility.Collapsed;
             }
-            SStaffRole.ItemsSource = DataBase.db.StaffRole.ToList();
+            
             if (staff == null || staff.PhotoContract == null)
             {
                 SContractPhoto.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/no_picture.jpg"));