Всем привет! Пишу конвертер валют и не пойму что за проблема.
| Код | using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Xml.Linq;
namespace WindowsFormsApplication3 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e) { XDocument xDocument = XDocument.Load(@"https://api.privatbank.ua/p24api/pubinfo?exchange&coursid=3");
var x = xDocument.Descendants().Elements("exchangerate") .Select(y => new Kurs() { ccy = y.Attribute("ccy").Value, buy = y.Attribute("buy").Value, sale = y.Attribute("sale").Value
}).ToList();
dataGridView1.DataSource = x; }
private void button2_Click(object sender, EventArgs e) { if (checkBox1.Checked) { string priceUSD = dataGridView1.Rows[2].Cells[1].Value.ToString(); double result1; Double.TryParse(priceUSD, out result1); int textValue; Int32.TryParse(textBox2.Text, out textValue); double result = result1 * textValue; textBox3.Text = Convert.ToString(result); }
}
private void checkBox1_CheckedChanged(object sender, EventArgs e) { textBox1.Text = dataGridView1.Rows[2].Cells[1].Value.ToString(); }
private void checkBox2_CheckedChanged(object sender, EventArgs e) { textBox1.Text = dataGridView1.Rows[1].Cells[1].Value.ToString(); }
private void checkBox3_CheckedChanged(object sender, EventArgs e) { textBox1.Text = dataGridView1.Rows[0].Cells[1].Value.ToString(); }
} public class Kurs { public string ccy { get; set; } public string buy { get; set; } public string sale { get; set; }
} }
|
http://i008.radikal.ru/1411/1b/3487772c60cc.png
Ошибки не вылетают, а в результате получается 0. Помогите пожалуйста. Заранее спасибо! |