void OnOKClick()
        {
            _chart = new XYChart(pictureBox1.Width, pictureBox1.Height, new System.Drawing.Font("宋体", 9F));
            _chart.IsSingleLine = true;
            _chart.NumberFont   = new System.Drawing.Font("宋体", 9F);
            _chart.NewLine("收入", System.Drawing.Color.ForestGreen);
            _chart.NewLine("支出", System.Drawing.Color.DarkRed);

            System.Collections.Generic.List <ConsumeType> consumeTypes = Program.DataStore.FindAllConsumeType("[Id],[Name],[IsOut]").ToList();
            DateTime?beginDate     = dtBeginDate.Value;
            DateTime?endDate       = dtEndDate.Value;
            decimal  totalInMoney  = 0M;
            decimal  totalOutMoney = 0M;

            for (int i = 0; i < consumeTypes.Count; i++)
            {
                ConsumeType consumeType = consumeTypes[i];
                decimal     money       = Program.DataStore.GetTotalMoneyByConsumeType(consumeType.Id, beginDate, endDate);

                int lineIndex = consumeType.IsOut ? 1:0;
                _chart.Lines[lineIndex].AddPoint(i + 1, money);
                _chart.AddXLabel(i + 1, consumeType.Name, lineIndex);
                if (consumeType.IsOut)
                {
                    totalOutMoney += money;
                }
                else
                {
                    totalInMoney += money;
                }
            }
            _chart.Lines[0].Value = totalInMoney.ToString("#,###.##");
            _chart.Lines[1].Value = totalOutMoney.ToString("#,###.##");
            Render();
        }
Example #2
0
        void OnOKClick()
        {
            if (!UIValidtion.Create()
                .Null(txtYear, "年份")
                .NumInt(2010, System.DateTime.Today.Year)
                .Result)
            {
                return;
            }
            _chart            = new XYChart(pictureBox1.Width, pictureBox1.Height, new System.Drawing.Font("宋体", 9F));
            _chart.NumberFont = new System.Drawing.Font("宋体", 9F);
            _chart.NewLine("收入", System.Drawing.Color.ForestGreen);
            _chart.NewLine("支出", System.Drawing.Color.DarkRed);

            //lines[0].Points.Add(new LinePoint(){ X
            string  xLabelNames   = "零一二三四五六七八九十";
            int     year          = int.Parse(txtYear.Text);
            decimal totalInMoney  = 0M;
            decimal totalOutMoney = 0M;

            for (int i = 1; i < 13; i++)
            {
                decimal inMoney  = Program.DataStore.GetTotalMoneyByMonth(year, i, false);
                decimal outMoney = Program.DataStore.GetTotalMoneyByMonth(year, i, true);
                _chart.Lines[0].AddPoint(i, inMoney);
                _chart.Lines[1].AddPoint(i, outMoney);
                string xLabelName = "";
                if (i > 10)
                {
                    xLabelName = "十" + xLabelNames[i - 10] + "月";
                }
                else
                {
                    xLabelName = xLabelNames[i] + "月";
                }
                _chart.AddXLabel(i, xLabelName);
                totalInMoney  += inMoney;
                totalOutMoney += outMoney;
            }
            _chart.Lines[0].Value = totalInMoney.ToString("#,###.##");
            _chart.Lines[1].Value = totalOutMoney.ToString("#,###.##");

            Render();
        }