فهرست منبع

Два часа работы

Oleg Kireev 3 سال پیش
والد
کامیت
047445614c

+ 1 - 3
Hotel_Course_Project/AdminPage.xaml.cs

@@ -20,16 +20,14 @@ namespace Hotel_Course_Project
     /// </summary>
     public partial class AdminPage : Page
     {
-        public List<Staff> staffls;
         public AdminPage(Staff admin)
         {
             InitializeComponent();
-            staffls = DataBase.db.Staff.ToList();
         }
 
         private void Page_Loaded(object sender, RoutedEventArgs e)
         {
-            StaffList.ItemsSource = staffls;
+            StaffList.ItemsSource = DataBase.db.Staff.ToList(); ;
         }
 
         private void AddStaffBtn_Click(object sender, RoutedEventArgs e)

+ 1 - 1
Hotel_Course_Project/AuthorizationWindow.xaml

@@ -20,6 +20,6 @@
         <TextBlock Grid.Row="1">Пароль</TextBlock>
         <TextBox x:Name="Login" Grid.Column="1"></TextBox>
         <PasswordBox x:Name="Password" Grid.Column="1" Grid.Row="1"></PasswordBox>
-        <Button Grid.Row="2" Grid.ColumnSpan="2" Name="AuthBtn" Click="AuthBtn_Click">Авторизоваться</Button>
+        <Button Grid.Row="2" Grid.ColumnSpan="2" Name="AuthBtn" Click="AuthBtn_Click" IsDefault="True">Авторизоваться</Button>
     </Grid>
 </Window>

+ 2 - 0
Hotel_Course_Project/Client.cs

@@ -25,8 +25,10 @@ namespace Hotel_Course_Project
         public string FName { get; set; }
         public string MName { get; set; }
         public byte[] Passport { get; set; }
+        public int Id_PersStatus { get; set; }
     
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<Order> Order { get; set; }
+        public virtual PersStasus PersStasus { get; set; }
     }
 }

+ 5 - 0
Hotel_Course_Project/Hotel_Course_Project.csproj

@@ -89,12 +89,16 @@
       <DependentUpon>ModelDB.tt</DependentUpon>
     </Compile>
     <Compile Include="PChanger.cs" />
+    <Compile Include="PersStasus.cs">
+      <DependentUpon>ModelDB.tt</DependentUpon>
+    </Compile>
     <Compile Include="Room.cs">
       <DependentUpon>ModelDB.tt</DependentUpon>
     </Compile>
     <Compile Include="RoomStatus.cs">
       <DependentUpon>ModelDB.tt</DependentUpon>
     </Compile>
+    <Compile Include="SomeMethods.cs" />
     <Compile Include="Staff.cs">
       <DependentUpon>ModelDB.tt</DependentUpon>
     </Compile>
@@ -194,6 +198,7 @@
       <DependentUpon>ModelDB.edmx</DependentUpon>
       <LastGenOutput>ModelDB.cs</LastGenOutput>
     </Content>
+    <Resource Include="Resources\no_picture.jpg" />
     <Resource Include="Resources\PersDefaultPhoto.png" />
   </ItemGroup>
   <ItemGroup>

+ 2 - 5
Hotel_Course_Project/MainWindow.xaml.cs

@@ -24,7 +24,6 @@ namespace Hotel_Course_Project
         {
             InitializeComponent();
             PChanger.MainFrame = MainFrame;
-
             switch (user.Id_StaffRole)
             {
                 case 1:
@@ -34,18 +33,16 @@ namespace Hotel_Course_Project
                     MainFrame.Navigate(new HostelsPage(user));
                     break;
             }
-
-            
         }
 
         private void MainFrame_ContentRendered(object sender, EventArgs e)
         {
-
+            var visibleBackBtn = PChanger.MainFrame.CanGoBack ? BackBtn.Visibility = Visibility.Visible : BackBtn.Visibility = Visibility.Collapsed;
         }
 
         private void BackBtn_Click(object sender, RoutedEventArgs e)
         {
-
+            PChanger.MainFrame.GoBack();
         }
     }
 }

