private int GetIdOfTheBankAccount() { BankAccountService.BankAccountServiceClient bankClient = new BankAccountService.BankAccountServiceClient(); BankAccountService.BankAccountB bankOb = new BankAccountService.BankAccountB(); int bankNo = Int32.Parse(txt_profileBankNumber.Text); bankOb = bankClient.GetBankAccount(bankNo); int accId = bankOb.AccountId; return(accId); }
private void btn_createProfile(object sender, RoutedEventArgs e) { if (txt_name.Text == "" || txt_pass.Password == "" || txt_confPass.Password == "" || txt_address.Text == "" || txt_email.Text == "" || txt_phone.Text == "") { MessageBox.Show("Fill all the profiles fields!"); return; } var newUser = CreateNewUser(); if (newUser == null) { return; } BankAccountService.BankAccountB bank = new BankAccountService.BankAccountB(); BankAccountService.BankAccountServiceClient accountClient = new BankAccountService.BankAccountServiceClient(); client.CreateUser(newUser); int idOfUser = client.GetUserIDByName(newUser.Name); /* userInfo[0] = newUser.UserId.ToString(); * userInfo[1] = newUser.BankAccountId.ToString(); * MessageBox.Show(userInfo[1]); * userInfo[2] = newUser.TypeOfUser.ToString();*/ string userIdS = idOfUser.ToString(); userInfo[0] = userIdS; string userBankAccIdS = "" + newUser.BankAccountId; userInfo[1] = userBankAccIdS; string userTypeS = newUser.TypeOfUser.ToString(); userInfo[2] = userTypeS; this.Content = null; MainPage main = new MainPage(userInfo); NavigationService.Navigate(main); main.btn_logOut.Visibility = Visibility.Visible; main.btn_log.Visibility = Visibility.Visible; main.btn_profile.Visibility = Visibility.Visible; }
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); }
private void btn_donateClick(object sender, RoutedEventArgs e) { if (disSelect == "") { MessageBox.Show("You have to choose specific disaster!"); return; } if (txt_amount.Text == "") { MessageBox.Show("You have to insert the amount for donation!"); return; } if (usernId == 0) { MessageBox.Show("You have to log in before donation!"); return; } decimal amount = 0; amount = decimal.Parse(txt_amount.Text); if (amount > userAcc.Amount) { MessageBox.Show("You don't haave enough money. Change the amount!"); return; } //bool donate=bankClient.donateToSpecificDisaster(amount, userAcc, disasterAcc); BankAccountService.BankAccountServiceClient bankCliente = new BankAccountService.BankAccountServiceClient(); userAcc.Amount = userAcc.Amount - amount; bool updatedUserAcc = bankCliente.Update(userAcc); if (!updatedUserAcc) { MessageBox.Show("Failed donation!It can not update user account! Your page will be refreshed!"); this.Content = null; DisasterPage refreshPage = new DisasterPage(userInfoData); NavigationService.Navigate(refreshPage); return; } userAcc = bankCliente.GetBankAccountById(userBankAccId); disasterAcc.Amount = disasterAcc.Amount + amount; bool updatedDisasterAcc = bankCliente.Update(disasterAcc); if (!updatedDisasterAcc) { MessageBox.Show("Failed donation!It can not update disaster account! Your page will be refreshed!"); this.Content = null; DisasterPage refreshPage = new DisasterPage(userInfoData); NavigationService.Navigate(refreshPage); return; } disasterAcc = bankCliente.GetBankAccountById(disasterAcc.AccountId); if (updatedDisasterAcc == true && updatedUserAcc == true) { MessageBox.Show("Donation is succesful!"); } txt_amount.Text = ""; }