예제 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            userLogin    = loginBox.Text;
            userPassword = passwordBox.Password;

            //ify sprawdzajace czy wprowadzone dane do formularza logowania sa sensowne
            if (CheckLogin(userLogin) && CheckPassword(userPassword))
            {
                //jesli wszystko ok to polaczenie z baza danych
                string connectionString = GetConnectionString();
                using (SqlConnection sqlConnection = new SqlConnection(connectionString))
                {
                    sqlConnection.Open();
                    SqlCommand sqlCommand = new SqlCommand("Select * from Konto where Login_='" + userLogin + "' and Haslo='" + userPassword + "'", sqlConnection);
                    sqlCommand.CommandType = System.Data.CommandType.Text;

                    SqlDataAdapter sqlDataAdapter = new SqlDataAdapter();
                    sqlDataAdapter.SelectCommand = sqlCommand;

                    DataSet dataSet = new DataSet();
                    sqlDataAdapter.Fill(dataSet);
                    if (dataSet.Tables[0].Rows.Count > 0)
                    {
                        //odnaleziono w bazie i pomyslnie zalogowano
                        MoviesPage actionPage = new MoviesPage(userLogin, "Welcome");
                        this.NavigationService.Navigate(actionPage);
                        ResetBoxes();
                    }
                    else
                    {
                        //nie ma takich danych w bazie
                        ErrorPage errorPage = new ErrorPage("Error during log in process! Please try again");
                        this.NavigationService.Navigate(errorPage);
                        ResetBoxes();
                    }
                }
            }
        }
예제 #2
0
        private void returnButton_Click(object sender, RoutedEventArgs e)
        {
            MoviesPage actionPage = new MoviesPage(CurrentUserLogin, null);

            this.NavigationService.Navigate(actionPage);
        }
예제 #3
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            MoviesPage actionPage = new MoviesPage(userLogin, "Skiped");

            this.NavigationService.Navigate(actionPage);
        }