+ 1 - 0
Hotel_Course_Project/ModelDB.Context.cs

@@ -34,5 +34,6 @@ namespace Hotel_Course_Project
         public virtual DbSet<sysdiagrams> sysdiagrams { get; set; }
         public virtual DbSet<Pay> Pay { get; set; }
         public virtual DbSet<PayType> PayType { get; set; }
+        public virtual DbSet<PersStasus> PersStasus { get; set; }
     }
 }

+ 98 - 0
Hotel_Course_Project/ModelDB.edmx

@@ -14,6 +14,7 @@
           <Property Name="FName" Type="nvarchar" MaxLength="50" Nullable="false" />
           <Property Name="MName" Type="nchar" MaxLength="10" />
           <Property Name="Passport" Type="image" />
+          <Property Name="Id_PersStatus" Type="int" Nullable="false" />
         </EntityType>
         <EntityType Name="Order">
           <Key>
@@ -43,6 +44,13 @@
           <Property Name="Id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
           <Property Name="Name" Type="nvarchar" MaxLength="50" />
         </EntityType>
+        <EntityType Name="PersStasus">
+          <Key>
+            <PropertyRef Name="Id" />
+          </Key>
+          <Property Name="Id" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
+          <Property Name="Name" Type="nvarchar" MaxLength="50" Nullable="false" />
+        </EntityType>
         <EntityType Name="Room">
           <Key>
             <PropertyRef Name="Id" />
@@ -72,6 +80,7 @@
           <Property Name="PhotoContract" Type="image" />
           <Property Name="Login" Type="nvarchar" MaxLength="50" Nullable="false" />
           <Property Name="Password" Type="nvarchar" MaxLength="50" Nullable="false" />
+          <Property Name="Id_PersStatus" Type="int" Nullable="false" />
         </EntityType>
         <EntityType Name="StaffRole">
           <Key>
@@ -90,6 +99,18 @@
           <Property Name="version" Type="int" />
           <Property Name="definition" Type="varbinary(max)" />
         </EntityType>
+        <Association Name="FK_Client_PersStasus">
+          <End Role="PersStasus" Type="Self.PersStasus" Multiplicity="1" />
+          <End Role="Client" Type="Self.Client" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="PersStasus">
+              <PropertyRef Name="Id" />
+            </Principal>
+            <Dependent Role="Client">
+              <PropertyRef Name="Id_PersStatus" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <Association Name="FK_Order_Client">
           <End Role="Client" Type="Self.Client" Multiplicity="0..1" />
           <End Role="Order" Type="Self.Order" Multiplicity="*" />
@@ -162,6 +183,18 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
+        <Association Name="FK_Staff_PersStasus">
+          <End Role="PersStasus" Type="Self.PersStasus" Multiplicity="1" />
+          <End Role="Staff" Type="Self.Staff" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="PersStasus">
+              <PropertyRef Name="Id" />
+            </Principal>
+            <Dependent Role="Staff">
+              <PropertyRef Name="Id_PersStatus" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
         <Association Name="FK_Staff_StaffRole">
           <End Role="StaffRole" Type="Self.StaffRole" Multiplicity="0..1" />
           <End Role="Staff" Type="Self.Staff" Multiplicity="*" />
@@ -179,11 +212,16 @@
           <EntitySet Name="Order" EntityType="Self.Order" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Pay" EntityType="Self.Pay" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="PayType" EntityType="Self.PayType" Schema="dbo" store:Type="Tables" />
+          <EntitySet Name="PersStasus" EntityType="Self.PersStasus" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Room" EntityType="Self.Room" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="RoomStatus" EntityType="Self.RoomStatus" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="Staff" EntityType="Self.Staff" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="StaffRole" EntityType="Self.StaffRole" Schema="dbo" store:Type="Tables" />
           <EntitySet Name="sysdiagrams" EntityType="Self.sysdiagrams" Schema="dbo" store:Type="Tables" />
