private void BtnSil_Click(object sender, EventArgs e)
        {
            SqlCommand komutSil = new SqlCommand("delete from Ogrenci where OgrID=@k1", bgl.baglanti());

            komutSil.Parameters.AddWithValue("@k1", TxtOgrID.Text);
            komutSil.ExecuteNonQuery();
            bgl.baglanti().Close();
            TxtOgrID.Clear();
            TxtOgrAd.Clear();
            TxtOgrSoyad.Clear();
            MaskTC.Clear();
            maskOgrTelefon.Clear();
            maskOgrDogum.Clear();
            OgrBolum.ResetText();
            OgrMail.Clear();
            OgrOdaNo.ResetText();
            TxtVeliAdSoyad.Clear();
            maskVeliTelefon.Clear();
            RichAdres.Clear();
            MessageBox.Show("Kayıt silindi");



            SqlCommand komutOda = new SqlCommand("update Odalar set OdaAktif=OdaAktif-1 where OdaNo=@oda1", bgl.baglanti());

            komutOda.Parameters.AddWithValue("@oda1", OgrOdaNo.Text);
            komutOda.ExecuteNonQuery();
            bgl.baglanti().Close();
        }
示例#2
0
 void temizle()
 {
     TxtOgrAd.Clear();
     TxtOgrSoyad.Clear();
     MskTC.Clear();
     MskOgrTelefon.Clear();
     MskDogum.Clear();
     CmbBolum.Text = "";
     TxtMail.Clear();
     CmbOdaNo.Text = "";
     TxtVeliAdSoyad.Clear();
     MskVeliTelefon.Clear();
     RchAdres.Clear();
 }
 private void btnTemizle_Click(object sender, EventArgs e)
 {
     TxtOgrAd.Clear();
     TxtOgrAd.Clear();
     TxtOgrSoyad.Clear();
     MsdTC.Clear();
     MskOgrTelefon.Clear();
     MskDogum.Clear();
     CmbBolum.Text = "";
     TxtMail.Clear();
     CmbOdaNo.Text = "";
     TxtVeliAdSoyad.Clear();
     MskVeliTelefon.Clear();
     RchAdres.Clear();
     TxtOgrAd.Focus();
 }
        private void BtnKaydet_Click(object sender, EventArgs e)
        {
            try
            {
                SqlCommand Kaydet = new SqlCommand("insert into Ogrenci (OgrAd,OgrSoyad,OgrTC,OgrTelefon,OgrDogum,OgrBolum,OgrMail,OgrOdaNo,OgrVeliAdSoyad,OgrVeliTelefon,OgrVeliAdres) values (@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10,@p11)", bgl.baglanti());
                Kaydet.Parameters.AddWithValue("@p1", TxtOgrAd.Text);
                Kaydet.Parameters.AddWithValue("@p2", TxtOgrSoyad.Text);
                Kaydet.Parameters.AddWithValue("@p3", MaskTC.Text);
                Kaydet.Parameters.AddWithValue("@p4", maskOgrTelefon.Text);
                Kaydet.Parameters.AddWithValue("@p5", maskOgrDogum.Text);
                Kaydet.Parameters.AddWithValue("@p6", OgrBolum.Text);
                Kaydet.Parameters.AddWithValue("@p7", OgrMail.Text);
                Kaydet.Parameters.AddWithValue("@p8", OgrOdaNo.Text);
                Kaydet.Parameters.AddWithValue("@p9", TxtVeliAdSoyad.Text);
                Kaydet.Parameters.AddWithValue("@p10", maskVeliTelefon.Text);
                Kaydet.Parameters.AddWithValue("@p11", RichAdres.Text);
                if (String.IsNullOrEmpty(TxtOgrAd.Text) && String.IsNullOrEmpty(TxtOgrSoyad.Text) && String.IsNullOrEmpty(MaskTC.Text) && String.IsNullOrEmpty(OgrBolum.Text) && String.IsNullOrEmpty(OgrMail.Text) && String.IsNullOrEmpty(OgrOdaNo.Text) && String.IsNullOrEmpty(TxtVeliAdSoyad.Text) && String.IsNullOrEmpty(RichAdres.Text))   //Masked formlarda hata araştır
                {
                    MessageBox.Show("Boş Alan Bırakmayınız");
                }
                else
                {
                    Kaydet.ExecuteNonQuery();
                    bgl.baglanti().Close();
                    MessageBox.Show("İşlem Başarılı!");
                    TxtOgrAd.Clear();
                    TxtOgrSoyad.Clear();
                    MaskTC.Clear();
                    maskOgrTelefon.Clear();
                    maskOgrDogum.Clear();
                    OgrBolum.ResetText();
                    OgrMail.Clear();
                    OgrOdaNo.ResetText();
                    TxtVeliAdSoyad.Clear();
                    maskVeliTelefon.Clear();
                    RichAdres.Clear();
                }



                //ÖğrID labele atama
                SqlCommand    komut = new SqlCommand("select OgrID from Ogrenci", bgl.baglanti());
                SqlDataReader oku   = komut.ExecuteReader();
                while (oku.Read())
                {
                    label6.Text = oku[0].ToString();
                }
                bgl.baglanti().Close();


                //Öğrenci Borç Alanı Oluşturma
                SqlCommand komutkaydet2 = new SqlCommand("insert into Borclar (OgrID,OgrAd,OgrSoyad) values (@b1,@b2,@b3)", bgl.baglanti());
                komutkaydet2.Parameters.AddWithValue("@b1", label6.Text);
                komutkaydet2.Parameters.AddWithValue("@b2", TxtOgrAd.Text);
                komutkaydet2.Parameters.AddWithValue("@b3", TxtOgrSoyad.Text);
                komutkaydet2.ExecuteNonQuery();
                bgl.baglanti().Close();
            }
            catch (Exception)
            {
                MessageBox.Show("ERROR!");
            }

            SqlCommand komutOda = new SqlCommand("update Odalar set OdaAktif=OdaAktif+1 where OdaNo=@oda1", bgl.baglanti());

            komutOda.Parameters.AddWithValue("@oda1", OgrOdaNo.Text);
            komutOda.ExecuteNonQuery();
            bgl.baglanti().Close();



            //FrmAnaForm fr = new FrmAnaForm();
            //fr.Refresh();
        }