EmployeeBrowseView.xaml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <Page x:Class="InvestTracker.Views.EmployeeBrowseView"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:vm="clr-namespace:InvestTracker.VM"
  7. xmlns:local="clr-namespace:InvestTracker.Views"
  8. xmlns:model="clr-namespace:InvestTracker.Entities"
  9. xmlns:validation="clr-namespace:InvestTracker.Validation" d:DataContext="{d:DesignInstance Type=vm:EmployeeBrowseVM}"
  10. mc:Ignorable="d"
  11. d:DesignHeight="450" d:DesignWidth="800"
  12. x:Name="EPage"
  13. Title="EmployeeBrowseView">
  14. <Page.Resources>
  15. <!--Шаблон яйчейки отображения даты-->
  16. <DataTemplate x:Key="RegularDateTemplate" >
  17. <TextBlock
  18. Text="{Binding Birthday,StringFormat={}{0:dd\.}{0:MM\.}{0:yyyy}}"
  19. VerticalAlignment="Center"
  20. HorizontalAlignment="Center" />
  21. </DataTemplate>
  22. <!--Шаблон яйчейки редактирования даты-->
  23. <DataTemplate x:Key="EditingDateTemplate">
  24. <DatePicker SelectedDate="{Binding Birthday, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
  25. </DataTemplate>
  26. <!--BTV-->
  27. <BooleanToVisibilityConverter x:Key="BTV"/>
  28. </Page.Resources>
  29. <StackPanel>
  30. <!--Этот FrameworkElement содержит все свойства у Page-->
  31. <FrameworkElement x:Name="ProxyElement" DataContext="{Binding}" Visibility="Collapsed"/>
  32. <Menu>
  33. <MenuItem Header="Действие" >
  34. <MenuItem Command="{Binding UndoCommand}" Header="Отменить" ></MenuItem>
  35. <Separator/>
  36. <MenuItem Command="{Binding NewCommand}" Header="Создать" ></MenuItem>
  37. <MenuItem Command="{Binding EditCommand}" Header="Редактировать" ></MenuItem>
  38. <MenuItem Command="{Binding SaveCommand}" Header="Сохранить" ></MenuItem>
  39. <MenuItem Command="{Binding FindCommand}" Header="Найти" />
  40. <Separator/>
  41. <MenuItem Command="{Binding DeleteCommand}" Header="Удалить" ></MenuItem>
  42. </MenuItem>
  43. <MenuItem Header="Отчет"></MenuItem>
  44. </Menu>
  45. <Label HorizontalAlignment="Center" FontSize="24">Список сотрудников</Label>
  46. <ToolBar Margin="8">
  47. <Button Name="Undo" Command="{Binding UndoCommand}" ToolTip="Отменить редактирование/создание">
  48. <Image Width="32" Height="32" Source="/Images/undo.png" />
  49. </Button>
  50. <Button Name="Add" Command="{Binding NewCommand}" ToolTip="Добавить">
  51. <Image Width="32" Height="32" Source="/Images/add.png" />
  52. </Button>
  53. <Button Name="Edit" Command="{Binding EditCommand}" ToolTip="Редактировать">
  54. <Image Width="32" Height="32" Source="/Images/edit.png" />
  55. </Button>
  56. <Button Name="Search" Command="{Binding ToggleFilterCommand}" ToolTip="Поиск">
  57. <Image Width="32" Height="32" Source="/Images/search.png" />
  58. </Button>
  59. <Button Name="Save" Command="{Binding SaveCommand}" ToolTip="Сохранить">
  60. <Image Width="32" Height="32" Source="/Images/save.png" />
  61. </Button>
  62. <Button Name="Delete" Command="{Binding DeleteCommand}" ToolTip="Удалить">
  63. <Image Width="32" Height="32" Source="/Images/delete.png" />
  64. </Button>
  65. </ToolBar>
  66. <!--Main-->
  67. <StackPanel>
  68. <!--Поле поиска-->
  69. <Grid
  70. Visibility="{Binding FilterActive,Converter={StaticResource BTV}}"
  71. Grid.Column="1"
  72. Background="#ddd"
  73. Margin="8">
  74. <Grid.ColumnDefinitions>
  75. <ColumnDefinition Width="64"/>
  76. <ColumnDefinition Width="*"/>
  77. <ColumnDefinition Width="32"/>
  78. </Grid.ColumnDefinitions>
  79. <Grid.RowDefinitions>
  80. <RowDefinition Height="16"/>
  81. <RowDefinition Height="32"/>
  82. <RowDefinition Height="32"/>
  83. </Grid.RowDefinitions>
  84. <Label
  85. Content="Поиск"
  86. HorizontalAlignment="Center"
  87. Grid.Column="0"
  88. Grid.ColumnSpan="3"
  89. Grid.Row="0"/>
  90. <Label
  91. Content="Фамилия"
  92. HorizontalAlignment="Right"
  93. VerticalAlignment="Center"
  94. Grid.Column="0"
  95. Grid.Row="1"/>
  96. <TextBox
  97. VerticalContentAlignment="Center"
  98. Grid.Column="1"
  99. Margin="4"
  100. Grid.Row="1"
  101. Text="{Binding FilterSurname,UpdateSourceTrigger=PropertyChanged}"/>
  102. <Button
  103. Command="{Binding FindCommand}"
  104. Grid.Column="2"
  105. Grid.Row="1"
  106. Grid.RowSpan="2"
  107. Margin="4"
  108. ToolTip="Поиск">
  109. <Image Source="/Images/search.png" />
  110. </Button>
  111. <Label
  112. Content="Должность"
  113. HorizontalAlignment="Right"
  114. VerticalAlignment="Center"
  115. Grid.Column="0"
  116. Grid.Row="2"/>
  117. <ComboBox
  118. VerticalContentAlignment="Center"
  119. Margin="4"
  120. Grid.Column="1"
  121. Grid.Row="2"
  122. ItemsSource="{Binding DataContext.AllTitles,Source={x:Reference ProxyElement}}"
  123. DisplayMemberPath="Name"
  124. SelectedItem="{Binding FilterTitle, UpdateSourceTrigger=PropertyChanged}"/>
  125. </Grid>
  126. <!--/Поле поиска-->
  127. <!--Сетка редактирования-->
  128. <DataGrid
  129. Margin="8"
  130. Grid.Column="0"
  131. AutoGenerateColumns="False"
  132. ItemsSource="{Binding Employees}"
  133. RowBackground="#ddd"
  134. AlternatingRowBackground="#eee"
  135. CanUserAddRows="False"
  136. CanUserDeleteRows="False"
  137. IsReadOnly="{Binding GridBlocked}"
  138. SelectedItem="{Binding SelectedEmployee}">
  139. <!--Рисуем восклицательный знак если в строке ошибка-->
  140. <DataGrid.RowValidationErrorTemplate>
  141. <ControlTemplate>
  142. <Grid
  143. Margin="0,-2,0,-2"
  144. ToolTip="{Binding
  145. RelativeSource={RelativeSource FindAncestor,
  146. AncestorType={x:Type DataGridRow}},
  147. Path=(Validation.Errors)[0].ErrorContent}">
  148. <Ellipse
  149. StrokeThickness="0"
  150. Fill="Red"
  151. Width="{TemplateBinding FontSize}"
  152. Height="{TemplateBinding FontSize}" />
  153. <TextBlock
  154. Text="!"
  155. FontSize="{TemplateBinding FontSize}"
  156. FontWeight="Bold"
  157. Foreground="White"
  158. HorizontalAlignment="Center" />
  159. </Grid>
  160. </ControlTemplate>
  161. </DataGrid.RowValidationErrorTemplate>
  162. <DataGrid.Columns>
  163. <DataGridTextColumn
  164. Binding="{Binding Path=Surname,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
  165. Header="Фамилия"/>
  166. <DataGridTextColumn
  167. Binding="{Binding Path=Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
  168. Header="Имя"/>
  169. <DataGridTextColumn
  170. Binding="{Binding Path=Patronymic,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
  171. Header="Отчество"/>
  172. <DataGridComboBoxColumn
  173. ItemsSource="{Binding DataContext.AllTitles,Source={x:Reference ProxyElement}}"
  174. DisplayMemberPath="Name"
  175. SelectedValueBinding="{Binding Path=TitleId, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
  176. SelectedValuePath="Id"
  177. Header="Должность"/>
  178. <DataGridTemplateColumn
  179. CellTemplate="{StaticResource RegularDateTemplate}"
  180. CellEditingTemplate="{StaticResource EditingDateTemplate}"
  181. Header="Дата рождения" />
  182. <DataGridTextColumn
  183. Binding="{Binding Path=Phone,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
  184. Header="Телефон" />
  185. <DataGridTextColumn
  186. EditingElementStyle="{StaticResource ValidationFail}"
  187. Header="Электронная почта">
  188. <DataGridTextColumn.Binding>
  189. <Binding
  190. Path="Email"
  191. Mode="TwoWay"
  192. UpdateSourceTrigger="PropertyChanged"
  193. ValidatesOnExceptions="True">
  194. <Binding.ValidationRules>
  195. <validation:Email/>
  196. </Binding.ValidationRules>
  197. </Binding>
  198. </DataGridTextColumn.Binding>
  199. </DataGridTextColumn>
  200. </DataGrid.Columns>
  201. </DataGrid>
  202. <!--/Сетка редактирования-->
  203. </StackPanel>
  204. <!--/Main-->
  205. </StackPanel>
  206. </Page>