Ejemplo n.º 1
0
        private void SetAcountBillAmount(AccountBill bill, DataGridViewRow row)
        {
            row.Cells[1].Value = Utility.FormatDateString(bill.LastBillStart) + " - " + Utility.FormatDateString(bill.LastBillEnd);
            row.Cells[2].Value = Utility.ConvertDouble(bill.Account.CreditAmount);
            row.Cells[3].Value = Utility.ConvertDouble(bill.AvaliableAmount);
            row.Cells[4].Value = Utility.ConvertDouble(bill.BillAmount);
            row.Cells[5].Value = Utility.ConvertDouble(bill.RepayAmount);
            row.Cells[6].Value = Utility.ConvertDouble(bill.NoRepayAmount);
            row.Cells[7].Value = Utility.ConvertDouble(bill.SwingAmount);
            row.Cells[8].Value = bill.Charge.ToString();

            // 已还清
            if (bill.isRepayAll)
            {
                row.Cells[9].Value           = "本期已还清";
                row.Cells[9].Style.ForeColor = Color.Green;
            }
            else
            {
                row.Cells[9].Value           = "本期尚未还清";
                row.Cells[9].Style.ForeColor = Color.Red;
            }

            row.Cells[10].Value = bill.LastDateTime;
        }
Ejemplo n.º 2
0
        public bool Add(AccountBill bill)
        {
            m_bills.Add(bill.Account.Name, bill);

            UpdateTotal(bill);
            return(true);
        }
Ejemplo n.º 3
0
        private void ShowByMonth()
        {
            if (m_dtBills.Count == 0)
            {
                return;
            }

            foreach (var bills in m_dtBills)
            {
                AddBlackRowWithTitle(bills.Key);

                AccountBill total = new AccountBill();
                total.Account.Name = "总计";
                foreach (var bill in bills.Value)
                {
                    total.Account.CreditAmount += bill.Account.CreditAmount;
                    total.AvaliableAmount      += bill.AvaliableAmount;
                    total.BillAmount           += bill.BillAmount;
                    total.RepayAmount          += bill.RepayAmount;
                    total.NoRepayAmount        += bill.NoRepayAmount;
                    total.SwingAmount          += bill.SwingAmount;
                    total.Charge += bill.Charge;

                    AddAccountBillToView(bill);
                }

                AddTotalBill(total);
                AddBlackRow();
            }
        }
Ejemplo n.º 4
0
 public void UpdateTotal(AccountBill bill)
 {
     m_total.Account.CreditAmount += bill.Account.CreditAmount;
     m_total.AvaliableAmount      += bill.AvaliableAmount;
     m_total.BillAmount           += bill.BillAmount;
     m_total.RepayAmount          += bill.RepayAmount;
     m_total.NoRepayAmount        += bill.NoRepayAmount;
     m_total.SwingAmount          += bill.SwingAmount;
     m_total.Charge += bill.Charge;
 }
Ejemplo n.º 5
0
        private void AddTotalBill(AccountBill total)
        {
            int rowIndex = m_billDgv.Rows.Add();

            for (int i = 0; i < 11; i++)
            {
                m_billDgv.Rows[rowIndex].Cells[i].Style.BackColor = Color.Coral;
            }

            SetTotalAccountAmount(m_billDgv.Rows[rowIndex], total);
        }
Ejemplo n.º 6
0
        private void AddAccountBill(AccountBill bill)
        {
            var account = bill.Account.Name;

            if (!m_accountBills.ContainsKey(account))
            {
                var bills = new List <AccountBill>();
                m_accountBills.Add(account, bills);
            }

            m_accountBills[account].Add(bill);
        }
Ejemplo n.º 7
0
        private void AddAccountBillToView(AccountBill bill)
        {
            DataGridViewRow row = new DataGridViewRow();

            row.CreateCells(m_billDgv);

            row.Cells[0].Value = bill.Account.Name;
            row.Cells[1].Value = Utility.FormatDateString(bill.LastBillStart) + " - " + Utility.FormatDateString(bill.LastBillEnd);

            SetAcountBillAmount(bill, row);
            m_billDgv.Rows.Add(row);
        }