+          <AssociationSet Name="FK_Client_PersStasus" Association="Self.FK_Client_PersStasus">
+            <End Role="PersStasus" EntitySet="PersStasus" />
+            <End Role="Client" EntitySet="Client" />
+          </AssociationSet>
           <AssociationSet Name="FK_Order_Client" Association="Self.FK_Order_Client">
             <End Role="Client" EntitySet="Client" />
             <End Role="Order" EntitySet="Order" />
@@ -208,6 +246,10 @@
             <End Role="RoomStatus" EntitySet="RoomStatus" />
             <End Role="Room" EntitySet="Room" />
           </AssociationSet>
+          <AssociationSet Name="FK_Staff_PersStasus" Association="Self.FK_Staff_PersStasus">
+            <End Role="PersStasus" EntitySet="PersStasus" />
+            <End Role="Staff" EntitySet="Staff" />
+          </AssociationSet>
           <AssociationSet Name="FK_Staff_StaffRole" Association="Self.FK_Staff_StaffRole">
             <End Role="StaffRole" EntitySet="StaffRole" />
             <End Role="Staff" EntitySet="Staff" />
@@ -227,6 +269,8 @@
           <Property Name="MName" Type="String" MaxLength="10" FixedLength="true" Unicode="true" />
           <Property Name="Passport" Type="Binary" MaxLength="Max" FixedLength="false" />
           <NavigationProperty Name="Order" Relationship="Self.FK_Order_Client" FromRole="Client" ToRole="Order" />
+          <Property Name="Id_PersStatus" Type="Int32" Nullable="false" />
+          <NavigationProperty Name="PersStasus" Relationship="gr692_kovModel.FK_Client_PersStasus" FromRole="Client" ToRole="PersStasus" />
         </EntityType>
         <EntityType Name="Order">
           <Key>
@@ -278,6 +322,8 @@
           <Property Name="Password" Type="String" MaxLength="50" FixedLength="false" Unicode="true" Nullable="false" />
           <NavigationProperty Name="Order" Relationship="Self.FK_Order_Staff" FromRole="Staff" ToRole="Order" />
           <NavigationProperty Name="StaffRole" Relationship="Self.FK_Staff_StaffRole" FromRole="Staff" ToRole="StaffRole" />
+          <Property Name="Id_PersStatus" Type="Int32" Nullable="false" />
+          <NavigationProperty Name="PersStasus" Relationship="gr692_kovModel.FK_Staff_PersStasus" FromRole="Staff" ToRole="PersStasus" />
         </EntityType>
         <EntityType Name="StaffRole">
           <Key>
@@ -395,6 +441,15 @@
             <End Role="PayType" EntitySet="PayType" />
             <End Role="Pay" EntitySet="Pay" />
           </AssociationSet>
+          <EntitySet Name="PersStasus" EntityType="gr692_kovModel.PersStasus" />
+          <AssociationSet Name="FK_Client_PersStasus" Association="gr692_kovModel.FK_Client_PersStasus">
+            <End Role="PersStasus" EntitySet="PersStasus" />
+            <End Role="Client" EntitySet="Client" />
+          </AssociationSet>
+          <AssociationSet Name="FK_Staff_PersStasus" Association="gr692_kovModel.FK_Staff_PersStasus">
+            <End Role="PersStasus" EntitySet="PersStasus" />
+            <End Role="Staff" EntitySet="Staff" />
+          </AssociationSet>
         </EntityContainer>
         <EntityType Name="Pay">
           <Key>
@@ -439,6 +494,39 @@
             </Dependent>
           </ReferentialConstraint>
         </Association>
