Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd64 committed Aug 3, 2017
1 parent 15ac07c commit fa59c86
Show file tree
Hide file tree
Showing 17 changed files with 1,408 additions and 0 deletions.
22 changes: 22 additions & 0 deletions TCMB.ExchangeRates/TCMB.ExchangeRates.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.15
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TCMB.ExchangeRates", "TCMB.ExchangeRates\TCMB.ExchangeRates.csproj", "{C84B0E93-D3FF-4A02-80B3-B9AEB5A998B1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C84B0E93-D3FF-4A02-80B3-B9AEB5A998B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C84B0E93-D3FF-4A02-80B3-B9AEB5A998B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C84B0E93-D3FF-4A02-80B3-B9AEB5A998B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C84B0E93-D3FF-4A02-80B3-B9AEB5A998B1}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions TCMB.ExchangeRates/TCMB.ExchangeRates/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" />
</startup>
</configuration>
19 changes: 19 additions & 0 deletions TCMB.ExchangeRates/TCMB.ExchangeRates/ExchangeRate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TCMB.ExchangeRates
{
public class ExchangeRate
{
public string CurrencyCode { get; set; }
public string Currency { get; set; }
public string Unit { get; set; }
public string ForexBuying { get; set; }
public string ForexSelling { get; set; }
public string BanknoteBuying { get; set; }
public string BanknoteSelling { get; set; }
}
}
106 changes: 106 additions & 0 deletions TCMB.ExchangeRates/TCMB.ExchangeRates/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

129 changes: 129 additions & 0 deletions TCMB.ExchangeRates/TCMB.ExchangeRates/Form1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Resources;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;

namespace TCMB.ExchangeRates
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

public enum Languages
{
English,
Türkçe
}

ResourceManager langRM = new ResourceManager("TCMB.ExchangeRates.Languages.tr-TR", typeof(Form1).Assembly);

private string today = "";

private void Form1_Load(object sender, EventArgs e)
{
try
{
XmlDocument doc = new XmlDocument();
WebClient web = new WebClient();

MemoryStream ms = new MemoryStream(web.DownloadData("http://www.tcmb.gov.tr/kurlar/today.xml"));
doc.Load(ms);

XmlNodeList nodes = doc.SelectNodes("//Currency");

today = doc.SelectSingleNode("//Tarih_Date").Attributes["Tarih"].Value.Trim();

cmbBoxLanguages.DataSource = Enum.GetValues(typeof(Languages));
cmbBoxLanguages.SelectedIndex = 1;

GetLstViewItems(nodes);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

private void cmbBoxLanguages_SelectedIndexChanged(object sender, EventArgs e)
{
GetSelectedLanguage(cmbBoxLanguages.SelectedIndex);

LoadLstViewColumns();
}

public void GetSelectedLanguage(int selectedLanguage)
{
if (selectedLanguage == (int)Languages.English)
{
langRM = new ResourceManager("TCMB.ExchangeRates.Languages.en-US", typeof(Form1).Assembly);
}
else if (selectedLanguage == (int)Languages.Türkçe)
{
langRM = new ResourceManager("TCMB.ExchangeRates.Languages.tr-TR", typeof(Form1).Assembly);
}
else
{
langRM = new ResourceManager("TCMB.ExchangeRates.Languages.tr-TR", typeof(Form1).Assembly);
}

this.Text = langRM.GetString("formTitle");
}

public void LoadLstViewColumns()
{
lblDate.Text = string.Format("{0} : {1}", langRM.GetString("lblDate"), today);

lstViewCurrency.Columns.Clear();

lstViewCurrency.Columns.Add(langRM.GetString("currencyCode"));
lstViewCurrency.Columns.Add(langRM.GetString("unit"));
lstViewCurrency.Columns.Add(langRM.GetString("currency"));
lstViewCurrency.Columns.Add(langRM.GetString("forexBuying"));
lstViewCurrency.Columns.Add(langRM.GetString("forexSelling"));
lstViewCurrency.Columns.Add(langRM.GetString("banknoteBuying"));
lstViewCurrency.Columns.Add(langRM.GetString("banknoteSelling"));

lstViewCurrency.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
lstViewCurrency.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize);
}

public void GetLstViewItems(XmlNodeList nodes)
{
foreach (XmlNode node in nodes)
{
ExchangeRate kur = new ExchangeRate()
{
CurrencyCode = node.Attributes["CurrencyCode"].Value.Trim(),
Unit = node["Unit"].InnerText.Trim(),
Currency = node["Isim"].InnerText.Trim(),
ForexBuying = node["ForexBuying"].InnerText.Trim(),
ForexSelling = node["ForexSelling"].InnerText.Trim(),
BanknoteBuying = node["BanknoteBuying"].InnerText.Trim(),
BanknoteSelling = node["BanknoteSelling"].InnerText.Trim()
};

ListViewItem li = new ListViewItem(kur.CurrencyCode);
li.SubItems.Add(kur.Unit);
li.SubItems.Add(kur.Currency);
li.SubItems.Add(kur.ForexBuying);
li.SubItems.Add(kur.ForexSelling);
li.SubItems.Add(kur.BanknoteBuying);
li.SubItems.Add(kur.BanknoteSelling);
li.Tag = kur;
lstViewCurrency.Items.Add(li);
}
}
}
}
Loading

0 comments on commit fa59c86

Please sign in to comment.