Exemplo n.º 1
0
        private void btnAdmin_Click(object sender, RoutedEventArgs e)
        {
            Hide();
            AdminWnd AdminWnd = new AdminWnd();

            AdminWnd.Owner   = this;
            AdminWnd.Closed += delegate
            {
                Show();
            };
            AdminWnd.ShowDialog();
        }
Exemplo n.º 2
0
        private async void MainWindowShow(object obj)
        {
            ILogin temp_obj = obj as ILogin;

            if (temp_obj == null)
            {
                return;
            }
            LoadVisible = true;
            _waitHandle = new AutoResetEvent(false);
            await Task.Run(() =>
            {
                foreach (var item in _model.db.StaffSet)
                {
                    if (item.login == Login && (item.password == temp_obj.GetPassword() || item.password == hashing.HashPassword(temp_obj.GetPassword())))
                    {
                        Cur_session.New_session(item.Staff_PosId, item.login, item.password, item.FirstName, item.LastName, item.Staff_Pos.Position, item.phone_number);
                        _waitHandle.Set();

                        break;
                    }
                }
                _waitHandle.Set();
            });

            _waitHandle.WaitOne();
            if (Cur_session.Id == -1)
            {
                WpfMessageBox.Show("Ошибка авторизации", "Пользователь с таким логином или паролем не найден.", 0, MessageBoxImage.Warning);
                LoadVisible = false;
                return;
            }
            if (Cur_session.Id == 1)
            {
                LoadVisible = false;
                _waitHandle.Close();
                AdminWnd adminWnd = new AdminWnd();
                adminWnd.Show();
                temp_obj.Close();
            }
            if (Cur_session.Id == 3)
            {
                LoadVisible = false;
                _waitHandle.Close();
                WaiterWnd waiterWnd = new WaiterWnd();
                waiterWnd.Show();
                temp_obj.Close();
            }
        }