Example #1
0
        void InitAccountView()
        {
            var root = m_accountTreeView.Nodes.Add("账号");

            var accounts = AccountBook.GetInstance().GetAll();

            foreach (var account in accounts)
            {
                var text = account.Name;
                text += " (卡号:" + account.Number + ")";
                var node = root.Nodes.Add(text);

                if (m_events.ContainsKey(account.Name))
                {
                    var dates = GetAccountEventsDateList(m_events[account.Name]);
                    if (dates != null && dates.Count > 0)
                    {
                        foreach (var date in dates)
                        {
                            node.Nodes.Add(date);
                        }
                    }
                }
            }
        }
Example #2
0
        // update and save to file
        private void UpdateDB()
        {
            StreamWriter writer = new StreamWriter(m_fileName);

            writer.Write("名称,账号,账号到期日,出账日期,账单最后还款日,信用额度,刷卡手续费率");
            writer.Write("\r\n");
            writer.Flush();

            foreach (var account in AccountBook.GetInstance().GetAll())
            {
                writer.Write(account.Name);
                WriteSpliter(writer);
                writer.Write(account.Number);
                WriteSpliter(writer);
                writer.Write(account.ExpiredDate);
                WriteSpliter(writer);
                writer.Write(account.BillStartDay);
                WriteSpliter(writer);
                writer.Write(account.BillExpiredDay);
                WriteSpliter(writer);
                writer.Write(account.CreditAmount);
                WriteSpliter(writer);
                writer.Write(account.Rate);
                writer.Write("\r\n");
                writer.Flush();
            }

            writer.Close();
        }
Example #3
0
        public void Load()
        {
            if (!File.Exists(m_fileName))
            {
                return;
            }

            StreamReader reader = new StreamReader(m_fileName);

            if (reader == null)
            {
                return;
            }

            reader.ReadLine();
            while (!reader.EndOfStream)
            {
                string   line  = reader.ReadLine();
                string[] items = line.Split(',');

                Account account = new Account();
                account.Name           = items[0];
                account.Number         = items[1];
                account.ExpiredDate    = items[2];
                account.BillStartDay   = int.Parse(items[3]);
                account.BillExpiredDay = int.Parse(items[4]);
                account.CreditAmount   = double.Parse(items[5]);
                account.Rate           = double.Parse(items[6]);

                AccountBook.GetInstance().Add(account);
            }

            reader.Close();
        }
        private void SetCardNumber(int selectedIndex)
        {
            var account = AccountBook.GetInstance().GetAll()[selectedIndex];

            m_cardNumberTxt.Text   = Utility.FormatAccountString(account.Number);
            m_creditAmountTxt.Text = account.CreditAmount.ToString();
            InitBillDruction(account.Name);
        }
Example #5
0
        public static AccountBook GetInstance()
        {
            if (m_instance == null)
            {
                m_instance = new AccountBook();
            }

            return(m_instance);
        }
Example #6
0
        public void RemoveAccount(string account)
        {
            BillBook.GetInstance().Remove(account);
            ResetView();
            m_billDB.Remove(account);

            AccountBook.GetInstance().Remove(account);
            m_accountBD.Remove(account);

            m_fundEventDB.Remove(account);
        }
