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 SSS { /// /// Логика взаимодействия для Page3.xaml /// public partial class Page3 : Page { Client user = new Client(); Entities ent = new Entities(); public Page3(int UsId) { InitializeComponent(); user = ent.Client.Where(x => x.id_Client == UsId).FirstOrDefault(); Nam.Text = user.Name; Srname.Text = user.Surname; Patr.Text = user.Patronymic; if (user.id_Gender == 1) { Gen.Text = "Мужской"; } else { Gen.Text = "Женский"; } string bd = user.BirthDate.ToString(); DateBirth.Text = DateTime.Parse(bd).ToShortDateString(); Log.Text = user.Login; Pass.Text = "сложный"; Photo ph = ent.Photo.Where(x => x.id_photo == user.id_photo).FirstOrDefault(); if (ph != null) { byte[] bt = ph.photo1; ShowImage(bt, imUser); } } void ShowImage(byte[] arr, System.Windows.Controls.Image img) { BitmapImage BI = new BitmapImage(); BI.BeginInit(); BI.StreamSource = new MemoryStream(arr); BI.EndInit(); img.Source = BI; } private void RedUserInfo(object sender, RoutedEventArgs e) { Izmen wns = new Izmen(user.id_Client); wns.ShowDialog(); MainFrame.Name1.Navigate(new Page3(user.id_Client); } private void RedAuthInfo(object sender, RoutedEventArgs e) { reddate wns = new reddate(user.id_Client); wns.ShowDialog(); MainFrame.Name1.Navigate(new Page3(user.id_Client)); } private void SelectPh(object sender, RoutedEventArgs e) { redphoto wns = new redphoto(user.id_Client); wns.ShowDialog(); MainFrame.Name1.Navigate(new Page3(user.id_Client)); } private void UploadPhoto(object sender, RoutedEventArgs e) { try { OpenFileDialog FileDialog = new OpenFileDialog(); FileDialog.ShowDialog(); Photo UpPh = new Photo(); UpPh.id_user = user.id_Client; UpPh.photo1 = File.ReadAllBytes(FileDialog.FileName); ent.Photo.Add(UpPh); ent.SaveChanges(); user.id_photo = UpPh.id_photo; ent.SaveChanges(); MessageBox.Show("Изображение загружено"); MainFrame.Name1.Navigate(new Page3(user.id_Client)); } catch { MessageBox.Show("Не удалось загрузить фото, повторите попытку!"); } } private void UploadPhotos(object sender, RoutedEventArgs e) { OpenFileDialog FileDialog = new OpenFileDialog(); FileDialog.Multiselect = true; if (FileDialog.ShowDialog() == true) { foreach (string file in FileDialog.FileNames) { Photo UsPh = new Photo(); UsPh.id_user = user.id_Client; UsPh.photo1 = File.ReadAllBytes(file); ent.Photo.Add(UsPh); } } ent.SaveChanges(); MessageBox.Show("Фотографии загружены"); } } } }