gr682_bpv 3 gadi atpakaļ
vecāks
revīzija
f2aa66f880

+ 1 - 1
HotelCalifornia/Client.xaml

@@ -25,7 +25,7 @@
             <TextBox Name="telephonetxt" Margin="10,15,0,0" FontSize="18" FontFamily="Century Gothic" Foreground="White" MaxLength="11"
   materialDesign:HintAssist.Hint="Телефон клиента" TextChanged="telephonetxt_TextChanged"/>
             <TextBox Name="passporttxt" Margin="10,15,0,0" FontSize="18" FontFamily="Century Gothic" Foreground="White" MaxLength="10"
-  materialDesign:HintAssist.Hint="Серия и номер клиента"  materialDesign:HintAssist.HelperText="Без пробелов" TextChanged="passporttxt_TextChanged"/>
+  materialDesign:HintAssist.Hint="Серия и номер паспорта"  materialDesign:HintAssist.HelperText="Без пробелов" TextChanged="passporttxt_TextChanged"/>
         </StackPanel>
         <StackPanel Margin="10,364,537,-0.4" Orientation="Horizontal">
             <Button Style="{StaticResource MaterialDesignIconButton}" Foreground="White" ToolTip="Добавить" Margin="25,0,0,0" Click="Add_Click">

+ 7 - 1
HotelCalifornia/Client.xaml.cs

@@ -44,7 +44,13 @@ namespace HotelCalifornia
         //Перетаскивание окна
         private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
         {
-            DragMove();
+            try
+            {
+                DragMove();
+            }
+            catch
+            {
+            }
         }
 
         //Возврат к окну выбора функции

+ 8 - 2
HotelCalifornia/ClientRoom.xaml.cs

@@ -44,7 +44,13 @@ namespace HotelCalifornia
         //Перетаскивание окна
         private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
         {
-            DragMove();
+            try
+            {
+                DragMove();
+            }
+            catch
+            {
+            }
         }
 
         //Выход из приложения
@@ -188,7 +194,7 @@ namespace HotelCalifornia
                             adapter2.Fill(dataSet2);
                             if (dataSet2.Tables[0].Rows.Count > 0)
                             {
-                                string sql = "DELETE FROM RoomClient WHERE ID_Room = '" + idroom.ToString() + "' and ID_Client = '"+idclient.ToString()+"'";
+                                string sql = "DELETE FROM RoomClient WHERE ID_Room = '" + idroom.ToString() + "' and ID_Client = '"+idclient.ToString()+"'; Update Rezervirovanie set ID_Status = '2' where ID_Client = '"+idclient.ToString()+"'; Update Room set Status_Room = '1' Where ID_Room = '"+idroom.ToString()+"'";
                                 SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
                                 dataAdapter.SelectCommand.ExecuteNonQuery();
                                 con.Close();

+ 10 - 0
HotelCalifornia/HotelCalifornia.csproj

@@ -69,6 +69,9 @@
     <Compile Include="ClientRoom.xaml.cs">
       <DependentUpon>ClientRoom.xaml</DependentUpon>
     </Compile>
+    <Compile Include="Report.xaml.cs">
+      <DependentUpon>Report.xaml</DependentUpon>
+    </Compile>
     <Compile Include="Rezerv.xaml.cs">
       <DependentUpon>Rezerv.xaml</DependentUpon>
     </Compile>
@@ -101,6 +104,10 @@
       <DependentUpon>MainWindow.xaml</DependentUpon>
       <SubType>Code</SubType>
     </Compile>
+    <Page Include="Report.xaml">
+      <SubType>Designer</SubType>
+      <Generator>MSBuild:Compile</Generator>
+    </Page>
     <Page Include="Rezerv.xaml">
       <SubType>Designer</SubType>
       <Generator>MSBuild:Compile</Generator>
@@ -169,6 +176,9 @@
   <ItemGroup>
     <Resource Include="Image\room.png" />
   </ItemGroup>
+  <ItemGroup>
+    <Resource Include="Image\gvozd.png" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="..\packages\MaterialDesignThemes.4.0.0\build\MaterialDesignThemes.targets" Condition="Exists('..\packages\MaterialDesignThemes.4.0.0\build\MaterialDesignThemes.targets')" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

BIN
HotelCalifornia/Image/gvozd.png


+ 2 - 0
HotelCalifornia/MainWindow.xaml

@@ -52,5 +52,7 @@
             <materialDesign:PackIcon
     Kind="WindowMinimize" Foreground="White"/>
         </Button>
+        <Image Source="Image/gvozd.png" Stretch="UniformToFill" Margin="104,10,573,374"/>
+        <Image Source="Image/gvozd.png" Stretch="UniformToFill" Margin="242,5,435,379"/>
     </Grid>
 </Window>

+ 26 - 6
HotelCalifornia/MainWindow.xaml.cs

@@ -34,7 +34,13 @@ namespace HotelCalifornia
         //Перетаскивание окна
         private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
         {
-            DragMove();
+            try
+            {
+                DragMove();
+            }
+            catch
+            {
+            }
         }
 
         //Выход из приложения
@@ -63,16 +69,30 @@ namespace HotelCalifornia
                     adapter.Fill(dataSet);
                     if (dataSet.Tables[0].Rows.Count > 0)
                     {
-                        Variant variant = new Variant();                    
+                        string idrole = dataSet.Tables[0].Rows[0]["ID_Role"].ToString();
                         string username = dataSet.Tables[0].Rows[0]["ID_Administrator"].ToString();
-                        variant.idadmintxt.Text = username;
-                        con.Close();
-                        variant.Show();
-                        this.Close();
+                        if (idrole.ToString() == "1")
+                        {
+                            Variant variant = new Variant();
+                            variant.idadmintxt.Text = username;
+                            con.Close();
+                            variant.Show();
+                            this.Close();
+                        }
+                        else
+                        {
+                            Staff staff = new Staff();
+                            staff.idadmintxt.Text = username;
+                            con.Close();
+                            staff.Show();
+                            this.Close();
+                        }               
                     }
                     else
                     {
                         con.Close();
+                        logintxt.Text = "";
+                        passwordtxt.Password = "";
                         MessageBox.Show("Такого Администратора нет в системе!", "Вход", MessageBoxButton.OK, MessageBoxImage.Information);
                     }
                 }

