//private void FaceIdBtn_Click(object sender, RoutedEventArgs e)
        //{

        //}

        private void BackBtn_Click(object sender, RoutedEventArgs e)
        {
            StartingUC startUC = new StartingUC(st);

            st.startGrid.Children.Clear();
            st.startGrid.Children.Add(startUC);
        }
Exemplo n.º 2
0
        public StartWindow()
        {
            InitializeComponent();
            StartingUC startUC = new StartingUC(this);

            this.startGrid.Children.Add(startUC);
        }
        private void SubmitBtn_Click(object sender, RoutedEventArgs e)
        {
            //go to database and create user then return to start uc
            StartingUC startUC = new StartingUC(st);

            st.startGrid.Children.Clear();
            st.startGrid.Children.Add(startUC);
        }
        private void LoginBtn_Click(object sender, RoutedEventArgs e)
        {
            using (LibraryDBEntities db = new LibraryDBEntities())
            {
                var login = Login.Text;

                var password = Password.Password;

                var loginSearch = from user in db.Users
                                  where user.Login == login
                                  select user;

                var userResult = loginSearch.FirstOrDefault();



                try
                {
                    if (Login.Text != "" && Password.Password != "")
                    {
                        if (userResult != null)
                        {
                            if (password == userResult.Password)
                            {
                                if (userResult.RoleID == 1)
                                {
                                    AdminMenu menu = new AdminMenu(userResult.Id);
                                    menu.Show();

                                    StartingUC startUC = new StartingUC(st);
                                    st.startGrid.Children.Clear();
                                    st.startGrid.Children.Add(startUC);
                                }
                                if (userResult.RoleID == 2)
                                {
                                    UserMenu menu = new UserMenu(userResult.Id);
                                    menu.Show();
                                    StartingUC startUC = new StartingUC(st);
                                    st.startGrid.Children.Clear();
                                    st.startGrid.Children.Add(startUC);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Wrong password!");
                            }
                        }

                        else
                        {
                            MessageBox.Show("Login not found!");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Fill in all fields!");
                    }
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
        }