Bu proje Hasan Burak ÖZTÜRK arkadaşımın projesidir ufak çaplı öğrenme aşamasında olan arkadaşlar için idealdir. Döviz kurları yayınlayan web sitesinden alınan verileri grafiksel olarak göstermek ve Merkez bankası döviz kurlarını kendi sunucunuza kaydetmek. ZedGraph kullanılarak grafik oluşturabilmek.. Umarım faydası olur..
Imports System System.Drawing System.Drawing.Drawing2D System.Configuration System.Data.SqlClient ZedGraph Class Frm_IkiTarihArasiDovizPrivate Sub Frm_IkiTarihArasiDoviz_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadEnd Sub Private Sub CMB_Secenek_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CMB_Secenek.SelectedIndexChangedIf CMB_Secenek.SelectedIndex > 0 Then
DTG_Data.DataSource = CreateDataTable()
CreateGraph(ZedGraphKur)
End If
End Sub
Function CreateDataTable() As System.Data.DataTableDim dtData As New DataTable()Try
' Sql ile Balant ilemlerimiz oluturuluyor...
SqlCnn.ConnectionString = ConfigurationManager.ConnectionStrings(
Dim SqlCnn As New SqlConnection()"HSN_Baglanti").ConnectionString' Sql ile balantmz alyor...
If SqlCnn.State = ConnectionState.Closed Then
SqlCnn.Open()
End If
' Sql'le gndereceimiz komutlarn nesnesi oluturuluyor...
SqlCmd.Connection = SqlCnn
SqlCmd.CommandType = CommandType.Text
Dim SqlCmd As New SqlCommand()If CMB_Secenek.SelectedIndex > 0 Then
SqlCmd.CommandText =
"Select DovizKodu AS Kod, DovizAlisFiyat, DovizSatisFiyat, DovizTarih From Hsn_Doviz Where DovizKodu=@DovizKod AND DovizTarih BETWEEN @IlkTarih AND @SonTarih ORDER BY DovizTarih DESC"
SqlCmd.Parameters.AddWithValue(
SqlCmd.Parameters.AddWithValue(
SqlCmd.Parameters.AddWithValue(
"@DovizKod", CMB_Secenek.Text)"@IlkTarih", DP_IlkTarih.Value.ToString("yyyy-MM-dd 00:00:00"))"@SonTarih", DP_SonTarih.Value.ToString("yyyy-MM-dd 23:59:59"))'Else
' SqlCmd.CommandText = "Select DovizKodu AS Kod, DovizAlisFiyat, DovizSatisFiyat, DovizTarih From Hsn_Doviz Where DovizTarih BETWEEN @IlkTarih AND @SonTarih ORDER BY DovizTarih DESC"
' SqlCmd.Parameters.AddWithValue("@IlkTarih", DP_IlkTarih.Value.ToString("yyyy-MM-dd 00:00:00"))
' SqlCmd.Parameters.AddWithValue("@SonTarih", DP_SonTarih.Value.ToString("yyyy-MM-dd 23:59:59"))
End If
SqlDap.Fill(dtData)
SqlCmd.Dispose()
Dim SqlDap As New SqlDataAdapter(SqlCmd)If SqlCnn.State = ConnectionState.Open Then
SqlCnn.Close()
End If
Catch
End Try
Return dtDataEnd Function
myPane.CurveList.Clear()
Private Sub CreateGraph(ByVal zgc As ZedGraphControl)Dim myPane As GraphPane = zgc.GraphPane' Set the titles and axis labels
myPane.Title.Text =
"Tarihler Aras Kur Karlatrma"
myPane.XAxis.Title.Text = CMB_Secenek.Text &
" Doviz Kur Tarihi"
myPane.YAxis.Title.Text = CMB_Secenek.Text &
" Doviz Sat Fiyat"
myPane.XAxis.Type = AxisType.Date
myPane.XAxis.Scale.MinorStep = 1.0
myPane.XAxis.Scale.MinorUnit = DateUnit.Day
myPane.XAxis.Scale.MajorStepAuto =
False
' Make up some data points from the Sine function
dtKur = CreateDataTable()
Dim list = New PointPairList()Dim dtKur As New DataTableDim xTarih As Double
If dtKur.Rows.Count > 0 Then
xTarih =
list.Add(xTarih, dtKur.Rows(index)(2))
index += 1
For index As Integer = 0 To dtKur.Rows.Count - 1CDbl(New XDate(CDate(dtKur.Rows(index)(3)).Year, CDate(dtKur.Rows(index)(3)).Month, CDate(dtKur.Rows(index)(3)).Day))Next indexEnd If
' Generate a blue curve with circle symbols, and "My Curve 2" in the legend
Dim myCurve As LineItem = myPane.AddCurve(CMB_Secenek.Text, list, Color.Black, SymbolType.Square)' Fill the area under the curve with a white-red gradient at 45 degrees
myCurve.Line.Fill =
New Fill(Color.White, Color.Red, 45.0F)' Make the symbols opaque by filling them with white
myCurve.Symbol.Fill =
New Fill(Color.White)' Fill the axis background with a color gradient
myPane.Chart.Fill =
New Fill(Color.White, Color.LightGoldenrodYellow, 45.0F)' Fill the pane background with a color gradient
myPane.Fill =
New Fill(Color.White, Color.FromArgb(220, 220, 255), 45.0F)' Calculate the Axis Scale Ranges
zgc.AxisChange()
zgc.Refresh()
End
End Sub Class
Imports
Imports
Imports
Imports
Imports
Imports
Public
CMB_Secenek.SelectedIndex = 0