浏览代码

///////////////

gr682_bpv 4 年之前
父节点
当前提交
ff39a006b6

+ 3 - 2
HotelCalifornia/Client.xaml

@@ -6,8 +6,8 @@
         xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
         xmlns:local="clr-namespace:HotelCalifornia"
         mc:Ignorable="d"
-        Title="Client" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Icon="image/h1.png">
-    <Grid MouseDown="Grid_MouseDown" Loaded="Grid_Loaded">
+        Title="Client" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Icon="image/h1.png" Loaded="Window_Loaded">
+    <Grid MouseDown="Grid_MouseDown">
         <Grid.Background>
             <LinearGradientBrush StartPoint="0.1,0" EndPoint="0.9,1">
                 <GradientStop Color="#7E42F5" Offset="1" />
@@ -56,5 +56,6 @@
         <Button Style="{StaticResource MaterialDesignIconButton}" Foreground="White" ToolTip="Обновить" Margin="508,76,244,325.6" Click="Refresh_Click">
             <materialDesign:PackIcon Kind="Refresh" />
         </Button>
+        <TextBlock Name="idadmintxt" Visibility="Hidden"/>
     </Grid>
 </Window>

+ 26 - 27
HotelCalifornia/Client.xaml.cs

@@ -25,14 +25,17 @@ namespace HotelCalifornia
         public Client()
         {
             InitializeComponent();
+            //Таймер на обновление времени
             DispatcherTimer timer = new DispatcherTimer();
             timer.Tick += new EventHandler(Update_Timer_Tick);
             timer.Interval = new TimeSpan(0, 0, 1);
             timer.Start();
         }
 
+        //Строка подключения
         SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=kursah;Integrated Security=True");
 
+        //Вывод даты и время в textblock
         private void Update_Timer_Tick(object sender, EventArgs e)
         {
             timetxt.Text = DateTime.Now.ToString();
@@ -47,38 +50,26 @@ namespace HotelCalifornia
         //Возврат к окну выбора функции
         private void Back(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите вернуться к предыдущему окну?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Variant variant = new Variant();
-                    this.Close();
-                    variant.Show();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            Variant variant = new Variant();
+            variant.idadmintxt.Text = idadmintxt.Text;
+            this.Close();
+            variant.Show();     
         }
 
         //Выход из приложения
         private void Close(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите выйти из приложения?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Application.Current.Shutdown();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            Application.Current.Shutdown();
         }
 
+        //Свернуть окно
         private void WindMin_Click(object sender, RoutedEventArgs e)
         {
             this.WindowState = WindowState.Minimized;
         }
 
+        //Ограничение для ввода текста
+        #region Ограничение
         private void familiatxt_TextChanged(object sender, TextChangedEventArgs e)
         {
             if (sender is TextBox textBox)
@@ -123,7 +114,9 @@ namespace HotelCalifornia
                (textBox.Text.Where(ch => (ch >= '0' && ch <= '9')).ToArray());
             }
         }
+        #endregion
 
+        //Добавление клиента
         private void Add_Click(object sender, RoutedEventArgs e)
         {
             try
@@ -139,8 +132,8 @@ namespace HotelCalifornia
                 else
                 {
                     con.Open();
-                        string reg = "INSERT INTO Client (LastName_Client,FirstName_Client,MiddleName_Client,Telephone_Client,Passport) VALUES('" + familiatxt.Text + "','" + nametxt.Text + "','" + otchestvotxt.Text + "','" + telephonetxt.Text + "','" + passporttxt.Text + "')";
-                        SqlDataAdapter dataAdapter = new SqlDataAdapter(reg, con);
+                        string sql = "INSERT INTO Client (LastName_Client,FirstName_Client,MiddleName_Client,Telephone_Client,Passport) VALUES('" + familiatxt.Text + "','" + nametxt.Text + "','" + otchestvotxt.Text + "','" + telephonetxt.Text + "','" + passporttxt.Text + "')";
+                        SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
                         dataAdapter.SelectCommand.ExecuteNonQuery();
                         con.Close();
                         idclienttxt.Text = "";
@@ -160,6 +153,7 @@ namespace HotelCalifornia
             }
         }
 
+        //Обновление клиента
         private void Update_Click(object sender, RoutedEventArgs e)
         {
             if (idclienttxt.Text == "")
@@ -200,6 +194,7 @@ namespace HotelCalifornia
             }
         }
 
+        //Удаление клиента
         private void Delete_Click(object sender, RoutedEventArgs e)
         {
             if (idclienttxt.Text == "")
@@ -232,6 +227,7 @@ namespace HotelCalifornia
             }
         }
 