+        <EntityType Name="PersStasus">
+          <Key>
+            <PropertyRef Name="Id" />
+          </Key>
+          <Property Name="Id" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
+          <Property Name="Name" Type="String" Nullable="false" MaxLength="50" FixedLength="false" Unicode="true" />
+          <NavigationProperty Name="Client" Relationship="gr692_kovModel.FK_Client_PersStasus" FromRole="PersStasus" ToRole="Client" />
+          <NavigationProperty Name="Staff" Relationship="gr692_kovModel.FK_Staff_PersStasus" FromRole="PersStasus" ToRole="Staff" />
+        </EntityType>
+        <Association Name="FK_Client_PersStasus">
+          <End Type="gr692_kovModel.PersStasus" Role="PersStasus" Multiplicity="1" />
+          <End Type="gr692_kovModel.Client" Role="Client" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="PersStasus">
+              <PropertyRef Name="Id" />
+            </Principal>
+            <Dependent Role="Client">
+              <PropertyRef Name="Id_PersStatus" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
+        <Association Name="FK_Staff_PersStasus">
+          <End Type="gr692_kovModel.PersStasus" Role="PersStasus" Multiplicity="1" />
+          <End Type="gr692_kovModel.Staff" Role="Staff" Multiplicity="*" />
+          <ReferentialConstraint>
+            <Principal Role="PersStasus">
+              <PropertyRef Name="Id" />
+            </Principal>
+            <Dependent Role="Staff">
+              <PropertyRef Name="Id_PersStatus" />
+            </Dependent>
+          </ReferentialConstraint>
+        </Association>
       </Schema>
     </edmx:ConceptualModels>
     <!-- C-S mapping content -->
@@ -448,6 +536,7 @@
           <EntitySetMapping Name="Client">
             <EntityTypeMapping TypeName="gr692_kovModel.Client">
               <MappingFragment StoreEntitySet="Client">
+                <ScalarProperty Name="Id_PersStatus" ColumnName="Id_PersStatus" />
                 <ScalarProperty Name="Id" ColumnName="Id" />
                 <ScalarProperty Name="LName" ColumnName="LName" />
                 <ScalarProperty Name="FName" ColumnName="FName" />
@@ -491,6 +580,7 @@
           <EntitySetMapping Name="Staff">
             <EntityTypeMapping TypeName="gr692_kovModel.Staff">
               <MappingFragment StoreEntitySet="Staff">
+                <ScalarProperty Name="Id_PersStatus" ColumnName="Id_PersStatus" />
                 <ScalarProperty Name="Id" ColumnName="Id" />
                 <ScalarProperty Name="LName" ColumnName="LName" />
                 <ScalarProperty Name="FName" ColumnName="FName" />
@@ -539,6 +629,14 @@
               </MappingFragment>
             </EntityTypeMapping>
           </EntitySetMapping>
+          <EntitySetMapping Name="PersStasus">
+            <EntityTypeMapping TypeName="gr692_kovModel.PersStasus">
+              <MappingFragment StoreEntitySet="PersStasus">
+                <ScalarProperty Name="Name" ColumnName="Name" />
+                <ScalarProperty Name="Id" ColumnName="Id" />
+              </MappingFragment>
+            </EntityTypeMapping>
+          </EntitySetMapping>
         </EntityContainerMapping>
       </Mapping>
     </edmx:Mappings>

+ 4 - 1
Hotel_Course_Project/ModelDB.edmx.diagram

@@ -4,7 +4,7 @@
   <edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
     <!-- Diagram content (shape and connector positions) -->
     <edmx:Diagrams>
-      <Diagram DiagramId="7b379ebd51334675b3099ff3e8b1d4e0" Name="Diagram1" ZoomLevel="95">
+      <Diagram DiagramId="7b379ebd51334675b3099ff3e8b1d4e0" Name="Diagram1" ZoomLevel="82">
         <EntityTypeShape EntityType="gr692_kovModel.Client" Width="1.5" PointX="3" PointY="5.625" IsExpanded="true" />
         <EntityTypeShape EntityType="gr692_kovModel.Order" Width="1.5" PointX="5.25" PointY="1" IsExpanded="true" />
         <EntityTypeShape EntityType="gr692_kovModel.Room" Width="1.5" PointX="3" PointY="1.5" IsExpanded="true" />
