コード例 #1
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);
        }
コード例 #2
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);
        }