+ 61 - 0
HotelCalifornia/Report.xaml

@@ -0,0 +1,61 @@
+<Window x:Class="HotelCalifornia.Report"
+        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:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
+        xmlns:local="clr-namespace:HotelCalifornia"
+        mc:Ignorable="d"
+        Title="Report" 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" />
+                <GradientStop Color="#383E7A" Offset="0"/>
+            </LinearGradientBrush>
+        </Grid.Background>
+        <TextBlock Name="idadmintxt" Visibility="Hidden"/>
+        <Button Name="WindMin"
+  Style="{StaticResource MaterialDesignIconButton}" ToolTip="Свернуть окно" Margin="694,10,58,391.6" Click="WindMin_Click">
+            <materialDesign:PackIcon Kind="WindowMinimize" Foreground="White"/>
+        </Button>
+        <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="Выход из приложения" Margin="742,10,10,391.6" Click="Close">
+            <materialDesign:PackIcon Kind="ExitToApp" Foreground="White"/>
+        </Button>
+        <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="Вернуться к окну выбора функции" Margin="10,10,742,391.6" Click="Back">
+            <materialDesign:PackIcon Kind="Backburger"  Foreground="White"/>
+        </Button>
+        <Label Content="Отчеты" Foreground="White" FontSize="35" FontFamily="Century Gothic" HorizontalAlignment="Center"  Width="136" Margin="332,14,332,377.6"/>
+        <Button
+            Background="#7E42F5" BorderBrush="Black"
+            materialDesign:ButtonAssist.CornerRadius="25"
+            Margin="50,87,600,307.6" Height="Auto" Click="Rezervirovanie_Click">
+            <TextBlock Text="Резервирование" />
+        </Button>
+        <Button
+            Background="#7E42F5" BorderBrush="Black"
+            materialDesign:ButtonAssist.CornerRadius="25"
+            Margin="230,87,420,307.6" Height="Auto" Click="Client_Click">
+            <TextBlock Text="Клиенты" />
+        </Button>
+        <Button
+            Background="#7E42F5" BorderBrush="Black"
+            materialDesign:ButtonAssist.CornerRadius="25"
+            Margin="424,87,226,307.6" Height="Auto" Click="Room_Click">
+            <TextBlock Text="Комнаты"/>
+        </Button>
+        <Button
+            Background="#7E42F5" BorderBrush="Black"
+            materialDesign:ButtonAssist.CornerRadius="25"
+            Margin="605,87,50,307.6" Height="Auto" Click="RoomClient_Click">
+            <TextBlock Text="Заселенные"/>
+        </Button>
+        <DataGrid Name="datareport" IsReadOnly="True" Margin="50,150,50,51" BorderThickness="1" BorderBrush="Black"/>
+        <Button
+            Background="#7E42F5" BorderBrush="Black"
+            materialDesign:ButtonAssist.CornerRadius="25"
+            Margin="564,403,50,5.6" Height="Auto" Click="Savereport_Click">
+            <TextBlock Text="Сохранить отчет" />
+        </Button>
+    </Grid>
+</Window>

