Преглед изворни кода

мелкие правки, пред релиз

Oleg Kireev пре 3 година
родитељ
комит
0fc20c70cd

+ 7 - 6
Hotel_Course_Project/AdminPage.xaml

@@ -18,13 +18,14 @@
                     </Grid.RowDefinitions>
                     <Grid.ColumnDefinitions>
                         <ColumnDefinition Width="100"></ColumnDefinition>
-                        <ColumnDefinition></ColumnDefinition>
-                        <ColumnDefinition></ColumnDefinition>
+                        <ColumnDefinition Width="301*"></ColumnDefinition>
+                        <ColumnDefinition Width="46*"/>
+                        <ColumnDefinition Width="347*"></ColumnDefinition>
                     </Grid.ColumnDefinitions>
 
                     <Button x:Name="AddStaffBtn" Click="AddStaffBtn_Click">Добавить</Button>
 
-                    <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center">
+                    <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center" Margin="5,0,8.836,0">
                         <TextBlock VerticalAlignment="Center">Сортировка</TextBlock>
                         <ComboBox Margin="10,0,0,0" VerticalAlignment="Center" Name="SortStaffCB" SelectionChanged="SortStaffCB_SelectionChanged">
                             <ComboBoxItem IsSelected="True" Name="activeS">Активные пользователи</ComboBoxItem>
@@ -32,12 +33,12 @@
                         </ComboBox>
                     </StackPanel>
 
-                    <StackPanel Grid.Column="2" Orientation="Horizontal">
+                    <StackPanel Grid.Column="3" Orientation="Horizontal">
                         <TextBlock VerticalAlignment="Center">Поиск</TextBlock>
                         <TextBox  Name="StaffSeacrhTB" TextChanged="StaffSeacrhTB_TextChanged" VerticalAlignment="Center" Width="100"></TextBox>
                         <Button Name="StaffSrchBtn" Click="StaffSrchBtn_Click">Поиск</Button>
                     </StackPanel>
-                    <DataGrid x:Name="StaffList" Grid.Row="1" Grid.ColumnSpan="3" AutoGenerateColumns="False" ColumnWidth="*" IsReadOnly="True" SelectionMode="Single">
+                    <DataGrid x:Name="StaffList" Grid.Row="1" Grid.ColumnSpan="4" AutoGenerateColumns="False" ColumnWidth="*" IsReadOnly="True" SelectionMode="Single">
                         <!--<DataGrid.ItemContainerStyle>
                             <Style TargetType="DataGridRow">
                                 <EventSetter Event="MouseDoubleClick" Handler="Row_DoubleClick"/>
@@ -142,7 +143,7 @@
                         <RowDefinition Height="40"></RowDefinition>
                         <RowDefinition></RowDefinition>
                     </Grid.RowDefinitions>
-                    
+
                     <StackPanel Orientation="Horizontal">
                         <TextBlock VerticalAlignment="Center">Поиск</TextBlock>
                         <TextBox  Name="PaySeacrhTB" TextChanged="PaySeacrhTB_TextChanged" VerticalAlignment="Center" Width="100"></TextBox>

+ 19 - 55
Hotel_Course_Project/App.xaml

@@ -6,60 +6,24 @@
 
 
     <Application.Resources>
