Ejemplo n.º 1
0
        private void UserProfile_Click(object sender, RoutedEventArgs e)
        {
            UserProfileView userProfileView = new UserProfileView();

            userProfileView.Show();
            this.Close();
        }
Ejemplo n.º 2
0
        private void SignupButton_Click(object sender, RoutedEventArgs e)
        {
            string name     = NameTextBox.Text.ToString();
            string email    = EmailTextBox.Text.ToString();
            string password = PasswordTextBox.Text.ToString();

            try
            {
                string          MyConString = "Server=127.0.0.1;Port=3306;Uid=root;Pwd=;Database=tokiohotel;";
                MySqlConnection connection  = new MySqlConnection(MyConString);
                MySqlCommand    command     = connection.CreateCommand();
                command.CommandText = "INSERT INTO users (name,password,email,image) VALUES (@nam,@pass, @eml,@img)";
                //command.Parameters.AddWithValue("@id", 2);

                command.Parameters.AddWithValue("@nam", name);
                command.Parameters.AddWithValue("@pass", password);
                command.Parameters.AddWithValue("@eml", email);
                command.Parameters.AddWithValue("@img", "none");

                connection.Open();

                command.ExecuteNonQuery();
                command.CommandText = "select id from users where name=@na and email=@mai and password=@pas";
                command.Parameters.AddWithValue("@na", name);
                command.Parameters.AddWithValue("@pas", password);
                command.Parameters.AddWithValue("@mai", email);
                MySqlDataReader Reader;
                Reader = command.ExecuteReader();
                while (Reader.Read())
                {
                    ID = Reader[0].ToString();
                }
                user.UserName  = name;
                user.Pasword   = password;
                user.UserEmail = email;
                connection.Close();

                MessageBox.Show("User Added Successfully");

                NameTextBox.Text     = "";
                EmailTextBox.Text    = "";
                PasswordTextBox.Text = "";

                userProfileViewModel         = new UserProfileViewModel(User);
                _userProfileView             = new UserProfileView(userProfileViewModel);
                _userProfileView.DataContext = userProfileViewModel;
                _userProfileView.Show();
            }
            catch (Exception)
            {
                MessageBox.Show("DB Error");
            }
        }
        private void LogInClick(object sender, RoutedEventArgs e)
        {
            string email    = EmailTextBox.Text.ToString();
            string password = PasswordTextBox.Text.ToString();


            try
            {
                string          MyConString = "Server=127.0.0.1;Port=3306;Uid=root;Pwd=;Database=tokiohotel;";
                MySqlConnection connection  = new MySqlConnection(MyConString);
                MySqlCommand    command     = connection.CreateCommand();
                MySqlDataReader Reader;
                command.CommandText = "select * from users where email =@uname AND password =@pass";
                command.Parameters.AddWithValue("@uname", email);
                command.Parameters.AddWithValue("@pass", password);

                connection.Open();

                int count = Convert.ToInt32(command.ExecuteScalar());

                if (count > 0)
                {
                    user.UserName = email;
                    user.Pasword  = password;
                    ID            = count.ToString();
                }
                else
                {
                    MessageBox.Show("Email or password is incorrect");
                }
                connection.Close();

                userProfileViewModel         = new UserProfileViewModel(User);
                _userProfileView             = new UserProfileView(userProfileViewModel);
                _userProfileView.DataContext = userProfileViewModel;
                _userProfileView.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("DB Error");
            }
        }