private void GetAccountInfo(int accountId)
 {
     BankAccountService.BankAccountB bankAccount = new BankAccountService.BankAccountB();
     bankAccount = bankClient.GetBankAccount(accountId);
     disAccNo    = bankAccount.AccountNo;
     disAccDate  = bankAccount.ExpiryDate;
     disAccCCV   = bankAccount.CCV;
 }
        private void Button_Finish(object sender, RoutedEventArgs e)
        {
            if (usernId == 0)
            {
                MessageBox.Show("You have to log in before manage order!");
                return;
            }
            if (orderLinesToOrder.Count == 0)
            {
                MessageBox.Show("You have to add products to order before finish it!");
                return;
            }

            BankAccountService.BankAccountB bank = new BankAccountService.BankAccountB();
            bank = bankClient.GetBankAccountById(userBankAccId);

            if (totalPrice > bank.Amount)
            {
                MessageBox.Show("Your balance is less than the total price, you have to remove some order lines!");
                return;
            }

            OrderService.Order order = new OrderService.Order();
            order.OrderDate = DateTime.Now;
            order.UserId    = usernId;

            int orderId = orderClient.CreateOrderAndReturnId(order);

            foreach (OrderLineService.OrderLine line in orderLinesToOrder)
            {
                line.OrderID = orderId;
                orderLineClient.UpdateOrderLine(line);
            }

            bool pay = true;

            pay = bankClient.donateMoneyToAllDisasters(totalPrice, userBankAccId);

            if (pay)
            {
                MessageBox.Show("Your order was paid!");
            }

            MessageBox.Show("Your order was finished!");

            listBox.SelectedItem            = null;
            listBox_OrderLines.SelectedItem = null;
            listBox_OrderLines.Items.Clear();
            orderLinesToOrder = null;
            this.Content      = null;
            ShopPage refreshPage = new ShopPage(userInfoData);

            NavigationService.Navigate(refreshPage);
        }
        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);
        }
        public DisasterPage(int[] userInfo) : this()
        {
            usernId       = userInfo[0];
            userBankAccId = userInfo[1];
            userType      = userInfo[2];

            userInfoData[0] = userInfo[0];
            userInfoData[1] = userInfo[1];
            userInfoData[2] = userInfo[2];
            if (userBankAccId != 0)
            {
                userAcc = bankClient.GetBankAccountById(userBankAccId);
            }
        }
        private void ListBox_allDis_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (listBox_allDis.SelectedItem != null)
            {
                disSelect            = (string)listBox_allDis.SelectedItem;
                d                    = disClient.GetDisasterByName(disSelect);
                txt_description.Text = d.Description;
                txt_category.Text    = d.CategoryId.ToString();
                txt_priority.Text    = d.Priority.ToString();
                txt_region.Text      = d.Region;
                txt_victims.Text     = d.Victims.ToString();

                disasterAcc = bankClient.GetBankAccountById(d.DisasterBankAccountId);
            }
        }
        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 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 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 = "";
        }