Ejemplo n.º 1
0
        private void AddStock()
        {
            string code = this.tx_code.Text.Trim();

            if (code == string.Empty)
            {
                MessageBox.Show("请输入股票代码");
                return;
            }
            List <SecurityInfo> lists = GlobalValue.GetFutureByCode(code);

            if (lists.Count == 0)
            {
                MessageBox.Show("找不到股票代码");
                return;
            }

            //SecurityInfo si = new SecurityInfo();
            if (lists.Count == 1)
            {
                //si = lists[0];
                AddStock(lists[0]);
            }
            else
            {
                uc_StockSelect uc_select = new uc_StockSelect();
                uc_select.Top  = this.tx_code.Top + this.panel1.Height;
                uc_select.Left = this.tx_code.Left;
                this.Controls.Add(uc_select);
                uc_select.BringToFront();
                uc_select.DataSource = lists;
                uc_select.DataBind();
                uc_select.Show();
                uc_select.Focus();
                uc_select.Stock_Selected += uc_select_Stock_Selected;
                uc_select.Leave          += uc_select_Leave;
            }
        }
Ejemplo n.º 2
0
        private void bt_add_Click(object sender, EventArgs e)
        {
            string policyname;

            try
            {
                policyname = this.cb_policy.SelectedItem.ToString();
            }
            catch
            {
                policyname = string.Empty;
            }
            if (policyname == string.Empty)
            {
                MessageBox.Show("请选择策略名称", "错误");
                return;
            }
            string code = string.Empty;

            code = this.comboBox2.Text.Trim();

            if (code == string.Empty)
            {
                MessageBox.Show(this, "请输入股票代码", "错误");
            }
            List <SecurityInfo> lists = GlobalValue.GetFutureByCode(code);

            if (lists.Count == 0)
            {
                MessageBox.Show("找不到股票代码");
                return;
            }

            if (lists.Count == 1)
            {
                si = lists[0];
            }
            else
            {
                uc_StockSelect uc_select = new uc_StockSelect();
                uc_select.Top  = this.comboBox2.Top + this.comboBox2.Height;
                uc_select.Left = this.comboBox2.Left;
                this.Controls.Add(uc_select);
                uc_select.BringToFront();
                uc_select.DataSource = lists;
                uc_select.DataBind();
                uc_select.Show();
                uc_select.Focus();
                uc_select.Stock_Selected += uc_select_Stock_Selected;
                uc_select.Leave          += uc_select_Leave;
            }
            GridRowTag grt   = new GridRowTag(assembly, this.propertyGrid1.SelectedObject, si);
            int        index = this.grid_stocks.Rows.Add();

            this.grid_stocks.Rows[index].Cells[0].Value = si.Code;
            this.grid_stocks.Rows[index].Cells[1].Value = si.Name;
            this.grid_stocks.Rows[index].Cells[2].Value = si.Market;
            this.grid_stocks.Rows[index].Cells[3].Value = policyname;
            this.grid_stocks.Rows[index].Cells[4].Value = "删除";
            this.grid_stocks.Rows[index].Tag            = grt;
            cb_policy_SelectedIndexChanged(this, new EventArgs());
        }