public KeyListPage(Models.Event tatEvent)
 {
     InitializeComponent();
     tatEvent1             = tatEvent;
     KeyListDG.ItemsSource = TatarCulturDbEntities.GetContext().Keys.Where(p => p.IdEvent == tatEvent.IdEvent).OrderBy(p => p.KeyEvent).ToList();
     DataContext           = _currentKey;
 }
Exemple #2
0
        private void BtnSaveClick(object sender, RoutedEventArgs e)
        {
            StringBuilder _error = CheckFields();

            if (_error.Length > 0)
            {
                MessageBox.Show(_error.ToString());
                return;
            }
            if (_currentType.IdType == 0)
            {
                TatarCulturDbEntities.GetContext().Types.Add(_currentType);
            }

            try
            {
                TatarCulturDbEntities.GetContext().SaveChanges();
                MessageBox.Show("Запись Изменена");
                Manager.MainFrame.GoBack();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            Manager.MainFrame.GoBack();
        }
Exemple #3
0
        private void UpdateData()
        {
            var _currentObject = TatarCulturDbEntities.GetContext().Objects.OrderBy(p => p.Name).ToList();

            if (ComboType.SelectedIndex > 0)
            {
                _currentObject = _currentObject.Where(p => p.IdType == (ComboType.SelectedItem as Models.Type).IdType).ToList();
            }

            _currentObject = _currentObject.Where(p => p.Name.ToLower().Contains(TBoxSearch.Text.ToLower())).ToList();
            MapTat.Children.Clear();
            foreach (Models.Object obj in _currentObject)
            {
                Location pinLocation       = new Location((double)obj.Latitude, (double)obj.Longitude);
                Location pinLocationCenter = new Location(55.60307988301807, 49.586290315150926);
                var      pin = new Pushpin();
                pin.ToolTip  = $"{obj.Name}";
                pin.Location = pinLocation;

                MapTat.Children.Add(pin);
                MapTat.ZoomLevel = 8;
                MapTat.Center    = pinLocationCenter;
            }
            LViewObject.ItemsSource = _currentObject;
            TextBlockCount.Text     = $"Результат запроса: {_currentObject.Count} записей из {_itemcount}";
        }
        private void BtnSaveClick(object sender, RoutedEventArgs e)
        {
            StringBuilder _error = CheckFields();

            if (_error.Length > 0)
            {
                MessageBox.Show(_error.ToString());
                return;
            }
            if (_currentKey.IdKey == 0)
            {
                _currentKey.IdEvent = tatEvent1.IdEvent;
                _currentKey.Active  = false;
                TatarCulturDbEntities.GetContext().Keys.Add(_currentKey);
            }

            try
            {
                TatarCulturDbEntities.GetContext().SaveChanges();
                MessageBox.Show($"Ключь {_currentKey.KeyEvent} сохранен!");
            }
            catch (Exception ex)
            {
                MessageBox.Show($"{_currentKey.IdKey} {_currentKey.IdEvent} {_currentKey.Active} {_currentKey.KeyEvent}");
                MessageBox.Show(ex.Message.ToString());
            }
            Manager.MainFrame.GoBack();
        }
Exemple #5
0
 public PageUser(User user)
 {
     InitializeComponent();
     DataContext                = user;
     ListBoxKey.Visibility      = Visibility.Collapsed;
     ListBoxComment.ItemsSource = TatarCulturDbEntities.GetContext().Comments.Where(p => p.IdUser == user.IdUser).OrderBy(p => p.IdComment).ToList();
     ListBoxKey.ItemsSource     = TatarCulturDbEntities.GetContext().Sales.Where(p => p.IdUser == user.IdUser).OrderBy(p => p.IdSale).ToList();
 }
Exemple #6
0
        private void BtnDeleteClick(object sender, RoutedEventArgs e)
        {
            var  selectedUser = UserListDG.SelectedItems.Cast <User>().ToList();
            User info         = selectedUser[0];

            StringBuilder s = new StringBuilder();

            if (info.Sales.Count > 0)
            {
                s.AppendLine($"Есть связанные записи c истории");
            }
            if (info.Comments.Count > 0)
            {
                s.AppendLine($"Есть связанные записи c комментариями");
            }

            if (s.Length > 0)
            {
                MessageBox.Show(s.ToString());
            }

            MessageBoxResult messageBoxResult = MessageBox.Show($"Удалить запись???", "Удаление", MessageBoxButton.OKCancel, MessageBoxImage.Question);


            if (messageBoxResult == MessageBoxResult.OK)
            {
                try
                {
                    User x = selectedUser[0];
                    if (x.Sales.Count > 0)
                    {
                        var  saleUser = TatarCulturDbEntities.GetContext().Sales.Where(p => p.IdUser == x.IdUser).ToList();
                        Sale sale     = saleUser[0];
                        TatarCulturDbEntities.GetContext().Sales.Remove(sale);
                    }
                    if (x.Comments.Count > 0)
                    {
                        var     commentUser = TatarCulturDbEntities.GetContext().Comments.Where(p => p.IdUser == x.IdUser).ToList();
                        Comment com         = commentUser[0];
                        TatarCulturDbEntities.GetContext().Comments.Remove(com);
                    }



                    TatarCulturDbEntities.GetContext().Users.Remove(x);
                    TatarCulturDbEntities.GetContext().SaveChanges();
                    MessageBox.Show("Записи удалены");

                    List <User> users = TatarCulturDbEntities.GetContext().Users.OrderBy(p => p.Login).ToList();
                    UserListDG.ItemsSource = null;
                    UserListDG.ItemsSource = users;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString(), "Ошибка удаления", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
        private void UpdateData()
        {
            var _currentComment = TatarCulturDbEntities.GetContext().Comments.OrderBy(p => p.IdComment).ToList();

            _currentComment = _currentComment.Where(p => p.User.Login.ToLower().Contains(TBoxSearch.Text.ToLower())).ToList();


            CommentListDG.ItemsSource = _currentComment;
            TextBlockCount.Text       = $"Результат запроса: {_currentComment.Count} записей из {_itemcount-1}";
        }
 private void btnSaveClick(object sender, RoutedEventArgs e)
 {
     try
     {
         TatarCulturDbEntities.GetContext().SaveChanges();
         MessageBox.Show("Изменения сохранены");
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ошибка");
     }
 }
Exemple #9
0
        private void UpdateData()
        {
            var _currentUser = TatarCulturDbEntities.GetContext().Users.OrderBy(p => p.IdRols).ToList();

            if (ComboType.SelectedIndex > 0)
            {
                _currentUser = _currentUser.Where(p => p.IdRols == (ComboType.SelectedItem as UserRol).IdRols).ToList();
            }
            _currentUser = _currentUser.Where(p => p.Login.ToLower().Contains(TBoxSearch.Text.ToLower())).ToList();


            UserListDG.ItemsSource = _currentUser;
            TextBlockCount.Text    = $"Результат запроса: {_currentUser.Count} записей из {_itemcount-1}";
        }
        public AddUserPage(User selecetUser, int idUser)
        {
            InitializeComponent();

            if (selecetUser != null)
            {
                _currentUser = selecetUser;
                _filePath    = _currentDirectory + _currentUser.UserPhoto;
                _fileCompare = _filePath;
                Title        = "Редактирование данных пользователя";
            }
            cmbRol.Visibility   = Visibility.Collapsed;
            RolLabel.Visibility = Visibility.Collapsed;
            _currentUser.IdRols = idUser;
            idUser1             = idUser;
            _photoName          = _currentUser.UserPhoto;
            DataContext         = _currentUser;
            cmbRol.ItemsSource  = TatarCulturDbEntities.GetContext().UserRols.ToList();
        }
Exemple #11
0
        private void BtnEnterClick(object sender, RoutedEventArgs e)
        {
            List <User> users = TatarCulturDbEntities.GetContext().Users.ToList();
            User        user  = users.FirstOrDefault(p => p.Login == TbLogin.Text && p.Password == PbPassword.Password);

            StringBuilder error = new StringBuilder();

            if (string.IsNullOrWhiteSpace(TbLogin.Text))
            {
                error.AppendLine("Введите логин");
            }

            if (string.IsNullOrWhiteSpace(PbPassword.Password))
            {
                error.AppendLine("Введите пароль");
            }
            if (error.Length > 0)
            {
                MessageBox.Show(error.ToString(), "Ошибка авторизации", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }


            if (user != null)
            {
                int rols = (int)user.IdRols;
                Manager.idUser = user.IdUser;


                MainWindow mainWindow = new MainWindow(rols, user);
                mainWindow.Owner = this;
                this.Hide();
                mainWindow.Show();
            }

            else if (user == null)
            {
                MessageBox.Show("Неверный пароль или логин", "Неверный пароль или логин", MessageBoxButton.OK, MessageBoxImage.Error);
                PbPassword.Clear();
            }
        }
        private void btnDeleteClick(object sender, RoutedEventArgs e)
        {
            var selectedKey = KeyListDG.SelectedItems.Cast <Models.Key>().ToList();
            MessageBoxResult messageBoxResult = MessageBox.Show($"Удалить {selectedKey.Count()} записей???", "Удаление", MessageBoxButton.OKCancel, MessageBoxImage.Question);

            if (messageBoxResult == MessageBoxResult.OK)
            {
                try
                {
                    TatarCulturDbEntities.GetContext().Keys.RemoveRange(selectedKey);
                    TatarCulturDbEntities.GetContext().SaveChanges();
                    MessageBox.Show("Записи удалены");
                    List <Models.Key> key = TatarCulturDbEntities.GetContext().Keys.OrderBy(p => p.KeyEvent).ToList();
                    KeyListDG.ItemsSource = key;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
Exemple #13
0
        private StringBuilder CheckFields()
        {
            StringBuilder s = new StringBuilder();

            if (string.IsNullOrWhiteSpace(_currentType.Name))
            {
                s.AppendLine("Название типа невведено!");
            }
            List <Models.Type> types = TatarCulturDbEntities.GetContext().Types.ToList();

            Models.Type type = types.FirstOrDefault(p => p.Name == _currentType.Name);
            if (type != null)
            {
                string name = type.Name;
                if (name == _currentType.Name)
                {
                    s.AppendLine("Такой тип уже есть!");
                }
            }
            return(s);
        }
Exemple #14
0
        private void LoadData()
        {
            Location pinLocation = new Location(55.7887, 49.1221);

            MapTat.Center = pinLocation;

            var type = TatarCulturDbEntities.GetContext().Types.OrderBy(p => p.Name).ToList();

            type.Insert(0, new Models.Type
            {
                Name = "Все типы"
            });
            ComboType.ItemsSource   = type;
            ComboType.SelectedIndex = 0;

            var obj = TatarCulturDbEntities.GetContext().Objects.ToList();

            LViewObject.ItemsSource = obj;
            _itemcount          = LViewObject.Items.Count;
            TextBlockCount.Text = $"Результат запроса: {_itemcount} записей из {_itemcount}";
        }
Exemple #15
0
        private void LViewObjectSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (LViewObject.SelectedIndex >= 0)
            {
                MapTat.Children.Clear();
                StackInfo.Visibility = Visibility.Visible;
                Models.Object obj         = (LViewObject.SelectedItem as Models.Object);
                var           i           = TatarCulturDbEntities.GetContext().Objects.Where(x => x.IdObject == obj.IdObject).ToList();
                Location      pinLocation = new Location((double)obj.Latitude, (double)obj.Longitude);
                Pushpin       pin         = new Pushpin();
                pin.Location = pinLocation;

                MapTat.Children.Add(pin);
                MapTat.ZoomLevel = 15;
                MapTat.Center    = pinLocation;
                this.DataContext = obj;
                if (obj.Description == null)
                {
                    textblockInfo.Text = "Нет информации";
                }
                else if (obj.Description.Length > 250)
                {
                    int text = obj.Description.Length - 250;
                    var des  = obj.Description;
                    des = des.Substring(0, des.Length - text);
                    des = des.Insert(des.Length, " ...");
                    textblockInfo.Text = des;
                }
                else
                {
                    textblockInfo.Text = obj.Description;
                }
            }
            else
            {
                StackInfo.Visibility = Visibility.Collapsed;
            }
        }