Oleg Kireev hace 3 años
padre
commit
e8a0c7f291

+ 1 - 1
Hotel_Course_Project/MainWindow.xaml

@@ -12,7 +12,7 @@
             <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
 
-        <Button HorizontalAlignment="Left" Name="BackBtn" Click="BackBtn_Click">Назад</Button>
+        <Button HorizontalAlignment="Left" Name="BackBtn" Click="BackBtn_Click" IsCancel="True">Назад</Button>
         <Button HorizontalAlignment="Left" Name="ExitBtn" Click="ExitBtn_Click">Выйти</Button>
         <Frame Name="MainFrame" Grid.Row="1" NavigationUIVisibility="Hidden" ContentRendered="MainFrame_ContentRendered"></Frame>
     </Grid>

+ 4 - 7
Hotel_Course_Project/StaffChangeOrAddPage.xaml

@@ -22,25 +22,22 @@
             <RowDefinition></RowDefinition>
             <RowDefinition></RowDefinition>
             <RowDefinition></RowDefinition>
-            <RowDefinition></RowDefinition>
         </Grid.RowDefinitions>
         <TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">Фамилия</TextBlock>
         <TextBlock Grid.Row="1" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">Имя</TextBlock>
         <TextBlock Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">Отчество</TextBlock>
         <TextBlock Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">Логин</TextBlock>
-        <TextBlock Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">Пароль</TextBlock>
-        <TextBlock Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">Занимаемая должность</TextBlock>
+        <TextBlock Grid.Row="4" Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Center">Занимаемая должность</TextBlock>
 
         <TextBox Grid.Row="0" Grid.Column="2" x:Name="SLName" Text="{Binding LName}"></TextBox>
         <TextBox Grid.Row="1" Grid.Column="2" x:Name="SFName" Text="{Binding FName}"></TextBox>
         <TextBox Grid.Row="2" Grid.Column="2" x:Name="SMName" Text="{Binding MName}"></TextBox>
         <TextBox Grid.Row="3" Grid.Column="2" x:Name="SLogin" Text="{Binding Login}"></TextBox>
-        <TextBox Grid.Row="4" Grid.Column="2" x:Name="SPassword" Text="{Binding Password}"></TextBox>
-        <ComboBox Grid.Row="5" Grid.Column="2" x:Name="SStaffRole" SelectedItem="{Binding StaffRole}" DisplayMemberPath="Name" ItemsSource="{Binding Id_StaffRole.StaffRole.Id.Name}"></ComboBox>
+        <ComboBox Grid.Row="4" Grid.Column="2" x:Name="SStaffRole" SelectedItem="{Binding StaffRole}" DisplayMemberPath="Name" ItemsSource="{Binding Id_StaffRole.StaffRole.Id.Name}"></ComboBox>
         <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center">Фотография Договора</TextBlock>
         <Image x:Name="SContractPhoto" Grid.RowSpan="4" Grid.Row="1" Source="{Binding PhotoContract}" MouseLeftButtonDown="SContractPhoto_MouseLeftButtonDown"></Image>
 
-        <Button Grid.Row="6" Grid.Column="1" x:Name="StaffDeleteOrRestoreBtn" Click="StaffDeleteOrRestoreBtn_Click"></Button>
-        <Button Grid.Row="6" Grid.Column="2" x:Name="StaffChangeOrAddBtn" Click="StaffChangeOrAddBtn_Click"></Button>
+        <Button Grid.Row="5" Grid.Column="1" x:Name="StaffDeleteOrRestoreBtn" Click="StaffDeleteOrRestoreBtn_Click"></Button>
+        <Button Grid.Row="5" Grid.Column="2" x:Name="StaffChangeOrAddBtn" Click="StaffChangeOrAddBtn_Click"></Button>
     </Grid>
 </Page>

+ 6 - 6
Hotel_Course_Project/StaffChangeOrAddPage.xaml.cs

