123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- 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
- {
- /// <summary>
- /// Логика взаимодействия для UserPage.xaml
- /// </summary>
- 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("Ваши фото добавлены");
- }
- }
- }
|