Example #7
0
        private bool AddAccount(Account newAccount)
        {
            if (AccountBook.GetInstance().Exist(newAccount.Name))
            {
                string msg = "账号\"" + newAccount.Name + "\"已经存在!";
                MessageBox.Show(this, msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }

            m_newAccount = newAccount;
            AccountBook.GetInstance().Add(newAccount);
            return(true);
        }
        private void m_applyBtn_Click(object sender, EventArgs e)
        {
            if (m_accountComb.SelectedIndex == -1)
            {
                MessageBox.Show(this, "请先选择一个信用卡/账号,如果没有请先添加一个!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var name = m_accountComb.SelectedItem.ToString();

            if (string.IsNullOrEmpty(name))
            {
                MessageBox.Show(this, "请先选择一个信用卡/账号,如果没有请先添加一个!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            double billVal = 0.0;

            try
            {
                billVal = double.Parse(m_billAmountTxt.Text.Trim());
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "请输入一个有效的账单金额!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            double avaliable = 0.0;

            try
            {
                avaliable = double.Parse(m_avaliableAmountTxt.Text.Trim());
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "请输入一个有效的可用额度!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // 使用一个新的对象与旧的账单区分开来
            Account account = AccountBook.GetInstance().Find(name);

            m_bill = new AccountBill(account);
            m_bill.LastDateTime    = Utility.GetCurrentDTString();
            m_bill.AvaliableAmount = avaliable;
            m_bill.SetBillAmount(billVal);

            DialogResult = DialogResult.OK;
            this.Close();
        }
Example #9
0
        private void InitAccountStatistics()
        {
            var font = new Font("宋体", 9.5f, FontStyle.Bold);

            creditAmount.DefaultCellStyle.Font      = font;
            creditAmount.DefaultCellStyle.ForeColor = Color.Green;
            creditAmount.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
            rateColumn.DefaultCellStyle.Alignment   = DataGridViewContentAlignment.MiddleRight;

            foreach (var account in AccountBook.GetInstance().GetAll())
            {
                AddAccountToView(account);
            }
        }
        private void InitAccountList()
        {
            if (AccountBook.GetInstance().Count == 0)
            {
                return;
            }

            m_accountComb.Items.Clear();
            m_accountComb.Items.AddRange(AccountBook.GetInstance().GetAllAccountName().ToArray());

            if (m_accountComb.Items.Count > 0)
            {
                m_accountComb.SelectedIndex = 0;
                SetCardNumber(0);
            }
        }
Example #11
0
        public void Clear()
        {
            // history
            m_billDB.Clear();
            m_accountBD.Clear();
            m_fundEventDB.Clear();
            var historyDB = new HistoryBillDB();

            historyDB.Clear();

            // cache
            AccountBook.GetInstance().Clear();
            BillBook.GetInstance().Clear();

            ResetView();
        }
        private void m_avaliableAmountTxt_TextChanged(object sender, EventArgs e)
        {
            m_avaliableAmountTxt.Text = Utility.FormatDoubleString(Utility.ConvertToOrigin(m_avaliableAmountTxt.Text.Trim()));
            Utility.SetSelectToLastest(m_avaliableAmountTxt);

            var    account = AccountBook.GetInstance().GetAll()[m_accountComb.SelectedIndex];
            string origin  = Utility.ConvertToOrigin(m_avaliableAmountTxt.Text);

            if (origin.Length == 0)
            {
                m_billAmountTxt.Text = "0.0";
            }
            else
            {
                m_billAmountTxt.Text = Utility.ConvertDouble(account.CreditAmount - double.Parse(origin));
            }
        }
Example #13
0
        public void Load()
        {
            if (!File.Exists(m_fileName))
            {
                return;
            }

            StreamReader reader = new StreamReader(m_fileName);

            if (reader == null)
            {
                return;
            }

            reader.ReadLine();
            while (!reader.EndOfStream)
            {
                string   line  = reader.ReadLine();
                string[] items = line.Split(',');

                // bind account
                string      accountName = items[0];
                Account     account     = AccountBook.GetInstance().Find(accountName);
                AccountBill bill        = new AccountBill(account);

                bill.LastBillStart   = DateTime.Parse(items[2]);
                bill.LastBillEnd     = DateTime.Parse(items[3]);
                bill.AvaliableAmount = double.Parse(items[4]);
                bill.BillAmount      = double.Parse(items[5]);
                bill.RepayAmount     = double.Parse(items[6]);
                bill.NoRepayAmount   = double.Parse(items[7]);
                bill.SwingAmount     = double.Parse(items[8]);
                bill.BillSetDate     = items[9];
                bill.LastDateTime    = items[10];
                bill.Charge          = double.Parse(items[11]);

                BillBook.GetInstance().Add(bill);
            }

            reader.Close();
        }
Example #14
0
 void LoadAccountEvents()
 {
     m_events = m_fundEventDB.Load(AccountBook.GetInstance().GetAllAccountName());
 }
Example #15
0
        private Account GetAccountInView(int rowIndex)
        {
            string accountName = m_accountListDGV.Rows[rowIndex].Cells[0].Value.ToString();

            return(AccountBook.GetInstance().Find(accountName));
        }