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 bool CheckBankAccount() { if (txt_accountNo.Text == "" || txt_CCV.Text == "" || txt_expiryDate.Text == "") { MessageBox.Show("Fill all the bank account fields!"); return(false); } bool validAccount = false; int bankNo = 0; DateTime expiryDate = new DateTime(2019, 10, 9); int CCV = 0; BankAccountService.BankAccountServiceClient bankClient = new BankAccountService.BankAccountServiceClient(); if (txt_accountNo != null) { try { bankNo = Int32.Parse(txt_accountNo.Text); } catch (Exception) { MessageBox.Show("Please provide number only"); return(false); } } if (txt_expiryDate != null) { try { expiryDate = Convert.ToDateTime(txt_expiryDate.Text); } catch (Exception) { MessageBox.Show("Please insert date like this yyyy-mm-yy!"); return(false); } } if (txt_CCV != null) { try { CCV = Int32.Parse(txt_CCV.Text); } catch (Exception) { MessageBox.Show("Please insert only numbers like this 111!"); return(false); } } validAccount = bankClient.CheckBankAccount(bankNo, expiryDate, CCV); if (validAccount != true) { MessageBox.Show("There is no bank account with this information!"); } return(validAccount); }