29 Eylül 2016 Perşembe

9 Ağustos 2016 Salı

3 Haziran 2016 Cuma

C# Sözlük Yapımı Access Veri Tabanlı





Form1 Kodları:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace Tr_Ing_Sozluk
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        OleDbConnection baglanti = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Sozluk.accdb;");

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked && textBox1.Text != "")
            {
                Tr_Ing_Ara(textBox1.Text);
            }
            else if (radioButton2.Checked && textBox1.Text != "")
            {
                Ing_Tr_Ara(textBox1.Text);
            }
        }

        private void Tr_Ing_Ara(string kelime)
        {
            listBox1.Items.Clear();

            try
            {
                if (baglanti.State != ConnectionState.Open)
                    baglanti.Open();

                OleDbCommand komut = new OleDbCommand("Select * From Kelimeler Where Turkce Like '%"+kelime+"%'", baglanti);
                OleDbDataReader oku = komut.ExecuteReader();

                while (oku.Read())
                {
                    listBox1.Items.Add(oku["Ingilizce"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {

                if (baglanti.State != ConnectionState.Closed)
                    baglanti.Close();
            }
        }

        private void Ing_Tr_Ara(string kelime)
        {
            listBox1.Items.Clear();

            try
            {
                if (baglanti.State != ConnectionState.Open)
                    baglanti.Open();

                OleDbCommand komut = new OleDbCommand("Select * From Kelimeler Where Ingilizce Like '%" + kelime + "%'", baglanti);
                OleDbDataReader oku = komut.ExecuteReader();

                while (oku.Read())
                {
                    listBox1.Items.Add(oku["Turkce"].ToString());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {

                if (baglanti.State != ConnectionState.Closed)
                    baglanti.Close();
            }
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            label1.Text = "Kelime:";
            this.Text = "Sözlük Türkçe-İngilizce";
        }

        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            label1.Text = "Word:";
            this.Text = "Sözlük İngilizce-Türkçe";
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            KelimeEkle frm = new KelimeEkle();
            if (frm.ShowDialog() == DialogResult.OK)
            {
                if (frm.Tr == "" || frm.Ing == "")
                {
                    MessageBox.Show("Alanları Boş Geçmeyiniz!!!.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                try
                {
                    if (baglanti.State != ConnectionState.Open)
                        baglanti.Open();

                    OleDbCommand komut = new OleDbCommand("Insert Into Kelimeler (Turkce,Ingilizce) Values('" + frm.Tr + "','" + frm.Ing + "')", baglanti);
                    komut.ExecuteNonQuery();
                    MessageBox.Show("Kelimeler Eklendi.", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                finally
                {

                    if (baglanti.State != ConnectionState.Closed)
                        baglanti.Close();

                }

            }
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Made By Fikri KOCAOĞLAN","Hazırlayan",MessageBoxButtons.OK,MessageBoxIcon.Information);
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://csharp-uygulamalari.blogspot.com.tr/");
        }
    }
}

Form2 Kodları:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Tr_Ing_Sozluk
{
    public partial class KelimeEkle : Form
    {
        public KelimeEkle()
        {
            InitializeComponent();
        }

        public string Tr
        {
            get { return textBox1.Text; }
            set { textBox1.Text = value; }
        }

        public string Ing
        {
            get { return textBox2.Text; }
            set { textBox2.Text = value; }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }
    }

}



Veri Tabanı Görüntüsü:

Paylaş:

Popüler

Son

Kategoriler