Переглянути джерело

доделал добавление.
сортировки и фильтры пока недоделаны

fly9024 11 місяців тому
батько
коміт
f126fc0618

+ 22 - 1
AvaloniaApplication5/ViewModels/MainWindowViewModel.cs

@@ -64,7 +64,28 @@ namespace AvaloniaApplication5.ViewModels
             }
         }
 
-        
+        public List<string> Genders//список полов для фильтра
+        {
+            get
+            {
+                List<string> newlist = new List<string>() {"Любой"};
+                newlist.AddRange(DBConnect.Genders.Select(x => x.Gender1).ToList());
+                return newlist;
+            }
+        }
+
+        public string FilterByGender { get => filterByGender;
+            set
+            {
+               
+                if (!(value =="Любой" || value == null))
+                UserList = UserList.Where(x => x.User.IdGenderNavigation.Gender1 == value).ToList();        
+            } 
+        }
+
+        string filterByGender = "Любой";
+
+
 
         #endregion
 

+ 3 - 2
AvaloniaApplication5/ViewModels/PageUserCabinetViewModel.cs

@@ -24,18 +24,19 @@ namespace AvaloniaApplication5.ViewModels
             this.dBConnect = dBConnect;
             int maxid = dBConnect.Logintables.Select(x => x.Id).Max();
             currentUser = new Logintable() { User = new User() { IdLogin = ++maxid }, IdRole =2 };
+            changePass = true;//÷òîáû èçìåíåíèå ïàðîëÿ áûëî àêèâíî
         }
 
         public Logintable? CurrentUser { get => currentUser; set => currentUser = value; }
 
-        public List<string> Genders => dBConnect.Genders.Select(x=>x.Gender1).ToList();
+        public List<Gender> Genders => dBConnect.Genders.ToList();
 
         public string DR { get => CurrentUser.User.BirthDate.ToString(); set => CurrentUser.User.BirthDate = DateTime.Parse(value); }
         public bool ChangePass { get => changePass; set =>this.RaiseAndSetIfChanged(ref changePass, value); }
         public string PasswordMatch { get => passwordMatch; set => passwordMatch = value; }
         public string Message { get => message; set =>this.RaiseAndSetIfChanged(ref message,value); }
 
-        bool changePass;
+        bool changePass = false;
 
         string passwordMatch;
         string message;

+ 1 - 1
AvaloniaApplication5/Views/PageLogin.axaml

@@ -16,7 +16,7 @@
 		<TextBox Text="{Binding PageLoginVM.Login}"/>
 		<TextBlock Classes="AuthTBStyle" Text="Введите пароль"/>
 		<TextBox PasswordChar="•" Text="{Binding PageLoginVM.Password}"/>
-		<Button Content="Войти" Command="{Binding LoadPageList}"/>
+		<Button Content="Войти" Command="{Binding LoadPageList}" IsDefault="True"/>
 		<TextBlock Classes="ErrorMessage" Text="{Binding PageLoginVM.Message}"/>
 	</StackPanel>
 </UserControl>

+ 9 - 2
AvaloniaApplication5/Views/PageUserCabinet.axaml

@@ -11,7 +11,7 @@
 		<TextBox Text="{Binding PageUCabinetVM.CurrentUser.User.Name}"/>
 		<TextBlock Text="Логин"/>
 		<TextBox Text="{Binding PageUCabinetVM.CurrentUser.Login}"/>
-		<CheckBox Content="Изменить пароль" IsChecked="{Binding PageUCabinetVM.ChangePass}"/>
+		<CheckBox Content="Изменить пароль" IsChecked="{Binding PageUCabinetVM.ChangePass}" IsEnabled="{Binding !PageUCabinetVM.ChangePass}"/>
 		<StackPanel IsVisible="{Binding PageUCabinetVM.ChangePass}">
 			<TextBlock Text="Введите новый пароль"/>
 			<TextBox Text="{Binding PageUCabinetVM.CurrentUser.Password,Mode=OneWayToSource}" PasswordChar="•"/>
@@ -21,7 +21,14 @@
 		<TextBlock Text="Роль в системе"/>
 		<TextBlock Text="{Binding PageUCabinetVM.CurrentUser.IdRoleNavigation.Role1}"/>
 		<TextBlock Text="Пол"/>
-		<ComboBox ItemsSource="{Binding PageUCabinetVM.Genders}" SelectedValue="{Binding PageUCabinetVM.CurrentUser.User.IdGenderNavigation.Gender1}"/>
+		<ComboBox ItemsSource="{Binding PageUCabinetVM.Genders}" SelectedValue="{Binding PageUCabinetVM.CurrentUser.User.IdGenderNavigation}">
+			<ComboBox.ItemTemplate>
+				<DataTemplate>
+					<TextBlock Text="{Binding Gender1}"/>
+				</DataTemplate>
+			</ComboBox.ItemTemplate>
+		</ComboBox>
+		
 		<TextBlock Text="Дата рождения"/>
 		<DatePicker SelectedDate="{Binding PageUCabinetVM.DR}"/>
 		<TextBlock Text="{Binding  PageUCabinetVM.Message}"/>

+ 14 - 2
AvaloniaApplication5/Views/PageUserList.axaml

@@ -9,9 +9,21 @@
 	<Grid ColumnDefinitions="*,*" RowDefinitions="50,*">
 		<StackPanel Orientation="Horizontal" Grid.Row="0">
 			<Button Content="Добавить пользователя" Command="{Binding $parent[Window].((vm:MainWindowViewModel)DataContext).EditUser}" CommandParameter="0"/>
-			<ComboBox ItemsSource="{Binding OrdersName}" SelectedValue="{Binding OrderByName}">
+			<StackPanel>
+				<TextBlock Text="Сортировка по имени"/>
+				<ComboBox ItemsSource="{Binding OrdersName}" SelectedValue="{Binding OrderByName}"/>
+			</StackPanel>
+			<StackPanel>
+				<TextBlock Text="Фильтр по полу"/>
+				<ComboBox ItemsSource="{Binding Genders}" SelectedValue="{Binding FilterByGender}"/>
+			</StackPanel>
+			<StackPanel>
+				<TextBlock Text="Поиск по имени"/>
+				<TextBox />
+			</StackPanel>
+			
+			
 			
-			</ComboBox>
 				
 			
 		</StackPanel>