+        //Фомировка данных из БД
         void showgrid()
         {
             try
@@ -259,11 +255,7 @@ namespace HotelCalifornia
             }
         }
 
-        private void Grid_Loaded(object sender, RoutedEventArgs e)
-        {
-            showgrid();
-        }
-
+        //Выбор строки из БД
         private void dataclient_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             try
@@ -286,6 +278,7 @@ namespace HotelCalifornia
             }
         }
 
+        //Обновление
         private void Refresh_Click(object sender, RoutedEventArgs e)
         {
             idclienttxt.Text = "";
@@ -296,5 +289,11 @@ namespace HotelCalifornia
             passporttxt.Text = "";
             showgrid();
         }
+
+        //Запуск в самом начале
+        private void Window_Loaded(object sender, RoutedEventArgs e)
+        {
+            showgrid();
+        }
     }
 }

+ 1 - 0
HotelCalifornia/ClientRoom.xaml

@@ -50,5 +50,6 @@
         <Button Style="{StaticResource MaterialDesignIconButton}" Foreground="White" ToolTip="Обновить" Margin="508,103,244,298.6" Click="Refresh_Click">
             <materialDesign:PackIcon Kind="Refresh" />
         </Button>
+        <TextBlock Name="idadmintxt" Visibility="Hidden"/>
     </Grid>
 </Window>

+ 26 - 15
HotelCalifornia/ClientRoom.xaml.cs

@@ -25,49 +25,50 @@ namespace HotelCalifornia
         public ClientRoom()
         {
             InitializeComponent();
+            //Таймер на обновление времени
             DispatcherTimer timer = new DispatcherTimer();
             timer.Tick += new EventHandler(Update_Timer_Tick);
             timer.Interval = new TimeSpan(0, 0, 1);
             timer.Start();
         }
 
+        //Строка подключения
         SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=kursah;Integrated Security=True");
 
+        //Вывод даты и время в textblock
         private void Update_Timer_Tick(object sender, EventArgs e)
         {
             timetxt.Text = DateTime.Now.ToString();
         }
 
+        //Перетаскивание окна
         private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
         {
             DragMove();
         }
 
+        //Выход из приложения
         private void Close(object sender, RoutedEventArgs e)
         {
             Application.Current.Shutdown();
         }
 
+        //Свернуть окно
         private void WindMin_Click(object sender, RoutedEventArgs e)
         {
             this.WindowState = WindowState.Minimized;
         }
 
+        //Возврат к окну выбора функции
         private void Back(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите вернуться к предыдущему окну?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Variant variant = new Variant();
-                    this.Close();
-                    variant.Show();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            Variant variant = new Variant();
+            variant.idadmintxt.Text = idadmintxt.Text;
+            this.Close();
+            variant.Show();    
         }
 
+        //Выбор строки из БД
         private void dataClientRoom_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             try
@@ -86,6 +87,7 @@ namespace HotelCalifornia
             }
         }
 
+        //Добавление заселения
         private void Add_Click(object sender, RoutedEventArgs e)
         {
             try
@@ -128,8 +130,8 @@ namespace HotelCalifornia
                             }
                             else
                             {
-                                string reg = "INSERT INTO RoomClient (ID_Room,ID_Client) VALUES('" + idroom.ToString() + "','" + idclient.ToString() + "')";
-                                SqlDataAdapter dataAdapter = new SqlDataAdapter(reg, con);
+                                string sql = "INSERT INTO RoomClient (ID_Room,ID_Client) VALUES('" + idroom.ToString() + "','" + idclient.ToString() + "')";
+                                SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
                                 dataAdapter.SelectCommand.ExecuteNonQuery();
                                 con.Close();
                                 showgrid();
@@ -148,6 +150,7 @@ namespace HotelCalifornia
             }
         }
 
+        //Удаление заселения
         private void Delete_Click(object sender, RoutedEventArgs e)
         {
             if (roomcombo.Text == "" || clientcombo.Text == "")
@@ -212,6 +215,7 @@ namespace HotelCalifornia
             }
         }
 
+        //Запуск в самом начале
         private void Window_Loaded(object sender, RoutedEventArgs e)
         {
             fillroomcombo();
@@ -219,6 +223,7 @@ namespace HotelCalifornia
             showgrid();
         }
 
