Beispiel #1
0
        public Account OpenAccount(string id, string pwd, double money, double credit)
        {
            CreditAccount account = new CreditAccount(id, pwd, money, credit);

            accounts.Add(account);
            return(account);
        }
Beispiel #2
0
        // constructor for credit account
        public Account OpenAccount(string id, string pwd, double limit)
        {
            Account account = new CreditAccount(id, pwd, limit);

            _accounts.Add(account);

            return(account);
        }
Beispiel #3
0
Datei: Bank.cs Projekt: q2git/VS
        public Account OpenAccount(double credit, string id, string pwd)
        {
            CreditAccount account = new CreditAccount(id, pwd, credit);

            accounts.Add(account);
            UpdateAccount(account);

            return(account);
        }
Beispiel #4
0
        /// <summary>
        /// 将普通账户升级为信用卡账户
        /// </summary>
        /// <param name="id">账户id</param>
        /// <param name="credit">信用额度</param>
        /// <returns>是否成功</returns>
        public bool changeToCreditAccount(string id, decimal credit)
        {
            Account acc = this[id];

            if (acc == null || acc is CreditAccount)
            {
                return(false);                         //账户不存在或已经是信用卡账户,无需升级
            }
            this[id] = new CreditAccount(acc, credit); //升级并更新原账户
            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// 提升信用额度
        /// </summary>
        /// <param name="credit">提升至额度,应比当前额度高</param>
        /// <returns></returns>
        public decimal CreditUpTo(decimal credit)
        {
            if (!(account is CreditAccount))
            {
                return(0);
            }
            CreditAccount cAcc     = account as CreditAccount;
            decimal       upCredit = credit - cAcc.Credit;

            upCredit = upCredit > 0 ? upCredit : 0;
            cAcc.CreditUp(upCredit);
            return(upCredit);
        }
Beispiel #6
0
        private void ShowMoney()
        {
            Account acc = atm.GetAccount();

            lblMoney.Text = "账户余额:" + acc.Money + "元";
            if (acc is CreditAccount)
            {
                CreditAccount cAcc = acc as CreditAccount;
                lblCredit.Text        = $"信用总额度:{cAcc.Credit}元\r\n已透支取款:{cAcc.UsedCredit}元";
                btnCreditOpen.Visible = false;
                lblCredit.Visible     = true;
                btnCreditUp.Visible   = true;
            }
            else
            {
                lblCredit.Visible     = false;
                btnCreditUp.Visible   = false;
                btnCreditOpen.Visible = true;
            }
        }