gr672_bda 4 anos atrás
pai
commit
5f74d3592e

+ 2 - 3
ProjectAnalogParus/FullInformationStudentPage.xaml

@@ -16,9 +16,8 @@
         <TextBox Name="txtNumberGroup" HorizontalAlignment="Left" Height="23" Margin="200,221,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
         <TextBox Name="txtCourse" HorizontalAlignment="Left" Height="23" Margin="200,259,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
         <Button Name="SaveInfo" Content="Сохранить" HorizontalAlignment="Left" Margin="108,338,0,0" VerticalAlignment="Top" Width="97" Click="EditInformationStudent_Click" Height="34"/>
-        <Button Name="AddInfo" Content="Добавить" HorizontalAlignment="Left" Margin="108,338,0,0" VerticalAlignment="Top" Width="97" Click="AddInformationStudent_Click" Height="34"/>
-        <Button  Content="Выход" HorizontalAlignment="Left" Margin="234,338,0,0" VerticalAlignment="Top" Width="86" Click="Cancel_Click" Height="34"/>
-        <Button Content="Добавить фотографию" HorizontalAlignment="Left" Margin="359,221,0,0" VerticalAlignment="Top" Width="140" Height="23" Click="PhotoInsert_Click"/>
+        <Button Name="AddInfo" Content="Добавить" HorizontalAlignment="Left" Margin="108,338,0,0" VerticalAlignment="Top" Width="145" Click="AddInformationStudent_Click" Height="34"/>
+        <Button Content="Добавить фотографию" HorizontalAlignment="Left" Margin="319,338,0,0" VerticalAlignment="Top" Width="180" Height="34" Click="PhotoInsert_Click"/>
         <Image Name="PhotoOfClent" HorizontalAlignment="Left" Height="149" Margin="359,53,0,0" VerticalAlignment="Top" Width="140"/>
         <TextBlock HorizontalAlignment="Left" Margin="108,53,0,0" TextWrapping="Wrap" Text="Фамилия" VerticalAlignment="Top" Height="23" Width="87"/>
         <TextBlock HorizontalAlignment="Left" Margin="108,95,0,0" TextWrapping="Wrap" Text="Имя" VerticalAlignment="Top" Height="23" Width="87"/>

+ 19 - 0
ProjectAnalogParus/ListStudentPage.xaml.cs

@@ -51,7 +51,26 @@ namespace ProjectAnalogParus
 
         private void DeleteStudent_Click(object sender, RoutedEventArgs e)
         {
+            Student stud = (Student)Studentgrid.SelectedItem;
+            if (stud != null)
+            {
+                MessageBoxResult result = MessageBox.Show("Удалить данные?", "", MessageBoxButton.YesNo);
+                if (result == MessageBoxResult.Yes)
+                {
+                    var selectedItem = (Student)Studentgrid.SelectedItem;
+                    if (selectedItem != null)
+                    {
+                        db.Student.Remove(selectedItem);
+                        db.SaveChanges();
+                        Studentgrid.ItemsSource = db.Student.ToList();
+                    }
 
+                }
+            }
+            else
+            {
+                MessageBox.Show("Не выбрана строка!");
+            }
         }
     }
 }