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);
            }
        }
        public static void StoreTransaction(ShareTransaction trans)
        {
            bool newRow = false;
            EMMADataSet.ShareTransactionDataTable table = new EMMADataSet.ShareTransactionDataTable();
            EMMADataSet.ShareTransactionRow row;

            tableAdapter.FillByTransID(table, trans.ID);
            if (table.Count > 0)
            {
                row = table[0];
            }
            else
            {
                row = table.NewShareTransactionRow();
                newRow = true;
            }

            row.CorpID = trans.CorpID;
            row.DeltaQuantity = trans.DeltaQuantity;
            row.DateTime = trans.TransactionDate;
            row.PricePerShare = trans.PricePerShare;
            row.ReportGroupID = trans.ReportGroupID;

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

            tableAdapter.Update(table);
        }