@@ -62,7 +62,7 @@ namespace Hotel_Course_Project
                 else
                 {
                     int numRole = DataBase.db.StaffRole.SingleOrDefault(item => item.Name == SStaffRole.Text).Id;
-                    if (TestAddStaff(SLName.Text, SFName.Text, SMName.Text, SLogin.Text, SPassword.Text, numRole) == true)
+                    if (TestAddStaff(SLName.Text, SFName.Text, SMName.Text, SLogin.Text, numRole) == true)
                     {
                         DataBase.db.Staff.Add(addStaff);
                         var lastId = DataBase.db.Staff.OrderByDescending(item => item.Id).FirstOrDefault().Id;
@@ -73,7 +73,7 @@ namespace Hotel_Course_Project
                     }
                     else
                     {
-                        if (SLName.Text == null || SLName.Text == "" || SFName.Text == null || SFName.Text == "" || SMName.Text == null || SMName.Text == "" || SLogin.Text == null || SLogin.Text == "" || SPassword.Text == null || SPassword.Text == "")
+                        if (SLName.Text == null || SLName.Text == "" || SFName.Text == null || SFName.Text == "" || SMName.Text == null || SMName.Text == "" || SLogin.Text == null || SLogin.Text == "")
                         {
                             MessageBox.Show("Ключевые поля не были заполнены!");
                         }
@@ -86,7 +86,7 @@ namespace Hotel_Course_Project
             }
             else
             {
-                if (SLName.Text == null || SFName.Text == null || SLogin.Text == null || SPassword.Text == null)
+                if (SLName.Text == null || SFName.Text == null || SLogin.Text == null)
                 {
                     MessageBox.Show("Ключевые поля не были заполнены!");
                     return;
@@ -107,9 +107,9 @@ namespace Hotel_Course_Project
             }
         }
 
-        public bool TestAddStaff(string LName, string FName, string MName, string Login, string Password, int numRole)
+        public bool TestAddStaff(string LName, string FName, string MName, string Login, int numRole)
         {
-            if (LName == null || LName == "" || FName == null || FName == "" || Login == null || Login == "" || Password == null || Password == "")
+            if (LName == null || LName == "" || FName == null || FName == "" || Login == null || Login == "")
             {
                 return false;
             }
@@ -128,7 +128,7 @@ namespace Hotel_Course_Project
                         FName = FName,
                         MName = MName,
                         Login = Login,
-                        Password = Password,
+                        Password = SomeMethods.Hash("12345678"),
                         Id_StaffRole = numRole,
                         Id_PersStatus = 1
                     };

+ 5 - 17
UnitTestCourseProject/UnitTest.cs

@@ -19,7 +19,6 @@ namespace UnitTestCourseProject
             Assert.IsFalse(authorization.Auth("12334", "541231"));
             Assert.IsFalse(authorization.Auth("Login", "Parol"));
         }
-
         [TestMethod]
         public void TestAddStaff()
         {
@@ -29,41 +28,35 @@ namespace UnitTestCourseProject
             string Fname = "";
             string Mname = "";
             string Login = "";
-            string Password = "";
-            Assert.IsFalse(staffChangeOrAdd.TestAddStaff(LName, Fname, Mname, Login, Password, 2));
+            Assert.IsFalse(staffChangeOrAdd.TestAddStaff(LName, Fname, Mname, Login,2));
 
             staffChangeOrAdd = new StaffChangeOrAddPage(null);
             LName = "";
             Fname = "Иван";
             Mname = "Иванович";
             Login = "123";
-            Password = "123";
-            Assert.IsFalse(staffChangeOrAdd.TestAddStaff(LName, Fname, Mname, Login, Password, 2));
+            Assert.IsFalse(staffChangeOrAdd.TestAddStaff(LName, Fname, Mname, Login,2));
 
             staffChangeOrAdd = new StaffChangeOrAddPage(null);
             LName = "Иванов";
             Fname = "";
             Mname = "Иванович";
             Login = "dsa";
-            Password = "dsa";
-            Assert.IsFalse(staffChangeOrAdd.TestAddStaff(LName, Fname, Mname, Login, Password, 2));
-
+            Assert.IsFalse(staffChangeOrAdd.TestAddStaff(LName, Fname, Mname, Login, 2));
             //Корректные данные о персонале
             staffChangeOrAdd = new StaffChangeOrAddPage(null);
             LName = "Иванов";
             Fname = "Иван";
             Mname = "Иванович";
             Login = "123435267";
-            Password = "password";
-            Assert.IsTrue(staffChangeOrAdd.TestAddStaff(LName, Fname, Mname, Login, Password, 1));
+            Assert.IsTrue(staffChangeOrAdd.TestAddStaff(LName, Fname, Mname, Login, 1));
 
             staffChangeOrAdd = new StaffChangeOrAddPage(null);
             LName = "Петренко";
             Fname = "Михаил";
             Mname = "Григорьевич";
             Login = "Admin1";
-            Password = "Admin";
-            Assert.IsTrue(staffChangeOrAdd.TestAddStaff(LName, Fname, Mname, Login, Password, 1));
+            Assert.IsTrue(staffChangeOrAdd.TestAddStaff(LName, Fname, Mname, Login, 1));
         }
         [TestMethod]
         public void TestAddClient()
@@ -87,7 +80,6 @@ namespace UnitTestCourseProject
             Mname = "Петрович";
             Assert.IsFalse(clientChangeOrAdd.TestAddClient(Lname, Fname, Mname));
         }
-
         [TestMethod]
         public void TestSearchStaff()
         {
@@ -104,7 +96,6 @@ namespace UnitTestCourseProject
                 FName = "Иван",
                 MName = "Иванович",
                 Login = "123",
-                Password = "123",
                 Id_PersStatus = 1,
                 Id_StaffRole = 1
             }; 
@@ -115,7 +106,6 @@ namespace UnitTestCourseProject
                 FName = "Пётр",
                 MName = "Петрович",
                 Login = "234",
-                Password = "123",
                 Id_PersStatus = 1,
                 Id_StaffRole = 1
             };
@@ -126,7 +116,6 @@ namespace UnitTestCourseProject
                 FName = "Фёдор",
                 MName = "Фёдорович",
                 Login = "345",
-                Password = "123",
                 Id_PersStatus = 1,
                 Id_StaffRole = 1
             };
@@ -137,7 +126,6 @@ namespace UnitTestCourseProject
                 FName = "Давид",
                 MName = "Давидович",
                 Login = "456",
-                Password = "123",
                 Id_PersStatus = 1,
                 Id_StaffRole = 1
             };