Пример #1
0
        private void button11_Click(object sender, EventArgs e)
        {
            CommonBusinessRule cb = new CommonBusinessRule();
            var a  = comboBox1.SelectedIndex;
            var ps = cb.QueryProducts(dateTimePicker1.Value, dateTimePicker2.Value);

            if (a == 1)
            {
                ps = ps.Where(x => x.Type == "B");
            }
            else if (a == 2)
            {
                ps = ps.Where(x => x.Type == "S");
            }
            this.Stocks = ps.Select(x => new Stock()
            {
                Id   = x.Id,
                Name = x.Name
            }).Distinct();
            this.iStock = -1;
            InitListView();
            if (this.Stocks.Count() > 0)
            {
                button1_Click(sender, e);
            }
        }
Пример #2
0
        private void InitProductsTable(DateTime start, DateTime end)
        {
            panel1.Controls.Clear();
            CommonBusinessRule cb = new CommonBusinessRule();

            this.Products = cb.QueryProducts(start, end);

            TableLayoutPanel table = new TableLayoutPanel();
            int ic = 0;

            string[] titles = new string[] { "股票代碼", "股票名稱", "交易日期", "交易方式", "成交價", "數量", "手續費", "交易稅", "收付", "損益", "報酬率" };
            foreach (var t in titles)
            {
                Label title = new Label();
                title.Text = t;
                table.Controls.Add(title, ic, 0);
                ic = ic + 1;
            }
            table.Size = new Size(1140, 20);
            panel1.Controls.Add(table);
            table = new TableLayoutPanel();
            int ir = 0;

            foreach (var p in this.Products)
            {
                Label title = new Label();
                title.Text = p.Id;
                table.Controls.Add(title, 0, ir);

                title      = new Label();
                title.Text = p.Name;
                table.Controls.Add(title, 1, ir);

                title      = new Label();
                title.Text = p.Date;
                table.Controls.Add(title, 2, ir);

                title      = new Label();
                title.Text = p.Type == "B"?"買進":"賣出";
                table.Controls.Add(title, 3, ir);

                title      = new Label();
                title.Text = p.Price.ToString();
                table.Controls.Add(title, 4, ir);

                title      = new Label();
                title.Text = p.Vol.ToString();
                table.Controls.Add(title, 5, ir);

                title      = new Label();
                title.Text = p.Fee.ToString();
                table.Controls.Add(title, 6, ir);

                title      = new Label();
                title.Text = p.Tax.ToString();
                table.Controls.Add(title, 7, ir);

                title      = new Label();
                title.Text = p.Income.ToString();
                table.Controls.Add(title, 8, ir);

                title      = new Label();
                title.Text = p.Increase.ToString();
                table.Controls.Add(title, 9, ir);

                title      = new Label();
                title.Text = p.Rate.ToString();
                table.Controls.Add(title, 10, ir);
                ir = ir + 1;
            }
            //table.Location = new Point(14, 43);
            table.Top        = 20;
            table.Size       = new Size(1140, 300);
            table.AutoScroll = true;
            panel1.Controls.Add(table);
            Chart();
            //this.Controls.Add(table);
        }