|
@@ -0,0 +1,141 @@
|
|
|
+
|
|
|
+using Cake.Core.IO;
|
|
|
+using Microsoft.Win32;
|
|
|
+using System;
|
|
|
+using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
+using System.Linq;
|
|
|
+using System.Text;
|
|
|
+using System.Threading.Tasks;
|
|
|
+using System.Windows;
|
|
|
+using System.Windows.Controls;
|
|
|
+using System.Windows.Data;
|
|
|
+using System.Windows.Documents;
|
|
|
+using System.Windows.Input;
|
|
|
+using System.Windows.Media;
|
|
|
+using System.Windows.Media.Imaging;
|
|
|
+using System.Windows.Navigation;
|
|
|
+using System.Windows.Shapes;
|
|
|
+
|
|
|
+namespace ProjectAnalogParus
|
|
|
+{
|
|
|
+ /// <summary>
|
|
|
+ /// Логика взаимодействия для FullInformationStudentPage.xaml
|
|
|
+ /// </summary>
|
|
|
+ public partial class FullInformationStudentPage : Page
|
|
|
+ {
|
|
|
+ gr672_bdaEntities db = new gr672_bdaEntities();
|
|
|
+ public int? IdStudent { get; set; }
|
|
|
+ public FullInformationStudentPage(int? StudentId)
|
|
|
+ {
|
|
|
+ InitializeComponent();
|
|
|
+
|
|
|
+ cmbSpecialty.ItemsSource = db.Specialty.ToList();
|
|
|
+ cmbSpecialty.DisplayMemberPath = "NameSpecialty";
|
|
|
+ cmbSpecialty.SelectedValuePath = "IdSpecialty";
|
|
|
+
|
|
|
+ IdStudent = StudentId;
|
|
|
+ if (StudentId != null)
|
|
|
+ {
|
|
|
+ this.Title = "Дополнительная информация";
|
|
|
+ Student st = db.Student.SingleOrDefault(item => item.IdStudent == StudentId);
|
|
|
+ txtLastName.Text = st.LastName;
|
|
|
+ txtFirstName.Text = st.FirstName;
|
|
|
+ txtMiddleName.Text = st.Middlename;
|
|
|
+ cmbSpecialty.Text = st.Group.Specialty.NameSpecialty;
|
|
|
+ txtNumberGroup.Text = Convert.ToString(st.Group.NumberGroup);
|
|
|
+ txtCourse.Text = Convert.ToString(st.Group.Course);
|
|
|
+ AddInfo.Visibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ this.Title = "Добавление студента";
|
|
|
+ SaveInfo.Visibility = Visibility.Collapsed;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void EditInformationStudent_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if (txtCourse.Text == string.Empty && txtFirstName.Text == string.Empty && txtLastName.Text == string.Empty && txtMiddleName.Text == string.Empty && txtNumberGroup.Text == string.Empty && cmbSpecialty.Text == string.Empty)
|
|
|
+ {
|
|
|
+ MessageBox.Show("Ключевые поля не заполнены");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Student stud = db.Student.SingleOrDefault(item => item.IdStudent == IdStudent);
|
|
|
+ stud.LastName = txtLastName.Text;
|
|
|
+ stud.FirstName = txtFirstName.Text;
|
|
|
+ stud.Middlename = txtMiddleName.Text;
|
|
|
+ stud.Group.NumberGroup = Convert.ToInt32(txtNumberGroup.Text);
|
|
|
+ stud.Group.Course = Convert.ToInt32(txtCourse.Text);
|
|
|
+ stud.Group.SpecialtyId = Convert.ToInt32((cmbSpecialty.SelectedItem as Specialty).IdSpecialty);
|
|
|
+ db.SaveChanges();
|
|
|
+ MessageBox.Show("Данные изменены и сохранены");
|
|
|
+ FramePage.MainFrame.Navigate(new ListStudentPage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void Cancel_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ FramePage.MainFrame.Navigate(new ListStudentPage());
|
|
|
+ }
|
|
|
+
|
|
|
+ private void AddInformationStudent_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ if(txtCourse != null && txtFirstName != null && txtLastName != null && txtMiddleName != null && txtNumberGroup != null && cmbSpecialty != null)
|
|
|
+ {
|
|
|
+ Group group = new Group()
|
|
|
+ {
|
|
|
+ NumberGroup = Convert.ToInt32(txtNumberGroup.Text),
|
|
|
+ Course = Convert.ToInt32(txtCourse.Text),
|
|
|
+ SpecialtyId = Convert.ToInt32((cmbSpecialty.SelectedItem as Specialty).IdSpecialty)
|
|
|
+ };
|
|
|
+
|
|
|
+ Student stud = new Student()
|
|
|
+ {
|
|
|
+ LastName = txtLastName.Text,
|
|
|
+ FirstName = txtFirstName.Text,
|
|
|
+ Middlename = txtMiddleName.Text,
|
|
|
+ GroupId = group.IdGroup
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ db.Student.Add(stud);
|
|
|
+ db.Group.Add(group);
|
|
|
+ db.SaveChanges();
|
|
|
+ MessageBox.Show("Студент добавлен!");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("Не все поля заполнены!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ class ConvertImageToByte
|
|
|
+ {
|
|
|
+ public static byte[] ImageToByte(string Path)
|
|
|
+ {
|
|
|
+ byte[] image;
|
|
|
+ image = File.ReadAllBytes(Path);
|
|
|
+ return image;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private void PhotoInsert_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ OpenFileDialog ofdPicture = new OpenFileDialog();
|
|
|
+ ofdPicture.Filter =
|
|
|
+ "Image files|*.bmp;*.jpg;*.gif;*.png;*.tif|All files|*.*";
|
|
|
+ ofdPicture.FilterIndex = 1;
|
|
|
+
|
|
|
+ if (ofdPicture.ShowDialog() == true)
|
|
|
+ PhotoOfClent.Source =
|
|
|
+ new BitmapImage(new Uri(ofdPicture.FileName));
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+}
|