public MaintBankTrans(PublicCorp corpData, BankTransactionType defaultType)
 {
     InitializeComponent();
     this.DialogResult = DialogResult.Cancel;
     _corpData = corpData;
     _defaultType = defaultType;
     _transactionData = new BankTransaction(corpData.BankAccountID, defaultType);
 }
        public MaintBankAccount(PublicCorp corp)
        {
            InitializeComponent();
            _corp = corp;
            _oldCorpData = _corp;

            if (_corp != null)
            {
                _oldCorp = _corp.ID;
                _oldOwner = _corp.OwnerID;
                _lastCorp = _corp.ID;
                _lastOwner = _corp.OwnerID;
            }

            _bindingSource = new BindingSource();
        }
        private void ListCorpWebLinks_Load(object sender, EventArgs e)
        {
            _selectedCorp = _startCorp;
            DisplayData();

            PublicCorpsList corpData = PublicCorps.GetAll();
            corpData.Sort("Name ASC");
            cmbCorpShown.DisplayMember = "Name";
            cmbCorpShown.ValueMember = "ID";
            cmbCorpShown.DataSource = corpData;

            if (_startCorp !=null)
            {
                cmbCorpShown.SelectedValue = _startCorp.ID;
            }
        }
        private void ListShareValueHistory_Load(object sender, EventArgs e)
        {
            _currentCorp = _startCorp;
            DisplayData();

            PublicCorpsList corpData = PublicCorps.GetAll(false);
            corpData.Sort("Name ASC");
            cmbSelectedCorp.DisplayMember = "Name";
            cmbSelectedCorp.ValueMember = "ID";
            cmbSelectedCorp.DataSource = corpData;

            if (_startCorp != null)
            {
                cmbSelectedCorp.SelectedValue = _startCorp.ID;
            }
        }
Exemplo n.º 5
0
        public static void StoreCorp(PublicCorp data)
        {
            bool newRow = false;
            EMMADataSet.PublicCorpsDataTable table = new EMMADataSet.PublicCorpsDataTable();
            EMMADataSet.PublicCorpsRow row;

            tableAdapter.FillByID(table, data.ID);
            if (table.Count > 0)
            {
                row = table[0];
            }
            else
            {
                row = table.NewPublicCorpsRow();
                newRow = true;
            }

            row.CorpName = data.Name;
            row.Ticker = data.Ticker;
            row.Description = data.Description;
            row.CEO = data.CEO;
            row.EstimatedNAV = data.NAV;
            row.NAVTakenAt = data.NAVDate;
            row.ValuePerShare = data.ShareValue;
            row.ExpectedPayoutPerShare = data.ExpectedPayout;
            row.PayoutPeriodID = (short)data.PayoutPeriod;
            row.Bank = data.Bank;
            row.RiskRatingID = (short)data.CorpRiskRating;

            if (newRow)
            {
                table.AddPublicCorpsRow(row);
            }

            tableAdapter.Update(table);
        }
Exemplo n.º 6
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;
 }
 /// <summary>
 /// Constructor to use if creating a new public corp.
 /// </summary>
 public MaintPublicCorp()
 {
     InitializeComponent();
     _corpData = new PublicCorp();
     _oldShareVal = decimal.MinValue;
 }
 private void RowSelected(int rowIndex)
 {
     bool done = false;
     while (!done)
     {
         try
         {
             selectedCorp = (PublicCorp)sharesGrid.Rows[rowIndex].DataBoundItem;
             btnCorpDetail.Enabled = true;
             btnBuySell.Enabled = (selectedCorp.Bank ? selectedCorp.BankAccountID > 0 : true);
             btnDeleteCorp.Enabled = (selectedCorp.Bank ?
                 selectedCorp.BankAccountID > 0 : PublicCorps.AllowDelete(selectedCorp.ID));
             done = true;
         }
         catch (InvalidOperationException)
         {
             // This can happen when deleting corps. Just wait a little and try again
             Thread.Sleep(100);
         }
     }
 }
 private void cmbSelectedCorp_SelectedIndexChanged(object sender, EventArgs e)
 {
     _currentCorp = (PublicCorp)cmbSelectedCorp.SelectedItem;
     DisplayData();
 }
 public ListShareTransactions(PublicCorp corpData)
 {
     _startCorp = corpData;
     InitializeComponent();
 }
 private void cmbCorpShown_SelectedIndexChanged(object sender, EventArgs e)
 {
     _selectedCorp = (PublicCorp)cmbCorpShown.SelectedItem;
     DisplayData();
 }
        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);
            }
        }
Exemplo n.º 13
0
 static void Cache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<int, PublicCorp> args)
 {
     PublicCorp data = null;
     EMMADataSet.PublicCorpsDataTable table =new EMMADataSet.PublicCorpsDataTable();
     tableAdapter.FillByID(table, args.Key);
     if (table.Count > 0)
     {
         data = new PublicCorp(table[0]);
     }
     args.Data = data;
 }
 private void CorpChanged()
 {
     if (cmbAccountCorp.SelectedValue != null && _oldCorpData == null)
     {
         int newCorp = (int)cmbAccountCorp.SelectedValue;
         if (_lastCorp > 0 && _lastCorp != newCorp && _lastOwner > 0)
         {
             BankAccounts.DeleteAccount(_lastCorp, _lastOwner);
         }
         _corp = PublicCorps.GetCorp(newCorp);
         // If the corp comes from the cache it may still have details for a different
         // owner's bank account, need to make sure we clear any existing details.
         _corp.OwnerID = -1;
         _corp.ReloadBankAccountDetails();
     }
     _lastCorp = _corp.ID;
     DisplayOwners();
     DisplayData();
 }
