浏览代码

6 работа

ГаряевСА 1 月之前
父节点
当前提交
051f8602ec
共有 3 个文件被更改,包括 36 次插入16 次删除
  1. 13 0
      Teachers/Models/ParticalTeacher.cs
  2. 2 1
      Teachers/ViewModels/ShowTeacherVM.cs
  3. 21 15
      Teachers/Views/ShowTeacherV.axaml

+ 13 - 0
Teachers/Models/ParticalTeacher.cs

@@ -52,5 +52,18 @@ namespace Teachers.Models
                 return massage;
             }
         }
+        public int CountHour
+        {
+            get
+            {
+                int sum = 0;
+                foreach (var item in Teachercourses)
+                {
+                    sum += item.Course.Hours.Value;
+                }
+                return sum;
+            }
+        }
     }
+    
 }

+ 2 - 1
Teachers/ViewModels/ShowTeacherVM.cs

@@ -13,7 +13,8 @@ namespace Teachers.ViewModels
     {
         public List<Teacher> TeacherList => MainWindowViewModel.myConnection.Teachers
                                                                                      .Include(x => x.Gender)
-                                                                                     .Include(x => x.Teachercourses).ThenInclude(x => x.Course).ToList();
+                                                                                     .Include(x => x.Teachercourses).ThenInclude(x => x.Course)
+                                                                                     .Include(x => x.Teacherdisciplines).ThenInclude(x => x.Discipline).ToList();
 
     }
 }

+ 21 - 15
Teachers/Views/ShowTeacherV.axaml

@@ -12,42 +12,48 @@
 			<ListBox.ItemTemplate>
 				<DataTemplate>
 					<Border BorderThickness="2" BorderBrush="Green">
+						<StackPanel Orientation="Horizontal" Margin="20">
 						<StackPanel>
 							<TextBlock FontWeight="Bold">Личная информация:</TextBlock>
 							<TextBlock Text="{Binding FIO}"></TextBlock>
 							<StackPanel Orientation="Horizontal">
-								<TextBlock Text="Пол: "></TextBlock>
-								<TextBlock Text="{Binding Gender.Title}"></TextBlock>
+								<TextBlock Text="{Binding Gender.Title, StringFormat= Пол: {0}}"></TextBlock>
 							</StackPanel>
 							<StackPanel Orientation="Horizontal">
-								<TextBlock Text="Дата рождения: "></TextBlock>
-								<TextBlock Text="{Binding Dateofbirth, StringFormat=D}"></TextBlock>
+								<TextBlock Text="{Binding Dateofbirth, StringFormat=Дата рождения: {0:D}}"></TextBlock>
 							</StackPanel>
 							<StackPanel Orientation="Horizontal">
-								<TextBlock Text="Стаж работы: "></TextBlock>
-								<TextBlock Text="{Binding ExperienceYM}"></TextBlock>
+								<TextBlock Text="{Binding ExperienceYM, StringFormat= Стаж работы: {0}}"></TextBlock>
 							</StackPanel>
 							<TextBlock FontWeight="Bold">Контактная информация:</TextBlock>
 							<StackPanel Orientation="Horizontal">
-								<TextBlock Text="Почта: "></TextBlock>
-								<TextBlock Text="{Binding Email}" Margin="0,0,30,0"></TextBlock>								
-								<TextBlock Text="Телефон: "></TextBlock>
-								<TextBlock Text="{Binding PhoneText}"></TextBlock>
-							</StackPanel>
-							<StackPanel Orientation="Horizontal">
-							<TextBlock FontWeight="Bold" Text="Курсы в общем объеме "></TextBlock>
-							<TextBlock Text=""></TextBlock>
+								<TextBlock Text="{Binding Email, StringFormat=Почта: {0}}" Margin="0,0,30,0"></TextBlock>								
+								<TextBlock Text="{Binding PhoneText, StringFormat=Телефон: {0}}"></TextBlock>
 							</StackPanel>
+							<TextBlock FontWeight="Bold" Text="{Binding CountHour, StringFormat=Курсы в общем объеме {0} часов}"></TextBlock>
 							<StackPanel>
 								<ItemsRepeater ItemsSource="{Binding Teachercourses}">									
 									<ItemsRepeater.ItemTemplate>
 										<DataTemplate>					
-											<TextBlock Text="{Binding Course.Title}"></TextBlock>
+											<TextBlock Text="{Binding Course.Title, StringFormat = - {0}}"></TextBlock>
 										</DataTemplate>
 									</ItemsRepeater.ItemTemplate>
 								</ItemsRepeater>
 							</StackPanel>
 						</StackPanel>
+						<StackPanel>
+							<TextBlock FontWeight="Bold" Text="Преподоваемые предметы: "></TextBlock>
+							<StackPanel>
+								<ItemsRepeater ItemsSource="{Binding Teacherdisciplines}">
+									<ItemsRepeater.ItemTemplate>
+										<DataTemplate>
+											<TextBlock Text="{Binding Discipline.Title, StringFormat = - {0}}"></TextBlock>
+										</DataTemplate>
+									</ItemsRepeater.ItemTemplate>
+								</ItemsRepeater>
+							</StackPanel>
+						</StackPanel>
+						</StackPanel>
 					</Border>
 				</DataTemplate>
 			</ListBox.ItemTemplate>