Пример #1
0
 public UcBill(Model.BillModel model, Action <UcBill, bool> action, int num)
 {
     InitializeComponent();
     billModel   = model;
     this.action = action;
     this.num    = num;
 }
Пример #2
0
        /// <summary>
        /// 按天计息到期一次性还本息
        /// </summary>
        /// <param name="billModel"></param>
        /// <returns></returns>
        public static List <Model.BillDetailModel> GetDetailsByToEnd(Model.BillModel billModel)
        {
            List <Model.BillDetailModel> details = new List <Model.BillDetailModel>();

            Model.BillDetailModel detail = new Model.BillDetailModel();
            double interest = 0;

            if (billModel.DeadlineType == 1)
            {
                //按天总利息
                interest = Math.Round(billModel.YearRete / 365 * billModel.Deadline * billModel.TotalMoney, 2);
            }
            else
            {
                //按月总利息
                interest = Math.Round(billModel.YearRete / 12 * billModel.Deadline * billModel.TotalMoney, 2);    //总利息
            }

            detail.ReceivableInterest             = interest;
            detail.ReceivablePrincipalAndInterest = billModel.TotalMoney + interest;
            detail.ReceivableDay = billModel.EndDay;
            detail.Periods       = "1/1";
            details.Add(detail);

            return(details);
        }
Пример #3
0
        /// <summary>
        /// 等额本金还款
        /// </summary>
        /// <param name="billModel"></param>
        /// <returns></returns>
        public static List <Model.BillDetailModel> GetDetailsByEveragePrincipal(Model.BillModel billModel)
        {
            List <Model.BillDetailModel> details = new List <Model.BillDetailModel>();

            Model.BillDetailModel detail = null;
            double   montyMoney          = billModel.TotalMoney / billModel.Deadline;//月还款本金
            double   SurplusPayment      = 0;
            DateTime beginDay            = DateTime.Parse(billModel.BeginDay);

            for (int i = 0; i < billModel.Deadline; i++)
            {
                detail = new Model.BillDetailModel();
                if (i == 0)
                {
                    SurplusPayment            = billModel.TotalMoney - montyMoney;                               //剩余本金
                    detail.ReceivableInterest = Math.Round(billModel.TotalMoney * (billModel.YearRete / 12), 2); //月利息
                }
                else
                {
                    detail.ReceivableInterest = Math.Round(SurplusPayment * (billModel.YearRete / 12), 2); //月利息=上个月的剩余本金×利率
                    SurplusPayment            = SurplusPayment - montyMoney;                               //剩余本金
                }

                detail.ReceivablePrincipalAndInterest = Math.Round(montyMoney + detail.ReceivableInterest, 2);
                detail.ReceivableDay = beginDay.AddMonths(i + 1).ToString("yyyy-MM-dd");
                detail.Periods       = string.Format("{0}/{1}", i + 1, billModel.Deadline);

                details.Add(detail);
            }
            return(details);
        }
Пример #4
0
        private Model.BillModel GetBillModel()
        {
            Model.BillModel billModel = new Model.BillModel();

            billModel.SiteName       = txtSiteName.Text.Trim();
            billModel.SiteUserName   = txtSiteUserName.Text.Trim();
            billModel.Remark         = txtRemark.Text.Trim();
            billModel.BeginDay       = this.dateTimePicker1.Value.ToString("yyyy-MM-dd");
            billModel.Deadline       = int.Parse(txtDeadline.Text.Trim());
            billModel.DeadlineType   = radioButton2.Checked ? 1 : 2; //按月:2   按天:1
            billModel.TotalMoney     = double.Parse(txtTotalMoney.Text.Trim());
            billModel.YearRete       = float.Parse(txtYearRate.Text.Trim()) / 100;
            billModel.WayOfRepayment = (E_WayOfRepayment)cmbWayOfRepayment.SelectedIndex;
            if (billModel.DeadlineType == 1)
            {
                billModel.EndDay = DateTime.Parse(billModel.BeginDay).AddDays(billModel.Deadline).ToString("yyyy-MM-dd");
            }
            else
            {
                billModel.EndDay = DateTime.Parse(billModel.BeginDay).AddMonths(billModel.Deadline).ToString("yyyy-MM-dd");
            }

            billModel.CreateTime = System.DateTime.Now;
            billModel.UpdateTime = System.DateTime.Now;

            return(billModel);
        }
