1
0

2 Commity 51acdd3642 ... b893ad81fc

Autor SHA1 Správa Dátum
  emoRussiunGirl b893ad81fc ладно 4 mesiacov pred
  emoRussiunGirl 23856599c9 Добавил маненьку маненьку, терь прикольне 4 mesiacov pred

+ 63 - 7
SocialEducatorAvalonia/ViewModels/AddPaymentsViewModel.cs

@@ -9,7 +9,8 @@ using System.Collections.Immutable;
 using System.Collections.ObjectModel;
 using System.Linq;
 using System.Threading.Tasks;
-using static System.Runtime.InteropServices.JavaScript.JSType;
+using Org.BouncyCastle.Asn1.Cms;
+using Microsoft.EntityFrameworkCore;
 
 namespace SocialEducatorAvalonia.ViewModels
 {
@@ -24,6 +25,67 @@ namespace SocialEducatorAvalonia.ViewModels
         readonly ImmutableSortedDictionary<string, int> _paymentDict;
         public ImmutableSortedDictionary<string, int> PaymentDict { get => _paymentDict; }
 
+        readonly ImmutableArray<string> _paymentsType;
+        public ImmutableArray<string> PaymentType { get => _paymentsType; }
+
+        [ObservableProperty]
+        decimal _payment = 0;
+
+        [ObservableProperty]
+        string _selectedPayment = "Не выбрано";
+
+        [ObservableProperty]
+        bool _selectedComboBox = false;     
+
+        [RelayCommand]
+        void CheckBoxClicked()
+        {
+            foreach (var item in PersonsPaymentList)
+            {
+                item.IsChecked = SelectedComboBox;
+            }
+        }
+
+        // TODO: немного доработать с выделением и проверкой дичи всякой
+
+        [RelayCommand]
+        void ApllyFilters()
+        {
+            if (SelectedPayment is not "Не выбрано")
+            {
+                foreach (var item in _personsPaymentList)
+                {
+                    if (item.IsChecked)
+                    {
+                        item.PaymentType = SelectedPayment;
+                    }
+                }
+            }
+
+            if (Payment > 0)
+            {
+                foreach (var item in _personsPaymentList)
+                {
+                    if (item.IsChecked)
+                    {
+                        item.Payment = Payment;
+                    }
+                }
+            }
+
+        }
+
+        public AddPaymentsViewModel()
+        {
+            _paymentTypeList = [.. DbContext.TypesOfPayments.Select(x => x.TypeTittle)];
+
+            _paymentDict = DbContext.TypesOfPayments.OrderBy(x => x.TypeTittle)
+                .ToImmutableSortedDictionary(x => x.TypeTittle, x => x.TypeOfPaymentId);
+
+            _paymentsType = PaymentDict.Keys.ToImmutableArray().Add("Не выбрано");
+        }
+
+
         public static void TakeList(List<Student> students)
         {
             if (students is not null && students.Count >= 1)
@@ -45,13 +107,7 @@ namespace SocialEducatorAvalonia.ViewModels
             }
         }
 
-        public AddPaymentsViewModel()
-        {
-            _paymentTypeList = [.. DbContext.TypesOfPayments.Select(x => x.TypeTittle)];
 
-            _paymentDict = DbContext.TypesOfPayments.OrderBy(x => x.TypeTittle)
-                .ToImmutableSortedDictionary(x => x.TypeTittle, x => x.TypeOfPaymentId);
-        }
 
         [RelayCommand]
         async Task SaveListToDataBase()

+ 0 - 2
SocialEducatorAvalonia/ViewModels/PaymentsViewModel.cs

@@ -282,9 +282,7 @@ namespace SocialEducatorAvalonia.ViewModels
                 if (CheckAllFields()) // могу менять
                     collection = new(DbContext.StudentsAndPayments.Where(x => x.TypePayment.TypeTittle == value).Select(x => x.Student).Distinct());
                 else // не могу менять
-                {
                     collection = new(StudentsList.Where(x => x.StudentsAndPayments.Where(y => y.TypePayment.TypeTittle == value).Count() >= 1).ToList());
-                }
 
                 if (collection.Count == 0)
                     MessageBoxManager.GetMessageBoxStandard("Сообщение для вас", "Нету записей с данной выплатой", ButtonEnum.Ok, Icon.Database).ShowAsync();

+ 84 - 79
SocialEducatorAvalonia/Views/AddPaymentsView.axaml

@@ -2,110 +2,115 @@
              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"
-             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"  
-             xmlns:vm="clr-namespace:SocialEducatorAvalonia.ViewModels;assembly=SocialEducatorAvalonia"             
+             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
+             xmlns:vm="clr-namespace:SocialEducatorAvalonia.ViewModels;assembly=SocialEducatorAvalonia"
              x:Class="SocialEducatorAvalonia.Views.AddPaymentsView"
