C#’da Detaylı Ürün Ekleme Programı ve Onunla Birlikte Kullanılan XAML Kodlamaları

3 Kas

C#’da Detaylı Ürün Ekleme Programı ve Onunla Birlikte Kullanılan XAML Kodlamaları

Herkese Merhaba arkadaşlar, sizlere son dönem final sınavıma çalıştığım uygulamayı paylaşmak istedim. Büyük bir oranda işinize yaracağını umuyorum. Bize sorulan soru aşağıdaki şekilde. Bu uygulama sayesinde, C#’da Ürün ekleme kaldırma, silme güncelleme gibi işlemleri Veri Tabanına kayıt ederek rahatlıkla yapabilirsiniz.

  1. Aşağıdaki XAML uygulamasını oluşturunuz.
    Veri tabanında üyeler isimli tabloya kullanıcı adı ve şifre girildiğinde(Form 1) ikinci formdaki ürün bilgileri tablosu görüntülenmektedir. Kullanıcı adı ve şifre şifrelenmektedir.
    Form 2 ‘de ürün, fiyat ve adet seçildiğinde Ödeme Tutarı ile, müşteri ve ürün bilgilerini içeren fatura düzenlenmektedir(Fatura.txt).
    Not: Proje ayrıntılarını kendiniz belirleyiniz. Örneğin; Üye kayıt formu, ürün kayıt formu projenizde olabilir ya da veri tabanında daha önceden girdiğiniz üye ve ürün bilgilerini kullanabilirsiniz.

Üyeler Tablosu:
ID
Kullanıcı Adı
E-Mail
İsim
Adres
Ürünler Tablosu:
ID
Ürün Adı
Adet
Fiyat
KDV

Öncelikle sizlere Kayit.XAML kodlarını veriyorum.

</pre>
<pre>&lt;Window x:Class=&quot;GorselProgramlama_FinalProject.Kayit&quot; xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; Title=&quot;Kayit&quot; Height=&quot;377&quot; Width=&quot;469&quot;&gt; &lt;Grid&gt; &lt;Label Content=&quot;Kullanıcı Adı :&quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;97,50,0,0&quot; Name=&quot;label1&quot; VerticalAlignment=&quot;Top&quot; /&gt; &lt;TextBox Height=&quot;23&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,54,75,0&quot; Name=&quot;txtKadi&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;180&quot; /&gt; &lt;Label Content=&quot;Şifre :&quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;97,79,0,0&quot; Name=&quot;label2&quot; VerticalAlignment=&quot;Top&quot; /&gt; &lt;Label Content=&quot;Şifre Tekrarı :&quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;97,108,0,0&quot; Name=&quot;label3&quot; VerticalAlignment=&quot;Top&quot; /&gt; &lt;Label Content=&quot;Ad Soyad :&quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;97,137,0,0&quot; Name=&quot;label4&quot; VerticalAlignment=&quot;Top&quot; /&gt; &lt;TextBox Height=&quot;23&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,141,75,0&quot; Name=&quot;txtAdSoyad&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;180&quot; /&gt; &lt;Label Content=&quot;Mail Adresi :&quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;97,166,0,0&quot; Name=&quot;label5&quot; VerticalAlignment=&quot;Top&quot; /&gt; &lt;TextBox Height=&quot;23&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,170,75,0&quot; Name=&quot;txtMail&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;180&quot; /&gt; &lt;Label Content=&quot;Adres :&quot; Height=&quot;28&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;97,195,0,0&quot; Name=&quot;label6&quot; VerticalAlignment=&quot;Top&quot; /&gt; &lt;Button Content=&quot;Kaydol&quot; Height=&quot;23&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,261,75,0&quot; Name=&quot;btnKayit&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;122&quot; Click=&quot;btnKayit_Click&quot; /&gt; &lt;Button Content=&quot;Geri&quot; Height=&quot;23&quot; Margin=&quot;97,261,0,0&quot; Name=&quot;btnGeri&quot; VerticalAlignment=&quot;Top&quot; HorizontalAlignment=&quot;Left&quot; Width=&quot;127&quot; Click=&quot;btnGeri_Click&quot; /&gt; &lt;TextBox Height=&quot;23&quot; HorizontalAlignment=&quot;Right&quot; Margin=&quot;0,200,75,0&quot; Name=&quot;txtAdres&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;180&quot; /&gt; &lt;PasswordBox Height=&quot;23&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;192,84,0,0&quot; Name=&quot;pbSifre&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;180&quot; /&gt; &lt;PasswordBox Height=&quot;23&quot; HorizontalAlignment=&quot;Left&quot; Margin=&quot;192,113,0,0&quot; Name=&quot;pbSifreTekrari&quot; VerticalAlignment=&quot;Top&quot; Width=&quot;180&quot; /&gt; &lt;/Grid&gt; &lt;/Window&gt; 

