コード例 #1
0
 public int WithdrawingAmount(int AccNum, int Amount)
 {
     try
     {
         BankDatabaseEntities bankDatabaseEntities = new BankDatabaseEntities();
         int    bal     = bankDatabaseEntities.AccountDetails.Find(AccNum).Balance;
         String AccType = bankDatabaseEntities.AccountDetails.Find(AccNum).AccountType;
         AccType = AccType.Trim();
         if (AccType == "Current")
         {
             if (bal - Amount >= 0)
             {
                 bal = bal - Amount;
             }
             else
             {
                 return(-10000);
             }
         }
         else if (AccType == "Savings")
         {
             if (bal - Amount >= 1000)
             {
                 bal = bal - Amount;
             }
             else
             {
                 return(-10000);
             }
         }
         else
         {
             if (bal - Amount >= -1000)
             {
                 bal = bal - Amount;
             }
             else
             {
                 return(-10000);
             }
         }
         bankDatabaseEntities.AccountDetails.Find(AccNum).Balance = bal;
         bankDatabaseEntities.SaveChanges();
         return(bal);
     }
     catch (Exception e)
     {
         return(-10001);
     }
 }
コード例 #2
0
 public int DepositingAmount(int AccNum, int Amount)
 {
     try
     {
         BankDatabaseEntities bankDatabaseEntities = new BankDatabaseEntities();
         int bal = bankDatabaseEntities.AccountDetails.Find(AccNum).Balance;
         bal = bal + Amount;
         bankDatabaseEntities.AccountDetails.Find(AccNum).Balance = bal;
         bankDatabaseEntities.SaveChanges();
         return(bal);
     }
     catch (Exception e)
     {
         return(-10001);
     }
 }
コード例 #3
0
 public int AddingAccount(BankEntities FieldsObject)
 {
     try
     {
         BankDatabaseEntities bankDatabaseEntities = new BankDatabaseEntities();
         AccountDetail        accountDetail        = new AccountDetail();
         accountDetail.AccountNumber = FieldsObject.AccountNumber;
         accountDetail.Balance       = FieldsObject.AccountBalance;
         accountDetail.BranchName    = FieldsObject.BranchName;
         accountDetail.AccountType   = FieldsObject.AccountType;
         bankDatabaseEntities.AccountDetails.Add(accountDetail);
         bankDatabaseEntities.SaveChanges();
         return(1);
     }
     catch (Exception e)
     {
         //Console.WriteLine(e.Message);
         return(-10000);
     }
 }