+ 180 - 0
HotelCalifornia/Report.xaml.cs

@@ -0,0 +1,180 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+using System.Data.SqlClient;
+using System.Data;
+
+namespace HotelCalifornia
+{
+    /// <summary>
+    /// Логика взаимодействия для Report.xaml
+    /// </summary>
+    public partial class Report : Window
+    {
+        public Report()
+        {
+            InitializeComponent();
+        }
+
+        //Строка подключения
+        SqlConnection con = new SqlConnection("Data Source=localhost;Initial Catalog=kursah;Integrated Security=True");
+
+        private void Window_Loaded(object sender, RoutedEventArgs e)
+        {
+
+        }
+
+        private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            try
+            {
+                DragMove();
+            }
+            catch
+            {
+            }
+        }
+
+        private void WindMin_Click(object sender, RoutedEventArgs e)
+        {
+            this.WindowState = WindowState.Minimized;
+        }
+
+        private void Close(object sender, RoutedEventArgs e)
+        {
+            Application.Current.Shutdown();
+        }
+
+        private void Back(object sender, RoutedEventArgs e)
+        {
+            Variant variant = new Variant();
+            variant.idadmintxt.Text = idadmintxt.Text;
+            this.Close();
+            variant.Show();
+        }
+
+        private void Client_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                con.Open();
+                string sql = "SELECT ID_Client, LastName_Client, FirstName_Client, MiddleName_Client, Telephone_Client, Passport From Client";
+                SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
+                DataTable data = new DataTable("Client");
+                dataAdapter.Fill(data);
+                datareport.ItemsSource = data.DefaultView;
+                dataAdapter.Update(data);
+                con.Close();
+                datareport.Columns[0].Header = "ID";
+                datareport.Columns[1].Header = "Фамилия";
+                datareport.Columns[2].Header = "Имя";
+                datareport.Columns[3].Header = "Отчество";
+                datareport.Columns[4].Header = "Телефон";
+                datareport.Columns[5].Header = "Паспорт";
+                datareport.Columns[0].Visibility = Visibility.Collapsed;
+                datareport.Margin = new Thickness(150, 150, 130, 51);
+            }
+            catch (Exception ex)
+            {
+                con.Close();
+                MessageBox.Show("Возникла ошибка! " + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
+            }
+        }
+
+        private void Room_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                con.Open();
+                string sql = "SELECT ID_Room, Number_Room, Telephone_Room, RoomStatus.Status From Room inner join RoomStatus on RoomStatus.ID_Status = Room.Status_Room";
+                SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
+                DataTable data = new DataTable("Room");
+                dataAdapter.Fill(data);
+                datareport.ItemsSource = data.DefaultView;
+                dataAdapter.Update(data);
+                con.Close();
+                datareport.Columns[0].Header = "ID";
+                datareport.Columns[1].Header = "Номер комнты";
+                datareport.Columns[2].Header = "Телефон комнаты";
+                datareport.Columns[3].Header = "Статус комнаты";
+                datareport.Columns[0].Visibility = Visibility.Collapsed;
+                datareport.Margin = new Thickness(190, 150, 170, 51);
+            }
+            catch (Exception ex)
+            {
+                con.Close();
+                MessageBox.Show("Возникла ошибка! " + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
+            }
+        }
+
+        private void Rezervirovanie_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                con.Open();
+                string sql = "SELECT Number_Room, Client.LastName_Client, Rezervirovanie.Date_in,Rezervirovanie.Date_out, StatusRezervirovanie.RezervStatus From Room inner join Rezervirovanie on Room.ID_Room = Rezervirovanie.ID_Room inner join Client on Rezervirovanie.[ID_Client] = Client.ID_Client inner join StatusRezervirovanie on Rezervirovanie.ID_Status = StatusRezervirovanie.ID_Status";
+                SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
+                DataTable data = new DataTable("Rezervirovanie");
+                dataAdapter.Fill(data);
+                datareport.ItemsSource = data.DefaultView;
+                dataAdapter.Update(data);
+                con.Close();
+                datareport.Columns[0].Header = "Номер комнаты";
+                datareport.Columns[1].Header = "Фамилия";
+                datareport.Columns[2].Header = "Дата прибытия";
+                datareport.Columns[3].Header = "Дата отбытия";
+                datareport.Columns[4].Header = "Статус";
+                (datareport.Columns[2] as DataGridTextColumn).Binding.StringFormat = "dd/MM/yyyy";
+                (datareport.Columns[3] as DataGridTextColumn).Binding.StringFormat = "dd/MM/yyyy";
+                datareport.Margin = new Thickness(100, 150, 100, 51);
+            }
+            catch (Exception ex)
+            {
+                con.Close();
+                MessageBox.Show("Возникла ошибка! " + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
+            }
+        }
+
+        private void RoomClient_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                con.Open();
+                string sql = "SELECT Number_Room, Client.LastName_Client From Room inner join RoomClient on Room.ID_Room = RoomClient.ID_Room inner join Client on RoomClient.ID_Client = Client.ID_Client";
+                SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
+                DataTable data = new DataTable("RoomClient");
+                dataAdapter.Fill(data);
+                datareport.ItemsSource = data.DefaultView;
+                dataAdapter.Update(data);
+                con.Close();
+                datareport.Columns[0].Header = "Номер комнты";
+                datareport.Columns[1].Header = "Фамилия клиента";
+                datareport.Margin = new Thickness(250, 150, 250, 51);
+            }
+            catch (Exception ex)
+            {
+                con.Close();
+                MessageBox.Show("Возникла ошибка! " + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
+            }
+        }
+
+        private void Savereport_Click(object sender, RoutedEventArgs e)
+        {
+            PrintDialog print = new PrintDialog();
+            if (print.ShowDialog() == true)
+            {
+                print.PrintVisual(datareport, "Report");
+            }
+        }
+    }
+}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 17 - 6
HotelCalifornia/Rezerv.xaml.cs