@@ -21,6 +21,9 @@
         <EntityTypeShape EntityType="gr692_kovModel.PayType" Width="1.5" PointX="0.75" PointY="15" />
         <AssociationConnector Association="gr692_kovModel.FK_Order_Pay" />
         <AssociationConnector Association="gr692_kovModel.FK_Pay_PayType" />
+        <EntityTypeShape EntityType="gr692_kovModel.PersStasus" Width="1.5" PointX="0.75" PointY="8" />
+        <AssociationConnector Association="gr692_kovModel.FK_Client_PersStasus" />
+        <AssociationConnector Association="gr692_kovModel.FK_Staff_PersStasus" />
       </Diagram>
     </edmx:Diagrams>
   </edmx:Designer>

+ 32 - 0
Hotel_Course_Project/PersStasus.cs

@@ -0,0 +1,32 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     Этот код создан по шаблону.
+//
+//     Изменения, вносимые в этот файл вручную, могут привести к непредвиденной работе приложения.
+//     Изменения, вносимые в этот файл вручную, будут перезаписаны при повторном создании кода.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Hotel_Course_Project
+{
+    using System;
+    using System.Collections.Generic;
+    
+    public partial class PersStasus
+    {
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
+        public PersStasus()
+        {
+            this.Client = new HashSet<Client>();
+            this.Staff = new HashSet<Staff>();
+        }
+    
+        public int Id { get; set; }
+        public string Name { get; set; }
+    
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<Client> Client { get; set; }
+        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
+        public virtual ICollection<Staff> Staff { get; set; }
+    }
+}

BIN
Hotel_Course_Project/Resources/no_picture.jpg


+ 39 - 0
Hotel_Course_Project/SomeMethods.cs

@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Media.Imaging;
+
+namespace Hotel_Course_Project
+{
+    class SomeMethods
+    {
+        public static BitmapImage ConvertByteToBitmapImage(byte[] array)
+        {
+            using (var ms = new System.IO.MemoryStream(array))
+            {
+                var image = new BitmapImage();
+                image.BeginInit();
+                image.CacheOption = BitmapCacheOption.OnLoad;
+                image.StreamSource = ms;
+                image.EndInit();
+                return image;
+            }
+        }
+
+        public static byte[] ConvertBitmapImageToByte(BitmapSource image)
+        {
+            using (var stream = new MemoryStream())
+            {
+                var encoder = new PngBitmapEncoder();
+                encoder.Frames.Add(BitmapFrame.Create(image));
+                encoder.Save(stream);
+                return stream.ToArray();
+            }
+        }
+
+
+    }
+}

+ 2 - 0
Hotel_Course_Project/Staff.cs

@@ -28,9 +28,11 @@ namespace Hotel_Course_Project
         public byte[] PhotoContract { get; set; }
         public string Login { get; set; }
         public string Password { get; set; }
+        public int Id_PersStatus { get; set; }
     
         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
         public virtual ICollection<Order> Order { get; set; }
         public virtual StaffRole StaffRole { get; set; }
+        public virtual PersStasus PersStasus { get; set; }
     }
 }

+ 3 - 2
Hotel_Course_Project/StaffChangeOrAddPage.xaml

@@ -6,7 +6,7 @@
       xmlns:local="clr-namespace:Hotel_Course_Project"
       mc:Ignorable="d" 
       d:DesignHeight="450" d:DesignWidth="800"
-      Title="StaffChangeOrAddPage" Loaded="Page_Loaded">
+      >
 
     <Grid>
         <Grid.ColumnDefinitions>
@@ -36,8 +36,9 @@
         <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>
+        <Image x:Name="SContractPhoto" Grid.RowSpan="4" Source="{Binding PhotoContract}" MouseLeftButtonDown="SContractPhoto_MouseLeftButtonDown"></Image>
 
