private void Form2_Load(object sender, EventArgs e) { cmbCurrency1.Items.AddRange(data.ToArray()); cmbCurrency1.DisplayMember = "CurrencyCode"; cmbCurrency2.Items.AddRange(data.ToArray()); cmbCurrency2.DisplayMember = "CurrencyCode"; //combobox içerisinde görüntülenecek olan alanları displayMember ile yazıyoruz. cmbCurrencyType.DataSource = Enum.GetValues(typeof(ForexType)); //Kullanım Şekli ForexModel selection1 = f.GetByCurrencyCode("EUR"); ForexModel selection2 = f.GetByCurrencyCode("USD"); ForexType type = ForexType.ForexSelling; //ForexManager ex = new ForexManager(); //decimal result = ex.Exchange(type, selection1, selection2, 100); //lblForexValue.Text = result +" "+ selection2.CurrencyCode; ForexManagerTwo t = new ForexManagerTwo(new ForexExchangeUnitOne()); t.Exchange(selection1, selection2, 100, type); }
private void btnExchange_Click(object sender, EventArgs e) { //unboxing işlemleri ForexType _type = (ForexType)cmbCurrencyType.SelectedItem; ForexModel _selection1 = (ForexModel)cmbCurrency1.SelectedItem; ForexModel _selection2 = (ForexModel)cmbCurrency2.SelectedItem; decimal amount = decimal.Parse(txtCurrencyAmount.Text); ForexManager manager = new ForexManager(); lblForexValue.Text = manager.Exchange(_type, _selection1, _selection2, amount).ToString() + " " + _selection2.CurrencyCode; }
public decimal Exchange(ForexType type, ForexModel from, ForexModel to, decimal amount) { decimal result = 0; if (type == ForexType.ForexBuying) { result = service.Exchange(decimal.Parse(from.ForexBuying), decimal.Parse(to.ForexBuying), amount); } else if (type == ForexType.ForexSelling) { result = service.Exchange(decimal.Parse(from.ForexSelling), decimal.Parse(to.ForexSelling), amount); } return(result); }
public decimal Exchange(ForexModel from, ForexModel to, decimal amount, ForexType type) { return(exchangeService.Exchange(decimal.Parse(from.ForexSelling), decimal.Parse(to.ForexSelling), amount)); }