+ 8 - 2
HotelCalifornia/Room.xaml.cs

@@ -49,7 +49,13 @@ namespace HotelCalifornia
         //Перетаскивание окна
         private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
         {
-            DragMove();
+            try
+            {
+                DragMove();
+            }
+            catch
+            {
+            }
         }
 
         //Возврат к окну выбора функции
@@ -179,7 +185,7 @@ namespace HotelCalifornia
                         else
                             status = "2";
                         con.Open();
-                        string sql = "Update Room set Number_Room ='" + numbertxt.Text + "', Telephone_Room = '" + telephonetxt.Text + "', Status_Room = '" + status.ToString() + "' where ID_Room = '" + idroomtxt.Text + "'";
+                        string sql = "Update Room set Number_Room ='" + numbertxt.Text + "', Telephone_Room = '" + telephonetxt.Text + "', Status_Room = '" + status.ToString() + "' where ID_Room = '" + idroomtxt.Text + "'; DELETE FROM RoomClient WHERE ID_Room = '"+idroomtxt.Text+ "'; DELETE FROM Rezervirovanie WHERE ID_Room = '"+idroomtxt.Text+"' and ID_Status = 1";
                         SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
                         dataAdapter.SelectCommand.ExecuteNonQuery();
                         con.Close();

+ 5 - 3
HotelCalifornia/Staff.xaml

@@ -22,10 +22,10 @@
   Style="{StaticResource MaterialDesignIconButton}" ToolTip="Свернуть окно" Margin="694,10,58,391.6" Click="WindMin_Click">
             <materialDesign:PackIcon Kind="WindowMinimize" Foreground="White"/>
         </Button>