-        <Button Grid.Row="6" Grid.Column="1" x:Name="StaffDELETEBtn" Click="StaffDELETEBtn_Click"></Button>
+        <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>
     </Grid>
 </Page>

+ 74 - 11
Hotel_Course_Project/StaffChangeOrAddPage.xaml.cs

@@ -1,5 +1,7 @@
-using System;
+using Microsoft.Win32;
+using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -20,32 +22,93 @@ namespace Hotel_Course_Project
     /// </summary>
     public partial class StaffChangeOrAddPage : Page
     {
+        public byte[] cotractImage;
+        public string FilePath;
         public Staff _staff;
-        public List<StaffRole> RoleList;
         public StaffChangeOrAddPage(Staff staff)
         {
             InitializeComponent();
             DataContext = staff;
             _staff = staff;
-            RoleList = DataBase.db.StaffRole.ToList();
-            
-
+            if (DataContext != null)
+            {
+                SStaffRole.Text = staff.ToString();
+                StaffChangeOrAddBtn.Content = "Изменить данные";
+                this.Title = "Информация о сотруднике";
+            }
+            else
+            {
+                StaffChangeOrAddBtn.Content = "Добавить сотрудника";
+                this.Title = "Окно добавления сотрудника";
+            }
+            SStaffRole.ItemsSource = DataBase.db.StaffRole.ToList();
+            if (staff == null || staff.PhotoContract == null)
+            {
+            SContractPhoto.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/no_picture.jpg"));
+            }
         }
 
-        private void Page_Loaded(object sender, RoutedEventArgs e)
+        private void StaffChangeOrAddBtn_Click(object sender, RoutedEventArgs e)
         {
-            SStaffRole.Text = _staff.ToString();
-            SStaffRole.ItemsSource = RoleList;
+            var existUser = DataBase.db.Staff.SingleOrDefault(item => item.Login == SLogin.Text);
+            if (existUser != null && DataContext == null) 
+            {
+                MessageBox.Show("Такой логин уже имеется в базе данных");
+                return;
+            }
+            else if (SLName.Text == null || SFName.Text == null || SLogin.Text == null || SPassword.Text == null || SContractPhoto == null)
+            {
+                MessageBox.Show("Ключевые поля не были заполнены");
+                return;
+            }
+            else
+            {
+                if( DataContext == null)
+                {
+                    int numRole = DataBase.db.StaffRole.SingleOrDefault(item => item.Name == SStaffRole.Text).Id;
+                    Staff staff = new Staff()
+                    {
+                        LName = SLName.Text,
+                        FName = SFName.Text,
+                        MName = SMName.Text,
+                        Login = SLogin.Text,
+                        Password = SPassword.Text,
+                        Id_StaffRole = numRole,
+                        PhotoContract = cotractImage,
+                        Id_PersStatus = 1
+                    };
+                    DataBase.db.Staff.Add(staff);
+                    var lastId = DataBase.db.Staff.OrderByDescending(item => item.Id).FirstOrDefault().Id;
+                    DataBase.db.SaveChanges();                    
+                }
+                else
+                {
+
+                }
+            }
+
         }
 
-        private void StaffDELETEBtn_Click(object sender, RoutedEventArgs e)
+        private void StaffDeleteOrRestoreBtn_Click(object sender, RoutedEventArgs e)
         {
 
         }
 
-        private void StaffChangeOrAddBtn_Click(object sender, RoutedEventArgs e)
+        private void SContractPhoto_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
         {
-
+            OpenFileDialog openFileDialog = new OpenFileDialog();
+            if (openFileDialog.ShowDialog() == true)
+            {
+                FilePath = openFileDialog.FileName;
+                string uriString = $"{FilePath}";
+                BitmapImage bitimage = new BitmapImage(new Uri(@uriString));
+                SContractPhoto.Source = bitimage;
+                cotractImage = SomeMethods.ConvertBitmapImageToByte(bitimage);
+            }
+            else
+            {
+                FilePath = string.Empty;
+            }
         }
     }
 }