IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası

IRCForumları - IRC ve mIRC Kullanıcılarının Buluşma Noktası (https://www.ircforumlari.net/)
-   C# (https://www.ircforumlari.net/c/)
-   -   C# İle Veritabanı Projesi (https://www.ircforumlari.net/c/537948-c-ile-veritabani-projesi.html)

aSi 21 Temmuz 2013 11:37

C# İle Veritabanı Projesi
 
C# dilinde yazılan bu programda uygulama klasöründe bulunan veritabanına (Microsoft Access) erişim sağlanmış ve bir proje geliştirilmeye çalışılmıştır. Yönetici şifresi "1" dir. Programda C# programlama dili üzerinden access veritabanı erişim, kayıt ekleme, kayıt arama, kayıt silme ve kayıt düzenleme gibi işlemler yapılmıştır.

Kod:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
 
namespace yazılım
{
    public partial class Form1 : Form
    {
        public Form2 f2;
        //public Form3 f3;
        OleDbConnection conn = new OleDbConnection("provider = Microsoft.Jet.OleDb.4.0; Data Source= stok.mdb");
        //Access baglantısı olusturur
   
        int column = 0;
        int row = 0;
        //int total = 0;
        //int row2 = 0;
        //int num3;
        //int num2;
        //int son;
     
     
        public Form1()
        {
         
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
         
            textBox1.Visible = false;
          // textBox2.Visible = false;
            groupBox3.Visible = false;
         
        }
 
 
     
 
   
 
     
 
        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            groupBox3.Visible = true;
            dataGridView1.Rows.Clear();
         
 
            row = 0;
 
            conn.Open();
            string sql;
            sql = "select * from personel2";
            OleDbCommand cmd = new OleDbCommand(sql, conn);
            OleDbDataReader mrdr;
            mrdr = cmd.ExecuteReader();
 
            while (mrdr.Read() == true)
            {
 
                dataGridView1.Rows.Add();
                dataGridView1[column++, row].Value = (string)mrdr["adi"];
                dataGridView1[column++, row].Value = (string)mrdr["soyadi"];
           
              //  dataGridView1[column++, row].Value = (mrdr["ceptel"]).ToString();
                //dataGridView1[column++, row].Value = (mrdr["evtel"]).ToString();
                //dataGridView1[column++, row].Value = (string)mrdr["email"];
              // dataGridView1[column++, row].Value = (string)mrdr["adres"];
                dataGridView1[column++, row].Value = (string)mrdr["cinsiyet"];
 
                row++;
                column = 0;
 
            }
 
            mrdr.Close();
            conn.Close();
 
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            Application.Exit();//uygulamayı kapatır.
 
        }
 
        private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            textBox1.Visible = true;
            //textBox2.Visible = false;
            groupBox3.Visible = false;
            textBox1.Focus();
        }
   
     
 
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                try
                {
                    int pass = int.Parse(textBox1.Text);
 
                    if (pass == 1)
                    {
                        string date3 = (monthCalendar1.SelectionStart.ToShortDateString());
                        f2 = new Form2(conn, date3);
                        f2.Show();
                        conn.Close();
 
                    }
                    else
                    {
                        MessageBox.Show("Doğru Şifreyi Giriniz");
                        textBox1.Text = "";
                    }
                }
                catch (Exception en)
                {
                    MessageBox.Show(en.Message);
                }
            }
            conn.Close();
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                //veri tabanındaki verileri okuma komutu
                OleDbCommand veri2 = new OleDbCommand("SELECT * FROM product ORDER BY pid", conn);
                OleDbDataReader oku = null;
                conn.Open();//baglanti acar
                oku = veri2.ExecuteReader();//veri aktarma komutu calisir
              // listView2.Items.Clear();//listview deki verileri temizler
                while (oku.Read())//veri tabanindaki verileri listview e yazdiran dongu
                {
                    ListViewItem urunItem = new ListViewItem(oku["pid"].ToString());
                    urunItem.SubItems.Add(oku["pname"].ToString());
                    urunItem.SubItems.Add(oku["pprice"].ToString());
                    urunItem.SubItems.Add(oku["psayi"].ToString());
 
 
 
                  //  listView2.Items.Add(urunItem);
                }
 
                conn.Close();//baglanti kapatir
            }
            catch
            {
                MessageBox.Show("Veri Tabaniyla Baglanti Kurulamadi.\nProgramin bulundugu dizinde kayit.mdb\ndosyasinin bulundugundan emin olun\nve programi tekrar baslatin");
            }
        }
 
        private void radioButton3_CheckedChanged_1(object sender, EventArgs e)
        {
            //textBox2.Visible = true;
            textBox1.Visible = false;
            groupBox3.Visible = false;
            //textBox2.Focus();
        }
 
        private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                try
                {
                  // int pass = int.Parse(textBox2.Text);
 
                    //if (pass == 1)
                    {
                        string date4 = (monthCalendar1.SelectionStart.ToShortDateString());
                        //f3 = new Form3(conn, date4);
                        //f3.Show();
                        conn.Close();
 
                    }
                    //else
                    {
                        MessageBox.Show("Doğru Şifreyi Giriniz");
                      // textBox2.Text = "";
                    }
                }
                catch (Exception en)
                {
                    MessageBox.Show(en.Message);
                }
            }
            conn.Close();
        }
 
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
 
        }
 
     
 
     
    }
}



Tüm Zamanlar GMT +3 Olarak Ayarlanmış. Şuanki Zaman: 06:45.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO
Copyright ©2004 - 2025 IRCForumlari.Net Sparhawk