+			 xmlns:views="clr-namespace:TextPlays.Views"
+			 xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
              x:DataType="vm:AddPaymentsViewModel"
              x:Name="root">
 
-  <Grid RowDefinitions="80, *">
+	<Grid RowDefinitions="100, *">
 
-    <StackPanel Grid.Row="0" Orientation="Vertical" Classes="def">
+		<StackPanel Grid.Row="0" Orientation="Vertical" Classes="def">
 
-      <StackPanel Orientation="Horizontal" Classes="def">
+			<StackPanel Orientation="Horizontal" Classes="def">
 
-        <Button Content="Назад" Command="{Binding GoBackCommand}" HorizontalAlignment="Stretch" Margin="40 0 0 0">
-          <PathIcon Data="{StaticResource arrow_reply_regular}"/>
-        </Button>
+				<Button Content="Назад" Command="{Binding GoBackCommand}" HorizontalAlignment="Stretch" Margin="40 0 0 0">
+					<PathIcon Data="{StaticResource arrow_reply_regular}"/>
+				</Button>
 
-        <Button Content="Добавить запись" Command="{Binding AddRecordOfStudentCommand}"/>
+				<Button Content="Добавить запись" Command="{Binding AddRecordOfStudentCommand}"/>
 
-        <Button Content="Сохранить в БД" Command="{Binding SaveListToDataBaseCommand}"/>
+				<Button Content="Сохранить в БД" Command="{Binding SaveListToDataBaseCommand}"/>
 
-        <Button Content="Очистить" Command="{Binding ClearAllFieldsCommand}"/>
+				<Button Content="Очистить" Command="{Binding ClearAllFieldsCommand}"/>
 
-        <!--<Button Content="Добавить из файла" Command=""/>-->
+				<!--<Button Content="Добавить из файла" Command=""/>-->
 
+			</StackPanel>
 
-      </StackPanel>
 
+			<StackPanel Orientation="Horizontal" Classes="def">
+				
+				<ComboBox Width="200"  SelectedItem="{Binding SelectedPayment}" ItemsSource="{Binding PaymentType}"/>
 
-      <StackPanel Orientation="Horizontal" Classes="def">
+				<TextBox Width="100" Watermark="Деньга" Text="{Binding Payment}"/>
 
-        
-        
-        <!--<Button Content="Очистить" Command="{Binding ClearAllFieldsCommand}"/>-->
+				<Button Content="Применить фильтры" Command="{Binding ApllyFiltersCommand }" />
+				
+				<CheckBox Content="Выделить все" IsChecked="{Binding SelectedComboBox, Mode=TwoWay}"
+                  Command="{Binding CheckBoxClickedCommand}"/>
 
+				
+				<!--<Button Content="Очистить" Command="{Binding ClearAllFieldsCommand}"/>-->
 
-      </StackPanel>
-      
-      
-      
-      
-      
-    </StackPanel>
+			</StackPanel>
 
-    <DataGrid Classes="def" Grid.Row="1" ItemsSource="{Binding PersonsPaymentList, Mode=TwoWay}" BorderBrush="White" GridLinesVisibility="All">
 
-      <DataGrid.Columns>
-        <DataGridTextColumn Width="300" Binding="{Binding FIO, Mode=TwoWay}"  Header="ФИО"/>
-        
-        <DataGridTextColumn Width="100" Binding="{Binding Payment, Mode=TwoWay}"  Header="Выплата"/>        
-        
-        <DataGridTemplateColumn Header="Тип вылаты" Width="250">
-          <DataGridTemplateColumn.CellTemplate>
-            <DataTemplate>              
-              <ComboBox ItemsSource="{Binding #root((vm:AddPaymentsViewModel)DataContext).PaymentTypeList}"
-                        SelectedItem="{Binding PaymentType, Mode=TwoWay}"/>              
-            </DataTemplate>
-          </DataGridTemplateColumn.CellTemplate>
-        </DataGridTemplateColumn>
+		</StackPanel>
 
-        <DataGridTemplateColumn Header="Дата выплаты" Width="140">
-          <DataGridTemplateColumn.CellTemplate>
-            <DataTemplate>
-              <CalendarDatePicker Watermark="01/01/2020" SelectedDateFormat="Custom" CustomDateFormatString="dd-MM-yyy"
-                                  SelectedDate="{Binding CurrentPaymentDate, Mode=TwoWay}"/>
-            </DataTemplate>
-          </DataGridTemplateColumn.CellTemplate>
-        </DataGridTemplateColumn>
+		<DataGrid Classes="def" Grid.Row="1" ItemsSource="{Binding PersonsPaymentList, Mode=TwoWay}" BorderBrush="White" GridLinesVisibility="All">
 
