Пример #1
0
        public void Deposit(string accountNo, decimal money)
        {
            IAccountData objAccountData = null;

            try
            {
                objAccountData = Builder.AccountData();
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    System.Data.DataSet ds = objAccountData.GetAccount(accountNo);
                    if (ds.Tables[0].Rows.Count == 0)
                    {
                        throw new Exception("Account not found.");
                    }
                    money = (ds.Tables[0].Rows[0]["Balance"] == DBNull.Value) ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[0]["Balance"]) + money;
                    if (!objAccountData.UpdateAccount(accountNo, money))
                    {
                        throw new Exception("Error: Can not update data.");
                    }
                    scope.Complete();
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                if (objAccountData != null)
                {
                    objAccountData.Dispose();
                }
            }
        }
Пример #2
0
 public bool UpdateAccount(string accountNo, decimal balance)
 {
     try
     {
         using (IAccountData accountData = Builder.AccountData())
         {
             return(accountData.UpdateAccount(accountNo, balance));
         }
     }
     catch (Exception ex)
     {
         throw new BSLException("UpdateAccount event occurs an error.[" + ex.Message + "]", ex, true);
     }
 }