Kayit.cs Kodlarını veriyorum

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace GorselProgramlama_FinalProject
{
    /// &amp;lt;summary&amp;gt;
    /// Interaction logic for Kayit.xaml
    /// &amp;lt;/summary&amp;gt;
    public partial class Kayit : Window
    {
        private SqlConnection con;
        public Kayit()
        {
            InitializeComponent();
            con = new SqlConnection(@&amp;quot;Data Source=localhost;Initial Catalog=UrunDB;Integrated Security=True&amp;quot;);
        }

        private void btnGeri_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void btnKayit_Click(object sender, RoutedEventArgs e)
        {
            if (txtKadi.Text != &amp;quot;&amp;quot; &amp;amp;&amp;amp; pbSifre.Password != &amp;quot;&amp;quot; &amp;amp;&amp;amp; pbSifreTekrari.Password != &amp;quot;&amp;quot; &amp;amp;&amp;amp; txtAdSoyad.Text != &amp;quot;&amp;quot; &amp;amp;&amp;amp;
                txtAdres.Text != &amp;quot;&amp;quot;)
            {
                if (pbSifre.Password == pbSifreTekrari.Password)
                {
                    MD5CryptoServiceProvider md5_nesne = new MD5CryptoServiceProvider();
                    char[] kar_dizi = txtKadi.Text.ToCharArray();
                    int uzunluk = kar_dizi.Length;
                    byte[] byte_dizi_kullanici = new byte[uzunluk];
                    for (int i = 0; i &amp;lt; uzunluk; i++)
                    {
                        byte_dizi_kullanici[i] = (byte) kar_dizi[i];
                    }
                    UnicodeEncoding uni_nesne = new UnicodeEncoding();
                    byte[] byte_dizi_parola = uni_nesne.GetBytes(pbSifre.Password);
                    byte[] sifeli_kullanici = md5_nesne.ComputeHash(byte_dizi_kullanici);
                    byte[] sifeli_parola = md5_nesne.ComputeHash(byte_dizi_parola);
                    string kullanici_str = BitConverter.ToString(sifeli_kullanici);
                    string parola_str = BitConverter.ToString(sifeli_parola);
                    try
                    {
                        SqlCommand com = new SqlCommand();
                        com.CommandText = String.Format(@&amp;quot;insert into uyeler (KullaniciAdi,Sifre,AdSoyad,Mail,Adres) values ('{0}','{1}','{2}','{3}','{4}')&amp;quot;,
                            kullanici_str, parola_str, txtAdSoyad.Text, txtMail.Text, txtAdres.Text);
                        com.Connection = con;
                        con.Open();
                        com.ExecuteNonQuery();
                        con.Close();
                        MessageBox.Show(&amp;quot;Kayıt İşlemi Tamamlandı.&amp;quot;, &amp;quot;BİLGİLENDİRME&amp;quot;, MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    catch
                    {
                        MessageBox.Show(&amp;quot;Kayıt İşlemi Sırasında Bir Hata Oluştu.\nLütfen Daha Sonra Tekrar Deneyiniz !&amp;quot;, &amp;quot;HATA&amp;quot;, MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else MessageBox.Show(&amp;quot;Şifre Tekrarı Hatalı&amp;quot;, &amp;quot;HATA&amp;quot;, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else MessageBox.Show(&amp;quot;Boş Alan Bırakmayınız&amp;quot;, &amp;quot;HATA&amp;quot;, MessageBoxButton.OK, MessageBoxImage.Error);
        }
    }
}

Urunler.XAML

&amp;lt;Window x:Class=&amp;quot;GorselProgramlama_FinalProject.Urunler&amp;quot;
        xmlns=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;
        xmlns:x=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;
        Title=&amp;quot;Urunler&amp;quot; Height=&amp;quot;241&amp;quot; Width=&amp;quot;412&amp;quot; Loaded=&amp;quot;Window_Loaded&amp;quot;&amp;gt;
    &amp;lt;Grid&amp;gt;
        &amp;lt;ComboBox Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;178,47,0,0&amp;quot; Name=&amp;quot;cbUrunAdi&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;120&amp;quot; /&amp;gt;
        &amp;lt;TextBox Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;178,83,0,0&amp;quot; Name=&amp;quot;txtAdet&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;120&amp;quot; /&amp;gt;
        &amp;lt;Label Content=&amp;quot;Urun Adi :&amp;quot; Height=&amp;quot;28&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;88,47,0,0&amp;quot; Name=&amp;quot;label1&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; /&amp;gt;
        &amp;lt;Label Content=&amp;quot;Urun Adet :&amp;quot; Height=&amp;quot;28&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;88,79,0,0&amp;quot; Name=&amp;quot;label2&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; /&amp;gt;
        &amp;lt;Button Content=&amp;quot;Kaydet&amp;quot; Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;201,125,0,0&amp;quot; Name=&amp;quot;btnOdeme&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;97&amp;quot; Click=&amp;quot;btnOdeme_Click&amp;quot; /&amp;gt;
        &amp;lt;Button Content=&amp;quot;Urun Ekle&amp;quot; Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;88,125,0,0&amp;quot; Name=&amp;quot;btnUrunEkle&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;94&amp;quot; Click=&amp;quot;btnUrunEkle_Click&amp;quot; /&amp;gt;
    &amp;lt;/Grid&amp;gt;
&amp;lt;/Window&amp;gt;

Urunsler.cs

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace GorselProgramlama_FinalProject
{
    /// &amp;lt;summary&amp;gt;
    /// Interaction logic for Form2.xaml
    /// &amp;lt;/summary&amp;gt;
    public partial class Urunler : Window
    {
        private SqlConnection con;
        private string AdSoyad;
        public Urunler(string AdSoyad)
        {
            this.AdSoyad = AdSoyad;
            con = new SqlConnection(@&amp;quot;Data Source=localhost;Initial Catalog=UrunDB;Integrated Security=True&amp;quot;);
            InitializeComponent();
        }

        private void btnUrunEkle_Click(object sender, RoutedEventArgs e)
        {
            UrunEkle ue = new UrunEkle();
            ue.Show();
        }

        private void btnOdeme_Click(object sender, RoutedEventArgs e)
        {
            if (cbUrunAdi.SelectedItem != &amp;quot;Urun Seç&amp;quot; &amp;amp;&amp;amp; txtAdet.Text != &amp;quot;&amp;quot;)
            {
                con.Open();
                string selectSorgusu = String.Format(&amp;quot;Select * from urunler where UrunAdi='&amp;quot; + cbUrunAdi.SelectedItem + &amp;quot;'&amp;quot;);
                SqlDataAdapter sorgu = new SqlDataAdapter(selectSorgusu, con);
                DataTable urun = new DataTable();
                sorgu.Fill(urun);
                if (int.Parse(urun.Rows[0][&amp;quot;Adet&amp;quot;].ToString()) &amp;gt;= int.Parse(txtAdet.Text))
                {
                    try
                    {
                        SqlCommand com = new SqlCommand();
                        com.CommandText = &amp;quot;update urunler set Adet=&amp;quot; + (int.Parse(urun.Rows[0][&amp;quot;Adet&amp;quot;].ToString()) - int.Parse(txtAdet.Text)) + &amp;quot; where ID=&amp;quot; + int.Parse(urun.Rows[0][&amp;quot;ID&amp;quot;].ToString());
                        com.Connection = con;
                        com.ExecuteNonQuery();
                        int adet = int.Parse(txtAdet.Text);
                        double fiyat = double.Parse(urun.Rows[0][&amp;quot;Fiyat&amp;quot;].ToString());
                        double kdv = double.Parse(urun.Rows[0][&amp;quot;KDV&amp;quot;].ToString());
                        double tutar = (adet*fiyat) + ((adet*fiyat)*(kdv/100));
                        FileStream fs = new FileStream(&amp;quot;fatura.txt&amp;quot;, FileMode.Append);
                        StreamWriter sw = new StreamWriter(fs);
                        sw.WriteLine(&amp;quot;Adi Soyadi : &amp;quot; + AdSoyad);
                        sw.WriteLine(&amp;quot;Urun Adi : &amp;quot; + cbUrunAdi.SelectedItem);
                        sw.WriteLine(&amp;quot;Adedi : &amp;quot; + adet);
                        sw.WriteLine(&amp;quot;Fiyati : &amp;quot; + fiyat);
                        sw.WriteLine(&amp;quot;KDV : &amp;quot; + kdv);
                        sw.WriteLine(&amp;quot;Odeme Tutari : &amp;quot; + tutar);
                        sw.WriteLine(&amp;quot;---------------------&amp;quot;);
                        sw.WriteLine();
                        sw.Flush();
                        sw.Close();
                        fs.Close(); 
                        MessageBox.Show(&amp;quot;Odeme işlemi başarılı !&amp;quot;, &amp;quot;BİLGİLENDİRME&amp;quot;, MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    catch
                    {
                        MessageBox.Show(&amp;quot;Bir Hata Oluştu&amp;quot;, &amp;quot;HATA&amp;quot;, MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
                else MessageBox.Show(&amp;quot;Seçilen Ürün İçin Stok Bulunamadı.\nVarolan Stok :&amp;quot; + urun.Rows[0][&amp;quot;Adet&amp;quot;], &amp;quot;HATA&amp;quot;, MessageBoxButton.OK, MessageBoxImage.Error);
                con.Close();
            }
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            con.Open();
            string selectSorgusu = String.Format(&amp;quot;Select * from urunler&amp;quot;);
            SqlDataAdapter sorgu = new SqlDataAdapter(selectSorgusu, con);
            DataTable urun = new DataTable();
            cbUrunAdi.Items.Clear();
            cbUrunAdi.Items.Add(&amp;quot;Urun Seç&amp;quot;);
            cbUrunAdi.SelectedIndex = 0;
            sorgu.Fill(urun);
            if (urun.Rows.Count != 0)
                for (int i = 0; i &amp;lt; urun.Rows.Count; i++)
                    cbUrunAdi.Items.Add(urun.Rows[i][&amp;quot;UrunAdi&amp;quot;].ToString());
            con.Close();
        }
    }
}

urunekle.xaml

&amp;lt;Window x:Class=&amp;quot;GorselProgramlama_FinalProject.UrunEkle&amp;quot;
        xmlns=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;
        xmlns:x=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;
        Title=&amp;quot;UrunEkle&amp;quot; Height=&amp;quot;332&amp;quot; Width=&amp;quot;528&amp;quot;&amp;gt;
    &amp;lt;Grid&amp;gt;
        &amp;lt;Label Content=&amp;quot;Urun Adı :&amp;quot; Height=&amp;quot;28&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;133,65,0,0&amp;quot; Name=&amp;quot;label1&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; /&amp;gt;
        &amp;lt;TextBox Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Right&amp;quot; Margin=&amp;quot;0,69,98,0&amp;quot; Name=&amp;quot;txtUrunAdi&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;180&amp;quot; /&amp;gt;
        &amp;lt;Label Content=&amp;quot;Adet :&amp;quot; Height=&amp;quot;28&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;133,94,0,0&amp;quot; Name=&amp;quot;label4&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; /&amp;gt;
        &amp;lt;TextBox Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Right&amp;quot; Margin=&amp;quot;0,98,98,0&amp;quot; Name=&amp;quot;txtAdet&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;180&amp;quot; /&amp;gt;
        &amp;lt;Label Content=&amp;quot;Fiyat :&amp;quot; Height=&amp;quot;28&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;133,123,0,0&amp;quot; Name=&amp;quot;label5&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; /&amp;gt;
        &amp;lt;TextBox Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Right&amp;quot; Margin=&amp;quot;0,127,98,0&amp;quot; Name=&amp;quot;txtFiyat&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;180&amp;quot; /&amp;gt;
        &amp;lt;Label Content=&amp;quot;KDV :&amp;quot; Height=&amp;quot;28&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;133,152,0,0&amp;quot; Name=&amp;quot;label6&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; /&amp;gt;
        &amp;lt;Button Content=&amp;quot;Ekle&amp;quot; Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Right&amp;quot; Margin=&amp;quot;0,208,98,0&amp;quot; Name=&amp;quot;btnEkle&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;122&amp;quot; Click=&amp;quot;btnEkle_Click&amp;quot; /&amp;gt;
        &amp;lt;Button Content=&amp;quot;Geri&amp;quot; Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;133,208,0,0&amp;quot; Name=&amp;quot;btnGeri&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;127&amp;quot; Click=&amp;quot;btnGeri_Click&amp;quot; /&amp;gt;
        &amp;lt;TextBox Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Right&amp;quot; Margin=&amp;quot;0,157,98,0&amp;quot; Name=&amp;quot;txtKDV&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;180&amp;quot; /&amp;gt;
    &amp;lt;/Grid&amp;gt;
&amp;lt;/Window&amp;gt;

UrunEkle.cs

using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace GorselProgramlama_FinalProject
{
    /// &amp;lt;summary&amp;gt;
    /// Interaction logic for UrunEkle.xaml
    /// &amp;lt;/summary&amp;gt;
    public partial class UrunEkle : Window
    {
        private SqlConnection con;
        public UrunEkle()
        {
            con = new SqlConnection(@&amp;quot;Data Source=localhost;Initial Catalog=UrunDB;Integrated Security=True&amp;quot;);
            InitializeComponent();
        }

        private void btnGeri_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void btnEkle_Click(object sender, RoutedEventArgs e)
        {
            if (txtUrunAdi.Text != &amp;quot;&amp;quot; &amp;amp;&amp;amp; txtAdet.Text != &amp;quot;&amp;quot; &amp;amp;&amp;amp; txtFiyat.Text != &amp;quot;&amp;quot; &amp;amp;&amp;amp; txtKDV.Text != &amp;quot;&amp;quot;)
            {
                try
                {
                    SqlCommand com = new SqlCommand();
                    com.CommandText = String.Format(@&amp;quot;insert into urunler (UrunAdi,Adet,Fiyat,KDV) values ('{0}',{1},{2},{3})&amp;quot;,
                        txtUrunAdi.Text, int.Parse(txtAdet.Text), float.Parse(txtFiyat.Text), float.Parse(txtKDV.Text));
                    com.Connection = con;
                    con.Open();
                    com.ExecuteNonQuery();
                    con.Close();
                    MessageBox.Show(&amp;quot;Urun Ekleme İşlemi Başarılı.&amp;quot;, &amp;quot;BİLGİLENDİRME&amp;quot;, MessageBoxButton.OK, MessageBoxImage.Information);
                }
                catch
                {
                    MessageBox.Show(&amp;quot;Ekleme Sırasında Bir Hata Oluştu.\nLütfen Sayısal Değerleri Kontrol Ediniz !&amp;quot;, &amp;quot;HATA&amp;quot;, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            else MessageBox.Show(&amp;quot;Boş Alan Bırakmayınız&amp;quot;, &amp;quot;HATA&amp;quot;, MessageBoxButton.OK, MessageBoxImage.Error);
        }
    }
}

MainWindow.xaml

&amp;lt;Window x:Class=&amp;quot;GorselProgramlama_FinalProject.MainWindow&amp;quot;
        xmlns=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;
        xmlns:x=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;
        Title=&amp;quot;MainWindow&amp;quot; Height=&amp;quot;232&amp;quot; Width=&amp;quot;521&amp;quot;&amp;gt;
    &amp;lt;Grid Height=&amp;quot;192&amp;quot; Width=&amp;quot;494&amp;quot;&amp;gt;
        &amp;lt;Button Content=&amp;quot;Giris&amp;quot; Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Right&amp;quot; Margin=&amp;quot;0,127,139,0&amp;quot; Name=&amp;quot;btnGiris&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;95&amp;quot; Click=&amp;quot;btnGiris_Click&amp;quot; /&amp;gt;
        &amp;lt;Label Content=&amp;quot;Kullanıcı Adı :&amp;quot; Height=&amp;quot;28&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;140,53,0,0&amp;quot; Name=&amp;quot;label1&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; /&amp;gt;
        &amp;lt;TextBox Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Right&amp;quot; Margin=&amp;quot;0,57,139,0&amp;quot; Name=&amp;quot;txtKadi&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;120&amp;quot; /&amp;gt;
        &amp;lt;Button Content=&amp;quot;Kayit&amp;quot; Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;146,127,0,0&amp;quot; Name=&amp;quot;btnKayit&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;95&amp;quot; Click=&amp;quot;btnKayit_Click&amp;quot; /&amp;gt;
        &amp;lt;Label Content=&amp;quot;Şifre :&amp;quot; Height=&amp;quot;28&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;140,87,0,0&amp;quot; Name=&amp;quot;label2&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; /&amp;gt;
        &amp;lt;PasswordBox Height=&amp;quot;23&amp;quot; HorizontalAlignment=&amp;quot;Left&amp;quot; Margin=&amp;quot;235,88,0,0&amp;quot; Name=&amp;quot;pbSifre&amp;quot; VerticalAlignment=&amp;quot;Top&amp;quot; Width=&amp;quot;120&amp;quot; /&amp;gt;
    &amp;lt;/Grid&amp;gt;
&amp;lt;/Window&amp;gt;

MainWindow.cs

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace GorselProgramlama_FinalProject
{
    /// &amp;lt;summary&amp;gt;
    /// Interaction logic for MainWindow.xaml
    /// &amp;lt;/summary&amp;gt;
    public partial class MainWindow : Window
    {
        private SqlConnection con;
        public MainWindow()
        {
            InitializeComponent();
            con = new SqlConnection(&amp;quot;Data Source=localhost;Initial Catalog=UrunDB;Integrated Security=True&amp;quot;);
        }

        private void btnGiris_Click(object sender, RoutedEventArgs e)
        {
            MD5CryptoServiceProvider md5_nesne = new MD5CryptoServiceProvider();
            char[] kar_dizi = txtKadi.Text.ToCharArray();
            int uzunluk = kar_dizi.Length;
            byte[] byte_dizi_kullanici = new byte[uzunluk];
            for (int i = 0; i &amp;lt; uzunluk; i++)
            {
                byte_dizi_kullanici[i] = (byte)kar_dizi[i];
            }
            UnicodeEncoding uni_nesne = new UnicodeEncoding();
            byte[] byte_dizi_parola = uni_nesne.GetBytes(pbSifre.Password);
            byte[] sifeli_kullanici = md5_nesne.ComputeHash(byte_dizi_kullanici);
            byte[] sifeli_parola = md5_nesne.ComputeHash(byte_dizi_parola);
            string kullanici_str = BitConverter.ToString(sifeli_kullanici);
            string parola_str = BitConverter.ToString(sifeli_parola);
            con.Open();
            string selectSorgusu = String.Format(&amp;quot;Select * from uyeler where KullaniciAdi='&amp;quot; + kullanici_str + &amp;quot;' and Sifre='&amp;quot; + parola_str + &amp;quot;'&amp;quot;);
            SqlDataAdapter sorgu = new SqlDataAdapter(selectSorgusu, con);
            DataTable user = new DataTable();
            sorgu.Fill(user);
            if (user.Rows.Count!=0)
            {
                Urunler frm = new Urunler(user.Rows[0][&amp;quot;AdSoyad&amp;quot;].ToString());
                con.Close();
                frm.Show();
            }
            else
            {
                MessageBox.Show(&amp;quot;Hatalı Kullanıcı Adı veya Şifre&amp;quot;, &amp;quot;HATA&amp;quot;, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            con.Close();
        }

        private void btnKayit_Click(object sender, RoutedEventArgs e)
        {
            Kayit kyt=new Kayit();
            kyt.Show();
        }
    }
}

Veri tabanını indirmek için vermiş olduğum bağlantıya tıklamanız yeterli.

İnsanlık hali belki çalışmaya bilir bunun için sizlere bende olan ve sağlam hiç bir sorunu bulunmayan halini paylaşmak istiyorum. Sağlam halini indirmek için buraya tıklaya bilirsiniz. Teşekkür etmenize gerek yok, işinize yarasın yeter… 🙂

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir