public void RutTien()
        {
            Console.WriteLine("Nhập số tiền cần rút: ");
            decimal amount = Utility.GetUnsignedDecimalNumber();

            // lấy thông tin tài khoản mới nhất trước khi kiểm tra số dư.
            MainThread.currentLoggedInAccount = model.GetAccountByUsername(MainThread.currentLoggedInAccount.UserName);
            if (amount > MainThread.currentLoggedInAccount.Balance)
            {
                Console.WriteLine("Không đủ tiền trong tài khoản.");
                return;
            }
            Console.WriteLine("Nhập nội dung giao dịch: ");
            var content            = Console.ReadLine();
            var transactionHistory = new TransactionHistory()
            {
                Id                    = Guid.NewGuid().ToString(),
                Type                  = TransactionHistory.TransactionType.WITHDRAW,
                Amount                = amount,
                Content               = content,
                SenderAccountNumber   = MainThread.currentLoggedInAccount.AccountNumber,
                ReceiverAccountNumber = MainThread.currentLoggedInAccount.AccountNumber
            };

            if (model.UpdateBalance(MainThread.currentLoggedInAccount, transactionHistory))
            {
                Console.WriteLine("Giao dịch thành công.");
            }
        }
Beispiel #2
0
        public void Withdrawal()
        {
            if (Program.CurrentLoggedInAccount != null)
            {
                Console.Clear();
                Console.WriteLine("===== Withdrawal on SHB =====");
                Console.WriteLine("Enter your amount: ");
                var amount = double.Parse(Console.ReadLine());
                if (amount <= 0)
                {
                    Console.WriteLine("Your amount is unavaiable. Please try again");
                    return;
                }

                var transaction = new SHBTransaction
                {
                    TransactionId     = Guid.NewGuid().ToString(),
                    SenderAccountId   = Program.CurrentLoggedInAccount.AccountNumber,
                    ReceiverAccountId = Program.CurrentLoggedInAccount.AccountNumber,
                    Type         = 1,
                    Message      = "Withdrawal completed: " + amount,
                    Amount       = amount,
                    CreatedAtMLS = DateTime.Now.Ticks,
                    UpdatedAtMLS = DateTime.Now.Ticks,
                    Status       = 1
                };
                bool result = shbAccountModel.UpdateBalance(Program.CurrentLoggedInAccount, transaction);
            }
            else
            {
                Console.WriteLine("Please login your account to use this function.");
            }
        }
Beispiel #3
0
        public void RutTien()
        {
            if (Program.currentLoggedInAccount != null)
            {
                Console.Clear();
                Console.WriteLine("Tiến hành rút tiền tại hệ thống SHB.");
                Console.WriteLine("Vui lòng nhập số tiền cần rút.");
                var amount = double.Parse(Console.ReadLine());
                if (amount <= 0)
                {
                    Console.WriteLine("Số lượng không hợp lệ, vui lòng thử lại.");
                    return;
                }

                var transaction = new SHBTransaction
                {
                    TransactionId         = Guid.NewGuid().ToString(),
                    SenderAccountNumber   = Program.currentLoggedInAccount.AccountNumber,
                    ReceiverAccountNumber = Program.currentLoggedInAccount.AccountNumber,
                    Type         = 1,
                    Message      = "Tiến hành rút tiền tại ATM với số tiền: " + amount,
                    Amount       = amount,
                    CreatedAtMLS = DateTime.Now.Ticks,
                    UpdatedAtMLS = DateTime.Now.Ticks,
                    Status       = 1
                };
                bool result = shbAccountModel.UpdateBalance(Program.currentLoggedInAccount, transaction);
            }
            else
            {
                Console.WriteLine("Vui lòng đăng nhập để sử dụng chức năng này.");
            }
        }
Beispiel #4
0
        public void Withdraw()
        {
            if (Program.currentLoggedInAccount != null)
            {
                Console.Clear();
                Console.WriteLine("Withdraw money at the banking system SHB.");
                Console.WriteLine("Please enter the amount to withdraw: ");
                var amount = double.Parse(Console.ReadLine());

                if (amount > Program.currentLoggedInAccount.Balance)
                {
                    Console.WriteLine("Invalid amount, please check again.");
                    return;
                }

                var transaction = new SHBTransaction
                {
                    TransactionId         = Guid.NewGuid().ToString(),
                    SenderAccountNumber   = Program.currentLoggedInAccount.AccountNumber,
                    ReceiverAccountNumber = Program.currentLoggedInAccount.AccountNumber,
                    Type        = SHBTransaction.TransactionType.WITHDRAW,
                    Amount      = amount,
                    Message     = "withdraw money at ATM SHB with money: " + amount,
                    CreateAtMLS = DateTime.Now.Ticks,
                    UpdateAtMLS = DateTime.Now.Ticks,
                    Status      = SHBTransaction.TransactionStatus.DONE
                };
                if (shbAccountModel.UpdateBalance(Program.currentLoggedInAccount, transaction))
                {
                    Console.WriteLine("Successful transaction.");
                }
//                bool result = shbAccountModel.UpdateBalance(Program.currentLoggedInAccount, transaction);
            }
            else
            {
                Console.WriteLine("Please login to use this function.");
            }
        }