-        <DataGridTemplateColumn Header="Конечная дата" Width="140">
-          <DataGridTemplateColumn.CellTemplate>
-            <DataTemplate>
-              <CalendarDatePicker Watermark="01/01/2020" SelectedDateFormat="Custom" CustomDateFormatString="dd-MM-yyy"
-                                  SelectedDate="{Binding EndRangeDate, Mode=TwoWay}"/>
-            </DataTemplate>
-          </DataGridTemplateColumn.CellTemplate>
-        </DataGridTemplateColumn>
+			<DataGrid.Columns>
+				<DataGridTextColumn Width="300" Binding="{Binding FIO, Mode=TwoWay}"  Header="ФИО"/>
 
-        <DataGridTemplateColumn Header="В списке" Width="100">
-          <DataGridTemplateColumn.CellTemplate>
-            <DataTemplate>
-              <CheckBox HorizontalAlignment="Center" VerticalAlignment="Center"
-                              IsChecked="{Binding  Path=IsChecked, Mode=TwoWay}"
+				<DataGridTextColumn Width="100" Binding="{Binding Payment, Mode=TwoWay}"  Header="Выплата"/>
+
+				<DataGridTemplateColumn Header="Тип вылаты" Width="250">
+					<DataGridTemplateColumn.CellTemplate>
+						<DataTemplate>
+							<ComboBox ItemsSource="{Binding #root((vm:AddPaymentsViewModel)DataContext).PaymentTypeList}"
+									  SelectedItem="{Binding PaymentType, Mode=TwoWay}"/>
+						</DataTemplate>
+					</DataGridTemplateColumn.CellTemplate>
+				</DataGridTemplateColumn>
+
+				<DataGridTemplateColumn Header="Дата выплаты" Width="140">
+					<DataGridTemplateColumn.CellTemplate>
+						<DataTemplate>
+							<CalendarDatePicker Watermark="01/01/2020" SelectedDateFormat="Custom" CustomDateFormatString="dd-MM-yyy"
+												SelectedDate="{Binding CurrentPaymentDate, Mode=TwoWay}"/>
+						</DataTemplate>
+					</DataGridTemplateColumn.CellTemplate>
+				</DataGridTemplateColumn>
+
+				<DataGridTemplateColumn Header="Конечная дата" Width="140">
+					<DataGridTemplateColumn.CellTemplate>
+						<DataTemplate>
+							<CalendarDatePicker Watermark="01/01/2020" SelectedDateFormat="Custom" CustomDateFormatString="dd-MM-yyy"
+												SelectedDate="{Binding EndRangeDate, Mode=TwoWay}"/>
+						</DataTemplate>
+					</DataGridTemplateColumn.CellTemplate>
+				</DataGridTemplateColumn>
+
+				<DataGridTemplateColumn Header="В списке" Width="100">
+					<DataGridTemplateColumn.CellTemplate>
+						<DataTemplate>
+							<CheckBox HorizontalAlignment="Center" VerticalAlignment="Center"
+											IsChecked="{Binding  Path=IsChecked, Mode=TwoWay}"
                               />
-            </DataTemplate>
-          </DataGridTemplateColumn.CellTemplate>
-        </DataGridTemplateColumn>
+						</DataTemplate>
+					</DataGridTemplateColumn.CellTemplate>
+				</DataGridTemplateColumn>
 
-        <!--Command="{Binding #root((vm:PaymentsViewModel)DataContext).AddToListCommand, Mode=OneWay}"
+				<!--Command="{Binding #root((vm:PaymentsViewModel)DataContext).AddToListCommand, Mode=OneWay}"
         CommandParameter="{Binding}"-->
 
-        <DataGridTemplateColumn Width="*" Header="Удалить из списка">
-          <DataGridTemplateColumn.CellTemplate>
-            <DataTemplate>
-              <Button Content="Удалить" Command="{Binding #root((vm:AddPaymentsViewModel)DataContext).DeleteFieldCommand}"
-                      CommandParameter="{Binding}"/>
-            </DataTemplate>
-          </DataGridTemplateColumn.CellTemplate>
-        </DataGridTemplateColumn>
-
-
-      </DataGrid.Columns>     
-      
-    </DataGrid>    
-    
-  </Grid>
-  
+				<DataGridTemplateColumn Width="*" Header="Удалить из списка">
+					<DataGridTemplateColumn.CellTemplate>
+						<DataTemplate>
+							<Button Content="Удалить" Command="{Binding #root((vm:AddPaymentsViewModel)DataContext).DeleteFieldCommand}"
+									CommandParameter="{Binding}"/>
+						</DataTemplate>
+					</DataGridTemplateColumn.CellTemplate>
+				</DataGridTemplateColumn>
+
+
+			</DataGrid.Columns>
+
+		</DataGrid>
+
+	</Grid>
+
 </UserControl>