|
@@ -1,4 +1,5 @@
|
|
|
-using System;
|
|
|
+using Microsoft.Win32;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.IO;
|
|
|
using System.Linq;
|
|
@@ -21,90 +22,47 @@ namespace mateo
|
|
|
byte[] image; //очищать!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
int idattraction = 0;
|
|
|
|
|
|
+ public void Update() //функция для обновления информации о пользователе
|
|
|
+ {
|
|
|
+ //фио
|
|
|
+ var fio = DB.GetContext().Users.FirstOrDefault(x => x.IDUsers == DB.Iduser);
|
|
|
+ txtNameProfile.Text = fio.LastName + " " + fio.FirstName + " " + fio.MiddleName;
|
|
|
+
|
|
|
+ //выводим баланс карты
|
|
|
+ DB.Idcard = fio.FKCard;
|
|
|
+ txtBalanceProfile.Text = String.Format("{0:0.00}", Convert.ToDecimal(DB.GetContext().Card.FirstOrDefault(x => x.IDCard == fio.FKCard).Balance));
|
|
|
+
|
|
|
+ //выводим картинку из бд
|
|
|
+ if (fio.Image != null)
|
|
|
+ {
|
|
|
+ image = fio.Image;
|
|
|
+ MemoryStream ms = new MemoryStream(image);
|
|
|
+ imgProfile.Source = BitmapFrame.Create(ms);
|
|
|
+ }
|
|
|
+ if (imgProfile.Source != null) btnAddPhoto.Content = "изменить фото";
|
|
|
+ }
|
|
|
|
|
|
public MainWindow()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
- listAttraction.ItemsSource = DB.GetContext().Attraction.Where(x => x.FKStatusAttraction != 2).ToList();
|
|
|
-
|
|
|
+ listAllAttraction.ItemsSource = DB.GetContext().Attraction.Where(x => x.FKStatusAttraction != 2).ToList();
|
|
|
+ Update();//??здесь?
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
#region раздел Услуги
|
|
|
private void btnUslugiClick(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
+ stackAttraction.Visibility = Visibility.Hidden;
|
|
|
gridTickets.Visibility = Visibility.Hidden;
|
|
|
+ gridProfile.Visibility = Visibility.Hidden;
|
|
|
+ gridPlusBalance.Visibility = Visibility.Hidden;
|
|
|
+ listAllAttraction.Visibility = Visibility.Visible;
|
|
|
}
|
|
|
|
|
|
- #endregion
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private void btnProfileClick(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- gridTickets.Visibility = Visibility.Hidden;
|
|
|
-
|
|
|
- Profile profile = new Profile();
|
|
|
- profile.Show();
|
|
|
- this.Close();
|
|
|
- }
|
|
|
-
|
|
|
- private void btnBronClick(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- border_bron.Visibility = Visibility.Visible;
|
|
|
- }
|
|
|
-
|
|
|
- private void btn_pay_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void btn_first_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void btn_cancel_Click(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- border_bron.Visibility = Visibility.Hidden;
|
|
|
- }
|
|
|
-
|
|
|
- #region соцсети
|
|
|
- private void btn_whatsapp(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void btn_gmail(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void btn_vk(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- private void btn_insta(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- #endregion
|
|
|
- private void btnLogout(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- First first = new First();
|
|
|
- first.Show();
|
|
|
- this.Close();
|
|
|
- }
|
|
|
- private void btnExit(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- Application.Current.Shutdown();
|
|
|
- }
|
|
|
-
|
|
|
- private void ViewAttraction(object sender, MouseButtonEventArgs e)
|
|
|
+ private void ViewAllAttraction(object sender, MouseButtonEventArgs e) //просмотр каждого аттракцинона для выбора нужного
|
|
|
{
|
|
|
- if (listAttraction.SelectedItem is Attraction attraction)
|
|
|
+ if (listAllAttraction.SelectedItem is Attraction attraction)
|
|
|
{
|
|
|
stackPriceOld.Visibility = Visibility.Visible;
|
|
|
stackPriceBaby.Visibility = Visibility.Visible;
|
|
@@ -121,43 +79,24 @@ namespace mateo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void btnBackAttraction(object sender, RoutedEventArgs e)
|
|
|
+ private void btnBackAttraction(object sender, RoutedEventArgs e) //кнопка Назад после просмотра
|
|
|
{
|
|
|
stackAttraction.Visibility = Visibility.Hidden;
|
|
|
}
|
|
|
|
|
|
+ #endregion
|
|
|
|
|
|
- public void Summ(decimal summ)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- summ = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).Sum(x => x.Quantity * x.Summ);
|
|
|
- }
|
|
|
- catch
|
|
|
- {
|
|
|
- summ = 0;
|
|
|
- }
|
|
|
- if (summ == 0) txtSumm.Text = "Сумма: 0.00";
|
|
|
-
|
|
|
- else txtSumm.Text = String.Format("Сумма: {0:0,00}", summ);
|
|
|
- }
|
|
|
|
|
|
- private void btnTickets(object sender, RoutedEventArgs e)
|
|
|
- {
|
|
|
- gridTickets.Visibility = Visibility.Visible;
|
|
|
- listTickets.ItemsSource = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).ToList();
|
|
|
- decimal summ = 0;
|
|
|
- Summ(summ);
|
|
|
- }
|
|
|
+ #region Раздел Билеты
|
|
|
|
|
|
- private void BtnAddOldAttraction(object sender, RoutedEventArgs e)
|
|
|
+ private void BtnAddOldAttraction(object sender, RoutedEventArgs e) //+ для добавления билета с типом Взрослый
|
|
|
{
|
|
|
|
|
|
//записываем id аттракциона по названию
|
|
|
var attr = DB.GetContext().Attraction.Where(x => x.NameAttraction == txtNameAttraction.Text).FirstOrDefault();
|
|
|
idattraction = attr.IDAttraction;
|
|
|
|
|
|
- if (DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKAttraction == idattraction && x.FKStatusPuy == 2&&x.FKTypeTickets==1).FirstOrDefault() != null)
|
|
|
+ if (DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKAttraction == idattraction && x.FKStatusPuy == 2 && x.FKTypeTickets == 1).FirstOrDefault() != null)
|
|
|
MessageBox.Show("Вы уже добавили такой билет, если хотите изменить количество, перейдите пожалуйста в раздел \"Билеты\"", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
else
|
|
|
{
|
|
@@ -180,7 +119,7 @@ namespace mateo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void BtnAddBabyAttraction(object sender, RoutedEventArgs e)
|
|
|
+ private void BtnAddBabyAttraction(object sender, RoutedEventArgs e) //+ для добавления билета с типом Детский
|
|
|
{
|
|
|
var attr = DB.GetContext().Attraction.Where(x => x.NameAttraction == txtNameAttraction.Text).FirstOrDefault();
|
|
|
//записываем id аттракциона по названию
|
|
@@ -203,35 +142,43 @@ namespace mateo
|
|
|
DB.GetContext().Tickets.Add(tickets);
|
|
|
DB.GetContext().SaveChanges();
|
|
|
MessageBox.Show("Билет добавлен в раздел \"Билеты\"", "Информация", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
- listTickets.ItemsSource = DB.GetContext().Tickets.Where(x => x.FKUser==DB.Iduser&&x.FKStatusPuy==2).ToList();
|
|
|
+ listTickets.ItemsSource = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).ToList();
|
|
|
+
|
|
|
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void BtnDeleteTickets(object sender, RoutedEventArgs e)
|
|
|
+ public decimal Summ(decimal summ) //функция для вывода суммы добавленных билетов
|
|
|
{
|
|
|
- if ((sender as Button).DataContext is Tickets tickets)
|
|
|
+ try
|
|
|
{
|
|
|
- decimal summ = 0;
|
|
|
- DB.GetContext().Tickets.Remove(tickets);
|
|
|
- DB.GetContext().SaveChanges();
|
|
|
- listTickets.ItemsSource = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).ToList();
|
|
|
- try
|
|
|
- {
|
|
|
- summ = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).Sum(x => x.Quantity * x.Summ);
|
|
|
- }
|
|
|
- catch
|
|
|
- {
|
|
|
- summ = 0;
|
|
|
- }
|
|
|
- if (summ == 0) txtSumm.Text = "Сумма: 0.00";
|
|
|
-
|
|
|
- else txtSumm.Text = String.Format("Сумма: {0:0,00}", summ);
|
|
|
+ summ = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).Sum(x => x.Quantity * x.Summ);
|
|
|
}
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ summ = 0;
|
|
|
+ }
|
|
|
+ if (summ == 0) txtSumm.Text = "Сумма: 0.00";
|
|
|
+
|
|
|
+ else txtSumm.Text = String.Format("Сумма: {0:0,00}", summ);
|
|
|
+
|
|
|
+ return summ;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void btnTickets(object sender, RoutedEventArgs e) //вывод добавленных билетов
|
|
|
+ {
|
|
|
+ stackAttraction.Visibility = Visibility.Hidden;
|
|
|
+ listAllAttraction.Visibility = Visibility.Hidden;
|
|
|
+ gridProfile.Visibility = Visibility.Hidden;
|
|
|
+ gridPlusBalance.Visibility = Visibility.Hidden;
|
|
|
+ gridTickets.Visibility = Visibility.Visible;
|
|
|
+
|
|
|
+ listTickets.ItemsSource = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).ToList();
|
|
|
+ decimal summ = 0;
|
|
|
+ summ = Summ(summ);
|
|
|
}
|
|
|
|
|
|
- private void BtnTicketsMinus(object sender, RoutedEventArgs e)
|
|
|
+ private void BtnTicketsMinus(object sender, RoutedEventArgs e) //уменьшение количества билетов
|
|
|
{
|
|
|
if ((sender as Button).DataContext is Tickets tickets)
|
|
|
{
|
|
@@ -240,12 +187,11 @@ namespace mateo
|
|
|
DB.GetContext().SaveChanges();
|
|
|
listTickets.ItemsSource = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).ToList();
|
|
|
decimal summ = 0;
|
|
|
- Summ(summ);
|
|
|
-
|
|
|
+ summ = Summ(summ);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void BtnTicketsPlus(object sender, RoutedEventArgs e)
|
|
|
+ private void BtnTicketsPlus(object sender, RoutedEventArgs e) //увеличение количества билетов
|
|
|
{
|
|
|
if ((sender as Button).DataContext is Tickets tickets)
|
|
|
{
|
|
@@ -254,12 +200,33 @@ namespace mateo
|
|
|
DB.GetContext().SaveChanges();
|
|
|
listTickets.ItemsSource = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).ToList();
|
|
|
decimal summ = 0;
|
|
|
- Summ(summ);
|
|
|
+ summ = Summ(summ);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BtnDeleteTickets(object sender, RoutedEventArgs e) //удаление добавленных билетов
|
|
|
+ {
|
|
|
+ if ((sender as Button).DataContext is Tickets tickets)
|
|
|
+ {
|
|
|
+ decimal summ = 0;
|
|
|
+ DB.GetContext().Tickets.Remove(tickets);
|
|
|
+ DB.GetContext().SaveChanges();
|
|
|
+ listTickets.ItemsSource = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).ToList();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ summ = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).Sum(x => x.Quantity * x.Summ);
|
|
|
+ }
|
|
|
+ catch
|
|
|
+ {
|
|
|
+ summ = 0;
|
|
|
+ }
|
|
|
+ if (summ == 0) txtSumm.Text = "Сумма: 0.00";
|
|
|
|
|
|
+ else txtSumm.Text = String.Format("Сумма: {0:0,00}", summ);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void BtnPuyAll(object sender, RoutedEventArgs e)
|
|
|
+ private void BtnPuyAll(object sender, RoutedEventArgs e) //покупка всех добавленных билетов и заненсение в таблицу History
|
|
|
{
|
|
|
if (DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).FirstOrDefault() == null)
|
|
|
{
|
|
@@ -269,7 +236,7 @@ namespace mateo
|
|
|
else
|
|
|
{
|
|
|
decimal summ = 0;
|
|
|
- Summ(summ);
|
|
|
+ summ = Summ(summ);
|
|
|
|
|
|
var card = DB.GetContext().Users.Where(x => x.IDUsers == DB.Iduser).FirstOrDefault().FKCard;
|
|
|
var balance = DB.GetContext().Card.Where(x => x.IDCard == card).FirstOrDefault();
|
|
@@ -299,19 +266,123 @@ namespace mateo
|
|
|
|
|
|
listTickets.ItemsSource = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).ToList();
|
|
|
|
|
|
- try
|
|
|
- {
|
|
|
- summ = DB.GetContext().Tickets.Where(x => x.FKUser == DB.Iduser && x.FKStatusPuy == 2).Sum(x => x.Quantity * x.Summ);
|
|
|
- }
|
|
|
- catch
|
|
|
- {
|
|
|
- summ = 0;
|
|
|
- }
|
|
|
- if (summ == 0) txtSumm.Text = "Сумма: 0.00";
|
|
|
-
|
|
|
- else txtSumm.Text = String.Format("Сумма: {0:0,00}", summ);
|
|
|
+ summ = Summ(summ);
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ #region Раздел Профиль
|
|
|
+ private void btnProfileClick(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ stackAttraction.Visibility = Visibility.Hidden;
|
|
|
+ listAllAttraction.Visibility = Visibility.Hidden;
|
|
|
+ gridTickets.Visibility = Visibility.Hidden;
|
|
|
+ gridProfile.Visibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BtnAddPhoto(object sender, RoutedEventArgs e) //добавить/изменить фото пользователя в разделе Профиль и в бд
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ string imageLoc;
|
|
|
+ OpenFileDialog dld = new OpenFileDialog();
|
|
|
+ dld.Filter = "JPG Files (*.jpg)|*.jpg|PNG Files (*.png)|*.png|JPEG Files (*.jpeg)|*.jpeg";
|
|
|
+ dld.Title = "Выберите изображение пользователя";
|
|
|
+ bool? result = dld.ShowDialog();
|
|
|
+ if (result == true)
|
|
|
+ {
|
|
|
+ imageLoc = dld.FileName;
|
|
|
+ imgProfile.Source = new BitmapImage(new Uri(imageLoc));
|
|
|
+ FileStream fs = new FileStream(imageLoc, FileMode.Open, FileAccess.Read);
|
|
|
+ BinaryReader br = new BinaryReader(fs);
|
|
|
+
|
|
|
+ image = br.ReadBytes((int)fs.Length);
|
|
|
+ var img = DB.GetContext().Users.Where(x => x.IDUsers == DB.Iduser).FirstOrDefault();
|
|
|
+ img.Image = image;
|
|
|
+ DB.GetContext().SaveChanges();
|
|
|
+ }
|
|
|
+ if (imgProfile.Source != null) btnAddPhoto.Content = "изменить фото";
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ MessageBox.Show(ex.Message);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BtnDeletePhoto(object sender, RoutedEventArgs e) //удаление фото в тч из бд
|
|
|
+ {
|
|
|
+ var fio = DB.GetContext().Users.FirstOrDefault(x => x.IDUsers == DB.Iduser);
|
|
|
+ fio.Image = null;
|
|
|
+ DB.GetContext().SaveChanges();
|
|
|
+ imgProfile.Source = null;
|
|
|
+ btnAddPhoto.Content = "добавить фото";
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BtbBalance(object sender, RoutedEventArgs e) //кнопка Пополнить баланс, открываем форму для пополнения баланса
|
|
|
+ {
|
|
|
+ gridPlusBalance.Visibility = Visibility.Visible;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BtbPlusBalance(object sender, RoutedEventArgs e) //пополняем баланс (незакончено, надо чтобы пользователь вводил номер банковской карты)
|
|
|
+ {
|
|
|
+ //"пополняем баланс" типа
|
|
|
+ if (txtPlusBalabce.Text != "")
|
|
|
+ {
|
|
|
+ var a = DB.GetContext().Card.Where(x => x.IDCard == DB.Idcard).FirstOrDefault();
|
|
|
+ a.Balance += Convert.ToDecimal(txtPlusBalabce.Text);
|
|
|
+ DB.GetContext().SaveChanges();
|
|
|
+ gridPlusBalance.Visibility = Visibility.Hidden;
|
|
|
+ }
|
|
|
+ var fio = DB.GetContext().Users.FirstOrDefault(x => x.IDUsers == DB.Iduser);
|
|
|
+ DB.Idcard = fio.FKCard;
|
|
|
+ txtBalanceProfile.Text = DB.GetContext().Card.FirstOrDefault(x => x.IDCard == fio.FKCard).Balance.ToString();
|
|
|
+ Update();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BtnCancelBalance(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ gridPlusBalance.Visibility = Visibility.Hidden;
|
|
|
+ }
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
+ #region Прочее
|
|
|
+ private void btnLogout(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ First first = new First();
|
|
|
+ first.Show();
|
|
|
+ this.Close();
|
|
|
+ }
|
|
|
+ private void btnExit(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ Application.Current.Shutdown();
|
|
|
+ }
|
|
|
+
|
|
|
+ #region СоцСети
|
|
|
+ private void btn_whatsapp(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void btn_gmail(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void btn_vk(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ private void btn_insta(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #endregion
|
|
|
}
|
|
|
}
|