예제 #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (txtOgrenciNo.Text == "" || txtOgrenciNot.Text == "")
            {
                MessageBox.Show("Alanları Doldurun");
            }
            else
            {
                string           yol      = "Data source = DB.db";
                SQLiteConnection baglanti = new SQLiteConnection(yol);
                baglanti.Open();
                try
                {
                    string        sql        = "insert into ogrenciler(OgrenciNo,OgrenciNot) values (@OgrenciNo,@OgrenciNot)";
                    SQLiteCommand komutislet = new SQLiteCommand(sql, baglanti);

                    komutislet.Parameters.AddWithValue("@OgrenciNo", txtOgrenciNo.Text);
                    komutislet.Parameters.AddWithValue("@OgrenciNot", txtOgrenciNot.Text);
                    komutislet.ExecuteNonQuery();
                    baglanti.Dispose();
                    MessageBox.Show("kayıt yapıldı ");
                    DBislemci.GridDoldur(dataGrid1);
                    txtOgrenciNo.Text  = "";
                    txtOgrenciNot.Text = "";
                }
                catch (Exception ee)
                {
                    MessageBox.Show("AYNI NUMARADAN OLABİLİR DEĞİŞTİRİN \n\n " + ee.ToString());
                }
                finally
                {
                    baglanti.Dispose();
                }
            }
        }
예제 #2
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            if (txtOgrenciNo.Text == "")
            {
                MessageBox.Show("Öğrenci No Giriniz ");
            }
            else
            {
                if (MessageBox.Show("Silinsin Mi ?", "Soru", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                {
                    // hiçbir şey yapma
                }
                else
                {
                    // evet şeyler yap

                    string           yol      = "Data source = DB.db";
                    SQLiteConnection baglanti = new SQLiteConnection(yol);
                    baglanti.Open();
                    try
                    {
                        string        sql        = "delete from ogrenciler where OgrenciNo=" + txtOgrenciNo.Text + "";
                        SQLiteCommand komutislet = new SQLiteCommand(sql, baglanti);
                        komutislet.ExecuteNonQuery();
                        baglanti.Close();
                        MessageBox.Show("Silindi");
                        DBislemci.GridDoldur(dataGrid1);
                        txtOgrenciNo.Text  = "";
                        txtOgrenciNot.Text = "";
                    }
                    catch (Exception ee)
                    {
                        MessageBox.Show("Hata Alanları Kotrol Edin " + ee.ToString());
                    }
                    finally
                    {
                        baglanti.Dispose();
                    }
                }
            }
        }
예제 #3
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     DBislemci.GridDoldur(dataGrid1);
 }