+        //Фомировка данных из БД
         void showgrid()
         {
             try
@@ -236,20 +241,23 @@ namespace HotelCalifornia
             }
             catch (Exception ex)
             {
+                con.Close();
                 MessageBox.Show("Возникла ошибка! " + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
 
+        //Заполнение combo
+        #region Combo
+        //Combo комнаты
         void fillroomcombo()
         {
-
             try
             {
                 roomcombo.Items.Clear();
                 con.Open();
                 SqlCommand sql = con.CreateCommand();
                 sql.CommandType = CommandType.Text;
-                sql.CommandText = "Select Number_Room from Room WHERE Status_Room = 1";
+                sql.CommandText = "Select Number_Room from Room WHERE Status_Room = 2";
                 sql.ExecuteNonQuery();
                 DataTable dt = new DataTable();
                 SqlDataAdapter da = new SqlDataAdapter(sql);
@@ -266,6 +274,7 @@ namespace HotelCalifornia
                 MessageBox.Show("Возникла ошибка! " + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
+        //Combo клиента
         void fillclientcombo()
         {
             try
@@ -291,7 +300,9 @@ namespace HotelCalifornia
                 MessageBox.Show("Возникла ошибка! " + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
+        #endregion
 
+        //Обновление
         private void Refresh_Click(object sender, RoutedEventArgs e)
         {
             showgrid();

+ 6 - 10
HotelCalifornia/MainWindow.xaml.cs

@@ -28,6 +28,7 @@ namespace HotelCalifornia
             InitializeComponent();        
         }
 
+        //Строка подключения
         SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=kursah;Integrated Security=True");
  
         //Перетаскивание окна
@@ -39,15 +40,7 @@ namespace HotelCalifornia
         //Выход из приложения
         private void Close(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите выйти из приложения?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Application.Current.Shutdown();
-                    break;
-                case MessageBoxResult.No:         
-                    break;
-            }                 
+            Application.Current.Shutdown();        
         }
 
         //Авторизация пользователя
@@ -74,7 +67,6 @@ namespace HotelCalifornia
                         string username = dataSet.Tables[0].Rows[0]["ID_Administrator"].ToString();
                         variant.idadmintxt.Text = username;
                         con.Close();
-                        MessageBox.Show("Добро пожаловать!", "Вход", MessageBoxButton.OK, MessageBoxImage.Information);
                         variant.Show();
                         this.Close();
                     }
@@ -92,6 +84,8 @@ namespace HotelCalifornia
             }       
         }
 
+        //Ограничение для ввода текста
+        #region Ограничения
         //Запрет пробела
         private void logintxt_PreviewKeyDown(object sender, KeyEventArgs e)
         {
@@ -128,7 +122,9 @@ namespace HotelCalifornia
             bool c = new Regex("[^0-9]+").IsMatch(e.Text);
             e.Handled = a && b && c;
         }
+        #endregion
 
+        //Свернуть окно
         private void WindMin_Click(object sender, RoutedEventArgs e)
         {
             this.WindowState = WindowState.Minimized;

+ 36 - 1
HotelCalifornia/Rezerv.xaml

@@ -6,7 +6,7 @@
         xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
         xmlns:local="clr-namespace:HotelCalifornia"
         mc:Ignorable="d"
-        Title="Rezerv" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Icon="image/h1.png">
+        Title="Rezerv" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Icon="image/h1.png" Loaded="Window_Loaded">
     <Grid MouseDown="Grid_MouseDown">
         <Grid.Background>
             <LinearGradientBrush StartPoint="0.1,0" EndPoint="0.9,1">
@@ -26,5 +26,40 @@
             <materialDesign:PackIcon
     Kind="WindowMinimize" Foreground="White"/>
         </Button>
+        <StackPanel Margin="6,158,534,86.6" Orientation="Vertical">
+            <ComboBox BorderBrush="White" Name="clientcombo" Margin="10,0,0,0" FontSize="18" FontFamily="Century Gothic" Foreground="White" Style="{StaticResource MaterialDesignFloatingHintComboBox}"
+             materialDesign:ColorZoneAssist.Mode="Inverted" materialDesign:HintAssist.Hint="Клиент" Height="48"/>
+            <ComboBox BorderBrush="White" Name="roomcombo" Margin="10,0,0,0" FontSize="18" FontFamily="Century Gothic" Foreground="White" Style="{StaticResource MaterialDesignFloatingHintComboBox}"
+             materialDesign:ColorZoneAssist.Mode="Inverted" materialDesign:HintAssist.Hint="Комната" Height="48"/>
+            <DatePicker Name="datein" Foreground="White" BorderBrush="White"  Margin="10,10,0,0" Style="{StaticResource MaterialDesignFloatingHintDatePicker}" FontSize="18" FontFamily="Century Gothic" SelectedDateFormat="Short" materialDesign:HintAssist.Hint="Дата прибытия"/>
+            <DatePicker Name="dateout" Foreground="White" BorderBrush="White"  Margin="10,15,0,0" Style="{StaticResource MaterialDesignDatePicker}" FontSize="18" FontFamily="Century Gothic" SelectedDateFormat="Short" materialDesign:HintAssist.Hint="Дата отъезда"/>
+        </StackPanel>
+        <DataGrid Name="datarezerv" IsReadOnly="True" HorizontalAlignment="Left" Height="257" Margin="290,158,0,0" VerticalAlignment="Top" Width="497" SelectionChanged="datarezerv_SelectionChanged" />
+        <StackPanel Margin="13,362,534,1.6" Orientation="Horizontal">
+            <Button Style="{StaticResource MaterialDesignIconButton}" Foreground="White" ToolTip="Добавить" Margin="25,0,0,0" Click="Add_Click">
+                <materialDesign:PackIcon Kind="Add" />
+            </Button>
+            <Button Style="{StaticResource MaterialDesignIconButton}" Foreground="White" ToolTip="Редактировать" Margin="25,0,0,0" Click="Update_Click">
+                <materialDesign:PackIcon Kind="Edit" />
+            </Button>
+            <Button Style="{StaticResource MaterialDesignIconButton}" Foreground="White" ToolTip="Удалить" Margin="25,0,0,0" Click="Delete_Click">
+                <materialDesign:PackIcon Kind="Delete" />
+            </Button>
+        </StackPanel>
+        <TextBlock Name="idadmintxt" Visibility="Hidden"/>
+        <ComboBox BorderBrush="White" Name="room1combo" Margin="302,103,362,296.6" FontSize="18" FontFamily="Century Gothic" Foreground="White" Style="{StaticResource MaterialDesignFloatingHintComboBox}"
+             materialDesign:ColorZoneAssist.Mode="Inverted" materialDesign:HintAssist.Hint="Выборка" Height="50"/>
+        <Button Style="{StaticResource MaterialDesignFloatingActionMiniLightButton}" ToolTip="Поиск" Margin="450,113,310,296.6" Click="Search_Click">
+            <materialDesign:PackIcon
+    Kind="Search"
+    Height="25"
+    Width="25"/>
+        </Button>
+        <Button Style="{StaticResource MaterialDesignIconButton}" Foreground="White" ToolTip="Обновить" Margin="499,107,253,294.6" Click="Refresh_Click">
+            <materialDesign:PackIcon Kind="Refresh" />
+        </Button>
+        <TextBlock Name="numbroomtxt" Visibility="Hidden"/>
+        <Label Content="Резервирование" Foreground="White" FontSize="35" FontFamily="Century Gothic" HorizontalAlignment="Center"  Width="312" Margin="244,22,244,369.6"  />
+        <TextBlock x:Name="timetxt" HorizontalAlignment="Center" FontFamily="Century Gothic" Margin="551,120,20,0" TextWrapping="Wrap" Foreground="White" FontSize="22" VerticalAlignment="Top" Height="28" Width="229"/>
     </Grid>
 </Window>

文件差异内容过多而无法显示
+ 375 - 12
HotelCalifornia/Rezerv.xaml.cs


+ 3 - 2
HotelCalifornia/Room.xaml

@@ -6,8 +6,8 @@
         xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
         xmlns:local="clr-namespace:HotelCalifornia"
         mc:Ignorable="d"
-        Title="Room" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Icon="image/h1.png">
-    <Grid MouseDown="Grid_MouseDown" Loaded="Grid_Loaded" >
+        Title="Room" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Icon="image/h1.png" Loaded="Window_Loaded">
+    <Grid MouseDown="Grid_MouseDown">
         <Grid.Background>
             <LinearGradientBrush StartPoint="0.1,0" EndPoint="0.9,1">
                 <GradientStop Color="#7E42F5" Offset="1" />
@@ -54,5 +54,6 @@
         <Button Style="{StaticResource MaterialDesignIconButton}" Foreground="White" ToolTip="Обновить" Margin="508,76,244,325.6" Click="Refresh_Click">
             <materialDesign:PackIcon Kind="Refresh" />
         </Button>
+        <TextBlock Name="idadmintxt" Visibility="Hidden"/>
     </Grid>
 </Window>

+ 33 - 33
HotelCalifornia/Room.xaml.cs

@@ -27,6 +27,7 @@ namespace HotelCalifornia
         public Room()
         {
             InitializeComponent();
+            //Таймер на обновление времени
             DispatcherTimer timer = new DispatcherTimer();
             timer.Tick += new EventHandler(Update_Timer_Tick);
             timer.Interval = new TimeSpan(0, 0, 1);
@@ -35,8 +36,11 @@ namespace HotelCalifornia
 
         //Строка подключения
         SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=kursah;Integrated Security=True");
+
+        //Значение статуса
         string status = "";
 
+        //Вывод даты и время в textblock
         private void Update_Timer_Tick(object sender, EventArgs e)
         {
             timetxt.Text = DateTime.Now.ToString();
@@ -48,36 +52,23 @@ namespace HotelCalifornia
             DragMove();
         }
 
-        //Возвращение к предыдущему окну
+        //Возврат к окну выбора функции
         private void Back(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите вернуться к предыдущему окну?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Variant variant = new Variant();
-                    this.Close();
-                    variant.Show();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            Variant variant = new Variant();
+            variant.idadmintxt.Text = idadmintxt.Text;
+            this.Close();
+            variant.Show();
         }
 
-        //Закрытие окна
+        //Выход из приложения
         private void Close(object sender, RoutedEventArgs e)
-        {
-            MessageBoxResult result = MessageBox.Show("Вы хотите выйти из приложения?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Application.Current.Shutdown();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+        {                
+            Application.Current.Shutdown();
         }
 
+        //Ограничение для ввода текста
+        #region Ограничения
         //Для ввода только цифр
         private void numbertxt_PreviewTextInput(object sender, TextCompositionEventArgs e)
         {
@@ -107,8 +98,9 @@ namespace HotelCalifornia
                 e.Handled = true;
             }
         }
+        #endregion
 
-        //Добавление
+        //Добавление комнаты
         private void Add_Click(object sender, RoutedEventArgs e)
         {
             try
@@ -141,8 +133,8 @@ namespace HotelCalifornia
                             status = "1";
                         else
                             status = "2";
-                        string reg = "INSERT INTO Room (Number_Room,Telephone_Room,Status_Room) VALUES('" + numbertxt.Text + "','" + telephonetxt.Text + "','" + status.ToString() + "')";
-                        SqlDataAdapter dataAdapter = new SqlDataAdapter(reg, con);
+                        string sql = "INSERT INTO Room (Number_Room,Telephone_Room,Status_Room) VALUES('" + numbertxt.Text + "','" + telephonetxt.Text + "','" + status.ToString() + "')";
+                        SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
                         dataAdapter.SelectCommand.ExecuteNonQuery();
                         con.Close();
                         idroomtxt.Text = "";
@@ -161,11 +153,7 @@ namespace HotelCalifornia
             }
         }
 
-        private void WindMin_Click(object sender, RoutedEventArgs e)
-        {
-            this.WindowState = WindowState.Minimized;
-        }
-
+        //Обнавление комнаты
         private void Update_Click(object sender, RoutedEventArgs e)
         {
             try
@@ -215,6 +203,7 @@ namespace HotelCalifornia
             }
         }
 
+        //Удаление комнаты
         private void Delete_Click(object sender, RoutedEventArgs e)
         {
             if (idroomtxt.Text == "")
@@ -245,11 +234,13 @@ namespace HotelCalifornia
             }
         }
 
-        private void Grid_Loaded(object sender, RoutedEventArgs e)
+        //Свернуть окно
+        private void WindMin_Click(object sender, RoutedEventArgs e)
         {
-            showgrid();
+            this.WindowState = WindowState.Minimized;
         }
 
+        //Фомировка данных из БД
         void showgrid()
         {
             try
@@ -270,10 +261,12 @@ namespace HotelCalifornia
             }
             catch (Exception ex)
             {
+                con.Close();
                 MessageBox.Show("Возникла ошибка! " + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
 
+        //Выбор строки из БД
         private void dataroom_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             try
@@ -298,6 +291,7 @@ namespace HotelCalifornia
             }
         }
 
+        //Обновление
         private void Refresh_Click(object sender, RoutedEventArgs e)
         {
             showgrid();
@@ -306,5 +300,11 @@ namespace HotelCalifornia
             telephonetxt.Text = "";
             yescheck.IsChecked = true;
         }
+
+        //Запуск в самом начале
+        private void Window_Loaded(object sender, RoutedEventArgs e)
+        {
+            showgrid();
+        }
     }
 }

