예제 #1
0
        /*Method return customer object by using account number*/
        public Customer_BO giveAccount(int accountNO)
        {
            Administrator_DAL  administrator = new Administrator_DAL();
            List <Customer_BO> list          = administrator.getAccountList();
            Customer_BO        customer      = null;

            foreach (Customer_BO cus in list)
            {
                if (cus.Account_No == accountNO)
                {
                    customer = cus;
                }
            }
            return(customer);
        }
예제 #2
0
        /*method update account of a specific customer*/
        public bool update_BLL(Customer_BO customerPrevious, Customer_BO customerNew)
        {
            bool result = false;
            Administrator_DAL  administrator = new Administrator_DAL();
            List <Customer_BO> list          = administrator.getAccountList();

            foreach (Customer_BO cus in list)
            {
                if (cus.Account_No == customerPrevious.Account_No)
                {
                    if (customerNew.Account_No > 0)
                    {
                        cus.Account_No = customerNew.Account_No;
                    }
                    if (customerNew.userName != "")
                    {
                        cus.userName = customerNew.userName;
                    }
                    if (customerNew.Password != "")
                    {
                        cus.Password = customerNew.Password;
                    }
                    if (customerNew.holderName != "")
                    {
                        cus.holderName = customerNew.holderName;
                    }
                    if (customerNew.Type != "")
                    {
                        cus.Type = customerNew.Type;
                    }
                    if (customerNew.Balance >= 0)
                    {
                        cus.Balance = customerNew.Balance;
                    }
                    if (customerNew.Status != "")
                    {
                        cus.Status = customerNew.Status;
                    }
                    result = true;
                    break;
                }
            }
            administrator.writeFile(list);
            return(result);
        }
예제 #3
0
        /*method Delete Account of a customer specify by the account number*/
        public bool deleteAccount(int accountNO)
        {
            bool result = false;
            Administrator_DAL  administrator = new Administrator_DAL();
            List <Customer_BO> list          = administrator.getAccountList();

            if (list != null)
            {
                foreach (Customer_BO cus in list)
                {
                    if (cus.Account_No == accountNO)
                    {
                        result = list.Remove(cus);
                        break;
                    }
                }
                administrator.writeFile(list);
            }
            return(result);
        }
예제 #4
0
        /*Method return the list of customer accounts according to mini and max amount range*/
        public List <Customer_BO> byAmounts(int min, int max)
        {
            Administrator_DAL  administrator_DAL = new Administrator_DAL();
            List <Customer_BO> list        = administrator_DAL.getAccountList();
            List <Customer_BO> matchedList = new List <Customer_BO>();

            if (list != null)
            {
                foreach (Customer_BO cus in list)
                {
                    if (cus.Balance >= min && cus.Balance <= max)
                    {
                        matchedList.Add(cus);
                    }
                }
            }
            if (list == null)
            {
                matchedList = null;
            }
            return(matchedList);
        }
예제 #5
0
        /*Method use to search accounts according to inputs of Search Menu*/
        public List <Customer_BO> search_BLL(Customer_BO customer)
        {
            Administrator_DAL  administrator = new Administrator_DAL();
            List <Customer_BO> completeList  = administrator.getAccountList();
            List <Customer_BO> listMatched   = administrator.getAccountList();

            if (customer.Account_No > 0)
            {
                foreach (Customer_BO cus in listMatched.ToList())
                {
                    if (cus.Account_No != customer.Account_No)
                    {
                        listMatched.Remove(cus);
                    }
                }
            }
            if (customer.userName != "")
            {
                foreach (Customer_BO cus in listMatched.ToList())
                {
                    if (cus.userName != customer.userName)
                    {
                        listMatched.Remove(cus);
                    }
                }
            }
            if (customer.Password != "")
            {
                foreach (Customer_BO cus in listMatched.ToList())
                {
                    if (cus.Password != customer.Password)
                    {
                        listMatched.Remove(cus);
                    }
                }
            }
            if (customer.holderName != "")
            {
                foreach (Customer_BO cus in listMatched.ToList())
                {
                    if (cus.holderName != customer.holderName)
                    {
                        listMatched.Remove(cus);
                    }
                }
            }
            if (customer.Balance > 0)
            {
                foreach (Customer_BO cus in listMatched.ToList())
                {
                    if (cus.Balance != customer.Balance)
                    {
                        listMatched.Remove(cus);
                    }
                }
            }
            if (customer.Status != "")
            {
                foreach (Customer_BO cus in listMatched.ToList())
                {
                    if (cus.Status != customer.Status)
                    {
                        listMatched.Remove(cus);
                    }
                }
            }
            if (customer.Type != "")
            {
                foreach (Customer_BO cus in listMatched.ToList())
                {
                    if (cus.Type != customer.Type)
                    {
                        listMatched.Remove(cus);
                    }
                }
            }
            if (customer.Account_No < 0 && customer.userName == "" && customer.Password == "" && customer.holderName == "" &&
                customer.Balance < 0 && customer.Status == "" && customer.Type == "")
            {
                listMatched.Clear();
            }
            return(listMatched);
        }