Przeglądaj źródła

add checkbox "projects" on "AddEmployees"

AngelikaSuhareva 2 miesięcy temu
rodzic
commit
64777493f3

+ 1 - 1
ViewModels/AddEmployeesViewModel.cs

@@ -14,7 +14,7 @@ namespace Acosta.ViewModels
         {
             this.myConnection = myConnection;
             CurrentUser = new Employee();
-            myConnection.Add(CurrentUser);  
+            myConnection.Add(CurrentUser);
         }
 
         public Employee CurrentUser { get => currentUser; set => currentUser = value; }

+ 6 - 1
ViewModels/MainWindowViewModel.cs

@@ -4,6 +4,8 @@ using ReactiveUI;
 using Acosta.Models;
 using System.Linq;
 using Acosta.ViewModels;
+using System.Collections.Generic;
+using Microsoft.EntityFrameworkCore;
 
 namespace Acosta.ViewModels
 {
@@ -33,7 +35,7 @@ namespace Acosta.ViewModels
         }
 
         public UserControl UC { get => uc; set => this.RaiseAndSetIfChanged(ref uc, value); } 
-        private UserControl uc = new AuthorizationView();
+        private UserControl uc = new AddEmployeesView();
 
         public void LoadPersonalAccount()
         {
@@ -52,6 +54,9 @@ namespace Acosta.ViewModels
                 AuthorizationVM.Message = "Успех!";
             }
         }
+
+        public List<Project> ListProjects => myConnection.Projects.ToList();
+
         public void ExitFromProfile()
         {
             UC = new AuthorizationView();

+ 19 - 19
Views/AddEmployeesView.axaml

@@ -154,51 +154,51 @@
 					<Border Background="#969696" CornerRadius="13"  Width="1150" Height="0.5" Margin="200 30 0 10" HorizontalAlignment="Left"></Border>
 					<StackPanel Orientation="Horizontal">
 						<TextBlock Classes="TextToTextBox">Фамилия:</TextBlock>
-						<TextBox Watermark="Фималия" Width="360" Margin="160 20 0 0"></TextBox>
+						<TextBox Text="{Binding AddEmployeesViewModel.CurrentUser.Surname}" Watermark="Фамилия" Width="360" Margin="160 20 0 0"></TextBox>
 					</StackPanel>
 					<Border Background="#969696" CornerRadius="13"  Width="1150" Height="0.5" Margin="200 30 0 10" HorizontalAlignment="Left"></Border>
 					<StackPanel Orientation="Horizontal">
 						<TextBlock Classes="TextToTextBox">Имя:</TextBlock>
-						<TextBox Watermark="Имя" Width="360" Margin="200 20 0 0"></TextBox>
+						<TextBox Text="{Binding AddEmployeesViewModel.CurrentUser.Name}" Watermark="Имя" Width="360" Margin="200 20 0 0"></TextBox>
 					</StackPanel>
 					<Border Background="#969696" CornerRadius="13"  Width="1150" Height="0.5" Margin="200 30 0 10" HorizontalAlignment="Left"></Border>
 					<StackPanel Orientation="Horizontal">
 						<TextBlock Classes="TextToTextBox">Отчетсво:</TextBlock>
-						<TextBox Watermark="Отчетсво" Width="360" Margin="156 20 0 0"></TextBox>
+						<TextBox Text="{Binding AddEmployeesViewModel.CurrentUser.Patronymic}" Watermark="Отчетсво" Width="360" Margin="156 20 0 0"></TextBox>
 					</StackPanel>
 					<Border Background="#969696" CornerRadius="13"  Width="1150" Height="0.5" Margin="200 30 0 10" HorizontalAlignment="Left"></Border>
 					<StackPanel Orientation="Horizontal">
 						<TextBlock Classes="TextToTextBox">Почта:</TextBlock>
-						<TextBox Watermark="Почта" Width="360" Margin="183 20 0 0"></TextBox>
+						<TextBox Text="{Binding AddEmployeesViewModel.CurrentUser.Email}" Watermark="Почта" Width="360" Margin="183 20 0 0"></TextBox>
 					</StackPanel>
 					<Border Background="#969696" CornerRadius="13"  Width="1150" Height="0.5" Margin="200 30 0 10" HorizontalAlignment="Left"></Border>
 					<StackPanel Orientation="Horizontal">
 						<TextBlock Classes="TextToTextBox">Пароль:</TextBlock>
-						<TextBox Watermark="Пароль" Width="360" Margin="170 20 0 0"></TextBox>
+						<TextBox Text="{Binding AddEmployeesViewModel.CurrentUser.Password}" Watermark="Пароль" Width="360" Margin="170 20 0 0"></TextBox>
 					</StackPanel>
 					<Border Background="#969696" CornerRadius="13"  Width="1150" Height="0.5" Margin="200 30 0 10" HorizontalAlignment="Left"></Border>
 					<StackPanel Orientation="Horizontal">
 						<TextBlock Classes="TextToTextBox">Телефон:</TextBlock>
-						<TextBox Watermark="Телефон" Width="360" Margin="165 20 0 0"></TextBox>
+						<TextBox Text="{Binding AddEmployeesViewModel.CurrentUser.Phonenumber}" Watermark="Телефон" Width="360" Margin="165 20 0 0"></TextBox>
 					</StackPanel>
 					<Border Background="#969696" CornerRadius="13"  Width="1150" Height="0.5" Margin="200 30 0 10" HorizontalAlignment="Left"></Border>
 					<StackPanel Orientation="Horizontal">
 						<TextBlock Classes="TextToTextBox">Роль:</TextBlock>
-						<TextBox Watermark="Роль" Width="360" Margin="200 20 0 0"></TextBox>
+						<TextBox Text="{Binding AddEmployeesViewModel.CurrentUser.Role}" Watermark="Роль" Width="360" Margin="200 20 0 0"></TextBox>
 					</StackPanel>
 					<Border Background="#969696" CornerRadius="13"  Width="1150" Height="0.5" Margin="197 30 0 10" HorizontalAlignment="Left"></Border>
-					<StackPanel Orientation="Vertical">
-						<TextBlock Classes="TextToTextBox">Проекты:</TextBlock>
-						<CheckBox Classes="TextToCheckBox" Margin="202 10 0 0">
-							<TextBlock>Проект “...”</TextBlock>
-						</CheckBox>
-						<CheckBox Classes="TextToCheckBox" Margin="202 10 0 0">
-							<TextBlock>Проект “...”</TextBlock>
-						</CheckBox>
-						<CheckBox Classes="TextToCheckBox" Margin="202 10 0 0">
-							<TextBlock>Проект “...”</TextBlock>
-						</CheckBox>
-					</StackPanel>
+					<TextBlock Classes="TextToTextBox">Проекты:</TextBlock>
+					<ListBox ItemsSource="{Binding ListProjects}">
+						<ListBox.ItemTemplate>
+							<DataTemplate>
+								<StackPanel Orientation="Vertical">
+									<CheckBox Classes="TextToCheckBox" Margin="202 10 0 0">
+										<TextBlock Text="{Binding Title}"></TextBlock>
+									</CheckBox>
+								</StackPanel>
+							</DataTemplate>
+						</ListBox.ItemTemplate>
+					</ListBox>
 				</StackPanel>
 			</ScrollViewer>
 		</StackPanel>