Пример #1
0
        // submits the information from the submission textboxes to the list, saves the changes, and updates the UI
        private void ButtonSubmit_Click(object sender, EventArgs e)
        {
            double btc = 0.0;
            double dollars = 0.0;
            Double.TryParse(TextboxBitcoinAmount.Text, out btc);
            Double.TryParse(TextboxDollarAmount.Text, out dollars);

            // textboxes are cleared
            TextboxBitcoinAmount.Text = "";
            TextboxDollarAmount.Text = "";

            // if the input is negative then it is made positive
            if (btc < 0.0) btc = btc * -1.0;
            if (dollars < 0.0) dollars = dollars * -1.0;

            i_investment c_investment = new i_investment();
            c_investment.bitcoinAmount = btc;
            c_investment.dollarAmount = dollars;
            c_investment.date = p_access.completeDate;
            p_access.investments.Add(c_investment);

            SaveChanges();
            UpdateUI();
        }
Пример #2
0
        // this function reads in the information from the log file and stores it in a list
        private void GetInvestmentsFromFile()
        {
            using (StreamReader sr = new StreamReader(p_access.fileName))
            {
                while (sr.Peek() >= 0) // while there are more characters
                {
                    string tmpStr;
                    tmpStr = sr.ReadLine(); // read in a line

                    string[] tmpStrArray = tmpStr.Split(new char[] { '\t' }); // split by \t into array

                    // information from array is added to the list
                    i_investment c_investment = new i_investment();
                    Double.TryParse(tmpStrArray[0], out c_investment.bitcoinAmount);
                    Double.TryParse(tmpStrArray[1], out c_investment.dollarAmount);
                    c_investment.date = tmpStrArray[2];
                    p_access.investments.Add(c_investment);
                }
            }
        }