예제 #1
0
        public void OpenNewAccount(string accountNo)
        {
            IAccountData objAccountData = null;

            try
            {
                objAccountData = Builder.AccountData();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    if (objAccountData.CheckAccount(accountNo))
                    {
                        throw new Exception("Already account.");
                    }
                    if (!objAccountData.AddAccount(accountNo, 0))
                    {
                        throw new Exception("Error: Can not add data");
                    }
                    scope.Complete();
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                if (objAccountData != null)
                {
                    objAccountData.Dispose();
                }
            }
        }
예제 #2
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();
                }
            }
        }
예제 #3
0
        public void CloseAccount(string accountNo)
        {
            IAccountData objAccountData = null;

            try
            {
                objAccountData = Builder.AccountData();
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    if (!objAccountData.CheckAccount(accountNo))
                    {
                        throw new Exception("Account not found.");
                    }
                    if (!objAccountData.DeleteAccount(accountNo))
                    {
                        throw new Exception("Error: Can not delete data.");
                    }
                    scope.Complete();
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                if (objAccountData != null)
                {
                    objAccountData.Dispose();
                }
            }
        }
예제 #4
0
        public AccountEntity LoadAccount(string accountNo)
        {
            IAccountData objAccountData = null;

            try
            {
                objAccountData = Builder.AccountData();
                return(this.ConvertDataRowToEntity(objAccountData.GetAccount(accountNo).Tables[0].Rows[0]));
            }
            catch
            {
                throw;
            }
            finally
            {
                if (objAccountData != null)
                {
                    objAccountData.Dispose();
                }
            }
        }