+ 5 - 4
HotelCalifornia/Staff.xaml

@@ -6,8 +6,8 @@
         xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
         xmlns:local="clr-namespace:HotelCalifornia"
         mc:Ignorable="d"
-        Title="Staff" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Icon="image/h1.png">
-    <Grid Loaded="Grid_Loaded">
+        Title="Staff" Height="450" Width="800" WindowStartupLocation="CenterScreen" ResizeMode="NoResize" WindowStyle="None" Icon="image/h1.png" Loaded="Window_Loaded">
+    <Grid MouseDown="Grid_MouseDown">
         <Grid.Background>
             <LinearGradientBrush StartPoint="0.1,0" EndPoint="0.9,1">
                 <GradientStop Color="#7E42F5" Offset="1" />
@@ -34,8 +34,8 @@
                 materialDesign:HintAssist.Hint="Отчество работника" TextChanged="otchestvotxt_TextChanged"/>
             <TextBox x:Name="logintxt" Margin="10,15,0,0" FontSize="18" FontFamily="Century Gothic" Foreground="White" MaxLength="10"
                 materialDesign:HintAssist.Hint="Логин работника" TextChanged="logintxt_TextChanged"/>
-            <TextBox x:Name="passwordtxt" Margin="10,15,0,0" FontSize="18" FontFamily="Century Gothic" Foreground="White" MaxLength="10"
-                materialDesign:HintAssist.Hint="Пароль работника" TextChanged="passwordtxt_TextChanged"/>
+            <PasswordBox x:Name="passwordtxt" Margin="10,15,0,0" FontSize="18" FontFamily="Century Gothic" Foreground="White" MaxLength="10"
+                materialDesign:HintAssist.Hint="Пароль работника" PasswordChanged="passwordtxt_PasswordChanged"/>
         </StackPanel>
         <StackPanel Margin="6,364,547,-0.4" Orientation="Horizontal">
             <Button x:Name="Add" Style="{StaticResource MaterialDesignIconButton}" Foreground="White" ToolTip="Добавить" Margin="25,0,0,0" Click="Add_Click">