Exemplo n.º 15
0
 public MaintDividend(PublicCorp corp)
 {
     InitializeComponent();
     _startCorp = corp;
     _dividend = new Dividend((corp == null ? 0 : corp.ID));
 }
        public void LoadOldEmmaXML(string filename, int reportGroupID)
        {
            EMMADataSet.ShareTransactionDataTable table = new EMMADataSet.ShareTransactionDataTable();
            XmlDocument xml = new XmlDocument();
            UpdateStatus(0, 0, "", "Loading file", false);
            xml.Load(filename);

            XmlNodeList nodes = xml.SelectNodes("/DocumentElement/ShareTransaction");

            int counter = 0;
            UpdateStatus(0, 0, "", "Extracting data from XML", false);
            foreach (XmlNode node in nodes)
            {
                EMMADataSet.ShareTransactionRow trans = table.NewShareTransactionRow();
                trans.DateTime = DateTime.Parse(node.SelectSingleNode("DateTime").FirstChild.Value);
                string corpName = node.SelectSingleNode("CorpName").FirstChild.Value;
                try
                {
                    trans.CorpID = PublicCorps.GetCorp(corpName).ID;
                }
                catch (EMMADataMissingException)
                {
                    PublicCorp newCorp = new PublicCorp();
                    newCorp.Name = corpName;
                    PublicCorps.StoreCorp(newCorp);
                    trans.CorpID = PublicCorps.GetCorp(corpName).ID;
                }
                trans.ReportGroupID = reportGroupID;
                bool sell = node.SelectSingleNode("Type").FirstChild.Value.Trim().ToUpper().Equals("SELL");
                trans.DeltaQuantity = int.Parse(node.SelectSingleNode("Quantity").FirstChild.Value,
                    System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
                if (sell) { trans.DeltaQuantity *= -1; }
                trans.PricePerShare = decimal.Parse(node.SelectSingleNode("Price").FirstChild.Value,
                    System.Globalization.CultureInfo.InvariantCulture.NumberFormat);
                table.AddShareTransactionRow(trans);

                counter++;
                UpdateStatus(counter, nodes.Count, "", "", false);
            }

            UpdateStatus(0, 0, "", "Updating database", false);
            lock (tableAdapter)
            {
                tableAdapter.Update(table);
            }
        }
Exemplo n.º 17
0
        public static void StoreAccount(PublicCorp data, int reportGroupID, long ownerID)
        {
            EMMADataSet.BankAccountRow account = null;
            EMMADataSet.BankAccountDataTable table = new EMMADataSet.BankAccountDataTable();
            bool newRow = false;

            if (data.BankAccountID != 0)
            {
                bankAccountTableAdapter.FillByID(table, data.BankAccountID);
                account = table.FindByAccountID(data.BankAccountID);
            }

            if (account == null)
            {
                account = table.NewBankAccountRow();
                newRow = true;
            }

            account.PublicCorpID = data.ID;
            account.ReportGroupID = reportGroupID;
            account.Balance = 0;
            account.OwnerID = ownerID;
            if (newRow)
            {
                table.AddBankAccountRow(account);
            }
            bankAccountTableAdapter.Update(table);
        }
 /// <summary>
 /// Constructor to use if modifying an existing corp.
 /// </summary>
 /// <param name="corpID"></param>
 public MaintPublicCorp(PublicCorp corpData)
 {
     InitializeComponent();
     _corpData = corpData;
     _oldShareVal = _corpData.ShareValue;
 }
Exemplo n.º 19
0
        public static PublicCorp GetCorp(string corpName)
        {
            PublicCorp retVal = null;
            EMMADataSet.PublicCorpsDataTable table = new EMMADataSet.PublicCorpsDataTable();
            EMMADataSet.PublicCorpsRow rowData = null;

            lock (tableAdapter)
            {
                tableAdapter.FillByName(table, corpName);
            }
            if (table.Count == 1)
            {
                rowData = table[0];
            }
            else
            {
                lock (tableAdapter)
                {
                    tableAdapter.FillByName(table, "%" + corpName + "%");
                }

                if (table.Count < 1)
                {
                    throw new EMMADataMissingException(ExceptionSeverity.Error, "No public corp found " +
                        "matching '" + corpName + "'", "PublicCorps", corpName);
                }
                else if (table.Count > 1)
                {
                    SortedList<object, string> options = new SortedList<object, string>();
                    foreach (EMMADataSet.PublicCorpsRow corp in table)
                    {
                        options.Add(corp.CorpID, corp.CorpName);
                    }
                    OptionPicker picker = new OptionPicker("Select Corp (" + corpName + ")",
                        "Choose the specific corp you want from those listed below.", options);
                    if (picker.ShowDialog() != System.Windows.Forms.DialogResult.Cancel)
                    {
                        rowData = table.FindByCorpID((int)picker.SelectedItem);
                    }
                }
                else
                {
                    rowData = table[0];
                }
            }

            if (rowData != null) { retVal = new PublicCorp(rowData); }
            return retVal;
        }
Exemplo n.º 20
0
 public MaintWebLink(PublicCorp corp)
 {
     InitializeComponent();
     _startCorp = corp;
     _link = new WebLink(corp.ID);
 }
 public ListCorpWebLinks(PublicCorp _corpData)
 {
     InitializeComponent();
     _startCorp = _corpData;
 }
Exemplo n.º 22
0
 private void cmbCorp_SelectedIndexChanged(object sender, EventArgs e)
 {
     _selectedCorp = (PublicCorp)cmbCorp.SelectedItem;
 }
 public ListShareValueHistory(PublicCorp corp)
 {
     InitializeComponent();
     _startCorp = corp;
 }
Exemplo n.º 24
0
 public ListDividend(PublicCorp corp)
 {
     InitializeComponent();
     chkShowAll.Checked = false;
     _startCorp = corp;
 }