-        <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="Вернуться к окну выбора функции" Margin="10,10,742,391.6" Click="Back">
+        <Button Style="{StaticResource MaterialDesignIconButton}" ToolTip="Вернуться к окну авторизации" Margin="10,10,742,391.6" Click="Back">
             <materialDesign:PackIcon Kind="Backburger"  Foreground="White"/>
         </Button>
-        <StackPanel Margin="6,124,547,85.6" Orientation="Vertical">
+        <StackPanel Margin="6,94,547,46.6" Orientation="Vertical">
             <TextBox x:Name="familiyatxt" Margin="10,15,0,0" FontSize="18" FontFamily="Century Gothic" Foreground="White" MaxLength="15"
                 materialDesign:HintAssist.Hint="Фамилия работника" TextChanged="familiyatxt_TextChanged"/>
             <TextBox x:Name="nametxt" Margin="10,15,0,0" FontSize="18" FontFamily="Century Gothic" Foreground="White" MaxLength="10"
@@ -36,8 +36,10 @@
                 materialDesign:HintAssist.Hint="Логин работника" TextChanged="logintxt_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"/>
+            <ComboBox Name="rolecombo" Margin="10,5,0,0" FontSize="18" FontFamily="Century Gothic" Foreground="White" Style="{StaticResource MaterialDesignFloatingHintComboBox}"
+             materialDesign:ColorZoneAssist.Mode="Inverted" materialDesign:HintAssist.Hint="Роль" Height="48"/>
         </StackPanel>
-        <StackPanel Margin="6,364,547,-0.4" Orientation="Horizontal">
+        <StackPanel Margin="6,374,547,-10.4" Orientation="Horizontal">
             <Button x:Name="Add" Style="{StaticResource MaterialDesignIconButton}" Foreground="White" ToolTip="Добавить" Margin="25,0,0,0" Click="Add_Click">
                 <materialDesign:PackIcon Kind="Add" />
             </Button>

+ 57 - 9
HotelCalifornia/Staff.xaml.cs

@@ -56,10 +56,9 @@ namespace HotelCalifornia
         //Возврат к окну выбора функции
         private void Back(object sender, RoutedEventArgs e)
         {
-            Variant variant = new Variant();
-            variant.idadmintxt.Text = idadmintxt.Text;
+            MainWindow mainWindow = new MainWindow();
             this.Close();
-            variant.Show();
+            mainWindow.Show();
         }
 
         //Выбор строки из БД
@@ -77,6 +76,7 @@ namespace HotelCalifornia
                     otchestvotxt.Text = rowView["MiddleName"].ToString();
                     logintxt.Text = rowView["Login"].ToString();
                     passwordtxt.Password = rowView["Password"].ToString();
+                    rolecombo.Text = rowView["Name_Role"].ToString();
                 }
             }
             catch (Exception ex)
