123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- 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
- {
- /// <summary>
- /// Логика взаимодействия для Page3.xaml
- /// </summary>
- 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;
- Fam.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 = "сложный";
- Photos ph = ent.Photos.Where(x => x.id_photo == user.id_photo).FirstOrDefault();
- if (ph != null)
- {
- byte[] bt = ph.Photo;
- 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();
- ClassF.Mfrm.Navigate(new Page3(user.id_Client));
- }
- private void RedAuthInfo(object sender, RoutedEventArgs e)
- {
- IzmenPar wns = new IzmenPar(user.id_Client);
- wns.ShowDialog();
- ClassF.Mfrm.Navigate(new Page3(user.id_Client));
- }
- private void SelectPh(object sender, RoutedEventArgs e)
- {
- redphoto wns = new redphoto(user.id_Client);
- wns.ShowDialog();
- ClassF.Mfrm.Navigate(new Page3(user.id_Client));
- }
- private void UploadPhoto(object sender, RoutedEventArgs e)
- {
- try
- {
- OpenFileDialog FileDialog = new OpenFileDialog();
- FileDialog.ShowDialog();
- Photos UpPh = new Photos();
- UpPh.id_Client = user.id_Client;
- UpPh.Photo = File.ReadAllBytes(FileDialog.FileName);
- ent.Photos.Add(UpPh);
- ent.SaveChanges();
- user.id_photo = UpPh.id_photo;
- ent.SaveChanges();
- MessageBox.Show("Изображение загружено");
- ClassF.Mfrm.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)
- {
- Photos UsPh = new Photos();
- UsPh.id_Client = user.id_Client;
- UsPh.Photo = File.ReadAllBytes(file);
- ent.Photos.Add(UsPh);
- }
- }
- ent.SaveChanges();
- MessageBox.Show("Фотографии загружены");
- }
- }
- }
|