Ejemplo n.º 1
0
 private void Window_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (Visibility == Visibility.Visible)
     {
         TourBaseEntitiesDB.GetContext().ChangeTracker.Entries().ToList().ForEach(p => p.Reload());
         DGridTours.ItemsSource = TourBaseEntitiesDB.GetContext().Tour.ToList();
     }
 }
Ejemplo n.º 2
0
 public static TourBaseEntitiesDB GetContext()
 {
     if (_context == null)
     {
         _context = new TourBaseEntitiesDB();
     }
     return(_context);
 }
Ejemplo n.º 3
0
        private void UpdateEquipment()
        {
            var currentTour = TourBaseEntitiesDB.GetContext().Tour.ToList();

            currentTour = currentTour.Where(p => p.Name.ToLower().Contains(TBoxSearch.Text.ToLower())).ToList();


            DGridTours.ItemsSource = currentTour.OrderBy(p => p.Name).ToList();
        }
Ejemplo n.º 4
0
 public AddHotel(Hotel selectedHotel)
 {
     InitializeComponent();
     if (selectedHotel != null)
     {
         _currentHotel = selectedHotel;
     }
     DataContext           = _currentHotel;
     CountryCB.ItemsSource = TourBaseEntitiesDB.GetContext().Country.ToList();
     countries             = TourBaseEntitiesDB.GetContext().Country.ToList();
 }
Ejemplo n.º 5
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_currentHotel.CountOfStars.ToString()))
            {
                errors.AppendLine("Укажите количество звезд у отеля");
            }
            if (_currentHotel.CountOfStars > 5)
            {
                errors.AppendLine("Количество звезд у отеля не может быть больше 5");
            }
            if (_currentHotel.CountOfStars < 1)
            {
                errors.AppendLine("Количество звезд у отеля не может быть меньше 1");
            }
            if (string.IsNullOrWhiteSpace(_currentHotel.Name))
            {
                errors.AppendLine("Укажите наименование отеля");
            }
            if (string.IsNullOrWhiteSpace(_currentHotel.CountryCode))
            {
                errors.AppendLine("Укажите страну у отеля");
            }



            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            else
            {
                TourBaseEntitiesDB.GetContext().Hotel.Add(_currentHotel);
            }


            TourBaseEntitiesDB.GetContext().SaveChanges();
            MessageBox.Show("Запись успешно сохранена!");
            HotelsPage ht = new HotelsPage();

            ht.Visibility = Visibility.Visible;
            this.Close();
        }