@@ -88,7 +88,7 @@ namespace HotelCalifornia
         //Добавление администратора
         private void Add_Click(object sender, RoutedEventArgs e)
         {
-            if (familiyatxt.Text == "" || nametxt.Text == "" || otchestvotxt.Text == "" || logintxt.Text == "" || passwordtxt.Password == "")
+            if (familiyatxt.Text == "" || nametxt.Text == "" || otchestvotxt.Text == "" || logintxt.Text == "" || passwordtxt.Password == "" || rolecombo.Text == "")
             {
                 MessageBox.Show("Заполните все поля!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
             }
@@ -110,7 +110,12 @@ namespace HotelCalifornia
                     }
                     else
                     {
-                        string sql = "INSERT INTO Administrator (LastName,FirstName,MiddleName,Login,Password) VALUES('" + familiyatxt.Text + "','" + nametxt.Text + "','" + otchestvotxt.Text + "','" + logintxt.Text + "','" + passwordtxt.Password + "')";
+                        string idrole = "";
+                        if (rolecombo.Text == "Администратор")
+                            idrole = "1";
+                        else
+                            idrole = "2";
+                        string sql = "INSERT INTO Administrator (LastName,FirstName,MiddleName,Login,Password,ID_Role) VALUES('" + familiyatxt.Text + "','" + nametxt.Text + "','" + otchestvotxt.Text + "','" + logintxt.Text + "','" + passwordtxt.Password + "', '" + idrole.ToString() + "')";
                         SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
                         dataAdapter.SelectCommand.ExecuteNonQuery();
                         con.Close();
@@ -121,6 +126,7 @@ namespace HotelCalifornia
                         otchestvotxt.Text = "";
                         logintxt.Text = "";
                         passwordtxt.Password = "";
+                        rolecombo.Text = "";
                         MessageBox.Show("Администратор был добавлен!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
                     }
                 }
@@ -139,7 +145,7 @@ namespace HotelCalifornia
             {
                 MessageBox.Show("Поле не выбрано! Выберите нужное поле!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
             }
-            else if (familiyatxt.Text == "" || nametxt.Text == "" || otchestvotxt.Text == "" || logintxt.Text == "" || passwordtxt.Password == "")
+            else if (familiyatxt.Text == "" || nametxt.Text == "" || otchestvotxt.Text == "" || logintxt.Text == "" || passwordtxt.Password == "" || rolecombo.Text == "")
             {
                 MessageBox.Show("Заполните все поля!", "Предупреждение", MessageBoxButton.OK, MessageBoxImage.Information);
             }
@@ -148,7 +154,12 @@ namespace HotelCalifornia
                 try
                 {
                     con.Open();
-                    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 + "'";
+                    string idrole = "";
+                    if (rolecombo.Text == "Администратор")
+                        idrole = "1";
+                    else
+                        idrole = "2";
+                    string sql = "Update Administrator set FirstName ='" + nametxt.Text + "', LastName = '" + familiyatxt.Text + "', MiddleName = '" + otchestvotxt.Text + "', Login = '" + logintxt.Text + "', Password = '" + passwordtxt.Password + "', ID_Role = '"+idrole.ToString()+"' where ID_Administrator = '" + idtxt.Text + "'";
                     SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
                     dataAdapter.SelectCommand.ExecuteNonQuery();
                     con.Close();
@@ -158,6 +169,7 @@ namespace HotelCalifornia
                     otchestvotxt.Text = "";
                     logintxt.Text = "";
                     passwordtxt.Password = "";
+                    rolecombo.Text = "";
                     showgrid();
                     MessageBox.Show("Администратор был изменен!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
                 }
@@ -191,6 +203,7 @@ namespace HotelCalifornia
                     otchestvotxt.Text = "";
                     logintxt.Text = "";
                     passwordtxt.Password = "";
+                    rolecombo.Text = "";
                     showgrid();
                     MessageBox.Show("Администратор удален!", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
                 }
@@ -256,7 +269,7 @@ namespace HotelCalifornia
             try
             {
                 con.Open();
-                string sql = "SELECT * From Administrator";
+                string sql = "SELECT ID_Administrator,LastName, FirstName, MiddleName, Login, Password, [Name_Role]  From Administrator inner join Role on Administrator.ID_Role = Role.ID_Role";
                 SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, con);
                 DataTable data = new DataTable("Administrator");
                 dataAdapter.Fill(data);
@@ -268,6 +281,7 @@ namespace HotelCalifornia
                 datastaff.Columns[2].Header = "Имя";
                 datastaff.Columns[3].Header = "Отчество";
                 datastaff.Columns[4].Header = "Логин";
+                datastaff.Columns[6].Header = "Роль";
                 datastaff.Columns[5].Visibility = Visibility.Collapsed;
                 datastaff.Columns[0].Visibility = Visibility.Collapsed;
             }
@@ -278,6 +292,32 @@ namespace HotelCalifornia
             }
         }
 