Пример #5
0
        public Model.BillModel GetBillModel()
        {
            int    qixian     = int.Parse(textBox1.Text.Trim());
            double totalmoney = double.Parse(txtjine.Text.Trim());
            double pref       = double.Parse(textBox2.Text.Trim());

            Model.BillModel bill = new Model.BillModel();
            bill.YearRete   = pref;
            bill.TotalMoney = totalmoney;
            bill.Deadline   = qixian;
            bill.BeginDay   = this.dateTimePicker1.Text;

            return(bill);
        }
Пример #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (this.cmbWayOfRepayment.SelectedIndex == 0)
            {
                MessageBox.Show("请选择还款方式!");
                return;
            }

            Model.BillModel billModel            = GetBillModel();
            List <Model.BillDetailModel> details = WayOfRepayment.GetDetailsByBillInfo(ref billModel);

            if (details != null && details.Count > 0)
            {
                ShowList(details);
            }
        }
Пример #7
0
        /// <summary>
        /// 根据投资条件计算还款计划
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static List <Model.BillDetailModel> GetDetailsByBillInfo(ref Model.BillModel model)
        {
            List <Model.BillDetailModel> list = null;

            if (model.WayOfRepayment == E_WayOfRepayment.等额本息)
            {
                list = GetDetailsByEveragePrincipalAndInterest(model);
            }
            else if (model.WayOfRepayment == E_WayOfRepayment.等额本金)
            {
                list = GetDetailsByEveragePrincipal(model);
            }
            else if (model.WayOfRepayment == E_WayOfRepayment.月付息到期付本)
            {
                list = GetDetailsByMonthInterestEndPrincipal(model);
            }
            else if (model.WayOfRepayment == E_WayOfRepayment.月付息按季付本)
            {
                list = GetDetailsByMonthInterestSeasonCapital(model);
            }
            else if (model.WayOfRepayment == E_WayOfRepayment.一次性本息)
            {
                list = GetDetailsByToEnd(model);
            }

            if (list != null && list.Count > 0)
            {
                model.BillID = Guid.NewGuid().ToString();
                //model.Periods = string.Format("0/{0}", list[0].Periods.Split('/')[1]);
                model.ReceivablePeriod = list.Count;
                model.EndDay           = list[list.Count - 1].ReceivableDay;
                model.YearRete         = Math.Round(model.YearRete * 100, 2);

                for (int i = 0; i < list.Count; i++)
                {
                    model.ReceivablePrincipalAndInterest += list[i].ReceivablePrincipalAndInterest;
                    list[i].BillID       = model.BillID;
                    list[i].BillDetailID = Guid.NewGuid().ToString();
                    list[i].UpdateTime   = DateTime.Now;
                    list[i].CreateTime   = DateTime.Now;
                }
                model.ReceivablePrincipalAndInterest = Math.Round(model.ReceivablePrincipalAndInterest, 2);
            }

            return(list);
        }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (this.cmbWayOfRepayment.SelectedIndex == 0)
            {
                MessageBox.Show("请选择还款方式!");
                return;
            }

            Model.BillModel billModel            = GetBillModel();
            List <Model.BillDetailModel> details = WayOfRepayment.GetDetailsByBillInfo(ref billModel);

            StringBuilder builder = new StringBuilder();

            builder.Append("Insert into billInfo (BillID ,SiteName,SiteUserName,TotalMoney,YearRete,Deadline,DeadlineType,ReceivedPeriod,ReceivablePeriod,ReceivablePrincipalAndInterest,ReceivedPrincipalAndInterest,WayOfRepayment,Reward,BeginDay,EndDay,YuQiCount,Deleted,Flag,Remark,UpdateTime,Createtime)");
            builder.Append(string.Format("Values('{0}','{1}','{2}',{3},{4},{5},{6},0,{7},{8},{9},{10},{11},'{12}','{13}',{14},{15},{16},'{17}','{18}','{19}')",
                                         billModel.BillID, billModel.SiteName, billModel.SiteUserName, billModel.TotalMoney, billModel.YearRete,
                                         billModel.Deadline, billModel.DeadlineType, billModel.ReceivablePeriod, billModel.ReceivablePrincipalAndInterest,
                                         billModel.ReceivedPrincipalAndInterest, (int)billModel.WayOfRepayment, billModel.Reward, billModel.BeginDay,
                                         billModel.EndDay, billModel.YuQiCount, billModel.Deleted, billModel.Deleted, billModel.Remark,
                                         billModel.UpdateTime.ToString("s"), billModel.CreateTime.ToString("s")));

            for (int i = 0; i < details.Count; i++)
            {
                builder.Append("|");    //语句分隔符
                builder.Append("Insert into billdetail( BillDetailID,BillID,Periods,ReceivableDay,ReceivedDay,ReceivablePrincipalAndInterest,ReceivableInterest,ReceivedPrincipalAndInterest,IsYuQi,Deleted,Flag,UpdateTime,CreateTime)");
                builder.Append(string.Format("Values('{0}','{1}','{2}','{3}','{4}',{5},{6},{7},{8},{9},{10},'{11}','{12}')",
                                             details[i].BillDetailID, details[i].BillID, details[i].Periods, details[i].ReceivableDay,
                                             details[i].ReceivedDay, details[i].ReceivablePrincipalAndInterest,
                                             details[i].ReceivableInterest, details[i].ReceivedPrincipalAndInterest,
                                             details[i].IsYuQi, details[i].Deleted, details[i].Flag, details[i].UpdateTime.ToString("s"),
                                             details[i].CreateTime.ToString("s")));
            }


            bool flag = SQLiteHelper.UpdateData(builder.ToString(), true);

            if (flag)
            {
                AppInfo.Instance.IsChanged = true;
                MessageBox.Show("添加成功!");
            }
            else
            {
                MessageBox.Show("添加失败!");
            }
        }
