private void Button_Update(object sender, RoutedEventArgs e)
        {
            UserService.UserB user = new UserService.UserB();
            user.UserId = userId;
            user.Name   = txt_profileName.Text;

            user.Address = txt_profileAddress.Text;
            user.Phone   = txt_profilePhone.Text;
            if (txt_profileEmail.Text != currentEmail)
            {
                if (!client.CheckEmailIfExists(txt_profileEmail.Text))
                {
                    user.Email = txt_profileEmail.Text;
                }
                else
                {
                    MessageBox.Show("This email already exists!");
                    return;
                }
            }
            else
            {
                user.Email = txt_profileEmail.Text;
            }

            if (txt_profilePassword.Text == txt_profileConfirmPass.Text)
            {
                user.Password = txt_profileConfirmPass.Text;
            }
            else
            {
                MessageBox.Show("Passwords are not match!");
                return;
            }
            int      bankNo     = Int32.Parse(txt_profileBankNumber.Text);
            DateTime expiryDate = Convert.ToDateTime(txt_profileExpiryDate.Text);
            int      CCV        = Int32.Parse(txt_profileCCv.Text);

            if (bankClient.CheckBankAccount(bankNo, expiryDate, CCV))
            {
                user.BankAccountId = GetIdOfTheBankAccount();
            }
            else
            {
                MessageBox.Show("Wrong Bank Account Information!");
                return;
            }

            bool updated = client.UpdateUser(user);

            if (updated)
            {
                MessageBox.Show("Your profile was updated!");
                txt_profileConfirmPass.Text = "";
            }
            else
            {
                MessageBox.Show("Something went wrong!");
            }
        }
        private UserService.UserB CreateNewUser()
        {
            UserService.UserB newOne = new UserService.UserB();



            if (txt_name != null)
            {
                newOne.Name = txt_name.Text;
                name        = txt_name.Text;
            }
            if (txt_pass != null && txt_confPass != null)
            {
                if (txt_pass.Password == txt_confPass.Password)
                {
                    newOne.Password = txt_pass.Password;
                    pas             = txt_pass.Password;
                }
                else
                {
                    MessageBox.Show("The passwords not match!");
                }
            }
            if (txt_email != null)
            {
                email = txt_email.Text;
                if (!client.CheckEmailIfExists(email))
                {
                    newOne.Email = txt_email.Text;
                }
                else
                {
                    MessageBox.Show("This email already exists!");
                }
            }

            if (txt_address != null)
            {
                newOne.Address = txt_address.Text;
                address        = txt_address.Text;
            }
            if (txt_phone != null)
            {
                newOne.Phone = txt_phone.Text;
                phone        = txt_phone.Text;
            }
            bool validAccount = CheckBankAccount();

            if (validAccount == true)
            {
                newOne.BankAccountId = GetIdOfTheBankAccount();
            }
            else
            {
                return(null);
            }
            return(newOne);
        }
Exemplo n.º 3
0
        private string GetUserName(int id)
        {
            UserService.UserClient client = new UserService.UserClient();
            string name = "";

            UserService.UserB user = new UserService.UserB();
            user = client.GetUser(id);
            name = user.Name;
            return(name);
        }
        private void loadAllData()
        {
            UserService.UserB user = new UserService.UserB();
            BankAccountService.BankAccountB account = new BankAccountService.BankAccountB();
            account = bankClient.GetBankAccountById(userBankAccId);
            user    = client.GetUser(userId);
            txt_profileName.Text    = user.Name;
            txt_profileEmail.Text   = user.Email;
            currentEmail            = user.Email;
            txt_profileAddress.Text = user.Address;

            txt_profilePhone.Text = user.Phone;

            txt_profileBankNumber.Text = account.AccountNo.ToString();
            txt_profileCCv.Text        = account.CCV.ToString();
            txt_profileExpiryDate.Text = account.ExpiryDate.ToString();
        }
 private void UserList_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (userList.SelectedItem != null)
     {
         userSelect          = (string)userList.SelectedItem;
         user                = usrClient.GetUserByName(userSelect);
         userId              = user.UserId;
         password            = user.Password;
         txt_Name.Text       = user.Name;
         txt_Email.Text      = user.Email;
         currentEmail        = user.Email;
         txt_Address.Text    = user.Address;
         txt_PhoneNo.Text    = user.Phone.ToString();
         txt_TypeOfUser.Text = user.TypeOfUser.ToString();
         accID               = user.BankAccountId;
     }
 }
        private void Button_Update(object sender, RoutedEventArgs e)
        {
            UserService.UserB user = new UserService.UserB();
            user.Password      = password;
            user.UserId        = userId;
            user.Name          = txt_Name.Text;
            user.BankAccountId = accID;
            user.Address       = txt_Address.Text;
            user.Phone         = txt_PhoneNo.Text;
            user.TypeOfUser    = Int32.Parse(txt_TypeOfUser.Text);
            if (txt_Email.Text != currentEmail)
            {
                if (!usrClient.CheckEmailIfExists(txt_Email.Text))
                {
                    user.Email = txt_Email.Text;
                }
                else
                {
                    MessageBox.Show("This email already exists!");
                    return;
                }
            }
            else
            {
                user.Email = txt_Email.Text;
            }



            bool updated = usrClient.UpdateUser(user);

            if (updated)
            {
                MessageBox.Show("User profile was updated!");
            }
            else
            {
                MessageBox.Show("Something went wrong!");
            }
            userList.Items.Clear();
            loadAllUsers();
        }