@@ -54,5 +54,6 @@
         <Button Style="{StaticResource MaterialDesignIconButton}" Foreground="White" ToolTip="Обновить" Margin="508,76,244,325.6" Click="Refresh_Click">
             <materialDesign:PackIcon Kind="Refresh" />
         </Button>
+        <TextBlock Name="idadmintxt" Visibility="Hidden"/>
     </Grid>
 </Window>

+ 49 - 41
HotelCalifornia/Staff.xaml.cs

@@ -25,52 +25,44 @@ namespace HotelCalifornia
         public Staff()
         {
             InitializeComponent();
-            DispatcherTimer timer = new DispatcherTimer();
+            //Таймер на обновление времени
+            DispatcherTimer timer = new DispatcherTimer();   
             timer.Tick += new EventHandler(Update_Timer_Tick);
             timer.Interval = new TimeSpan(0, 0, 1);
             timer.Start();
         }
 
+        //Строка подключения
         SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=kursah;Integrated Security=True");
 
+        //Вывод даты и время в textblock
         private void Update_Timer_Tick(object sender, EventArgs e)
         {
             timetxt.Text = DateTime.Now.ToString();
         }
 
+        //Выход из приложения
         private void Close(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите выйти из приложения?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Application.Current.Shutdown();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            Application.Current.Shutdown();
         }
 
