Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 4
0
 public AccountEntity[] SearchAccountAndBalance(string accountNo, string balance)
 {
     try
     {
         using (IAccountData accountData = Builder.AccountData())
         {
             return(this.ConvertDataTableToEntities(accountData.ListAccount(accountNo, balance).Tables[0]));
         }
     }
     catch (Exception ex)
     {
         throw new BSLException("SearchAccountAndBalance event occurs an error.[" + ex.Message + "]", ex, true);
     }
 }
Ejemplo n.º 5
0
 public bool CheckAccount(string accountNo)
 {
     try
     {
         using (IAccountData accountData = Builder.AccountData())
         {
             return(accountData.CheckAccount(accountNo));
         }
     }
     catch (Exception ex)
     {
         throw new BSLException("CheckAccount event occurs an error.[" + ex.Message + "]", ex, true);
     }
 }
Ejemplo n.º 6
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);
     }
 }
Ejemplo n.º 7
0
 public AccountEntity[] Search(string search)
 {
     try
     {
         using (IAccountData accountData = Builder.AccountData())
         {
             Entities.AccountEntity ac = new AccountEntity();
             ac.Equals("");
             return(this.ConvertDataTableToEntities(accountData.ListAccount(search).Tables[0]));
         }
     }
     catch (Exception ex)
     {
         throw new BSLException("Search event occurs an error.[" + ex.Message + "]", ex, true);
     }
 }
Ejemplo n.º 8
0
        public bool AddAccount(string accountNo, decimal balance)
        {
            try
            {
                // Validation Exist AccountNo
                if (CheckAccount(accountNo))
                {
                    return(false);
                }

                using (IAccountData accountData = Builder.AccountData())
                {
                    return(accountData.AddAccount(accountNo, balance));
                }
            }
            catch (Exception ex)
            {
                throw new BSLException("AddAccount event occurs an error.[" + ex.Message + "]", ex, true);
            }
        }
Ejemplo n.º 9
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();
                }
            }
        }
Ejemplo n.º 10
0
 public AccountEntity[] SearchAccount(string accountNo)
 {
     try
     {
         using (IAccountData objAccountData = Builder.AccountData())
         {
             //objAccountData.AddAccount(accountNo);
             //objAccountData.ListAccount(accountNo);
             //objAccountData = Builder.AccountData();
             Entities.AccountEntity ac = new AccountEntity();
             ac.Equals("");
             return(this.ConvertDataTableToEntities(objAccountData.ListAccount(accountNo).Tables[0]));
         }
     }
     catch (Exception ex)
     {
         throw new BSLException("SearchAccount event occurs an error.[" + ex.Message + "]", ex, true);
     }
     finally
     {
         //if (objAccountData != null) objAccountData.Dispose();
     }
 }