Nesne Yönelimli Programlama hakkında bilgi sahibi olmak isteyen herkese kişilere güzel bir örnek olacağını düşüyorum. Katmanlı mimaride aklınıza takılan sorulara cevap bulabilirsiniz umarım sistemde bulunanlar.
Veritabanına ulaşan katman ve buna uyumlu nesneler, kullanıcı arayüzü database olarak access database kullanılmıştır.
Imports WinOtoParkApp.WinOtoParkApp
Public Class FrmAnaEkran
Private Sub Temizle()
cmbKat.Text = String.Empty
cmbOdemeDurum.Text = String.Empty
cmbUcret.Text = String.Empty
cmbYer.Text = String.Empty
txtAraba.Text = String.Empty
txtAraba.Tag = String.Empty
txtMusteri.Text = String.Empty
txtMusteri.Tag = String.Empty
End Sub
Private Sub DataGetir()
Dim Sorgu As String
Sorgu = "SELECT Park.*, Musteri.*, Araba.* FROM (Park INNER JOIN Musteri ON Park.MusteriID = Musteri.MusteriID) INNER JOIN Araba ON Park.ArabaID = Araba.ArabaID WHERE ((Park.ParkIslem='Giriş')) ORDER BY Park.ParkGirisTarih DESC"
Dim getData As New Kayit()
MyDataGrid.DataSource = getData.GetDataTable(CommandType.Text, Sorgu)
End Sub
Private Sub FrmAnaEkran_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataGetir()
txtAraba.Tag = String.Empty
txtMusteri.Tag = String.Empty
End Sub
Private Sub btnMusteriTanim_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMusteriTanim.Click
Dim frm As New FrmMusteriTanimla()
frm.ShowDialog()
End Sub
Private Sub btnArabaTanim_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnArabaTanim.Click
Dim frm As New FrmArabaTanimla()
frm.ShowDialog()
End Sub
Private Sub btnKaydet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnKaydet.Click
If (String.IsNullOrEmpty(txtAraba.Tag) = False And String.IsNullOrEmpty(txtMusteri.Tag) = False And String.IsNullOrEmpty(cmbKat.Text) And String.IsNullOrEmpty(cmbUcret.Text) = False And String.IsNullOrEmpty(cmbOdemeDurum.Text) = False And String.IsNullOrEmpty(cmbYer.Text) = False) = False Then
Dim getDataVarmi As New Kayit()
If getDataVarmi.GetDataTable(CommandType.Text, "Select * From Park Where ParkIslem='Giriş' AND ArabaID=" + txtAraba.Tag.ToString.Trim()).Rows.Count <= 0 Then
If getDataVarmi.GetDataTable(CommandType.Text, "Select * From Park Where ParkIslem='Giriş' AND ParkKatNo='" + cmbKat.Text + "' AND ParkYerNo='" + cmbYer.Text + "'").Rows.Count <= 0 Then
If Park.Ekle(Ortak.ntoi32(txtMusteri.Tag.ToString.Trim), Ortak.ntoi32(txtAraba.Tag.ToString.Trim), Ortak.ntof(cmbUcret.Text), cmbKat.Text, cmbYer.Text, Ortak.ntodt(dpGirisTarih.Value), Ortak.ntodt(dpCikisTarih.Value), "Giriş", cmbOdemeDurum.Text) > 0 Then
DataGetir()
Temizle()
Ortak.Mesaj("Park Etme İşlemi Başarılı...", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Ortak.Mesaj("Lütfen bilgilerinizi kontrol edip tekrar deneyiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Else
Ortak.Mesaj("Park etmek istediğiniz yer dolu lütfen başka bir seçiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Else
Ortak.Mesaj("Park etmek istediğiniz araç zaten bir yere yerleştirilmiş durumda.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Else
Ortak.Mesaj("Lütfen tüm alanların dolu olduğunu kontrol edip tekrar deneyiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
Private Sub btnGuncelle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGuncelle.Click
If (String.IsNullOrEmpty(lblParkBilgi.Tag) = False And String.IsNullOrEmpty(txtAraba.Tag) = False And String.IsNullOrEmpty(txtMusteri.Tag) = False And String.IsNullOrEmpty(cmbKat.Text) And String.IsNullOrEmpty(cmbUcret.Text) = False And String.IsNullOrEmpty(cmbOdemeDurum.Text) = False And String.IsNullOrEmpty(cmbYer.Text) = False) = False Then
Dim getDataVarmi As New Kayit()
If getDataVarmi.GetDataTable(CommandType.Text, "Select * From Park Where ParkIslem='Giriş' AND ParkID<>" + lblParkBilgi.Tag.ToString.Trim() + " AND ArabaID=" + txtAraba.Tag.ToString.Trim()).Rows.Count <= 0 Then
If getDataVarmi.GetDataTable(CommandType.Text, "Select * From Park Where ParkIslem='Giriş' AND ParkID<>" + lblParkBilgi.Tag.ToString.Trim() + " AND ParkKatNo='" + cmbKat.Text + "' AND ParkYerNo='" + cmbYer.Text + "'").Rows.Count <= 0 Then
If Park.Guncelle(Ortak.ntoi32(lblParkBilgi.Tag), Ortak.ntoi32(txtMusteri.Tag), Ortak.ntoi32(txtAraba.Tag), cmbUcret.Text, cmbKat.Text, cmbYer.Text, Ortak.ntodt(dpGirisTarih.Value), Ortak.ntodt(dpCikisTarih.Value), lblParkBilgi.Text, cmbOdemeDurum.Text) > 0 Then
DataGetir()
Temizle()
Ortak.Mesaj("Park Güncelleme İşlemi Başarılı...", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Ortak.Mesaj("Lütfen bilgilerinizi kontrol edip tekrar deneyiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Else
Ortak.Mesaj("Park etmek istediğiniz yer dolu lütfen başka bir seçiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Else
Ortak.Mesaj("Park etmek istediğiniz araç zaten bir yere yerleştirilmiş durumda.", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Else
Ortak.Mesaj("Lütfen tüm alanların dolu olduğunu kontrol edip tekrar deneyiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
Private Sub btnSil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSil.Click
If (String.IsNullOrEmpty(lblParkBilgi.Tag) = False) Then
If Park.Sil(Ortak.ntoi(lblParkBilgi.Tag)) > 0 Then
DataGetir()
Temizle()
Ortak.Mesaj("Park Kayıt Sil İşlemi Başarılı...", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Ortak.Mesaj("Lütfen bilgilerinizi kontrol edip tekrar deneyiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
Else
Ortak.Mesaj("Lütfen tüm alanların dolu olduğunu kontrol edip tekrar deneyiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
Private Sub MyDataGrid_DoubleClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyDataGrid.DoubleClick
lblParkBilgi.Tag = MyDataGrid.CurrentRow.Cells("ParkID").Value
lblParkBilgi.Text = Ortak.ntos(MyDataGrid.CurrentRow.Cells("ParkIslem").Value)
lblParkBilgi.BackColor = Color.FromName(MyDataGrid.CurrentRow.Cells("ArabaRenk").Value)
lblParkBilgi.ForeColor = Color.FromName(MyDataGrid.CurrentRow.Cells("ArabaRenk").Value)
txtMusteri.Text = Ortak.ntos(MyDataGrid.CurrentRow.Cells("MusteriTCKimlik").Value) + " - " + Ortak.ntos(MyDataGrid.CurrentRow.Cells("MusteriAd").Value) + " " + Ortak.ntos(MyDataGrid.CurrentRow.Cells("MusteriSoyad").Value) + " (" + Ortak.ntos(MyDataGrid.CurrentRow.Cells("MusteriCinsiyet").Value) + ")"
txtMusteri.Tag = Ortak.ntos(MyDataGrid.CurrentRow.Cells("MusteriID").Value)
txtAraba.Text = Ortak.ntos(MyDataGrid.CurrentRow.Cells("ArabaPlaka").Value) + " - " + Ortak.ntos(MyDataGrid.CurrentRow.Cells("ArabaMarka").Value) + " (" + Ortak.ntos(MyDataGrid.CurrentRow.Cells("ArabaTipi").Value) + ")"
txtAraba.Tag = Ortak.ntos(MyDataGrid.CurrentRow.Cells("ArabaID").Value)
cmbKat.Text = Ortak.ntos(MyDataGrid.CurrentRow.Cells("ParkKatNo").Value)
cmbYer.Text = Ortak.ntos(MyDataGrid.CurrentRow.Cells("ParkYerNo").Value)
cmbOdemeDurum.Text = Ortak.ntos(MyDataGrid.CurrentRow.Cells("ParkUcretiDurum").Value)
cmbOdemeDurum.Tag = Ortak.ntos(MyDataGrid.CurrentRow.Cells("ParkUcretiDurum").Value)
cmbUcret.Text = Ortak.ntos(MyDataGrid.CurrentRow.Cells("ParkUcreti").Value)
dpGirisTarih.Value = Ortak.ntos(MyDataGrid.CurrentRow.Cells("ParkGirisTarih").Value)
dpCikisTarih.Value = Ortak.ntos(MyDataGrid.CurrentRow.Cells("ParkCikisTarih").Value)
End Sub
Private Sub txtMusteri_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtMusteri.KeyDown
If (String.IsNullOrEmpty(txtMusteri.Text) = False) Then
If e.KeyData = Keys.Enter Then
If (String.IsNullOrEmpty(txtMusteri.Text) = False) Then
If e.KeyData = Keys.Enter Then
Dim frm As New FrmMusteriArama
frm.Kriter = txtMusteri.Text.Replace("*", "%")
Select Case frm.ShowDialog()
Case DialogResult.Cancel
Exit Select
Case DialogResult.OK
txtMusteri.Text = frm.GetBilgi
txtMusteri.Tag = frm.GetMusteriID
Exit Select
End Select
End If
End If
End If
End If
End Sub
Private Sub txtAraba_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtAraba.KeyDown
If (String.IsNullOrEmpty(txtAraba.Text) = False) Then
If e.KeyData = Keys.Enter Then
Dim frm As New FrmArabaArama
frm.Kriter = txtAraba.Text.Replace("*", "%")
Select Case frm.ShowDialog()
Case DialogResult.Cancel
Exit Select
Case DialogResult.OK
lblParkBilgi.BackColor = frm.ArabaColor
lblParkBilgi.ForeColor = frm.ArabaColor
txtAraba.Text = frm.GetBilgi
txtAraba.Tag = frm.GetArabaID
Exit Select
End Select
End If
End If
End Sub
Private Sub MyDataGrid_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles MyDataGrid.CellFormatting
If MyDataGrid.Columns(e.ColumnIndex).Name = "ParkIslem" Then
Dim HucreStili As New DataGridViewCellStyle()
If (e.Value.ToString = "Giriş") Then
HucreStili.BackColor = Color.Blue
HucreStili.ForeColor = Color.White
HucreStili.SelectionBackColor = Color.Blue
HucreStili.SelectionForeColor = Color.White
Else
HucreStili.BackColor = Color.Red
HucreStili.ForeColor = Color.White
HucreStili.SelectionBackColor = Color.Red
HucreStili.SelectionForeColor = Color.White
End If
MyDataGrid.Rows(e.RowIndex).Cells("ParkIslem").Style = HucreStili
End If
End Sub
Private Sub btnCikisYap_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCikisYap.Click
If cmbOdemeDurum.Tag.ToString.Trim = "Bekleniyor" Then
Ortak.Mesaj("Lütfen otopark ücretini ödeme yapınız.!", "Ücret Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Return
End If
If Park.Guncelle(Ortak.ntoi32(MyDataGrid.CurrentRow.Cells("ParkID").Value), Ortak.ntodt(dpCikisTarih.Value), "Çıkış", cmbOdemeDurum.Text) > 0 Then
DataGetir()
Temizle()
Ortak.Mesaj("Park Güncelleme İşlemi Başarılı...", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information)
Else
Ortak.Mesaj("Lütfen bilgilerinizi kontrol edip tekrar deneyiniz!", "Uyarı", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End Sub
Private Sub btnCikisYapanlar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCikisYapanlar.Click
Dim Sorgu As String
Sorgu = "SELECT Park.*, Musteri.*, Araba.* FROM (Park INNER JOIN Musteri ON Park.MusteriID = Musteri.MusteriID) INNER JOIN Araba ON Park.ArabaID = Araba.ArabaID WHERE ((Park.ParkIslem='" + btnCikisYapanlar.Tag + "')) ORDER BY Park.ParkGirisTarih DESC"
Dim getData As New Kayit()
MyDataGrid.DataSource = getData.GetDataTable(CommandType.Text, Sorgu)
If btnCikisYapanlar.Tag = "Çıkış" Then
btnCikisYapanlar.Text = "Giriş Yapanları Getir"
btnCikisYapanlar.Tag = "Giriş"
Else
btnCikisYapanlar.Text = "Çıkış Yapanları Getir"
btnCikisYapanlar.Tag = "Çıkış"
End If
End Sub
End Class