+        void fillrolecombo()
+        {
+            try
+            {
+                rolecombo.Items.Clear();
+                con.Open();
+                SqlCommand sql = con.CreateCommand();
+                sql.CommandType = CommandType.Text;
+                sql.CommandText = "Select Name_Role from Role";
+                sql.ExecuteNonQuery();
+                DataTable dt = new DataTable();
+                SqlDataAdapter da = new SqlDataAdapter(sql);
+                da.Fill(dt);
+                foreach (DataRow dr in dt.Rows)
+                {
+                    rolecombo.Items.Add(dr["Name_Role"].ToString());
+                }
+                con.Close();
+            }
+            catch (Exception ex)
+            {
+                con.Close();
+                MessageBox.Show("Возникла ошибка! " + ex.ToString(), "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
+            }
+        }
+
         //Обновление
         private void Refresh_Click(object sender, RoutedEventArgs e)
         {
@@ -288,18 +328,26 @@ namespace HotelCalifornia
             otchestvotxt.Text = "";
             logintxt.Text = "";
             passwordtxt.Password = "";
+            rolecombo.Text = "";
         }
 
         //Перетаскивание окна
         private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
         {
-            DragMove();
+            try
+            {
+                DragMove();
+            }
+            catch
+            {
+            }
         }
 
         //Запуск в самом начале
         private void Window_Loaded(object sender, RoutedEventArgs e)
         {
             showgrid();
+            fillrolecombo();
         }
     }
 }

+ 4 - 4
HotelCalifornia/Variant.xaml

@@ -16,8 +16,8 @@
         </Grid.Background>
         <Label Content="Выберите нужную функцию" Foreground="White" FontSize="35" FontFamily="Century Gothic" HorizontalAlignment="Center" Margin="148,54,148,336.6"/>
         <Label Content="Комнаты" Foreground="White" FontSize="20" FontFamily="Century Gothic" HorizontalAlignment="Center" Margin="60,272,644,143.6"/>
-        <Label Content="Работники" Foreground="White" FontSize="20" FontFamily="Century Gothic" HorizontalAlignment="Center" Margin="196,272,488,143.6" Width="116"/>
-        <Label Content="Клиенты" Foreground="White" FontSize="20" FontFamily="Century Gothic" HorizontalAlignment="Center" Margin="352,272,355,143.6" Width="93"/>
+        <Label Content="Отчеты" Foreground="White" FontSize="20" FontFamily="Century Gothic" HorizontalAlignment="Center" Margin="216,272,500,143.6" Width="84"/>
+        <Label Content="Клиенты" Foreground="White" FontSize="20" FontFamily="Century Gothic" HorizontalAlignment="Center" Margin="356,272,351,143.6" Width="93"/>
         <Label Content="Резервирование" Foreground="White" FontSize="20" FontFamily="Century Gothic" HorizontalAlignment="Center" Margin="620,272,-1,143.6" Width="181"/>
         <Label Content="Заселение" Foreground="White" FontSize="20" FontFamily="Century Gothic" HorizontalAlignment="Center" Margin="484,272,189,143.6" Width="127"/>
         <StackPanel Orientation="Horizontal" Margin="0,172,0,159.6" HorizontalAlignment="Center" VerticalAlignment="Center" Width="800" Height="118">
@@ -29,9 +29,9 @@
     Width="35" />
             </Button>
             <Button
-  Style="{StaticResource MaterialDesignFloatingActionLightButton}" Margin="90,0,0,0" Click="StaffGO_Click">
+  Style="{StaticResource MaterialDesignFloatingActionLightButton}" Margin="90,0,0,0" Click="ReportGO_Click">
                 <materialDesign:PackIcon
-    Kind="Work"
+    Kind="FileReport"
     Height="35"
     Width="35" />
             </Button>

+ 12 - 6
HotelCalifornia/Variant.xaml.cs

@@ -39,7 +39,13 @@ namespace HotelCalifornia
         //Перетаскивание окна
         private void Grid_MouseDown(object sender, MouseButtonEventArgs e)
         {
-            DragMove();
+            try
+            {
+                DragMove();
+            }
+            catch
+            {
+            }
         }
 
         //Выход из приложения
@@ -80,13 +86,13 @@ namespace HotelCalifornia
             this.WindowState = WindowState.Minimized;
         }
 
-        //Переход к окну работников
-        private void StaffGO_Click(object sender, RoutedEventArgs e)
+        //Переход к окну отчетов
+        private void ReportGO_Click(object sender, RoutedEventArgs e)
         {
-            Staff staff = new Staff();
-            staff.idadmintxt.Text = idadmintxt.Text;
+            Report report = new Report();
+            report.idadmintxt.Text = idadmintxt.Text;
             this.Close();
-            staff.Show();
+            report.Show();
         }
 
         //Переход к окну заселения

BIN
sssss.jpg


BIN
Курсач.jpg


BIN
Курсач.vsdx