+        //Свернуть окно
         private void WindMin_Click(object sender, RoutedEventArgs e)
         {
             this.WindowState = WindowState.Minimized;
         }
 
+        //Возврат к окну выбора функции
         private void Back(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите вернуться к предыдущему окну?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Variant variant = new Variant();
-                    this.Close();
-                    variant.Show();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            Variant variant = new Variant();
+            variant.idadmintxt.Text = idadmintxt.Text;
+            this.Close();
+            variant.Show();
         }
 
+        //Выбор строки из БД
         private void datastaff_SelectionChanged(object sender, SelectionChangedEventArgs e)
         {
             try
@@ -84,7 +76,7 @@ namespace HotelCalifornia
                     familiyatxt.Text = rowView["LastName"].ToString();
                     otchestvotxt.Text = rowView["MiddleName"].ToString();
                     logintxt.Text = rowView["Login"].ToString();
-                    passwordtxt.Text = rowView["Password"].ToString();
+                    passwordtxt.Password = rowView["Password"].ToString();
                 }
             }
             catch (Exception ex)
@@ -93,9 +85,10 @@ namespace HotelCalifornia
             }
         }
 
+        //Добавление администратора
         private void Add_Click(object sender, RoutedEventArgs e)
         {
-            if (familiyatxt.Text == "" || nametxt.Text == "" || otchestvotxt.Text == "" || logintxt.Text == "" || passwordtxt.Text == "")
+            if (familiyatxt.Text == "" || nametxt.Text == "" || otchestvotxt.Text == "" || logintxt.Text == "" || passwordtxt.Password == "")
             {
                 MessageBox.Show("Заполните все поля!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
             }
@@ -117,8 +110,8 @@ namespace HotelCalifornia
                     }
                     else
                     {
-                        string reg = "INSERT INTO Administrator (LastName,FirstName,MiddleName,Login,Password) VALUES('" + familiyatxt.Text + "','" + nametxt.Text + "','" + otchestvotxt.Text + "','" + logintxt.Text + "','" + passwordtxt.Text + "')";
-                        SqlDataAdapter dataAdapter = new SqlDataAdapter(reg, con);
+                        string sql = "INSERT INTO Administrator (LastName,FirstName,MiddleName,Login,Password) VALUES('" + familiyatxt.Text + "','" + nametxt.Text + "','" + otchestvotxt.Text + "','" + logintxt.Text + "','" + passwordtxt.Password + "')";
+                        SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
                         dataAdapter.SelectCommand.ExecuteNonQuery();
                         con.Close();
                         showgrid();
@@ -127,7 +120,7 @@ namespace HotelCalifornia
                         familiyatxt.Text = "";
                         otchestvotxt.Text = "";
                         logintxt.Text = "";
-                        passwordtxt.Text = "";
+                        passwordtxt.Password = "";
                         MessageBox.Show("Администратор был добавлен!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
                     }
                 }
@@ -139,13 +132,14 @@ namespace HotelCalifornia
             }
         }
 