Ejemplo n.º 8
0
        private void AddYearmonthBill(AccountBill bill)
        {
            // 格式:1900-01
            var billDate = Utility.FormatDateString(bill.LastBillStart).Substring(0, 7);

            if (!m_dtBills.ContainsKey(billDate))
            {
                var bills = new List <AccountBill>();
                m_dtBills.Add(billDate, bills);
            }

            m_dtBills[billDate].Add(bill);
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
        private void InitBillDruction(string accountName)
        {
            AccountBill bill = BillBook.GetInstance().Find(accountName);

            if (Bill == null)
            {
                var lastBillStart = new DateTime();
                var lastBillEnd   = new DateTime();
                Utility.CalcLastBillDruction(bill.Account.BillStartDay, ref lastBillStart, ref lastBillEnd);
                m_billDructionLB.Text = Utility.FormatDateString(lastBillStart) + " - " + Utility.FormatDateString(lastBillEnd);
            }
            else
            {
                m_billDructionLB.Text = "";
            }
        }
Ejemplo n.º 11
0
        // update and save to file
        private void SaveToDB(AccountBill bill)
        {
            bool exist = File.Exists(m_fileName);

            StreamWriter writer = null;

            if (!exist)
            {
                writer = new StreamWriter(m_fileName);
                writer.Write("账号名称,信用额度,账单起始日期,账单截止日期,可用额度,账单金额,已还金额,未还金额,刷卡合计,上次设置账单日期时间,最后操作日期时间,刷卡手续费");
                writer.Write("\r\n");
                writer.Flush();
            }
            else
            {
                writer = new StreamWriter(m_fileName, true);
            }

            writer.Write(bill.Account.Name);
            WriteSpliter(writer);
            writer.Write(bill.Account.CreditAmount);
            WriteSpliter(writer);
            writer.Write(Utility.FormatDateString(bill.LastBillStart));
            WriteSpliter(writer);
            writer.Write(Utility.FormatDateString(bill.LastBillEnd));
            WriteSpliter(writer);
            writer.Write(bill.AvaliableAmount);
            WriteSpliter(writer);
            writer.Write(bill.BillAmount);
            WriteSpliter(writer);
            writer.Write(bill.RepayAmount);
            WriteSpliter(writer);
            writer.Write(bill.NoRepayAmount);
            WriteSpliter(writer);
            writer.Write(bill.SwingAmount);
            WriteSpliter(writer);
            writer.Write(bill.BillSetDate);
            WriteSpliter(writer);
            writer.Write(bill.LastDateTime);
            WriteSpliter(writer);
            writer.Write(bill.Charge);
            writer.Write("\r\n");
            writer.Flush();

            writer.Close();
        }
Ejemplo n.º 12
0
        public List <AccountBill> Load()
        {
            List <AccountBill> bills = new List <AccountBill>();

            if (!File.Exists(m_fileName))
            {
                return(bills);
            }

            StreamReader reader = new StreamReader(m_fileName);

            if (reader == null)
            {
                return(bills);
            }

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

                AccountBill bill = new AccountBill();
                bill.Account.Name         = items[0];
                bill.Account.CreditAmount = double.Parse(items[1]);
                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]);

                bills.Add(bill);
            }

            reader.Close();
            return(bills);
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 14
0
        private void SetTotalAccountAmount(DataGridViewRow row, AccountBill bill)
        {
            var font = new Font("微软雅黑", 9.5f, FontStyle.Bold);

            row.Cells[0].Value      = bill.Account.Name;
            row.Cells[0].Style.Font = font;
            row.Cells[2].Value      = Utility.ConvertDouble(bill.Account.CreditAmount);
            row.Cells[2].Style.Font = font;
            row.Cells[3].Value      = Utility.ConvertDouble(bill.AvaliableAmount);
            row.Cells[3].Style.Font = font;
            row.Cells[4].Value      = Utility.ConvertDouble(bill.BillAmount);
            row.Cells[4].Style.Font = font;
            row.Cells[5].Value      = Utility.ConvertDouble(bill.RepayAmount);
            row.Cells[5].Style.Font = font;
            row.Cells[6].Value      = Utility.ConvertDouble(bill.NoRepayAmount);
            row.Cells[6].Style.Font = font;
            row.Cells[7].Value      = Utility.ConvertDouble(bill.SwingAmount);
            row.Cells[7].Style.Font = font;
            row.Cells[8].Value      = bill.Charge.ToString();
            row.Cells[8].Style.Font = font;
        }
Ejemplo n.º 15
0
 public void Update(AccountBill bill)
 {
     UpdateDB();
 }
Ejemplo n.º 16
0
 public void Add(AccountBill bill)
 {
     UpdateDB();
 }
Ejemplo n.º 17
0
 public void Add(AccountBill bill)
 {
     SaveToDB(bill);
 }
Ejemplo n.º 18
0
 public void ResetBilll(AccountBill bill)
 {
     m_bills[bill.Account.Name] = bill;
 }