private void btnNewCorp_Click(object sender, EventArgs e) { MaintPublicCorp newCorp = new MaintPublicCorp(); if (newCorp.ShowDialog() != DialogResult.Cancel) { _corpData = PublicCorps.GetAll(); cmbCorp.SelectedValue = newCorp.CorpData.ID; } }
public static PublicCorpsList GetAll(bool includeBanks, bool includeNonBanks) { PublicCorpsList retVal = new PublicCorpsList(); EMMADataSet.PublicCorpsDataTable table = new EMMADataSet.PublicCorpsDataTable(); tableAdapter.Fill(table); foreach (EMMADataSet.PublicCorpsRow row in table) { if ((row.Bank && includeBanks) || (!row.Bank && includeNonBanks)) { retVal.Add(new PublicCorp(row)); } } return retVal; }
private void NewShareTrans_Load(object sender, EventArgs e) { _corpData = PublicCorps.GetAll(false); _corpData.Sort("Name ASC"); cmbCorp.DataSource = _corpData; cmbCorp.DisplayMember = "Name"; cmbCorp.ValueMember = "ID"; if (_data.CorpID != 0) { cmbCorp.SelectedValue = _data.CorpID; } txtPrice.Tag = _data.PricePerShare; dtpTransDate.Value = _data.TransactionDate; cmbType.SelectedIndex = 0; }
public static PublicCorpsList GetReportGroupInvestments(int reportGroupID, bool banks) { PublicCorpsList retVal = new PublicCorpsList(); EMMADataSet.InvestmentsDataTable table = new EMMADataSet.InvestmentsDataTable(); invTableAdapter.FillByReportGroup(table, reportGroupID, banks); foreach (EMMADataSet.InvestmentsRow row in table) { if (banks) { // If this is a bank then we need to get the owner IDs that hold accounts with // this corp and group. EMMADataSet.BankAccountDataTable accounts = BankAccounts.GetBankAccountData( UserAccount.CurrentGroup.ID, 0, row.CorpID); foreach (EMMADataSet.BankAccountRow account in accounts) { PublicCorp corpData = new PublicCorp(row); corpData.OwnerID = account.OwnerID; retVal.Add(corpData); } if (accounts.Count == 0) { PublicCorp corpData = new PublicCorp(row); retVal.Add(corpData); } } else { retVal.Add(new PublicCorp(row)); } } return retVal; }
private void MaintBankAccount_Load(object sender, EventArgs e) { try { if (_oldCorpData != null) { cmbAccountCorp.Enabled = false; if (_oldCorpData.OwnerID != 0) { cmbOwner.Enabled = false; } } _corpData = PublicCorps.GetAll(true, false); _corpData.Sort("Name ASC"); cmbAccountCorp.DisplayMember = "Name"; cmbAccountCorp.ValueMember = "ID"; cmbAccountCorp.DataSource = _corpData; if (_oldCorpData != null) { cmbAccountCorp.SelectedValue = _oldCorp; } cmbAccountCorp.SelectedIndexChanged += new EventHandler(cmbAccountCorp_SelectedIndexChanged); cmbOwner.SelectedIndexChanged += new EventHandler(cmbOwner_SelectedIndexChanged); if (_corp == null) { _corp = new PublicCorp(); } CorpChanged(); //DisplayOwners(); //DisplayData(); } catch (Exception ex) { EMMAException emmaEx = ex as EMMAException; if (emmaEx == null) { emmaEx = new EMMAException(ExceptionSeverity.Error, "Problem loading " + "bank account window", ex); } MessageBox.Show("Problem loading bank account window: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void DisplayData() { try { //PublicCorp oldSelection = null; //if (sharesGrid.SelectedRows != null && sharesGrid.SelectedRows.Count > 0) //{ // oldSelection = (PublicCorp)sharesGrid.SelectedRows[0].DataBoundItem; //} _investments = PublicCorps.GetReportGroupInvestments(UserAccount.CurrentGroup.ID, _bankMode); if (chkInvestedOnly.Checked && !_bankMode) { _investments.ItemFilter = "SharesOwned > 0"; } else { _investments.ItemFilter = ""; } DataGridViewCellStyle style = new DataGridViewCellStyle(ValueColumn.DefaultCellStyle); style.Format = IskAmount.FormatString(); ValueColumn.DefaultCellStyle = style; sharesGrid.AutoGenerateColumns = false; CorpNameColumn.DataPropertyName = "Name"; QuantityColumn.DataPropertyName = "SharesOwned"; QuantityColumn.Visible = !_bankMode; if (!_bankMode) { ValueColumn.DataPropertyName = "SharesOwnedValue"; ValueColumn.HeaderText = "Value"; AccountOwnerColumn.DataPropertyName = ""; AccountOwnerColumn.Visible = false; } else { ValueColumn.DataPropertyName = "AmountInAccount"; ValueColumn.HeaderText = "Account Balance"; AccountOwnerColumn.DataPropertyName = "Owner"; AccountOwnerColumn.Visible = true; } DataGridViewColumn sortColumn = CorpNameColumn; ListSortDirection sortDirection = ListSortDirection.Ascending; if (sharesGrid.SortedColumn != null) { sortColumn = sharesGrid.SortedColumn; } if (sharesGrid.SortOrder == SortOrder.Descending) { sortDirection = ListSortDirection.Descending; } if (_investments.ItemFilter.Length > 0) { sharesGrid.DataSource = _investments.FiltredItems; } else { sharesGrid.DataSource = _investments; } //if (oldSelection != null) //{ // for (int i = 0; i < sharesGrid.Rows.Count; i++) // { // if (((PublicCorp)sharesGrid.Rows[i].DataBoundItem).Equals(oldSelection)) // { // sharesGrid.Rows[i].Selected = true; // } // } //} sharesGrid.Sort(sortColumn, sortDirection); btnCorpDetail.Enabled = false; btnDeleteCorp.Enabled = false; btnBuySell.Enabled = !_bankMode; if (sharesGrid.Rows.Count > 0) { sharesGrid.Rows[0].Selected = true; RowSelected(0); } } catch (Exception ex) { EMMAException emmaEx = ex as EMMAException; if (emmaEx == null) { emmaEx = new EMMAException(ExceptionSeverity.Error, "Problem displaying current investments", ex); } MessageBox.Show(emmaEx.Message + ": " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }