Example #1
0
        public IActionResult WithdrawAmount(Transaction transaction)
        {
            try
            {
                var checkTransaction = _context.Customers.FromSqlRaw("EXEC PROC_WITHDRAW @CUSTOMERID={0},@AMOUNT={1}", transaction.CustomerId, transaction.Amount).ToListAsync().Result.FirstOrDefault();

                if (checkTransaction.Name == "InsufficientFunds")
                {
                    return(Ok("Insufficient Funds..... Please withdraw valid amount."));
                }
                else
                {
                    Customer cus = _context.Customers.Include(x => x.Accounts)
                                   .ThenInclude(x => x.AccountBalances)
                                   .Where(x => x.CustomerId == transaction.CustomerId).FirstOrDefault();
                    BalanceDetails balance = new BalanceDetails();
                    balance.CustomerId = cus.CustomerId;
                    var Account = cus.Accounts.Where(x => x.CustomerId == balance.CustomerId).FirstOrDefault();
                    balance.AccountId = Account.AccountId;
                    balance.Name      = cus.Name;
                    var AccountNumber = cus.Accounts.Where(x => x.AccountId == balance.AccountId).FirstOrDefault();
                    balance.AccountNumber = AccountNumber.AccountNumber;
                    var balanceDetails = Account.AccountBalances.Where(x => x.AccountId == balance.AccountId).FirstOrDefault();
                    balance.Balance = balanceDetails.Balance;
                    return(Ok(balance));
                }
            }
            catch (Exception)
            {
                return(Ok("Error occured while doing withdraw."));
            }
        }
Example #2
0
        public IActionResult DepositAmount(Transaction transaction)
        {
            try
            {
                _context.Customers.FromSqlRaw("EXEC PROC_DEPOSIT @CUSTOMERID={0},@AMOUNT={1}", transaction.CustomerId, transaction.Amount).ToListAsync().Result.FirstOrDefault();

                Customer cus = _context.Customers.Include(x => x.Accounts)
                               .ThenInclude(x => x.AccountBalances)
                               .Where(x => x.CustomerId == transaction.CustomerId).FirstOrDefault();

                BalanceDetails balance = new BalanceDetails();
                balance.CustomerId = cus.CustomerId;
                var Account = cus.Accounts.Where(x => x.CustomerId == balance.CustomerId).FirstOrDefault();
                balance.AccountId = Account.AccountId;
                balance.Name      = cus.Name;
                var AccountNumber = cus.Accounts.Where(x => x.AccountId == balance.AccountId).FirstOrDefault();
                balance.AccountNumber = AccountNumber.AccountNumber;
                var balanceDetails = Account.AccountBalances.Where(x => x.AccountId == balance.AccountId).FirstOrDefault();
                balance.Balance = balanceDetails.Balance;

                return(Ok(balance));
            }
            catch (Exception)
            {
                return(Ok("Error occured while doing Deposit."));
            }
        }
Example #3
0
        /// <summary>
        /// 执行查询命令
        /// </summary>
        protected override void ExecuteQueryCommand()
        {
            IsLoadingList = IsBusy = true;
            BalanceDetails.Clear();

            Action action = () => CommunicateManager.Invoke <IAccountService>(service =>
            {
                var result = service.GetScoreAccountDetails(StartTime, EndTime, (CurrentPageIndex - 1) * PageSize, PageSize, OutTradeNo);
                DispatcherHelper.UIDispatcher.Invoke(new Action(() =>
                {
                    TotalCount = result.TotalCount;
                }));

                if (result.List == null)
                {
                    return;
                }
                foreach (var item in result.List)
                {
                    DispatcherHelper.UIDispatcher.Invoke(new Action <BalanceDetailDto>(BalanceDetails.Add), item);
                }
            }, UIManager.ShowErr);

            Task.Factory.StartNew(action).ContinueWith(task =>
            {
                Action setBusyAction = () => { IsLoadingList = IsBusy = false; };
                DispatcherHelper.UIDispatcher.Invoke(setBusyAction);
            });
        }