+        //Обновление администратора
         private void Update_Click(object sender, RoutedEventArgs e)
         {
             if (idtxt.Text == "")
             {
                 MessageBox.Show("Поле не выбрано! Выберите нужное поле!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
             }
-            else if (familiyatxt.Text == "" || nametxt.Text == "" || otchestvotxt.Text == "" || logintxt.Text == "" || passwordtxt.Text == "")
+            else if (familiyatxt.Text == "" || nametxt.Text == "" || otchestvotxt.Text == "" || logintxt.Text == "" || passwordtxt.Password == "")
             {
                 MessageBox.Show("Заполните все поля!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
             }
@@ -154,7 +148,7 @@ namespace HotelCalifornia
                 try
                 {
                     con.Open();
-                    string sql = "Update Administrator set FirstName ='" + nametxt.Text + "', LastName = '" + familiyatxt.Text + "', MiddleName = '" + otchestvotxt.Text + "', Login = '" + logintxt.Text + "', Password = '" + passwordtxt.Text + "' where ID_Administrator = '" + idtxt.Text + "'";
+                    string sql = "Update Administrator set FirstName ='" + nametxt.Text + "', LastName = '" + familiyatxt.Text + "', MiddleName = '" + otchestvotxt.Text + "', Login = '" + logintxt.Text + "', Password = '" + passwordtxt.Password + "' where ID_Administrator = '" + idtxt.Text + "'";
                     SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
                     dataAdapter.SelectCommand.ExecuteNonQuery();
                     con.Close();
@@ -163,7 +157,7 @@ namespace HotelCalifornia
                     familiyatxt.Text = "";
                     otchestvotxt.Text = "";
                     logintxt.Text = "";
-                    passwordtxt.Text = "";
+                    passwordtxt.Password = "";
                     showgrid();
                     MessageBox.Show("Администратор был изменен!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
                 }
@@ -175,6 +169,7 @@ namespace HotelCalifornia
             }
         }
 
+        //Удаление администратора
         private void Delete_Click(object sender, RoutedEventArgs e)
         {
             if (idtxt.Text == "")
@@ -195,7 +190,7 @@ namespace HotelCalifornia
                     familiyatxt.Text = "";
                     otchestvotxt.Text = "";
                     logintxt.Text = "";
-                    passwordtxt.Text = "";
+                    passwordtxt.Password = "";
                     showgrid();
                     MessageBox.Show("Администратор удален!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
                 }
@@ -207,6 +202,8 @@ namespace HotelCalifornia
             }
         }
 
+        //Ограничение для ввода текста
+        #region Ограничение
         private void nametxt_TextChanged(object sender, TextChangedEventArgs e)
         {
             if (sender is TextBox textBox)
@@ -243,7 +240,7 @@ namespace HotelCalifornia
             }
         }
 
