Esempio n. 1
0
        public static void RemoveAccount()
        {
            Console.Write("Type the customer's account number: ");
            uint acctnum = 0;

            try
            {
                acctnum = Convert.ToUInt32(Console.ReadLine());
            }
            catch (Exception)
            {
                var originalForeground = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Invalid input.\n");
                Console.ForegroundColor = originalForeground;
            }

            if (HsCustomers.Remove(FindCustomer(acctnum)))
            {
                Console.WriteLine("Customer was successfully removed");
            }
            else
            {
                Console.WriteLine("Customer was not found");
            }
        }
Esempio n. 2
0
 private static bool AddNewCustomer(ref Customer newCustomer)
 {
     if (HsCustomers.Add(newCustomer))
     {
         Console.WriteLine(@"'{0}' added successfully", newCustomer);
     }
     else
     {
         Console.WriteLine("Customer could not be added");
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
        public static Customer FindCustomerByName(string[] cname)
        {
            using (var look = HsCustomers.GetEnumerator())
            {
                while (look.MoveNext())
                {
                    if (look.Current.FirstName != cname[0] && look.Current.LastName != cname[1])
                    {
                        return(look.Current);
                    }
                }
            }
            var originalForeground = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Customer not found. \n{0}");
            Console.ForegroundColor = originalForeground;
            return(null);
        }
Esempio n. 4
0
 private static Customer FindCustomer(uint accountNumber)
 {
     using (var lookup = HsCustomers.GetEnumerator())
     {
         if (lookup.MoveNext() == false)
         {
             return(null);
         }
         do
         {
             if (lookup.Current.CheckingAccountNumber.Equals(accountNumber) ||
                 lookup.Current.SavingsAccountNumber.Equals(accountNumber))
             {
                 return(lookup.Current);
             }
         } while (lookup.MoveNext());
     }
     Console.WriteLine("Customer not found.\n");
     return(null);
 }