예제 #1
0
        private void button_Show_Transactions_Click(object sender, EventArgs e)
        {
            if (m_oA == null)
            {
                return;
            }
            MessageBox.Show(string.Join(", ", m_oA.GetSymbolInHoldings()));

            DataGridView TransactionGrid = new DataGridView();

            TransactionGrid.AutoGenerateColumns = false;
            TransactionGrid.AllowUserToAddRows  = false;

            TransactionGrid.Columns.Add(
                new DataGridViewTextBoxColumn()
            {
                CellTemplate     = new DataGridViewTextBoxCell(),
                Name             = "Amount",
                HeaderText       = "Amount",
                DataPropertyName = "Amount",
                ReadOnly         = true
            }
                );
            TransactionGrid.Columns.Add(
                new DataGridViewTextBoxColumn()
            {
                CellTemplate     = new DataGridViewTextBoxCell(),
                Name             = "TransactionDate",
                HeaderText       = "Date",
                DataPropertyName = "TransactionDate",
                ReadOnly         = true
            }
                );
            TransactionGrid.Columns.Add(
                new DataGridViewTextBoxColumn()
            {
                CellTemplate     = new DataGridViewTextBoxCell(),
                Name             = "TransactionType",
                HeaderText       = "Type",
                DataPropertyName = "TransactionType",
                ReadOnly         = true
            }
                );
            TransactionGrid.Columns.Add(
                new DataGridViewTextBoxColumn()
            {
                CellTemplate     = new DataGridViewTextBoxCell(),
                Name             = "Symbol",
                HeaderText       = "Symbol",
                DataPropertyName = "Symbol",
                ReadOnly         = true
            }
                );
            TransactionGrid.Columns.Add(
                new DataGridViewTextBoxColumn()
            {
                CellTemplate     = new DataGridViewTextBoxCell(),
                Name             = "Revenue",
                HeaderText       = "Revenue",
                DataPropertyName = "Revenue",
                ReadOnly         = true
            }
                );

            DataTable TransactionsDT = new DataTable();

            TransactionsDT.Columns.Add("Amount");
            TransactionsDT.Columns.Add("TransactionDate");
            TransactionsDT.Columns.Add("TransactionType");
            TransactionsDT.Columns.Add("Symbol");
            TransactionsDT.Columns.Add("Revenue");

            DataRow row = null;

            foreach (ITransactionInterface oT in m_oA.Transactions)
            {
                row                    = TransactionsDT.NewRow();
                row["Amount"]          = oT.DebitAccount.Equals(m_oA.Identifier) ? oT.DebitAmount.ToString() : oT.CreditAmount.ToString();
                row["TransactionDate"] = oT.TransactionDate;
                row["TransactionType"] = oT.TransactionType.ToString();
                row["Symbol"]          = oT.SecuritiesTrade != null ? oT.SecuritiesTrade.Security.Symbol : "";
                row["Revenue"]         = oT.SecuritiesTrade != null && oT.SecuritiesTrade.Revenue != null?oT.SecuritiesTrade.Revenue.ToString() : "";

                TransactionsDT.Rows.Add(row);
            }
            TransactionGrid.DataSource       = TransactionsDT;
            TransactionGrid.Dock             = DockStyle.Fill;
            TransactionGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells;

            UserControl TransactionControl = new CreateDataGridControlFromObject(
                new DataGridForControl
            {
                DataGridViewToBuild = TransactionGrid,
                GroupBoxCaption     = string.Format("Transactions on {0}", m_oA.GetCustomer().FullName)
            }
                );

            Form Ftrans = new Form();

            Ftrans.Controls.Add(TransactionControl);
            Ftrans.ShowDialog();


            //window.ShowDialog();
        }