private void ButtonAction_Click(object sender, ListViewColumnMouseEventArgs e) { ShowSellDialog(e.Item.Tag.ToString(), Convert.ToInt32(Convert.ToDecimal(e.Item.SubItems[1].Text))); }
private void ButtonActionInfo_Click(object sender, ListViewColumnMouseEventArgs e) { if (m_oA == null) { return; } string Symbol = e.Item.Tag.ToString(); 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 } ); TransactionGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells; 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.Where(t => t.SecuritiesTrade != null && t.SecuritiesTrade.Security.Symbol.Equals(Symbol))) { 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; UserControl TransactionControl = new CreateDataGridControlFromObject( new DataGridForControl { DataGridViewToBuild = TransactionGrid, GroupBoxCaption = string.Format("Transactions on {0} for {1}", m_oA.GetCustomer().FullName, Symbol) } ); Form Ftrans = new Form(); Ftrans.Controls.Add(TransactionControl); Ftrans.Width = TransactionControl.Width + 50; Ftrans.ShowDialog(); }