Преглед на файлове

"сделал" украл, стили, доделал смену логина\пароля

Oleg Kireev преди 3 години
родител
ревизия
c574530b55

+ 59 - 0
Hotel_Course_Project/App.xaml

@@ -3,4 +3,63 @@
              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
              xmlns:local="clr-namespace:Hotel_Course_Project"
              StartupUri="AuthorizationWindow.xaml">
+
+
+    <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>
+    </Application.Resources>
 </Application>

+ 11 - 0
Hotel_Course_Project/App.xaml.cs

@@ -1,4 +1,6 @@
 using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
 
 namespace Hotel_Course_Project
 {
@@ -7,5 +9,14 @@ namespace Hotel_Course_Project
     /// </summary>
     public partial class App : Application
     {
+        private void MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
+        {
+            ((Border)sender).Background = new SolidColorBrush(Color.FromRgb(120, 125, 124));
+        }
+
+        private void MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
+        {
+            ((Border)sender).Background = new SolidColorBrush(Color.FromRgb(79, 88, 86));
+        }
     }
 }

+ 1 - 0
Hotel_Course_Project/AuthorizationWindow.xaml.cs

@@ -31,6 +31,7 @@ namespace Hotel_Course_Project
                 }
                 else
                 {
+                    SomeMethods.pass = Password.Password;
                     MainWindow mainWindow = new MainWindow(user);
                     mainWindow.Show();
                     Close();

+ 3 - 3
Hotel_Course_Project/ChangePasLogWindow.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" Loaded="Window_Loaded">
     <Grid>
         <Grid.ColumnDefinitions>
             <ColumnDefinition></ColumnDefinition>
@@ -18,8 +18,8 @@
         </Grid.RowDefinitions>
         <TextBlock>Логин</TextBlock>
         <TextBlock Grid.Row="1">Пароль</TextBlock>
-        <TextBox Grid.Column="1" Name="TBLogin" Text="{Binding Staff.Login}"></TextBox>
-        <TextBox Grid.Column="1" Grid.Row="1" Name="TBPassword" Text="{Binding Staff.Password}"></TextBox>
+        <TextBox Grid.Column="1" Name="TBLogin"></TextBox>
+        <TextBox Grid.Column="1" Grid.Row="1" Name="TBPassword" ></TextBox>
         <Button Grid.Row="2" Name="BackBtn" Click="BackBtn_Click">Назад</Button>
         <Button Grid.Row="2" Grid.Column="1" Name="SaveBtn" Click="SaveBtn_Click">Изменить</Button>
     </Grid>

+ 15 - 4
Hotel_Course_Project/ChangePasLogWindow.xaml.cs

@@ -21,20 +21,21 @@ namespace Hotel_Course_Project
     {
         Staff _staff;
         public ChangePasLogWindow(Staff staff)
-        {
-            DataContext = staff;
+        {            
             _staff = staff;
             InitializeComponent();
         }
 
         private void BackBtn_Click(object sender, RoutedEventArgs e)
         {
-            PChanger.MainFrame.GoBack();
+            DialogResult = false;
+            this.Close();
         }
 
         private void SaveBtn_Click(object sender, RoutedEventArgs e)
         {
-            var user = DataBase.db.Staff.SingleOrDefault(x => x.Login == TBLogin.Text && x.Password == SomeMethods.Hash(TBPassword.Text) && x.Login != _staff.Login);
+            string pass = SomeMethods.Hash(TBPassword.Text);
+            var user = DataBase.db.Staff.SingleOrDefault(x => x.Login == TBLogin.Text && x.Password == pass && x.Login != _staff.Login);
             if(TBLogin.Text == "" || TBPassword.Text == "")
             {
                 MessageBox.Show("Пустые поля");
@@ -45,8 +46,18 @@ namespace Hotel_Course_Project
             }
             else
             {
+                var _user = DataBase.db.Staff.SingleOrDefault(x => x.Login == _staff.Login);
+                _user.Login = TBLogin.Text;
+                _user.Password = SomeMethods.Hash(TBPassword.Text);
                 DataBase.db.SaveChanges();
+                this.Close();
             }
         }
+
+        private void Window_Loaded(object sender, RoutedEventArgs e)
+        {
+            TBLogin.Text = _staff.Login;
+            TBPassword.Text = SomeMethods.pass;
+        }
     }
 }

+ 6 - 2
Hotel_Course_Project/MainWindow.xaml.cs

@@ -8,10 +8,12 @@ namespace Hotel_Course_Project
     /// </summary>
     public partial class MainWindow : Window
     {
+        Staff _user;
         public MainWindow(Staff user)
         {
             InitializeComponent();
             PChanger.MainFrame = MainFrame;
+            _user = user;
             switch (user.Id_StaffRole)
             {
                 case 1:
@@ -20,7 +22,7 @@ namespace Hotel_Course_Project
                 case 2:
                     MainFrame.Navigate(new HostelsPage(user));
                     break;
-            }
+            }            
         }
 
         private void MainFrame_ContentRendered(object sender, EventArgs e)
@@ -50,7 +52,9 @@ namespace Hotel_Course_Project
 
         private void ChangeLogPasBtn_Click(object sender, RoutedEventArgs e)
         {
-
+            ChangePasLogWindow changePasLog = new ChangePasLogWindow(_user);
+            changePasLog.ShowDialog();
+            PChanger.MainFrame.Refresh();
         }
     }
 }

+ 3 - 1
Hotel_Course_Project/SomeMethods.cs

@@ -73,7 +73,7 @@ namespace Hotel_Course_Project
 
             //вычисляем хеш-представление в байтах  
             byte[] byteHash = CSP.ComputeHash(bytes);
-
+            
             //создаем пустую строку
             string hash = string.Empty;
 
@@ -85,5 +85,7 @@ namespace Hotel_Course_Project
             return hash;
         }
         #endregion
+
+        public static string pass;
     }
 }