예제 #1
0
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            if (loaded)
            {
                if (((DataGridView)sender).SelectedRows != null && ((DataGridView)sender).SelectedRows.Count > 0)
                {
                    //chart1.Series.Clear();
                    List <CurrencyRate> currencyList = new List <CurrencyRate>();

                    DataGridViewRow row  = ((DataGridView)sender).SelectedRows[0];
                    string          name = row.Cells["Name"].Value.ToString();
                    DataTable       dt   = StaticSQL.GetCurrencyHistoryByName(name);

                    if (!chart1.Series.Any(x => x.Name == name))
                    {
                        chart1.Series.Add(name);
                        chart1.Series[name].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                        chart1.Series[name].ToolTip   = name;
                    }

                    foreach (DataRow item in dt.Rows)
                    {
                        decimal  value = (decimal)item["Value"];
                        DateTime date  = (DateTime)item["Date"];
                        chart1.Series[name].Points.AddXY(date, value);
                        //currencyList.Add(item);
                    }
                }
            }
        }
예제 #2
0
        public void FillDataBaseWithCurrencies(List <CurrencyRate> currencyList)
        {
            if (currencyList.First().Date == StaticSQL.GetLatestUpdateDate())
            {
                return;
            }

            foreach (CurrencyRate currency in currencyList)
            {
                StaticSQL.InsertCurrencyData(currency);
            }
        }
예제 #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            StaticSQL.SetConnectionString("Server=DESKTOP-6CLE20J\\SQLEXPRESS;Database=CurrencyLIVE;Trusted_Connection=true;");

            XmlReader xmlReader = XmlReader.Create("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml");

            currencyList = ReadValuesFromXML(xmlReader);
            FillDataBaseWithCurrencies(currencyList);
            dataGridView1.DataSource = currencyList.Select(CurrencyRate => new { CurrencyRate.Date, CurrencyRate.Name, CurrencyRate.Value }).ToList();
            dataGridView1.ClearSelection();
            FillComboBoxes(currencyList);
            loaded = true;
        }