Пример #9
0
 public UcBill(Action <UcBill, bool> action)
 {
     InitializeComponent();
     this.action = action;
     billModel   = new Model.BillModel();
 }
Пример #10
0
 public UcBill()
 {
     InitializeComponent();
     billModel = new Model.BillModel();
 }
Пример #11
0
        /// <summary>
        /// 按日计息按月还息到期还本
        /// </summary>
        /// <param name="bill"></param>
        /// <returns></returns>
        public static List <Model.BillDetailModel> GetDetailsByDayMonthInterestSeasonCapital(Model.BillModel bill)
        {
            List <Model.BillDetailModel> details = new List <Model.BillDetailModel>();


            return(details);
        }
Пример #12
0
        /// <summary>
        /// 按月计息按季还款
        /// </summary>
        /// <param name="billModel"></param>
        /// <returns></returns>
        public static List <Model.BillDetailModel> GetDetailsByMonthInterestSeasonCapital(Model.BillModel billModel)
        {
            List <Model.BillDetailModel> details = new List <Model.BillDetailModel>();

            int    curMonth;                                                                                         //当前期数
            double curMoney;                                                                                         //当前未还本金
            int    seasonCount   = billModel.Deadline % 3 > 0 ? billModel.Deadline / 3 + 1 : billModel.Deadline / 3; //分成几季
            double seasonCapital = Math.Round(billModel.TotalMoney / seasonCount);                                   //每季应还的本金
            double interest;                                                                                         //每月应还利息

            DateTime beginDay = DateTime.Parse(billModel.BeginDay);

            for (int i = 0; i < seasonCount; i++)
            {
                curMoney = billModel.TotalMoney - seasonCapital * i;
                interest = Math.Round((curMoney * billModel.YearRete / 12), 2);

                Model.BillDetailModel detail = null;
                for (int j = 1; j <= 3; j++)
                {
                    detail   = new Model.BillDetailModel();
                    curMonth = i * 3 + j;
                    if (curMonth < billModel.Deadline && curMonth % 3 == 0 && curMonth != 0)
                    {
                        detail.ReceivablePrincipalAndInterest = interest + seasonCapital;
                        detail.ReceivableInterest             = interest;
                    }
                    else if (curMonth < billModel.Deadline)
                    {
                        detail.ReceivablePrincipalAndInterest = interest;
                        detail.ReceivableInterest             = interest;
                    }
                    else if (curMonth == billModel.Deadline)
                    {
                        detail.ReceivablePrincipalAndInterest = interest + seasonCapital;
                        detail.ReceivableInterest             = interest;
                    }
                    detail.ReceivableDay = beginDay.AddMonths((i * 3) + j).ToString("yyyy-MM-dd");
                    detail.Periods       = string.Format("{0}/{1}", (i * 3) + j, billModel.Deadline);
                    details.Add(detail);
                }
            }


            return(details);
        }