Example #4
0
    public static string updateDetails(BalanceDetails detail)
    {
        string config =
            Convert.ToString(ConfigurationManager.ConnectionStrings["dbcon"]);

        List <BalanceDetails> BalanceDetails = new List <BalanceDetails>();

        SqlConnection con = new SqlConnection(config);

        con.Open();

        SqlCommand cmd =
            new SqlCommand("update HR_Employees_Vacation_Balance set Annual_Balance = @Annual_Balance, Casual_Balance= @Casual_Balance, Q1= @Q1, Q2= @Q2, Q3= @Q3, Q4= @Q4, Old_Balance= @Old_Balance, Old_Balance_ExpirationDate= @Old_Balance_ExpirationDate where id = @id;",
                           con);

        cmd.Parameters.AddWithValue("@Annual_Balance", detail.Annual_Balance);
        cmd.Parameters.AddWithValue("@Casual_Balance", detail.Casual_Balance);
        cmd.Parameters.AddWithValue("@Q1", detail.Q1);
        cmd.Parameters.AddWithValue("@Q2", detail.Q2);
        cmd.Parameters.AddWithValue("@Q3", detail.Q3);
        cmd.Parameters.AddWithValue("@Q4", detail.Q4);
        cmd.Parameters.AddWithValue("@Old_Balance", detail.Old_Balance);
        cmd
        .Parameters
        .AddWithValue("@Old_Balance_ExpirationDate",
                      detail.Old_Balance_ExpirationDate);
        cmd.Parameters.AddWithValue("@id", detail.id);

        cmd.ExecuteNonQuery();

        con.Close();

        return(JsonConvert.SerializeObject(BalanceDetails));
    }
Example #5
0
        private void currentBalance_MouseHover(object sender, EventArgs e)
        {
            balanceDetails          = new BalanceDetails(this, starting, income, expense, apartment.getBalance());
            balanceDetails.Location = this.PointToClient(MousePosition);

            // balanceDetails.

            this.Controls.Add(balanceDetails);
            balanceDetails.BringToFront();
        }
        /// <summary>
        /// Get balances of all the currency pair of an account id
        /// </summary>
        /// <param name="accountId"></param>
        /// <returns></returns>
        public List <BalanceDetails> GetBalances(AccountId accountId)
        {
            List <BalanceDetails> balanceDetails = new List <BalanceDetails>();
            List <Balance>        balances       = _balanceRepository.GetAllCurrienceBalances(accountId);

            for (int i = 0; i < balances.Count; i++)
            {
                BalanceDetails details = new BalanceDetails(balances[i].Currency.Name, balances[i].AvailableBalance);
                balanceDetails.Add(details);
            }
            return(balanceDetails);
        }
Example #7
0
        /// <summary>
        /// 执行查询命令
        /// </summary>
        protected override void ExecuteQueryCommand()
        {
            //if (StartTime == null)
            //{
            //    UIManager.ShowMessage("请选择开始时间");
            //    return;
            //}
            //if (EndTime == null)
            //{
            //    UIManager.ShowMessage("请选择结束时间");
            //    return;
            //}

            //TimeSpan ts = EndTime.Value - StartTime.Value;
            //if (ts.Days > 92)
            //{
            //    UIManager.ShowMessage("导出的日期间隔最大为3个月时间");
            //    return;
            //}

            _isQueryList = IsBusy = true;
            BalanceDetails.Clear();

            Action action = () => CommunicateManager.Invoke <IAccountService>(service =>
            {
                var result = service.GetReadyAccountDetails(StartTime, EndTime, OutTradeNo, null, (CurrentPageIndex - 1) * PageSize, PageSize);
                DispatcherHelper.UIDispatcher.Invoke(new Action(() =>
                {
                    TotalCount = result.TotalCount;
                }));

                if (result.List == null)
                {
                    return;
                }
                foreach (var item in result.List)
                {
                    DispatcherHelper.UIDispatcher.Invoke(new Action <BalanceDetailDto>(BalanceDetails.Add), item);
                }
            }, UIManager.ShowErr);

            Task.Factory.StartNew(action).ContinueWith(task =>
            {
                Action setBusyAction = () => { _isQueryList = IsBusy = false; };
                DispatcherHelper.UIDispatcher.Invoke(setBusyAction);
            });
        }