public EditDialog(ViewData data)
 {
     InitializeComponent();
     this.data = data;
     editing = true;
     UpdateFields();
 }
 private int CompareBySymbol(ViewData obj1, ViewData obj2)
 {
     return String.Compare(obj1.symbol, obj2.symbol);
 }
        /// <summary>
        /// Retrieves all of the records into a DataTable
        /// </summary>
        /// <returns> 1 if records were successfully retrieved </returns>
        public override bool GetAllRecords(out List<ViewData> list)
        {
            list = new List<ViewData>();
            lock (syncObject)
            {
                if (!Open("GetAllRecords"))
                {
                    Logger.Log("GetAllRecords: Open() failed");
                    return false;
                }

                SQLiteCommand sqlCommand = new SQLiteCommand("SELECT * FROM Positions", connection);
                string results = string.Empty;
                SQLiteDataReader reader;
                try
                {
                    reader = sqlCommand.ExecuteReader();
                    while (reader.Read())
                    {
                        //for (int i = 0; i != reader.FieldCount; ++i)
                        //{
                        //    string typeName = reader.GetDataTypeName(i);
                        //    string colName = reader.GetName(i);
                        //    Type type = reader.GetFieldType(i);
                        //    object o = reader.GetValue(i);
                        //}
                        ViewData record = new ViewData();
                        record.id = reader.GetInt64((int)ColumnIndices.ID);
                        record.symbol = reader.GetString((int)ColumnIndices.Symbol);
                        record.buyDate = reader.GetDateTime((int)ColumnIndices.BuyDate);
                        record.buyPrice = reader.GetDecimal((int)ColumnIndices.BuyPrice);
                        record.sharesBought = reader.GetDouble((int)ColumnIndices.SharesBought);
                        record.numShares = reader.GetDouble((int)ColumnIndices.NumShares);
                        record.highestClose = reader.GetDecimal((int)ColumnIndices.HighestClose);
                        record.lastClose = reader.GetDecimal((int)ColumnIndices.LastClose);
                        record.fixedStop = reader.GetDecimal((int)ColumnIndices.FixedStopPrice);
                        record.stopPercent = reader.GetInt32((int)ColumnIndices.StopPercent);
                        record.useTrailing = reader.GetBoolean((int)ColumnIndices.UseTrailing);
                        record.useDividends = reader.GetBoolean((int)ColumnIndices.UseDividends);
                        record.dividends = reader.GetDecimal((int)ColumnIndices.Dividends);
                        record.useOptions = reader.GetBoolean((int)ColumnIndices.UseOptions);
                        record.options = reader.GetDecimal((int)ColumnIndices.OptionsSold);
                        record.lastUpdate = reader.GetDateTime((int)ColumnIndices.LastUpdate);
                        list.Add(record);
                    }
                    reader.Close();
                }
                catch (SQLiteException e)
                {
                    MessageBox.Show("GetAllRecords - " + e.Message);
                    return false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("GetAllRecords - " + ex.Message);
                    return false;
                }
                finally
                {
                    connection.Close();
                }
            }   // lock

            list.Sort(CompareBySymbol);
            return true;
        }