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 SneakersSkakunov { /// /// Логика взаимодействия для UserPage.xaml /// public partial class UserPage : Page { Users user = new Users(); Sniker snk = new Sniker(); public UserPage(int UsId) { InitializeComponent(); user = snk.Users.Where(x => x.id_Users == UsId).FirstOrDefault(); imya.Text = user.Name; fam.Text = user.Surname; otch.Text = user.Patronymic; if (user.id_Gender == 1) { pol.Text = "Мужской"; } else { pol.Text = "Женский"; } string bd = user.DateBirth.ToString(); BirthDate.Text = DateTime.Parse(bd).ToShortDateString(); lg.Text = user.Login; pss.Text = "Надежный"; PhotoUsers ph = snk.PhotoUsers.Where(x => x.id_photouser == user.id_photouser).FirstOrDefault(); if (ph != null) { byte[] bt = ph.PhotoUser; ShowImage(bt, foto); } } 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) { Redact wns = new Redact(user.id_Users); wns.ShowDialog(); MainFrame.mframe.Navigate(new UserPage(user.id_Users)); } private void RedAuthInfo(object sender, RoutedEventArgs e) { RedactAuth wns = new RedactAuth(user.id_Users); wns.ShowDialog(); MainFrame.mframe.Navigate(new UserPage(user.id_Users)); } private void SelectPh(object sender, RoutedEventArgs e) { RedactPhotoUser wns = new RedactPhotoUser(user.id_Users); wns.ShowDialog(); MainFrame.mframe.Navigate(new UserPage(user.id_Users)); } private void UploadPhoto(object sender, RoutedEventArgs e) { try { OpenFileDialog FileDialog = new OpenFileDialog(); FileDialog.ShowDialog(); PhotoUsers UpPh = new PhotoUsers(); UpPh.id_Users = user.id_Users; UpPh.PhotoUser = File.ReadAllBytes(FileDialog.FileName); snk.PhotoUsers.Add(UpPh); snk.SaveChanges(); user.id_photouser = UpPh.id_photouser; snk.SaveChanges(); MessageBox.Show("Ваше фото добавлено"); MainFrame.mframe.Navigate(new UserPage(user.id_Users)); } 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) { PhotoUsers UsPh = new PhotoUsers(); UsPh.id_Users = user.id_Users; UsPh.PhotoUser = File.ReadAllBytes(file); snk.PhotoUsers.Add(UsPh); } } snk.SaveChanges(); MessageBox.Show("Ваши фото добавлены"); } } }