示例#1
0
 public void Delete(int accountNo)
 {
     using (AccountEntities db = new AccountEntities())
     {
         if (db.accounts.Any(a => a.account == accountNo))
         {
             accounts account = db.accounts.First(a => a.account == accountNo);
             db.accounts.Remove(account);
             db.SaveChanges();
         }
         else
         {
             throw new ArgumentException();
         }
     }
 }
示例#2
0
 public void Create(int accountNo)
 {
     using (AccountEntities db = new AccountEntities())
     {
         if (!db.accounts.Any(a => a.account == accountNo))
         {
             accounts account = new accounts {
                 account = accountNo, balance = 0
             };
             db.accounts.Add(account);
             db.SaveChanges();
         }
         else
         {
             throw new ArgumentException();
         }
     }
 }
示例#3
0
 public void Change(int accountNo, decimal sum)
 {
     using (AccountEntities db = new AccountEntities())
     {
         if (db.accounts.Any(a => a.account == accountNo))
         {
             accounts     account     = db.accounts.First(a => a.account == accountNo);
             transactions transaction = new transactions {
                 accounts = account, transAmount = sum, transDate = DateTime.Now
             };
             db.transactions.Add(transaction);
             db.SaveChanges();
         }
         else
         {
             throw new ArgumentException();
         }
     }
 }