-        private void passwordtxt_TextChanged(object sender, TextChangedEventArgs e)
+        private void passwordtxt_PasswordChanged(object sender, RoutedEventArgs e)
         {
             if (sender is TextBox textBox)
             {
@@ -251,19 +248,16 @@ namespace HotelCalifornia
                (textBox.Text.Where(ch => (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9')).ToArray());
             }
         }
+        #endregion
 
-        private void Grid_Loaded(object sender, RoutedEventArgs e)
-        {
-            showgrid();
-        }
-
+        //Фомировка данных из БД
         void showgrid()
         {
             try
             {
                 con.Open();
-                string rke = "SELECT * From Administrator";
-                SqlDataAdapter dataAdapter = new SqlDataAdapter(rke, con);
+                string sql = "SELECT * From Administrator";
+                SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
                 DataTable data = new DataTable("Administrator");
                 dataAdapter.Fill(data);
                 datastaff.ItemsSource = data.DefaultView;
@@ -274,15 +268,17 @@ namespace HotelCalifornia
                 datastaff.Columns[2].Header = "Имя";
                 datastaff.Columns[3].Header = "Отчество";
                 datastaff.Columns[4].Header = "Логин";
-                datastaff.Columns[5].Header = "Пароль";
+                datastaff.Columns[5].Visibility = Visibility.Collapsed;
                 datastaff.Columns[0].Visibility = Visibility.Collapsed;
             }
             catch (Exception ex)
             {
+                con.Close();
                 MessageBox.Show("Возникла ошибка! " + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
 
+        //Обновление
         private void Refresh_Click(object sender, RoutedEventArgs e)
         {
             showgrid();
@@ -291,7 +287,19 @@ namespace HotelCalifornia
             familiyatxt.Text = "";
             otchestvotxt.Text = "";
             logintxt.Text = "";
-            passwordtxt.Text = "";
+            passwordtxt.Password = "";
+        }
+
+        //Перетаскивание окна
+        private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            DragMove();
+        }
+
+        //Запуск в самом начале
+        private void Window_Loaded(object sender, RoutedEventArgs e)
+        {
+            showgrid();
         }
     }
-}
+}

+ 28 - 76
HotelCalifornia/Variant.xaml.cs

@@ -30,7 +30,7 @@ namespace HotelCalifornia
             timer.Start();
         }
 
-        //Вывод даты и время в textbox
+        //Вывод даты и время в textblock
         private void Update_Timer_Tick(object sender, EventArgs e)
         {
             timetxt.Text = DateTime.Now.ToString();
@@ -45,65 +45,36 @@ namespace HotelCalifornia
         //Выход из приложения
         private void Close(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите выйти из приложения?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Application.Current.Shutdown();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            Application.Current.Shutdown();
         }
         
         //Возврат к окну авторизации
         private void Back(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите вернуться к окну авторизации?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    MainWindow mainWindow = new MainWindow();
-                    this.Close();
-                    mainWindow.Show();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            MainWindow mainWindow = new MainWindow();
+            this.Close();
+            mainWindow.Show();
         }
 
         //Переход к окну клиентов
         private void KlientGO_Click(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите перейти к окну клиентов?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Client client = new Client();
-                    this.Close();
-                    client.Show();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            Client client = new Client();
+            client.idadmintxt.Text = idadmintxt.Text;
+            this.Close();
+            client.Show();
         }
 
         //Переход к окну комнат
         private void RoomGO_Click(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите перейти к окну комнат?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Room room = new Room();
-                    this.Close();
-                    room.Show();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            Room room = new Room();
+            room.idadmintxt.Text = idadmintxt.Text;
+            this.Close();
+            room.Show();
         }
 
+        //Свернуть окно
         private void WindMin_Click(object sender, RoutedEventArgs e)
         {
             this.WindowState = WindowState.Minimized;
@@ -112,47 +83,28 @@ namespace HotelCalifornia
         //Переход к окну работников
         private void StaffGO_Click(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите перейти к окну работников?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Staff staff = new Staff();
-                    this.Close();
-                    staff.Show();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            Staff staff = new Staff();
+            staff.idadmintxt.Text = idadmintxt.Text;
+            this.Close();
+            staff.Show();
         }
 
+        //Переход к окну заселения
         private void ZaselenieGO_Click(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите перейти к окну заселения?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    ClientRoom clientRoom = new ClientRoom();
-                    this.Close();
-                    clientRoom.Show();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            ClientRoom clientRoom = new ClientRoom();
+            clientRoom.idadmintxt.Text = idadmintxt.Text;
+            this.Close();
+            clientRoom.Show();
         }
 
+        //Переход к окну резервирования
         private void RezervirovanieGO_Click(object sender, RoutedEventArgs e)
         {
-            MessageBoxResult result = MessageBox.Show("Вы хотите перейти к окну резервирования?", "Предупреждение", MessageBoxButton.YesNo, MessageBoxImage.Question);
-            switch (result)
-            {
-                case MessageBoxResult.Yes:
-                    Rezerv rezerv = new Rezerv();
-                    this.Close();
-                    rezerv.Show();
-                    break;
-                case MessageBoxResult.No:
-                    break;
-            }
+            Rezerv rezerv = new Rezerv();
+            rezerv.idadmintxt.Text = idadmintxt.Text;
+            this.Close();
+            rezerv.Show();
         }
     }
 }