-        <ResourceDictionary>
-            <Style TargetType="Grid">
-                <Setter Property="Background">
-                    <Setter.Value>
-                        <RadialGradientBrush MappingMode="RelativeToBoundingBox" GradientOrigin="0.9,0.2" Center="0.5,0.5" RadiusX="0.7" RadiusY="0.7">
-                            <GradientStop Color="#FF1B1B15" Offset="1"/>
-                            <GradientStop Color="#FF142F2C"/>
-                        </RadialGradientBrush>
-                    </Setter.Value>
-                </Setter>
-            </Style>
-
-
-            <Style TargetType="Button">
-                <Setter Property="Template">
-                    <Setter.Value>
-                        <ControlTemplate TargetType="Button">
-                            <Grid Background="{TemplateBinding Background}">
-                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                            </Grid>
-                        </ControlTemplate>
-                    </Setter.Value>
-                </Setter>
-
-                <Setter Property="Template">
-                    <Setter.Value>
-                        <ControlTemplate TargetType="Button">
-                            <Border Name="Border" CornerRadius="15" Background="#FF4F5856" BorderBrush="Black" MouseEnter="MouseEnter" MouseLeave="MouseLeave">
-                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
-                            </Border>
-                        </ControlTemplate>
-                    </Setter.Value>
-                </Setter>
-                <Setter Property="Background" Value="{Binding ElementName=Border}"/>
-            </Style>
-
-            <Style TargetType="DataGrid">
-                <Setter Property="FontSize" Value="20"/>
-
-
-                <Setter Property="Foreground" Value="White"/>
-                <Setter Property="RowBackground" Value="Transparent"/>
-                <Setter Property="BorderBrush" Value="Transparent"/>
-                <Setter Property="Background" Value="Transparent"/>
-            </Style>
-
-            <Style x:Key="ColumnHeaderStyle" TargetType="{x:Type DataGridColumnHeader}">
-                <Setter Property="Background" Value="Transparent" />
-                <Setter Property="FontWeight" Value="Bold"/>
-            </Style>
-
-            <Style x:Key="RowHeaderStyle" TargetType="{x:Type DataGridRowHeader}">
-                <Setter Property="Background" Value="Transparent" />
-            </Style>
-        </ResourceDictionary>
+        <Style TargetType="Button">
+            <Setter Property="Height" Value="30"></Setter>
+            <Setter Property="Width" Value="100"></Setter>
+            <Setter Property="Background" Value="#FF1BA9B8"></Setter>
+            <Setter Property="Foreground" Value="White"></Setter>
+            
+        </Style>
+        <Style TargetType="TextBlock">
+            <Setter Property="HorizontalAlignment" Value="Right"></Setter>
+            <Setter Property="VerticalAlignment" Value="Center"></Setter>
+        </Style>
+        <Style TargetType="TextBox">
+            <Setter Property="VerticalAlignment" Value="Center"></Setter>
+            <Setter Property="BorderThickness" Value="0 0 0 1"></Setter>
+        </Style>
+        <Style TargetType="PasswordBox">
+            <Setter Property="VerticalAlignment" Value="Center"></Setter>
+            <Setter Property="BorderThickness" Value="0 0 0 1"></Setter>
+        </Style>
     </Application.Resources>
 </Application>

+ 2 - 1
Hotel_Course_Project/AuthorizationWindow.xaml.cs

@@ -63,7 +63,8 @@ namespace Hotel_Course_Project
 
         private void LostPass_Click(object sender, RoutedEventArgs e)
         {
-            HelpQustionWindow helpQustion = new HelpQustionWindow();
+            LoginRememberWindow LoginRemember = new LoginRememberWindow();
+            LoginRemember.ShowDialog();
         }
     }
 }

+ 21 - 3
Hotel_Course_Project/EnterLoginWindow.xaml.cs

@@ -26,13 +26,31 @@ namespace Hotel_Course_Project
 
         private void AcceptBtn_Click(object sender, RoutedEventArgs e)
         {
-            DialogResult = false;
+            var user = DataBase.db.Staff.SingleOrDefault(x => x.Login == Login.Text);
+            if (user != null)
+            {
+                if (user.HelpQuestion != null)
+                {
+                    HelpQustionWindow helpQustionWindow = new HelpQustionWindow(user);
+                    helpQustionWindow.ShowDialog();
+                    DialogResult = true;
+                }
+                else
+                {
+                    MessageBox.Show("Для данного аккаунта нет возможности восстановления пароля через секретный вопрос. обратитесь к администратору");
+                    DialogResult = false;
+                }
+            }
+            else
+            {
+                MessageBox.Show("Такого логина не существует");
+                Login.Text = "";
+            }
         }
 
         private void Cancelbtn_Click(object sender, RoutedEventArgs e)
         {
-            if (DataBase.db.Staff.SingleOrDefault(x => x.Login == Login.Text))
-            DialogResult = true;
+            DialogResult = false;
         }
     }
 }

+ 39 - 2
Hotel_Course_Project/HelpQustionWindow.xaml.cs