Пример #13
0
        /// <summary>
        /// 月还息到期还本
        /// </summary>
        /// <param name="billModel"></param>
        /// <returns></returns>
        public static List <Model.BillDetailModel> GetDetailsByMonthInterestEndPrincipal(Model.BillModel billModel)
        {
            List <Model.BillDetailModel> details = new List <Model.BillDetailModel>();

            double[] depAcctbal = new double[billModel.Deadline]; /*总还款*/
            //double[] payrateAcct = new double[bill.Deadline]; /*每月应还利息*/

            double interest = Math.Round((billModel.TotalMoney * billModel.YearRete / 12), 2);

            Model.BillDetailModel detail = null;
            DateTime beginDay            = DateTime.Parse(billModel.BeginDay);

            for (int i = 0; i < billModel.Deadline; i++)
            {
                detail = new Model.BillDetailModel();
                detail.ReceivableInterest = interest;
                if ((i + 1) == billModel.Deadline)
                {
                    detail.ReceivablePrincipalAndInterest = interest + billModel.TotalMoney;
                }
                else
                {
                    detail.ReceivablePrincipalAndInterest = interest;
                }

                detail.ReceivableDay = beginDay.AddMonths(i + 1).ToString("yyyy-MM-dd");
                detail.Periods       = string.Format("{0}/{1}", i + 1, billModel.Deadline);
                details.Add(detail);
            }

            return(details);
        }
Пример #14
0
        /// <summary>
        /// 等额本息还款
        /// </summary>
        /// <param name="billModel"></param>
        /// <returns></returns>
        public static List <Model.BillDetailModel> GetDetailsByEveragePrincipalAndInterest(Model.BillModel billModel)
        {
            List <Model.BillDetailModel> details = new List <Model.BillDetailModel>();

            double tlnAcct = 0;

            tlnAcct = billModel.TotalMoney;

            Model.BillDetailModel detail = null;
            DateTime beginDay            = DateTime.Parse(billModel.BeginDay);

            for (int i = 0; i < billModel.Deadline; i++)
            {
                detail = new Model.BillDetailModel();
                double paybaseAcct = (Math.Pow((1 + billModel.YearRete / 12), i + 1) - Math.Pow((1 + billModel.YearRete / 12), i)) / (Math.Pow((1 + billModel.YearRete / 12), billModel.Deadline) - 1) * billModel.TotalMoney;
                detail.ReceivableInterest             = tlnAcct * billModel.YearRete / 12;                      //利息
                detail.ReceivablePrincipalAndInterest = Math.Round(paybaseAcct + detail.ReceivableInterest, 2); //还款总额
                detail.ReceivableInterest             = Math.Round(detail.ReceivableInterest, 2);
                tlnAcct = tlnAcct - paybaseAcct;

                detail.ReceivableDay = beginDay.AddMonths(i + 1).ToString("yyyy-MM-dd");
                detail.Periods       = string.Format("{0}/{1}", i + 1, billModel.Deadline);
                details.Add(detail);
            }

            return(details);
        }