Ejemplo n.º 6
0
        private void RemoveBtn(object sender, RoutedEventArgs e)
        {
            var TourForRemoving = DGridTours.SelectedItems.Cast <Tour>().ToList();

            if (MessageBox.Show($"Вы точно хотите удалить следующие {TourForRemoving.Count()} элементов?", "Внимание", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                try
                {
                    TourBaseEntitiesDB.GetContext().Tour.RemoveRange(TourForRemoving);
                    TourBaseEntitiesDB.GetContext().SaveChanges();
                    MessageBox.Show("Данны успешно удалены!");

                    DGridTours.ItemsSource = TourBaseEntitiesDB.GetContext().Tour.ToList();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
Ejemplo n.º 7
0
        private void btnSave(object sender, RoutedEventArgs e)
        {
            var imageBuffer = BitmapSourceToByteArray((BitmapSource)Picture.Source);

            _currentTour.ImagePreview = imageBuffer;
            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_currentTour.TicketCount.ToString()))
            {
                errors.AppendLine("Укажите количество билетов у тура");
            }
            if (string.IsNullOrWhiteSpace(_currentTour.Name))
            {
                errors.AppendLine("Укажите наименование тура");
            }
            if (string.IsNullOrWhiteSpace(_currentTour.Price.ToString()))
            {
                errors.AppendLine("Укажите цену у тура");
            }



            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            else
            {
                TourBaseEntitiesDB.GetContext().Tour.Add(_currentTour);
            }


            TourBaseEntitiesDB.GetContext().SaveChanges();
            MessageBox.Show("Запись успешно сохранена!");
            ToursPage tr = new ToursPage();

            tr.Visibility = Visibility.Visible;
            this.Close();
        }
Ejemplo n.º 8
0
        private void userTicket(object sender, RoutedEventArgs e)
        {
            var name     = Name.Text;
            var midname  = MidName.Text;
            var lastname = LastName.Text;
            var howvidan = howVidan.Text;
            var placereg = placeRegister.Text;
            var Serial   = serial.Text;
            var Number   = number.Text;

            StringBuilder errors = new StringBuilder();

            if (string.IsNullOrWhiteSpace(name.ToString()))
            {
                errors.AppendLine("Заполните поле Имя");
            }
            if (string.IsNullOrWhiteSpace(midname.ToString()))
            {
                errors.AppendLine("Заполните поле Фамилия");
            }
            if (string.IsNullOrWhiteSpace(lastname.ToString()))
            {
                errors.AppendLine("Заполните поле Отчество");
            }
            if (string.IsNullOrWhiteSpace(howvidan.ToString()))
            {
                errors.AppendLine("Заполните поле Кем выдан");
            }
            if (string.IsNullOrWhiteSpace(placereg.ToString()))
            {
                errors.AppendLine("Заполните поле Место регистрации");
            }
            if (string.IsNullOrWhiteSpace(Serial.ToString()))
            {
                errors.AppendLine("Заполните поле Серия");
            }
            if (string.IsNullOrWhiteSpace(Number.ToString()))
            {
                errors.AppendLine("Заполните поле Номер");
            }
            if (Serial.Length != 4)
            {
                errors.AppendLine("Некоректно заполнено поле Серия");
            }
            if (Number.Length != 6)
            {
                errors.AppendLine("Некоректно заполнено поле Номер");
            }
            if (CBoxHotel.SelectedItem == null)
            {
                errors.AppendLine("Не выбран отель.");
            }
            if (CBoxTour.SelectedItem == null)
            {
                errors.AppendLine("Не выбран тур");
            }



            if (errors.Length > 0)
            {
                MessageBox.Show(errors.ToString());
                return;
            }
            else
            {
                using (StreamWriter incdate = File.AppendText(@"C:\ticketsUser\ticket.txt"))
                {
                    incdate.WriteLine(Name.Text, '\n');
                    incdate.WriteLine(MidName.Text, '\n');
                    incdate.WriteLine(LastName.Text, '\n');
                    incdate.WriteLine(howVidan.Text, '\n');
                    incdate.WriteLine(placeRegister.Text, '\n');
                    incdate.WriteLine(serial.Text, '\n');
                    incdate.WriteLine(number.Text, '\n');
                    incdate.WriteLine(CBoxTour.SelectedIndex.ToString(), '\n');
                    incdate.WriteLine(CBoxHotel.SelectedIndex.ToString(), '\n');
                }


                //MailAddress from = new MailAddress("*****@*****.**", "Denis");
                //MailAddress to = new MailAddress(Email.Text.ToString());
                //MailMessage m = new MailMessage(from, to);
                //m.Subject = "Тест";
                //m.Body = "<h2>Письмо-тест работы smtp-клиента</h2>";
                //m.IsBodyHtml = true;
                //SmtpClient smtp = new SmtpClient("smtp.mail.ru", 465);
                //smtp.UseDefaultCredentials = false;
                //smtp.Credentials = new NetworkCredential("*****@*****.**", "Ltybc55329");
                //smtp.EnableSsl = true;
                //smtp.Send(m);


                using (var db = new TourBaseEntitiesDB())
                {
                }
                MessageBox.Show("Данные успешно сохранены и отправлены вам на почту");
            }
        }
Ejemplo n.º 9
0
 public TakeTicket()
 {
     InitializeComponent();
     CBoxTour.ItemsSource  = TourBaseEntitiesDB.GetContext().Tour.ToList();
     CBoxHotel.ItemsSource = TourBaseEntitiesDB.GetContext().Hotel.ToList();
 }
Ejemplo n.º 10
0
 public ToursPage()
 {
     InitializeComponent();
     DGridTours.ItemsSource = TourBaseEntitiesDB.GetContext().Tour.ToList();
 }
Ejemplo n.º 11
0
        private void saveBtn(object sender, RoutedEventArgs e)
        {
            var lg = loginn.Text;
            var pw = password.Password;

            using (var db = new TourBaseEntitiesDB())
            {
                StringBuilder errors = new StringBuilder();
                var           p      = db.Users.Any(l => l.login == loginn.Text);


                if (pw.Length < 6 || pw.Length > 20)
                {
                    errors.AppendLine("Длина пароля должна состоять от 6 до 20 символов");
                }
                if (!pw.Any(char.IsUpper))
                {
                    errors.AppendLine("Пароль должен содержать хотя бы одну заглавную букву");
                }
                if (!pw.Any(char.IsDigit))
                {
                    errors.AppendLine("Пароль должен содержать хотя бы одну цифру");
                }
                if (pw.Intersect("!@#$%^").Count() == 0)
                {
                    errors.AppendLine("Пароль должен содержать хотя бы один символ из набора  '!@#$%^'");
                }
                if (String.IsNullOrEmpty(lg))
                {
                    errors.AppendLine("Логин не введен, повторите попытку");
                }
                if (String.IsNullOrEmpty(pw))
                {
                    errors.AppendLine("Пароль не введен, повторите попытку");
                }
                if (password.Password != repeatpassword.Password)
                {
                    errors.AppendLine("Пароли не совпадают, повторите попытку!");
                }
                if (p == true)
                {
                    errors.AppendLine("Пользователь с таким логином уже существует, придумайте другой.");
                }
                if (errors.Length > 0)
                {
                    MessageBox.Show(errors.ToString());
                    return;
                }
                else
                {
                    Users user = new Users
                    {
                        login    = loginn.Text,
                        password = password.Password,
                        name     = name.Text,
                        surname  = surname.Text,
                        Role     = "Simple_user",
                    };
                    db.Users.Add(user);
                    db.SaveChanges();
                    MessageBox.Show("Аккаунт успешно создан!");

                    Login login = new Login();
                    login.Visibility = Visibility.Visible;
                    this.Close();
                }
            }
        }