@@ -19,15 +19,21 @@ namespace Hotel_Course_Project
     /// </summary>
     public partial class HelpQustionWindow : Window
     {
+        public Staff _user;
         public HelpQustionWindow(Staff user)
         {
             InitializeComponent();
+            _user = user;
             TypeQuestionCB.ItemsSource = DataBase.db.HelpQuestion.ToList();
             if (user.Id_HelpQuestion != null)
             {
                 TypeQuestionCB.Text = user.ToString();
                 TypeQuestionCB.IsEditable = false;
             }
+            else
+            {
+                TypeQuestionCB.IsEditable = true;
+            }
         }
 
         private void CancelBtn_Click(object sender, RoutedEventArgs e)
@@ -37,8 +43,39 @@ namespace Hotel_Course_Project
 
         private void AcceptBtn_Click(object sender, RoutedEventArgs e)
         {
-
-            DialogResult = true;
+            if(TypeQuestionCB.SelectedItem == null)
+            {
+                MessageBox.Show("Выберите вопрос");
+            }
+            else if(AnswerTB.Text == "" || AnswerTB.Text ==  string.Empty)
+            {
+                MessageBox.Show("Поле с ответом -- пустое");
+            }
+            else
+            {
+                int numQuestion = DataBase.db.HelpQuestion.SingleOrDefault(x => x.Name == TypeQuestionCB.Text).id;
+                if (_user.Id_HelpQuestion == null)
+                {
+                    _user.Id_HelpQuestion = numQuestion;
+                    _user.AnswerOnHelpQuestion = AnswerTB.Text;
+                    MessageBox.Show("Способ восстановления пароля добавлен");
+                    DialogResult = true;
+                }
+                else
+                {
+                    if (_user.Id_HelpQuestion != numQuestion || (_user.Id_HelpQuestion == numQuestion && _user.AnswerOnHelpQuestion != AnswerTB.Text))
+                    {
+                        MessageBox.Show("Ошибка при восстановлении пароля");
+                        AnswerTB.Text = "";
+                    }
+                    else
+                    {
+                        _user.Password = SomeMethods.Hash("123");
+                        DataBase.db.SaveChanges();
+                        DialogResult = true;
+                    }
+                }
+            }
         }
     }
 }

+ 1 - 1
Hotel_Course_Project/LoginRememberWindow.xaml

@@ -5,7 +5,7 @@
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         xmlns:local="clr-namespace:Hotel_Course_Project"
         mc:Ignorable="d"
-        Title="Проверка логина" Height="200" Width="300">
+        Title="Проверка логина" Height="200" Width="300" WindowStartupLocation="CenterScreen">
     <Grid>
         <Grid.RowDefinitions>
             <RowDefinition></RowDefinition>

+ 1 - 0
Hotel_Course_Project/LoginRememberWindow.xaml.cs

@@ -26,6 +26,7 @@ namespace Hotel_Course_Project
 
         private void CancelBtn_Click(object sender, RoutedEventArgs e)
         {
+            MessageBox.Show("Обратитесь к администратору");
             DialogResult = false;
         }
 

+ 1 - 1
Hotel_Course_Project/MainWindow.xaml

@@ -14,7 +14,7 @@
 
         <Button HorizontalAlignment="Left" Name="BackBtn" Click="BackBtn_Click" IsCancel="True">Назад</Button>
         <Button HorizontalAlignment="Left" Name="ExitBtn" Click="ExitBtn_Click">Выйти</Button>
-        <Button HorizontalAlignment="Right" Name="ChangeLogPasBtn" Click="ChangeLogPasBtn_Click">Изменить логин\пароль</Button>
+        <Button HorizontalAlignment="Right" Width="150" Name="ChangeLogPasBtn" Click="ChangeLogPasBtn_Click">Изменить логин\пароль</Button>
         <Frame Name="MainFrame" Grid.Row="1" NavigationUIVisibility="Hidden" ContentRendered="MainFrame_ContentRendered"></Frame>
     </Grid>
 </Window>

+ 1 - 2
Hotel_Course_Project/MainWindow.xaml.cs

@@ -29,8 +29,7 @@ namespace Hotel_Course_Project
                 helpQustion.ShowDialog();
                 DataBase.db.SaveChanges();
             }
-        }
-
+        }        
         private void MainFrame_ContentRendered(object sender, EventArgs e)
         {
             var visibleExitBtn = PChanger.MainFrame.CanGoBack ? ExitBtn.Visibility = Visibility.Collapsed : ExitBtn.Visibility = Visibility.Visible;